Sign in to follow this  
k00k

Bounding Sphere/Box or Another Method for my Terrain

Recommended Posts

Guy's ive been working on this for awhile here and still yet a little bit new to doing things of this nature so please bear with me .. I have my terrain setup to read my bmp heightmap into my engine and im using 2 textures with alpha blending via a shader onto my terrain. all works fine with the terrain but now I want my player model to follow the terrain. So what i was thinking and after alot of reading is that I would need to create a Bounding Sphere or Box around the player model or around the terrain which is it? I would imagine I would do this around my player and my terrain so that I can do collision detection on the two but the player should always be touching the ground unless jumping around so im not sure how this all would work. I can handle doing the collision detection I have setup a few scenario's where I have 2 cubes they slide into each other from random distances and once they touch it fires off a message to the screen. just for practice. well thats bout all thanks for your responses ..

Share this post


Link to post
Share on other sites
You'll want the bounding box to be around your player. You'll need to modify your terrain engine so that you can request a height (y) value at any given x,z coordinate. Then you just move the player's feet to that location.

Example:

int NewHeight = MyTerrain->GetHeightValue(playerX, playerZ);
MovePlayerFeet(NewHeight);

It's a rather simple concept. The more difficult part is getting the y value of the terrain, because x & z are floats and they may be between two vertices. You'll have to interpolate between the vertices. How to do this part will vary depending on who you talk to.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this