本文整理汇总了C++中Pnt3f::normalize方法的典型用法代码示例。如果您正苦于以下问题:C++ Pnt3f::normalize方法的具体用法?C++ Pnt3f::normalize怎么用?C++ Pnt3f::normalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pnt3f
的用法示例。
在下文中一共展示了Pnt3f::normalize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: originalGazePos
void C3DSLoader::Draw(Pnt3f pos0,Pnt3f pos1, Pnt3f orient, float scale)
{
Pnt3f originalGazePos(-pos0.x,-pos0.y,-pos0.z);
Pnt3f newGazePos(pos1.x-pos0.x,pos1.y-pos0.y,pos1.z-pos0.z);
originalGazePos.normalize();
newGazePos.normalize();
orient.normalize();
float productValue = originalGazePos.x * newGazePos.x + originalGazePos.y * newGazePos.y + originalGazePos.z * newGazePos.z;
float cosValue = productValue / 1;
float angle = acos(cosValue) * 180 / M_PI;
//glPushMatrix();
//glRotatef(angle, 0,1,0);
glPushAttrib(GL_CURRENT_BIT);
glDisable(GL_TEXTURE_2D);
for(int i = 0; i < m_3DModel.numOfObjects; i++)
{
if(m_3DModel.pObject.size() <= 0)
break;
t3DObject *pObject = &m_3DModel.pObject[i];
if(pObject->bHasTexture)
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_textures[pObject->materialID]);
}
else
glDisable(GL_TEXTURE_2D);
glColor3ub(255, 255, 255);
glBegin(GL_TRIANGLES);
for(int j = 0; j < pObject->numOfFaces; j++)
{for(int tex = 0; tex < 3; tex++)
{
int index = pObject->pFaces[j].vertIndex[tex];
glNormal3f(pObject->pNormals[index].x,pObject->pNormals[index].y,
pObject->pNormals[index].z);
if(pObject->bHasTexture)
{
if(pObject->pTexVerts)
glTexCoord2f(pObject->pTexVerts[index].x,pObject->pTexVerts[index].y);
}
else
{
if(m_3DModel.pMaterials.size() && pObject->materialID>= 0)
{
BYTE *pColor = m_3DModel.pMaterials[pObject->materialID].color;
glColor3ub(pColor[0],pColor[1],pColor[2]);
}
}
//gluLookAt(pos0.x, pos0.y, pos0.z, pos1.x, pos1.y, pos1.z, 0, 1, 0);
glVertex3f(pObject->pVerts[index].x + pos0.x, pObject->pVerts[index].y + pos0.y, pObject->pVerts[index].z + pos0.z);
}
}
glEnd();
}
glEnable(GL_TEXTURE_2D);
glPopAttrib();
//glPopMatrix();
}