示例#1
0
文件: Materials.cpp 项目: istee/cor3d
GLvoid Material::SetDiffuseColor(GLenum face, const Color4& c)
{
    switch (face)
    {
    case GL_FRONT:
        _front_diffuse.r() = c.r();
        _front_diffuse.g() = c.g();
        _front_diffuse.b() = c.b();
        _front_diffuse.a() = c.a();
    break;

    case GL_BACK:
        _back_diffuse.r() = c.r();
        _back_diffuse.g() = c.g();
        _back_diffuse.b() = c.b();
        _back_diffuse.a() = c.a();
    break;

    case GL_FRONT_AND_BACK:
        _front_diffuse.r() = c.r();
        _front_diffuse.g() = c.g();
        _front_diffuse.b() = c.b();
        _front_diffuse.a() = c.a();

        _back_diffuse.r() = c.r();
        _back_diffuse.g() = c.g();
        _back_diffuse.b() = c.b();
        _back_diffuse.a() = c.a();
    break;
    }
}
示例#2
0
文件: Materials.cpp 项目: istee/cor3d
GLvoid Material::SetSpecularColor(GLenum face, const Color4& c)
{
    switch (face)
    {
    case GL_FRONT:
        _front_specular.r() = c.r();
        _front_specular.g() = c.g();
        _front_specular.b() = c.b();
        _front_specular.a() = c.a();
    break;

    case GL_BACK:
        _back_specular.r() = c.r();
        _back_specular.g() = c.g();
        _back_specular.b() = c.b();
        _back_specular.a() = c.a();
    break;

    case GL_FRONT_AND_BACK:
        _front_specular.r() = c.r();
        _front_specular.g() = c.g();
        _front_specular.b() = c.b();
        _front_specular.a() = c.a();

        _back_specular.r() = c.r();
        _back_specular.g() = c.g();
        _back_specular.b() = c.b();
        _back_specular.a() = c.a();
    break;
    }
}
示例#3
0
// ----------------------------------------------------------------
//	Name:			renderRectangle
//	Description:	根据参数TRectanglef提供的参数绘制矩形
//	Return Value:	void
// ----------------------------------------------------------------
void Helper::renderRectangle( const TRectanglef& rect, 
							 Color4 color, bool isEmpty )
{
	float left = rect.m_Left;
	float right = rect.m_Right;
	float bottom = rect.m_Bottom;
	float top = rect.m_Top;

	glPushMatrix();
	{	
		glColor4f( color.r(), color.g(), color.b(), color.a() );
		glLineWidth(2.0);
		if( isEmpty ) 
		{
			glBegin(GL_LINE_STRIP);
			glVertex3f(left, bottom, 0.0);
			glVertex3f(right, bottom, 0.0);
			glVertex3f(right, top, 0.0);
			glVertex3f(left, top, 0.0);
			glVertex3f(left, bottom, 0.0);
			glEnd();
		}
		else
		{
			glBegin(GL_QUADS);
			glVertex3f(left, bottom, 0.0);
			glVertex3f(right, bottom, 0.0);
			glVertex3f(right, top, 0.0);
			glVertex3f(left, top, 0.0);
			glEnd();
		}
		glLineWidth(1.0);
	} glPopMatrix();
}
示例#4
0
// ----------------------------------------------------------------
//	Name:			renderBox
//	Description:	根据参数Box提供的参数绘制box线框
//	Return Value:	void
// ----------------------------------------------------------------
void Helper::renderBox(const Box3f& box, Color4 color)
{
	glPushMatrix();
	{
		glColor4f( color.r(), color.g(), color.b(), color.a() );
		ColorCube::renderColorCube( box );
	} glPopMatrix();
}
示例#5
0
 Color4ub toColor4ub(const Color4& _color)
 {
   using gex::color::clamp;
   return Color4ub(
       clamp(int(255*_color.r()),0,255),
       clamp(int(255*_color.g()),0,255),
       clamp(int(255*_color.b()),0,255),
       clamp(int(255*_color.a()),0,255));
 }
示例#6
0
// ----------------------------------------------------------------
//	Name:			renderElipse
//	Description:	根据参数TRectanglef提供的参数绘制椭圆
//	Return Value:	void
// ----------------------------------------------------------------
void Helper::renderElipse( const TRectanglef& rect, 
						  Color4 color, bool isEmpty )
{
	float xpos = rect.GetCenter().x();
	float ypos = rect.GetCenter().y();

	float xradius = rect.GetSize().x() / 2;
	float yradius = rect.GetSize().y() / 2;

	const float DEG2RAD = 3.14159/180;

	glPushMatrix();
	{
		glColor4f( color.r(), color.g(), color.b(), color.a() );
		glLineWidth(5.0);
		if( isEmpty )
		{
			glBegin(GL_LINE_LOOP);   
			for (int i=0; i<360; i++)   
			{   
				//convert   degrees   into   radians   
				float degInRad = i*DEG2RAD;   
				glVertex2f( xpos + cos(degInRad) * xradius, ypos + sin(degInRad) * yradius );   
			}   
			glEnd();   
		}
		else
		{
			glBegin(GL_TRIANGLE_FAN);
			glVertex2f(xpos, ypos);
			//draw the vertex on the contour of the circle
			for(int i = 0; i < 360; i++)
			{	
				float degInRad = i*DEG2RAD;   
				glVertex2f( xpos + cos(degInRad) * xradius, ypos + sin(degInRad) * yradius );
			}
			glVertex2f( 1.0 * xradius + xpos, 0.0 *yradius + ypos );
			glEnd();
		}
		glLineWidth(1.0);
	}glPopMatrix();
}
示例#7
0
static std::string Color_str(const Color4& c)
{
  return stringf("<rgba: %.2f %.2f %.2f %.2f>",
                 c.r(), c.g(), c.b(), c.a());
}
示例#8
0
文件: Materials.cpp 项目: istee/cor3d
GLvoid Material::SetAmbientColor(GLenum face, const Color4& c)
{
    SetAmbientColor(face, c.r(), c.g(), c.b(), c.a());
}