Angular movement #337
Unanswered
sourcefranke
asked this question in
Q&A
Replies: 1 comment
-
Here's a version you can copy paste into the demos (toss it into the Simulation = Simulation.Create(BufferPool, new DemoNarrowPhaseCallbacks(new SpringSettings(30, 1)), new DemoPoseIntegratorCallbacks(new Vector3(0, -10, 0)), new SolveDescription(8, 1));
// Create the dynamic body.
var bodyShape = new Box(1, 1, 1);
var movingBodyDescription = BodyDescription.CreateDynamic(new Vector3(0, 3, 0), new Vector3(), bodyShape.ComputeInertia(1), Simulation.Shapes.Add(bodyShape), 0.01f);
var movingBodyHandle = Simulation.Bodies.Add(movingBodyDescription);
// Ccreate a kinematic body to attach the dynamic body to.
// (Note that bodies don't have to have a shape!
// That can be useful if you want to use a two-body constraint with a single body.
// The second body can just be a kinematic proxy with no shape.)
var kinematicBodyDescription = BodyDescription.CreateKinematic(new Vector3(3, 3, 0), new Vector3(), Simulation.Shapes.Add(bodyShape), 0.01f);
var kinematicBodyHandle = Simulation.Bodies.Add(kinematicBodyDescription);
// Create the revolute joint
var hingeJoint = new Hinge()
{
// The bodies connected to the constraint start with identity rotation, so we can configure the local axes more intuitively.
// ("local" here means "local to the body's frame of reference." When the body rotates, the hinge axis rotates with it.)
LocalHingeAxisA = new Vector3(0, 1, 0),
LocalHingeAxisB = new Vector3(0, 1, 0),
LocalOffsetA = new Vector3(1.5f, 0, 0),
LocalOffsetB = new Vector3(-1.5f, 0, 0),
SpringSettings = new SpringSettings(30, 1)
};
Simulation.Solver.Add(movingBodyHandle, kinematicBodyHandle, hingeJoint);
// Define the angular motor
var motor = new AngularMotor { TargetVelocityLocalA = new Vector3(), Settings = new MotorSettings(float.MaxValue, 0.01f) };
Simulation.Solver.Add(movingBodyHandle, kinematicBodyHandle, motor); In general, I'd recommend playing around in the demos as a starting point. It's easier to incrementally modify things than to try to start from scratch. Eventually, context windows are going to be large enough that you can just dump the entire physics engine and its documentation into the AI directly and ask it to do everything for you. Alas, not yet. We might have to wait several MONTHS before that's economical. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I am pretty new to kinematics.
There's a topic I currently need to do some research for at a new work project.
It's about putting two bodies together with some joint in between.
What I try to achieve: I want to move only the second body and let it rotate around the joint.
But I am struggling at some point, because of I am not sure, what's missing to make it work.
Or did I even do something completely wrong already.
To ensure, it's clear, what I try to achieve, I've attached some drawings.
Again, sorry, I'm a total beginner in getting familiar and gathering domain knowledge.
I have tried to come up with some solution with the help of chatGPT.
The issue there (as you maybe already tried by yourself),
this chat bot was mixing things up in terms of version 1 and version 2 of this framework.
Code snippet
What I've "produced" so far (with the help of the well-known AI chat tool):
Beta Was this translation helpful? Give feedback.
All reactions