void RenderablePlayerMovingObject::render() {
	if (!this->dead)
	{
		IMoveable* move = this->getMoveable();
		move->setPosition(this->position);

		if (this->heading != Vector4() && this->heading != Vector(0.0f, 0.0f, -1.0f)) {

			// reset rotation
			move->setRotation(0, 0, 0);

			// rotate the z vector to face the new heading
			move->rotate(
				Vector4::cross(this->heading, Vector(0.0f, 0.0f, -1.0f)),
				Vector4::angle(this->heading, Vector(0.0f, 0.0f, -1.0f))
				);

			// calculate where Y is now pointing
			Vector4 newY = move->getRotation() * Vector(0.0f, 1.0f, 0.0f);
			if (newY != up) {
				move->rotate(
					Vector4::cross(up, newY),
					Vector4::angle(up, newY)
					);
			}

		}
		RenderableObject::render();
	}
}
示例#2
0
void	GameplayEngine::refreshEntitiesPositions()
{
	for (std::deque<IEntity *>::iterator it = this->entities_.begin() ;
		it != this->entities_.end() ; ++it)
	{
		IEntity *		fetch = *it;
		IMoveable *		m = 0;
		
		if ((m = cast_entity<IEntity, IMoveable>(fetch)))
		{
			Point pos = m->getPosition();

			m->setPosition(pos.x_ - 20, pos.y_);
		}
	}
}