首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络游戏 >

游戏公司面试题,80分求解,该如何解决

2012-04-17 
游戏公司面试题,80分求解内容如题,自己做了一些,有些不知道对错,所以干脆拿上来大家一起讨论学习一下,跪谢

游戏公司面试题,80分求解
内容如题,自己做了一些,有些不知道对错,所以干脆拿上来大家一起讨论学习一下,跪谢各位了。各位解答时请注明是哪道题,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.


[解决办法]
关于第五题,不知道是否可以这样做:
将渲染和AI从整个系统中分离出来,即将系统分成渲染,AI和"其他"这样三个部分,"其他部分"包括剩下的脚本,用户输入,UI及物理系统;
然后使用多线程运行这三个部分,并保证"其他部分"达到每秒60帧的帧率,而渲染和AI则可以在较低的帧率下运行。

题目的条件中给出的运行状况是每帧耗时45ms,而要求是每帧16ms,目前的状况几乎是要求的三倍。
我的理解是,要让整个代码达到要求是不可能的,能做的只有让代码"看起来"达到要求。
[解决办法]
1.字母变大小写。。。。初级题。。。。不说了。。。
为什么都是英文。。。。。。
[解决办法]
第5题,我的想法是AISystem可以几帧计算一次,UserInputSystem也可以几帧计算一次,这两个不需要毎帧计算的;RenderSystem和PhysicalSystem必须毎帧计算,没办法,这两个是省不出来的。
[解决办法]
有点难,不过高手应该很容易!
[解决办法]
严重同意7楼的.
[解决办法]
渲染就是体现帧速的东西,每秒多少帧就是渲染多少次,所以这个不能省。
物理如果隔多帧渲染的话,渲染出来的物体可能看起来运动会有些不自然,至多隔一帧吧。而且在这道题里,物理并不算是瓶颈。
[解决办法]
第一题用对应ASCII码计算???
英文,不甚懂...
[解决办法]
RenderSystem和PhysicsSystem是需要实时进行的.
AISystem\ScriptingSystem\UISystem的运行频率可以比较低.
UserInputSystem输入系统单独一个线程..


[解决办法]
我怎么觉得像是EA的题呢?
[解决办法]
7。

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

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


[解决办法]
Vright= -Vleft,是的。inverse是因为我认为相机是在世界坐标建立的所以结果是:Mcamera*Mworld,
而我们流水线是Mworld*Mview,所以要构造成这个就需要构造成这个形式,Mcamera*Mworld=Mworld*Mview,
于是Mview=inverse(Mcamera),当然Mcamera要满足要存在逆阵的条件,这个只是我求Mview的方法而已。。
我认为这个inverse(Mcamera)就是题中的rotation matrix

热点排行