bool ParameterModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (!index.isValid() || index.column() != 1 || role != Qt::EditRole) return false; Parameter* param = parameter(index); if( isComponent(index) ) { // Parameter component. if( param->componentValue(index.row()) != value ) { param->setComponentValue(index.row(), value); emit dataChanged(index, index); QModelIndex parentIndex = createIndex(index.internalId(), 1, -1); emit dataChanged(parentIndex, parentIndex); } return true; } else { // Root parameter. if( param->value() != value ) { param->setValue(value); emit dataChanged(index, index); } return true; } return false; }
/*! Returns a QDeclarativeDomComponent for this object if it is a sub-component, or an invalid QDeclarativeDomComponent if not. QDeclarativeDomObject::isComponent() can be used to check if this object represents a sub-component. \sa QDeclarativeDomObject::isComponent() */ QDeclarativeDomComponent QDeclarativeDomObject::toComponent() const { QDeclarativeDomComponent rv; if (isComponent()) rv.d = d; return rv; }
static void alignComponents(void) { Entity *e; float x, y; float c, s; for (e = battle.entityHead.next ; e != NULL ; e = e->next) { if (isComponent(e)) { removeFromQuadtree(e, &battle.quadtree); s = sin(TO_RAIDANS(e->owner->angle)); c = cos(TO_RAIDANS(e->owner->angle)); x = (e->offsetX * c) - (e->offsetY * s); y = (e->offsetX * s) + (e->offsetY * c); x += e->owner->x; y += e->owner->y; e->x = x; e->y = y; if (e->flags & EF_STATIC) { e->angle = e->owner->angle; } addToQuadtree(e, &battle.quadtree); } } }
/*! Returns the list of assigned properties on this object. In the following example, "text" and "x" properties would be returned. \qml Text { text: "Hello world!" x: 100 } \endqml */ QList<QDeclarativeDomProperty> QDeclarativeDomObject::properties() const { QList<QDeclarativeDomProperty> rv; if (!d->object || isComponent()) return rv; QDeclarativeDomObjectPrivate::Properties properties = d->properties(); for (int ii = 0; ii < properties.count(); ++ii) { QDeclarativeDomProperty domProperty; domProperty.d->property = properties.at(ii).first; domProperty.d->property->addref(); domProperty.d->propertyName = properties.at(ii).second; rv << domProperty; } if (d->object->defaultProperty) { QDeclarativeDomProperty domProperty; domProperty.d->property = d->object->defaultProperty; domProperty.d->property->addref(); domProperty.d->propertyName = d->object->defaultProperty->name; rv << domProperty; } return rv; }
void Hydrax::setWaterColor(const Ogre::Vector3 &WaterColor) { mWaterColor = WaterColor; if (!mCreated) { return; } Ogre::ColourValue WC = Ogre::ColourValue(WaterColor.x, WaterColor.y, WaterColor.z); mRttManager->getTexture(RttManager::RTT_REFLECTION)-> getBuffer()->getRenderTarget()->getViewport(0)-> setBackgroundColour(WC); mRttManager->getTexture(RttManager::RTT_REFRACTION)-> getBuffer()->getRenderTarget()->getViewport(0)-> setBackgroundColour(WC); if (!isComponent(HYDRAX_COMPONENT_DEPTH)) { return; } mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_WATER, "uWaterColor", WaterColor); if (isComponent(HYDRAX_COMPONENT_UNDERWATER)) { mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_UNDERWATER, "uWaterColor", WaterColor); //mMaterialManager->getCompositor(MaterialManager::COMP_UNDERWATER)-> // getTechnique(0)->getTargetPass(0)->getPass(0)->setClearColour(WC); if (getHeigth(mCamera->getDerivedPosition()) > mCamera->getDerivedPosition().y-1.25f) { if (mMaterialManager->isCompositorEnable(MaterialManager::COMP_UNDERWATER)) { mMaterialManager->setCompositorEnable(MaterialManager::COMP_UNDERWATER, false); mMaterialManager->setCompositorEnable(MaterialManager::COMP_UNDERWATER, true); } } } }
void Hydrax::_setStrength(const Ogre::Real &Strength) { if (isComponent(HYDRAX_COMPONENT_FOAM)) { mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_WATER, "uFoamRange", Strength); if (isComponent(HYDRAX_COMPONENT_UNDERWATER)) { mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_UNDERWATER, "uFoamRange", Strength); } } mDecalsManager->_setWaterStrength(Strength); }
void Hydrax::setFoamStart(const Ogre::Real &FoamStart) { if(!isComponent(HYDRAX_COMPONENT_FOAM)) { return; } mFoamStart = FoamStart; mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_WATER, "uFoamStart", FoamStart); if(isComponent(HYDRAX_COMPONENT_UNDERWATER)) { mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_UNDERWATER, "uFoamStart", FoamStart); } }
void Hydrax::setSunArea(const Ogre::Real &SunArea) { if(!isComponent(HYDRAX_COMPONENT_SUN)) { return; } mSunArea = SunArea; mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_WATER, "uSunArea", SunArea); if(isComponent(HYDRAX_COMPONENT_UNDERWATER)) { mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_UNDERWATER, "uSunArea", SunArea); } }
void Hydrax::setSunColor(const Ogre::Vector3 &SunColor) { if(!isComponent(HYDRAX_COMPONENT_SUN)) { return; } mSunColor = SunColor; mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_WATER, "uSunColor", SunColor); if(isComponent(HYDRAX_COMPONENT_UNDERWATER)) { mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_UNDERWATER, "uSunColor", SunColor); } }
void Hydrax::setSunPosition(const Ogre::Vector3 &SunPosition) { if(!isComponent(HYDRAX_COMPONENT_SUN)) { return; } mSunPosition = SunPosition; mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_WATER, "uSunPosition", mMesh->getObjectSpacePosition(SunPosition)); if(isComponent(HYDRAX_COMPONENT_UNDERWATER)) { mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_UNDERWATER, "uSunPosition", mMesh->getObjectSpacePosition(SunPosition)); } }
RKComponentBase::ComponentStatus RKComponentBase::recursiveStatus () { RK_TRACE (PLUGIN); bool processing = false; bool children_satisfied = true; // we always need to interate over all children, since we need to make sure to find any which are dead or processing. for (QHash<QString, RKComponentBase*>::const_iterator it = child_map.constBegin (); it != child_map.constEnd (); ++it) { ComponentStatus s = it.value ()->recursiveStatus (); if (s == Dead) return Dead; if (s == Processing) processing = true; else if (s != Satisfied) children_satisfied = false; } if (processing) return Processing; bool req = required; if (isComponent () && static_cast<RKComponent*>(this)->isInactive ()) req = false; if (!req) return Satisfied; if (children_satisfied && isValid ()) return Satisfied; if (isComponent ()) RK_DO (qDebug ("component not satisfied: %s", qPrintable (static_cast<RKComponent*> (this)->getIdInParent ())), PLUGIN, DL_DEBUG); return Unsatisfied; }
void Hydrax::setSmoothPower(const Ogre::Real &SmoothPower) { if(!isComponent(HYDRAX_COMPONENT_SMOOTH)) { return; } mSmoothPower = SmoothPower; mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_WATER, "uSmoothPower", SmoothPower); }
void Hydrax::setCausticsEnd(const Ogre::Real &CausticsEnd) { if(!isComponent(HYDRAX_COMPONENT_CAUSTICS)) { return; } mCausticsEnd = CausticsEnd; mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_DEPTH, "uCausticsEnd", CausticsEnd); }
void Hydrax::setNormalDistortion(const Ogre::Real &NormalDistortion) { mNormalDistortion = NormalDistortion; mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_WATER, "uNormalDistortion", NormalDistortion); if(isComponent(HYDRAX_COMPONENT_UNDERWATER)) { mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_UNDERWATER, "uNormalDistortion", NormalDistortion); } }
void Hydrax::setGlobalTransparency(const Ogre::Real &GlobalTransparency) { mGlobalTransparency = GlobalTransparency; mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_WATER, "uGlobalTransparency", GlobalTransparency); if(isComponent(HYDRAX_COMPONENT_UNDERWATER)) { mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_UNDERWATER, "uGlobalTransparency", GlobalTransparency); } }
void Hydrax::setFullReflectionDistance(const Ogre::Real &FullReflectionDistance) { mFullReflectionDistance = FullReflectionDistance; mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_WATER, "uFullReflectionDistance", FullReflectionDistance); if(isComponent(HYDRAX_COMPONENT_UNDERWATER)) { mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_UNDERWATER, "uFullReflectionDistance", FullReflectionDistance); } }
void Hydrax::setCausticsPower(const Ogre::Real &CausticsPower) { if (!isComponent(HYDRAX_COMPONENT_CAUSTICS)) { return; } mCausticsPower = CausticsPower; mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_WATER, "uCausticsPower", CausticsPower); if (isComponent(HYDRAX_COMPONENT_UNDERWATER)) { mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_UNDERWATER, "uCausticsPower", CausticsPower); mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_UNDERWATER_COMPOSITOR, "uCausticsPower", CausticsPower); } }
void Hydrax::setPolygonMode(const Ogre::PolygonMode& PM) { if (!mCreated) { return; } mMaterialManager->getMaterial(MaterialManager::MAT_WATER)->getTechnique(0)->getPass(0)->setPolygonMode(PM); if (isComponent(HYDRAX_COMPONENT_UNDERWATER)) { mMaterialManager->getMaterial(MaterialManager::MAT_UNDERWATER)->getTechnique(0)->getPass(0)->setPolygonMode(PM); } mPolygonMode = PM; }
void Hydrax::_checkVisible() { if (!mCreated) { return; } if (!mVisible) { // Stop RTTs: mRttManager->removeAll(); // Hide hydrax mesh mMesh->getSceneNode()->setVisible(false); // Stop compositor (MaterialManager::setCompositorEnable(...) checks if underwater compositor exists) mMaterialManager->setCompositorEnable(MaterialManager::COMP_UNDERWATER, false); } else { // Start reflection and refraction RTTs: mRttManager->initialize(RttManager::RTT_REFLECTION); mRttManager->initialize(RttManager::RTT_REFRACTION); // Start depth rtt if needed: if (isComponent(HYDRAX_COMPONENT_DEPTH)) { mRttManager->initialize(RttManager::RTT_DEPTH); } // Start GPU normals rtt if needed: if (mModule->getNormalMode() == MaterialManager::NM_RTT) { mGPUNormalMapManager->create(); } // Set over-water material and check for underwater: mMesh->setMaterialName(mMaterialManager->getMaterial(MaterialManager::MAT_WATER)->getName()); mMaterialManager->reload(MaterialManager::MAT_WATER); _checkUnderwater(0); // Set hydrax mesh node visible mMesh->getSceneNode()->setVisible(true); } }
void Hydrax::setDistLimit(const Ogre::Real &DistLimit) { if (!isComponent(HYDRAX_COMPONENT_DEPTH)) { return; } mDistLimit = DistLimit; if (mDistLimit <= 0) { mDistLimit = 1; } mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_DEPTH, "uDistLimit", 1/mDistLimit); }
QVariant ParameterModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) { return QVariant(); } if( isComponent(index) ) { // Parameter component. if (index.column() == 0) { if (role == Qt::DisplayRole) return parameter(index)->componentName(index.row()); } else if (index.column() == 1) { if (role == Qt::DisplayRole) return parameter(index)->componentDisplayValue(index.row()); if (role == Qt::EditRole) return parameter(index)->componentValue(index.row()); } } else { // Root parameter. if (index.column() == 0) { if (role == Qt::DisplayRole || role == Qt::EditRole) { return parameter(index)->name(); } if (role == Qt::ToolTipRole) { // only show tooltip when over col 0, otherwise it gets annoying return parameter(index)->description(); } } else if (index.column() == 1) { if (role == Qt::DisplayRole) { return parameter(index)->displayValue(); } else if (role == Qt::EditRole) { return parameter(index)->value(); } else if (role == Qt::DecorationRole) { return parameter(index)->decoration(); } } } return QVariant(); }
void Hydrax::setPosition(const Ogre::Vector3 &Position) { mPosition = Position; if(!mCreated) { return; } if(isComponent(HYDRAX_COMPONENT_DEPTH)) { mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_VERTEX, MaterialManager::MAT_DEPTH, "uPlaneYPos", Position.y); } mMesh->getSceneNode()->setPosition(Position.x - mMesh->getSize().Width / 2, Position.y, Position.z - mMesh->getSize().Height / 2); mRttManager->getPlanesSceneNode()->setPosition(Position); // For world-space -> object-space conversion setSunPosition(mSunPosition); }
void Hydrax::_checkUnderwater(const Ogre::Real& timeSinceLastFrame) { if (!isComponent(HYDRAX_COMPONENT_UNDERWATER)) { mCurrentFrameUnderwater = false; return; } // If the camera is under the current water x/z position if (getHeigth(mCamera->getDerivedPosition()) > mCamera->getDerivedPosition().y-mUnderwaterCameraSwitchDelta) { mCurrentFrameUnderwater = true; if (mMesh->getMaterialName() != mMaterialManager->getMaterial(MaterialManager::MAT_UNDERWATER)->getName()) { mRttManager->getTexture(RttManager::RTT_REFRACTION)-> getBuffer()->getRenderTarget()->getViewport(0)-> setSkiesEnabled(true); if (isComponent(HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS)) { mRttManager->getTexture(RttManager::RTT_REFLECTION)-> getBuffer()->getRenderTarget()->getViewport(0)-> setSkiesEnabled(false); if (isComponent(HYDRAX_COMPONENT_DEPTH)) { mRttManager->initialize(RttManager::RTT_DEPTH_REFLECTION); } } else { mRttManager->remove(RttManager::RTT_REFLECTION); } if (isComponent(HYDRAX_COMPONENT_DEPTH) && isComponent(HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS)) { mRttManager->initialize(RttManager::RTT_DEPTH_REFLECTION); } mMaterialManager->reload(MaterialManager::MAT_UNDERWATER); mMaterialManager->setCompositorEnable(MaterialManager::COMP_UNDERWATER, true); mMesh->setMaterialName(mMaterialManager->getMaterial(MaterialManager::MAT_UNDERWATER)->getName()); } // Update god rays if (isComponent(HYDRAX_COMPONENT_UNDERWATER_GODRAYS)) { mGodRaysManager->update(timeSinceLastFrame); } } else { mCurrentFrameUnderwater = false; if (mMesh->getMaterialName() != mMaterialManager->getMaterial(MaterialManager::MAT_WATER)->getName()) { // We asume that RefractionRtt/ReflectionRtt are initialized mRttManager->getTexture(RttManager::RTT_REFRACTION)-> getBuffer()->getRenderTarget()->getViewport(0)-> setSkiesEnabled(false); if (!isComponent(HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS)) { mRttManager->initialize(RttManager::RTT_REFLECTION); mMaterialManager->reload(MaterialManager::MAT_WATER); } mRttManager->getTexture(RttManager::RTT_REFLECTION)-> getBuffer()->getRenderTarget()->getViewport(0)-> setSkiesEnabled(true); if (isComponent(HYDRAX_COMPONENT_DEPTH) && isComponent(HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS)) { mRttManager->remove(RttManager::RTT_DEPTH_REFLECTION); } mMaterialManager->setCompositorEnable(MaterialManager::COMP_UNDERWATER, false); mMesh->setMaterialName(mMaterialManager->getMaterial(MaterialManager::MAT_WATER)->getName()); } } }
void Hydrax::setComponents(const HydraxComponent &Components) { mComponents = Components; if (isComponent(HYDRAX_COMPONENT_SMOOTH) || isComponent(HYDRAX_COMPONENT_CAUSTICS) || isComponent(HYDRAX_COMPONENT_UNDERWATER_GODRAYS)) { // Delete smooth and/or caustics components wich needs depth component if (!isComponent(HYDRAX_COMPONENT_DEPTH)) { HydraxComponent s = HYDRAX_COMPONENTS_NONE, f = HYDRAX_COMPONENTS_NONE, u = HYDRAX_COMPONENTS_NONE, ur = HYDRAX_COMPONENTS_NONE; if (isComponent(HYDRAX_COMPONENT_SUN)) { s = HYDRAX_COMPONENT_SUN; } if (isComponent(HYDRAX_COMPONENT_FOAM)) { f = HYDRAX_COMPONENT_FOAM; } if (isComponent(HYDRAX_COMPONENT_UNDERWATER)) { u = HYDRAX_COMPONENT_UNDERWATER; } if (isComponent(HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS)) { ur = HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS; } if (isComponent(HYDRAX_COMPONENT_SMOOTH)) { HydraxLOG("Smooth component needs depth component... smooth component desactivated."); } if (isComponent(HYDRAX_COMPONENT_CAUSTICS)) { HydraxLOG("Caustics component needs depth component... caustics component desactivated."); } if (isComponent(HYDRAX_COMPONENT_UNDERWATER_GODRAYS)) { HydraxLOG("God rays component needs depth component... god rays component desactivated."); } mComponents = static_cast<HydraxComponent>(s|f|u|ur); } } if (isComponent(HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS) || isComponent(HYDRAX_COMPONENT_UNDERWATER_GODRAYS)) { // Delete underwater reflections components wich needs underwater component if (!isComponent(HYDRAX_COMPONENT_UNDERWATER)) { HydraxComponent s = HYDRAX_COMPONENTS_NONE, f = HYDRAX_COMPONENTS_NONE, d = HYDRAX_COMPONENTS_NONE, sm = HYDRAX_COMPONENTS_NONE, c = HYDRAX_COMPONENTS_NONE; if (isComponent(HYDRAX_COMPONENT_SUN)) { s = HYDRAX_COMPONENT_SUN; } if (isComponent(HYDRAX_COMPONENT_FOAM)) { f = HYDRAX_COMPONENT_FOAM; } if (isComponent(HYDRAX_COMPONENT_DEPTH)) { d = HYDRAX_COMPONENT_DEPTH; } if (isComponent(HYDRAX_COMPONENT_SMOOTH)) { sm = HYDRAX_COMPONENT_SMOOTH; } if (isComponent(HYDRAX_COMPONENT_CAUSTICS)) { c = HYDRAX_COMPONENT_CAUSTICS; } if (isComponent(HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS)) { HydraxLOG("Underwater reflections component needs underwater component... underwater reflections component desactivated."); } if (isComponent(HYDRAX_COMPONENT_UNDERWATER_GODRAYS)) { HydraxLOG("God rays component needs underwater component... god rays component desactivated."); } mComponents = static_cast<HydraxComponent>(s|f|d|sm|c); } if (isComponent(HYDRAX_COMPONENT_UNDERWATER_GODRAYS) && !isComponent(HYDRAX_COMPONENT_SUN)) { HydraxLOG("God rays component needs sun component... god rays component desactivated."); HydraxComponent f = HYDRAX_COMPONENTS_NONE, d = HYDRAX_COMPONENTS_NONE, c = HYDRAX_COMPONENTS_NONE, sm = HYDRAX_COMPONENTS_NONE, u = HYDRAX_COMPONENTS_NONE, ur = HYDRAX_COMPONENTS_NONE; if (isComponent(HYDRAX_COMPONENT_FOAM)) { f = HYDRAX_COMPONENT_FOAM; } if (isComponent(HYDRAX_COMPONENT_DEPTH)) { d = HYDRAX_COMPONENT_DEPTH; } if (isComponent(HYDRAX_COMPONENT_SMOOTH)) { sm = HYDRAX_COMPONENT_SMOOTH; } if (isComponent(HYDRAX_COMPONENT_CAUSTICS)) { c = HYDRAX_COMPONENT_CAUSTICS; } if (isComponent(HYDRAX_COMPONENT_UNDERWATER)) { u = HYDRAX_COMPONENT_UNDERWATER; } if (isComponent(HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS)) { ur = HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS; } mComponents = static_cast<HydraxComponent>(f|d|sm|c|u|ur); } } int NumberOfDepthChannels = 0; if (isComponent(HYDRAX_COMPONENT_DEPTH)) { NumberOfDepthChannels++; if (isComponent(HYDRAX_COMPONENT_CAUSTICS)) { NumberOfDepthChannels++; } if (isComponent(HYDRAX_COMPONENT_UNDERWATER_GODRAYS)) { NumberOfDepthChannels++; } } if (NumberOfDepthChannels > 0) { mRttManager->setNumberOfChannels(RttManager::RTT_DEPTH, static_cast<RttManager::NumberOfChannels>(NumberOfDepthChannels)); } if (!mCreated || !mModule) { return; } if (isComponent(HYDRAX_COMPONENT_UNDERWATER_GODRAYS)) { mGodRaysManager->create(mComponents); } else { mGodRaysManager->remove(); } // Check for Rtt's if (mCurrentFrameUnderwater && isComponent(HYDRAX_COMPONENT_UNDERWATER) && !isComponent(HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS)) { mRttManager->remove(RttManager::RTT_REFLECTION); } else { mRttManager->initialize(RttManager::RTT_REFLECTION); } if (!isComponent(HYDRAX_COMPONENT_DEPTH)) { mRttManager->remove(RttManager::RTT_DEPTH); mRttManager->remove(RttManager::RTT_DEPTH_REFLECTION); } else { mRttManager->initialize(RttManager::RTT_DEPTH); if (isComponent(HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS) && mCurrentFrameUnderwater) { mRttManager->initialize(RttManager::RTT_DEPTH_REFLECTION); } else { mRttManager->remove(RttManager::RTT_DEPTH_REFLECTION); } } if (!isComponent(HYDRAX_COMPONENT_UNDERWATER) && mCurrentFrameUnderwater) { mRttManager->getTexture(RttManager::RTT_REFRACTION)-> getBuffer()->getRenderTarget()->getViewport(0)-> setSkiesEnabled(false); mRttManager->getTexture(RttManager::RTT_REFLECTION)-> getBuffer()->getRenderTarget()->getViewport(0)-> setSkiesEnabled(true); } mMesh->setMaterialName("BaseWhiteNoLighting"); mMaterialManager->createMaterials(mComponents, MaterialManager::Options(mShaderMode, mModule->getNormalMode())); if (!isComponent(HYDRAX_COMPONENT_UNDERWATER)) { mCurrentFrameUnderwater = false; } mMesh->setMaterialName(mCurrentFrameUnderwater ? mMaterialManager->getMaterial(MaterialManager::MAT_UNDERWATER)->getName() : mMaterialManager->getMaterial(MaterialManager::MAT_WATER)->getName()); if (mCurrentFrameUnderwater) { mMaterialManager->setCompositorEnable(MaterialManager::COMP_UNDERWATER, true); } }
void Hydrax::create() { if (!mModule) { HydraxLOG("Module isn't set, skipping..."); return; } if (mCreated) { HydraxLOG("Hydrax is alredy created, skipping..."); return; } HydraxLOG("Creating module..."); mModule->create(); if (mModule->getNormalMode() == MaterialManager::NM_RTT) { if (!mModule->getNoise()->createGPUNormalMapResources(mGPUNormalMapManager)) { HydraxLOG(mModule->getNoise()->getName() + " doesn't support GPU Normal map generation."); } } else { if (mModule->getNoise()->areGPUNormalMapResourcesCreated()) { mModule->getNoise()->removeGPUNormalMapResources(mGPUNormalMapManager); } } HydraxLOG("Module created."); HydraxLOG("Initializating RTT Manager..."); mRttManager->initialize(RttManager::RTT_REFLECTION); mRttManager->initialize(RttManager::RTT_REFRACTION); if (isComponent(HYDRAX_COMPONENT_DEPTH)) { mRttManager->initialize(RttManager::RTT_DEPTH); } HydraxLOG("RTT manager initialized."); HydraxLOG("Registring device restored listener..."); mDeviceListener.mHydrax = this; Ogre::Root::getSingleton().getRenderSystem()->addListener(&mDeviceListener); HydraxLOG("Device restored listener registred."); HydraxLOG("Creating materials..."); mMaterialManager->createMaterials(mComponents, MaterialManager::Options(mShaderMode, mModule->getNormalMode())); mMesh->setMaterialName(mMaterialManager->getMaterial(MaterialManager::MAT_WATER)->getName()); HydraxLOG("Materials created."); if (isComponent(HYDRAX_COMPONENT_UNDERWATER_GODRAYS)) { HydraxLOG("Creating god rays..."); mGodRaysManager->create(mComponents); HydraxLOG("God rays created."); } HydraxLOG("Creating water mesh..."); mMesh->setOptions(mModule->getMeshOptions()); mMesh->create(); HydraxLOG("Water mesh created."); mCreated = true; // Hide if !mVisible _checkVisible(); // Check for underwater _checkUnderwater(0); }
void Hydrax::setWaterColor(const Ogre::Vector3 &WaterColor) { mWaterColor = WaterColor; if (!mCreated) { return; } Ogre::ColourValue WC = Ogre::ColourValue(WaterColor.x, WaterColor.y, WaterColor.z); Ogre::TexturePtr tex; if (isComponent(HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS) || !_isCurrentFrameUnderwater()) { /* Fix from http://www.ogre3d.org/addonforums/viewtopic.php?f=20&t=10925 mRttManager->getTexture(RttManager::RTT_REFLECTION)-> getBuffer()->getRenderTarget()->getViewport(0)-> setBackgroundColour(WC); */ tex = mRttManager->getTexture(RttManager::RTT_REFLECTION); if(!tex.isNull()) { tex->getBuffer()->getRenderTarget()->getViewport(0)->setBackgroundColour(WC); tex.setNull(); } } /* Fix from http://www.ogre3d.org/addonforums/viewtopic.php?f=20&t=10925 mRttManager->getTexture(RttManager::RTT_REFRACTION)-> getBuffer()->getRenderTarget()->getViewport(0)-> setBackgroundColour(WC); */ tex = mRttManager->getTexture(RttManager::RTT_REFRACTION); if(!tex.isNull()) { tex->getBuffer()->getRenderTarget()->getViewport(0)->setBackgroundColour(WC); tex.setNull(); } if (!isComponent(HYDRAX_COMPONENT_DEPTH)) { return; } mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_WATER, "uWaterColor", WaterColor); if (isComponent(HYDRAX_COMPONENT_UNDERWATER)) { mMaterialManager->setGpuProgramParameter( MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_UNDERWATER, "uWaterColor", WaterColor); //mMaterialManager->getCompositor(MaterialManager::COMP_UNDERWATER)-> // getTechnique(0)->getTargetPass(0)->getPass(0)->setClearColour(WC); /* Active creation/destruction if (getHeigth(mCamera->getDerivedPosition()) > mCamera->getDerivedPosition().y-1.25f) { if (mMaterialManager->isCompositorEnable(MaterialManager::COMP_UNDERWATER)) { mMaterialManager->setCompositorEnable(MaterialManager::COMP_UNDERWATER, false); mMaterialManager->setCompositorEnable(MaterialManager::COMP_UNDERWATER, true); } } */ } }