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


C++ GFXDrawUtil::drawCube方法代码示例

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


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

示例1: _renderObject

void SceneSpace::_renderObject( ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat )
{
   if( overrideMat )
      return;

   if( !mEditorRenderMaterial )
   {
      // We have no material for rendering so just render
      // a plain box.

      GFXTransformSaver saver;

      MatrixF mat = getRenderTransform();
      mat.scale( getScale() );

      GFX->multWorld( mat );

      GFXStateBlockDesc desc;
      desc.setZReadWrite( true, false );
      desc.setBlend( true );
      desc.setCullMode( GFXCullNone );

      GFXDrawUtil *drawer = GFX->getDrawUtil();
      drawer->drawCube( desc, mObjBox, _getDefaultEditorSolidColor() );

      // Render black wireframe.

      desc.setFillModeWireframe();
      drawer->drawCube( desc, mObjBox, _getDefaultEditorWireframeColor() );
   }
   else
   {
      //RDTODO
   }
}
开发者ID:03050903,项目名称:Torque3D,代码行数:35,代码来源:sceneSpace.cpp

示例2: _renderCellBounds

void Forest::_renderCellBounds( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat )
{
    PROFILE_SCOPE( Forest_RenderCellBounds );

    if ( overrideMat )
        return;

    GFXTransformSaver saver;

    MatrixF projBias(true);
    const Frustum frustum = GFX->getFrustum();
    MathUtils::getZBiasProjectionMatrix( 0.001f, frustum, &projBias );
    GFX->setProjectionMatrix( projBias );

    VectorF extents;
    Point3F pos;

    // Get top level cells
    Vector<ForestCell*> cellStack;
    mData->getCells( &cellStack );

    // Holds child cells we need to render as we encounter them.
    Vector<ForestCell*> frontier;

    GFXDrawUtil *drawer = GFX->getDrawUtil();

    GFXStateBlockDesc desc;
    desc.setZReadWrite( true, false );
    desc.setBlend( true );
    desc.setFillModeWireframe();

    while ( !cellStack.empty() )
    {
        while ( !cellStack.empty() )
        {
            const ForestCell *cell = cellStack.last();
            cellStack.pop_back();

            Box3F box = cell->getBounds();

            drawer->drawCube( desc, box, ColorI( 0, 255, 0 ) );

            RectF rect = cell->getRect();

            box.minExtents.set( rect.point.x, rect.point.y, box.minExtents.z );
            box.maxExtents.set( rect.point.x + rect.extent.x, rect.point.y + rect.extent.y, box.minExtents.z );

            drawer->drawCube( desc, box, ColorI::RED );

            // If this cell has children, add them to the frontier.
            if ( !cell->isLeaf() )
                cell->getChildren( &frontier );
        }

        // Now the frontier becomes the cellStack and we empty the frontier.
        cellStack = frontier;
        frontier.clear();
    }
}
开发者ID:RasterCode,项目名称:Torque3D,代码行数:59,代码来源:forestRender.cpp

示例3: renderSimple

void NavPath::renderSimple(ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat)
{
   if(overrideMat)
      return;

   if(state->isReflectPass() || !(isSelected() || mAlwaysRender))
      return;

   GFXDrawUtil *drawer = GFX->getDrawUtil();
   GFXStateBlockDesc desc;
   desc.setZReadWrite(true, false);
   desc.setBlend(true);
   desc.setCullMode(GFXCullNone);

   if(isSelected())
   {
      drawer->drawCube(desc, getWorldBox(), ColorI(136, 255, 228, 5));
      desc.setFillModeWireframe();
      drawer->drawCube(desc, getWorldBox(), ColorI::BLACK);
   }

   desc.setZReadWrite(!mXray, false);

   ColorI pathColour(255, 0, 255);

   if(!mIsLooping)
   {
      desc.setFillModeSolid();
      if(mFromSet) drawer->drawCube(desc, Point3F(0.2f, 0.2f, 0.2f), mFrom, pathColour);
      if(mToSet)   drawer->drawCube(desc, Point3F(0.2f, 0.2f, 0.2f), mTo, pathColour);
   }

   GFXStateBlockRef sb = GFX->createStateBlock(desc);
   GFX->setStateBlock(sb);

   PrimBuild::color3i(pathColour.red, pathColour.green, pathColour.blue);

   PrimBuild::begin(GFXLineStrip, mPoints.size());
   for (U32 i = 0; i < mPoints.size(); i++)
      PrimBuild::vertex3fv(mPoints[i]);
   PrimBuild::end();

   if(mRenderSearch && getServerObject())
   {
      NavPath *np = static_cast<NavPath*>(getServerObject());
      if(np->mQuery && !dtStatusSucceed(np->mStatus))
      {
         duDebugDrawTorque dd;
         dd.overrideColor(duRGBA(250, 20, 20, 255));
         duDebugDrawNavMeshNodes(&dd, *np->mQuery);
         dd.render();
      }
   }
}
开发者ID:Dwarf-King,项目名称:OmniEngine.Net,代码行数:54,代码来源:navPath.cpp

示例4: render

   void NavMesh::render(ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat)
   {
      if(overrideMat)
         return;

      if(state->isReflectPass())
         return;

      PROFILE_SCOPE(NavMesh_Render);

      GFXDrawUtil *drawer = GFX->getDrawUtil();

      GFXStateBlockDesc desc;
      desc.setZReadWrite(true, false);
      desc.setBlend(true);
      desc.setCullMode(GFXCullNone);

      drawer->drawCube(desc, getWorldBox(), ColorI(136, 255, 228, 45));
      desc.setFillModeWireframe();
      drawer->drawCube(desc, getWorldBox(), ColorI::BLACK);

      // Recast debug draw
      duDebugDrawTorque dd;
      NetObject *no = getServerObject();
      if(no && isSelected())
      {
         NavMesh *n = static_cast<NavMesh*>(no);
         RenderMode mode = mRenderMode;
         bool build = n->mBuilding;
         if(build)
         {
            mode = RENDER_NAVMESH;
            dd.overrideColour(duRGBA(255, 0, 0, 80));
         }
         n->mNavMeshLock.lock();
         switch(mode)
         {
         case RENDER_NAVMESH:    if(n->nm) duDebugDrawNavMesh          (&dd, *n->nm, 0); break;
         case RENDER_CONTOURS:   if(n->cs) duDebugDrawContours         (&dd, *n->cs); break;
         case RENDER_POLYMESH:   if(n->pm) duDebugDrawPolyMesh         (&dd, *n->pm); break;
         case RENDER_DETAILMESH: if(n->pmd) duDebugDrawPolyMeshDetail  (&dd, *n->pmd); break;
         case RENDER_PORTALS:    if(n->nm) duDebugDrawNavMeshPortals   (&dd, *n->nm); break;
         }
         if(n->cs && mRenderConnections && !build)   duDebugDrawRegionConnections(&dd, *n->cs);
         if(n->mInPolys && mRenderInput && !build)   n->mInPolys->render();
         n->mNavMeshLock.unlock();
      }
   }
开发者ID:belzilep,项目名称:Torque3D,代码行数:48,代码来源:navMesh.cpp

示例5: renderMissionArea

void EditTSCtrl::renderMissionArea()
{
   MissionArea* obj = MissionArea::getServerObject();
   if ( !obj )
      return;

   if ( !mRenderMissionArea && !obj->isSelected() )
      return;

   GFXDEBUGEVENT_SCOPE( Editor_renderMissionArea, ColorI::WHITE );

   F32 minHeight = 0.0f;
   F32 maxHeight = 0.0f;

   TerrainBlock* terrain = getActiveTerrain();
   if ( terrain )
   {
      terrain->getMinMaxHeight( &minHeight, &maxHeight );
      Point3F pos = terrain->getPosition();

      maxHeight += pos.z + mMissionAreaHeightAdjust;
      minHeight += pos.z - mMissionAreaHeightAdjust;
   }

   const RectI& area = obj->getArea();
   Box3F areaBox( area.point.x,
                  area.point.y,
                  minHeight,
                  area.point.x + area.extent.x,
                  area.point.y + area.extent.y,
                  maxHeight );

   GFXDrawUtil* drawer = GFX->getDrawUtil();

   GFXStateBlockDesc desc;
   desc.setCullMode( GFXCullNone );
   desc.setBlend( true );
   desc.setZReadWrite( false, false );

   desc.setFillModeSolid();
   drawer->drawCube( desc, areaBox, mMissionAreaFillColor );

   desc.setFillModeWireframe();
   drawer->drawCube( desc, areaBox, mMissionAreaFrameColor );
}
开发者ID:souxiaosou,项目名称:OmniEngine.Net,代码行数:45,代码来源:editTSCtrl.cpp

示例6: _renderObject

void SFXEmitter::_renderObject( ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat )
{   
   // Check to see if the emitter is in range and playing
   // and assign a proper color depending on this.

   ColorI color;
   if( _getPlaybackStatus() == SFXStatusPlaying )
   {
      if( isInRange() )
         color = smRenderColorPlayingInRange;
      else
         color = smRenderColorPlayingOutOfRange;
   }
   else
   {
      if( isInRange() )
         color = smRenderColorStoppedInRange;
      else
         color = smRenderColorStoppedOutOfRange;
   }

   // Draw the cube.
   
   GFXStateBlockDesc desc;
   desc.setZReadWrite( true, false );
   desc.setBlend( true );
   desc.setCullMode( GFXCullNone );

   GFXDrawUtil *drawer = GFX->getDrawUtil();
   drawer->drawCube( desc,  Point3F( 0.5f, 0.5f, 0.5f ), getBoxCenter(), color );
   
   // Render visual feedback for 3D sounds.
   
   if( ( smRenderEmitters || isSelected() ) && is3D() )
      _render3DVisualFeedback();
}
开发者ID:Azaezel,项目名称:Torque3D,代码行数:36,代码来源:sfxEmitter.cpp

示例7: _renderDebug

void ConvexShape::_renderDebug( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *mat )
{   
   GFXDrawUtil *drawer = GFX->getDrawUtil();

   GFX->setTexture( 0, NULL );

   // Render world box.
   if ( false )
   {
      Box3F wbox( mWorldBox );
      //if ( getServerObject() )      
      //   Box3F wbox = static_cast<ConvexShape*>( getServerObject() )->mWorldBox;      
      GFXStateBlockDesc desc;
      desc.setCullMode( GFXCullNone );
      desc.setFillModeWireframe();
      drawer->drawCube( desc, wbox, ColorI::RED );
   }


   const Vector< Point3F > &pointList = mGeometry.points;
	const Vector< ConvexShape::Face > &faceList = mGeometry.faces;

   // Render Edges.
   if ( false )
   {
      GFXTransformSaver saver;
      //GFXFrustumSaver fsaver;

      MatrixF xfm( getRenderTransform() );
      xfm.scale( getScale() );
      GFX->multWorld( xfm );

      GFXStateBlockDesc desc;
      desc.setZReadWrite( true, false );
      desc.setBlend( true );
      GFX->setStateBlockByDesc( desc );

      //MathUtils::getZBiasProjectionMatrix( 0.01f, state->getFrustum(), )

      const Point3F &camFvec = state->getCameraTransform().getForwardVector();



      for ( S32 i = 0; i < faceList.size(); i++ )
      {         
         const ConvexShape::Face &face = faceList[i];
         
         const Vector< ConvexShape::Edge > &edgeList = face.edges;

         const Vector< U32 > &facePntList = face.points;

         PrimBuild::begin( GFXLineList, edgeList.size() * 2 );
         
         PrimBuild::color( ColorI::WHITE * 0.8f );

         for ( S32 j = 0; j < edgeList.size(); j++ )         
         {
            PrimBuild::vertex3fv( pointList[ facePntList[ edgeList[j].p0 ] ] - camFvec * 0.001f );
            PrimBuild::vertex3fv( pointList[ facePntList[ edgeList[j].p1 ] ] - camFvec * 0.001f );
         }
         
         PrimBuild::end();
      }
   }

   ColorI faceColorsx[4] = 
   {
      ColorI( 255, 0, 0 ),
      ColorI( 0, 255, 0 ),
      ColorI( 0, 0, 255 ),
      ColorI( 255, 0, 255 )
   };

   MatrixF objToWorld( mObjToWorld );
   objToWorld.scale( mObjScale );

   // Render faces centers/colors.
   if ( false )
   {
      GFXStateBlockDesc desc;
      desc.setCullMode( GFXCullNone );
      
      Point3F size( 0.1f );

      for ( S32 i = 0; i < faceList.size(); i++ )
      {
         ColorI color = faceColorsx[ i % 4 ];
         S32 div = ( i / 4 ) * 4;
         if ( div > 0 )
            color /= div;
         color.alpha = 255;
         
         Point3F pnt;
         objToWorld.mulP( faceList[i].centroid, &pnt );
         drawer->drawCube( desc, size, pnt, color, NULL );
      }
   }

   // Render winding order.
   if ( false )
//.........这里部分代码省略.........
开发者ID:fr1tz,项目名称:alux3d,代码行数:101,代码来源:convexShape.cpp

示例8: drawActor

void drawActor( NxActor *inActor )
{
   GFXDrawUtil *drawer = GFX->getDrawUtil();
   //drawer->setZRead( false );

   // Determine alpha we render shapes with.
   const U8 enabledAlpha = 255;
   const U8 disabledAlpha = 100;
   U8 renderAlpha = inActor->readActorFlag( NX_AF_DISABLE_COLLISION ) ? disabledAlpha : enabledAlpha;

   // Determine color we render actors and shapes with.
   ColorI actorColor( 0, 0, 255, 200 );   
   ColorI shapeColor = ( inActor->isSleeping() ? ColorI( 0, 0, 255, renderAlpha ) : ColorI( 255, 0, 255, renderAlpha ) );      

   MatrixF actorMat(true);
   inActor->getGlobalPose().getRowMajor44( actorMat );

   GFXStateBlockDesc desc;
   desc.setBlend( true );
   desc.setZReadWrite( true, false );
   desc.setCullMode( GFXCullNone );

   // Draw an xfm gizmo for the actor's globalPose...
   //drawer->drawTransform( desc, actorMat, Point3F::One, actorColor );
   
   // Loop through and render all the actor's shapes....

   NxShape *const*pShapeArray = inActor->getShapes();
   U32 numShapes = inActor->getNbShapes();

   for ( U32 i = 0; i < numShapes; i++ )
   {
      const NxShape *shape = pShapeArray[i];

      Point3F shapePos = pxCast<Point3F>( shape->getGlobalPosition() );
      MatrixF shapeMat(true);
      shape->getGlobalPose().getRowMajor44(shapeMat);
      shapeMat.setPosition( Point3F::Zero );

      switch ( shape->getType() )
      {
         case NX_SHAPE_SPHERE:
         {
            NxSphereShape *sphere = (NxSphereShape*)shape;     
            drawer->drawSphere( desc, sphere->getRadius(), shapePos, shapeColor );

            break;
         }
         case NX_SHAPE_BOX:
         {
            NxBoxShape *box = (NxBoxShape*)shape;
            Point3F size = pxCast<Point3F>( box->getDimensions() );            
            drawer->drawCube( desc, size*2, shapePos, shapeColor, &shapeMat );            
            break;
         }
         case NX_SHAPE_CAPSULE:
         {
            shapeMat.mul( MatrixF( EulerF( mDegToRad(90.0f), mDegToRad(90.0f), 0 ) ) );

            NxCapsuleShape *capsule = (NxCapsuleShape*)shape;
            drawer->drawCapsule( desc, shapePos, capsule->getRadius(), capsule->getHeight(), shapeColor, &shapeMat );

            break;
         }
         default:
         {
            break;
         }
      }
   }

   //drawer->clearZDefined();
}
开发者ID:03050903,项目名称:Torque3D,代码行数:73,代码来源:pxUtils.cpp


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