Exemplo n.º 1
0
void SimpleEntityVisualization::updatePositionAndOrientation()
{
	if (mEntity.getPredictedPos().isValid()) {
		mSceneNode->setPosition(Convert::toOgre(mEntity.getPredictedPos()));
		mVelocitySceneNode->setPosition(Convert::toOgre(mEntity.getPredictedPos()));
	}
	if (mEntity.getOrientation().isValid()) {
		mSceneNode->setOrientation(Convert::toOgre(mEntity.getOrientation()));
	}
	if (mEntity.getVelocity().isValid() && mEntity.getVelocity() != WFMath::Vector<3>::ZERO()) {
		mVelocitySceneNode->setVisible(true);

		WFMath::Quaternion q;
		q.identity();
		q.rotation(WFMath::Vector<3>(-1, 0, 0), mEntity.getVelocity(), WFMath::Vector<3>(0, 0, 1));

		if (q.isValid()) {
			mVelocitySceneNode->setOrientation(Convert::toOgre(q));
		} else {
			mVelocitySceneNode->setVisible(false);
		}
	} else {
		mVelocitySceneNode->setVisible(false);
	}
}
Exemplo n.º 2
0
void NodeController::updatePosition()
{
	WFMath::Point<3> pos = mAttachment.getAttachedEntity().getPredictedPos();
	WFMath::Quaternion orientation = mAttachment.getAttachedEntity().getOrientation();
	WFMath::Vector<3> velocity = mAttachment.getAttachedEntity().getPredictedVelocity();
	mAttachment.setPosition(pos.isValid() ? pos : WFMath::Point<3>::ZERO(), orientation.isValid() ? orientation : orientation.identity(), velocity.isValid() ? velocity : WFMath::Vector<3>::ZERO());
}
Exemplo n.º 3
0
void EntityCreatorCreationInstance::setOrientation(const WFMath::Quaternion& orientation)
{
	if (orientation.isValid()) {
		if (mEntityNode) {
			mEntityNode->setOrientation(Convert::toOgre(orientation));
		} else {
			mInitialOrientation = orientation;
		}
	}
}
Exemplo n.º 4
0
void EntityMoverBase::setOrientation(const WFMath::Quaternion& rotation)
{
    if (rotation.isValid()) {
        //We need to offset into local space.
        Ogre::Quaternion rotOffset = Ogre::Quaternion::IDENTITY;
        if (mNode->getParent()) {
            rotOffset = mNode->getParent()->_getDerivedOrientation();
        }
        mNode->setOrientation(Convert::toOgre(rotation) - rotOffset);
        Moved.emit();
    }
}
Exemplo n.º 5
0
void Renderer::orient(const WFMath::Quaternion & orientation)
{
    if (!orientation.isValid()) {
        return;
    }
    float orient[4][4];
    WFMath::RotMatrix<3> omatrix(orientation); // .asMatrix(orient);
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            orient[i][j] = omatrix.elem(i,j);
        }
    }
    orient[3][0] = orient[3][1] = orient[3][2] = orient[0][3] = orient[1][3] = orient[2][3] = 0.0f;
    orient[3][3] = 1.0f;
    glMultMatrixf(&orient[0][0]);
}
Exemplo n.º 6
0
void Renderer::drawEntity(Eris::Entity * ent, RenderableEntity * pe,
                          const PosType & cp)
{
    assert(ent != 0);

    PosType pos = ent->getPosition();
    WFMath::Quaternion orientation = ent->getOrientation();

    if (!orientation.isValid()) {
        orientation.identity();
    }

    MovableEntity * me = dynamic_cast<MovableEntity *>(ent);
    if (me != NULL) {
        debug( std::cout << ent->getVelocity() << " "
                         << (worldTime - me->getTime()) << " " << pos; );