本文整理汇总了C++中Mat4f::storeIdentity方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat4f::storeIdentity方法的具体用法?C++ Mat4f::storeIdentity怎么用?C++ Mat4f::storeIdentity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat4f
的用法示例。
在下文中一共展示了Mat4f::storeIdentity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderQuaxolsIndividually
void Scene::RenderQuaxolsIndividually(Camera* pCamera, Shader* pShader) {
if(!m_pQuaxolMesh) return;
WasGLErrorPlusPrint();
pShader->StartUsing();
pShader->SetCameraParams(pCamera);
WasGLErrorPlusPrint();
Mat4f worldMatrix;
worldMatrix.storeIdentity();
pShader->SetOrientation(&worldMatrix);
WasGLErrorPlusPrint();
GLint hTex0 = pShader->getUniform("texDiffuse0");
WasGLErrorPlusPrint();
if (hTex0 != -1) {
SetTexture(0, hTex0);
}
for (auto quaxol : m_quaxols) {
const QuaxolSpec& q = quaxol;
float shift_amount = 10.0f;
Vec4f shift;
shift.x = shift_amount * q.x;
shift.y = shift_amount * q.y;
shift.z = shift_amount * q.z;
shift.w = shift_amount * q.w;
pShader->SetPosition(&shift);
WasGLErrorPlusPrint();
if (m_texList.size() > 0) {
int layerTexIndex = abs(q.w) % m_texList.size();
SetTexture(layerTexIndex, hTex0);
}
int tesseractTris = m_pQuaxolMesh->getNumberTriangles();
int startTriangle = 0;
int endTriangle = tesseractTris;
WasGLErrorPlusPrint();
GLuint colorHandle = pShader->GetColorHandle();
glBegin(GL_TRIANGLES);
//WasGLErrorPlusPrint();
Vec4f a, b, c;
int colorIndex = abs(q.w) % m_colorArray.size();
for (int t = startTriangle; t < endTriangle && t < tesseractTris; t++) {
if(colorHandle != -1) {
glVertexAttrib4fv(colorHandle,
m_colorArray[colorIndex].raw());
}
//WasGLErrorPlusPrint();
m_pQuaxolMesh->getTriangle(t, a, b, c);
glVertex4fv(a.raw());
glVertex4fv(b.raw());
glVertex4fv(c.raw());
//WasGLErrorPlusPrint();
//if ((t+1) % 2 == 0) {
// colorIndex = (colorIndex + 1) % m_colorArray.size();
//}
}
//WasGLErrorPlusPrint();
glEnd();
WasGLErrorPlusPrint();
}
pShader->StopUsing();
}
示例2: RenderQuaxolChunk
void Scene::RenderQuaxolChunk(Camera* pCamera, Shader* pShader) {
if(!m_pQuaxolChunk) return;
WasGLErrorPlusPrint();
pShader->StartUsing();
pShader->SetCameraParams(pCamera);
Mat4f worldMatrix;
worldMatrix.storeIdentity();
pShader->SetOrientation(&worldMatrix);
WasGLErrorPlusPrint();
if (m_pQuaxolAtlas) {
GLint hTex0 = pShader->getUniform("texDiffuse0");
if (hTex0 != -1) {
glActiveTexture(GL_TEXTURE0);
WasGLErrorPlusPrint();
glBindTexture(GL_TEXTURE_2D, m_pQuaxolAtlas->GetTextureID());
//WasGLErrorPlusPrint();
// glUniform1i(hTex0, 0);
}
}
GLint hTexCoord = glGetAttribLocation(pShader->getProgramId(), "vertCoord");
//GLint hTexCoord = pShader->getAttrib("vertCoord");
static Vec4f zero(0,0,0,0);
pShader->SetPosition(&zero);
GLuint colorHandle = pShader->GetColorHandle();
glBegin(GL_TRIANGLES);
// TODO: use vbo, as we have already done the work to put things into
// a nice format.
IndexList& indices = m_pQuaxolChunk->m_indices;
VecList& verts = m_pQuaxolChunk->m_verts;
QVertList& packVerts = m_pQuaxolChunk->m_packVerts;
int numTris = (int)indices.size() / 3;
int currentIndex = 0;
for (int tri = 0; tri < numTris; ++tri) {
const QuaxolVert& vA = packVerts[indices[currentIndex]];
const Vec4f& a = verts[indices[currentIndex++]];
const QuaxolVert& vB = packVerts[indices[currentIndex]];
const Vec4f& b = verts[indices[currentIndex++]];
const QuaxolVert& vC = packVerts[indices[currentIndex]];
const Vec4f& c = verts[indices[currentIndex++]];
if (colorHandle != -1) {
float minW = (std::min)(a.w, (std::min)(b.w, c.w));
int colorIndex = ((int)abs(minW)) % m_colorArray.size();
glVertexAttrib4fv(colorHandle, m_colorArray[colorIndex].raw());
}
if (hTexCoord != -1) {
const float invTexSteps = 1.0f / 16.0f;
int firstTriOffset = tri % 2;
glVertexAttrib2f(hTexCoord,
(float)((vA._uvInd % 8) + 0) * invTexSteps,
(float)((vA._uvInd / 8) + firstTriOffset) * invTexSteps);
glVertex4fv(a.raw());
glVertexAttrib2f(hTexCoord,
(float)((vB._uvInd % 8) + 1) * invTexSteps,
(float)((vB._uvInd / 8) + 0) * invTexSteps);
glVertex4fv(b.raw());
glVertexAttrib2f(hTexCoord,
(float)((vC._uvInd % 8) + firstTriOffset) * invTexSteps,
(float)((vC._uvInd / 8) + 1) * invTexSteps);
glVertex4fv(c.raw());
} else {
glVertex4fv(a.raw());
glVertex4fv(b.raw());
glVertex4fv(c.raw());
}
}
glEnd();
pShader->StopUsing();
}