Moderators: Sascha Willems, Thomas
joint 1 correct one
pinsAndPivotFrame
{m_x=3.5762786865234375e-07 m_y=0.00000000000000000 m_z=-0.99999994039535522 ...}
{m_x=0.00000000000000000 m_y=1.0000000000000000 m_z=0.00000000000000000 ...}
{m_x=0.99999994039535522 m_y=0.00000000000000000 m_z=3.5762786865234375e-07 ...}
matrix0
{m_x=1.0000000000000000 m_y=0.00000000000000000 m_z=0.00000000000000000 ...}
{m_x=0.00000000000000000 m_y=1.0000000000000000 m_z=0.00000000000000000 ...}
{m_x=0.00000000000000000 m_y=0.00000000000000000 m_z=1.0000000000000000 ...}
Joint 0 (the wrong one
matrix0
{m_x=5.9604644775390625e-08 m_y=0.00000000000000000 m_z=0.99999994039535522 ...}
{m_x=0.00000000000000000 m_y=1.0000000000000000 m_z=0.00000000000000000 ...}
{m_x=-0.99999994039535522 m_y=0.00000000000000000 m_z=5.9604644775390625e-08 ...}
pinsAndPivotFrame
{m_x=1.0000000000000000 m_y=0.00000000000000000 m_z=0.00000000000000000 ...}
{m_x=0.00000000000000000 m_y=1.0000000000000000 m_z=0.00000000000000000 ...}
{m_x=0.00000000000000000 m_y=0.00000000000000000 m_z=1.0000000000000000 ...}
void PhysicsTests::SpawnHingeSpringTest(const Vector3 worldPosition, const Quaternion worldOrientation)
{
//Set up contraption in around 0,0,0 world space
Node* baseNode = SpawnSamplePhysicsBox(scene_, Vector3::ZERO, Vector3(10,1,1));
HingeConstraint* constraint = baseNode->CreateComponent<HingeConstraint>();
constraint->SetOwnWorldPosition(Vector3(-5,0,0));
constraint->SetOtherWorldPosition(worldPosition);
constraint->SetNoPowerSpringDamper(true);
constraint->SetOwnWorldRotation(Quaternion(90, Vector3(0, 1, 0)));//<--this rotation throws things off.
//explicitly set world orientation of other frame because that wont be rotated by final move of whole contraption.
constraint->SetOtherWorldRotation(worldOrientation);
//finally move the whole contraption to desired location.
baseNode->SetWorldPosition(worldPosition);
baseNode->SetWorldRotation(worldOrientation);
}
constraint->SetOwnWorldRotation(Quaternion(90, Vector3(0, 1, 0)));//<--this rotation throws things off.
procedure TOXRenderList.RenderChildren(ctx: PRenderContext; nobj: TOXNewtonObject; child: boolean; steptime: dFloat);
var nObj0: TOXNewtonObject;
a: integer;
newMatx0: TMatrix;
begin
for a := 0 to nobj.mChildrens.Count - 1 do begin
nObj0 := TOXNewtonObject(nobj.mChildrens.Objects[a]);
nObj0.SetShader(mShader);
if (nObj0.mDynamic = false) then begin
if (nObj0.GetVisualOnly() = false) then
newMatx0 := MatrixMultiply(nObj0.mMatrix, nobj.GetAbsoluteMatrix())
else
if nObj0.GetFollowPhysics() = false then
newMatx0 := MatrixMultiply(nObj0.mCreationMatrix, nobj.GetCreationAbsoluteMatrix())
else
newMatx0 := MatrixMultiply(nObj0.mMatrix, nobj.mFinalAbsoluteMatrix);
end else begin
if (nObj0.mMass = 0.0) then begin
NewtonBodyGetMatrix(nObj0.mBody, @newMatx0.V[0].V[0]);
end else begin
newMatx0 := nObj0.mMatrix;
end;
end;
//
nObj0.mFinalAbsoluteMatrix := newMatx0;
//
glUniformMatrix4fv(glGetUniformLocation(mShader, 'Model_Matrix'), 1, false, @newMatx0.V[0].V[0]);
//
nObj0.RenderGL(ctx, steptime);
//
if (nObj0.mChildrens.Count > 0) then
RenderChildren(ctx, nObj0, true, steptime);
end;
end;
procedure TOXRenderList.RenderGL(ctx: PRenderContext; steptime: dFLoat);
var i : integer;
nObj : TOXNewtonObject;
newMatx : TMatrix;
begin
if (mShader = 0) then exit;
//
glUseProgram(mShader);
//
glUniformMatrix4fv(glGetUniformLocation(mShader, 'Projection_Matrix'), 1, false, @aProjMat.V[0].V[0]);
glUniformMatrix4fv(glGetUniformLocation(mShader, 'View_Matrix'), 1, false, @aViewMat.V[0].V[0]);
//
// The last added in the list is the first rendered.
for i := 0 to count -1 do begin
nObj := TOXNewtonObject(Objects[i]);
nObj.SetShader(mShader);
if (nObj.mDynamic = false) then begin
newMatx := nObj.GetAbsoluteMatrix();
end else begin
if (nObj.mMass = 0.0) then begin
NewtonBodyGetMatrix(nObj.mBody, @newMatx.V[0].V[0]);
end else begin
newMatx := nObj.mMatrix;
end;
end;
//
nObj.mChildrens.SetShader(mShader);
// Build the final matrix absolute to the parent.
nObj.mFinalAbsoluteMatrix := newMatx;
//
glUniformMatrix4fv(glGetUniformLocation(mShader, 'Model_Matrix'), 1, false, @newMatx.V[0].V[0]);
//
nObj.RenderGL(ctx, steptime);
//
RenderChildren(ctx, nObj, false, steptime);
//
end;
//
glUseProgram(0);
//
//
if (mListChanged = true) then begin
UpdateEditorList;
mListChanged := false;
end;
end;
Users browsing this forum: No registered users and 1 guest