Skip to main content
GameDev.net gamedev.net
🔒 Locked

Camera movement technique

Started by VISQI Oct 28, 2011 at 1:10 PM 9 replies 2.2k views
Original Post
VISQI
VISQI
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???
VISQI
VISQI

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???
kuramayoko10
kuramayoko10
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!
VISQI
VISQI

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.
VISQI
VISQI
bump
rouncer
rouncer
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.
dpadam450
dpadam450
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 
VISQI
VISQI

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??
L. Spiro
L. Spiro
Make a few wall shapes, make (or generate; it can't be that hard) a few AABB's for them, and make mazes out of those.

Mappy can be used to tell you where walls are, and with your "wall" properties you will then know how to render and collide with each wall.

Yes I know Mappy is 2D, but it can be used to plot the floor layout, which is all you need for positioning 3D objects as long as the ground is always flat.


L. Spiro
I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.