本文整理汇总了C++中SubModel::getAABoxBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ SubModel::getAABoxBounds方法的具体用法?C++ SubModel::getAABoxBounds怎么用?C++ SubModel::getAABoxBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SubModel
的用法示例。
在下文中一共展示了SubModel::getAABoxBounds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillSubModelArary
void fillSubModelArary(const ModelContainer* pModelContainer, const TreeNode *root, Array<SubModel>& array, Vector3& pLo, Vector3& pHi) {
Vector3 lo = Vector3(inf(), inf(), inf());
Vector3 hi = Vector3(-inf(), -inf(), -inf());
for(int i=0; i< root->getNValues(); i++) {
SubModel sm = pModelContainer->getSubModel(root->getStartPosition() + i);
lo = lo.min(sm.getAABoxBounds().low());
hi = hi.max(sm.getAABoxBounds().high());
array.append(sm);
}
if(root->getChild((TreeNode *) &pModelContainer->getTreeNode(0), 0)) {
fillSubModelArary(pModelContainer, root->getChild((TreeNode *)&pModelContainer->getTreeNode(0), 0), array, lo, hi);
}
if(root->getChild((TreeNode *)&pModelContainer->getTreeNode(0), 1)) {
fillSubModelArary(pModelContainer, root->getChild((TreeNode *)&pModelContainer->getTreeNode(0), 1), array, lo, hi);
}
float dist1 = (hi -lo).magnitude();
AABox b;
root->getBounds(b);
float dist2 = (b.high() -b.low()).magnitude();
if(dist1 > dist2) {
// error
int xxx = 0;
}
}
示例2: fillSubModelArary
void
fillSubModelArary (const ModelContainer* pModelContainer, const TreeNode *root, Array<SubModel>& array, Vector3& pLo, Vector3& pHi)
{
Vector3 lo = Vector3 (inf (), inf (), inf ());
Vector3 hi = Vector3 (-inf (), -inf (), -inf ());
//printf("[VMAP] %i Submodels\n", root->getNValues ());
for (int i = 0; i < root->getNValues (); i++)
{
SubModel sm = pModelContainer->getSubModel (root->getStartPosition () + i);
lo = lo.min (sm.getAABoxBounds ().low ());
hi = hi.max (sm.getAABoxBounds ().high ());
array.append (sm);
}
if (root->getChild ((TreeNode *) & pModelContainer->getTreeNode (0), 0))
{
fillSubModelArary (pModelContainer, root->getChild ((TreeNode *) & pModelContainer->getTreeNode (0), 0), array, lo, hi);
}
if (root->getChild ((TreeNode *) & pModelContainer->getTreeNode (0), 1))
{
fillSubModelArary (pModelContainer, root->getChild ((TreeNode *) & pModelContainer->getTreeNode (0), 1), array, lo, hi);
}
float dist1 = (hi - lo).magnitude ();
AABox b;
root->getBounds (b);
float dist2 = (b.high () - b.low ()).magnitude ();
if (dist1 > dist2)
{
// error
//printf("error in boundingbox size vs. hi-lo size.");
// this error seems to happen alot! maybe need to do something against it?
int xxx = 0;
}
}
示例3: getIntersectionTime
RealTime ModelContainer::getIntersectionTime(const Ray& pRay, bool pExitAtFirst, float pMaxDist) const
{
#ifdef _DEBUG_VMAPS
for(unsigned int i=0; i<getNSubModel(); i++)
{
SubModel model = getSubModel(i);
bool insiteOk;
Vector3 mynormal;
Vector3 location;
bool hitval = MyCollisionDetection::collisionLocationForMovingPointFixedAABox(
pRay.origin, pRay.direction,
model.getAABoxBounds(),
location,insiteOk, mynormal);
if(hitval)
{
float len2 = (location - pRay.origin).squaredLength();
int a = 0; // just to be able to set a breakpoint
}
}
TreeNode tn = getTreeNode(0);
for(int i=0; i<tn.getNValues(); i++)
{
SubModel mysm = getSubModel(tn.getStartPosition() + i);
AABox testbox = mysm.getAABoxBounds();
gBoxArray.append(AABox(testbox.low(), testbox.high()));
}
#endif
double firstDistance = inf();
Ray relativeRay = Ray::fromOriginAndDirection(pRay.origin - getBasePosition(), pRay.direction);
const IT end = endRayIntersection();
IT obj = beginRayIntersection(pRay, pMaxDist);
for ( ;obj != end; ++obj) // (preincrement is *much* faster than postincrement!)
{
/*
Call your accurate intersection test here. It is guaranteed
that the ray hits the bounding box of obj. (*obj) has type T,
so you can call methods directly using the "->" operator.
*/
SubModel const *model = &(*obj);
RealTime t = model->getIntersectionTime(pRay, pExitAtFirst, pMaxDist);
if(t > 0 && t < inf())
{
obj.markBreakNode();
if(firstDistance > t && pMaxDist >= t)
{
firstDistance = t;
if(pExitAtFirst) { break; }
}
}
}
return(firstDistance);
}
示例4: getViewPos
//===================================================
Vector3 getViewPos(const ModelContainer* mc, unsigned int pModelNr = 0) {
if(mc->getNSubModel() < pModelNr) {
pModelNr = mc->getNSubModel();
}
const SubModel sm = mc->getSubModel(pModelNr);
return (sm.getAABoxBounds().low());
}
示例5: 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);
}