Jump to content

[SOLVED] getIntersection doesn't work from objectmeshdynamic


photo

Recommended Posts

Posted

engine.editor.getIntersection works great for me.

but i found it's difficult to make the ObjectMeshDynamic.getIntersection work.

Vec3 p0, p1;
Unigine::getPlayerMouseDirection(p0,p1);
int ret[0];
int ddd=MeshEditNodes[0].getIntersection(p0,p1,0,ret);
log.message("DDD:%i \n",ddd);

MeshEditNodes[0] is a objectmeshdynamic object. if this function. it always return 0 from ddd.

if i use editor.getIntersection, it works.

Posted

the reason i use object.getIntersection is that i could get the intersection triangle  id.

Posted

Hi,

 

Just call updateBounds() method after ObjectMeshDynamic construction. This should help to get intersection work. Also, please make sure that you have a property (with intersection flag enabled) assigned to all mesh surfaces you want to have intersections with.

 

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted

hi silent:

   I tried put updateBounds after the create and also make sure the intersection property is checked for the surface.

  not still not detect any intersection. Could you make a test and see if it works?

 

code to create a plane

dynMesh = add_editor(Unigine::createPlane(1.0f,1.0f,1));
dynMesh.setWorldTransform(Mat4_identity);
dynMesh.setMaterial(material,"*");
dynMesh.setProperty(prop,"*");
dynMesh.setName("_NewPlane");
dynMesh.updateBounds();
and use the above code for intersection test in our loop.
thanks so much.
Posted

Hi,

 

We are trying to reproduce such behavior right now, so if you will give us more information about this issue it would be great:

  1. Is editor enabled when you are trying to use getIntersection() method with dynamic mesh?
  2. If you quit from editor (editor_quit in console) getIntersection() will work correctly?
  3. After ObjectMeshDynamic creation methon updateBounds() called in update?
  4. If you can provide actual test scene and further insttuctions for reproduction it would be great. We surely can find the reason of such behavior faster.

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted

Also, please, check the attached test scene. getIntersection() for ObjectMeshDynamic requires local p0, p1 coordinates, so it is necessary to modify getPlayerMouseDirection() function from utils.h (modified function included in test.cpp).

 

test_intersection.zip Does this sample working correctly?

 

In the next SDK update you will be able to get triangle index via engine.world.getIntersection() without modifying coordinates (p0, p1).

 

Thanks!

 

 

How to submit a good bug report
---
FTP server for test scenes and user uploads:

×
×
  • Create New...