Jump to content
  • Advertisement
Sign in to follow this  
VISQI

Camera movement technique

This topic is 2595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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???

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

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???

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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??

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!