arne
Senior Devvie   
money is the worst drug- we should not let it rule
|
 |
«
Posted
2005-04-02 11:45:24 » |
|
Hi When I add joints (Joint.attach(body1,body2) ) the bodies dissapear. Why? When I don't use the joints they're shown. Actually they get positions of NaN,NaN,NaN. What am I doing wrong?
|
|
|
|
harryk
Senior Newbie 
Stone golems rock!
|
 |
«
Reply #1 - Posted
2005-04-03 08:11:42 » |
|
What type of joint? Are you setting the anchor correctly? Code example? 
|
|
|
|
arne
Senior Devvie   
money is the worst drug- we should not let it rule
|
 |
«
Reply #2 - Posted
2005-04-03 10:00:07 » |
|
I just thought it might be a common problem  Here's the code: 1 2 3 4 5 6 7 8 9
| JointHinge j = new JointHinge(world); Vector3f v = getPos(split1[1]); Vector3f a = getPos(split1[2]); j.setAnchor(v.x,v.y,v.z); j.setAxis1(a.x,a.y,a.z); Body b1 = (Body) joints.get(split0[0]); Body b2 = (Body) joints.get(split0[1]); j.attach(b1,b2); |
Are you setting the anchor correctly? Are there any rules how to set the anchor ? Hope you can help me  Arne
|
|
|
|
Games published by our own members! Check 'em out!
|
|
holodri
Senior Newbie 
Java games rock!
|
 |
«
Reply #3 - Posted
2005-04-03 13:57:38 » |
|
have u tried to add the bodies before setting the anchor ?
|
|
|
|
arne
Senior Devvie   
money is the worst drug- we should not let it rule
|
 |
«
Reply #4 - Posted
2005-04-03 15:00:03 » |
|
No changes there either. I also tried switching setAxis1 and setAnchor. Still get NaN's.
|
|
|
|
arne
Senior Devvie   
money is the worst drug- we should not let it rule
|
 |
«
Reply #5 - Posted
2005-04-06 15:23:40 » |
|
Hey this can't be so hard, can it I also looked at the example code, but I don't get what I missed there. Do I have to add them maybe to some kind of space ? I really have no idea. I really appreaciate it if someone experienced with joints could help me. Thanks in advance arne
|
|
|
|
ewills
Junior Devvie  
Java skeletal animation systems rock!
|
 |
«
Reply #6 - Posted
2005-04-06 23:00:40 » |
|
I have only used JointBalls and JointAMotors, but here is my approach:
1. Create World and Space. 2. Create Bodies and Geoms, add Geoms to Space. 3. Set the position and orientation of the Bodies. 4. Create the JointBall and attach it to the Bodies. 5. Create the JointAMotor and attach it to the Bodies. 6. Set the mode for the JointAMotor (Euler). 7. Set the pivot of the joint.
Note that the ODE user guide suggests setting the pivot BEFORE attaching the joint. I adjust the pivot dynamically, which seems to work fine.
Hope this helps!
Edit: Step 7 also involves setting the JointAMotor axes before setting the pivot.
|
|
|
|
arne
Senior Devvie   
money is the worst drug- we should not let it rule
|
 |
«
Reply #7 - Posted
2005-04-07 07:16:09 » |
|
Thanks for the reply, but I still don't get it to work.  I followed your instruction step by step. Here's all the code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| public class Tester implements Demonstration{ Vector geoms = new Vector(); Body b; World world; public Tester() { Odejava.getInstance(); world = new World(); world.setStepInteractions(10); world.setStepSize(0.05f); Space s = new HashSpace(); GeomBox boxG = new GeomBox(280, 60,240); GeomSphere sphereG = new GeomSphere(100); Body boxB = new Body(world); b = boxB; boxB.addGeom(boxG); Body sphereB = new Body(world); sphereB.addGeom(sphereG); s.add(boxG); s.add(sphereG); boxB.setPosition(0,0,0); sphereB.setPosition(0,100, 50); boxB.setQuaternion(new Quat4f(0,0,0,1)); sphereB.setQuaternion(new Quat4f(0,0, 0,1)); geoms.add(boxG); geoms.add(sphereG); JointBall jh = new JointBall(world); jh.attach(boxB,sphereB); JointAMotor m = new JointAMotor(world); m.attach(boxB, sphereB); m.setMode(1); jh.setAnchor(0,0,0); jh.setAxis1(0,0,1); jh.setAxis1(1,0,0); } public java.util.List getGeoms() { return(geoms); } public void step() { world.step(); System.out.println(b.getPosition()); } public static void main(String[] args) { try { new RunDemo(new Tester()); } catch(Exception ex) { ex.printStackTrace(); } } |
When I don't call world.step the geoms are shown. But thats no use  . I don't exactly know how to configure the joints espacially the JointAMotor - how do I have to do this  - the javadoc doesn't say there very much and the Ode doc is only for this lowlevel stuff.
|
|
|
|
ewills
Junior Devvie  
Java skeletal animation systems rock!
|
 |
«
Reply #8 - Posted
2005-04-07 15:09:53 » |
|
Try calling Body.adjustMass(float f) on each Body after the Geom is added but before the joint and motor are attached. Also call these on the motor after attaching it: jointAMotor.setMode(Ode.dAMotorEuler); jointAMotor.setAxis(0, 1, 1.0f, 0.0f, 0.0f); jointAMotor.setAxis(2, 2, 0.0f, 1.0f, 0.0f);
|
|
|
|
arne
Senior Devvie   
money is the worst drug- we should not let it rule
|
 |
«
Reply #9 - Posted
2005-04-07 16:55:02 » |
|
Thanks a lot !!!  it works now - it was the Body.adjustMass() I forgot. Ok - this was only for my tester program - in my real program (the one for which I really wanted to have it) I set the mass and the bodies show when I don't add the Joint - when I add it, they don't - hmm this is strange... I'll try to work it out myself with now having some workable code  Arne
|
|
|
|
Games published by our own members! Check 'em out!
|
|
arne
Senior Devvie   
money is the worst drug- we should not let it rule
|
 |
«
Reply #10 - Posted
2005-04-07 17:33:53 » |
|
Ohh holy crap - my biggest nightmares came true !!! I got now to the error-source of that thingi - When I put My Geoms in GeomTransforms - then it starts sucking. It doesn't matter if I use my extended GeomTransforms or the normal ones - I get the same result  Is this now a bug  - it's probably clear, that the Joint is not able to work with that GeomTransform thingi. Anybody any ideas ? Arne
|
|
|
|
ewills
Junior Devvie  
Java skeletal animation systems rock!
|
 |
«
Reply #11 - Posted
2005-04-07 18:58:53 » |
|
I use both Joints and GeomTransforms. I have had some trouble with Body.adjustMass() and GeomTransforms. Make sure you are using the latest CVS and try using Body.setMassParameters() instead of Body.adjustMass().
|
|
|
|
arne
Senior Devvie   
money is the worst drug- we should not let it rule
|
 |
«
Reply #12 - Posted
2005-04-08 06:46:05 » |
|
Ok. I downloaded the latest cvs, but I can't get it to compile - it says it can't find package org.apache.xml.serialize and org.apache.xml.parsers ... Anyways I tried it with the old one, but with using setMassParameters instaed of adjustMass - and guess what ? - It works  Thanks a lot !!! One question only: I say there setMassParameters(mass, 0,0,0,1,1,1,0,0,0) - is this correct if I want to set the mass at the center of the body and the mass to be spread from there in every direction the same amount? Arne
|
|
|
|
ewills
Junior Devvie  
Java skeletal animation systems rock!
|
 |
«
Reply #13 - Posted
2005-04-08 22:08:28 » |
|
You're probably better off using setMassParemeters(mass, 0.0f, 0.0f, 0.0f, mass, mass, mass, 0.0f, 0.0f, 0.0f). This isn't correct, but works pretty well.
|
|
|
|
arne
Senior Devvie   
money is the worst drug- we should not let it rule
|
 |
«
Reply #14 - Posted
2005-04-09 05:40:09 » |
|
Thanx
|
|
|
|
darkprophet
Senior Devvie   
Go Go Gadget Arms
|
 |
«
Reply #15 - Posted
2005-04-11 12:10:02 » |
|
ewills, why are you setting mass, mass, mass instead of 1, 1,1? Is there any advantage to doing that?
DP
|
|
|
|
ewills
Junior Devvie  
Java skeletal animation systems rock!
|
 |
«
Reply #16 - Posted
2005-04-11 14:27:51 » |
|
Setting the moment of inertia to (1, 1, 1) for all objects will allow all objects to rotate at the same rate. Scaling the MOI by mass is not quite correct, but at least causes more massive objects to rotate slower than less massive objects.
|
|
|
|
arne
Senior Devvie   
money is the worst drug- we should not let it rule
|
 |
«
Reply #17 - Posted
2005-04-11 14:40:54 » |
|
Scaling the MOI by mass is not quite correct, but at least causes more massive objects to rotate slower than less massive objects.
Saying you need more force to accelerate it's rotation speed? Scaling the MOI by mass is not quite correct,
What actually would be correct? - just interested. This is probably not easy to answer, because it depends of what you want to have. Does the MOI also specify, how the mass is distributed in the bodies, for example? Arne
|
|
|
|
ewills
Junior Devvie  
Java skeletal animation systems rock!
|
 |
«
Reply #18 - Posted
2005-04-11 18:18:40 » |
|
In general, the mass and center of mass (COM) determine how easily an object can be moved around. Forces applied to a Body at its COM simply move the Body. Forces applied at locations other than the center of mass both move the Body and create torques. Torques rotate the Body according the Body's inertial tensor. The inertial tensor is usually represented by a symmetrical 3x3 matrix. The matrix is symmetrical, so you can represent the inertial tensor using 6 floats. The diagonals of the matrix are the moment of inertial (MOI). The MOI is the most important component of the inertial tensor Think of any torque applied to the Body being multiplied by the MOI. The MOI is a triple because the Body may rotate more easily about some axes due to the Body's geometry. Note that mass can be a scalar because forces from any direction affect the Body similarly. The other components of the inertial tensor ensure that a free-floating Body eventually rotates about it's principal axis of rotation. Think of these non-diagonal components of the inertial tensor matrix as constantly performing slight rotations. So that was just a quick brain dump  For more information on COM and inertial tensor calculation, see: http://scienceworld.wolfram.com/physics/MomentofInertia.htmlEdit: Oops! Torques is actually divided by the MOI to get angular acceleration. Similarly, Forces are divided by mass to get linear accelerations.
|
|
|
|
arne
Senior Devvie   
money is the worst drug- we should not let it rule
|
 |
«
Reply #19 - Posted
2005-04-13 16:48:29 » |
|
Ohh - this is to high for me - but the other stuff you said was more understandable  Now I've got at least some kind of idea what it is meant for.
|
|
|
|
|