cinetec_tech Posted September 8, 2014 Share Posted September 8, 2014 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. Link to comment
cinetec_tech Posted September 9, 2014 Author Share Posted September 9, 2014 the reason i use object.getIntersection is that i could get the intersection triangle id. Link to comment
silent Posted September 9, 2014 Share Posted September 9, 2014 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: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
cinetec_tech Posted September 9, 2014 Author Share Posted September 9, 2014 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. Link to comment
silent Posted September 10, 2014 Share Posted September 10, 2014 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: Is editor enabled when you are trying to use getIntersection() method with dynamic mesh? If you quit from editor (editor_quit in console) getIntersection() will work correctly? After ObjectMeshDynamic creation methon updateBounds() called in update? 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: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
silent Posted September 10, 2014 Share Posted September 10, 2014 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: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
cinetec_tech Posted September 10, 2014 Author Share Posted September 10, 2014 thanks Silent! you are very helpful! Link to comment
Recommended Posts