本文整理汇总了C++中SubModel::setBasePosition方法的典型用法代码示例。如果您正苦于以下问题:C++ SubModel::setBasePosition方法的具体用法?C++ SubModel::setBasePosition怎么用?C++ SubModel::setBasePosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SubModel
的用法示例。
在下文中一共展示了SubModel::setBasePosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillContainer
void ModelContainer::fillContainer(const AABSPTree<SubModel *>::Node& pNode, int &pSubModelPos, int &pTreeNodePos, int &pTrianglePos, Vector3& pLo, Vector3& pHi, Vector3& pFinalLo, Vector3& pFinalHi)
{
// TreeNode for the SubModel
TreeNode treeNode = TreeNode(pNode.valueArray.size(), pSubModelPos);
treeNode.setSplitAxis(pNode.splitAxis);
treeNode.setSplitLocation(pNode.splitLocation);
int currentTreeNodePos = pTreeNodePos++;
Vector3 lo = Vector3(inf(),inf(),inf());
Vector3 hi = Vector3(-inf(),-inf(),-inf());
for (int i=0; i<pNode.valueArray.size(); i++)
{
G3D::_AABSPTree::Handle<SubModel*>* h= pNode.valueArray[i];
SubModel *m = h->value;
memcpy(&getTreeNodes()[pTreeNodePos], &m->getTreeNode(0), sizeof(TreeNode) * m->getNNodes());
memcpy(&getTriangles()[pTrianglePos], &m->getTriangle(0), sizeof(TriangleBox) * m->getNTriangles());
SubModel newModel = SubModel(m->getNTriangles(), getTriangles(), pTrianglePos, m->getNNodes(), getTreeNodes(), pTreeNodePos);
newModel.setReletiveBounds(m->getReletiveBounds().getLo(), m->getReletiveBounds().getHi());
newModel.setBasePosition(m->getBasePosition());
iSubModel[pSubModelPos++] = newModel;
pTreeNodePos += m->getNNodes();
pTrianglePos += m->getNTriangles();
AABox box = m->getAABoxBounds();
lo = lo.min(box.low());
hi = hi.max(box.high());
pFinalLo = pFinalLo.min(lo);
pFinalHi = pFinalHi.max(hi);
}
/*
if(pNode.valueArray.size() == 0) {
int xxx = 0; // just for the breakpoint
}
*/
// get absolute bounds
if(pNode.child[0] != 0)
{
treeNode.setChildPos(0, pTreeNodePos);
fillContainer(*pNode.child[0], pSubModelPos, pTreeNodePos, pTrianglePos, lo, hi,pFinalLo,pFinalHi);
}
if(pNode.child[1] != 0)
{
treeNode.setChildPos(1, pTreeNodePos);
fillContainer(*pNode.child[1], pSubModelPos, pTreeNodePos, pTrianglePos, lo, hi,pFinalLo,pFinalHi);
}
pLo = pLo.min(lo);
pHi = pHi.max(hi);
treeNode.setBounds(lo,hi);
setTreeNode(treeNode, currentTreeNodePos);
}
示例2: readRawFile
//.........这里部分代码省略.........
}
// ---- indexes
if(fread(&blockId, 4, 1, rf) != 1) { fclose(rf); return(false); }
if(strcmp(blockId, "INDX") != 0) { fclose(rf); return(false); }
if(fread(&blocksize, sizeof(int), 1, rf) != 1) { fclose(rf); return(false); }
unsigned int nindexes;
if(fread(&nindexes, sizeof(uint32), 1, rf) != 1) { fclose(rf); return(false); }
if(nindexes >0)
{
unsigned short *indexarray = new unsigned short[nindexes*sizeof(unsigned short)];
if(fread(indexarray, sizeof(unsigned short), nindexes, rf) != nindexes) { fclose(rf); return(false); }
for(int i=0;i<(int)nindexes; i++)
{
unsigned short val = indexarray[i];
tempIndexArray.append(val);
}
delete indexarray;
}
// ---- vectors
if(fread(&blockId, 4, 1, rf) != 1) {fclose(rf); return(false); }
if(strcmp(blockId, "VERT") != 0) { fclose(rf); return(false); }
if(fread(&blocksize, sizeof(int), 1, rf) != 1) { fclose(rf); return(false); }
unsigned int nvectors;
if(fread(&nvectors, sizeof(int), 1, rf) != 1) { fclose(rf); return(false); }
float *vectorarray = 0;
if(nvectors >0)
{
vectorarray = new float[nvectors*sizeof(float)*3];
if(fread(vectorarray, sizeof(float)*3, nvectors, rf) != nvectors) { fclose(rf); return(false); }
}
// ----- liquit
if(flags & 0x00001000)
{
// we have liquit -> not handled yet ... skip
if(fread(&blockId, 4, 1, rf) != 1) { fclose(rf); return(false); }
if(strcmp(blockId, "LIQU") != 0) { fclose(rf); return(false); }
if(fread(&blocksize, sizeof(int), 1, rf) != 1) { fclose(rf); return(false); }
fseek(rf, blocksize, SEEK_CUR);
}
for(unsigned int i=0, indexNo=0; indexNo<nvectors; indexNo++)
{
Vector3 v = Vector3(vectorarray[i+2], vectorarray[i+1], vectorarray[i+0]);
i+=3;
v = pModelPosition.transform(v);
float swapy = v.y;
v.y = v.x;
v.x = swapy;
tempVertexArray.append(v);
}
// ---- calculate triangles
int rest = nindexes%3;
if(rest != 0)
{
nindexes -= rest;
}
for(unsigned int i=0;i<(nindexes);)
{
Triangle t = Triangle(tempVertexArray[tempIndexArray[i+2]], tempVertexArray[tempIndexArray[i+1]], tempVertexArray[tempIndexArray[i+0]] );
i+=3;
++trianglecount;
if(g>= startgroup && g <= endgroup)
{
gtree->insert(t);
}
}
if(vectorarray != 0)
{
delete vectorarray;
}
if(gtree->size() >0)
{
gtree->balance();
SubModel *sm = new SubModel(gtree);
sm->setIndoorFlag( isindoor );
#ifdef _ASSEMBLER_DEBUG
if(::g_df) fprintf(::g_df,"group trianglies: %d, Tris: %d, Nodes: %d, gtree.triangles: %d\n", g, sm->getNTriangles(), sm->getNNodes(), gtree->memberTable.size());
if(sm->getNTriangles() != gtree->memberTable.size())
{
if(::g_df) fprintf(::g_df,"ERROR !!!! group trianglies: %d, Tris: %d, Nodes: %d, gtree.triangles: %d\n", g, sm->getNTriangles(), sm->getNNodes(), gtree->memberTable.size());
}
#endif
sm->setBasePosition(pModelPosition.iPos);
pMainTree->insert(sm);
}
delete gtree;
}
fclose(rf);
result = true;
}
return(result);
}
示例3: readRawFile
//.........这里部分代码省略.........
for (int i=0;i<(int)nindexes; i++)
{
unsigned short val = indexarray[i];
tempIndexArray.append(val);
}
delete[] indexarray;
}
// ---- vectors
READ_OR_RETURN(&blockId, 4);
CMP_OR_RETURN(blockId, "VERT");
READ_OR_RETURN(&blocksize, sizeof(int));
unsigned int nvectors;
READ_OR_RETURN(&nvectors, sizeof(int));
float *vectorarray = 0;
// add vectorarray free
#undef READ_OR_RETURN
#undef CMP_OR_RETURN
#define READ_OR_RETURN(V,S) if (fread((V), (S), 1, rf) != 1) { \
fclose(rf); delete gtree; delete[] vectorarray; return(false); }
#define CMP_OR_RETURN(V,S) if (strcmp((V),(S)) != 0) { \
fclose(rf); delete gtree; delete[] vectorarray; return(false); }
if (nvectors >0)
{
vectorarray = new float[nvectors*sizeof(float)*3];
READ_OR_RETURN(vectorarray, nvectors*sizeof(float)*3);
}
// ----- liquit
if (flags & 1)
{
// we have liquit -> not handled yet ... skip
READ_OR_RETURN(&blockId, 4);
CMP_OR_RETURN(blockId, "LIQU");
READ_OR_RETURN(&blocksize, sizeof(int));
fseek(rf, blocksize, SEEK_CUR);
}
for (unsigned int i=0, indexNo=0; indexNo<nvectors; indexNo++)
{
Vector3 v = Vector3(vectorarray[i+2], vectorarray[i+1], vectorarray[i+0]);
i+=3;
v = pModelPosition.transform(v);
float swapy = v.y;
v.y = v.x;
v.x = swapy;
tempVertexArray.append(v);
}
// ---- calculate triangles
int rest = nindexes%3;
if (rest != 0)
{
nindexes -= rest;
}
for (unsigned int i=0;i<(nindexes);)
{
Triangle t = Triangle(tempVertexArray[tempIndexArray[i+2]], tempVertexArray[tempIndexArray[i+1]], tempVertexArray[tempIndexArray[i+0]] );
i+=3;
++trianglecount;
if (g>= startgroup && g <= endgroup)
{
gtree->insert(t);
}
}
// drop of temporary use defines
#undef READ_OR_RETURN
#undef CMP_OR_RETURN
if (vectorarray != 0)
{
delete vectorarray;
}
if (gtree->size() >0)
{
gtree->balance();
SubModel *sm = new SubModel(gtree);
#ifdef _ASSEMBLER_DEBUG
if (::g_df) fprintf(::g_df,"group trianglies: %d, Tris: %d, Nodes: %d, gtree.triangles: %d\n", g, sm->getNTriangles(), sm->getNNodes(), gtree->memberTable.size());
if (sm->getNTriangles() != gtree->memberTable.size())
{
if (::g_df) fprintf(::g_df,"ERROR !!!! group trianglies: %d, Tris: %d, Nodes: %d, gtree.triangles: %d\n", g, sm->getNTriangles(), sm->getNNodes(), gtree->memberTable.size());
}
#endif
sm->setBasePosition(pModelPosition.iPos);
pMainTree->insert(sm);
}
delete gtree;
}
fclose(rf);
return true;
}