本文整理汇总了C++中LightSource::CalculateLight方法的典型用法代码示例。如果您正苦于以下问题:C++ LightSource::CalculateLight方法的具体用法?C++ LightSource::CalculateLight怎么用?C++ LightSource::CalculateLight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LightSource
的用法示例。
在下文中一共展示了LightSource::CalculateLight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void WorldObject::Draw(Camera* camera)
{
glMatrixMode(GL_MODELVIEW);
camera->LoadMatrix();
glTranslatef(this->position.x, this->position.y, this->position.z);
glRotatef(this->rotation.z, 0, 0, 1.0f);
glRotatef(this->rotation.y, 0, 1.0f, 0);
glRotatef(this->rotation.x, 1.f, 0, 0);
glScalef(this->scale, this->scale, this->scale);
glBegin(GL_TRIANGLES);
for(int i = 0; i < this->faceCount; i++)
{
modelFace face = this->faces[i];
vector3 v1 = this->vertices[face.v1];
vector3 v2 = this->vertices[face.v2];
vector3 v3 = this->vertices[face.v3];
vector3 transformedv1 = this->GetTransformedVertex(face.v1);
vector3 transformedv2 = this->GetTransformedVertex(face.v2);
vector3 transformedv3 = this->GetTransformedVertex(face.v3);
vector3 v1norm = this->GetVertexNormal(face.v1);
vector3 v2norm = this->GetVertexNormal(face.v2);
vector3 v3norm = this->GetVertexNormal(face.v3);
vector3 v1Color = { 0, 0, 0 };
vector3 v2Color = { 0, 0, 0 };
vector3 v3Color = { 0, 0, 0 };
std::vector<LightSource*> lightSources = this->world->GetLightSources();
for(int i = 0; i < lightSources.size(); i++)
{
LightSource* ls = lightSources[i];
vector3 v1LightColor = ls->CalculateLight(this, transformedv1, v1norm, camera);
vector3 v2LightColor = ls->CalculateLight(this, transformedv2, v2norm, camera);
vector3 v3LightColor = ls->CalculateLight(this, transformedv3, v3norm, camera);
v1Color.x += v1LightColor.x;
v1Color.y += v1LightColor.y;
v1Color.z += v1LightColor.z;
v2Color.x += v2LightColor.x;
v2Color.y += v2LightColor.y;
v2Color.z += v2LightColor.z;
v3Color.x += v3LightColor.x;
v3Color.y += v3LightColor.y;
v3Color.z += v3LightColor.z;
}
glColor3f(v1Color.x, v1Color.y, v1Color.z);
glVertex3f(v1.x, v1.y, v1.z);
glColor3f(v2Color.x, v2Color.y, v2Color.z);
glVertex3f(v2.x, v2.y, v2.z);
glColor3f(v3Color.x, v3Color.y, v3Color.z);
glVertex3f(v3.x, v3.y, v3.z);
}
glEnd();
this->transformedNormalsAreValid = true;
}