Exemplo n.º 1
0
void ShapeNode::setLighting (int i)
{
	if (lightingEnabled==(bool)i) return;
	lightingEnabled = (bool)i;

	if (shapeGeode.valid() && !stateset->s_thing)
	{
		osg::StateSet *ss = shapeGeode->getOrCreateStateSet();
		if (lightingEnabled) ss->setMode( GL_LIGHTING, osg::StateAttribute::ON );
		else ss->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
	}

	BROADCAST(this, "si", "setLighting", getLighting());

}
Exemplo n.º 2
0
std::vector<lo_message> ShapeNode::getState () const
{
	// inherit state from base class
	std::vector<lo_message> ret = GroupNode::getState();

	lo_message msg;
	osg::Vec3 v;
	osg::Vec4 v4;

	//std::cout << "in getState. shape=" << shape << ", textureName=" << textureName << std::endl;

	msg = lo_message_new();
	lo_message_add(msg, "si", "setBillboard", getBillboard());
	ret.push_back(msg);
	
	msg = lo_message_new();
	v4 = this->getColor();
	lo_message_add(msg, "sffff", "setColor", v4.x(), v4.y(), v4.z(), v4.w());
	ret.push_back(msg);

	msg = lo_message_new();
	lo_message_add(msg,  "ss", "setTextureFromFile", texturePath.c_str());
	ret.push_back(msg);

	msg = lo_message_new();
	lo_message_add(msg,  "ss", "setStateSet", getStateSet());
	ret.push_back(msg);

	msg = lo_message_new();
	lo_message_add(msg, "si", "setRenderBin", getRenderBin());
	ret.push_back(msg);

	msg = lo_message_new();
	lo_message_add(msg, "si", "setLighting", getLighting());
	ret.push_back(msg);

	// put this one last:	
	msg = lo_message_new();
	lo_message_add(msg, "si", "setShape", getShape());
	ret.push_back(msg);

	return ret;
}
Exemplo n.º 3
0
color rayTrace(Ray &ray, int times)
{
	float t = (float)(~(1<<31));
    int iObjectIndex = 0;
    color c, cRefl;
    vect point;
	
    if(times < MAX_REFLECTION_TIMES_LIMIT)
    {
        if(rayIntersect(ray, iObjectIndex, t))
        {
            point = ray.d * t + ray.p0;
            Ray newRay= Ray(point, g_papoObjects[iObjectIndex]->getReflection((-1.0)*ray.d,point));
            cRefl = rayTrace(newRay, times + 1);
            c = getLighting(ray, point,iObjectIndex) *(1 - g_papoObjects[iObjectIndex]->reflPerc)  + g_papoObjects[iObjectIndex]->reflPerc * cRefl;
	    }
    }
	return c;
}