本文整理汇总了C++中SubMesh::getBoundingBox方法的典型用法代码示例。如果您正苦于以下问题:C++ SubMesh::getBoundingBox方法的具体用法?C++ SubMesh::getBoundingBox怎么用?C++ SubMesh::getBoundingBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SubMesh
的用法示例。
在下文中一共展示了SubMesh::getBoundingBox方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateSkinning
void FixedRenderer::updateSkinning(Mesh * mesh, Armature * armature)
{
unsigned int s;
unsigned int sSize = mesh->getSubMeshsNumber();
for(s=0; s<sSize; s++)
{
SubMesh * subMesh = &mesh->getSubMeshs()[s];
// data
Vector3 * vertices = subMesh->getVertices();
if(! vertices)
continue;
SkinData * skinData = subMesh->getSkinData();
if(armature && skinData)
{
unsigned int verticesSize = subMesh->getVerticesSize();
Vector3 * skinVertices = getVertices(verticesSize);
computeSkinning(armature, skinData, vertices, NULL, NULL, skinVertices, NULL, NULL);
subMesh->getBoundingBox()->initFromPoints(skinVertices, verticesSize);
}
}
mesh->updateBoundingBox();
}
示例2: createSubMesh
//.........这里部分代码省略.........
if(nodeMesh->mTangents)
{
Vector3 * tangents = subMesh->allocTangents(nodeMesh->mNumVertices);
for(i=0; i<nodeMesh->mNumVertices; i++)
tangents[i] = matrix.getRotatedVector3(Vector3(nodeMesh->mTangents[i].x, nodeMesh->mTangents[i].y, nodeMesh->mTangents[i].z)).getNormalized();
}
// colors
if(nodeMesh->mColors[0])
{
Color * colors = subMesh->allocColors(nodeMesh->mNumVertices);
for(i=0; i<nodeMesh->mNumVertices; i++)
colors[i] = Color(nodeMesh->mColors[0][i].r, nodeMesh->mColors[0][i].g, nodeMesh->mColors[0][i].b, nodeMesh->mColors[0][i].a);
}
// uvcoords
{
unsigned int t, nb_texLayers = 0;
for(t=0; t<AI_MAX_NUMBER_OF_TEXTURECOORDS; t++)
{
if(nodeMesh->mTextureCoords[t])
nb_texLayers++;
}
Vector2 * uvCoords = subMesh->allocTexCoords(nodeMesh->mNumVertices*nb_texLayers);
nb_texLayers = 0;
for(t=0; t<AI_MAX_NUMBER_OF_TEXTURECOORDS; t++)
{
if(nodeMesh->mTextureCoords[t])
{
unsigned int offset = nodeMesh->mNumVertices*nb_texLayers;
subMesh->setMapChannelOffset(t, offset);
for(i=0; i<nodeMesh->mNumVertices; i++){
uvCoords[offset+i] = Vector2(nodeMesh->mTextureCoords[t][i].x, 1-nodeMesh->mTextureCoords[t][i].y);
}
nb_texLayers++;
}
}
}
// indices
{
unsigned int f;
if(nodeMesh->mNumVertices < 65536)
{
unsigned short * indices = (unsigned short *)subMesh->allocIndices(nodeMesh->mNumFaces*3, VAR_USHORT);
for(f=0; f<nodeMesh->mNumFaces; f++)
{
aiFace * face = &nodeMesh->mFaces[f];
for(i=0; i<3; i++){
indices[f*3+i] = face->mIndices[i];
}
}
}
else
{
unsigned int * indices = (unsigned int *)subMesh->allocIndices(nodeMesh->mNumFaces*3, VAR_UINT);
for(f=0; f<nodeMesh->mNumFaces; f++)
{
aiFace * face = &nodeMesh->mFaces[f];
for(i=0; i<3; i++){
indices[f*3+i] = face->mIndices[i];
}
}
}
}
// bones
initBones(scene, nodeMesh, mesh, subMesh);
// display
subMesh->allocDisplays(1);
MaterialDisplay * display = subMesh->addNewDisplay(PRIMITIVE_TRIANGLES, 0, subMesh->getIndicesSize());
display->setMaterial(mesh->getMaterial(nodeMesh->mMaterialIndex));
// cull mode
int twosided = 0;
aiMaterial * mtl = scene->mMaterials[nodeMesh->mMaterialIndex];
if(AI_SUCCESS == aiGetMaterialInteger(mtl, AI_MATKEY_TWOSIDED, &twosided))
{
if(twosided != 0)
display->setCullMode(CULL_NONE);
}
// bounding box
subMesh->getBoundingBox()->initFromPoints(vertices, subMesh->getVerticesSize());
(*count)++;
}
for(unsigned int n=0; n<nd->mNumChildren; n++)
createSubMesh(scene, nd->mChildren[n], mesh, subMeshs, count, matrix);
}
示例3: drawScene
void FixedRenderer::drawScene(Scene * scene, OCamera * camera)
{
struct MEntityLight
{
Box3d lightBox;
OLight * light;
};
struct MSubMeshPass
{
unsigned int subMeshId;
unsigned int lightsNumber;
Object3d * object;
OLight * lights[4];
};
// sub objects
#define MAX_TRANSP_SUBOBJ 4096
static int transpList[MAX_TRANSP_SUBOBJ];
static float transpZList[MAX_TRANSP_SUBOBJ];
static MSubMeshPass transpSubObjs[MAX_TRANSP_SUBOBJ];
// lights list
#define MAX_ENTITY_LIGHTS 256
static int entityLightsList[MAX_ENTITY_LIGHTS];
static float entityLightsZList[MAX_ENTITY_LIGHTS];
static MEntityLight entityLights[MAX_ENTITY_LIGHTS];
// get render
RenderingContext * render = NeoEngine::getInstance()->getRenderingContext();
render->enableLighting();
render->enableBlending();
// make frustum
Frustum * frustum = camera->getFrustum();
frustum->makeVolume(camera);
// update visibility
updateVisibility(scene, camera);
// fog
enableFog(camera);
// camera
Vector3 cameraPos = camera->getTransformedPosition();
// transp sub obj number
unsigned int transpSubObsNumber = 0;
// lights
unsigned int l;
unsigned int lSize = scene->getLightsNumber();
// entities
unsigned int i;
unsigned int eSize = scene->getEntitiesNumber();
for(i=0; i<eSize; i++)
{
// get entity
OEntity * entity = scene->getEntityByIndex(i);
Mesh * mesh = entity->getMesh();
if(! entity->isActive())
continue;
if(! entity->isVisible())
{
if(mesh)
{
Armature * armature = mesh->getArmature();
ArmatureAnim * armatureAnim = mesh->getArmatureAnim();
if(armature)
{
// animate armature
if(mesh->getArmature())
{
Armature * armature = mesh->getArmature();
if(mesh->getArmatureAnim())
{
animateArmature(
mesh->getArmature(),
mesh->getArmatureAnim(),
entity->getCurrentFrame()
);
}
else
{
armature->processBonesLinking();
armature->updateBonesSkinMatrix();
}
}
// TODO : optimize and add a tag to desactivate it
updateSkinning(mesh, armature);
(*entity->getBoundingBox()) = (*mesh->getBoundingBox());
}
}
//.........这里部分代码省略.........