Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7104 for code/branches


Ignore:
Timestamp:
Jun 3, 2010, 2:21:26 AM (14 years ago)
Author:
scheusso
Message:

made planet synchronisable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation3/src/modules/objects/Planet.cc

    r6501 r7104  
    7070        {
    7171            Camera* activeCamera = CameraManager::getInstance().getActiveCamera();
    72             if (activeCamera)
     72            if (activeCamera && this->billboard_.getBillboardSet())
    7373            {
    7474                float distance = this->getPosition().distance( activeCamera->getWorldPosition() );
     
    8989    void Planet::init()
    9090    {
    91         float scaleFactor = this->getScale();
    92 
    93 #if OGRE_VERSION >= 0x010700
    94         Ogre::Mesh::LodValueList distList;
    95 #else
    96         Ogre::Mesh::LodDistanceList distList;
    97 #endif
    98 
    99         distList.push_back(10.0f*scaleFactor);
    100         distList.push_back(19.0f*scaleFactor);
    101         distList.push_back(27.0f*scaleFactor);
    102         distList.push_back(34.0f*scaleFactor);
    103         distList.push_back(40.0f*scaleFactor);
    104         distList.push_back(45.0f*scaleFactor);
    105         distList.push_back(49.0f*scaleFactor);
    106         distList.push_back(52.0f*scaleFactor);
    107         distList.push_back(54.0f*scaleFactor);
    108         distList.push_back(55.0f*scaleFactor);
    109 
    110         float reductionValue = 0.2f;
    111 
    112         this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue);
    113         billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->atmosphere_, Vector3(0,0,0));
    114 
    115         this->attachOgreObject(this->billboard_.getBillboardSet());
    116         this->billboard_.getBillboardSet()->setUseAccurateFacing(true);
    117         this->setCastShadows(true);
    118         this->billboard_.getBillboardSet()->setRenderQueueGroup(this->mesh_.getEntity()->getRenderQueueGroup());
    119         this->mesh_.setCastShadows(true);
    12091    }
    12192
    12293    void Planet::changedMesh()
    12394    {
    124         if (this->mesh_.getEntity())
    125             this->detachOgreObject(this->mesh_.getEntity());
     95        if( GameMode::showsGraphics() )
     96        {
     97            if (this->mesh_.getEntity())
     98                this->detachOgreObject(this->mesh_.getEntity());
    12699
    127         this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
     100            this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
    128101
    129         if (this->mesh_.getEntity())
    130         {
    131             this->attachOgreObject(this->mesh_.getEntity());
    132             this->mesh_.getEntity()->setCastShadows(this->bCastShadows_);
    133             this->mesh_.setVisible(this->isVisible());
     102            if (this->mesh_.getEntity())
     103            {
     104                this->attachOgreObject(this->mesh_.getEntity());
     105                this->mesh_.getEntity()->setCastShadows(this->bCastShadows_);
     106                this->mesh_.setVisible(this->isVisible());
     107               
     108                float scaleFactor = this->getScale();
     109               
     110    #if OGRE_VERSION >= 0x010700
     111                Ogre::Mesh::LodValueList distList;
     112    #else
     113                Ogre::Mesh::LodDistanceList distList;
     114    #endif
     115               
     116                distList.push_back(10.0f*scaleFactor);
     117                distList.push_back(19.0f*scaleFactor);
     118                distList.push_back(27.0f*scaleFactor);
     119                distList.push_back(34.0f*scaleFactor);
     120                distList.push_back(40.0f*scaleFactor);
     121                distList.push_back(45.0f*scaleFactor);
     122                distList.push_back(49.0f*scaleFactor);
     123                distList.push_back(52.0f*scaleFactor);
     124                distList.push_back(54.0f*scaleFactor);
     125                distList.push_back(55.0f*scaleFactor);
     126               
     127                float reductionValue = 0.2f;
     128               
     129                this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue);
     130                billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->atmosphere_, Vector3(0,0,0));
     131               
     132                this->attachOgreObject(this->billboard_.getBillboardSet());
     133                this->billboard_.getBillboardSet()->setUseAccurateFacing(true);
     134                this->setCastShadows(true);
     135                this->billboard_.getBillboardSet()->setRenderQueueGroup(this->mesh_.getEntity()->getRenderQueueGroup());
     136                this->mesh_.setCastShadows(true);
     137            }
    134138        }
    135         this->init();
    136139    }
    137140
     
    151154        SUPER(Planet, XMLPort, xmlelement, mode);
    152155
    153         if (GameMode::showsGraphics())
    154         {
    155             XMLPortParam(Planet, "atmosphere", setAtmosphere, getAtmosphere, xmlelement, mode).defaultValues("planet/Atmosphere");
    156             XMLPortParam(Planet, "atmospheresize", setAtmosphereSize, getAtmosphereSize, xmlelement,mode);
    157             XMLPortParam(Planet, "imagesize", setImageSize, getImageSize, xmlelement,mode);
    158             XMLPortParam(Planet, "mesh", setMeshSource, getMeshSource, xmlelement, mode);
    159             XMLPortParam(Planet, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true);
    160         }
     156        XMLPortParam(Planet, "atmosphere", setAtmosphere, getAtmosphere, xmlelement, mode).defaultValues("planet/Atmosphere");
     157        XMLPortParam(Planet, "atmospheresize", setAtmosphereSize, getAtmosphereSize, xmlelement,mode);
     158        XMLPortParam(Planet, "imagesize", setImageSize, getImageSize, xmlelement,mode);
     159        XMLPortParam(Planet, "mesh", setMeshSource, getMeshSource, xmlelement, mode);
     160        XMLPortParam(Planet, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true);
    161161    }
    162162
     
    164164    {
    165165        registerVariable(this->atmosphere_, VariableDirection::ToClient);
     166        registerVariable(this->atmosphereSize, VariableDirection::ToClient);
     167        registerVariable(this->imageSize, VariableDirection::ToClient);
     168        // Note: the meshSrc should be synchronised after atmosphere and other values, because the meshSrc callback setts the atmosphere billboards
    166169        registerVariable(this->meshSrc_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedMesh));
    167170        registerVariable(this->bCastShadows_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedShadows));
    168         registerVariable(this->atmosphereSize, VariableDirection::ToClient);
    169         registerVariable(this->imageSize, VariableDirection::ToClient);
    170171    }
    171172
Note: See TracChangeset for help on using the changeset viewer.