Re: Making a door hinge

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;[0] =[1] = entityTM.GetTranslation();
ac.qframe[0] = ac.qframe[1] = Quat(entityTM) * Quat::CreateRotationV0V1(Vec3(1, 0, 0), axis);
ac.damping = 0;
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


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 (3.1 MiB) Viewed 198 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 (162.08 KiB) Viewed 197 times
setup.jpg (162.08 KiB) Viewed 198 times

Who is online

Users browsing this forum: No registered users and 2 guests