Sign in to follow this  
frankypoo

way to convert mesh to functions?

Recommended Posts

is there a way to convert a mesh into a math function? here's why this might be useful. I create a world in 3ds max, including terrain, buildings, trees, etc. I import that .x through directx, and I (theoretically) convert the entire mesh into a math function, y as a function of x and z. then using this function, I can perform terrain following by determining where the hero just moved (x and z coords) and plug those points into the function. The result will be his vertical position. I might even be able to do detection of collision with walls, hills to steep in the + and - y direction, etc by determining the rate of change for the function at that point in the direction the hero tries to move. so it would be very useful to create a function from a mesh. a potential problem (if it's even possible in the first place) is that a mesh with multiple z per x/y position isn't an actual function. For example, the character walks into a 4 story building... now his x/y points plugged into the function say his vertical position is 4-fold. This could be easily handled, and actually beneficial. For example, to coll'n detect if the ceiling is sloping too close to the hero's head for him to keep moving, i can use the closest z result above the hero's midpoint. If that z is less than half his height, he needs to duck. the closest z below his midpoint is then used for his vertical position.

Share this post


Link to post
Share on other sites
basically what you want is an heightmap of your scene.Maybe you could try to create a depthmap from a point at the center of your world but with an y-coord very high (this way you're sure you can see everything). Store the depth of every pixel then use this texture as a normal heightmap. I dunno if this works, but sounds cool :D

Share this post


Link to post
Share on other sites
Any surface can be represented implicitly or parametrically as a function, but the results aren't too pretty in general. An explicit representation, as you describe, with one coordinate expressed in terms of the others, will exist under exceptional circumstances (in particular, when the geometry can be projected injectively under some basis onto a plane), but the result is little more than a heightmap.
As convenient as it would seem to have an analytic ("mathematical", very roughly speaking) function, the road is dark and full of monsters.

Far more effective, efficient and maintanable solutions exist for collision detection, heightmaps being one of the simplest.

I recommend you have a look at some of the collision resources here on GameDev and on the rest of the web. Depending on your situation, there are many possible suitable methods, but if I were you, I'd leave this one in the can.

Regards
Admiral

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