snow_zhangy Posted June 8, 2014 Share Posted June 8, 2014 hi: I'm running on the double precision simulation version. I found it's complicated to handle the vec3 to dvec3 or mat4 to dmat4 similiar. if i run the following #ifdef USE_DOUBLE dvec3 vPos=dvec3(0); #else vec3 vPos=vec3(0); #endif int idx1=mesh.getIndex(0); int idx2=mesh.getIndex(1); vPos=(mesh.getVertex(idx1)+mesh.getVertex(idx2))*0.5f; Node joint=add_editor(Unigine::createBox(vec3(1.0f))); joint.setPosition(vPos); i will get an can't convert vec3 to dvec3 error on the last line. but if i change vPos to vPos+=mesh.getVertex(idx1)+mesh.getVertex(idx2); vPos*=0.5f; it works fine. i need to know how to make it work for both single and double precision in uniginescript? or i have to stick with one? Link to comment
natalia Posted June 9, 2014 Share Posted June 9, 2014 Hi, you can use special "Scalar", "Vec3", "Mat4" types for define vectors and matrices. This types automatically detected from double or float coordinates precision. This types are defined in a "data/core/unigne.h". #include <unigine.h> Node dummy = new NodeDummy(); // double - Vec3 is dvec3, else Vec3 is vec3 Vec3 pos = Vec3_one; dummy.setPosition(pos); Link to comment
snow_zhangy Posted June 10, 2014 Author Share Posted June 10, 2014 Hi Natalia: Thanks for you help. Could you try node.setPosition(node2.getPosition()) in double precision build? It seems have the issue too. Link to comment
silent Posted June 10, 2014 Share Posted June 10, 2014 Hi, Sorry, can't reproduce with double precision builds. Could you please post sample code? Node node_0 = new NodeDummy(); Node node_1 = new NodeDummy(); node_0.setPosition(Vec3(1241.1f,12414.f,1224.f)); node_1.setPosition(node_0.getPosition()); 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
snow_zhangy Posted June 13, 2014 Author Share Posted June 13, 2014 try the following code. mesh is a ObjectMeshDynamic. basically i want to set an object to that vertex position. node.setPosition(mesh.getVertex(0)); Link to comment
silent Posted June 16, 2014 Share Posted June 16, 2014 Hi, The returning type of getVertext() is vec3, so this value without modifications can be used only with float precision builds. Try to pass Vec3 constructor explicit to the node.setPosition() function. For example: node.setPosition(Vec3(mesh.getVertex(0))); Thanks! 1 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
Recommended Posts