Page 2 of 2

Re: Making a door hinge

Posted: Sun Jun 17, 2018 8:06 am
by mknmknmknjk
check

Re: Making a door hinge

Posted: Mon Jun 18, 2018 3:22 am
by thehankinator
Ohhh man you are using a point constraint not a line constraint! Holy crap it finally works!!! This is the code that ended up doing the trick for me!

Code: Select all

Matrix34 entityTM = m_pEntity->GetWorldTM();
IPhysicalEntity *pPE = m_pEntity->GetPhysics();
pe_action_add_constraint ac;
Vec3 axis(0, 0, 1);

ac.flags = world_frames | constraint_no_tears;
ac.pBuddy = WORLD_ENTITY;
ac.xlimits[0] = DEG2RAD(-90.0f);
ac.xlimits[1] = DEG2RAD(90.0f);
ac.yzlimits[0] = 0;
ac.yzlimits[1] = 0;
ac.pt[0] = ac.pt[1] = entityTM.GetTranslation();
ac.qframe[0] = ac.qframe[1] = Quat(entityTM) * Quat::CreateRotationV0V1(Vec3(1, 0, 0), axis);
ac.damping = 0;
pPE->Action(&ac);
Things that I was also misssing was:
yzlimits[0] and [1] needed to be initialize to 0
xlimits[0] and [1] are in radians not degrees

Thanks so much for hanging in there with me on this!

Re: Making a door hinge

Posted: Mon Jun 18, 2018 9:08 am
by cry-alex
Hello,

I know I come a little bit late to the party ;) But I just wanted to mention that we added plane, point and line constraint components to the engine. You should be able to build the same sort of door with those components without touching much C++. I just gave it a really quick try and will show the result below.
door.gif
door.gif (3.1 MiB) Viewed 957 times
The entity consist out of a mesh component, rigid body component and the line constraint component. I just tweaked around with the attributes until I got the desired result.
setup.jpg
setup.jpg (162.08 KiB) Viewed 956 times
Cheers,
Alex