Advertisement Jump to content
Sign in to follow this  

walk on terrain mesh

This topic is 1880 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

how to make the camera/character/model walk on terrain if it's not a heightmap but just a simple terrain mesh designed in 3d modeling software like 3ds max and blender.

Share this post

Link to post
Share on other sites

You can use NVIDIA PhysX, it has a character controller, it provides a capsule shape which will move around overtop of an arbitrary mesh (i.e. the ground terrain mesh you have), it will also slide against walls.

The terrain, in PhysX, would be constructed by reading out the triangles that comprise the terrain mesh and passing them into a PxTriangleMeshDesc then into cookTriangleMesh.

From there, you'd just position the capsule controller above the ground and drop it and use keyboard controls (WASD) to move it around (based on your characters forward direction).

Share this post

Link to post
Share on other sites

Figured out :

void WalkOnTerrain()

	D3DXVECTOR3 org = pos + D3DXVECTOR3(0.0f, 10.0f, 0.0f);
	D3DXVECTOR3 dir = D3DXVECTOR3(0.0f, -1.0f, 0.0f);

	BOOL Hit;
	DWORD FaceIndex;
	float Dist;


	if (Hit)
		Cam.SetPosition(&D3DXVECTOR3(pos.x, org.y - Dist, pos.z)); // = org.y - Dist;

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!