Пример #1
0
//-------------------------------------------------------------------------------
Ogre::AxisAlignedBox CParticleEditor::getAABB() 
{
    if(mEntityHandle) 
        return mEntityHandle->getBoundingBox();

    if(mParticleHandle)
    {
        Ogre::AxisAlignedBox box = mParticleHandle->getBoundingBox();
        box.scale(mScale->get());
        return box;
    }
    else
        return Ogre::AxisAlignedBox::BOX_NULL;
}
Пример #2
0
QVector3D EC_Mesh::GetWorldSize() const
{
    QVector3D size(0,0,0);
    if (!entity_ || !adjustment_node_ || !placeable_)
        return size;

    // Get mesh bounds and scale it to the scene node
    EC_Placeable* placeable = checked_static_cast<EC_Placeable*>(placeable_.get());
    Ogre::AxisAlignedBox bbox = entity_->getMesh()->getBounds();
    bbox.scale(adjustment_node_->getScale());

    // Get size and take placeable scale into consideration to get real naali inworld size
    const Ogre::Vector3& bbsize = bbox.getSize();
    const Vector3df &placeable_scale = placeable->GetScale();
    // Swap y and z to make it align with other naali vectors
    size = QVector3D(bbsize.x*placeable_scale.x, bbsize.z*placeable_scale.z, bbsize.y*placeable_scale.y);
    return size;
}
Пример #3
0
QVector3D EC_Mesh::GetWorldSize() const
{
    QVector3D size(0,0,0);
    if (!entity_ || !adjustment_node_ || !placeable_)
        return size;

    // Get mesh bounds and scale it to the scene node
    EC_Placeable* placeable = checked_static_cast<EC_Placeable*>(placeable_.get());
    Ogre::AxisAlignedBox bbox = entity_->getMesh()->getBounds();
    ///\bug Rewrite this code to properly take the world transform into account. -jj.
    bbox.scale(adjustment_node_->getScale());

    // Get size and take placeable scale into consideration to get real in-world size
    const Ogre::Vector3& bbsize = bbox.getSize();
    const float3 &placeable_scale = placeable->WorldScale();
    // Swap y and z to make it align with other vectors
    size = QVector3D(bbsize.x*placeable_scale.x, bbsize.y*placeable_scale.y, bbsize.z*placeable_scale.z);
    return size;
}
Пример #4
0
void Tiles::initTile(Ogre::SceneManager *s,std::string name,std::string mesh,std::string mat, Ogre::Vector3 v,int x,int y,int h,int tileD)
{
  float d = tileD/100.0;
  std::cout<<name<<" ("<<v.x<<","<<v.y<<","<<v.z<<")"<<std::endl;
  sn = s->getRootSceneNode()->createChildSceneNode( name+"node",v);
  e = s->createEntity(name,Ogre::SceneManager::PT_CUBE);
  sn->attachObject(e);
  sn->scale(Ogre::Vector3(1,d*(h+1),1));
  
  e->setMaterialName(mat);
  e->setCastShadows(false);

  Ogre::AxisAlignedBox box = e->getBoundingBox();
  box.scale(Ogre::Vector3(1,d*(h+1),1));
  float dy = box.getCorner(Ogre::AxisAlignedBox::FAR_LEFT_BOTTOM ).y + tileD;
  sn->translate(0,-dy,0);
  u = NULL;
  this->x=x;
  this->y=y;
  this->h=h;

}
Пример #5
0
void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh)
{
    Ogre::SceneNode* insert = ptr.getRefData().getBaseNode();
    assert(insert);

    NifOgre::NIFLoader::load(mesh);
    Ogre::Entity *ent = mRenderer.getScene()->createEntity(mesh);


    Ogre::Vector3 extents = ent->getBoundingBox().getSize();
    extents *= insert->getScale();
    float size = std::max(std::max(extents.x, extents.y), extents.z);

    bool small = (size < Settings::Manager::getInt("small object size", "Viewing distance")) && Settings::Manager::getBool("limit small object distance", "Objects");

    // do not fade out doors. that will cause holes and look stupid
    if (ptr.getTypeName().find("Door") != std::string::npos)
        small = false;

    if (mBounds.find(ptr.getCell()) == mBounds.end())
        mBounds[ptr.getCell()] = Ogre::AxisAlignedBox::BOX_NULL;

    Ogre::AxisAlignedBox bounds = ent->getBoundingBox();
    bounds = Ogre::AxisAlignedBox(
        insert->_getDerivedPosition() + bounds.getMinimum(),
        insert->_getDerivedPosition() + bounds.getMaximum()
    );

    bounds.scale(insert->getScale());
    mBounds[ptr.getCell()].merge(bounds);

    bool transparent = false;
    for (unsigned int i=0; i<ent->getNumSubEntities(); ++i)
    {
        Ogre::MaterialPtr mat = ent->getSubEntity(i)->getMaterial();
        Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
        while (techIt.hasMoreElements())
        {
            Ogre::Technique* tech = techIt.getNext();
            Ogre::Technique::PassIterator passIt = tech->getPassIterator();
            while (passIt.hasMoreElements())
            {
                Ogre::Pass* pass = passIt.getNext();

                if (pass->getDepthWriteEnabled() == false)
                    transparent = true;
            }
        }
    }

    if(!mIsStatic || !Settings::Manager::getBool("use static geometry", "Objects") || transparent)
    {
        insert->attachObject(ent);

        ent->setRenderingDistance(small ? Settings::Manager::getInt("small object distance", "Viewing distance") : 0);
        ent->setVisibilityFlags(mIsStatic ? (small ? RV_StaticsSmall : RV_Statics) : RV_Misc);
        ent->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
    }
    else
    {
        Ogre::StaticGeometry* sg = 0;

        if (small)
        {
            if( mStaticGeometrySmall.find(ptr.getCell()) == mStaticGeometrySmall.end())
            {
                uniqueID = uniqueID +1;
                sg = mRenderer.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID));
                mStaticGeometrySmall[ptr.getCell()] = sg;

                sg->setRenderingDistance(Settings::Manager::getInt("small object distance", "Viewing distance"));
            }
            else
                sg = mStaticGeometrySmall[ptr.getCell()];
        }
        else
        {
            if( mStaticGeometry.find(ptr.getCell()) == mStaticGeometry.end())
            {

                uniqueID = uniqueID +1;
                sg = mRenderer.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID));
                mStaticGeometry[ptr.getCell()] = sg;
            }
            else
                sg = mStaticGeometry[ptr.getCell()];
        }

        // This specifies the size of a single batch region.
        // If it is set too high:
        //  - there will be problems choosing the correct lights
        //  - the culling will be more inefficient
        // If it is set too low:
        //  - there will be too many batches.
        sg->setRegionDimensions(Ogre::Vector3(2500,2500,2500));

        sg->addEntity(ent,insert->_getDerivedPosition(),insert->_getDerivedOrientation(),insert->_getDerivedScale());

        sg->setVisibilityFlags(small ? RV_StaticsSmall : RV_Statics);

        sg->setCastShadows(true);

        sg->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);

        mRenderer.getScene()->destroyEntity(ent);
    }
}