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

   GFXTransformSaver saver;

   GFXDrawUtil *drawer = GFX->getDrawUtil();

   AssertFatal( drawer, "Got NULL GFXDrawUtil!" );

   const Point3F &pos = getPosition();
   const VectorF &windVec = mWind->getDirection();

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

   // Draw an arrow pointing
   // in the wind direction.
   drawer->drawArrow( desc, pos, pos + (windVec * mWindStrength), ColorI( 0, 0, 255, 255 ) );//Point3F( -235.214, 219.589, 34.0991 ), Point3F( -218.814, 244.731, 37.5587 ), ColorI( 255, 255, 0, 255 ) );//
   drawer->drawArrow( desc, pos, pos + (mWind->getTarget() * mWindStrength ), ColorI( 255, 0, 0, 85 ) );

   // Draw a 2D circle for the wind radius.
   if ( isRadialEmitter() )
      drawer->drawSphere( desc, mWindRadius, pos, ColorI( 255, 0, 0, 80 ) );
}
void ForestWindEmitter::_renderEmitterInfo( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat )
{
   if ( overrideMat )
      return;

   GFXTransformSaver saver;

   GFXDrawUtil *drawer = GFX->getDrawUtil();

   AssertFatal( drawer, "Got NULL GFXDrawUtil!" );

   const Point3F &pos = getPosition();
   const VectorF &windVec = mWind->getDirection();

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

   // Draw an arrow pointing
   // in the wind direction.
   drawer->drawArrow( desc, pos, pos + (windVec * mWindStrength), ColorI( 0, 0, 255, 255 ) );//Point3F( -235.214, 219.589, 34.0991 ), Point3F( -218.814, 244.731, 37.5587 ), ColorI( 255, 255, 0, 255 ) );//
   drawer->drawArrow( desc, pos, pos + (mWind->getTarget() * mWindStrength ), ColorI( 255, 0, 0, 85 ) );

   
   S32 useRadius = mWindRadius;
   // Draw a 2D circle for the wind radius.
   if ( isRadialEmitter() )
   {
	   //WLE - Vince 
	   //So the problem is that when your inside the sphere it won't render so it might make someone 
	   //think that it's not working right.  So what I did was determine if the camera is inside the sphere.
	   //If the camera is inside the sphere, then I find the distance from the center of the sphere to the camera
	   //Round down and use that as the radius to draw the sphere.
	   //That way if someone zooms in or out, their screen is still showing the sphere.
      GameConnection * gc = GameConnection::getConnectionToServer();
      GameBase* gb = gc->getCameraObject();
       if (gb)
	   {
		  Point3F camPos = gb->getPosition();
		  if ( getPosition().isInsideSphere( camPos, mWindRadius ) )
			  useRadius =  getPosition().distanceTo(camPos);
	   }
      drawer->drawSphere( desc, useRadius, pos, ColorI( 255, 0, 0, 80 ) );
   }
}
void ForestWindEmitter::_renderEmitterInfo( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat )
{
   if ( overrideMat )
      return;

   GFXTransformSaver saver;

   GFXDrawUtil *drawer = GFX->getDrawUtil();

   AssertFatal( drawer, "Got NULL GFXDrawUtil!" );

   const Point3F &pos = getPosition();
   const VectorF &windVec = mWind->getDirection();

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

   // Draw an arrow pointing
   // in the wind direction.
   drawer->drawArrow( desc, pos, pos + (windVec * mWindStrength), ColorI( 0, 0, 255, 255 ) );//Point3F( -235.214, 219.589, 34.0991 ), Point3F( -218.814, 244.731, 37.5587 ), ColorI( 255, 255, 0, 255 ) );//
   drawer->drawArrow( desc, pos, pos + (mWind->getTarget() * mWindStrength ), ColorI( 255, 0, 0, 85 ) );

   S32 useRadius = mWindRadius;
   // Draw a 2D circle for the wind radius.
   if ( isRadialEmitter() )
   {
      // If the camera is close to the sphere, shrink the sphere so it remains visible.
      GameConnection* gc = GameConnection::getConnectionToServer();
      GameBase* gb;
      if ( gc && (gb = gc->getCameraObject()) )
      {
         F32 camDist = (gb->getPosition() - getPosition()).len();
         if ( camDist < mWindRadius )
            useRadius = camDist;
      }
      drawer->drawSphere( desc, useRadius, pos, ColorI( 255, 0, 0, 80 ) );
   }
}
示例#4
0
void DecalManager::renderDecalSpheres()
{
   if ( mData && Con::getBoolVariable( "$renderSpheres" ) )
   {
      PROFILE_SCOPE( DecalManager_renderDecalSpheres );

      const Vector<DecalSphere*> &grid = mData->getGrid();

      GFXDrawUtil *drawUtil = GFX->getDrawUtil();
      ColorI sphereLineColor( 0, 255, 0, 25 );
      ColorI sphereColor( 0, 0, 255, 30 );

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

      for ( U32 i = 0; i < grid.size(); i++ )
      {
         DecalSphere *decalSphere = grid[i];
         const SphereF &worldSphere = decalSphere->mWorldSphere;
         drawUtil->drawSphere( desc, worldSphere.radius, worldSphere.center, sphereColor );
      }
   }
}
示例#5
0
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();
}