forked from speed-dreams/speed-dreams-code
- Update OSG Clouds
- Update Osg Cars git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6167 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 122c404c18a6caf6635bcaaca63236181b3c760b Former-commit-id: 236a2ef6c33bb4112ea40852f6dc20b0c2bbd07a
This commit is contained in:
parent
b3329926c0
commit
dcf4f044b7
4 changed files with 34 additions and 35 deletions
|
@ -510,8 +510,6 @@ osg::ref_ptr<osg::Node> SDCar::loadCar(tCarElt *car, bool tracktype, bool subcat
|
|||
light2state->setMode(GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED);
|
||||
light2state->setMode(GL_FOG, osg::StateAttribute::ON | osg::StateAttribute::PROTECTED );
|
||||
light2state->setMode(GL_CULL_FACE, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED);
|
||||
|
||||
light2->setNodeMask(~(0x1 | 0x2));
|
||||
|
||||
std::string tmp = GetDataDir();
|
||||
snprintf(buf, nMaxTexPathSize, "cars/models/%s/", car->_carName);
|
||||
|
|
|
@ -89,6 +89,7 @@ class SDCars
|
|||
private :
|
||||
std::vector<SDCar *> the_cars;
|
||||
osg::ref_ptr<osg::Group> cars_branch;
|
||||
osg::ref_ptr<osg::Group> shadow_branch;
|
||||
tSituation *situation;
|
||||
|
||||
void addSDCar(SDCar * car);
|
||||
|
@ -104,7 +105,9 @@ public :
|
|||
SDCar *getCar(tCarElt*car);
|
||||
void unLoad();
|
||||
void updateShadingParameters(osg::Matrixf modelview);
|
||||
osg::ref_ptr<osg::Node> getCarsNode() { return cars_branch.get(); }
|
||||
osg::ref_ptr<osg::Node> getShadowNode() { return shadow_branch.get(); }
|
||||
osg::ref_ptr<osg::Node> getCarsNode() { return cars_branch.get(); }
|
||||
|
||||
};
|
||||
|
||||
#endif /* _OSGCAR_H_ */
|
||||
|
|
|
@ -402,8 +402,8 @@ void SDRender::Init(tTrack *track)
|
|||
}
|
||||
}
|
||||
|
||||
m_scene->addChild(cargroup.get());
|
||||
m_scene->addChild(scene.get());
|
||||
m_scene->addChild(cargroup.get());
|
||||
m_scene->addChild(background.get());
|
||||
|
||||
sceneGroup->addChild(m_scene.get());
|
||||
|
|
|
@ -51,7 +51,7 @@ static bool state_initialized = false;
|
|||
|
||||
// make an StateSet for a cloud layer given the named texture
|
||||
static osg::StateSet*
|
||||
SDMakeState(const std::string &path, const char* colorTexture)
|
||||
SDMakeState(const std::string &path, const char* colorTexture, const char* normalTexture )
|
||||
{
|
||||
osg::StateSet *stateSet = new osg::StateSet;
|
||||
|
||||
|
@ -65,6 +65,15 @@ SDMakeState(const std::string &path, const char* colorTexture)
|
|||
stateSet->setTextureAttributeAndModes(0, texture.get());
|
||||
stateSet->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::ON);
|
||||
|
||||
TmpPath = path+"data/sky/"+normalTexture;
|
||||
GfLogInfo("Path Sky cloud normal texture = %s\n", TmpPath.c_str());
|
||||
osg::ref_ptr<osg::Image> image2 = osgDB::readImageFile(TmpPath);
|
||||
osg::ref_ptr<osg::Texture2D> texture2 = new osg::Texture2D(image2.get());
|
||||
texture2->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
|
||||
texture2->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
|
||||
stateSet->setTextureAttributeAndModes(1, texture2.get());
|
||||
stateSet->setTextureMode(1, GL_TEXTURE_2D, osg::StateAttribute::ON);
|
||||
|
||||
osg::ref_ptr<osg::ShadeModel> Smooth = new osg::ShadeModel;
|
||||
Smooth->setMode(ShadeModel::SMOOTH);
|
||||
Smooth->setDataVariance(Object::STATIC);
|
||||
|
@ -81,21 +90,9 @@ SDMakeState(const std::string &path, const char* colorTexture)
|
|||
StandardBlendFunc->setSource(BlendFunc::SRC_ALPHA);
|
||||
StandardBlendFunc->setDestination(BlendFunc::ONE_MINUS_SRC_ALPHA);
|
||||
StandardBlendFunc->setDataVariance(Object::STATIC);
|
||||
stateSet->setAttributeAndModes(StandardBlendFunc.get());
|
||||
|
||||
/*osg::ref_ptr<osg::Material> material = new osg::Material;
|
||||
material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
|
||||
material->setEmission(osg::Material::FRONT_AND_BACK,
|
||||
osg::Vec4(0.05, 0.05, 0.05, 0));
|
||||
material->setSpecular(osg::Material::FRONT_AND_BACK,
|
||||
osg::Vec4(0, 0, 0, 1));
|
||||
material->setDiffuse(osg::Material::FRONT_AND_BACK,
|
||||
osg::Vec4(0.5, 0.5, 0.5, 1));
|
||||
material->setAmbient(osg::Material::FRONT_AND_BACK,
|
||||
osg::Vec4(0.2, 0.2, 0.2, 1));
|
||||
|
||||
stateSet->setAttribute(material.get());*/
|
||||
stateSet->setMode(GL_FOG, osg::StateAttribute::OFF);
|
||||
|
||||
stateSet->setAttributeAndModes(StandardBlendFunc.get());
|
||||
stateSet->setMode(GL_FOG, osg::StateAttribute::OFF);
|
||||
stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
|
||||
stateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
|
||||
stateSet->setMode(GL_LIGHT0, osg::StateAttribute::OFF);
|
||||
|
@ -281,6 +278,7 @@ void SDCloudLayer::setTextureOffset(const osg::Vec2& offset)
|
|||
osg::TexMat *texMat = dynamic_cast<osg::TexMat*>(attr);
|
||||
if (!texMat)
|
||||
return;
|
||||
|
||||
texMat->setMatrix(osg::Matrix::translate(offset[0],offset[1], 0.0));
|
||||
}
|
||||
|
||||
|
@ -298,53 +296,53 @@ void SDCloudLayer::rebuild()
|
|||
GfOut("initializing cloud layers\n");
|
||||
|
||||
osg::ref_ptr<osg::StateSet> state;
|
||||
state = SDMakeState(texture_path, "overcast.png");
|
||||
state = SDMakeState(texture_path, "overcast.png", "overcast_n.png");
|
||||
layer_states[SD_CLOUD_OVERCAST] = state;
|
||||
state = SDMakeState(texture_path, "overcast_top.png");
|
||||
state = SDMakeState(texture_path, "overcast_top.png", "overcast_top_n.png");
|
||||
layer_states2[SD_CLOUD_OVERCAST] = state;
|
||||
|
||||
state = SDMakeState(texture_path, "overcast2.png");
|
||||
state = SDMakeState(texture_path, "overcast2.png", "overcast2_n.png");
|
||||
layer_states[SD_CLOUD_OVERCAST2] = state;
|
||||
state = SDMakeState(texture_path, "overcast_top.png");
|
||||
state = SDMakeState(texture_path, "overcast2_top.png", "overcast2_top_n.png");
|
||||
layer_states2[SD_CLOUD_OVERCAST2] = state;
|
||||
|
||||
state = SDMakeState(texture_path, "broken.png");
|
||||
state = SDMakeState(texture_path, "broken.png", "broken_n.png");
|
||||
layer_states[SD_CLOUD_BROKEN] = state;
|
||||
layer_states2[SD_CLOUD_BROKEN] = state;
|
||||
|
||||
state = SDMakeState(texture_path, "broken2.png");
|
||||
state = SDMakeState(texture_path, "broken2.png", "broken2_n.png");
|
||||
layer_states[SD_CLOUD_BROKEN2] = state;
|
||||
layer_states2[SD_CLOUD_BROKEN2] = state;
|
||||
|
||||
state = SDMakeState(texture_path, "scattered.png");
|
||||
state = SDMakeState(texture_path, "scattered.png", "scattered_n.png" );
|
||||
layer_states[SD_CLOUD_SCATTERED] = state;
|
||||
layer_states2[SD_CLOUD_SCATTERED] = state;
|
||||
|
||||
state = SDMakeState(texture_path, "scattered2.png");
|
||||
state = SDMakeState(texture_path, "scattered2.png", "scattered2_n.png" );
|
||||
layer_states[SD_CLOUD_SCATTERED2] = state;
|
||||
layer_states2[SD_CLOUD_SCATTERED2] = state;
|
||||
|
||||
state = SDMakeState(texture_path, "many.png");
|
||||
state = SDMakeState(texture_path, "many.png", "many_n.png");
|
||||
layer_states[SD_CLOUD_MANY] = state;
|
||||
layer_states2[SD_CLOUD_MANY] = state;
|
||||
|
||||
state = SDMakeState(texture_path, "many2.png");
|
||||
state = SDMakeState(texture_path, "many2.png", "many2_n.png" );
|
||||
layer_states[SD_CLOUD_MANY2] = state;
|
||||
layer_states2[SD_CLOUD_MANY2] = state;
|
||||
|
||||
state = SDMakeState(texture_path, "few.png");
|
||||
state = SDMakeState(texture_path, "few.png", "few_n.png");
|
||||
layer_states[SD_CLOUD_FEW] = state;
|
||||
layer_states2[SD_CLOUD_FEW] = state;
|
||||
|
||||
state = SDMakeState(texture_path, "few2.png");
|
||||
state = SDMakeState(texture_path, "few2.png", "few2_n.png");
|
||||
layer_states[SD_CLOUD_FEW2] = state;
|
||||
layer_states2[SD_CLOUD_FEW2] = state;
|
||||
|
||||
state = SDMakeState(texture_path, "cirrus.png");
|
||||
state = SDMakeState(texture_path, "cirrus.png", "cirrus_n.png");
|
||||
layer_states[SD_CLOUD_CIRRUS] = state;
|
||||
layer_states2[SD_CLOUD_CIRRUS] = state;
|
||||
|
||||
state = SDMakeState(texture_path, "cirrus2.png");
|
||||
state = SDMakeState(texture_path, "cirrus2.png", "cirrus2_n.png");
|
||||
layer_states[SD_CLOUD_CIRRUS2] = state;
|
||||
layer_states2[SD_CLOUD_CIRRUS2] = state;
|
||||
|
||||
|
@ -474,7 +472,7 @@ bool SDCloudLayer::repaint( const osg::Vec3f &fog_color )
|
|||
= dynamic_cast<osg::TexEnvCombine*>(layer_root->getStateSet()
|
||||
->getTextureAttribute(1, osg::StateAttribute::TEXENV));
|
||||
combiner->setConstantColor(combineColor);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue