AggrorJorn Posted March 25, 2010 Share Posted March 25, 2010 I am trying to create a rope. I have been experimenting for 2 days now, trying al kinds of values. But unfortunately no good results sofar. Any suggestion for a command that would help to stabalize the rope would be great. See the txt file for the entire code. --box1 box1Body = CreateBodyBox(1,1,1,box1) box1=CreateCube() box1:SetParent(box1Body,1) box1Body:SetPosition(Vec3(0,30,0)) box1Body:SetMass(0) --some variables firstBodyCreated = 0 LastBody = nil Vec3Pos = Vec3 (0,0,0) i = 0 --Create more bodies in a loop for i = 0, 5, i+1 do Vec3Pos = Vec3 (0,i*1.1,0) if firstBodyCreated == 0 then NewBody = CreateBodyCylinder(0.5,2.5,box1Body) firstBodyCreated= 1 else NewBody = CreateBodyCylinder(0.5,2.6,LastBody) end NewBody:SetMass(10) NewBody:SetCollisionType(1,1) NewBody:SetPosition(Vec3Pos, 0) SetBodyElasticity(NewBody,10) NewBody:SetFriction( 5, 5 ) if LastBody~=nil then NewJoint = CreateJointBall (NewBody, LastBody,Vec3 (1, 1, 1)) SetBallJointLimits (NewJoint, 100,100,100) end LastBody = NewBody end DebugPhysics(1) Collisions(1,1,1) Quote Link to comment Share on other sites More sharing options...
Josh Posted March 25, 2010 Share Posted March 25, 2010 You might have more luck adding forces to make the nodes of the rope stay a certain distance from one another. You'd have more control that way, and can handle elasticity and breaking, and it's probably less overhead than using joints. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 26, 2010 Author Share Posted March 26, 2010 hmm Sounds more compicated to me. How do you see that going? Something like: The second box is being forced towards the position of the first box, while the first box is pushing the second box away from him? I think I'll try this wiki page first: http://leadwerks.com/wiki/index.php?title=CreateJointBall Also in to old forum I saw a topic where the same joint technique is used Quote Link to comment Share on other sites More sharing options...
Josh Posted March 27, 2010 Share Posted March 27, 2010 For each linked pair, take the distance between them, and add force to make them the distance they are supposed to be apart. If you just do this for each pair, it will work itself out and act like a rope. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Rekindled Phoenix Posted March 27, 2010 Share Posted March 27, 2010 I would love to see some kind of tutorial specific to ropes and joint related entities. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 29, 2010 Author Share Posted March 29, 2010 What do you mean with 'linked'? Like when linked inside the editor (green line per index)? Because I haven't seen a command in the wiki that can do this by code. The joints are giving me a lot of trouble, so I am gonna try your way now. This is what I have in mind: (according to your way) place 3 boxes under each other each box is parented to the one above (if it exists) a loop checks for the distance between 2 boxes if distance is lower than specified in variable then add force downwards the loop resets the boxes to its previous position, resulting in being pushed away over and over again I think the adding of forces is going to work as I expect. however, I think that the resetting of the boxes original position is going to cause unwanted results. I'll place back when I have something. Quote Link to comment Share on other sites More sharing options...
Rekindled Phoenix Posted May 8, 2010 Share Posted May 8, 2010 the loop resets the boxes to its previous position, resulting in being pushed away over and over again Aggror I think of placing the objects to the previous position, you should use a curve funtion to ease them back into place every frame loop. How does that sound? Quote Link to comment Share on other sites More sharing options...
TylerH Posted May 8, 2010 Share Posted May 8, 2010 The technique for this is called spring dampening. You create a "Spring" class that has two vectors or entities, and does the calculation in an Update call to determine the forces to apply. It is then dampened and modified to simulate elasticity, breaking, etc. It is commonly used in 3rd person cameras. I will look for an implementation I have done previously and report back here my findings. Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.