terrain and textures

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
pesant19
Posts: 4
Joined: Thu Mar 19, 2015 7:03 pm

terrain and textures

Post by pesant19 »

I am doing a golf game and I made my golf course in blender. I want to change the bouncing and friction of my golf ball depending on the texture the ball hit. I want to know is there a tutorial show how to change the bounce and friction of each texture that are on my model. How do I get eah texture of the model and set the bouncing and friction of them.
exemple the ball stop when she hit the sand or on the rough the friction is much higher than the green. :?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: terrain and textures

Post by Norbo »

The texture/material lookup process could be implemented as a set of AABBs with custom material properties, searched using the golf ball's position. Or you could query the StaticMesh.Mesh.Tree using the golf ball's bounding sphere to collect the triangle indices that are nearby, and then use that to index a material list. Or compute the barycentric weights of the golf ball position projected onto the mesh surface, use that to compute the uv coordinates from vertex uv coordinates, and then use the result to do a texture lookup. Or other options- note that these aren't really fundamentally related to the physics engine.

This lookup process could be used by a delegate in the MaterialManager.MaterialInteractions for the golf ball material and golf course material, or you could just set the entity.Material property appropriately to work with the default multiplicative MaterialBlender (you'd probably want to set the mesh's material coefficients to all 1 in this case). However, high friction alone will not give you the behavior you want. A ball will still roll freely on a surface with extremely high friction. It sounds like what you want is actually something like rolling friction to simulate the effect of the golf ball hitting grass or pushing sand. Since that's not simulated by material friction, you would need implement the effect yourself after doing the lookup process. Doing something like setting the golfBallEntity.LinearDamping or AngularDamping to a higher value when on a surface with high rolling friction could simulate what you want.
Post Reply