Bounding Sphere/Box or Another Method for my Terrain

Started by
0 comments, last by Supernat02 18 years, 7 months ago
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 ..
Advertisement
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.
Chris ByersMicrosoft DirectX MVP - 2005

This topic is closed to new replies.

Advertisement