void PlaneNodeProcessor::createCollision(Ogre::Entity *entity, DOMElement *physicsProxyElem)
{
    bool collisionEnabled = false;
    if (physicsProxyElem == NULL || !hasAttribute(physicsProxyElem, "collision"))
        collisionEnabled = false;
    else if(getAttributeValueAsBool(physicsProxyElem, "collision"))
        collisionEnabled = true;
    if(collisionEnabled)
    {
        std::vector<OgreNewt::CollisionPtr> collisions;
        OgreNewt::CollisionPtr collision = OgreNewt::CollisionPtr();
        OgreNewt::World* world = PhysicsManager::getSingleton()._getNewtonWorld();

        const AxisAlignedBox &aab = entity->getMesh()->getBounds();
        Ogre::Node* parentNode = entity->getParentNode();
        Ogre::Vector3 size = (aab.getMaximum() - aab.getMinimum()) * parentNode->getScale();

        const Quaternion orientation(0,0,0,0);// = parentNode->getOrientation();
        const Ogre::Vector3 pos = aab.getMinimum() * parentNode->getScale() + (size/2.0);

        collision = PhysicsManager::getSingleton().createCollision(entity, GT_BOX, "", Vector3::ZERO, Quaternion::IDENTITY, 0, NULL, NULL, true);

        if ( collision != NULL )
        {
            collisions.push_back(collision);
        }

        // Add to physics of map
        if (collisions.size() > 0)
        {
            PhysicsManager::getSingleton().addLevelGeometry(entity, collisions);
            LOG_WARNING(Logger::RULES, " Plane '"+entity->getName()+"' in levelGeometry geladen");
        }
    }
}
Example #2
0
void scaleAndTestMount(TestModel& model, Model::ModelMount& mount, const Ogre::Node& node)
{
	WFMath::AxisBox<3> axisBox(WFMath::Point<3>(0, 0, 0), WFMath::Point<3>(10, 10, 10));

	model.bbox = Ogre::AxisAlignedBox(Ogre::Vector3(0, 0, 0), Ogre::Vector3(5, 5, 5));
	mount.rescale(&axisBox);
	CPPUNIT_ASSERT(node.getScale() == Ogre::Vector3(2, 2, 2));

	model.bbox = Ogre::AxisAlignedBox(Ogre::Vector3(0, 0, 0), Ogre::Vector3(20, 20, 20));
	mount.rescale(&axisBox);
	CPPUNIT_ASSERT(node.getScale() == Ogre::Vector3(0.5, 0.5, 0.5));

	model.bbox = Ogre::AxisAlignedBox(Ogre::Vector3(10, 10, 10), Ogre::Vector3(20, 20, 20));
	mount.rescale(&axisBox);
	CPPUNIT_ASSERT(node.getScale() == Ogre::Vector3(1, 1, 1));

	model.bbox = Ogre::AxisAlignedBox(Ogre::Vector3(0, 10, 15), Ogre::Vector3(20, 20, 20));
	mount.rescale(&axisBox);
	CPPUNIT_ASSERT(node.getScale() == Ogre::Vector3(2, 1, 0.5));

}