Exemplo n.º 1
0
void gkPhysicsController::setTransformState(const gkTransformState& state)
{
	if (m_suspend || !m_collisionObject)
		return;

	m_collisionObject->setWorldTransform(state.toTransform());
}
Exemplo n.º 2
0
void gkGameObjectInstance::applyTransform(const gkTransformState& trans)
{
	if (!isInstanced())
		return;


	const gkMatrix4 plocal = trans.toMatrix();

	Objects::Iterator iter = m_objects.iterator();
	while (iter.hasMoreElements())
	{
		gkGameObject* obj = iter.getNext().second;

		if (obj->hasParent())
		{
			continue;
		}

		gkTransformState* initalTransformState = m_objInitialTransformstates.get(obj);

		// Update transform relative to owner
		gkMatrix4 clocal;
		initalTransformState->toMatrix(clocal);
		obj->setTransform(plocal * clocal);
	}
}
Exemplo n.º 3
0
void gkBone::applyRootTransform(const gkTransformState& root)
{
	gkMatrix4 bonemat = m_bind.toMatrix();
	gkMatrix4 objmat = root.toMatrix();

	bonemat = objmat * bonemat;

	m_bind = gkTransformState(bonemat);
}
Exemplo n.º 4
0
void gkGameObjectInstance::cloneObjects(gkScene* scene, const gkTransformState& from, int time,
                                        const gkVector3& linearVelocity, bool tsLinLocal,
                                        const gkVector3& angularVelocity, bool tsAngLocal)
{
	if (!isInstanced())
		return;

	GK_ASSERT(scene);


	const gkMatrix4 plocal = from.toMatrix();


	Objects::Iterator iter = m_objects.iterator();
	while (iter.hasMoreElements())
	{
		gkGameObject* oobj = iter.getNext().second;
		gkGameObject* nobj = scene->cloneObject(oobj, time);



		// be sure this info was not cloned!
		GK_ASSERT(!nobj->isGroupInstance());


		// Update transform relative to owner
		gkGameObjectProperties& props = nobj->getProperties();

		gkMatrix4 clocal;
		props.m_transform.toMatrix(clocal);

		// merge back to transform state
		props.m_transform = gkTransformState(plocal * clocal);


		nobj->createInstance();


		if (props.isRigidOrDynamic() || props.isGhost())
		{
			if (!linearVelocity.isZeroLength())
				nobj->setLinearVelocity(linearVelocity, tsLinLocal ? TRANSFORM_LOCAL : TRANSFORM_PARENT);
		}

		if (props.isRigid())
		{
			if (!angularVelocity.isZeroLength())
				nobj->setAngularVelocity(angularVelocity, tsAngLocal ? TRANSFORM_LOCAL : TRANSFORM_PARENT);
		}
	}

}