首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 培训 数据库 书店 程序员
中国软件网
欢迎您:游客 | 登录 注册 帮助
  • 游戏公司面试题,80分求解 [已结贴,结贴人:ayyuk]
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • ayyuk
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    • 揭贴率:
    发表于:2008-08-23 00:44:38 楼主
    内容如题,自己做了一些,有些不知道对错,所以干脆拿上来大家一起讨论学习一下,跪谢各位了。各位解答时请注明是哪道题,8道题每题10分一共80分。对不起了,我新手没多少分,否则会重重答谢大家的!!
    我会把自己的答案也放上来供大家参考指正。
    再次感谢!!!
    1. Without using any standard library functions, write a function that accepts a string and toggles all of the individual letters within between upper and lower case – optimally. For example, if the input string were “Mixed Case!” the output would be “mIXED cASE!”

    To make sure the test doesn’t go astray please write the main() function to call your function and pass in your name as a parameter.

    // insert code here

    2. Consider the following code snippet:

    Note: You should not use a compiler to answer this question.

    class AbstractBase
    {
    public:
    AbstractBase()
    {
    m_pCharArray = new char[ 16 ];
    }

    ~AbstractBase()
    {
    delete m_pCharArray;
    }

    virtual void function( void ) = 0;

    private:
    char *m_pCharArray;
    };

    class Derived : public AbstractBase
    {
    public:
    Derived()
    {
    m_pDerivedArray = new char[ 16 ];
    }

    ~Derived()
    {
    delete m_pDerivedArray;
    }

    void function( void ) {};

    private:
    char *m_pDerivedArray;

    };

    AbstractBase* factory( void )
    {
    return new Derived;
    }

    int main(int argc, char* argv[])
    {
    AbstractBase* pObject;
    pObject = factory();
    delete pObject;

    return 0;
    }


    The main function calls a factory method that returns ‘a kind of’ Base.  In this case you can see that the factory method specifically returns a specialized Derived class which is intentional.

    a) What bugs are present in the code?  What problems are caused by this?
    b) How would you fix them?

    3. What sort of performance overhead is incurred when using const in C++ programs to create classes and member functions that are considered to be ‘const correct’?

    4.  Consider the following function that takes in a pointer to the header of a linked list as a parameter, calls an unknown library function and dumps the value stored in each node.

    struct sllist
    {
    int value;
    sllist* pNext;
    };

    // parameter pHeader, pointer to the head of a linked list structure for integers
    // the list is of unknown size and is terminated with lastnode->pNext == NULL
    void DumpList( sllist *pHeader )
    {
    DodgyFunction( pHeader ); // library function, no source available

    // iteration code 
    sllist *pCurrent = pHeader; // point to head of the list
    while( pCurrent->pNext != NULL ) // iteration loop
    {
    printf("%d\n", pCurrent->value );
    pCurrent = pCurrent->pNext; // go to the next value
    }
    printf("%d\n", pCurrent->value ); // print the value in the last node
    }


    When you execute DumpList() it appears that the program remains stuck in the iteration loop.  At the time of calling this function, you have determined that you have a valid linked list that is correctly terminated.

    a) What is DodgyFunction() doing?
    b) Without changing the sllist node structure or altering the iteration code, add code after the DodgyFunction() call to confirm your theory.  The code should be as optimal as possible.


    5. You are working on a title that is specified to run at 60 frames per second (60Hz), but is currently under-performing.  Running a profiling tool tells you how much time is used in an average frame by major systems:

    RenderSystem::update() - 10ms
    AISystem::update() - 20ms
    ScriptingSystem::update() - 1ms
    UserInputSystem::update() - 8ms
    UISystem::update() - 2ms
    PhysicsSystem::update() - 4ms

    Describe ways you could get the program to run at 60Hz based on this profiling data.

    6. You have an array of 4 32-bit integers which you use to store a 128-bit number.  Fill in the following functions for bitwise shifting operations.

    Note: You should not use a compiler to answer this question.

            uint32 storage[4];
            void ShiftLeft(int count)
            {
                    // code
            }
            bool ShiftRight(int count)
            {
                    // code
            }

    7.  Given a 3d scene, an object at point O, and the camera at point C, we wish to define the orientation of the camera so that it points at the object.  In the scene, UP is defined by the vector (0,1,0).

    Show the AT vector and RIGHT vector for the camera such that it faces the object. Show the math necessary to compute these vectors.

    Show the rotation matrix for the camera.


    8. The game you are working on involves a projectile colliding with a polygon and bouncing away from it at the correct angle.

    Vector v represents the direction that the projectile was traveling prior to the collision and ax + by + cz + d is the plane equation representing the surface it collided with.

    Explain how would you calculate the direction that the projectile should be traveling after the collision?  Summarize your answer in mathematical form.
    180  修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • ayyuk
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-08-23 01:24:551楼 得分:0
    不顾顺序,看到哪个先说哪个了:

    第八题:ax + by + cz + d 平面的法线应该是 n=(a,b,c), 已知入射方向是v, 将v映射在n上求出v在n方向的分量v1,用(v-v1)得出v在平面上的分量v2,反射方向则应该是:v2-v1
    对吧?

    好困TT,接下来的明天说:)
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • ayyuk
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-08-23 01:28:502楼 得分:0
    第五题尤为费解。。。请大家赐教!不盛感激!
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • argoran
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-08-23 04:04:393楼 得分:20
    关于第五题,不知道是否可以这样做:
    将渲染和AI从整个系统中分离出来,即将系统分成渲染,AI和"其他"这样三个部分,"其他部分"包括剩下的脚本,用户输入,UI及物理系统;
    然后使用多线程运行这三个部分,并保证"其他部分"达到每秒60帧的帧率,而渲染和AI则可以在较低的帧率下运行。

    题目的条件中给出的运行状况是每帧耗时45ms,而要求是每帧16ms,目前的状况几乎是要求的三倍。
    我的理解是,要让整个代码达到要求是不可能的,能做的只有让代码"看起来"达到要求。
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • zogna
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-08-23 08:38:424楼 得分:5
    1.字母变大小写。。。。初级题。。。。不说了。。。
    为什么都是英文。。。。。。
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • ayyuk
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-08-23 08:52:505楼 得分:0
    第五题:

    恩,谢谢Argoran了:-),我开始也是这样想的,可是觉得AI就算单拿出来也是每帧20ms高于每帧16ms达不到要求。。。。
    那么,如您所说如果AI在低帧率下运行的话会出现怎样的效果?avatar的行动比物理环境的更新迟缓?(高手请不要笑话我,飘~)

    还是非常感谢!


    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • ayyuk
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-08-23 09:03:056楼 得分:0
    zogna同学:
    我把原文直接粘过来的所以是英文。今年美国一游戏公司的原题,因为没有答案,就是想大家对哪题感兴趣就一起做做交流交流:-)。
    今天出去办事,晚上回来接着做^^
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • gamedragon
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-08-23 14:46:367楼 得分:20
    第5题,我的想法是AISystem可以几帧计算一次,UserInputSystem也可以几帧计算一次,这两个不需要毎帧计算的;RenderSystem和PhysicalSystem必须毎帧计算,没办法,这两个是省不出来的。
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • tb01070
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-08-23 16:46:008楼 得分:5
    有点难,不过高手应该很容易!
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • redeyerabbit
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-08-23 20:07:549楼 得分:5
    严重同意7楼的.
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • ayyuk
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-08-24 01:19:0210楼 得分:0
    关于第五题,gamedragon同学:

    为什么一般物理和渲染一定不能省,能说说不?大谢^^
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • gamedragon
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-08-24 09:40:1311楼 得分:10
    渲染就是体现帧速的东西,每秒多少帧就是渲染多少次,所以这个不能省。
    物理如果隔多帧渲染的话,渲染出来的物体可能看起来运动会有些不自然,至多隔一帧吧。而且在这道题里,物理并不算是瓶颈。
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • freedomzcd
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-08-25 15:10:3512楼 得分:10
    第一题用对应ASCII码计算???
    英文,不甚懂...
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • freedomzcd
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-08-25 15:28:5213楼 得分:20
    RenderSystem和PhysicsSystem是需要实时进行的.
    AISystem\ScriptingSystem\UISystem的运行频率可以比较低.
    UserInputSystem输入系统单独一个线程..

    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • herosoulyy
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-08-27 10:11:1114楼 得分:5
    我怎么觉得像是EA的题呢?
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • bbvs1
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-09-07 14:15:1615楼 得分:0
    反射光v'=v2+v1=(v+v1)+v1=v+2v1=v+2n|v1|/|n|,

    |v1|=|v|cos@=|v|(v*n)/(|n||v|)=v*n/|n|
    所以
    v'=v+2n(v*n)/(|n|^2)
    其中n=(a,b,c)
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • bbvs1
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-09-07 14:43:0516楼 得分:40
    7。

    Vat=Vo-Vc,单位化Vat'=Vat/|Vat|,
    Vright=Vup叉乘Vat/|Vat|,
    单位化Vright'=Vright/|Vright|,
    于是
    camera matrix is
    Vright'
    Vup
    Vat'
    Vc

    这样的话,transform的时候一定要inverse,就OK了

    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • ayyuk
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-09-07 19:08:5417楼 得分:0
    感谢大家的发言,好像自己积分上涨了,所以又给这帖子加了100分!真的好喜欢csdn。

    第七题:
    bbvs1同学,非常感谢你的回复。只是我觉得应该是Vleft=Vup叉乘Vat/|Vat| 然后Vright= -Vleft。
    还有,最后一句话能不能帮忙解释一下,什么叫transform的时候一定要inverse?关于camera matrix,我的认识非常粗浅,只知道每一行代表一个向量,不知道用的时候怎么inverse之类,还有camera matrix和题中所说的rotation matrix是一回事吗?。。万分感谢了!
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • bbvs1
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2008-09-08 22:37:4218楼 得分:40
    Vright= -Vleft,是的。inverse是因为我认为相机是在世界坐标建立的所以结果是:Mcamera*Mworld,
    而我们流水线是Mworld*Mview,所以要构造成这个就需要构造成这个形式,Mcamera*Mworld=Mworld*Mview,
    于是Mview=inverse(Mcamera),当然Mcamera要满足要存在逆阵的条件,这个只是我求Mview的方法而已。。
    我认为这个inverse(Mcamera)就是题中的rotation matrix
    修改 删除 举报 引用 回复

    网站简介广告服务网站地图帮助联系方式诚聘英才English 问题报告
    北京创新乐知广告有限公司 版权所有 京 ICP 证 070598 号
    世纪乐知(北京)网络技术有限公司 提供技术支持
    Copyright © 2000-2008, CSDN.NET, All Rights Reserved