本文整理汇总了C++中DynamicObject::releaseNormalDataPtr方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicObject::releaseNormalDataPtr方法的具体用法?C++ DynamicObject::releaseNormalDataPtr怎么用?C++ DynamicObject::releaseNormalDataPtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicObject
的用法示例。
在下文中一共展示了DynamicObject::releaseNormalDataPtr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void Cal3dModel::renderMesh(bool useTextures, bool useLighting, bool select_mode) {
// get the renderer of the model
CalRenderer *pCalRenderer = m_calModel->getRenderer();
assert(pCalRenderer != NULL);
// We let open gl do this, so no need to do it twice
pCalRenderer->setNormalization(false);
// begin the rendering loop
if (!pCalRenderer->beginRendering()) {
// Some kind of error here!
return;
}
// get the number of meshes
int meshCount = pCalRenderer->getMeshCount();
int numSubMeshes = 0;
for (int i = 0; i < meshCount; ++i) {
numSubMeshes += pCalRenderer->getSubmeshCount(i);
}
m_dos.resize(numSubMeshes);
int counter = -1;
// render all meshes of the model
for(int meshId = 0; meshId < meshCount; ++meshId) {
// get the number of submeshes
int submeshCount = pCalRenderer->getSubmeshCount(meshId);
// render all submeshes of the mesh
for(int submeshId = 0; submeshId < submeshCount; ++submeshId) {
// select mesh and submesh for further data access
if(pCalRenderer->selectMeshSubmesh(meshId, submeshId)) {
DynamicObject* dyno = m_dos[++counter];
if (!dyno) {
dyno = new DynamicObject();
dyno->init();
dyno->contextCreated();
m_dos[counter] = dyno;
// Lets assume this doesn't change
static unsigned char meshColor[4];
static float ambient[4];
static float diffuse[4];
static float specular[4];
static float shininess;
pCalRenderer->getAmbientColor(&meshColor[0]);
ambient[0] = meshColor[0] / 255.0f;
ambient[1] = meshColor[1] / 255.0f;
ambient[2] = meshColor[2] / 255.0f;
ambient[3] = meshColor[3] / 255.0f;
dyno->setAmbient(ambient);
// set the material diffuse color
pCalRenderer->getDiffuseColor(&meshColor[0]);
diffuse[0] = meshColor[0] / 255.0f;
diffuse[1] = meshColor[1] / 255.0f;
diffuse[2] = meshColor[2] / 255.0f;
diffuse[3] = 1.0f;//meshColor[3] / 255.0f;
dyno->setDiffuse(diffuse);
// set the material specular color
pCalRenderer->getSpecularColor(&meshColor[0]);
specular[0] = meshColor[0] / 255.0f;
specular[1] = meshColor[1] / 255.0f;
specular[2] = meshColor[2] / 255.0f;
specular[3] = meshColor[3] / 255.0f;
dyno->setSpecular(specular);
dyno->setEmission(0.0f, 0.0f, 0.0f,0.0f);
shininess = pCalRenderer->getShininess();
dyno->setShininess(shininess);
dyno->getMatrix().rotateZ(-m_rotate / 180.0 * WFMath::Pi);
dyno->setState(m_state);
dyno->setSelectState(m_select_state);
dyno->setUseStencil(m_use_stencil);
}
// get the transformed vertices of the submesh
int vertexCount = pCalRenderer->getVertexCount();
bool realloc = false;
float *vertex_ptr, *normal_ptr, *texture_ptr;
int textureCoordinateCount = 0;
if (vertexCount > dyno->getNumPoints()) {
realloc = true;
vertex_ptr = dyno->createVertexData(vertexCount * 3);
pCalRenderer->getVertices(vertex_ptr);
dyno->releaseVertexDataPtr();
normal_ptr = dyno->createNormalData(vertexCount * 3);
pCalRenderer->getNormals(normal_ptr);
dyno->releaseNormalDataPtr();
} else {
vertex_ptr = dyno->getVertexDataPtr();
//.........这里部分代码省略.........