Camera movement technique

Started by
9 comments, last by L. Spiro 12 years, 5 months ago
I am designing a 3D maze game, and want to let the camera(player) when it hit a wall. Simple as that

I tried making an AABB out of every wall and make a sphere-Box intersection test between the camera and the wall, but it was just too annoying to implement an AABB for EVERY wall in a maze and it didn't work.

How can something like that be made???
Advertisement
You weren't trying to build the collision boxes for your maze by hand while sitting in front of a nifty, magical little box that could handle those tedious computations for you in a fraction of the time, were you?

You weren't trying to build the collision boxes for your maze by hand while sitting in front of a nifty, magical little box that could handle those tedious computations for you in a fraction of the time, were you?


if by building collision boxes you mean going through every wall in the maze and building an AABB for it, then yes, that is exactly what i did :)

Is there any easier(better) way that can detect walls in a better manner???
What 3D library are you using to build your game?
It probably already have collision implemented for you to every model you load.
Programming is an art. Game programming is a masterpiece!

What 3D library are you using to build your game?
It probably already have collision implemented for you to every model you load.


D3D9. So basically, i just use the camera as a sphere, and do intersection tests with the wall's AABB, and based on it, i determine if i should use the new position or just use the one i am currently using??

Will it be something like this???


D3DXVECTOR3 Camera::GetRealPos(D3DXVECTOR3& p)
{
D3DXVECTOR3 RealPos = p;

for(std::list<AABB>::iterator iter = gField->GetBoxes().begin(); iter != gField->GetBoxes().end();
iter++)
{
if(Test_BS_AABB_SingleAxis(mCameraSphere, *iter, 0) )
RealPos.x = mPos.x;

if(Test_BS_AABB_SingleAxis(mCameraSphere, *iter, 2) )
RealPos.z = mPos.z;
}

RealPos = mCameraSphere.Center;
return RealPos;
}


mPos is the Current position.

p is the position that the user has just inputed through W,A,S,D.

As you can see, i am testing it for the xz axis. Any axis the collides with the walls is not used. instead i just reuse the current position of it for the xz axises.
bump
well that actually isnt that crazy, as long as your automatically generating the aabbs off the map array, not just hardcoding them.

aabbs are quick as, so you can do heaps and heaps of them.


What would be better (if its an axis aligned wolfenstien map, which is what this sounds like) is to just convert the player position to a map array index and just access if its filled or solid.
How exactly did you build your map? If you are drawing it , then you should know what a wall is. If it is one big map, then try splitting up all the walls and export each wall, instead of 1 3D model with tons of walls. This way when you load the wall, you can load each wall individually, you can put it in a "class Wall" that has the AABB data that you need (Get the min/max x,y,z I assume you already know how to do the AABB test it sounds like). Then loop through each wall.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

...


well that actually isnt that crazy, as long as your automatically generating the aabbs off the map array, not just hardcoding them.

aabbs are quick as, so you can do heaps and heaps of them.


What would be better (if its an axis aligned wolfenstien map, which is what this sounds like) is to just convert the player position to a map array index and just access if its filled or solid.


I really didn't get what do you mean?? filled or solid??
It is kinda of a Wolfenstein game. I basically drew each wall (about 30 walls) in a single mesh, and i manually create an AABB for each one. My BuildMap() function is scary :)


I got some good ideas from here. How about i just do a Wall class, and i make a list or a vector or all the walls, and then just do an intersection test each frame??

This topic is closed to new replies.

Advertisement