lightmap Posted October 15, 2018 Share Posted October 15, 2018 (edited) Hello I'm coding rope interaction with controllers, and thinking of how to make rope grapping by hand in VR. JointParticles can't be saved as variable to enable/disable it and change anchor, so I need to create new one as controller get near? then, how to destroy JointParticles? JointBall - make things pinned in fixed place, unlike JointParticles - even with hand.BodyRigid.addJoint(rope_JointBall_1); WHAT do I need to set in JointBall parameters to let free jointed movement like with JointParticles? also how to get rope segments (BodyRope have getBodyParticles but no a word in documentation https://developer.unigine.com/en/docs/2.7.2/api/library/physics/class.bodyparticles?rlang=cs) Edited October 15, 2018 by lightmap Link to comment
silent Posted October 17, 2018 Share Posted October 17, 2018 Hi, Could you please give us some additional details - what is the rope in your assumptions? Maybe it will be easier not to bind joint directly to hand rather than just change joint position according to the hand (copy coordinates from hand and pass it to the object). You can see an example in VR Template demo (ObjHandle.cpp, holdIt() method)? If that doesn't help - could you please provide a small test scene with your rope implementation and VR features so we can check it as well on our side? 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
lightmap Posted October 17, 2018 Author Share Posted October 17, 2018 (edited) Hello Samples->UnigineScript->Physics->rope_03 if I change in Init() JointParticles to JointBall like so int init() { createInterface("samples/physics/"); engine.render.loadSettings("samples/common/world/render.settings"); createDefaultPlayer(Vec3(30.0f,0.0f,20.0f)); createPlaneWithBody(); setDescription("BodyRope"); // physics parameters engine.physics.setGravity(vec3(0.0f,0.0f,-9.8f * 2.0f)); engine.physics.setFrozenLinearVelocity(0.1f); engine.physics.setFrozenAngularVelocity(0.1f); int width = 7; int height = 7; vec3 size = vec3(8.0f,8.0f,1.0f); Body body_0 = createBodyBox(size,2.0f,0.5f,0.5f,get_material(0),translate(Vec3(0.0f,0.0f,10.0f))); Body body_1 = createBodyBox(size,2.0f,0.5f,0.5f,get_material(0),translate(Vec3(0.0f,0.0f,15.0f))); Body body_2 = createBodyBox(size,2.0f,0.5f,0.5f,get_material(0),translate(Vec3(0.0f,0.0f,20.0f))); forloop(int y = 1; height) { forloop(int x = 1; width) { Vec3 position = Vec3(float(x) / width - 0.5f,float(y) / height - 0.5f,15.0f) * size; BodyRope rope = createBodyRope(0.2f,20.0f,0.5f,20.0f,0.5f,0.5f,get_wire_material(1),translate(position)); rope.setNumIterations(8); class_remove(new JointBall(body_0,rope,position + Vec3(0.0f,0.0f,-5.0f)));// JointParticles class_remove(new JointBall(body_1,rope,position + Vec3(0.0f,0.0f, 0.0f)));// JointParticles class_remove(new JointBall(body_2,rope,position + Vec3(0.0f,0.0f, 5.0f)));// JointParticles } } return 1; } ropes just fall through, joints do not hold up ropes and boxes how to make JointBall to hold connections, what parameter am I missing? Edited October 17, 2018 by lightmap Link to comment
silent Posted October 17, 2018 Share Posted October 17, 2018 The thing is that you can't bind rope with JointBall, only JointParticles is suitable for that. Could you please give us more details and context why can't you use JointParticles in your setup? A small test scene or valid code part will be very useful to understand what is going on. 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
lightmap Posted October 17, 2018 Author Share Posted October 17, 2018 (edited) can't use JointParticles because can't save them to variable and disable/enable/destroy by some event I need to create joints and destroy at any rope position any count, usually 1-4 Edited October 17, 2018 by lightmap Link to comment
silent Posted October 18, 2018 Share Posted October 18, 2018 Are you using C# or C# + UnigineScript? How to reproduce it correctly? 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
cash-metall Posted October 18, 2018 Share Posted October 18, 2018 Example of saving and disable JointParticles to a variable. Samples->UnigineScript->Physics->rope_03 (to unhook the rope, press w) Body body_0; Body body_1; Body body_2; int width = 7; int height = 7; vec3 size = vec3(8.0f,8.0f,1.0f); Joint joints[0]; BodyRope r1; /* */ int init() { createInterface("samples/physics/rope_03.world"); engine.render.loadSettings(full_path("samples/common/world/render.render")); createDefaultPlayer(Vec3(30.0f,0.0f,20.0f)); createPlaneWithBody(); setDescription("BodyRope"); // physics parameters engine.physics.setGravity(vec3(0.0f,0.0f,-9.8f * 2.0f)); engine.physics.setFrozenLinearVelocity(0.1f); engine.physics.setFrozenAngularVelocity(0.1f); body_0 = createBodyBox(size,2.0f,0.5f,0.5f,get_material(0),translate(Vec3(0.0f,0.0f,10.0f))); body_1 = createBodyBox(size,2.0f,0.5f,0.5f,get_material(0),translate(Vec3(0.0f,0.0f,15.0f))); body_2 = createBodyBox(size,2.0f,0.5f,0.5f,get_material(0),translate(Vec3(0.0f,0.0f,20.0f))); forloop(int y = 1; height) { forloop(int x = 1; width) { Vec3 position = Vec3(float(x) / width - 0.5f,float(y) / height - 0.5f,15.0f) * size; r1 = createBodyRope(0.2f,20.0f,0.5f,20.0f,0.5f,0.5f,get_wire_material(1),translate(position)); r1.setNumIterations(8); JointParticles a1 = class_remove(new JointParticles(body_0,r1,position + Vec3(0.0f,0.0f,-5.0f),vec3(3.0f))); JointParticles a2 = class_remove(new JointParticles(body_1,r1,position + Vec3(0.0f,0.0f, 0.0f),vec3(3.0f))); JointParticles a3 = class_remove(new JointParticles(body_2,r1,position + Vec3(0.0f,0.0f, 5.0f),vec3(3.0f))); //saving all Joint in array joints.append(a1); joints.append(a2); joints.append(a3); } } return 1; } int shot = 1; /* */ int update() { if(shot) if(engine.controls.getState(CONTROLS_STATE_FORWARD) || engine.controls.getState(CONTROLS_STATE_TURN_UP)) { shot = 0; int id1 = r1.getID(); for (int i = 0; i < joints.size(); i++) { Joint j = joints.get(i); Body b1 = j.getBody1(); int id2 = b1.getID(); if (id1 == id2) { Body b2 = j.getBody0(); //remove joint with force cast r1.removeJoint(class_cast("Joint",j)); i--; } } } updatePhysics(); return 1; } You may have any problems because UnigineScript doesn't always successfully cast derivative classes to base class. Sometimes you need to manually specify the class. 1 Link to comment
lightmap Posted October 19, 2018 Author Share Posted October 19, 2018 Thanks for useful answers, now I can grab a rope! but sometimes after grabbing rope with hand fly away to somewhere far, how to increase stability and limit rope stretching? rope.setRestitution(0.01f); rope.setRigidity(0.01f); rope.setLinearStretch(1); rope.setNumIterations(8); Link to comment
silent Posted October 19, 2018 Share Posted October 19, 2018 It's hard to predict which settings will work in your case without seeing the full scene, sorry. Maybe that article will be helpful: https://developer.unigine.com/en/docs/2.7.2/principles/physics/bodies/rope/ 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
lightmap Posted November 7, 2018 Author Share Posted November 7, 2018 Hello JointParticles have size and if it covers several segments of rope with BodyParticles, then these BodyParticles fly away in some directions, and whole rope become like an enraged kraken... so I can’t grab rope with JointParticle size > rope segment, to set orientation of grabbed segment by controller How to make a fixed length rope, with no stretching (but soft) and no disconnections at JointParticles ? it is possible with unigine ? any length constrains? setLinearStretch=0 will collapse whole rope to a ring some mystery happens when I create new JointParticle at position where already present a JointParticle why Body connected to rope can't collide with it I know you busy doing targeted features, but aren't proper ropes "must have" for any sim engine? Superposition with ropes would be greater than ever ) Link to comment
silent Posted November 8, 2018 Share Posted November 8, 2018 Quote How to make a fixed length rope, with no stretching (but soft) and no disconnections at JointParticles ? Unfortunately, there is no way to achieve that currently in realtime. There is a custom rope in Superposition (unfortunately, it's also stretching) that used to hang lamps: It's made of JointBall, so maybe the right solution will be to implement your own rope on top of the JointBall. Overall physics engine improvement are planned to the next major version (like 3.x+). 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
Recommended Posts