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::unpackUpdate(NetConnection * con, BitStream * stream) { // Unpack Parent. Parent::unpackUpdate( con, stream ); MatrixF xfm; mathRead( *stream, &xfm ); Parent::setTransform( xfm ); U32 windMask = 0; if ( stream->readFlag() ) // EnabledMask mEnabled = stream->readFlag(); if ( stream->readFlag() ) // WindMask { stream->read( &mWindStrength ); stream->read( &mWindRadius ); mRadialEmitter = stream->readFlag(); stream->read( &mWindGustStrength ); stream->read( &mWindGustFrequency ); stream->read( &mWindGustYawAngle ); stream->read( &mWindGustYawFrequency ); stream->read( &mWindGustWobbleStrength ); stream->read( &mWindTurbulenceStrength ); stream->read( &mWindTurbulenceFrequency ); stream->readNormalVector( &mWindDirection, 8 ); windMask |= WindMask; mHasMount = stream->readFlag(); } // This does nothing if the masks are not set! if ( windMask != 0 && isProperlyAdded() ) { Point3F boxRad( 0, 0, 0 ); if ( !isRadialEmitter() ) boxRad.set( 10000.0f, 10000.0f, 10000.0f ); else boxRad.set( mWindRadius, mWindRadius, mWindRadius ); mObjBox.set( -boxRad, boxRad ); resetWorldBox(); _initWind( windMask ); } }
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 ) ); } }
bool ForestWindEmitter::onAdd() { if ( !Parent::onAdd() ) return false; // Only the client side actually does wind. if ( isClientObject() ) { // TODO: wasn't this a big hack we already fixed better? //Projectile::getGhostReceivedSignal().notify( this, &ForestWindEmitter::_onMountObjectGhostReceived ); _initWind(); WINDMGR->addEmitter( this ); } Point3F boxRad( 0, 0, 0 ); if ( !isRadialEmitter() ) boxRad.set( 10000.0f, 10000.0f, 10000.0f ); else boxRad.set( mWindRadius, mWindRadius, mWindRadius ); mObjBox.set( -boxRad, boxRad ); resetWorldBox(); enableCollision(); // If we are we editing the mission then // be sure to add us to the scene. if ( gEditingMission || mHasMount ) { addToScene(); mAddedToScene = true; } return true; }