本文整理汇总了C++中CAABBox::setCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ CAABBox::setCenter方法的具体用法?C++ CAABBox::setCenter怎么用?C++ CAABBox::setCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAABBox
的用法示例。
在下文中一共展示了CAABBox::setCenter方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// ***************************************************************************
bool CVisualCollisionMesh::build(const std::vector<CVector> &vertices, const std::vector<uint32> &triangles, CVertexBuffer &vbForShadowRender)
{
/* ***********************************************
* WARNING: This Class/Method must be thread-safe (ctor/dtor/serial): no static access for instance
* It can be loaded/called through CAsyncFileManager for instance
* ***********************************************/
uint i;
// if no vertices, or no triangles, abort
if(vertices.empty())
return false;
if(triangles.empty())
return false;
// vertices and triangles id are stored in uint16 form. so their should not be more than 65535*3 indices
if(vertices.size()>65535 || triangles.size()>65535*3)
return false;
// copy
_Vertices= vertices;
// compress indexes to 16 bits
_Triangles.resize(triangles.size());
for(i=0;i<_Triangles.size();i++)
_Triangles[i]= (uint16)triangles[i];
// Build the Local bbox for this col mesh
CAABBox localBBox;
localBBox.setCenter(vertices[0]);
for(i=1;i<vertices.size();i++)
localBBox.extend(vertices[i]);
// Build the Static Grid
uint numTris= (uint)triangles.size()/3;
_QuadGrid.create(16, numTris, localBBox);
// Add all triangles
for(i=0;i<numTris;i++)
{
CAABBox bb;
bb.setCenter(_Vertices[_Triangles[i*3+0]]);
bb.extend(_Vertices[_Triangles[i*3+1]]);
bb.extend(_Vertices[_Triangles[i*3+2]]);
_QuadGrid.add(i, bb);
}
// compile
_QuadGrid.compile();
// Keep a RefPtr on the AGP vertex Buffer for shadow receiving
_VertexBuffer= &vbForShadowRender;
return true;
}
示例2: checkAttack
bool CActor::checkAttack( CVectorD &pos )
{
/*
if we're close to an actor then attack them
*/
CAABBox box;
box.setCenter(CVector(_x*0.001f, _y*0.001f, 0.0f));
box.setHalfSize(CVector(5.0f, 5.0f, 1.0f));
CMoveManager::Grid.clearSelection();
CMoveManager::Grid.select(box);
CMoveManager::TObstacleGrid::CIterator it;
for (it=CMoveManager::Grid.begin(); it!=CMoveManager::Grid.end(); ++it)
{
CObstacle &other = (*it);
// attacks player if close to me
CVector d = pos-other.Position;
d.z = 0.0f;
if (other.Id.getType() == RYZOMID::player && d.norm() <= _AttackDistance)
{
nlinfo("Actor <%s> attacks player because _AttackDistance = %f and separation = %f", _name.c_str(), _AttackDistance, d.norm());
doFight(other.Id);
return true;
}
}
return false;
}
示例3:
/*
* render()
*/
void CPrimChecker::render(CPrimZone *zone, uint8 bits)
{
if (zone->VPoints.size() < 3)
return;
string name;
if (zone->getPropertyByName("name", name) && Verbose)
nlinfo("Rendering CPrimZone '%s'", name.c_str());
// get the bouding box of the CPrimZone
CAABBox box;
box.setCenter(zone->VPoints[0]);
box.setHalfSize(CVector::Null);
uint i;
for (i=1; i<zone->VPoints.size(); ++i)
box.extend(zone->VPoints[i]);
sint32 xmin, ymin, xmax, ymax;
xmin = (sint32)(floor(box.getMin().x));
ymin = (sint32)(floor(box.getMin().y));
xmax = (sint32)(ceil(box.getMax().x));
ymax = (sint32)(ceil(box.getMax().y));
// Fill grid with points that belong to the CPrimZone
sint32 x, y;
for (y=ymin; y<=ymax; ++y)
for (x=xmin; x<=xmax; ++x)
if (zone->contains(CVector((float)x, (float)y, 0.0f)))
_Grid.set(x, y, bits);
}
示例4:
void computeSurfaceQuadTree(CInteriorSurface &surface, CSurfaceQuadTree &quad)
{
uint i, j;
CAABBox box;
bool first = true;
for (i=0; i<surface.Faces.size(); ++i)
{
for (j=0; j<3; ++j)
{
const CVector &v = surface.CollisionMeshBuild->Vertices[surface.CollisionMeshBuild->Faces[surface.Faces[i]].V[j]];
if (first)
box.setCenter(v), first=false;
else
box.extend(v);
}
}
quad.clear();
quad.init(4.0f, 6, box.getCenter(), std::max(box.getHalfSize().x, box.getHalfSize().y));
for (i=0; i<surface.Faces.size(); ++i)
{
for (j=0; j<3; ++j)
{
const CVector &v = surface.CollisionMeshBuild->Vertices[surface.CollisionMeshBuild->Faces[surface.Faces[i]].V[j]];
quad.addVertex(v);
}
}
quad.compile();
}
示例5:
CAABBox NLPACS::CSurfElement::getBBox() const
{
CAABBox box;
box.setCenter((*Vertices)[Tri[0]]);
box.extend((*Vertices)[Tri[1]]);
box.extend((*Vertices)[Tri[2]]);
return box;
}
示例6: CVector
// ***************************************************************************
void CQuadGridClipClusterQTreeNode::init(CQuadGridClipCluster *owner, uint level, bool rootNode, const NLMISC::CAABBox &pivot)
{
Owner= owner;
RootNode= rootNode;
PivotBBox= pivot;
// If not a leaf, create sons
if(level>0)
{
LeafNode= false;
// split pivot for sons
CAABBox pivotSon;
pivotSon.setSize(PivotBBox.getHalfSize());
float xMin= PivotBBox.getMin().x/2;
float yMin= PivotBBox.getMin().y/2;
float xMax= PivotBBox.getMax().x/2;
float yMax= PivotBBox.getMax().y/2;
float xCenter= PivotBBox.getCenter().x/2;
float yCenter= PivotBBox.getCenter().y/2;
// LeftDown
pivotSon.setCenter( CVector(xMin+xCenter,yMin+yCenter,0) );
Sons[NL3D_QCC_LEFT_DOWN]= new CQuadGridClipClusterQTreeNode;
Sons[NL3D_QCC_LEFT_DOWN]->init(owner, level-1, false, pivotSon);
// RightDown
pivotSon.setCenter( CVector(xMax+xCenter,yMin+yCenter,0) );
Sons[NL3D_QCC_RIGHT_DOWN]= new CQuadGridClipClusterQTreeNode;
Sons[NL3D_QCC_RIGHT_DOWN]->init(owner, level-1, false, pivotSon);
// LeftUp
pivotSon.setCenter( CVector(xMin+xCenter,yMax+yCenter,0) );
Sons[NL3D_QCC_LEFT_UP]= new CQuadGridClipClusterQTreeNode;
Sons[NL3D_QCC_LEFT_UP]->init(owner, level-1, false, pivotSon);
// RithgUp
pivotSon.setCenter( CVector(xMax+xCenter,yMax+yCenter,0) );
Sons[NL3D_QCC_RIGHT_UP]= new CQuadGridClipClusterQTreeNode;
Sons[NL3D_QCC_RIGHT_UP]->init(owner, level-1, false, pivotSon);
}
else
{
LeafNode= true;
}
// Create the distMax list only if root or leaf. No models in interleaved branches.
if( LeafNode)
ListNode.Models.resize(Owner->_NumDistTotal);
}
示例7: cmb
void computeRetriever(CCollisionMeshBuild &cmb, CLocalRetriever &lr, CVector &translation, bool useCmbTrivialTranslation)
{
// set the retriever
lr.setType(CLocalRetriever::Interior);
// if should use the own cmb bbox, then compute it
if (useCmbTrivialTranslation)
{
translation = cmb.computeTrivialTranslation();
// snap the translation vector to a meter wide grid
translation.x = (float)ceil(translation.x);
translation.y = (float)ceil(translation.y);
translation.z = 0.0f;
}
uint i, j;
for (i=0; i<cmb.Faces.size(); ++i)
{
CVector normal = ((cmb.Vertices[cmb.Faces[i].V[1]]-cmb.Vertices[cmb.Faces[i].V[0]])^(cmb.Vertices[cmb.Faces[i].V[2]]-cmb.Vertices[cmb.Faces[i].V[0]])).normed();
if (normal.z < 0.0f)
{
nlwarning("Face %d in cmb (%s) has negative normal! -- face is flipped", i, cmb.Faces[i].Surface == CCollisionFace::InteriorSurfaceFirst ? "interior" : "exterior");
/*
std::swap(cmb.Faces[i].V[1], cmb.Faces[i].V[2]);
std::swap(cmb.Faces[i].Visibility[1], cmb.Faces[i].Visibility[2]);
*/
}
}
// first link faces
/*
linkMesh(cmb, false);
linkMesh(cmb, true);
*/
vector<string> errors;
cmb.link(false, errors);
cmb.link(true, errors);
if (!errors.empty())
{
nlwarning("Edge issues reported !!");
uint i;
for (i=0; i<errors.size(); ++i)
nlwarning("%s", errors[i].c_str());
nlerror("Can't continue.");
}
// translate the meshbuild to the local axis
cmb.translate(translation);
// find the exterior mesh border
CExteriorMesh extMesh;
buildExteriorMesh(cmb, extMesh);
lr.setExteriorMesh(extMesh);
// build the surfaces in the local retriever
buildSurfaces(cmb, lr);
// create the snapping faces and vertices
// after the build surfaces because the InternalSurfaceId is filled within buildSurfaces()...
buildSnapping(cmb, lr);
//
lr.computeLoopsAndTips();
lr.findBorderChains();
lr.updateChainIds();
lr.computeTopologies();
lr.unify();
lr.computeCollisionChainQuad();
/*
//
for (i=0; i<lr.getSurfaces().size(); ++i)
lr.dumpSurface(i);
*/
//
linkExteriorToInterior(lr);
// compute the bbox of the retriever
CAABBox bbox;
bool first = true;
for (i=0; i<extMesh.getEdges().size(); ++i)
if (!first)
bbox.extend(extMesh.getEdge(i).Start);
else
bbox.setCenter(extMesh.getEdge(i).Start), first=false;
for (i=0; i<lr.getOrderedChains().size(); ++i)
for (j=0; j<lr.getOrderedChain(i).getVertices().size(); ++j)
if (!first)
bbox.extend(lr.getOrderedChain(i)[j].unpack3f());
else
bbox.setCenter(lr.getOrderedChain(i)[j].unpack3f()), first=false;
//.........这里部分代码省略.........
示例8: main
int main(int argc, char **argv)
{
// Filter addSearchPath
NLMISC::createDebug();
InfoLog->addNegativeFilter("adding the path");
createDebug();
try
{
// Init
init();
uint i, j, k;
for (i=0; i<IGs.size(); ++i)
{
// load ig associated to the zone
string igName = IGs[i]+".ig";
CIFile igStream(CPath::lookup(igName));
CInstanceGroup ig;
igStream.serial(ig);
CAABBox igBBox;
bool boxSet = false;
nlinfo("Generating BBOX for %s", igName.c_str());
// search in group for water instance
for (j=0; j<ig._InstancesInfos.size(); ++j)
{
/*
Ben: c'est degueulasse, mais c'est les coders a la 3D, y savent pas coder
Hld: ouai, mais ca marche pas ton truc, alors p'tet qu'on sait pas coder mais toi non plus :p Special Dedicace to SupaGreg!
string shapeName = ig._InstancesInfos[j].Name+".shape";
*/
string shapeName = ig._InstancesInfos[j].Name;
if (CFile::getExtension (shapeName) == "")
shapeName += ".shape";
if (NonWaterShapes.find(shapeName) != NonWaterShapes.end())
continue;
string shapeNameLookup = CPath::lookup (shapeName, false, false);
if (!shapeNameLookup.empty())
{
CIFile f;
if (f.open (shapeNameLookup))
{
CShapeStream shape;
shape.serial(f);
CWaterShape *wshape = dynamic_cast<CWaterShape *>(shape.getShapePointer());
if (wshape == NULL)
{
NonWaterShapes.insert(shapeName);
continue;
}
CMatrix matrix;
ig.getInstanceMatrix(j, matrix);
CPolygon wpoly;
wshape->getShapeInWorldSpace(wpoly);
for (k=0; k<wpoly.Vertices.size(); ++k)
{
if (boxSet)
{
igBBox.extend(matrix * wpoly.Vertices[k]);
}
else
{
igBBox.setCenter(matrix * wpoly.Vertices[k]);
boxSet = true;
}
}
}
else
{
nlwarning ("Can't load shape %s", shapeNameLookup.c_str());
}
}
else
{
NonWaterShapes.insert(shapeName);
}
}
if (boxSet)
{
Boxes.push_back(CIGBox(igName, igBBox));
nlinfo("Bbox: (%.1f,%.1f)-(%.1f,%.1f)", igBBox.getMin().x, igBBox.getMin().y, igBBox.getMax().x, igBBox.getMax().y);
}
}
COFile output(Output);
output.serialCont(Boxes);
}
catch (Exception &e)
//.........这里部分代码省略.........
示例9: if
//.........这里部分代码省略.........
for (p=0; p<(sint)Elements.size(); ++p)
{
CSurfElement &e = *(Elements[p]);
CSurfElement &e0 = *e.EdgeLinks[0],
&e1 = *e.EdgeLinks[1],
&e2 = *e.EdgeLinks[2];
if (&e != NULL && &e0 != NULL && &e1 != NULL && &e2 != NULL &&
e.IsValid && e0.IsValid && e1.IsValid && e2.IsValid &&
!e.IsUnderWater && e0.IsUnderWater && e1.IsUnderWater && e2.IsUnderWater)
{
nlwarning("isolated submerged element '%d' !", p);
}
}
}
// translates vertices to the local axis
sint64 vx, vy, vz, tx, ty, tz;
tx = float2Fixed(Translation.x);
ty = float2Fixed(Translation.y);
tz = float2Fixed(Translation.z);
uint p;
for (i=0; i<_Vertices.size(); ++i)
{
vx = float2Fixed(_Vertices[i].x) + tx;
vy = float2Fixed(_Vertices[i].y) + ty;
vz = float2Fixed(_Vertices[i].z) + tz;
_Vertices[i] = CVector(fixed2Float(vx), fixed2Float(vy), fixed2Float(vz));
}
if(BestFittingBBoxSetuped)
BestFittingBBox.setCenter(BestFittingBBox.getCenter()+Translation);
//
//if (false)
{
//
// first pass of flood fill
// allow detecting landscape irregularities
//
if (Verbose)
nlinfo("build and flood fill surfaces -- pass 1");
uint32 surfId = 0; // + (ZoneId<<16);
for (p=0; p<Elements.size(); ++p)
{
if (Elements[p]->SurfaceId == UnaffectedSurfaceId)
{
Surfaces.push_back(CComputableSurface());
CComputableSurface &surf = Surfaces.back();
surf.BorderKeeper = &Borders;
surf.floodFill(Elements[p], surfId++, CSurfElemCompareSimple(), this);
surf.BBox = BestFittingBBox;
bool force = false;
if (surf.Area < 30.0f && surf.Elements.size() > 0)
{
uint i;
CAABBox aabbox;
示例10:
// ***************************************************************************
void IShape::getAABBox(CAABBox &bbox) const
{
bbox.setCenter(CVector::Null);
bbox.setHalfSize(CVector::Null);
}
示例11: UpdatePrimitives
void UpdatePrimitives ()
{
// Get the tools window
CMainFrame *mainWnd = getMainFrame ();
if (mainWnd)
{
CToolsLogic *toolWnd = dynamic_cast<CToolsLogic*>(getMainFrame ()->m_wndSplitter.GetPane(0,1));
// Sort the list
static vector<CDatabaseLocatorPointer> toSort;
toSort.clear ();
CWorldEditorDoc *doc = getDocument ();
std::list<NLLIGO::IPrimitive*>::iterator ite = ModifiedPrimitive.begin ();
while (ite != ModifiedPrimitive.end ())
{
CDatabaseLocatorPointer locator;
doc->getLocator (locator, *ite);
toSort.push_back (locator);
ite++;
}
sort (toSort.begin (), toSort.end ());
// For each modified primitive
sint i;
sint count = (sint)toSort.size ();
for (i=count-1; i>=0; i--)
{
CDatabaseLocatorPointer locator;
doc->getLocator (locator, toSort[i].Primitive);
IPrimitiveEditor *primitiveEditor = getPrimitiveEditor (const_cast<IPrimitive*>(toSort[i].Primitive));
// Logic tree structure modified ?
if (primitiveEditor->_Channels & LogicTreeStruct)
{
// Remove from the tree
primitiveEditor->removeFromLogicTree ();
}
}
// Selection is changed ?
bool selectionChanged = false;
// For each modified primitive
for (i=0; i<count; i++)
{
const IPrimitive *primitive = toSort[i].Primitive;
CDatabaseLocatorPointer locator;
doc->getLocator (locator, primitive);
IPrimitiveEditor *primitiveEditor = getPrimitiveEditor (const_cast<IPrimitive*>(primitive));
// Quad grid ?
if (primitiveEditor->_Channels & QuadTree)
{
// Remove from the container
primitiveEditor->removeFromQuadGrid ();
// Num points
uint pointCount = (primitive)->getNumVector ();
if (pointCount > 0)
{
// Point pointer
const CPrimVector *points = (primitive)->getPrimVector ();
// BBox
CAABBox bbox;
bbox.setCenter (points[0]);
// Extend the bbox
uint j;
for (j=1; j<pointCount; j++)
{
bbox.extend (points[j]);
}
// Insert in the quadtree
primitiveEditor->_QuadIterator = PrimitiveQuadGrid.insert (bbox.getMin (), bbox.getMax (), const_cast<IPrimitive*> (primitive));
// Get the linked primitives
const IPrimitive* linkedPrimitive = theApp.Config.getLinkedPrimitive (*primitive);
// Is this primitive linked with another one ?
if (linkedPrimitive)
{
IPrimitiveEditor *primitiveEditorLinked = getPrimitiveEditor (const_cast<IPrimitive*>(linkedPrimitive));
if (linkedPrimitive->getNumVector () > 0)
{
bbox.setCenter (points[0]);
bbox.extend (linkedPrimitive->getPrimVector ()[0]);
// Insert in the quadtree
primitiveEditor->_QuadIteratorLink = PrimitiveQuadGrid.insert (bbox.getMin (), bbox.getMax (), CQuadGridEntry
(const_cast<IPrimitive*> (primitive), const_cast<IPrimitive*> (linkedPrimitive)));
}
}
}
// Validate
primitiveEditor->_Channels &= ~QuadTree;
}
//.........这里部分代码省略.........
示例12: mirrorPhysiqueSelection
bool CExportNel::mirrorPhysiqueSelection(INode &node, TimeValue tvTime, const std::vector<uint> &vertIn,
float threshold)
{
bool ok;
uint i;
// no vertices selected?
if(vertIn.empty())
return true;
// **** Get all the skeleton node
std::vector<INode*> skeletonNodes;
INode *skelRoot= getSkeletonRootBone(node);
if(!skelRoot)
return false;
getObjectNodes(skeletonNodes, tvTime, skelRoot);
// **** Build the Vector (world) part
std::vector<CTempSkinVertex> tempVertex;
uint vertCount;
// Get a pointer on the object's node.
ObjectState os = node.EvalWorldState(tvTime);
Object *obj = os.obj;
// Check if there is an object
ok= false;
if (obj)
{
// Object can be converted in triObject ?
if (obj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0)))
{
// Get a triobject from the node
TriObject *tri = (TriObject*)obj->ConvertToType(tvTime, Class_ID(TRIOBJ_CLASS_ID, 0));
if (tri)
{
// Note that the TriObject should only be deleted
// if the pointer to it is not equal to the object
// pointer that called ConvertToType()
bool deleteIt=false;
if (obj != tri)
deleteIt = true;
// Get the node matrix. TODO: Matrix headhache?
/*Matrix3 nodeMatrixMax;
CMatrix nodeMatrix;
getLocalMatrix (nodeMatrixMax, node, tvTime);
convertMatrix (nodeMatrix, nodeMatrixMax);*/
// retrive Position geometry
vertCount= tri->NumPoints();
tempVertex.resize(vertCount);
for(uint i=0;i<vertCount;i++)
{
Point3 v= tri->GetPoint(i);
tempVertex[i].Pos.set(v.x, v.y, v.z);
}
// Delete the triObject if we should...
if (deleteIt)
tri->MaybeAutoDelete();
tri = NULL;
// ok!
ok= true;
}
}
}
if(!ok)
return false;
// no vertices? abort
if(vertCount==0)
return true;
// **** Mark all Input vertices
for(i=0;i<vertIn.size();i++)
{
nlassert(vertIn[i]<vertCount);
tempVertex[vertIn[i]].Input= true;
}
// **** Build the output vertices
std::vector<uint> vertOut;
vertOut.reserve(tempVertex.size());
// Build the in bbox
CAABBox bbox;
bbox.setCenter(tempVertex[vertIn[0]].Pos);
for(i=0;i<vertIn.size();i++)
{
bbox.extend(tempVertex[vertIn[i]].Pos);
}
bbox.setHalfSize(bbox.getHalfSize()+CVector(threshold, threshold, threshold));
//.........这里部分代码省略.........