Jump to content

questions about ObjectMesh's collision/intersection functions


photo

Recommended Posts

In ObjectMesh.h there are multiple functions for collision and intersection

   	// collision
  	 virtual int getCollision(const BoundBox &bb,Vector<int> &csurfaces);
  	 virtual int getCollision(const BoundSphere &bs,Vector<int> &csurfaces);
  	 virtual int getCollision(const BoundFrustum &bf,Vector<int> &csurfaces);
  	 virtual int getCollision(const vec3 &p0,const vec3 &p1,Vector<int> &csurfaces);

  	 // line intersections
  	 virtual int getIntersection(const vec3 &p0,const vec3 &p1,int surface);
  	 virtual int getIntersection(const vec3 &p0,const vec3 &p1,vec3 &ret_point,vec4 &ret_plane,int &ret_triangle,int surface);
  	 virtual int getIntersection(const vec3 &p0,const vec3 &p1,vec3 &ret_point,vec3 &ret_normal,vec4 &ret_texcoord,int surface);

  	 // random point
  	 virtual int getRandomPoint(vec3 &ret_point,vec3 &ret_normal,vec3 &ret_velocity,int surface);

 

but ObjectMeshDynamic only have those getIntersection functions, I'm still working on my speedtree plugin, all my speedtree objects use MeshDynamic, so even MeshDynamic don't have getCollision function, it still will collision with player. I'm confused, what's the purpose of these function? and why that every object need a function called getRandomPoint? what's the use of second and third getItersection function?

Link to comment

Collision functions are overloaded for ObjectMesh, because it can calculate collisions with its surfaces faster. The reason for that is it has a hierarchy inside (its own BSP tree for surfaces and polygons). All other objects use collision and intersection functions implemented in the base Object class.

 

getRandomPoint() is for generating particles across mesh surface, when Random emitter is used (check objects/particles_01 sample).

Link to comment

thanks for the explanation, seems it's not possible to implement all getIntersection function on a speedtree using its own collision system.

 

if I only implement this function on a speedtree mesh:

 

virtual int getIntersection(const vec3 &p0,const vec3 &p1,int surface);

 

will this mesh still can be collide with player or other objects? my test shows only this function can not be used for collision detection.

Link to comment

You can assign a body (BodyDummy) to an exported SpeedTree model, access capsule collision objects that SpeedTree provides and then create Unigine shapes (ShapeCapsule) based on that data. Effectively, that's what our export plugin does. The player as well as other physical objects will collide with a tree in this case.

Link to comment
×
×
  • Create New...