当前位置: 首页>>代码示例>>C++>>正文


C++ LightSource::setLight方法代码示例

本文整理汇总了C++中LightSource::setLight方法的典型用法代码示例。如果您正苦于以下问题:C++ LightSource::setLight方法的具体用法?C++ LightSource::setLight怎么用?C++ LightSource::setLight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LightSource的用法示例。


在下文中一共展示了LightSource::setLight方法的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;
}
开发者ID:carlosmccosta,项目名称:AR-Chess,代码行数:23,代码来源:ChessUtils.cpp

示例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;
}
开发者ID:bhulliger,项目名称:CRF,代码行数:75,代码来源:Universe.cpp


注:本文中的LightSource::setLight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。