Beispiel #1
0
void NewtonEntity::Update(float interpolationParam, NewtonWorld* world)
{
	// Calculate visual Transform by Interpolating between prev and curr State
	glm::vec4 position (prevPosition + (curPosition - prevPosition) * interpolationParam);
	glm::quat rotation = glm::gtc::quaternion::mix(prevRotation,curRotation,interpolationParam);

    matrix = createMat4(rotation,position);

}
Beispiel #2
0
void NewtonEntity::SetRotation(float rx, float ry, float rz)
{
    glm::mat4 mat = glm::gtx::euler_angles::yawPitchRoll(ry,rz,rx);
    curRotation = glm::gtc::quaternion::quat_cast(mat);
    prevRotation = curRotation;
    matrix = createMat4(curRotation,curPosition);
    if(body)
        NewtonBodySetMatrix( body, &matrix[0][0]);
}
Beispiel #3
0
NewtonBody* CreateRigidBody (NewtonWorld* world, NewtonEntity* ent, NewtonCollision* collision, dFloat mass)
{
	glm::vec3 minBox;
	glm::vec3 maxBox;
	glm::vec3 origin;
	glm::vec3 inertia;
	NewtonBody* body;

    glm::mat4 matrix = createMat4(ent->curRotation,ent->curPosition);

	// Now with the collision Shape we can crate a rigid body
	body = NewtonCreateBody (world, collision, &matrix[0][0]);

	// bodies can have a destructor.
	// this is a function callback that can be used to destroy any local data stored
	// and that need to be destroyed before the body is destroyed.
	NewtonBodySetDestructorCallback (body, DestroyBodyCallback);

	// save the entity as the user data for this body
	NewtonBodySetUserData (body, ent);
	ent->body=body;

	// we need to set the proper center of mass and inertia matrix for this body
	// the inertia matrix calculated by this function does not include the mass.
	// therefore it needs to be multiplied by the mass of the body before it is used.
	NewtonConvexCollisionCalculateInertialMatrix (collision, &inertia[0], &origin[0]);

	// set the body mass matrix
	NewtonBodySetMassMatrix (body, mass, mass * inertia.x, mass * inertia.y, mass * inertia.z);

	// set the body origin
	NewtonBodySetCentreOfMass (body, &origin[0]);

	// set the function callback to apply the external forces and torque to the body
	// the most common force is Gravity
	NewtonBodySetForceAndTorqueCallback (body, ApplyForceAndTorqueCallback);

	// set the function callback to set the transformation state of the graphic entity associated with this body
	// each time the body change position and orientation in the physics world
	NewtonBodySetTransformCallback (body, SetTransformCallback);

	return body;
}
Beispiel #4
0
void 
PropertyManager::addAttribute(wxPropertyGridManager *pg, std::unique_ptr<Attribute> &a) {

	switch (a->getType()) {

	case Enums::ENUM: createEnum(pg, a); break;
	case Enums::BOOL: createBool(pg, a); break;
	case Enums::BVEC4: createBVec4(pg, a); break;
	case Enums::INT: createInt(pg, a); break;
	case Enums::IVEC3: createIVec3(pg, a); break;
	case Enums::UINT: createUInt(pg, a); break;
	case Enums::UIVEC2: createUIVec2(pg, a); break;
	case Enums::UIVEC3: createUIVec3(pg, a); break;
	case Enums::FLOAT: createFloat(pg, a); break;
	case Enums::VEC2: createVec2(pg, a); break;
	case Enums::VEC3: createVec3(pg, a); break;
	case Enums::VEC4: createVec4(pg, a); break;
	case Enums::MAT3: createMat3(pg, a); break;
	case Enums::MAT4: createMat4(pg, a); break;
	case Enums::STRING: createString(pg, a); break;
	default: assert(false && "Missing datatype in property manager");

	}
}