⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fxsunlight.cc

📁 五行MMORPG引擎系统V1.0
💻 CC
📖 第 1 页 / 共 5 页
字号:
//-----------------------------------------------------------------------------
// Torque Game Engine
// Written by Melvyn May, Started on 27th August 2002.
//
// "My code is written for the Torque community, so do your worst with it,
//	just don't rip-it-off and call it your own without even thanking me".
//
//	- Melv.
//
//-----------------------------------------------------------------------------

#include "console/consoleTypes.h"
#include "dgl/dgl.h"
#include "core/bitStream.h"
#include "game/gameConnection.h"
#include "sceneGraph/sceneGraph.h"
#include "math/mathUtils.h"
#include "fxSunLight.h"
#include "game/fx/Celestial.h"//celestial


//------------------------------------------------------------------------------
//
//	Put this in /example/common/editor/EditorGui.cs in [function Creator::init( %this )]
//
//   %Environment_Item[<next item-index in list>] = "fxSunLight";  <-- ADD THIS.
//
//------------------------------------------------------------------------------
//
//	Put the function in /example/common/editor/ObjectBuilderGui.gui [around line 458] ...
//
//	function ObjectBuilderGui::buildfxSunLight(%this)
//	{
//		%this.className = "fxSunLight";
//		%this.process();
//	}
//
//------------------------------------------------------------------------------
//
//	Put the example 'corona.png' in the "/example/common/lighting/" directory.
//
//------------------------------------------------------------------------------

extern bool gEditingMission;

//------------------------------------------------------------------------------

IMPLEMENT_CO_NETOBJECT_V1(fxSunLight);

//------------------------------------------------------------------------------


//------------------------------------------------------------------------------
// Class: fxSunLight
//------------------------------------------------------------------------------

fxSunLight::fxSunLight()
{
   // Setup NetObject.
   mTypeMask |= StaticObjectType | StaticTSObjectType | StaticRenderedObjectType;
   mNetFlags.set(Ghostable | ScopeAlways);
   mAddedToScene = false;

   // Initialise Animation.
   InitialiseAnimation();

   // Reset Done SunLock Flag.
   mDoneSunLock = false;
}

//------------------------------------------------------------------------------

fxSunLight::~fxSunLight()
{
}

//------------------------------------------------------------------------------

void fxSunLight::initPersistFields()
{
   // Initialise parents' persistent fields.
   Parent::initPersistFields();

   // Add our own persistent fields.

   // Enable.
   addGroup( "Debugging" );
	addField( "Enable",				TypeBool,		Offset( mEnable,			fxSunLight ) );
   endGroup( "Debugging" );

   addGroup( "Media" );
	addField( "LocalFlareBitmap",		TypeFilename,	Offset(	mLocalFlareTextureName,	fxSunLight ) );
	addField( "RemoteFlareBitmap",		TypeFilename,	Offset(	mRemoteFlareTextureName,fxSunLight ) );
   endGroup( "Media" );

   // Sunlight.
   addGroup( "Sun Orbit" );
	addField( "SunAzimuth",			TypeF32,		Offset( mSunAzimuth,		fxSunLight ) );
	addField( "SunElevation",		TypeF32,		Offset( mSunElevation,		fxSunLight ) );
	addField( "LockToRealSun",		TypeBool,		Offset( mLockToRealSun,		fxSunLight ) );
   endGroup( "Sun Orbit" );

   // Flare.
   addGroup( "Lens Flare" );
	addField( "FlareTP",			TypeBool,		Offset( mFlareTP,			fxSunLight ) );
	addField( "Colour",				TypeColorF,		Offset( mFlareColour,		fxSunLight ) );
	addField( "Brightness",			TypeF32,		Offset( mFlareBrightness,	fxSunLight ) );
	addField( "FlareSize",			TypeF32,		Offset( mFlareSize,			fxSunLight ) );
	addField( "FadeTime",			TypeF32,		Offset( mFadeTime,			fxSunLight ) );
	addField( "BlendMode",			TypeS32,		Offset( mBlendMode,			fxSunLight ) );
   endGroup( "Lens Flare" );

   // Animation Options.
   addGroup( "Animation Options" );
	addField( "AnimColour",			TypeBool,		Offset( mUseColour,			fxSunLight ) );	
	addField( "AnimBrightness",		TypeBool,		Offset( mUseBrightness,		fxSunLight ) );	
	addField( "AnimRotation",		TypeBool,		Offset( mUseRotation,		fxSunLight ) );	
	addField( "AnimSize",			TypeBool,		Offset( mUseSize,			fxSunLight ) );	
	addField( "AnimAzimuth",		TypeBool,		Offset( mUseAzimuth,		fxSunLight ) );	
	addField( "AnimElevation",		TypeBool,		Offset( mUseElevation,		fxSunLight ) );	
	addField( "LerpColour",			TypeBool,		Offset( mLerpColour,		fxSunLight ) );	
	addField( "LerpBrightness",		TypeBool,		Offset( mLerpBrightness,	fxSunLight ) );	
	addField( "LerpRotation",		TypeBool,		Offset( mLerpRotation,		fxSunLight ) );	
	addField( "LerpSize",			TypeBool,		Offset( mLerpSize,			fxSunLight ) );	
	addField( "LerpAzimuth",		TypeBool,		Offset( mLerpAzimuth,		fxSunLight ) );	
	addField( "LerpElevation",		TypeBool,		Offset( mLerpElevation,		fxSunLight ) );	
	addField( "LinkFlareSize",		TypeBool,		Offset( mLinkFlareSize,		fxSunLight ) );	
	addField( "SingleColourKeys",	TypeBool,		Offset( mSingleColourKeys,	fxSunLight ) );	
   endGroup( "Animation Options" );

   // Animation Extents.
   addGroup( "Animation Extents" );
	addField( "MinColour",			TypeColorF,		Offset( mMinColour,			fxSunLight ) );
	addField( "MaxColour",			TypeColorF,		Offset( mMaxColour,			fxSunLight ) );
	addField( "MinBrightness",		TypeF32,		Offset( mMinBrightness,		fxSunLight ) );	
	addField( "MaxBrightness",		TypeF32,		Offset( mMaxBrightness,		fxSunLight ) );	
	addField( "MinRotation",		TypeF32,		Offset( mMinRotation,		fxSunLight ) );
	addField( "MaxRotation",		TypeF32,		Offset( mMaxRotation,		fxSunLight ) );
	addField( "MinSize",			TypeF32,		Offset( mMinSize,			fxSunLight ) );
	addField( "MaxSize",			TypeF32,		Offset( mMaxSize,			fxSunLight ) );
	addField( "MinAzimuth",			TypeF32,		Offset( mMinAzimuth,		fxSunLight ) );
	addField( "MaxAzimuth",			TypeF32,		Offset( mMaxAzimuth,		fxSunLight ) );
	addField( "MinElevation",		TypeF32,		Offset( mMinElevation,		fxSunLight ) );
	addField( "MaxElevation",		TypeF32,		Offset( mMaxElevation,		fxSunLight ) );
   endGroup( "Animation Extents" );

   // Animation Keys.
   addGroup( "Animation Keys" );
	addField( "RedKeys",			TypeString,		Offset( mRedKeys,			fxSunLight ) );
	addField( "GreenKeys",			TypeString,		Offset( mGreenKeys,			fxSunLight ) );
	addField( "BlueKeys",			TypeString,		Offset( mBlueKeys,			fxSunLight ) );
	addField( "BrightnessKeys",		TypeString,		Offset( mBrightnessKeys,	fxSunLight ) );
	addField( "RotationKeys",		TypeString,		Offset( mRotationKeys,		fxSunLight ) );
	addField( "SizeKeys",			TypeString,		Offset( mSizeKeys,			fxSunLight ) );
	addField( "AzimuthKeys",		TypeString,		Offset( mAzimuthKeys,		fxSunLight ) );
	addField( "ElevationKeys",		TypeString,		Offset( mElevationKeys,		fxSunLight ) );
   endGroup( "Animation Keys" );

   // Animation Times.
   addGroup( "Animation Times" );
	addField( "ColourTime",			TypeF32,		Offset( mColourTime,		fxSunLight ) );	
	addField( "BrightnessTime",		TypeF32,		Offset( mBrightnessTime,	fxSunLight ) );	
	addField( "RotationTime",		TypeF32,		Offset( mRotationTime,		fxSunLight ) );	
	addField( "SizeTime",			TypeF32,		Offset( mSizeTime,			fxSunLight ) );	
	addField( "AzimuthTime",		TypeF32,		Offset( mAzimuthTime,		fxSunLight ) );	
	addField( "ElevationTime",		TypeF32,		Offset( mElevationTime,		fxSunLight ) );	
   endGroup( "Animation Times" );
}

//------------------------------------------------------------------------------

// ********************************************************************************
// Debugging.
// ********************************************************************************

void fxSunLight::setEnable(bool Status)
{
   // Set Attribute.
   mEnable = Status;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

// ********************************************************************************
// Media.
// ********************************************************************************

void fxSunLight::setFlareBitmaps(const char* LocalName, const char* RemoteName)
{
   // Set Flare Texture Names.
   mLocalFlareTextureName = StringTable->insert(LocalName);
   mRemoteFlareTextureName = StringTable->insert(RemoteName);

   // Only let the client load an actual texture.
   if (isClientObject())
   {
      // Reset existing flare texture.
      mLocalFlareTextureHandle = NULL;
      mRemoteFlareTextureHandle = NULL;

      // Load textures if valid.
      if (*mLocalFlareTextureName) mLocalFlareTextureHandle = TextureHandle(mLocalFlareTextureName, BitmapTexture, true);
      if (*mRemoteFlareTextureName) mRemoteFlareTextureHandle = TextureHandle(mRemoteFlareTextureName, BitmapTexture, true);
   }

   // Set Config Change Mask.
#ifndef TGE_RPGCLIENT2 /// TGE_RPGIsServerObject
   if (isServerObject())
#endif
		setMaskBits(fxSunLightConfigChangeMask);
}

// ********************************************************************************
// Sun Orbit.
// ********************************************************************************

void fxSunLight::setSunAzimuth(F32 Azimuth)
{
   // Set Attribute.
   mSunAzimuth = Azimuth;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setSunElevation(F32 Elevation)
{
   // Set Attribute.
   mSunElevation = Elevation;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

// ********************************************************************************
// Flare.
// ********************************************************************************

void fxSunLight::setFlareTP(bool Status)
{
   // Set Attribute.
   mFlareTP = Status;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setFlareColour(ColorF Colour)
{
   // Set Attribute.
   mFlareColour = Colour;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setFlareBrightness(F32 Brightness)
{
   // Set Attribute.
   mFlareBrightness = Brightness;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setFlareSize(F32 Size)
{
   // Set Attribute.
   mFlareSize = Size;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setFadeTime(F32 Time)
{
   // Set Attribute.
   mFadeTime = Time;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setBlendMode(U32 Mode)
{
   // Set Attribute.
   mBlendMode = Mode;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

// ********************************************************************************
// Animation Options.
// ********************************************************************************

void fxSunLight::setUseColour(bool Status)
{
   // Set Attribute.
   mUseColour = Status;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setUseBrightness(bool Status)
{
   // Set Attribute.
   mUseBrightness = Status;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setUseRotation(bool Status)
{
   // Set Attribute.
   mUseRotation = Status;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setUseSize(bool Status)
{
   // Set Attribute.
   mUseSize = Status;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setUseAzimuth(bool Status)
{
   // Set Attribute.
   mUseAzimuth = Status;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setUseElevation(bool Status)
{
   // Set Attribute.
   mUseElevation = Status;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setLerpColour(bool Status)
{
   // Set Attribute.
   mLerpColour = Status;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setLerpBrightness(bool Status)
{
   // Set Attribute.
   mLerpBrightness = Status;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setLerpRotation(bool Status)
{
   // Set Attribute.
   mLerpRotation = Status;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setLerpSize(bool Status)
{
   // Set Attribute.
   mLerpSize = Status;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setLerpAzimuth(bool Status)
{
   // Set Attribute.
   mLerpAzimuth = Status;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setLerpElevation(bool Status)
{
   // Set Attribute.
   mLerpElevation = Status;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setLinkFlareSize(bool Status)
{
   // Set Attribute.
   mLinkFlareSize = Status;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setSingleColourKeys(bool Status)
{
   // Set Attribute.
   mSingleColourKeys = Status;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

// ********************************************************************************
// Animation Extents.
// ********************************************************************************

void fxSunLight::setMinColour(ColorF Colour)
{
   // Set Attribute.
   mMinColour = Colour;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setMaxColour(ColorF Colour)
{
   // Set Attribute.
   mMaxColour = Colour;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setMinBrightness(F32 Brightness)
{
   // Set Attribute.
   mMinBrightness = Brightness;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setMaxBrightness(F32 Brightness)
{
   // Set Attribute.
   mMaxBrightness = Brightness;
   // Set Config Change Mask.
   if (isServerObject()) setMaskBits(fxSunLightConfigChangeMask);
}

void fxSunLight::setMinRotation(F32 Rotation)
{
   // Set Attribute.
   mMinRotation = Rotation;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -