本文整理汇总了C++中LightSource::setStateSetModes方法的典型用法代码示例。如果您正苦于以下问题:C++ LightSource::setStateSetModes方法的具体用法?C++ LightSource::setStateSetModes怎么用?C++ LightSource::setStateSetModes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LightSource
的用法示例。
在下文中一共展示了LightSource::setStateSetModes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createLightSource
LightSource* ChessUtils::createLightSource(StateSet* stateSet, int lightNumber,
Vec4 position, Vec3 direction,
float spotCutoff, float spotExponent,
float constanteAttenuation,
Vec4 ambientLight, Vec4 diffuseLight, Vec4 specularLight) {
Light* light = new Light();
light->setLightNum(lightNumber);
light->setPosition(position);
light->setDirection(direction);
light->setAmbient(ambientLight);
light->setDiffuse(diffuseLight);
light->setSpecular(specularLight);
light->setConstantAttenuation(constanteAttenuation);
light->setSpotCutoff(spotCutoff);
light->setSpotExponent(spotExponent);
LightSource* lightS = new LightSource();
lightS->setLight(light);
lightS->setLocalStateSetModes(osg::StateAttribute::ON);
lightS->setStateSetModes(*stateSet, osg::StateAttribute::ON);
return lightS;
}
示例2: createUniverse
Node* Universe::createUniverse() {
// we need the scene's state set to enable the light for the entire scene
Group *scene = new Group();
lightStateSet = scene->getOrCreateStateSet();
lightStateSet->ref();
// create a light
LightSource *lightSource = new LightSource();
lightSource->setLight(createLight(Vec4(0.9, 0.9, 0.9, 1.0)));
// enable the light for the entire scene
lightSource->setLocalStateSetModes(StateAttribute::ON);
lightSource->setStateSetModes(*lightStateSet, StateAttribute::ON);
lightTransform = new PositionAttitudeTransform();
lightTransform->addChild(lightSource);
lightTransform->setPosition(Vec3(3, 0, 0));
// create objects
try {
CrfGeometry* crfGeometry = new CrfGeometry();
// Stars
Material *material = new Material();
material->setEmission(Material::FRONT, Vec4(1.0, 1.0, 1.0, 1.0));
material->setAmbient(Material::FRONT, Vec4(1.0, 1.0, 1.0, 1.0));
material->setShininess(Material::FRONT, 25.0);
crfGeometry->prepareMaterial(material);
if(_starfield_enabled) {
for (int i = 0; i < 6; i++) {
starField[i] = crfGeometry->createPlane(_diameter, "./textures/stars.jpg", true);
scene->addChild(starField[i]);
}
this->positionStarField();
}
if(_spacewarp_enabled)
scene->addChild(this->createSpacewarp());
// sun
crfGeometry->prepareMaterial(material);
sun = crfGeometry->createSphere(300, "./textures/sunmap.jpg", false);
// planets
Material *material2 = new Material();
material2->setEmission(Material::FRONT, Vec4(0.1, 0.1, 0.1, 1.0));
crfGeometry->prepareMaterial(material2);
mercury= crfGeometry->createSphere(3.8, "./textures/mercurymap.jpg", false);
venus = crfGeometry->createSphere(9.5, "./textures/venusmap.jpg", false);
earth = crfGeometry->createSphere(10, "./textures/earthmap1k.jpg", false);
emoon = crfGeometry->createSphere(2, "./textures/moonmap1k.jpg", false);
mars = crfGeometry->createSphere(5.3, "./textures/mars_1k_color.jpg", false);
jupiter = crfGeometry->createSphere(109, "./textures/jupitermap.jpg", false);
saturn = crfGeometry->createSphere(91, "./textures/saturnmap.jpg", false);
} catch (char *e) {
std::cerr << e;
}
lightTransform->addChild(sun);
scene->addChild(lightTransform);
scene->addChild(mercury);
scene->addChild(venus);
earth->addChild(emoon);
scene->addChild(earth);
scene->addChild(mars);
scene->addChild(jupiter);
scene->addChild(saturn);
return scene;
}