sergey.pozhidaev Posted October 8, 2013 Posted October 8, 2013 on ObjectMesh & ObjectDynamic objects getIntersection does not work, mask and setintersection flags = 1
frustum Posted October 8, 2013 Posted October 8, 2013 ObjectDynamic doesn't have intersection code. You have to provide invisible intersection mesh inside ObjectMesh.
sergey.pozhidaev Posted October 8, 2013 Author Posted October 8, 2013 i only want to create custom mesh with Unigine-pick system and modify it anytime ObjectMesh o = add_editor(new ObjectMesh(0)); o.addEmptySurface("surf0", 4, 6); o.setVertex(0,vec3(-1.5f,8,0),0); o.setVertex(1,vec3(-1.5f,1.5f,0),0); o.setVertex(2,vec3(-11,8,0),0); o.setVertex(3,vec3(-11,1.5f,0),0); o.setTexCoord(0,vec4(10,-6,0,0),0); o.setTexCoord(1,vec4(10,1,0,0),0); o.setTexCoord(2,vec4(0,-6,0,0),0); o.setTexCoord(3,vec4(0,1,0,0),0); o.setTangent(0,vec4(1,0,0.000015f,-1),0); o.setTangent(1,vec4(1,0,0.000015f,-1),0); o.setTangent(2,vec4(1,0,0.000015f,-1),0); o.setTangent(3,vec4(1,0,0.000015f,-1),0); vec3 norm = vec3(-0.000015f,-0.000015f,1); o.setNormal(0,norm,0); o.setNormal(1,norm,0); o.setNormal(2,norm,0); o.setNormal(3,norm,0); o.setIndex(0,2,0); o.setIndex(1,3,0); o.setIndex(2,0,0); o.setIndex(3,1,0); o.setIndex(4,0,0); o.setIndex(5,3,0); o.setMaterial("mesh_base","*"); o.setProperty("surface_base","*"); o.setEnabled(1,0); o.setIntersectionMask(1,0); o.setIntersection(1,0); and then i use: Vec3 p0,p1; Unigine::getPlayerMouseDirection(p0,p1); int ret[0]; Object o = engine.world.getIntersection(p0,p1,1,ret); but unigine does not detect my custom mesh
frustum Posted October 8, 2013 Posted October 8, 2013 Call "o.updateSurfaces();" after mesh creation.
sergey.pozhidaev Posted October 8, 2013 Author Posted October 8, 2013 i did it :D "unknown ObjectMesh class member updateSurfaces();"
frustum Posted October 8, 2013 Posted October 8, 2013 "ObjectMesh::updateSurfaces" method should exist in the latest SDK update.
sergey.pozhidaev Posted October 8, 2013 Author Posted October 8, 2013 how set bounds of ObjectMesh? it is not itersecting by getIntersection, how get intersection by Unigine on Custom ObjectMesh? or some other mesh, i need construct one mesh and get intersection by Unigine getIntersection, or i have to write own intersector for custom meshes?
sergey.pozhidaev Posted October 9, 2013 Author Posted October 9, 2013 ok, i know what is my problem: need to update bounds of custom mesh, but what i need to do for that?
sergey.pozhidaev Posted October 9, 2013 Author Posted October 9, 2013 ok, i`l use ObjectMeshDynamic - it works fine , because it consists updateBounds();
frustum Posted October 9, 2013 Posted October 9, 2013 Call "o.setSurfaceTransform(mat4_identity,0);" to recalculate bounds. ObjectMesh is much more effective for intersection and collision than ObjectMeshDynamic.
sergey.pozhidaev Posted October 9, 2013 Author Posted October 9, 2013 bounds recalced, but still no intersection :D , something else? on ObjectMeshDynamic it works
unclebob Posted November 8, 2013 Posted November 8, 2013 Hi Sergey! Sorry for late reply, have you still issuing this problem? I've modified mesh_01 example in samples/objects folder and added intersection test so it might help you. /* */ void update_scene() { while(1) { float ifps = engine.game.getIFps() * 0.1f; foreach(ObjectMesh mesh, i = 0; meshes; i++) { mesh.setWorldTransform(Mat4(mesh.getTransform() * quat(1.0f,1.0f,1.0f,ifps * i))); } vec3 p0,p1; Unigine::getPlayerMouseDirection(p0,p1); int ret[0]; Object o = engine.world.getIntersection(p0,p1,1,ret); if(o != NULL) { forloop(int i = 0; o.getNumSurfaces()) { o.setMaterialParameter("diffuse_color",vec4(1.0f,0.0f,0.0f,1.0f),i); o.setMaterialTexture("diffuse","",i); } } wait; } }
Recommended Posts