当前位置: 首页>>代码示例>>C++>>正文


C++ AABB3类代码示例

本文整理汇总了C++中AABB3的典型用法代码示例。如果您正苦于以下问题:C++ AABB3类的具体用法?C++ AABB3怎么用?C++ AABB3使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AABB3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RenderCube

void RenderCube()
{
    AABB3 box;
    box.min.x = box.min.y = box.min.z = -5.0f;
    box.max = -box.min;

    RenderVertex vl[8];
    for (int i = 0 ; i < 8 ; ++i) {
        vl[i].p = box.corner(i);
        //vl[i].argb = MAKE_ARGB(255, (i & 1) ? 255 : 0, (i & 2) ? 255 : 0, (i & 4) ? 255 : 0);
        vl[i].n = vl[i].p;
        vl[i].n.normalize();
        vl[i].u = (i & 1) ? 1.0f : 0.0f;
        vl[i].v = (i & 2) ? 1.0f : 0.0f;
    }

    RenderTri pl[6*2] = {
        { 0,4,6 },
        { 0,6,2 },
        { 1,3,7 },
        { 1,7,5 },
        { 0,1,5 },
        { 0,5,4 },
        { 2,6,7 },
        { 2,7,3 },
        { 0,2,3 },
        { 0,3,1 },
        { 4,5,7 },
        { 4,7,6 },
    };

    gRenderer.renderTriMesh(vl, 8, pl, 12);
}
开发者ID:7zhang,项目名称:studies,代码行数:33,代码来源:MyViewer.cpp

示例2: UpdateParticles

/**
 * updates position, velocity, and animation time of particles
 *  - rParticleSet.aabb is also updated
 *
 */
inline void CBE_ParticleSet::UpdateParticles( ParticleSetExtraData& rParticleSet, float dt, AABB3& aabb )
{
//	Vector3 vGravityAccel = m_pStage->GetGravityAccel();
//	float fGravityInfluenceFactor = m_fGravityInfluenceFactor;
	Vector3 vGravityAccel = m_pStage->GetGravityAccel() * m_fGravityInfluenceFactor;

//	AABB3 aabb;
	aabb.Nullify();

	int i, num_particles = rParticleSet.iNumParticles;
	for(i=0; i<num_particles; i++)
	{
		// update velocity
//		rParticleSet.pavVelocity[i] += (vGravityAccel * fGravityInfluenceFactor) * dt;
		rParticleSet.pavVelocity[i] += vGravityAccel * dt;

		// update position
		rParticleSet.pavPosition[i] += rParticleSet.pavVelocity[i] * dt;

		// update animation time
		rParticleSet.pafAnimationTime[i] += dt;

		aabb.AddPoint( rParticleSet.pavPosition[i] );
	}

	const float r = m_fParticleRadius;
	aabb.vMin -= Vector3(r,r,r);
	aabb.vMax += Vector3(r,r,r);

	rParticleSet.aabb = aabb;
}
开发者ID:nyankosoft,项目名称:amorphous,代码行数:36,代码来源:BE_ParticleSet.hpp

示例3: Entity

TerrainChunk::TerrainChunk(
    int xChunkIndex,
    int yChunkIndex,
    int zChunkIndex,
    Terrain *terrain
):
    Entity("TerrainChunk"),
    _xChunkIndex(xChunkIndex),
    _yChunkIndex(yChunkIndex),
    _zChunkIndex(zChunkIndex),
    _terrain(terrain)
{
    std::ostringstream stringStream;
    stringStream << "TerrainChunk [" <<
        _xChunkIndex << ", " <<
        _yChunkIndex << ", " <<
        _zChunkIndex << "]";

    _name = stringStream.str();

    _paletteRenderables.reserve(DefaultCapacity);

    _grid = new MatrixVoxelGrid(ChunkSize, ChunkSize, ChunkSize);

    // Setup for a correct model matrix.
    setPosition(
        _xChunkIndex * ChunkSize,
        _yChunkIndex * ChunkSize,
        _zChunkIndex * ChunkSize);

    // Setup for correct frustum culling.
    AABB3 localAABB;
    localAABB.setMinMax(Vector3(0, 0, 0), Vector3(ChunkSize, ChunkSize, ChunkSize));
    expandLocalAABB(localAABB);
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例4: orthographic_off_center

	Matrix44 MatrixUtils::orthographic_off_center( AABB3& bounds )
	{
		return orthographic_off_center(	
			bounds.vmin().x, bounds.vmax().x,
			bounds.vmin().y, bounds.vmax().y,
			bounds.vmin().z, bounds.vmax().z);
	}
开发者ID:kayru,项目名称:reversez,代码行数:7,代码来源:UtilMatrixUtils.cpp

示例5: getBoundingBox

/// \param m Specifies the transformation matrix to be applied.
/// \return The bounding box for the mesh under m.
AABB3 TriMesh::getBoundingBox(const Matrix4x3 &m) const
{
  AABB3 bb;
  bb.empty();
  for (int i = 0; i < vertexCount; ++i)
    bb.add(vertexList[i].p * m);
  return bb;
}
开发者ID:carussell,项目名称:nvvg,代码行数:10,代码来源:TriMesh.cpp

示例6: getBoundingBox

/// \param m Specifies the transformation matrix applied to the model.
/// \return The bounding box of the model in transformed space.
AABB3 Model::getBoundingBox(const Matrix4x3 &m) const
{
    AABB3 bb;
    bb.empty();
    for(int i = 0; i < m_partCount; ++i)
        bb.add(m_partMeshList[i].getBoundingBox(m));
    return bb;
}
开发者ID:kmh0237,项目名称:GameProgramming2Project,代码行数:10,代码来源:Model.cpp

示例7: assert

/// \param submodel Specifies the submodel whose bounding box is to be fetched.
/// \param m Specifies the transformation matrix representing the submodel in world space.
AABB3 ArticulatedModel::getSubmodelBoundingBox(int submodel, const Matrix4x3 &m) const
{
  assert(submodel < m_nSubmodelCount);
  AABB3 bb;
  bb.empty();
  for(int i = 0; i < m_nNextSubmodelPart[submodel]; ++i)
    bb.add(m_partMeshList[m_nSubmodelPart[submodel][i]].getBoundingBox(m));
  return bb;
}
开发者ID:kmh0237,项目名称:GameProgramming2Project,代码行数:11,代码来源:ArticulatedModel.cpp

示例8: fabs

/** 
    Adopted from Real Time Collision Detection
    5.2.3
*/
bool gh::Plane3::IntersectsWithAABB3( const AABB3& box ) const
{
    Vector3 center = box.calcCenter();
    Vector3 extents = box.getMax() - center;

    float r = extents.x * fabs( normal.x ) + extents.y * fabs( normal.y ) + extents.z * fabs( normal.z );
    float s = normal.dotProduct( center ) - distanceFromOrigin;

    return fabs( s ) <= r;
}
开发者ID:kaylareedhanson,项目名称:raytracer,代码行数:14,代码来源:Plane3.cpp

示例9: draw_aabb

	void PrimitiveBatch::draw_aabb( const AABB3& box, const ColourRGBA8& colour/*=ColourARGB8::White()*/ )
	{
		Vector3 v[8];

		v[0] = box.center() + box.dimensions() * Vector3(-0.5f,-0.5f,-0.5f);
		v[1] = box.center() + box.dimensions() * Vector3(+0.5f,-0.5f,-0.5f);
		v[2] = box.center() + box.dimensions() * Vector3(-0.5f,+0.5f,-0.5f);
		v[3] = box.center() + box.dimensions() * Vector3(+0.5f,+0.5f,-0.5f);
		v[4] = box.center() + box.dimensions() * Vector3(-0.5f,-0.5f,+0.5f);
		v[5] = box.center() + box.dimensions() * Vector3(+0.5f,-0.5f,+0.5f);
		v[6] = box.center() + box.dimensions() * Vector3(-0.5f,+0.5f,+0.5f);
		v[7] = box.center() + box.dimensions() * Vector3(+0.5f,+0.5f,+0.5f);

		draw_line(Line3(v[0],v[1]), colour);
		draw_line(Line3(v[2],v[3]), colour);
		draw_line(Line3(v[4],v[5]), colour);
		draw_line(Line3(v[6],v[7]), colour);

		draw_line(Line3(v[0],v[4]), colour);
		draw_line(Line3(v[1],v[5]), colour);
		draw_line(Line3(v[2],v[6]), colour);
		draw_line(Line3(v[3],v[7]), colour);

		draw_line(Line3(v[0],v[2]), colour);
		draw_line(Line3(v[1],v[3]), colour);
		draw_line(Line3(v[4],v[6]), colour);
		draw_line(Line3(v[5],v[7]), colour);
	}
开发者ID:kayru,项目名称:reversez,代码行数:28,代码来源:GfxPrimitiveBatch.cpp

示例10: ClipLineSegment

	// clip trace at the point of contact
void CTriangleMesh::ClipLineSegment( CJL_LineSegment& segment )
{
	Vector3 vStart = segment.vStart;
	Vector3 vEnd;
	if( segment.fFraction == 1.0f )
		vEnd = segment.vGoal;
	else
		vEnd = segment.vEnd;	// the line segment has been already clipped - set the current end point

	static vector<int> s_veciTriList;
	s_veciTriList.resize( 0 );

	AABB3 aabb;
	aabb.Nullify();
	aabb.AddPoint( vStart );
	aabb.AddPoint( vEnd );

	GetIntersectingTriangles( s_veciTriList, aabb );

	size_t i, iNumTris = s_veciTriList.size();

	if( iNumTris == 0 )
		return;	// no intersection

	Vector3 vOrigLineSegment = vEnd - vStart;

	for( i=0; i<iNumTris; i++ )
	{
		IndexedTriangle& tri = GetTriangle( s_veciTriList[i] );
		Triangle triangle( GetVertex( tri.GetIndex(0) ),
			                GetVertex( tri.GetIndex(1) ),
							GetVertex( tri.GetIndex(2) ),
							tri.m_vNormal );

		// check intersection between ray and triangle
		if( triangle.RayIntersect( vStart, vEnd ) )
		{	// found intersection
			// 'vEnd' now represents the intersection point

			// save contact surface
			segment.plane = triangle.GetPlane();

			// record surface material to 'tr'
			segment.iMaterialIndex = tri.m_iMaterialID;
		}
	}

	segment.fFraction *= Vec3Dot( vEnd - vStart, vOrigLineSegment ) / Vec3LengthSq( vOrigLineSegment );
	segment.vEnd = vEnd;
}
开发者ID:HermanHGF,项目名称:amorphous,代码行数:51,代码来源:TriangleMesh.cpp

示例11: SearchAdjacentLightSourceFaces_r

void CBSPMapData::SetLightsFromLightSourceFaces()
{
	vector<CMapFace> vecTempLightSourceFace;	// temporary buffer to hold light source faces
	size_t i,j;
	size_t iNumInteriorFaces = m_aInteriorFace.size();

	for(i=0; i<iNumInteriorFaces; i++)
	{	// set all the flags of light source faces to false
		m_aInteriorFace[i].m_bFlag = false;
	}

	// cluster light source faces	
	for(i=0; i<iNumInteriorFaces; i++)
	{
		vecTempLightSourceFace.clear();
		CMapFace& rFace1 = m_aInteriorFace[i];

		if( !rFace1.ReadTypeFlag(CMapFace::TYPE_LIGHTSOURCE) )
			continue;	// doesn't emit light by itself

		if( rFace1.m_bFlag == true )
			continue;	// already registered as a light source face

		rFace1.m_bFlag = true;
		vecTempLightSourceFace.push_back( rFace1 );

		// adjacent light source faces are converted into one point light
		SearchAdjacentLightSourceFaces_r( &vecTempLightSourceFace, rFace1, &m_aInteriorFace );

		// convert each cluster of light source faces into a point light
		AABB3 aabb;
		aabb.Nullify();
		for(j=0; j<vecTempLightSourceFace.size(); j++)
			vecTempLightSourceFace[j].AddToAABB( aabb );

		SPointLightDesc light = FindPointLightDesc( rFace1.m_acSurfaceName );
		CPointLight* pPointLight = new CPointLight;
		pPointLight->vPosition = aabb.GetCenterPosition();
		pPointLight->Color.fRed   = light.fRed;
		pPointLight->Color.fGreen = light.fGreen;
		pPointLight->Color.fBlue  = light.fBlue;
		pPointLight->fIntensity   = light.fIntensity;
		pPointLight->fAttenuation0 = light.fAttenuation[0];
		pPointLight->fAttenuation1 = light.fAttenuation[1];
		pPointLight->fAttenuation2 = light.fAttenuation[2];
		m_vecpLight.push_back( pPointLight );
	}
}
开发者ID:HermanHGF,项目名称:amorphous,代码行数:48,代码来源:BSPMapData.cpp

示例12:

void UniformGrid<T,CellType>::InitGrid(const AABB3<T> &boundingBox, const AABB3<T> &element)
{

    m_dCellSize = 2.0 * element.getBoundingSphereRadius();
    m_bxBox = boundingBox;

    int x = (2.0*m_bxBox.extents_[0]+m_dCellSize)/m_dCellSize;
    int y = (2.0*m_bxBox.extents_[1]+m_dCellSize)/m_dCellSize;
    int z = (2.0*m_bxBox.extents_[2]+m_dCellSize)/m_dCellSize;

    // int nGhostLayerCells = (2 * xy + 2 * xz + 2 * yz) + (4 * x + 4 * y + 4 * z) + 8;

    // pass a bounding box that is m_dCellSize bigger in each dimension
    m_pCells = new CellType[x*y*z];

    // printf("cell size: %f\n",m_dCellSize);
    // printf("domain extends : %f %f %f\n",boundingBox.extents_[0],boundingBox.extents_[1],boundingBox.extents_[2]);
    // printf("element extends : %f %f %f\n",element.extents_[0],element.extents_[1],element.extents_[2]);
    // printf("Dimensions : %d %d %d\n",x,y,z);
    // printf("Number of cells in uniform grid : %d\n",x*y*z);

    m_iDimension[0] = x;
    m_iDimension[1] = y;
    m_iDimension[2] = z;

    m_iTotalEntries=0;

}
开发者ID:rmuenste,项目名称:FullC0ntact,代码行数:28,代码来源:uniformgrid.cpp

示例13: if

bool Ned3DObjectManager::enforcePositions(GameObject &obj1, GameObject &obj2)
{
  const AABB3 &box1 = obj1.getBoundingBox(), &box2 = obj2.getBoundingBox();
  AABB3 intersectBox;
  if(AABB3::intersect(box1, box2, &intersectBox))
  {
    // Collision:  Knock back both objects
    //   - Kludge method:  Push back on smallest dimension
    Vector3 delta = intersectBox.size();
    Vector3 obj1Pos = obj1.getPosition(), obj2Pos = obj2.getPosition();
    if(delta.x <= delta.y)
      if(delta.x <= delta.z)
      {
        // Push back on x
        float dx = (box1.min.x < box2.min.x) ? -delta.x : delta.x;
        obj1Pos.x += dx;
        obj2Pos.x -= dx;
      }
      else
      {
        // Push back on z
        float dz = (box1.min.z < box2.min.z) ? -delta.z : delta.z;
        obj1Pos.z += dz;
        obj2Pos.z -= dz;
      }
    else if(delta.y <= delta.z)
    {
        // Push back on y
        float dy = (box1.min.y < box2.min.y) ? -delta.y : delta.y;
        obj1Pos.y += dy;
        obj2Pos.y -= dy;
    }
    else
    {
      // Push back on z
      float dz = (box1.min.z < box2.min.z) ? -delta.z : delta.z;
      obj1Pos.z += dz;
      obj2Pos.z -= dz;
    }
    obj1.setPosition(obj1Pos);
    obj2.setPosition(obj2Pos);
    return true;
  }
  return false;
}
开发者ID:carussell,项目名称:nvvg,代码行数:45,代码来源:Ned3DObjectManager.cpp

示例14: UpdateNozzleExhaust

void CBE_NozzleExhaust::UpdateNozzleExhaust( CCopyEntity* pCopyEnt, SBE_ParticleSetExtraData& rParticleSet, float dt )
{
	int i, num_particles = m_MaxNumParticlesPerSet;

//	float dt = fFrameTime;
	AABB3 aabb;
	aabb.Nullify();
//	UpdateParticles( rParticleSet, fFrameTime, aabb );
	float radius = m_fParticleRadius;
	for(i=0; i<num_particles; i++)
	{
		// update animation time
		rParticleSet.pafAnimationTime[i] += dt;

		if( rParticleSet.pafAnimationTime[i] < 0 )
			continue;

		// update velocity
//		rParticleSet.pavVelocity[i] += vGravityAccel * dt;

		// update position
		rParticleSet.pavPosition[i] += rParticleSet.pavVelocity[i] * dt;

		aabb.AddSphere( Sphere(rParticleSet.pavPosition[i],radius) );
	}

	pCopyEnt->world_aabb.MergeAABB( aabb );

	Vector3	vBasePos = Vector3(0,0,0);//pCopyEnt->Position();// + pCopyEnt->GetDirection() * pCopyEnt->f1;
	Vector3 vDir	= Vector3(0,0,1);//pCopyEnt->GetDirection();
	Vector3 vRight	= Vector3(1,0,0);//pCopyEnt->GetRightDirection();
	Vector3	vUp		= Vector3(0,1,0);//pCopyEnt->GetUpDirection();
	float cycle_time = m_fDuration;
	for( i=0; i<num_particles; i++ )
	{
		if( cycle_time <= rParticleSet.pafAnimationTime[i] )
		{
			// set new position & velocity

			CreateNewParticle( pCopyEnt, rParticleSet, i );
//			rParticleSet.pafAnimationTime[i] = 0;
		}
	}
}
开发者ID:HermanHGF,项目名称:amorphous,代码行数:44,代码来源:BE_NozzleExhaust.cpp

示例15: v

void AABB3::TransformBy(Matrix& matrix)
{
	AABB3	bb;

	Vector3f v(minVec);
	Vector3f w(maxVec);
	
	bb.Encapsulate(matrix.Transform(Vector3f(v.x(),v.y(),v.z())));
	bb.Encapsulate(matrix.Transform(Vector3f(w.x(),v.y(),v.z())));
	bb.Encapsulate(matrix.Transform(Vector3f(v.x(),w.y(),v.z())));
	bb.Encapsulate(matrix.Transform(Vector3f(w.x(),w.y(),v.z())));
	bb.Encapsulate(matrix.Transform(Vector3f(v.x(),v.y(),w.z())));
	bb.Encapsulate(matrix.Transform(Vector3f(w.x(),v.y(),w.z())));
	bb.Encapsulate(matrix.Transform(Vector3f(v.x(),w.y(),w.z())));
	bb.Encapsulate(matrix.Transform(Vector3f(w.x(),w.y(),w.z())));

	minVec.Set(bb.minVec);
	maxVec.Set(bb.maxVec);
}
开发者ID:WenbinWang,项目名称:strive3d,代码行数:19,代码来源:bounds.cpp


注:本文中的AABB3类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。