mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Fix line endings and tabs
This commit is contained in:
@ -1,234 +1,234 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsUtils.h"
|
||||
#include "hsScalar.h"
|
||||
#include "hsMemory.h"
|
||||
#include "hsGRenderProcs.h"
|
||||
#include "hsStream.h"
|
||||
#include "../plResMgr/plKey.h"
|
||||
#include "../plResMgr/hsResMgr.h"
|
||||
|
||||
hsGRenderProcs::hsGRenderProcs()
|
||||
: fNext(nil),
|
||||
fBack(nil),
|
||||
fPipeline(nil),
|
||||
fFlags(kNone),
|
||||
fLinkCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
hsGRenderProcs::~hsGRenderProcs()
|
||||
{
|
||||
}
|
||||
|
||||
hsGRenderProcs** hsGRenderProcs::IOneBeforeMe(hsGRenderProcs** base)
|
||||
{
|
||||
hsAssert(base, "Searching for place in baseless list");
|
||||
|
||||
if( !*base ||((*base)->GetPriority() > GetPriority()) )
|
||||
return base;
|
||||
|
||||
hsGRenderProcs* trav = *base;
|
||||
|
||||
while( trav->fNext && (trav->fNext->GetPriority() > GetPriority()) )
|
||||
trav = trav->fNext;
|
||||
|
||||
hsAssert((trav != this)&&(trav->fNext != this), "Found self in bad place");
|
||||
return &trav->fNext;
|
||||
}
|
||||
|
||||
void hsGRenderProcs::IInsert(hsGRenderProcs** ptr)
|
||||
{
|
||||
hsAssert(*ptr != this, "Re-Inserting self");
|
||||
hsAssert(ptr, "Inserting into nil list");
|
||||
if( *ptr )
|
||||
(*ptr)->fBack = &fNext;
|
||||
fNext = *ptr;
|
||||
fBack = ptr;
|
||||
*ptr = this;
|
||||
}
|
||||
|
||||
void hsGRenderProcs::IDetach()
|
||||
{
|
||||
if( fNext )
|
||||
fNext->fBack = fBack;
|
||||
*fBack = fNext;
|
||||
|
||||
fNext = nil;
|
||||
fBack = nil;
|
||||
}
|
||||
|
||||
void hsGRenderProcs::Enqueue(hsGRenderProcs** base)
|
||||
{
|
||||
// Already linked? Just note another link.
|
||||
if( fLinkCount++ )
|
||||
return;
|
||||
|
||||
IInsert(IOneBeforeMe(base));
|
||||
Ref();
|
||||
}
|
||||
|
||||
void hsGRenderProcs::Dequeue()
|
||||
{
|
||||
if( fBack && !--fLinkCount )
|
||||
{
|
||||
IDetach();
|
||||
UnRef();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void hsGRenderProcs::Read(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
SetFlags(s->ReadSwap32());
|
||||
ReadObjectRefs(s, mgr);
|
||||
Read(s);
|
||||
}
|
||||
|
||||
void hsGRenderProcs::ReadObjectRefs(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
if( fFlags & kObjectRefs )
|
||||
{
|
||||
int n = s->ReadSwap32();
|
||||
fObjectRefs.SetCount(n);
|
||||
int i;
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
fObjectRefs[i] = mgr->ReadKey(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hsGRenderProcs::WriteObjectRefs(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
if( fFlags & kObjectRefs )
|
||||
{
|
||||
s->WriteSwap32(fObjectRefs.GetCount());
|
||||
int i;
|
||||
for( i = 0; i < fObjectRefs.GetCount(); i++ )
|
||||
{
|
||||
// if( fObjectRefs[i] )
|
||||
{
|
||||
mgr->WriteKey(s,fObjectRefs[i]); // writes nil any...right?
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// mgr->WriteKey(s, nil);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hsGRenderProcs::Write(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
s->WriteSwap32(fFlags);
|
||||
|
||||
WriteObjectRefs(s, mgr);
|
||||
Write(s);
|
||||
}
|
||||
|
||||
plDrawable* hsGRenderProcs::GetObjectRef(int i)
|
||||
{
|
||||
return (plDrawable*)((i < fObjectRefs.GetCount()) && fObjectRefs[i] ? fObjectRefs[i]->GetObjectPtr() : nil);
|
||||
}
|
||||
|
||||
void hsGRenderProcs::SetNumObjectRefs(int n)
|
||||
{
|
||||
if( n > fObjectRefs.GetCount() )
|
||||
{
|
||||
int oldCnt = fObjectRefs.GetCount();
|
||||
fObjectRefs.SetCount(n);
|
||||
int i;
|
||||
for( i = oldCnt; i < n; i++ )
|
||||
fObjectRefs[i] = nil;
|
||||
}
|
||||
}
|
||||
|
||||
void hsGRenderProcs::SetObjectRef(plKey* key, int i)
|
||||
{
|
||||
if( i >= fObjectRefs.GetCount() )
|
||||
SetNumObjectRefs(i+1);
|
||||
fObjectRefs[i] = key;
|
||||
fFlags |= kObjectRefs;
|
||||
}
|
||||
|
||||
hsBool32 hsGRenderProcs::BeginTree(plPipeline* pipe, plDrawable* root)
|
||||
{
|
||||
hsAssert(fFlags & kObjectRefsInit, "Should have had refs initialized on read");
|
||||
|
||||
fPipeline = pipe;
|
||||
|
||||
if( Inclusive() )
|
||||
{
|
||||
fColorizer.Init(pipe);
|
||||
hsColorRGBA col = fColorizer.GetCurrentColor();
|
||||
if( !fColorizer.Colorizing() )
|
||||
{
|
||||
col.r = col.g = col.b = 1.f;
|
||||
}
|
||||
if( !fColorizer.Alpharizing() )
|
||||
col.a = 0.999f;
|
||||
fColorizer.PushColorize(col, !fColorizer.Colorizing() /* alpha only */);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
hsBool32 hsGRenderProcs::BeginObject(plPipeline* pipe, plDrawable* obj)
|
||||
{
|
||||
hsAssert(fFlags & kObjectRefsInit, "Should have had refs initialized on read");
|
||||
|
||||
fPipeline = pipe;
|
||||
|
||||
if( !Inclusive() )
|
||||
{
|
||||
fColorizer.Init(pipe);
|
||||
hsColorRGBA col = fColorizer.GetCurrentColor();
|
||||
if( !fColorizer.Colorizing() )
|
||||
{
|
||||
col.r = col.g = col.b = 1.f;
|
||||
}
|
||||
if( !fColorizer.Alpharizing() )
|
||||
col.a = 0.999f;
|
||||
fColorizer.PushColorize(col, !fColorizer.Colorizing() /* alpha only */);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void hsGRenderProcs::EndObject()
|
||||
{
|
||||
if( !Inclusive() )
|
||||
fColorizer.PopColorize();
|
||||
}
|
||||
|
||||
void hsGRenderProcs::EndTree()
|
||||
{
|
||||
if( Inclusive() )
|
||||
fColorizer.PopColorize();
|
||||
fPipeline = nil;
|
||||
}
|
||||
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsUtils.h"
|
||||
#include "hsScalar.h"
|
||||
#include "hsMemory.h"
|
||||
#include "hsGRenderProcs.h"
|
||||
#include "hsStream.h"
|
||||
#include "../plResMgr/plKey.h"
|
||||
#include "../plResMgr/hsResMgr.h"
|
||||
|
||||
hsGRenderProcs::hsGRenderProcs()
|
||||
: fNext(nil),
|
||||
fBack(nil),
|
||||
fPipeline(nil),
|
||||
fFlags(kNone),
|
||||
fLinkCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
hsGRenderProcs::~hsGRenderProcs()
|
||||
{
|
||||
}
|
||||
|
||||
hsGRenderProcs** hsGRenderProcs::IOneBeforeMe(hsGRenderProcs** base)
|
||||
{
|
||||
hsAssert(base, "Searching for place in baseless list");
|
||||
|
||||
if( !*base ||((*base)->GetPriority() > GetPriority()) )
|
||||
return base;
|
||||
|
||||
hsGRenderProcs* trav = *base;
|
||||
|
||||
while( trav->fNext && (trav->fNext->GetPriority() > GetPriority()) )
|
||||
trav = trav->fNext;
|
||||
|
||||
hsAssert((trav != this)&&(trav->fNext != this), "Found self in bad place");
|
||||
return &trav->fNext;
|
||||
}
|
||||
|
||||
void hsGRenderProcs::IInsert(hsGRenderProcs** ptr)
|
||||
{
|
||||
hsAssert(*ptr != this, "Re-Inserting self");
|
||||
hsAssert(ptr, "Inserting into nil list");
|
||||
if( *ptr )
|
||||
(*ptr)->fBack = &fNext;
|
||||
fNext = *ptr;
|
||||
fBack = ptr;
|
||||
*ptr = this;
|
||||
}
|
||||
|
||||
void hsGRenderProcs::IDetach()
|
||||
{
|
||||
if( fNext )
|
||||
fNext->fBack = fBack;
|
||||
*fBack = fNext;
|
||||
|
||||
fNext = nil;
|
||||
fBack = nil;
|
||||
}
|
||||
|
||||
void hsGRenderProcs::Enqueue(hsGRenderProcs** base)
|
||||
{
|
||||
// Already linked? Just note another link.
|
||||
if( fLinkCount++ )
|
||||
return;
|
||||
|
||||
IInsert(IOneBeforeMe(base));
|
||||
Ref();
|
||||
}
|
||||
|
||||
void hsGRenderProcs::Dequeue()
|
||||
{
|
||||
if( fBack && !--fLinkCount )
|
||||
{
|
||||
IDetach();
|
||||
UnRef();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void hsGRenderProcs::Read(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
SetFlags(s->ReadSwap32());
|
||||
ReadObjectRefs(s, mgr);
|
||||
Read(s);
|
||||
}
|
||||
|
||||
void hsGRenderProcs::ReadObjectRefs(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
if( fFlags & kObjectRefs )
|
||||
{
|
||||
int n = s->ReadSwap32();
|
||||
fObjectRefs.SetCount(n);
|
||||
int i;
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
fObjectRefs[i] = mgr->ReadKey(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hsGRenderProcs::WriteObjectRefs(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
if( fFlags & kObjectRefs )
|
||||
{
|
||||
s->WriteSwap32(fObjectRefs.GetCount());
|
||||
int i;
|
||||
for( i = 0; i < fObjectRefs.GetCount(); i++ )
|
||||
{
|
||||
// if( fObjectRefs[i] )
|
||||
{
|
||||
mgr->WriteKey(s,fObjectRefs[i]); // writes nil any...right?
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// mgr->WriteKey(s, nil);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hsGRenderProcs::Write(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
s->WriteSwap32(fFlags);
|
||||
|
||||
WriteObjectRefs(s, mgr);
|
||||
Write(s);
|
||||
}
|
||||
|
||||
plDrawable* hsGRenderProcs::GetObjectRef(int i)
|
||||
{
|
||||
return (plDrawable*)((i < fObjectRefs.GetCount()) && fObjectRefs[i] ? fObjectRefs[i]->GetObjectPtr() : nil);
|
||||
}
|
||||
|
||||
void hsGRenderProcs::SetNumObjectRefs(int n)
|
||||
{
|
||||
if( n > fObjectRefs.GetCount() )
|
||||
{
|
||||
int oldCnt = fObjectRefs.GetCount();
|
||||
fObjectRefs.SetCount(n);
|
||||
int i;
|
||||
for( i = oldCnt; i < n; i++ )
|
||||
fObjectRefs[i] = nil;
|
||||
}
|
||||
}
|
||||
|
||||
void hsGRenderProcs::SetObjectRef(plKey* key, int i)
|
||||
{
|
||||
if( i >= fObjectRefs.GetCount() )
|
||||
SetNumObjectRefs(i+1);
|
||||
fObjectRefs[i] = key;
|
||||
fFlags |= kObjectRefs;
|
||||
}
|
||||
|
||||
hsBool32 hsGRenderProcs::BeginTree(plPipeline* pipe, plDrawable* root)
|
||||
{
|
||||
hsAssert(fFlags & kObjectRefsInit, "Should have had refs initialized on read");
|
||||
|
||||
fPipeline = pipe;
|
||||
|
||||
if( Inclusive() )
|
||||
{
|
||||
fColorizer.Init(pipe);
|
||||
hsColorRGBA col = fColorizer.GetCurrentColor();
|
||||
if( !fColorizer.Colorizing() )
|
||||
{
|
||||
col.r = col.g = col.b = 1.f;
|
||||
}
|
||||
if( !fColorizer.Alpharizing() )
|
||||
col.a = 0.999f;
|
||||
fColorizer.PushColorize(col, !fColorizer.Colorizing() /* alpha only */);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
hsBool32 hsGRenderProcs::BeginObject(plPipeline* pipe, plDrawable* obj)
|
||||
{
|
||||
hsAssert(fFlags & kObjectRefsInit, "Should have had refs initialized on read");
|
||||
|
||||
fPipeline = pipe;
|
||||
|
||||
if( !Inclusive() )
|
||||
{
|
||||
fColorizer.Init(pipe);
|
||||
hsColorRGBA col = fColorizer.GetCurrentColor();
|
||||
if( !fColorizer.Colorizing() )
|
||||
{
|
||||
col.r = col.g = col.b = 1.f;
|
||||
}
|
||||
if( !fColorizer.Alpharizing() )
|
||||
col.a = 0.999f;
|
||||
fColorizer.PushColorize(col, !fColorizer.Colorizing() /* alpha only */);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void hsGRenderProcs::EndObject()
|
||||
{
|
||||
if( !Inclusive() )
|
||||
fColorizer.PopColorize();
|
||||
}
|
||||
|
||||
void hsGRenderProcs::EndTree()
|
||||
{
|
||||
if( Inclusive() )
|
||||
fColorizer.PopColorize();
|
||||
fPipeline = nil;
|
||||
}
|
||||
|
||||
|
@ -1,202 +1,202 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef hsGRenderProcs_inc
|
||||
#define hsGRenderProcs_inc
|
||||
|
||||
#include "hsRefCnt.h"
|
||||
#include "hsScalar.h"
|
||||
#include "hsMemory.h"
|
||||
#include "hsBiExpander.h"
|
||||
#include "../plPipeline/hsGColorizer.h"
|
||||
#include "../plResMgr/plCreatable.h"
|
||||
|
||||
class plPipeline;
|
||||
class plDrawable;
|
||||
class hsTriangle3;
|
||||
struct hsGTriVertex;
|
||||
struct hsGVertex3;
|
||||
struct hsGShadeVertex;
|
||||
struct hsGSplat3;
|
||||
class hsStream;
|
||||
class plKey;
|
||||
class hsBounds3Ext;
|
||||
class hsResMgr;
|
||||
|
||||
class hsGRenderProcs : public plCreatable {
|
||||
public:
|
||||
enum {
|
||||
kMaxLabelLen = 128
|
||||
};
|
||||
enum ProcType {
|
||||
kTypeAngleFade,
|
||||
kTypeDistFade,
|
||||
kTypeMotionBlur1,
|
||||
kTypeMotionBlur2,
|
||||
kTypeIntenseAlpha,
|
||||
kTypeGlobalShade,
|
||||
kTypeObjDistFade,
|
||||
kTypeDistShade,
|
||||
kTypeObjDistShade
|
||||
};
|
||||
enum {
|
||||
kNone = 0x0,
|
||||
kInclusive = 0x1, // Affect children
|
||||
kNOP = 0x2, // Turned off (till EndObject)
|
||||
kOpaque = 0x4,
|
||||
kCulled = 0x8,
|
||||
kObjectRefs = 0x10,
|
||||
kObjectRefsInit = 0x20
|
||||
};
|
||||
private:
|
||||
// Base class private stuff for managing the Queue of Procs on the device.
|
||||
|
||||
UInt32 fLinkCount;
|
||||
hsGRenderProcs* fNext;
|
||||
hsGRenderProcs** fBack;
|
||||
|
||||
hsGRenderProcs** IOneBeforeMe(hsGRenderProcs** base);
|
||||
void IInsert(hsGRenderProcs** beforeMe);
|
||||
void IDetach();
|
||||
|
||||
protected:
|
||||
|
||||
UInt32 fFlags;
|
||||
|
||||
hsGColorizer fColorizer;
|
||||
|
||||
plPipeline* fPipeline;
|
||||
|
||||
hsDynamicArray<plKey*> fObjectRefs;
|
||||
public:
|
||||
hsGRenderProcs();
|
||||
virtual ~hsGRenderProcs();
|
||||
|
||||
// BeginTree returns false if entire subtree is don't bother to draw,
|
||||
// else true. Mostly a culling tool.
|
||||
virtual hsBool32 BeginTree(plPipeline* pipe, plDrawable* root);
|
||||
|
||||
// BeginObject returns true if the object should be drawn, false if
|
||||
// don't bother. Can also do any initialization it wants. Should this
|
||||
// get something more innocuous like a bound instead of the SceneObject?
|
||||
// Is there anything else it might need to know?
|
||||
virtual hsBool32 BeginObject(plPipeline* pipe, plDrawable* obj);
|
||||
|
||||
// ProcessVerts takes the list of TriVerts and does what it will.
|
||||
// I'll outline the hsGTriVertex below. The difference between
|
||||
// the BaseVertex list and the UsedVertex list is interpolation.
|
||||
// Shade values and generated Texture Coords are computed for
|
||||
// the Base Triangle only, and then interpolated for vertices
|
||||
// generated by clipping. So Shade Values and Texture Coordinates
|
||||
// should only be computed in ProcessBaseVerts(). On the other
|
||||
// hand, only the vertices from actual drawn triangles are
|
||||
// transformed, and hence have a screen position to mess with.
|
||||
// So any wiggling of the screen position should happen in
|
||||
// ProcessUsedVerts(). These functions might be better named
|
||||
// ProcessShadeVerts() and ProcessXformVerts(), except that
|
||||
// vertex illumination (shade) is interpolated, but then
|
||||
// the interpolated shade is fed into the material to calculate
|
||||
// color. So messing with final color would happen in ProcessUsedVerts(),
|
||||
// whereas messing with illumination's in ProcessBaseVerts(). Messing
|
||||
// with UV's is equally valid in either. In general though, the number
|
||||
// of BaseVerts is less than or equal to the number of UsedVerts. Most
|
||||
// shaders would have one or the other a no-op.
|
||||
|
||||
// Process list of unique vertices (with unique hsGXformVerts) which will be drawn to screen
|
||||
virtual void ProcessScreenVerts(hsExpander<hsGVertex3*>& vList) {}
|
||||
|
||||
// Take a list of verts and modulate shades for them. Care should be taken to only bother with verts that
|
||||
// are not (hsGVertex3::kCulled|hsGVertex3::kDisabled). Also, any verts that this RenderProc causes
|
||||
// to go completely transparent should be flagged hsGVertex3::kCulled (NOT DISABLED).
|
||||
// See hsSfxDistFade for example (not exemplary) code.
|
||||
|
||||
// Process list of unique vertices (unique hsGShadeVerts) before interpolation
|
||||
virtual void ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList) {}
|
||||
// Process list of unique vertices (unique hsGShadeVerts) after interpolation - these will be drawn to screen
|
||||
virtual void ProcessPostInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList) {}
|
||||
|
||||
// Process list of unique Pre or Post Interpolation TriVerts (with hsGShade and hsGXformVerts)
|
||||
// While the TriVerts are unique, there may be sharing among constituents, i.e. position and uv.
|
||||
// Care must be taken when accumulating effects.
|
||||
virtual void ProcessPreInterpVerts(hsExpander<hsGTriVertex*>& vList) {}
|
||||
virtual void ProcessPostInterpVerts(hsExpander<hsGTriVertex*>& vList) {}
|
||||
|
||||
// Process list of triangles which are headed for the screen. vList is the full list of unique TriVerts
|
||||
// used by these triangles. If triangles are added, any generated verts MUST be added to vList. If
|
||||
// Triangles are removed, verts may be removed from vList (keeping in mind that vList verts may be
|
||||
// shared between triangles).
|
||||
virtual void ProcessPreClipTris(hsExpander<hsTriangle3*>& tList, hsExpander<hsGTriVertex*>& vList) {}
|
||||
virtual void ProcessPreInterpTris(hsExpander<hsTriangle3*>& tList, hsExpander<hsGTriVertex*>& vList) {}
|
||||
virtual void ProcessPostInterpTris(hsExpander<hsTriangle3*>& tList, hsExpander<hsGTriVertex*>& vList) {}
|
||||
|
||||
// Any cleanup for this object
|
||||
virtual void EndObject();
|
||||
|
||||
// Any cleanup for this subtree
|
||||
virtual void EndTree();
|
||||
|
||||
// Shaders can set their priority to affect order in which they are called
|
||||
// When pushed onto device, device uses this priority to sort into queue
|
||||
virtual hsScalar GetPriority() { return 0; }
|
||||
|
||||
// When a shader is pushed onto the device (by an object), the object
|
||||
// will pop it back off either before or after drawing its children,
|
||||
// depending on Inclusive(). Not meaningful for mate
|
||||
virtual hsBool32 Inclusive() { return fFlags & kInclusive; }
|
||||
|
||||
virtual void Enqueue(hsGRenderProcs** list);
|
||||
virtual void Dequeue();
|
||||
hsGRenderProcs* GetNext() { return fNext; }
|
||||
|
||||
// External object references. Individual RenderProc type responsible for what they're used for.
|
||||
void SetNumObjectRefs(int n);
|
||||
UInt32 GetNumObjectRefs() { return fObjectRefs.GetCount(); }
|
||||
void AddObjectRef(plKey* key) { fObjectRefs.Append(key); fFlags |= kObjectRefs; }
|
||||
void SetObjectRef(plKey* key, int i=0);
|
||||
void InsertObjectRef(int i, plKey* key) { fObjectRefs.InsertAtIndex(i, key); fFlags |= kObjectRefs; }
|
||||
plDrawable* GetObjectRef(int i);
|
||||
plKey* GetObjectRefKey(int i) { return fObjectRefs[i]; }
|
||||
void ReadObjectRefs(hsStream* s, hsResMgr* mgr);
|
||||
void WriteObjectRefs(hsStream* s, hsResMgr* mgr);
|
||||
|
||||
|
||||
virtual void Read(hsStream* s, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* s, hsResMgr* mgr);
|
||||
|
||||
virtual void Read(hsStream* s) = 0;
|
||||
virtual void Write(hsStream* s) = 0;
|
||||
|
||||
virtual const char* GetLabel() const = 0;
|
||||
virtual ProcType GetType() const = 0;
|
||||
|
||||
UInt32 GetFlags() { return fFlags; }
|
||||
void SetFlags(UInt32 f) { fFlags = f; }
|
||||
|
||||
CLASSNAME_REGISTER( hsGRenderProcs );
|
||||
GETINTERFACE_ANY( hsGRenderProcs, plCreatable );
|
||||
};
|
||||
|
||||
#endif // hsGRenderProcs_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef hsGRenderProcs_inc
|
||||
#define hsGRenderProcs_inc
|
||||
|
||||
#include "hsRefCnt.h"
|
||||
#include "hsScalar.h"
|
||||
#include "hsMemory.h"
|
||||
#include "hsBiExpander.h"
|
||||
#include "../plPipeline/hsGColorizer.h"
|
||||
#include "../plResMgr/plCreatable.h"
|
||||
|
||||
class plPipeline;
|
||||
class plDrawable;
|
||||
class hsTriangle3;
|
||||
struct hsGTriVertex;
|
||||
struct hsGVertex3;
|
||||
struct hsGShadeVertex;
|
||||
struct hsGSplat3;
|
||||
class hsStream;
|
||||
class plKey;
|
||||
class hsBounds3Ext;
|
||||
class hsResMgr;
|
||||
|
||||
class hsGRenderProcs : public plCreatable {
|
||||
public:
|
||||
enum {
|
||||
kMaxLabelLen = 128
|
||||
};
|
||||
enum ProcType {
|
||||
kTypeAngleFade,
|
||||
kTypeDistFade,
|
||||
kTypeMotionBlur1,
|
||||
kTypeMotionBlur2,
|
||||
kTypeIntenseAlpha,
|
||||
kTypeGlobalShade,
|
||||
kTypeObjDistFade,
|
||||
kTypeDistShade,
|
||||
kTypeObjDistShade
|
||||
};
|
||||
enum {
|
||||
kNone = 0x0,
|
||||
kInclusive = 0x1, // Affect children
|
||||
kNOP = 0x2, // Turned off (till EndObject)
|
||||
kOpaque = 0x4,
|
||||
kCulled = 0x8,
|
||||
kObjectRefs = 0x10,
|
||||
kObjectRefsInit = 0x20
|
||||
};
|
||||
private:
|
||||
// Base class private stuff for managing the Queue of Procs on the device.
|
||||
|
||||
UInt32 fLinkCount;
|
||||
hsGRenderProcs* fNext;
|
||||
hsGRenderProcs** fBack;
|
||||
|
||||
hsGRenderProcs** IOneBeforeMe(hsGRenderProcs** base);
|
||||
void IInsert(hsGRenderProcs** beforeMe);
|
||||
void IDetach();
|
||||
|
||||
protected:
|
||||
|
||||
UInt32 fFlags;
|
||||
|
||||
hsGColorizer fColorizer;
|
||||
|
||||
plPipeline* fPipeline;
|
||||
|
||||
hsDynamicArray<plKey*> fObjectRefs;
|
||||
public:
|
||||
hsGRenderProcs();
|
||||
virtual ~hsGRenderProcs();
|
||||
|
||||
// BeginTree returns false if entire subtree is don't bother to draw,
|
||||
// else true. Mostly a culling tool.
|
||||
virtual hsBool32 BeginTree(plPipeline* pipe, plDrawable* root);
|
||||
|
||||
// BeginObject returns true if the object should be drawn, false if
|
||||
// don't bother. Can also do any initialization it wants. Should this
|
||||
// get something more innocuous like a bound instead of the SceneObject?
|
||||
// Is there anything else it might need to know?
|
||||
virtual hsBool32 BeginObject(plPipeline* pipe, plDrawable* obj);
|
||||
|
||||
// ProcessVerts takes the list of TriVerts and does what it will.
|
||||
// I'll outline the hsGTriVertex below. The difference between
|
||||
// the BaseVertex list and the UsedVertex list is interpolation.
|
||||
// Shade values and generated Texture Coords are computed for
|
||||
// the Base Triangle only, and then interpolated for vertices
|
||||
// generated by clipping. So Shade Values and Texture Coordinates
|
||||
// should only be computed in ProcessBaseVerts(). On the other
|
||||
// hand, only the vertices from actual drawn triangles are
|
||||
// transformed, and hence have a screen position to mess with.
|
||||
// So any wiggling of the screen position should happen in
|
||||
// ProcessUsedVerts(). These functions might be better named
|
||||
// ProcessShadeVerts() and ProcessXformVerts(), except that
|
||||
// vertex illumination (shade) is interpolated, but then
|
||||
// the interpolated shade is fed into the material to calculate
|
||||
// color. So messing with final color would happen in ProcessUsedVerts(),
|
||||
// whereas messing with illumination's in ProcessBaseVerts(). Messing
|
||||
// with UV's is equally valid in either. In general though, the number
|
||||
// of BaseVerts is less than or equal to the number of UsedVerts. Most
|
||||
// shaders would have one or the other a no-op.
|
||||
|
||||
// Process list of unique vertices (with unique hsGXformVerts) which will be drawn to screen
|
||||
virtual void ProcessScreenVerts(hsExpander<hsGVertex3*>& vList) {}
|
||||
|
||||
// Take a list of verts and modulate shades for them. Care should be taken to only bother with verts that
|
||||
// are not (hsGVertex3::kCulled|hsGVertex3::kDisabled). Also, any verts that this RenderProc causes
|
||||
// to go completely transparent should be flagged hsGVertex3::kCulled (NOT DISABLED).
|
||||
// See hsSfxDistFade for example (not exemplary) code.
|
||||
|
||||
// Process list of unique vertices (unique hsGShadeVerts) before interpolation
|
||||
virtual void ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList) {}
|
||||
// Process list of unique vertices (unique hsGShadeVerts) after interpolation - these will be drawn to screen
|
||||
virtual void ProcessPostInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList) {}
|
||||
|
||||
// Process list of unique Pre or Post Interpolation TriVerts (with hsGShade and hsGXformVerts)
|
||||
// While the TriVerts are unique, there may be sharing among constituents, i.e. position and uv.
|
||||
// Care must be taken when accumulating effects.
|
||||
virtual void ProcessPreInterpVerts(hsExpander<hsGTriVertex*>& vList) {}
|
||||
virtual void ProcessPostInterpVerts(hsExpander<hsGTriVertex*>& vList) {}
|
||||
|
||||
// Process list of triangles which are headed for the screen. vList is the full list of unique TriVerts
|
||||
// used by these triangles. If triangles are added, any generated verts MUST be added to vList. If
|
||||
// Triangles are removed, verts may be removed from vList (keeping in mind that vList verts may be
|
||||
// shared between triangles).
|
||||
virtual void ProcessPreClipTris(hsExpander<hsTriangle3*>& tList, hsExpander<hsGTriVertex*>& vList) {}
|
||||
virtual void ProcessPreInterpTris(hsExpander<hsTriangle3*>& tList, hsExpander<hsGTriVertex*>& vList) {}
|
||||
virtual void ProcessPostInterpTris(hsExpander<hsTriangle3*>& tList, hsExpander<hsGTriVertex*>& vList) {}
|
||||
|
||||
// Any cleanup for this object
|
||||
virtual void EndObject();
|
||||
|
||||
// Any cleanup for this subtree
|
||||
virtual void EndTree();
|
||||
|
||||
// Shaders can set their priority to affect order in which they are called
|
||||
// When pushed onto device, device uses this priority to sort into queue
|
||||
virtual hsScalar GetPriority() { return 0; }
|
||||
|
||||
// When a shader is pushed onto the device (by an object), the object
|
||||
// will pop it back off either before or after drawing its children,
|
||||
// depending on Inclusive(). Not meaningful for mate
|
||||
virtual hsBool32 Inclusive() { return fFlags & kInclusive; }
|
||||
|
||||
virtual void Enqueue(hsGRenderProcs** list);
|
||||
virtual void Dequeue();
|
||||
hsGRenderProcs* GetNext() { return fNext; }
|
||||
|
||||
// External object references. Individual RenderProc type responsible for what they're used for.
|
||||
void SetNumObjectRefs(int n);
|
||||
UInt32 GetNumObjectRefs() { return fObjectRefs.GetCount(); }
|
||||
void AddObjectRef(plKey* key) { fObjectRefs.Append(key); fFlags |= kObjectRefs; }
|
||||
void SetObjectRef(plKey* key, int i=0);
|
||||
void InsertObjectRef(int i, plKey* key) { fObjectRefs.InsertAtIndex(i, key); fFlags |= kObjectRefs; }
|
||||
plDrawable* GetObjectRef(int i);
|
||||
plKey* GetObjectRefKey(int i) { return fObjectRefs[i]; }
|
||||
void ReadObjectRefs(hsStream* s, hsResMgr* mgr);
|
||||
void WriteObjectRefs(hsStream* s, hsResMgr* mgr);
|
||||
|
||||
|
||||
virtual void Read(hsStream* s, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* s, hsResMgr* mgr);
|
||||
|
||||
virtual void Read(hsStream* s) = 0;
|
||||
virtual void Write(hsStream* s) = 0;
|
||||
|
||||
virtual const char* GetLabel() const = 0;
|
||||
virtual ProcType GetType() const = 0;
|
||||
|
||||
UInt32 GetFlags() { return fFlags; }
|
||||
void SetFlags(UInt32 f) { fFlags = f; }
|
||||
|
||||
CLASSNAME_REGISTER( hsGRenderProcs );
|
||||
GETINTERFACE_ANY( hsGRenderProcs, plCreatable );
|
||||
};
|
||||
|
||||
#endif // hsGRenderProcs_inc
|
||||
|
@ -1,218 +1,218 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsMemory.h"
|
||||
#include "hsSfxAngleFade.h"
|
||||
#include "hsStream.h"
|
||||
#include "../plPipeline/plPipeline.h"
|
||||
//#include "../plPipeline/hsG3DDevice.h"
|
||||
#include "../plGeometry/hsTriangle3.h"
|
||||
#include "../plMath/hsFastMath.h"
|
||||
|
||||
hsSfxAngleFade::hsSfxAngleFade()
|
||||
{
|
||||
}
|
||||
|
||||
hsSfxAngleFade::~hsSfxAngleFade()
|
||||
{
|
||||
}
|
||||
|
||||
hsScalar hsSfxAngleFade::IOpacFromDot(hsScalar dot)
|
||||
{
|
||||
if( (fFlags & kTwoSided)
|
||||
&&(dot < 0) )
|
||||
dot = -dot;
|
||||
|
||||
if( dot <= fTable[0].fCosineDel )
|
||||
return fTable[0].fOpacity;
|
||||
|
||||
int i;
|
||||
for( i = 0; (i < fTable.GetCount()) && (dot >= fTable[i].fCosineDel); i++ )
|
||||
dot -= fTable[i].fCosineDel;
|
||||
|
||||
if( i >= fTable.GetCount() )
|
||||
return fTable[fTable.GetCount()-1].fOpacity;
|
||||
|
||||
dot *= fTable[i-1].fCosineNorm;
|
||||
hsScalar opac0 = fTable[i-1].fOpacity;
|
||||
hsScalar opac1 = fTable[i].fOpacity;
|
||||
|
||||
return opac0 + dot * (opac1 - opac0);
|
||||
}
|
||||
|
||||
void hsSfxAngleFade::ProcessPreInterpTris(hsExpander<hsTriangle3*>& tList, hsExpander<hsGTriVertex*>& vList)
|
||||
{
|
||||
if( !(fFlags & kFaceNormals) )
|
||||
return;
|
||||
|
||||
#if 0 // Taken out 2.26.2001 mcn 'cause it accesses the (now defunct) 3DDevice directly
|
||||
|
||||
hsPoint3 vPos = fPipeline->GetViewPositionLocal();
|
||||
hsG3DDevice* dev = fPipeline->Get3DDevice();
|
||||
|
||||
fSetVector.Clear();
|
||||
|
||||
for( tList.First(); tList.More(); tList.Plus() )
|
||||
{
|
||||
hsTriangle3* tri = tList.Current();
|
||||
hsVector3& norm = tri->fNormal;
|
||||
|
||||
|
||||
hsScalar dot, opac;
|
||||
hsGVertex3* vtx;
|
||||
hsGShadeVertex* shade;
|
||||
hsVector3 vDir;
|
||||
|
||||
vtx = tri->GetVertex(0);
|
||||
if( !fSetVector.IsBitSet(vtx->fShadeIdx) )
|
||||
{
|
||||
vDir.Set(&vPos, &vtx->fLocalPos);
|
||||
dot = hsFastMath::InvSqrtAppr(vDir.MagnitudeSquared());
|
||||
dot *= norm.InnerProduct(vDir);
|
||||
|
||||
shade = dev->GetShadeEntry(vtx);
|
||||
opac = IOpacFromDot(dot);
|
||||
shade->fColor.a *= opac;
|
||||
|
||||
fSetVector.SetBit(vtx->fShadeIdx);
|
||||
}
|
||||
|
||||
vtx = tri->GetVertex(1);
|
||||
if( !fSetVector.IsBitSet(vtx->fShadeIdx) )
|
||||
{
|
||||
vDir.Set(&vPos, &vtx->fLocalPos);
|
||||
dot = hsFastMath::InvSqrtAppr(vDir.MagnitudeSquared());
|
||||
dot *= norm.InnerProduct(vDir);
|
||||
|
||||
shade = dev->GetShadeEntry(vtx);
|
||||
opac = IOpacFromDot(dot);
|
||||
shade->fColor.a *= opac;
|
||||
|
||||
fSetVector.SetBit(vtx->fShadeIdx);
|
||||
}
|
||||
|
||||
vtx = tri->GetVertex(2);
|
||||
if( !fSetVector.IsBitSet(vtx->fShadeIdx) )
|
||||
{
|
||||
vDir.Set(&vPos, &vtx->fLocalPos);
|
||||
dot = hsFastMath::InvSqrtAppr(vDir.MagnitudeSquared());
|
||||
dot *= norm.InnerProduct(vDir);
|
||||
|
||||
shade = dev->GetShadeEntry(vtx);
|
||||
opac = IOpacFromDot(dot);
|
||||
shade->fColor.a *= opac;
|
||||
|
||||
fSetVector.SetBit(vtx->fShadeIdx);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void hsSfxAngleFade::ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList)
|
||||
{
|
||||
if( fFlags & kFaceNormals )
|
||||
return;
|
||||
|
||||
hsVector3 vDir =fPipeline->GetViewDirLocal();
|
||||
hsPoint3 vPos = fPipeline->GetViewPositionLocal();
|
||||
|
||||
for( vList.First(); vList.More(); vList.Plus() )
|
||||
{
|
||||
hsGShadeVertex* shade = vList.Current();
|
||||
|
||||
hsScalar dot;
|
||||
if( !(fFlags & kDirectional) )
|
||||
{
|
||||
vDir.Set(&vPos, &shade->fLocalPos);
|
||||
dot = hsFastMath::InvSqrtAppr(vDir.MagnitudeSquared());
|
||||
dot *= shade->fNormal.InnerProduct(vDir);
|
||||
}
|
||||
else
|
||||
{
|
||||
dot = shade->fNormal.InnerProduct(vDir);
|
||||
}
|
||||
|
||||
hsScalar opac = IOpacFromDot(dot);
|
||||
|
||||
shade->fShade.a *= opac;
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxAngleFade::MakeTable(float* cosList, float* opacList, int num)
|
||||
{
|
||||
fTable.Reset();
|
||||
if( !num )
|
||||
return;
|
||||
|
||||
int i;
|
||||
for( i = 0; i < num; i++ )
|
||||
{
|
||||
hsSfxAfTableEntry* t = fTable.Append();
|
||||
t->fCosineDel = cosList[i];
|
||||
t->fOpacity = opacList[i];
|
||||
}
|
||||
for( i = num-1; i > 0; i-- )
|
||||
fTable[i].fCosineDel -= fTable[i-1].fCosineDel;
|
||||
for( i = 0; i < num-1; i++ )
|
||||
fTable[i].fCosineNorm = hsScalarInvert(fTable[i+1].fCosineDel);
|
||||
fTable[num-1].fCosineNorm = 0;
|
||||
hsAssert(fTable.GetCount() == num, "Mismatch making table");
|
||||
}
|
||||
|
||||
void hsSfxAngleFade::Read(hsStream* s)
|
||||
{
|
||||
fTable.Reset();
|
||||
|
||||
Int32 cnt = s->ReadSwap32();
|
||||
|
||||
if( cnt )
|
||||
{
|
||||
hsSfxAfTableEntry* arr = new hsSfxAfTableEntry[cnt];
|
||||
int i;
|
||||
for( i = 0; i < cnt; i++ )
|
||||
{
|
||||
arr[i].fCosineDel = s->ReadSwapScalar();
|
||||
arr[i].fCosineNorm = s->ReadSwapScalar();
|
||||
arr[i].fOpacity = s->ReadSwapScalar();
|
||||
}
|
||||
|
||||
fTable.SetArray(arr, cnt);
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxAngleFade::Write(hsStream* s)
|
||||
{
|
||||
s->WriteSwap32(fTable.GetCount());
|
||||
|
||||
for( fTable.First(); fTable.More(); fTable.Plus() )
|
||||
{
|
||||
s->WriteSwapScalar(fTable.Current().fCosineDel);
|
||||
s->WriteSwapScalar(fTable.Current().fCosineNorm);
|
||||
s->WriteSwapScalar(fTable.Current().fOpacity);
|
||||
}
|
||||
}
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsMemory.h"
|
||||
#include "hsSfxAngleFade.h"
|
||||
#include "hsStream.h"
|
||||
#include "../plPipeline/plPipeline.h"
|
||||
//#include "../plPipeline/hsG3DDevice.h"
|
||||
#include "../plGeometry/hsTriangle3.h"
|
||||
#include "../plMath/hsFastMath.h"
|
||||
|
||||
hsSfxAngleFade::hsSfxAngleFade()
|
||||
{
|
||||
}
|
||||
|
||||
hsSfxAngleFade::~hsSfxAngleFade()
|
||||
{
|
||||
}
|
||||
|
||||
hsScalar hsSfxAngleFade::IOpacFromDot(hsScalar dot)
|
||||
{
|
||||
if( (fFlags & kTwoSided)
|
||||
&&(dot < 0) )
|
||||
dot = -dot;
|
||||
|
||||
if( dot <= fTable[0].fCosineDel )
|
||||
return fTable[0].fOpacity;
|
||||
|
||||
int i;
|
||||
for( i = 0; (i < fTable.GetCount()) && (dot >= fTable[i].fCosineDel); i++ )
|
||||
dot -= fTable[i].fCosineDel;
|
||||
|
||||
if( i >= fTable.GetCount() )
|
||||
return fTable[fTable.GetCount()-1].fOpacity;
|
||||
|
||||
dot *= fTable[i-1].fCosineNorm;
|
||||
hsScalar opac0 = fTable[i-1].fOpacity;
|
||||
hsScalar opac1 = fTable[i].fOpacity;
|
||||
|
||||
return opac0 + dot * (opac1 - opac0);
|
||||
}
|
||||
|
||||
void hsSfxAngleFade::ProcessPreInterpTris(hsExpander<hsTriangle3*>& tList, hsExpander<hsGTriVertex*>& vList)
|
||||
{
|
||||
if( !(fFlags & kFaceNormals) )
|
||||
return;
|
||||
|
||||
#if 0 // Taken out 2.26.2001 mcn 'cause it accesses the (now defunct) 3DDevice directly
|
||||
|
||||
hsPoint3 vPos = fPipeline->GetViewPositionLocal();
|
||||
hsG3DDevice* dev = fPipeline->Get3DDevice();
|
||||
|
||||
fSetVector.Clear();
|
||||
|
||||
for( tList.First(); tList.More(); tList.Plus() )
|
||||
{
|
||||
hsTriangle3* tri = tList.Current();
|
||||
hsVector3& norm = tri->fNormal;
|
||||
|
||||
|
||||
hsScalar dot, opac;
|
||||
hsGVertex3* vtx;
|
||||
hsGShadeVertex* shade;
|
||||
hsVector3 vDir;
|
||||
|
||||
vtx = tri->GetVertex(0);
|
||||
if( !fSetVector.IsBitSet(vtx->fShadeIdx) )
|
||||
{
|
||||
vDir.Set(&vPos, &vtx->fLocalPos);
|
||||
dot = hsFastMath::InvSqrtAppr(vDir.MagnitudeSquared());
|
||||
dot *= norm.InnerProduct(vDir);
|
||||
|
||||
shade = dev->GetShadeEntry(vtx);
|
||||
opac = IOpacFromDot(dot);
|
||||
shade->fColor.a *= opac;
|
||||
|
||||
fSetVector.SetBit(vtx->fShadeIdx);
|
||||
}
|
||||
|
||||
vtx = tri->GetVertex(1);
|
||||
if( !fSetVector.IsBitSet(vtx->fShadeIdx) )
|
||||
{
|
||||
vDir.Set(&vPos, &vtx->fLocalPos);
|
||||
dot = hsFastMath::InvSqrtAppr(vDir.MagnitudeSquared());
|
||||
dot *= norm.InnerProduct(vDir);
|
||||
|
||||
shade = dev->GetShadeEntry(vtx);
|
||||
opac = IOpacFromDot(dot);
|
||||
shade->fColor.a *= opac;
|
||||
|
||||
fSetVector.SetBit(vtx->fShadeIdx);
|
||||
}
|
||||
|
||||
vtx = tri->GetVertex(2);
|
||||
if( !fSetVector.IsBitSet(vtx->fShadeIdx) )
|
||||
{
|
||||
vDir.Set(&vPos, &vtx->fLocalPos);
|
||||
dot = hsFastMath::InvSqrtAppr(vDir.MagnitudeSquared());
|
||||
dot *= norm.InnerProduct(vDir);
|
||||
|
||||
shade = dev->GetShadeEntry(vtx);
|
||||
opac = IOpacFromDot(dot);
|
||||
shade->fColor.a *= opac;
|
||||
|
||||
fSetVector.SetBit(vtx->fShadeIdx);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void hsSfxAngleFade::ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList)
|
||||
{
|
||||
if( fFlags & kFaceNormals )
|
||||
return;
|
||||
|
||||
hsVector3 vDir =fPipeline->GetViewDirLocal();
|
||||
hsPoint3 vPos = fPipeline->GetViewPositionLocal();
|
||||
|
||||
for( vList.First(); vList.More(); vList.Plus() )
|
||||
{
|
||||
hsGShadeVertex* shade = vList.Current();
|
||||
|
||||
hsScalar dot;
|
||||
if( !(fFlags & kDirectional) )
|
||||
{
|
||||
vDir.Set(&vPos, &shade->fLocalPos);
|
||||
dot = hsFastMath::InvSqrtAppr(vDir.MagnitudeSquared());
|
||||
dot *= shade->fNormal.InnerProduct(vDir);
|
||||
}
|
||||
else
|
||||
{
|
||||
dot = shade->fNormal.InnerProduct(vDir);
|
||||
}
|
||||
|
||||
hsScalar opac = IOpacFromDot(dot);
|
||||
|
||||
shade->fShade.a *= opac;
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxAngleFade::MakeTable(float* cosList, float* opacList, int num)
|
||||
{
|
||||
fTable.Reset();
|
||||
if( !num )
|
||||
return;
|
||||
|
||||
int i;
|
||||
for( i = 0; i < num; i++ )
|
||||
{
|
||||
hsSfxAfTableEntry* t = fTable.Append();
|
||||
t->fCosineDel = cosList[i];
|
||||
t->fOpacity = opacList[i];
|
||||
}
|
||||
for( i = num-1; i > 0; i-- )
|
||||
fTable[i].fCosineDel -= fTable[i-1].fCosineDel;
|
||||
for( i = 0; i < num-1; i++ )
|
||||
fTable[i].fCosineNorm = hsScalarInvert(fTable[i+1].fCosineDel);
|
||||
fTable[num-1].fCosineNorm = 0;
|
||||
hsAssert(fTable.GetCount() == num, "Mismatch making table");
|
||||
}
|
||||
|
||||
void hsSfxAngleFade::Read(hsStream* s)
|
||||
{
|
||||
fTable.Reset();
|
||||
|
||||
Int32 cnt = s->ReadSwap32();
|
||||
|
||||
if( cnt )
|
||||
{
|
||||
hsSfxAfTableEntry* arr = new hsSfxAfTableEntry[cnt];
|
||||
int i;
|
||||
for( i = 0; i < cnt; i++ )
|
||||
{
|
||||
arr[i].fCosineDel = s->ReadSwapScalar();
|
||||
arr[i].fCosineNorm = s->ReadSwapScalar();
|
||||
arr[i].fOpacity = s->ReadSwapScalar();
|
||||
}
|
||||
|
||||
fTable.SetArray(arr, cnt);
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxAngleFade::Write(hsStream* s)
|
||||
{
|
||||
s->WriteSwap32(fTable.GetCount());
|
||||
|
||||
for( fTable.First(); fTable.More(); fTable.Plus() )
|
||||
{
|
||||
s->WriteSwapScalar(fTable.Current().fCosineDel);
|
||||
s->WriteSwapScalar(fTable.Current().fCosineNorm);
|
||||
s->WriteSwapScalar(fTable.Current().fOpacity);
|
||||
}
|
||||
}
|
||||
|
@ -1,74 +1,74 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef hsSfxAngleFade_inc
|
||||
#define hsSfxAngleFade_inc
|
||||
|
||||
#include "hsBiExpander.h"
|
||||
#include "hsGRenderProcs.h"
|
||||
#include "hsBitVector.h"
|
||||
|
||||
class hsSfxAngleFade : public hsGRenderProcs {
|
||||
public:
|
||||
enum {
|
||||
kDirectional = 0x10000,
|
||||
kTargetRelative = 0x20000,
|
||||
kTwoSided = 0x40000,
|
||||
kFaceNormals = 0x80000
|
||||
};
|
||||
struct hsSfxAfTableEntry {
|
||||
hsScalar fCosineDel;
|
||||
hsScalar fCosineNorm;
|
||||
hsScalar fOpacity;
|
||||
};
|
||||
protected:
|
||||
|
||||
hsBitVector fSetVector;
|
||||
hsExpander<hsSfxAfTableEntry> fTable;
|
||||
|
||||
hsScalar IOpacFromDot(hsScalar dot);
|
||||
public:
|
||||
hsSfxAngleFade();
|
||||
virtual ~hsSfxAngleFade();
|
||||
|
||||
virtual void ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList);
|
||||
virtual void ProcessPreInterpTris(hsExpander<hsTriangle3*>& tList, hsExpander<hsGTriVertex*>& vList);
|
||||
|
||||
void MakeTable(float* cosList, float* opacList, int num); // lists sorted from lowest cosine to highest
|
||||
|
||||
virtual void Read(hsStream* s);
|
||||
virtual void Write(hsStream* s);
|
||||
|
||||
virtual const char* GetLabel() const { return "hsSfxAngleFade"; }
|
||||
|
||||
virtual ProcType GetType() const { return kTypeAngleFade; }
|
||||
|
||||
CLASSNAME_REGISTER( hsSfxAngleFade );
|
||||
GETINTERFACE_ANY( hsSfxAngleFade, hsGRenderProcs );
|
||||
|
||||
};
|
||||
|
||||
#endif // hsSfxAngleFade_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef hsSfxAngleFade_inc
|
||||
#define hsSfxAngleFade_inc
|
||||
|
||||
#include "hsBiExpander.h"
|
||||
#include "hsGRenderProcs.h"
|
||||
#include "hsBitVector.h"
|
||||
|
||||
class hsSfxAngleFade : public hsGRenderProcs {
|
||||
public:
|
||||
enum {
|
||||
kDirectional = 0x10000,
|
||||
kTargetRelative = 0x20000,
|
||||
kTwoSided = 0x40000,
|
||||
kFaceNormals = 0x80000
|
||||
};
|
||||
struct hsSfxAfTableEntry {
|
||||
hsScalar fCosineDel;
|
||||
hsScalar fCosineNorm;
|
||||
hsScalar fOpacity;
|
||||
};
|
||||
protected:
|
||||
|
||||
hsBitVector fSetVector;
|
||||
hsExpander<hsSfxAfTableEntry> fTable;
|
||||
|
||||
hsScalar IOpacFromDot(hsScalar dot);
|
||||
public:
|
||||
hsSfxAngleFade();
|
||||
virtual ~hsSfxAngleFade();
|
||||
|
||||
virtual void ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList);
|
||||
virtual void ProcessPreInterpTris(hsExpander<hsTriangle3*>& tList, hsExpander<hsGTriVertex*>& vList);
|
||||
|
||||
void MakeTable(float* cosList, float* opacList, int num); // lists sorted from lowest cosine to highest
|
||||
|
||||
virtual void Read(hsStream* s);
|
||||
virtual void Write(hsStream* s);
|
||||
|
||||
virtual const char* GetLabel() const { return "hsSfxAngleFade"; }
|
||||
|
||||
virtual ProcType GetType() const { return kTypeAngleFade; }
|
||||
|
||||
CLASSNAME_REGISTER( hsSfxAngleFade );
|
||||
GETINTERFACE_ANY( hsSfxAngleFade, hsGRenderProcs );
|
||||
|
||||
};
|
||||
|
||||
#endif // hsSfxAngleFade_inc
|
||||
|
@ -1,315 +1,315 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsMemory.h"
|
||||
#include "hsSfxDistFade.h"
|
||||
#include "hsStream.h"
|
||||
#include "../plPipeline/plPipeline.h"
|
||||
#include "../plGeometry/hsTriangle3.h"
|
||||
#include "../plDrawable/plDrawable.h"
|
||||
|
||||
#include "../plIntersect/hsBounds.h"
|
||||
|
||||
|
||||
static hsScalar globalScale = 1.f;
|
||||
|
||||
hsSfxDistFade::hsSfxDistFade()
|
||||
: fMinDist(0), fMaxDist(0)
|
||||
{
|
||||
}
|
||||
|
||||
hsSfxDistFade::~hsSfxDistFade()
|
||||
{
|
||||
}
|
||||
|
||||
hsScalar hsSfxDistFade::IOpacFromDist(hsScalar dist)
|
||||
{
|
||||
if( dist <= fTable[0].fDistDel )
|
||||
return fTable[0].fOpacity;
|
||||
|
||||
int i;
|
||||
for( i = 0; (i < fTable.GetCount()) && (dist >= fTable[i].fDistDel); i++ )
|
||||
dist -= fTable[i].fDistDel;
|
||||
|
||||
if( i >= fTable.GetCount() )
|
||||
return fTable[fTable.GetCount()-1].fOpacity;
|
||||
|
||||
dist *= fTable[i-1].fDistNorm;
|
||||
hsScalar opac0 = fTable[i-1].fOpacity;
|
||||
hsScalar opac1 = fTable[i].fOpacity;
|
||||
|
||||
return opac0 + dist * (opac1 - opac0);
|
||||
}
|
||||
|
||||
hsBool32 hsSfxDistFade::BeginObject(plPipeline* pipe, plDrawable* obj)
|
||||
{
|
||||
hsGRenderProcs::BeginObject(pipe, obj);
|
||||
|
||||
fFlags &= ~(kCulled | kNOP);
|
||||
|
||||
hsPoint3 vPos;
|
||||
if( GetObjectRef(1) )
|
||||
{
|
||||
hsPoint3 wPos;
|
||||
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&wPos);
|
||||
hsMatrix44 w2l = fPipeline->GetWorldToLocal();
|
||||
vPos = w2l * wPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
vPos = fPipeline->GetViewPositionLocal();
|
||||
}
|
||||
|
||||
hsScalar scale = 1.f / fPipeline->GetLocalScale();
|
||||
scale *= globalScale;
|
||||
|
||||
const hsBounds3Ext& bnd = obj->GetLocalBounds();
|
||||
|
||||
hsPoint3 inner, outer;
|
||||
bnd.ClosestPoint(vPos, inner, outer);
|
||||
|
||||
hsScalar minDist, maxDist;
|
||||
|
||||
minDist = hsVector3(&vPos, &inner).Magnitude();
|
||||
maxDist = hsVector3(&vPos, &outer).Magnitude();
|
||||
|
||||
minDist *= scale;
|
||||
maxDist *= scale;
|
||||
|
||||
if( (fFlags & kCullsBefore)
|
||||
&&(maxDist <= fMinDist) )
|
||||
{
|
||||
fFlags |= kCulled;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( (fFlags & kCullsBeyond)
|
||||
&&(minDist > fMaxDist) )
|
||||
{
|
||||
fFlags |= kCulled;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( (fFlags & kIdleBefore)
|
||||
&&(maxDist < fMinIdle) )
|
||||
fFlags |= kNOP;
|
||||
|
||||
if( (fFlags & kIdleBeyond)
|
||||
&&(minDist > fMaxIdle) )
|
||||
fFlags |= kNOP;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void hsSfxDistFade::ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList)
|
||||
{
|
||||
if( fFlags & (kPostInterp | kNOP) )
|
||||
return;
|
||||
|
||||
hsPoint3 vPos;
|
||||
if( GetObjectRef(1) )
|
||||
{
|
||||
hsPoint3 wPos;
|
||||
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&wPos);
|
||||
hsMatrix44 w2l = fPipeline->GetWorldToLocal();
|
||||
vPos = w2l * wPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
vPos = fPipeline->GetViewPositionLocal();
|
||||
}
|
||||
hsScalar scale = 1.f / fPipeline->GetLocalScale();
|
||||
|
||||
scale *= globalScale;
|
||||
|
||||
for( vList.First(); vList.More(); vList.Plus() )
|
||||
{
|
||||
hsGShadeVertex* shade = vList.Current();
|
||||
|
||||
hsScalar dist = hsVector3(&shade->fLocalPos, &vPos).Magnitude();
|
||||
dist *= scale;
|
||||
|
||||
hsScalar opac = IOpacFromDist(dist);
|
||||
|
||||
if( opac > 0 )
|
||||
shade->fShade.a *= opac;
|
||||
else
|
||||
{
|
||||
shade->fShade.a = 0;
|
||||
shade->fBaseVertex->fFlags |= hsGVertex3::kCulled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxDistFade::ProcessPostInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList)
|
||||
{
|
||||
if( !(fFlags & kPostInterp) )
|
||||
return;
|
||||
|
||||
if( fFlags & kNOP )
|
||||
return;
|
||||
|
||||
hsPoint3 vPos;
|
||||
if( GetObjectRef(1) )
|
||||
{
|
||||
hsPoint3 wPos;
|
||||
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&wPos);
|
||||
hsMatrix44 w2l = fPipeline->GetWorldToLocal();
|
||||
vPos = w2l * wPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
vPos = fPipeline->GetViewPositionLocal();
|
||||
}
|
||||
hsScalar scale = 1.f / fPipeline->GetLocalScale();
|
||||
|
||||
for( vList.First(); vList.More(); vList.Plus() )
|
||||
{
|
||||
hsGShadeVertex* shade = vList.Current();
|
||||
|
||||
hsScalar dist = hsVector3(&shade->fLocalPos, &vPos).Magnitude();
|
||||
dist *= scale;
|
||||
|
||||
hsScalar opac = IOpacFromDist(dist);
|
||||
|
||||
if( opac > 0 )
|
||||
shade->fColor.a *= opac;
|
||||
else
|
||||
{
|
||||
shade->fColor.a = 0;
|
||||
shade->fBaseVertex->fFlags |= hsGVertex3::kCulled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxDistFade::MakeTable(float* distList, float* opacList, int num)
|
||||
{
|
||||
fTable.Reset();
|
||||
if( !num )
|
||||
return;
|
||||
|
||||
int i;
|
||||
for( i = 0; i < num; i++ )
|
||||
{
|
||||
hsSfxDfTableEntry* t = fTable.Append();
|
||||
t->fDistDel = distList[i];
|
||||
t->fOpacity = opacList[i];
|
||||
}
|
||||
for( i = num-1; i > 0; i-- )
|
||||
fTable[i].fDistDel -= fTable[i-1].fDistDel;
|
||||
for( i = 0; i < num-1; i++ )
|
||||
fTable[i].fDistNorm = hsScalarInvert(fTable[i+1].fDistDel);
|
||||
fTable[num-1].fDistNorm = 0;
|
||||
hsAssert(fTable.GetCount() == num, "Mismatch making table");
|
||||
|
||||
if( fTable[0].fOpacity <= 0 )
|
||||
fFlags |= kCullsBefore;
|
||||
if( fTable[num-1].fOpacity <= 0 )
|
||||
fFlags |= kCullsBeyond;
|
||||
if( fTable[0].fOpacity >= 1.f )
|
||||
fFlags |= kIdleBefore;
|
||||
if( fTable[num-1].fOpacity >= 1.f )
|
||||
fFlags |= kIdleBeyond;
|
||||
|
||||
int iMin;
|
||||
for( iMin = 0; (iMin < fTable.GetCount())&&(fTable[iMin].fOpacity <= 0); iMin++ );
|
||||
fMinDist = fTable[0].fDistDel;
|
||||
for( i = 1; i < iMin; i++ )
|
||||
fMinDist += fTable[i].fDistDel;
|
||||
|
||||
for( iMin = 0; (iMin < fTable.GetCount())&&(fTable[iMin].fOpacity >= 1.f); iMin++ );
|
||||
fMinIdle = fTable[0].fDistDel;
|
||||
for( i = 1; i < iMin; i++ )
|
||||
fMinIdle += fTable[i].fDistDel;
|
||||
|
||||
int iMax;
|
||||
for( iMax = fTable.GetCount()-1; (iMax >= 0)&&(fTable[iMax].fOpacity <= 0); iMax-- );
|
||||
if( ++iMax >= fTable.GetCount() )
|
||||
iMax = fTable.GetCount()-1;
|
||||
fMaxDist = fTable[0].fDistDel;
|
||||
for( i = 1; i <= iMax; i++ )
|
||||
fMaxDist += fTable[i].fDistDel;
|
||||
|
||||
for( iMax = fTable.GetCount()-1; (iMax >= 0)&&(fTable[iMax].fOpacity >= 1.f); iMax-- );
|
||||
if( ++iMax >= fTable.GetCount() )
|
||||
iMax = fTable.GetCount()-1;
|
||||
fMaxIdle = fTable[0].fDistDel;
|
||||
for( i = 1; i <= iMax; i++ )
|
||||
fMaxIdle += fTable[i].fDistDel;
|
||||
}
|
||||
|
||||
void hsSfxDistFade::Read(hsStream* s)
|
||||
{
|
||||
fTable.Reset();
|
||||
|
||||
fMinDist = s->ReadSwapScalar();
|
||||
fMaxDist = s->ReadSwapScalar();
|
||||
|
||||
if( fFlags & (kIdleBefore | kIdleBeyond) )
|
||||
{
|
||||
fMinIdle = s->ReadSwapScalar();
|
||||
fMaxIdle = s->ReadSwapScalar();
|
||||
}
|
||||
|
||||
Int32 cnt = s->ReadSwap32();
|
||||
|
||||
if( cnt )
|
||||
{
|
||||
hsSfxDfTableEntry* arr = new hsSfxDfTableEntry[cnt];
|
||||
int i;
|
||||
for( i = 0; i < cnt; i++ )
|
||||
{
|
||||
arr[i].fDistDel = s->ReadSwapScalar();
|
||||
arr[i].fDistNorm = s->ReadSwapScalar();
|
||||
arr[i].fOpacity = s->ReadSwapScalar();
|
||||
}
|
||||
|
||||
fTable.SetArray(arr, cnt);
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxDistFade::Write(hsStream* s)
|
||||
{
|
||||
s->WriteSwapScalar(fMinDist);
|
||||
s->WriteSwapScalar(fMaxDist);
|
||||
|
||||
if( fFlags & (kIdleBefore | kIdleBeyond) )
|
||||
{
|
||||
s->WriteSwapScalar(fMinIdle);
|
||||
s->WriteSwapScalar(fMaxIdle);
|
||||
}
|
||||
|
||||
s->WriteSwap32(fTable.GetCount());
|
||||
|
||||
for( fTable.First(); fTable.More(); fTable.Plus() )
|
||||
{
|
||||
s->WriteSwapScalar(fTable.Current().fDistDel);
|
||||
s->WriteSwapScalar(fTable.Current().fDistNorm);
|
||||
s->WriteSwapScalar(fTable.Current().fOpacity);
|
||||
}
|
||||
}
|
||||
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsMemory.h"
|
||||
#include "hsSfxDistFade.h"
|
||||
#include "hsStream.h"
|
||||
#include "../plPipeline/plPipeline.h"
|
||||
#include "../plGeometry/hsTriangle3.h"
|
||||
#include "../plDrawable/plDrawable.h"
|
||||
|
||||
#include "../plIntersect/hsBounds.h"
|
||||
|
||||
|
||||
static hsScalar globalScale = 1.f;
|
||||
|
||||
hsSfxDistFade::hsSfxDistFade()
|
||||
: fMinDist(0), fMaxDist(0)
|
||||
{
|
||||
}
|
||||
|
||||
hsSfxDistFade::~hsSfxDistFade()
|
||||
{
|
||||
}
|
||||
|
||||
hsScalar hsSfxDistFade::IOpacFromDist(hsScalar dist)
|
||||
{
|
||||
if( dist <= fTable[0].fDistDel )
|
||||
return fTable[0].fOpacity;
|
||||
|
||||
int i;
|
||||
for( i = 0; (i < fTable.GetCount()) && (dist >= fTable[i].fDistDel); i++ )
|
||||
dist -= fTable[i].fDistDel;
|
||||
|
||||
if( i >= fTable.GetCount() )
|
||||
return fTable[fTable.GetCount()-1].fOpacity;
|
||||
|
||||
dist *= fTable[i-1].fDistNorm;
|
||||
hsScalar opac0 = fTable[i-1].fOpacity;
|
||||
hsScalar opac1 = fTable[i].fOpacity;
|
||||
|
||||
return opac0 + dist * (opac1 - opac0);
|
||||
}
|
||||
|
||||
hsBool32 hsSfxDistFade::BeginObject(plPipeline* pipe, plDrawable* obj)
|
||||
{
|
||||
hsGRenderProcs::BeginObject(pipe, obj);
|
||||
|
||||
fFlags &= ~(kCulled | kNOP);
|
||||
|
||||
hsPoint3 vPos;
|
||||
if( GetObjectRef(1) )
|
||||
{
|
||||
hsPoint3 wPos;
|
||||
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&wPos);
|
||||
hsMatrix44 w2l = fPipeline->GetWorldToLocal();
|
||||
vPos = w2l * wPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
vPos = fPipeline->GetViewPositionLocal();
|
||||
}
|
||||
|
||||
hsScalar scale = 1.f / fPipeline->GetLocalScale();
|
||||
scale *= globalScale;
|
||||
|
||||
const hsBounds3Ext& bnd = obj->GetLocalBounds();
|
||||
|
||||
hsPoint3 inner, outer;
|
||||
bnd.ClosestPoint(vPos, inner, outer);
|
||||
|
||||
hsScalar minDist, maxDist;
|
||||
|
||||
minDist = hsVector3(&vPos, &inner).Magnitude();
|
||||
maxDist = hsVector3(&vPos, &outer).Magnitude();
|
||||
|
||||
minDist *= scale;
|
||||
maxDist *= scale;
|
||||
|
||||
if( (fFlags & kCullsBefore)
|
||||
&&(maxDist <= fMinDist) )
|
||||
{
|
||||
fFlags |= kCulled;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( (fFlags & kCullsBeyond)
|
||||
&&(minDist > fMaxDist) )
|
||||
{
|
||||
fFlags |= kCulled;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( (fFlags & kIdleBefore)
|
||||
&&(maxDist < fMinIdle) )
|
||||
fFlags |= kNOP;
|
||||
|
||||
if( (fFlags & kIdleBeyond)
|
||||
&&(minDist > fMaxIdle) )
|
||||
fFlags |= kNOP;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void hsSfxDistFade::ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList)
|
||||
{
|
||||
if( fFlags & (kPostInterp | kNOP) )
|
||||
return;
|
||||
|
||||
hsPoint3 vPos;
|
||||
if( GetObjectRef(1) )
|
||||
{
|
||||
hsPoint3 wPos;
|
||||
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&wPos);
|
||||
hsMatrix44 w2l = fPipeline->GetWorldToLocal();
|
||||
vPos = w2l * wPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
vPos = fPipeline->GetViewPositionLocal();
|
||||
}
|
||||
hsScalar scale = 1.f / fPipeline->GetLocalScale();
|
||||
|
||||
scale *= globalScale;
|
||||
|
||||
for( vList.First(); vList.More(); vList.Plus() )
|
||||
{
|
||||
hsGShadeVertex* shade = vList.Current();
|
||||
|
||||
hsScalar dist = hsVector3(&shade->fLocalPos, &vPos).Magnitude();
|
||||
dist *= scale;
|
||||
|
||||
hsScalar opac = IOpacFromDist(dist);
|
||||
|
||||
if( opac > 0 )
|
||||
shade->fShade.a *= opac;
|
||||
else
|
||||
{
|
||||
shade->fShade.a = 0;
|
||||
shade->fBaseVertex->fFlags |= hsGVertex3::kCulled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxDistFade::ProcessPostInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList)
|
||||
{
|
||||
if( !(fFlags & kPostInterp) )
|
||||
return;
|
||||
|
||||
if( fFlags & kNOP )
|
||||
return;
|
||||
|
||||
hsPoint3 vPos;
|
||||
if( GetObjectRef(1) )
|
||||
{
|
||||
hsPoint3 wPos;
|
||||
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&wPos);
|
||||
hsMatrix44 w2l = fPipeline->GetWorldToLocal();
|
||||
vPos = w2l * wPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
vPos = fPipeline->GetViewPositionLocal();
|
||||
}
|
||||
hsScalar scale = 1.f / fPipeline->GetLocalScale();
|
||||
|
||||
for( vList.First(); vList.More(); vList.Plus() )
|
||||
{
|
||||
hsGShadeVertex* shade = vList.Current();
|
||||
|
||||
hsScalar dist = hsVector3(&shade->fLocalPos, &vPos).Magnitude();
|
||||
dist *= scale;
|
||||
|
||||
hsScalar opac = IOpacFromDist(dist);
|
||||
|
||||
if( opac > 0 )
|
||||
shade->fColor.a *= opac;
|
||||
else
|
||||
{
|
||||
shade->fColor.a = 0;
|
||||
shade->fBaseVertex->fFlags |= hsGVertex3::kCulled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxDistFade::MakeTable(float* distList, float* opacList, int num)
|
||||
{
|
||||
fTable.Reset();
|
||||
if( !num )
|
||||
return;
|
||||
|
||||
int i;
|
||||
for( i = 0; i < num; i++ )
|
||||
{
|
||||
hsSfxDfTableEntry* t = fTable.Append();
|
||||
t->fDistDel = distList[i];
|
||||
t->fOpacity = opacList[i];
|
||||
}
|
||||
for( i = num-1; i > 0; i-- )
|
||||
fTable[i].fDistDel -= fTable[i-1].fDistDel;
|
||||
for( i = 0; i < num-1; i++ )
|
||||
fTable[i].fDistNorm = hsScalarInvert(fTable[i+1].fDistDel);
|
||||
fTable[num-1].fDistNorm = 0;
|
||||
hsAssert(fTable.GetCount() == num, "Mismatch making table");
|
||||
|
||||
if( fTable[0].fOpacity <= 0 )
|
||||
fFlags |= kCullsBefore;
|
||||
if( fTable[num-1].fOpacity <= 0 )
|
||||
fFlags |= kCullsBeyond;
|
||||
if( fTable[0].fOpacity >= 1.f )
|
||||
fFlags |= kIdleBefore;
|
||||
if( fTable[num-1].fOpacity >= 1.f )
|
||||
fFlags |= kIdleBeyond;
|
||||
|
||||
int iMin;
|
||||
for( iMin = 0; (iMin < fTable.GetCount())&&(fTable[iMin].fOpacity <= 0); iMin++ );
|
||||
fMinDist = fTable[0].fDistDel;
|
||||
for( i = 1; i < iMin; i++ )
|
||||
fMinDist += fTable[i].fDistDel;
|
||||
|
||||
for( iMin = 0; (iMin < fTable.GetCount())&&(fTable[iMin].fOpacity >= 1.f); iMin++ );
|
||||
fMinIdle = fTable[0].fDistDel;
|
||||
for( i = 1; i < iMin; i++ )
|
||||
fMinIdle += fTable[i].fDistDel;
|
||||
|
||||
int iMax;
|
||||
for( iMax = fTable.GetCount()-1; (iMax >= 0)&&(fTable[iMax].fOpacity <= 0); iMax-- );
|
||||
if( ++iMax >= fTable.GetCount() )
|
||||
iMax = fTable.GetCount()-1;
|
||||
fMaxDist = fTable[0].fDistDel;
|
||||
for( i = 1; i <= iMax; i++ )
|
||||
fMaxDist += fTable[i].fDistDel;
|
||||
|
||||
for( iMax = fTable.GetCount()-1; (iMax >= 0)&&(fTable[iMax].fOpacity >= 1.f); iMax-- );
|
||||
if( ++iMax >= fTable.GetCount() )
|
||||
iMax = fTable.GetCount()-1;
|
||||
fMaxIdle = fTable[0].fDistDel;
|
||||
for( i = 1; i <= iMax; i++ )
|
||||
fMaxIdle += fTable[i].fDistDel;
|
||||
}
|
||||
|
||||
void hsSfxDistFade::Read(hsStream* s)
|
||||
{
|
||||
fTable.Reset();
|
||||
|
||||
fMinDist = s->ReadSwapScalar();
|
||||
fMaxDist = s->ReadSwapScalar();
|
||||
|
||||
if( fFlags & (kIdleBefore | kIdleBeyond) )
|
||||
{
|
||||
fMinIdle = s->ReadSwapScalar();
|
||||
fMaxIdle = s->ReadSwapScalar();
|
||||
}
|
||||
|
||||
Int32 cnt = s->ReadSwap32();
|
||||
|
||||
if( cnt )
|
||||
{
|
||||
hsSfxDfTableEntry* arr = new hsSfxDfTableEntry[cnt];
|
||||
int i;
|
||||
for( i = 0; i < cnt; i++ )
|
||||
{
|
||||
arr[i].fDistDel = s->ReadSwapScalar();
|
||||
arr[i].fDistNorm = s->ReadSwapScalar();
|
||||
arr[i].fOpacity = s->ReadSwapScalar();
|
||||
}
|
||||
|
||||
fTable.SetArray(arr, cnt);
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxDistFade::Write(hsStream* s)
|
||||
{
|
||||
s->WriteSwapScalar(fMinDist);
|
||||
s->WriteSwapScalar(fMaxDist);
|
||||
|
||||
if( fFlags & (kIdleBefore | kIdleBeyond) )
|
||||
{
|
||||
s->WriteSwapScalar(fMinIdle);
|
||||
s->WriteSwapScalar(fMaxIdle);
|
||||
}
|
||||
|
||||
s->WriteSwap32(fTable.GetCount());
|
||||
|
||||
for( fTable.First(); fTable.More(); fTable.Plus() )
|
||||
{
|
||||
s->WriteSwapScalar(fTable.Current().fDistDel);
|
||||
s->WriteSwapScalar(fTable.Current().fDistNorm);
|
||||
s->WriteSwapScalar(fTable.Current().fOpacity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,91 +1,91 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef hsSfxDistFade_inc
|
||||
#define hsSfxDistFade_inc
|
||||
|
||||
#include "hsBiExpander.h"
|
||||
#include "hsGRenderProcs.h"
|
||||
|
||||
class hsSfxDistFade : public hsGRenderProcs {
|
||||
public:
|
||||
enum {
|
||||
kCullsBefore = 0x10000,
|
||||
kCullsBeyond = 0x20000,
|
||||
|
||||
kDistFromView = 0x40000,
|
||||
kDistFromTarget = 0x80000,
|
||||
kDistAlongX = 0x100000,
|
||||
kDistAlongY = 0x200000,
|
||||
kDistAlongZ = 0x400000,
|
||||
kWorldDist = 0x800000,
|
||||
|
||||
kPostInterp = 0x1000000,
|
||||
|
||||
kIdleBefore = 0x2000000,
|
||||
kIdleBeyond = 0x4000000
|
||||
};
|
||||
|
||||
struct hsSfxDfTableEntry {
|
||||
hsScalar fDistDel;
|
||||
hsScalar fDistNorm;
|
||||
hsScalar fOpacity;
|
||||
};
|
||||
protected:
|
||||
|
||||
hsScalar fMinDist;
|
||||
hsScalar fMaxDist;
|
||||
|
||||
hsScalar fMinIdle;
|
||||
hsScalar fMaxIdle;
|
||||
|
||||
hsExpander<hsSfxDfTableEntry> fTable;
|
||||
|
||||
hsScalar IOpacFromDist(hsScalar dist);
|
||||
public:
|
||||
hsSfxDistFade();
|
||||
virtual ~hsSfxDistFade();
|
||||
|
||||
virtual hsBool32 BeginObject(plPipeline* pipe, plDrawable* obj);
|
||||
|
||||
virtual void ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList);
|
||||
virtual void ProcessPostInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList);
|
||||
|
||||
void MakeTable(float* distList, float* opacList, int num); // lists sorted from lowest cosine to highest
|
||||
|
||||
virtual void Read(hsStream* s);
|
||||
virtual void Write(hsStream* s);
|
||||
|
||||
virtual const char* GetLabel() const { return "hsSfxDistFade"; }
|
||||
|
||||
virtual ProcType GetType() const { return kTypeDistFade; }
|
||||
|
||||
CLASSNAME_REGISTER( hsSfxDistFade );
|
||||
GETINTERFACE_ANY( hsSfxDistFade, hsGRenderProcs );
|
||||
|
||||
};
|
||||
|
||||
#endif // hsSfxDistFade_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef hsSfxDistFade_inc
|
||||
#define hsSfxDistFade_inc
|
||||
|
||||
#include "hsBiExpander.h"
|
||||
#include "hsGRenderProcs.h"
|
||||
|
||||
class hsSfxDistFade : public hsGRenderProcs {
|
||||
public:
|
||||
enum {
|
||||
kCullsBefore = 0x10000,
|
||||
kCullsBeyond = 0x20000,
|
||||
|
||||
kDistFromView = 0x40000,
|
||||
kDistFromTarget = 0x80000,
|
||||
kDistAlongX = 0x100000,
|
||||
kDistAlongY = 0x200000,
|
||||
kDistAlongZ = 0x400000,
|
||||
kWorldDist = 0x800000,
|
||||
|
||||
kPostInterp = 0x1000000,
|
||||
|
||||
kIdleBefore = 0x2000000,
|
||||
kIdleBeyond = 0x4000000
|
||||
};
|
||||
|
||||
struct hsSfxDfTableEntry {
|
||||
hsScalar fDistDel;
|
||||
hsScalar fDistNorm;
|
||||
hsScalar fOpacity;
|
||||
};
|
||||
protected:
|
||||
|
||||
hsScalar fMinDist;
|
||||
hsScalar fMaxDist;
|
||||
|
||||
hsScalar fMinIdle;
|
||||
hsScalar fMaxIdle;
|
||||
|
||||
hsExpander<hsSfxDfTableEntry> fTable;
|
||||
|
||||
hsScalar IOpacFromDist(hsScalar dist);
|
||||
public:
|
||||
hsSfxDistFade();
|
||||
virtual ~hsSfxDistFade();
|
||||
|
||||
virtual hsBool32 BeginObject(plPipeline* pipe, plDrawable* obj);
|
||||
|
||||
virtual void ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList);
|
||||
virtual void ProcessPostInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList);
|
||||
|
||||
void MakeTable(float* distList, float* opacList, int num); // lists sorted from lowest cosine to highest
|
||||
|
||||
virtual void Read(hsStream* s);
|
||||
virtual void Write(hsStream* s);
|
||||
|
||||
virtual const char* GetLabel() const { return "hsSfxDistFade"; }
|
||||
|
||||
virtual ProcType GetType() const { return kTypeDistFade; }
|
||||
|
||||
CLASSNAME_REGISTER( hsSfxDistFade );
|
||||
GETINTERFACE_ANY( hsSfxDistFade, hsGRenderProcs );
|
||||
|
||||
};
|
||||
|
||||
#endif // hsSfxDistFade_inc
|
||||
|
@ -1,276 +1,276 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsMemory.h"
|
||||
#include "hsSfxDistShade.h"
|
||||
#include "hsStream.h"
|
||||
#include "../plGeometry/hsTriangle3.h"
|
||||
|
||||
#include "../plIntersect/hsBounds.h"
|
||||
#include "../plDrawable/plDrawable.h"
|
||||
#include "../plPipeline/plPipeline.h"
|
||||
|
||||
static hsScalar globalScale = 1.f;
|
||||
|
||||
hsSfxDistShade::hsSfxDistShade()
|
||||
: fMinDist(0), fMaxDist(0)
|
||||
{
|
||||
}
|
||||
|
||||
hsSfxDistShade::~hsSfxDistShade()
|
||||
{
|
||||
}
|
||||
|
||||
hsScalar hsSfxDistShade::IShadeFromDist(hsScalar dist)
|
||||
{
|
||||
if( dist <= fTable[0].fDistDel )
|
||||
return fTable[0].fShade;
|
||||
|
||||
int i;
|
||||
for( i = 0; (i < fTable.GetCount()) && (dist >= fTable[i].fDistDel); i++ )
|
||||
dist -= fTable[i].fDistDel;
|
||||
|
||||
if( i >= fTable.GetCount() )
|
||||
return fTable[fTable.GetCount()-1].fShade;
|
||||
|
||||
dist *= fTable[i-1].fDistNorm;
|
||||
hsScalar shade0 = fTable[i-1].fShade;
|
||||
hsScalar shade1 = fTable[i].fShade;
|
||||
|
||||
return shade0 + dist * (shade1 - shade0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
hsBool32 hsSfxDistShade::BeginObject(plPipeline* pipe, plDrawable* obj)
|
||||
{
|
||||
hsGRenderProcs::BeginObject(pipe, obj);
|
||||
|
||||
fFlags &= ~(kCulled | kNOP);
|
||||
|
||||
hsPoint3 vPos;
|
||||
if( GetObjectRef(1) )
|
||||
{
|
||||
hsPoint3 wPos;
|
||||
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&wPos);
|
||||
hsMatrix44 w2l = pipe->GetWorldToLocal();
|
||||
vPos = w2l * wPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
vPos = pipe->GetViewPositionLocal();
|
||||
}
|
||||
hsVector3 vDir = -pipe->GetViewDirLocal();
|
||||
|
||||
hsScalar scale = 1.f / fPipeline->GetLocalScale();
|
||||
scale *= globalScale;
|
||||
|
||||
hsScalar vD = -(vDir.InnerProduct(vPos));
|
||||
vD *= scale;
|
||||
|
||||
const hsBounds3Ext& bnd = obj->GetLocalBounds();
|
||||
|
||||
hsPoint3 corner;
|
||||
bnd.GetCorner(&corner);
|
||||
hsVector3 axis[3];
|
||||
bnd.GetAxes(axis+0, axis+1, axis+2);
|
||||
|
||||
hsScalar dist = vDir.InnerProduct(corner) + vD;
|
||||
hsScalar minDist = dist;
|
||||
hsScalar maxDist = dist;
|
||||
|
||||
int i;
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
dist = vDir.InnerProduct(axis[i]);
|
||||
if( dist < 0 )
|
||||
minDist += dist;
|
||||
else
|
||||
maxDist += dist;
|
||||
}
|
||||
|
||||
minDist *= scale;
|
||||
maxDist *= scale;
|
||||
|
||||
fFlags &= ~kShadeConstant;
|
||||
if( maxDist < fMinDist )
|
||||
{
|
||||
fFlags |= kShadeConstant;
|
||||
fConstShade = fTable[0].fShade;
|
||||
}
|
||||
else if( minDist > fMaxDist )
|
||||
{
|
||||
fFlags |= kShadeConstant;
|
||||
fConstShade = fTable[fTable.GetCount()-1].fShade;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void hsSfxDistShade::ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList)
|
||||
{
|
||||
if( fFlags & kShadeConstant )
|
||||
{
|
||||
IConstShadeVerts(vList);
|
||||
}
|
||||
else
|
||||
{
|
||||
ICalcShadeVerts(vList);
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxDistShade::IConstShadeVerts(hsExpander<hsGShadeVertex*>& vList)
|
||||
{
|
||||
for( vList.First(); vList.More(); vList.Plus() )
|
||||
{
|
||||
hsGShadeVertex* svtx = vList.Current();
|
||||
svtx->fShade.r *= fConstShade;
|
||||
svtx->fShade.g *= fConstShade;
|
||||
svtx->fShade.b *= fConstShade;
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxDistShade::ICalcShadeVerts(hsExpander<hsGShadeVertex*>& vList)
|
||||
{
|
||||
hsPoint3 vPos;
|
||||
if( GetObjectRef(1) )
|
||||
{
|
||||
hsPoint3 wPos;
|
||||
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&wPos);
|
||||
hsMatrix44 w2l = fPipeline->GetWorldToLocal();
|
||||
vPos = w2l * wPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
vPos = fPipeline->GetViewPositionLocal();
|
||||
}
|
||||
hsVector3 vDir = fPipeline->GetViewDirLocal();
|
||||
|
||||
hsScalar vDist = vDir.InnerProduct(vPos);
|
||||
|
||||
hsScalar scale = 1.f / fPipeline->GetLocalScale();
|
||||
scale *= globalScale;
|
||||
|
||||
for( vList.First(); vList.More(); vList.Plus() )
|
||||
{
|
||||
hsGShadeVertex* svtx = vList.Current();
|
||||
|
||||
hsScalar dist = -vDir.InnerProduct(svtx->fLocalPos);
|
||||
dist += vDist;
|
||||
dist *= scale;
|
||||
|
||||
hsScalar shade = IShadeFromDist(dist);
|
||||
|
||||
if( shade > 0 )
|
||||
{
|
||||
svtx->fShade.r *= shade;
|
||||
svtx->fShade.g *= shade;
|
||||
svtx->fShade.b *= shade;
|
||||
}
|
||||
else
|
||||
{
|
||||
svtx->fShade.r = 0;
|
||||
svtx->fShade.g = 0;
|
||||
svtx->fShade.b = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxDistShade::MakeTable(float* distList, float* shadeList, int num)
|
||||
{
|
||||
fTable.Reset();
|
||||
if( !num )
|
||||
return;
|
||||
|
||||
int i;
|
||||
for( i = 0; i < num; i++ )
|
||||
{
|
||||
hsSfxDfTableEntry* t = fTable.Append();
|
||||
t->fDistDel = distList[i];
|
||||
t->fShade = shadeList[i];
|
||||
}
|
||||
for( i = num-1; i > 0; i-- )
|
||||
fTable[i].fDistDel -= fTable[i-1].fDistDel;
|
||||
for( i = 0; i < num-1; i++ )
|
||||
fTable[i].fDistNorm = hsScalarInvert(fTable[i+1].fDistDel);
|
||||
fTable[num-1].fDistNorm = 0;
|
||||
hsAssert(fTable.GetCount() == num, "Mismatch making table");
|
||||
|
||||
int iMin;
|
||||
for( iMin = 0; (iMin < fTable.GetCount())&&(fTable[iMin].fShade <= 0); iMin++ );
|
||||
fMinDist = fTable[0].fDistDel;
|
||||
for( i = 1; i < iMin; i++ )
|
||||
fMinDist += fTable[i].fDistDel;
|
||||
|
||||
int iMax;
|
||||
for( iMax = fTable.GetCount()-1; (iMax >= 0)&&(fTable[iMax].fShade <= 0); iMax-- );
|
||||
if( ++iMax >= fTable.GetCount() )
|
||||
iMax = fTable.GetCount()-1;
|
||||
fMaxDist = fTable[0].fDistDel;
|
||||
for( i = 1; i <= iMax; i++ )
|
||||
fMaxDist += fTable[i].fDistDel;
|
||||
|
||||
}
|
||||
|
||||
void hsSfxDistShade::Read(hsStream* s)
|
||||
{
|
||||
fTable.Reset();
|
||||
|
||||
fMinDist = s->ReadSwapScalar();
|
||||
fMaxDist = s->ReadSwapScalar();
|
||||
|
||||
Int32 cnt = s->ReadSwap32();
|
||||
|
||||
if( cnt )
|
||||
{
|
||||
hsSfxDfTableEntry* arr = TRACKED_NEW hsSfxDfTableEntry[cnt];
|
||||
int i;
|
||||
for( i = 0; i < cnt; i++ )
|
||||
{
|
||||
arr[i].fDistDel = s->ReadSwapScalar();
|
||||
arr[i].fDistNorm = s->ReadSwapScalar();
|
||||
arr[i].fShade = s->ReadSwapScalar();
|
||||
}
|
||||
|
||||
fTable.SetArray(arr, cnt);
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxDistShade::Write(hsStream* s)
|
||||
{
|
||||
s->WriteSwapScalar(fMinDist);
|
||||
s->WriteSwapScalar(fMaxDist);
|
||||
|
||||
s->WriteSwap32(fTable.GetCount());
|
||||
|
||||
for( fTable.First(); fTable.More(); fTable.Plus() )
|
||||
{
|
||||
s->WriteSwapScalar(fTable.Current().fDistDel);
|
||||
s->WriteSwapScalar(fTable.Current().fDistNorm);
|
||||
s->WriteSwapScalar(fTable.Current().fShade);
|
||||
}
|
||||
}
|
||||
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsMemory.h"
|
||||
#include "hsSfxDistShade.h"
|
||||
#include "hsStream.h"
|
||||
#include "../plGeometry/hsTriangle3.h"
|
||||
|
||||
#include "../plIntersect/hsBounds.h"
|
||||
#include "../plDrawable/plDrawable.h"
|
||||
#include "../plPipeline/plPipeline.h"
|
||||
|
||||
static hsScalar globalScale = 1.f;
|
||||
|
||||
hsSfxDistShade::hsSfxDistShade()
|
||||
: fMinDist(0), fMaxDist(0)
|
||||
{
|
||||
}
|
||||
|
||||
hsSfxDistShade::~hsSfxDistShade()
|
||||
{
|
||||
}
|
||||
|
||||
hsScalar hsSfxDistShade::IShadeFromDist(hsScalar dist)
|
||||
{
|
||||
if( dist <= fTable[0].fDistDel )
|
||||
return fTable[0].fShade;
|
||||
|
||||
int i;
|
||||
for( i = 0; (i < fTable.GetCount()) && (dist >= fTable[i].fDistDel); i++ )
|
||||
dist -= fTable[i].fDistDel;
|
||||
|
||||
if( i >= fTable.GetCount() )
|
||||
return fTable[fTable.GetCount()-1].fShade;
|
||||
|
||||
dist *= fTable[i-1].fDistNorm;
|
||||
hsScalar shade0 = fTable[i-1].fShade;
|
||||
hsScalar shade1 = fTable[i].fShade;
|
||||
|
||||
return shade0 + dist * (shade1 - shade0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
hsBool32 hsSfxDistShade::BeginObject(plPipeline* pipe, plDrawable* obj)
|
||||
{
|
||||
hsGRenderProcs::BeginObject(pipe, obj);
|
||||
|
||||
fFlags &= ~(kCulled | kNOP);
|
||||
|
||||
hsPoint3 vPos;
|
||||
if( GetObjectRef(1) )
|
||||
{
|
||||
hsPoint3 wPos;
|
||||
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&wPos);
|
||||
hsMatrix44 w2l = pipe->GetWorldToLocal();
|
||||
vPos = w2l * wPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
vPos = pipe->GetViewPositionLocal();
|
||||
}
|
||||
hsVector3 vDir = -pipe->GetViewDirLocal();
|
||||
|
||||
hsScalar scale = 1.f / fPipeline->GetLocalScale();
|
||||
scale *= globalScale;
|
||||
|
||||
hsScalar vD = -(vDir.InnerProduct(vPos));
|
||||
vD *= scale;
|
||||
|
||||
const hsBounds3Ext& bnd = obj->GetLocalBounds();
|
||||
|
||||
hsPoint3 corner;
|
||||
bnd.GetCorner(&corner);
|
||||
hsVector3 axis[3];
|
||||
bnd.GetAxes(axis+0, axis+1, axis+2);
|
||||
|
||||
hsScalar dist = vDir.InnerProduct(corner) + vD;
|
||||
hsScalar minDist = dist;
|
||||
hsScalar maxDist = dist;
|
||||
|
||||
int i;
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
dist = vDir.InnerProduct(axis[i]);
|
||||
if( dist < 0 )
|
||||
minDist += dist;
|
||||
else
|
||||
maxDist += dist;
|
||||
}
|
||||
|
||||
minDist *= scale;
|
||||
maxDist *= scale;
|
||||
|
||||
fFlags &= ~kShadeConstant;
|
||||
if( maxDist < fMinDist )
|
||||
{
|
||||
fFlags |= kShadeConstant;
|
||||
fConstShade = fTable[0].fShade;
|
||||
}
|
||||
else if( minDist > fMaxDist )
|
||||
{
|
||||
fFlags |= kShadeConstant;
|
||||
fConstShade = fTable[fTable.GetCount()-1].fShade;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void hsSfxDistShade::ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList)
|
||||
{
|
||||
if( fFlags & kShadeConstant )
|
||||
{
|
||||
IConstShadeVerts(vList);
|
||||
}
|
||||
else
|
||||
{
|
||||
ICalcShadeVerts(vList);
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxDistShade::IConstShadeVerts(hsExpander<hsGShadeVertex*>& vList)
|
||||
{
|
||||
for( vList.First(); vList.More(); vList.Plus() )
|
||||
{
|
||||
hsGShadeVertex* svtx = vList.Current();
|
||||
svtx->fShade.r *= fConstShade;
|
||||
svtx->fShade.g *= fConstShade;
|
||||
svtx->fShade.b *= fConstShade;
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxDistShade::ICalcShadeVerts(hsExpander<hsGShadeVertex*>& vList)
|
||||
{
|
||||
hsPoint3 vPos;
|
||||
if( GetObjectRef(1) )
|
||||
{
|
||||
hsPoint3 wPos;
|
||||
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&wPos);
|
||||
hsMatrix44 w2l = fPipeline->GetWorldToLocal();
|
||||
vPos = w2l * wPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
vPos = fPipeline->GetViewPositionLocal();
|
||||
}
|
||||
hsVector3 vDir = fPipeline->GetViewDirLocal();
|
||||
|
||||
hsScalar vDist = vDir.InnerProduct(vPos);
|
||||
|
||||
hsScalar scale = 1.f / fPipeline->GetLocalScale();
|
||||
scale *= globalScale;
|
||||
|
||||
for( vList.First(); vList.More(); vList.Plus() )
|
||||
{
|
||||
hsGShadeVertex* svtx = vList.Current();
|
||||
|
||||
hsScalar dist = -vDir.InnerProduct(svtx->fLocalPos);
|
||||
dist += vDist;
|
||||
dist *= scale;
|
||||
|
||||
hsScalar shade = IShadeFromDist(dist);
|
||||
|
||||
if( shade > 0 )
|
||||
{
|
||||
svtx->fShade.r *= shade;
|
||||
svtx->fShade.g *= shade;
|
||||
svtx->fShade.b *= shade;
|
||||
}
|
||||
else
|
||||
{
|
||||
svtx->fShade.r = 0;
|
||||
svtx->fShade.g = 0;
|
||||
svtx->fShade.b = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxDistShade::MakeTable(float* distList, float* shadeList, int num)
|
||||
{
|
||||
fTable.Reset();
|
||||
if( !num )
|
||||
return;
|
||||
|
||||
int i;
|
||||
for( i = 0; i < num; i++ )
|
||||
{
|
||||
hsSfxDfTableEntry* t = fTable.Append();
|
||||
t->fDistDel = distList[i];
|
||||
t->fShade = shadeList[i];
|
||||
}
|
||||
for( i = num-1; i > 0; i-- )
|
||||
fTable[i].fDistDel -= fTable[i-1].fDistDel;
|
||||
for( i = 0; i < num-1; i++ )
|
||||
fTable[i].fDistNorm = hsScalarInvert(fTable[i+1].fDistDel);
|
||||
fTable[num-1].fDistNorm = 0;
|
||||
hsAssert(fTable.GetCount() == num, "Mismatch making table");
|
||||
|
||||
int iMin;
|
||||
for( iMin = 0; (iMin < fTable.GetCount())&&(fTable[iMin].fShade <= 0); iMin++ );
|
||||
fMinDist = fTable[0].fDistDel;
|
||||
for( i = 1; i < iMin; i++ )
|
||||
fMinDist += fTable[i].fDistDel;
|
||||
|
||||
int iMax;
|
||||
for( iMax = fTable.GetCount()-1; (iMax >= 0)&&(fTable[iMax].fShade <= 0); iMax-- );
|
||||
if( ++iMax >= fTable.GetCount() )
|
||||
iMax = fTable.GetCount()-1;
|
||||
fMaxDist = fTable[0].fDistDel;
|
||||
for( i = 1; i <= iMax; i++ )
|
||||
fMaxDist += fTable[i].fDistDel;
|
||||
|
||||
}
|
||||
|
||||
void hsSfxDistShade::Read(hsStream* s)
|
||||
{
|
||||
fTable.Reset();
|
||||
|
||||
fMinDist = s->ReadSwapScalar();
|
||||
fMaxDist = s->ReadSwapScalar();
|
||||
|
||||
Int32 cnt = s->ReadSwap32();
|
||||
|
||||
if( cnt )
|
||||
{
|
||||
hsSfxDfTableEntry* arr = TRACKED_NEW hsSfxDfTableEntry[cnt];
|
||||
int i;
|
||||
for( i = 0; i < cnt; i++ )
|
||||
{
|
||||
arr[i].fDistDel = s->ReadSwapScalar();
|
||||
arr[i].fDistNorm = s->ReadSwapScalar();
|
||||
arr[i].fShade = s->ReadSwapScalar();
|
||||
}
|
||||
|
||||
fTable.SetArray(arr, cnt);
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxDistShade::Write(hsStream* s)
|
||||
{
|
||||
s->WriteSwapScalar(fMinDist);
|
||||
s->WriteSwapScalar(fMaxDist);
|
||||
|
||||
s->WriteSwap32(fTable.GetCount());
|
||||
|
||||
for( fTable.First(); fTable.More(); fTable.Plus() )
|
||||
{
|
||||
s->WriteSwapScalar(fTable.Current().fDistDel);
|
||||
s->WriteSwapScalar(fTable.Current().fDistNorm);
|
||||
s->WriteSwapScalar(fTable.Current().fShade);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,81 +1,81 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef hsSfxDistShade_inc
|
||||
#define hsSfxDistShade_inc
|
||||
|
||||
#include "hsBiExpander.h"
|
||||
#include "hsGRenderProcs.h"
|
||||
|
||||
class hsSfxDistShade : public hsGRenderProcs {
|
||||
public:
|
||||
enum {
|
||||
kShadeConstant = 0x10000
|
||||
};
|
||||
|
||||
struct hsSfxDfTableEntry {
|
||||
hsScalar fDistDel;
|
||||
hsScalar fDistNorm;
|
||||
hsScalar fShade;
|
||||
};
|
||||
protected:
|
||||
|
||||
hsScalar fMinDist;
|
||||
hsScalar fMaxDist;
|
||||
|
||||
hsScalar fConstShade;
|
||||
|
||||
hsScalar fMinIdle;
|
||||
hsScalar fMaxIdle;
|
||||
|
||||
hsExpander<hsSfxDfTableEntry> fTable;
|
||||
|
||||
void IConstShadeVerts(hsExpander<hsGShadeVertex*>& vList);
|
||||
void ICalcShadeVerts(hsExpander<hsGShadeVertex*>& vList);
|
||||
hsScalar IShadeFromDist(hsScalar dist);
|
||||
public:
|
||||
hsSfxDistShade();
|
||||
virtual ~hsSfxDistShade();
|
||||
|
||||
virtual hsBool32 BeginObject(plPipeline* pipe, plDrawable* obj);
|
||||
|
||||
virtual void ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList);
|
||||
|
||||
void MakeTable(float* distList, float* shadeList, int num); // lists sorted from lowest cosine to highest
|
||||
|
||||
virtual void Read(hsStream* s);
|
||||
virtual void Write(hsStream* s);
|
||||
|
||||
virtual const char* GetLabel() const { return "hsSfxDistShade"; }
|
||||
|
||||
virtual ProcType GetType() const { return kTypeDistShade; }
|
||||
|
||||
CLASSNAME_REGISTER( hsSfxDistShade );
|
||||
GETINTERFACE_ANY( hsSfxDistShade, hsGRenderProcs );
|
||||
|
||||
};
|
||||
|
||||
#endif // hsSfxDistShade_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef hsSfxDistShade_inc
|
||||
#define hsSfxDistShade_inc
|
||||
|
||||
#include "hsBiExpander.h"
|
||||
#include "hsGRenderProcs.h"
|
||||
|
||||
class hsSfxDistShade : public hsGRenderProcs {
|
||||
public:
|
||||
enum {
|
||||
kShadeConstant = 0x10000
|
||||
};
|
||||
|
||||
struct hsSfxDfTableEntry {
|
||||
hsScalar fDistDel;
|
||||
hsScalar fDistNorm;
|
||||
hsScalar fShade;
|
||||
};
|
||||
protected:
|
||||
|
||||
hsScalar fMinDist;
|
||||
hsScalar fMaxDist;
|
||||
|
||||
hsScalar fConstShade;
|
||||
|
||||
hsScalar fMinIdle;
|
||||
hsScalar fMaxIdle;
|
||||
|
||||
hsExpander<hsSfxDfTableEntry> fTable;
|
||||
|
||||
void IConstShadeVerts(hsExpander<hsGShadeVertex*>& vList);
|
||||
void ICalcShadeVerts(hsExpander<hsGShadeVertex*>& vList);
|
||||
hsScalar IShadeFromDist(hsScalar dist);
|
||||
public:
|
||||
hsSfxDistShade();
|
||||
virtual ~hsSfxDistShade();
|
||||
|
||||
virtual hsBool32 BeginObject(plPipeline* pipe, plDrawable* obj);
|
||||
|
||||
virtual void ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList);
|
||||
|
||||
void MakeTable(float* distList, float* shadeList, int num); // lists sorted from lowest cosine to highest
|
||||
|
||||
virtual void Read(hsStream* s);
|
||||
virtual void Write(hsStream* s);
|
||||
|
||||
virtual const char* GetLabel() const { return "hsSfxDistShade"; }
|
||||
|
||||
virtual ProcType GetType() const { return kTypeDistShade; }
|
||||
|
||||
CLASSNAME_REGISTER( hsSfxDistShade );
|
||||
GETINTERFACE_ANY( hsSfxDistShade, hsGRenderProcs );
|
||||
|
||||
};
|
||||
|
||||
#endif // hsSfxDistShade_inc
|
||||
|
@ -1,226 +1,226 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsMemory.h"
|
||||
#include "hsSfxGlobalShade.h"
|
||||
#include "hsStream.h"
|
||||
//#include "../plPipeline/hsG3DDevice.h"
|
||||
#include "../plPipeline/plPipeline.h"
|
||||
#include "../plGLight/hsGProjector3.h"
|
||||
#include "../plSurface/hsGLayer.h"
|
||||
#include "../plSurface/hsGMaterial.h"
|
||||
#include "../plDrawable/plDrawable.h"
|
||||
#include "../plIntersect/hsBounds.h"
|
||||
|
||||
|
||||
void hsSfxGlobalShade::ISetIntensity(hsPoint3& pos)
|
||||
{
|
||||
if( fGSFlags & kFromFog )
|
||||
ISetFromFog(pos);
|
||||
else
|
||||
if( fGSFlags & kFromClear )
|
||||
ISetFromClear(pos);
|
||||
else
|
||||
if( fGSFlags & kFromLights )
|
||||
ISetFromLights(pos);
|
||||
|
||||
fIntensity.a = hsMaximum(fIntensity.r, hsMaximum(fIntensity.g, fIntensity.b));
|
||||
}
|
||||
|
||||
void hsSfxGlobalShade::ISetFromClear(hsPoint3& pos)
|
||||
{
|
||||
fIntensity.Set(0,0,0,0);
|
||||
#if 0 // Taken out 2.26.2001 mcn 'cause it accesses the (now defunct) 3DDevice directly
|
||||
hsG3DDevice* dev = fPipeline->Get3DDevice();
|
||||
hsGEnvironment* env = dev->GetEnvironment();
|
||||
if( env && (env->GetFlags() & hsGEnvironment::kClearColorSet) )
|
||||
{
|
||||
fIntensity = env->GetClearColor();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void hsSfxGlobalShade::ISetFromFog(hsPoint3& pos)
|
||||
{
|
||||
fIntensity.Set(0,0,0,0);
|
||||
#if 0 // Taken out 2.26.2001 mcn 'cause it accesses the (now defunct) 3DDevice directly
|
||||
hsG3DDevice* dev = fPipeline->Get3DDevice();
|
||||
hsGEnvironment* env = dev->GetEnvironment();
|
||||
if( env && (env->GetFlags() & hsGEnvironment::kFogColorSet) )
|
||||
{
|
||||
fIntensity = env->GetFogColor();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void hsSfxGlobalShade::ISetFromLights(hsPoint3& pos)
|
||||
{
|
||||
fIntensity = ISumLights(pos);
|
||||
}
|
||||
|
||||
hsColorRGBA hsSfxGlobalShade::ISumLights(hsPoint3& pos)
|
||||
{
|
||||
hsColorRGBA accum;
|
||||
accum.Set(0,0,0,0);
|
||||
|
||||
#if 0 // Taken out 2.26.2001 mcn 'cause it accesses the (now defunct) 3DDevice directly
|
||||
hsG3DDevice* dev = fPipeline->Get3DDevice();
|
||||
for( dev->FirstProjector(); dev->MoreProjectors(); dev->IncProjector() )
|
||||
{
|
||||
hsGProjector3* proj = dev->CurrProjector();
|
||||
|
||||
if( proj->IsOmni() )
|
||||
{
|
||||
hsScalar intensity = proj->AttenuatePoint(&pos) * proj->GetIntensity();
|
||||
|
||||
if( intensity > 0.f )
|
||||
{
|
||||
hsColorRGBA col = intensity * proj->GetLightColor();
|
||||
accum += col;
|
||||
}
|
||||
}
|
||||
else
|
||||
if( proj->IsPerspective() ) // spot
|
||||
{
|
||||
hsPoint4 ang;
|
||||
UInt32 clips;
|
||||
proj->GetNdcPoints(1, &pos, sizeof(pos), &ang, kClipAll, &clips);
|
||||
|
||||
if( !clips
|
||||
|| !( proj->IsAttenuated() || proj->AttenuatesAlpha() || (clips & ~kClipYon) )
|
||||
)
|
||||
{
|
||||
hsScalar intensity = proj->AttenuatePoint(&pos) * proj->GetIntensity();
|
||||
|
||||
if( intensity > 0.f )
|
||||
{
|
||||
hsColorRGBA col = intensity * proj->GetLightColor();
|
||||
accum += col;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // directional
|
||||
{
|
||||
hsColorRGBA col = proj->GetIntensity() * proj->GetLightColor();
|
||||
accum += col;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return accum;
|
||||
}
|
||||
|
||||
void hsSfxGlobalShade::ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList)
|
||||
{
|
||||
if( fCurrentLayer )
|
||||
{
|
||||
if( fGSFlags & kAffectDiffuse )
|
||||
fCurrentLayer->SetColor(fRestoreColor.r, fRestoreColor.g, fRestoreColor.b, fRestoreColor.a);
|
||||
else
|
||||
fCurrentLayer->SetAmbientColor(fRestoreColor.r, fRestoreColor.g, fRestoreColor.b, fRestoreColor.a);
|
||||
}
|
||||
|
||||
#if 0 // Taken out 2.26.2001 mcn 'cause it accesses the (now defunct) 3DDevice directly
|
||||
hsG3DDevice* dev = fPipeline->Get3DDevice();
|
||||
hsRefCnt_SafeAssign(fCurrentLayer, dev->GetCurrentLayer());
|
||||
if( fCurrentLayer )
|
||||
{
|
||||
fRestoreColor = fGSFlags & kAffectDiffuse ? fCurrentLayer->GetColor() : fCurrentLayer->GetAmbientColor();
|
||||
hsColorRGBA col = fAmbient;
|
||||
if( fGSFlags & kScalarIntensity )
|
||||
{
|
||||
col.r += fDiffuse.r * fIntensity.a;
|
||||
col.g += fDiffuse.g * fIntensity.a;
|
||||
col.b += fDiffuse.b * fIntensity.a;
|
||||
}
|
||||
else
|
||||
{
|
||||
col.r += fDiffuse.r * fIntensity.r;
|
||||
col.g += fDiffuse.g * fIntensity.g;
|
||||
col.b += fDiffuse.b * fIntensity.b;
|
||||
}
|
||||
if( fGSFlags & kAffectDiffuse )
|
||||
fCurrentLayer->SetColor(col.r, col.g, col.b, fRestoreColor.a);
|
||||
else
|
||||
fCurrentLayer->SetAmbientColor(col.r, col.g, col.b, fRestoreColor.a);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
hsBool32 hsSfxGlobalShade::BeginObject(plPipeline* pipe, plDrawable* obj)
|
||||
{
|
||||
hsBool32 retVal = hsGRenderProcs::BeginObject(pipe, obj);
|
||||
|
||||
const hsBounds3Ext& bnd = obj->GetLocalBounds();
|
||||
hsPoint3 pos = bnd.GetCenter();
|
||||
ISetIntensity(pos);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void hsSfxGlobalShade::EndObject()
|
||||
{
|
||||
hsGRenderProcs::EndObject();
|
||||
if( fCurrentLayer )
|
||||
{
|
||||
if( fGSFlags & kAffectDiffuse )
|
||||
fCurrentLayer->SetColor(fRestoreColor.r, fRestoreColor.g, fRestoreColor.b, fRestoreColor.a);
|
||||
else
|
||||
fCurrentLayer->SetAmbientColor(fRestoreColor.r, fRestoreColor.g, fRestoreColor.b, fRestoreColor.a);
|
||||
hsRefCnt_SafeUnRef(fCurrentLayer);
|
||||
fCurrentLayer = nil;
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxGlobalShade::Read(hsStream* s)
|
||||
{
|
||||
fGSFlags = s->ReadSwap32();
|
||||
fAmbient.Read(s);
|
||||
fDiffuse.Read(s);
|
||||
if( fGSFlags & kFromLights )
|
||||
fGSFlags |= kAffectDiffuse;
|
||||
}
|
||||
|
||||
void hsSfxGlobalShade::Write(hsStream* s)
|
||||
{
|
||||
s->WriteSwap32(fGSFlags);
|
||||
fAmbient.Write(s);
|
||||
fDiffuse.Write(s);
|
||||
}
|
||||
|
||||
hsSfxGlobalShade::hsSfxGlobalShade()
|
||||
{
|
||||
fCurrentLayer = nil;
|
||||
fGSFlags = 0;
|
||||
fAmbient.Set(0,0,0,0);
|
||||
fDiffuse.Set(1.f,1.f,1.f,1.f);
|
||||
}
|
||||
|
||||
hsSfxGlobalShade::~hsSfxGlobalShade()
|
||||
{
|
||||
hsRefCnt_SafeUnRef(fCurrentLayer); // should be nil anyway unless we're destroyed during processing
|
||||
}
|
||||
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsMemory.h"
|
||||
#include "hsSfxGlobalShade.h"
|
||||
#include "hsStream.h"
|
||||
//#include "../plPipeline/hsG3DDevice.h"
|
||||
#include "../plPipeline/plPipeline.h"
|
||||
#include "../plGLight/hsGProjector3.h"
|
||||
#include "../plSurface/hsGLayer.h"
|
||||
#include "../plSurface/hsGMaterial.h"
|
||||
#include "../plDrawable/plDrawable.h"
|
||||
#include "../plIntersect/hsBounds.h"
|
||||
|
||||
|
||||
void hsSfxGlobalShade::ISetIntensity(hsPoint3& pos)
|
||||
{
|
||||
if( fGSFlags & kFromFog )
|
||||
ISetFromFog(pos);
|
||||
else
|
||||
if( fGSFlags & kFromClear )
|
||||
ISetFromClear(pos);
|
||||
else
|
||||
if( fGSFlags & kFromLights )
|
||||
ISetFromLights(pos);
|
||||
|
||||
fIntensity.a = hsMaximum(fIntensity.r, hsMaximum(fIntensity.g, fIntensity.b));
|
||||
}
|
||||
|
||||
void hsSfxGlobalShade::ISetFromClear(hsPoint3& pos)
|
||||
{
|
||||
fIntensity.Set(0,0,0,0);
|
||||
#if 0 // Taken out 2.26.2001 mcn 'cause it accesses the (now defunct) 3DDevice directly
|
||||
hsG3DDevice* dev = fPipeline->Get3DDevice();
|
||||
hsGEnvironment* env = dev->GetEnvironment();
|
||||
if( env && (env->GetFlags() & hsGEnvironment::kClearColorSet) )
|
||||
{
|
||||
fIntensity = env->GetClearColor();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void hsSfxGlobalShade::ISetFromFog(hsPoint3& pos)
|
||||
{
|
||||
fIntensity.Set(0,0,0,0);
|
||||
#if 0 // Taken out 2.26.2001 mcn 'cause it accesses the (now defunct) 3DDevice directly
|
||||
hsG3DDevice* dev = fPipeline->Get3DDevice();
|
||||
hsGEnvironment* env = dev->GetEnvironment();
|
||||
if( env && (env->GetFlags() & hsGEnvironment::kFogColorSet) )
|
||||
{
|
||||
fIntensity = env->GetFogColor();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void hsSfxGlobalShade::ISetFromLights(hsPoint3& pos)
|
||||
{
|
||||
fIntensity = ISumLights(pos);
|
||||
}
|
||||
|
||||
hsColorRGBA hsSfxGlobalShade::ISumLights(hsPoint3& pos)
|
||||
{
|
||||
hsColorRGBA accum;
|
||||
accum.Set(0,0,0,0);
|
||||
|
||||
#if 0 // Taken out 2.26.2001 mcn 'cause it accesses the (now defunct) 3DDevice directly
|
||||
hsG3DDevice* dev = fPipeline->Get3DDevice();
|
||||
for( dev->FirstProjector(); dev->MoreProjectors(); dev->IncProjector() )
|
||||
{
|
||||
hsGProjector3* proj = dev->CurrProjector();
|
||||
|
||||
if( proj->IsOmni() )
|
||||
{
|
||||
hsScalar intensity = proj->AttenuatePoint(&pos) * proj->GetIntensity();
|
||||
|
||||
if( intensity > 0.f )
|
||||
{
|
||||
hsColorRGBA col = intensity * proj->GetLightColor();
|
||||
accum += col;
|
||||
}
|
||||
}
|
||||
else
|
||||
if( proj->IsPerspective() ) // spot
|
||||
{
|
||||
hsPoint4 ang;
|
||||
UInt32 clips;
|
||||
proj->GetNdcPoints(1, &pos, sizeof(pos), &ang, kClipAll, &clips);
|
||||
|
||||
if( !clips
|
||||
|| !( proj->IsAttenuated() || proj->AttenuatesAlpha() || (clips & ~kClipYon) )
|
||||
)
|
||||
{
|
||||
hsScalar intensity = proj->AttenuatePoint(&pos) * proj->GetIntensity();
|
||||
|
||||
if( intensity > 0.f )
|
||||
{
|
||||
hsColorRGBA col = intensity * proj->GetLightColor();
|
||||
accum += col;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // directional
|
||||
{
|
||||
hsColorRGBA col = proj->GetIntensity() * proj->GetLightColor();
|
||||
accum += col;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return accum;
|
||||
}
|
||||
|
||||
void hsSfxGlobalShade::ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList)
|
||||
{
|
||||
if( fCurrentLayer )
|
||||
{
|
||||
if( fGSFlags & kAffectDiffuse )
|
||||
fCurrentLayer->SetColor(fRestoreColor.r, fRestoreColor.g, fRestoreColor.b, fRestoreColor.a);
|
||||
else
|
||||
fCurrentLayer->SetAmbientColor(fRestoreColor.r, fRestoreColor.g, fRestoreColor.b, fRestoreColor.a);
|
||||
}
|
||||
|
||||
#if 0 // Taken out 2.26.2001 mcn 'cause it accesses the (now defunct) 3DDevice directly
|
||||
hsG3DDevice* dev = fPipeline->Get3DDevice();
|
||||
hsRefCnt_SafeAssign(fCurrentLayer, dev->GetCurrentLayer());
|
||||
if( fCurrentLayer )
|
||||
{
|
||||
fRestoreColor = fGSFlags & kAffectDiffuse ? fCurrentLayer->GetColor() : fCurrentLayer->GetAmbientColor();
|
||||
hsColorRGBA col = fAmbient;
|
||||
if( fGSFlags & kScalarIntensity )
|
||||
{
|
||||
col.r += fDiffuse.r * fIntensity.a;
|
||||
col.g += fDiffuse.g * fIntensity.a;
|
||||
col.b += fDiffuse.b * fIntensity.a;
|
||||
}
|
||||
else
|
||||
{
|
||||
col.r += fDiffuse.r * fIntensity.r;
|
||||
col.g += fDiffuse.g * fIntensity.g;
|
||||
col.b += fDiffuse.b * fIntensity.b;
|
||||
}
|
||||
if( fGSFlags & kAffectDiffuse )
|
||||
fCurrentLayer->SetColor(col.r, col.g, col.b, fRestoreColor.a);
|
||||
else
|
||||
fCurrentLayer->SetAmbientColor(col.r, col.g, col.b, fRestoreColor.a);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
hsBool32 hsSfxGlobalShade::BeginObject(plPipeline* pipe, plDrawable* obj)
|
||||
{
|
||||
hsBool32 retVal = hsGRenderProcs::BeginObject(pipe, obj);
|
||||
|
||||
const hsBounds3Ext& bnd = obj->GetLocalBounds();
|
||||
hsPoint3 pos = bnd.GetCenter();
|
||||
ISetIntensity(pos);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void hsSfxGlobalShade::EndObject()
|
||||
{
|
||||
hsGRenderProcs::EndObject();
|
||||
if( fCurrentLayer )
|
||||
{
|
||||
if( fGSFlags & kAffectDiffuse )
|
||||
fCurrentLayer->SetColor(fRestoreColor.r, fRestoreColor.g, fRestoreColor.b, fRestoreColor.a);
|
||||
else
|
||||
fCurrentLayer->SetAmbientColor(fRestoreColor.r, fRestoreColor.g, fRestoreColor.b, fRestoreColor.a);
|
||||
hsRefCnt_SafeUnRef(fCurrentLayer);
|
||||
fCurrentLayer = nil;
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxGlobalShade::Read(hsStream* s)
|
||||
{
|
||||
fGSFlags = s->ReadSwap32();
|
||||
fAmbient.Read(s);
|
||||
fDiffuse.Read(s);
|
||||
if( fGSFlags & kFromLights )
|
||||
fGSFlags |= kAffectDiffuse;
|
||||
}
|
||||
|
||||
void hsSfxGlobalShade::Write(hsStream* s)
|
||||
{
|
||||
s->WriteSwap32(fGSFlags);
|
||||
fAmbient.Write(s);
|
||||
fDiffuse.Write(s);
|
||||
}
|
||||
|
||||
hsSfxGlobalShade::hsSfxGlobalShade()
|
||||
{
|
||||
fCurrentLayer = nil;
|
||||
fGSFlags = 0;
|
||||
fAmbient.Set(0,0,0,0);
|
||||
fDiffuse.Set(1.f,1.f,1.f,1.f);
|
||||
}
|
||||
|
||||
hsSfxGlobalShade::~hsSfxGlobalShade()
|
||||
{
|
||||
hsRefCnt_SafeUnRef(fCurrentLayer); // should be nil anyway unless we're destroyed during processing
|
||||
}
|
||||
|
||||
|
@ -1,104 +1,104 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
|
||||
#ifndef hsSfxGlobalShade_inc
|
||||
#define hsSfxGlobalShade_inc
|
||||
|
||||
#include "hsBiExpander.h"
|
||||
#include "hsGRenderProcs.h"
|
||||
#include "hsColorRGBA.h"
|
||||
#include "hsGeometry3.h"
|
||||
|
||||
class hsGLayer;
|
||||
|
||||
class hsSfxGlobalShade : public hsGRenderProcs {
|
||||
public:
|
||||
enum {
|
||||
kNone = 0x0,
|
||||
kFromFog = 0x1,
|
||||
kFromClear = 0x2,
|
||||
kFromLights = 0x4,
|
||||
kSourceMask = kFromFog | kFromClear | kFromLights,
|
||||
kScalarIntensity = 0x8,
|
||||
kAffectDiffuse = 0x10
|
||||
};
|
||||
protected:
|
||||
|
||||
// Constants from which to work.
|
||||
UInt32 fGSFlags;
|
||||
|
||||
hsColorRGBA fAmbient;
|
||||
hsColorRGBA fDiffuse;
|
||||
|
||||
// Calculated each invocation.
|
||||
hsColorRGBA fIntensity;
|
||||
|
||||
hsGLayer* fCurrentLayer;
|
||||
hsColorRGBA fRestoreColor;
|
||||
|
||||
void ISetIntensity(hsPoint3& pos);
|
||||
void ISetFromFog(hsPoint3& pos);
|
||||
void ISetFromClear(hsPoint3& pos);
|
||||
void ISetFromLights(hsPoint3& pos);
|
||||
hsColorRGBA ISumLights(hsPoint3& pos);
|
||||
public:
|
||||
hsSfxGlobalShade();
|
||||
virtual ~hsSfxGlobalShade();
|
||||
|
||||
virtual void ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList);
|
||||
|
||||
virtual hsBool32 BeginObject(plPipeline* pipe, plDrawable* obj);
|
||||
virtual void EndObject();
|
||||
|
||||
virtual void Read(hsStream* s);
|
||||
virtual void Write(hsStream* s);
|
||||
|
||||
virtual const char* GetLabel() const { return "hsSfxGlobalShade"; }
|
||||
|
||||
virtual ProcType GetType() const { return kTypeGlobalShade; }
|
||||
|
||||
void SetAmbient(const hsColorRGBA& col) { fAmbient = col; }
|
||||
hsColorRGBA GetAmbient() const { return fAmbient; }
|
||||
|
||||
void SetDiffuse(const hsColorRGBA& col) { fDiffuse = col; }
|
||||
hsColorRGBA GetDiffuse() const { return fDiffuse; }
|
||||
|
||||
void SetSource(UInt32 f) { fGSFlags &= ~kSourceMask; fGSFlags |= f; }
|
||||
UInt32 GetSource() { return fGSFlags & kSourceMask; }
|
||||
|
||||
void SetScalar(hsBool32 on) { if(on)fGSFlags |= kScalarIntensity; else fGSFlags &= ~kScalarIntensity; }
|
||||
hsBool32 GetScalar() { return 0 != (fGSFlags & kScalarIntensity); }
|
||||
|
||||
void SetAffectDiffuse(hsBool32 on) { if(on)fGSFlags |= kAffectDiffuse; else fGSFlags &= ~kAffectDiffuse; }
|
||||
hsBool32 GetAffectDiffuse() { return 0 != (fGSFlags & kAffectDiffuse); }
|
||||
|
||||
CLASSNAME_REGISTER( hsSfxGlobalShade );
|
||||
GETINTERFACE_ANY( hsSfxGlobalShade, hsGRenderProcs );
|
||||
|
||||
};
|
||||
|
||||
#endif // hsSfxGlobalShade_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
|
||||
#ifndef hsSfxGlobalShade_inc
|
||||
#define hsSfxGlobalShade_inc
|
||||
|
||||
#include "hsBiExpander.h"
|
||||
#include "hsGRenderProcs.h"
|
||||
#include "hsColorRGBA.h"
|
||||
#include "hsGeometry3.h"
|
||||
|
||||
class hsGLayer;
|
||||
|
||||
class hsSfxGlobalShade : public hsGRenderProcs {
|
||||
public:
|
||||
enum {
|
||||
kNone = 0x0,
|
||||
kFromFog = 0x1,
|
||||
kFromClear = 0x2,
|
||||
kFromLights = 0x4,
|
||||
kSourceMask = kFromFog | kFromClear | kFromLights,
|
||||
kScalarIntensity = 0x8,
|
||||
kAffectDiffuse = 0x10
|
||||
};
|
||||
protected:
|
||||
|
||||
// Constants from which to work.
|
||||
UInt32 fGSFlags;
|
||||
|
||||
hsColorRGBA fAmbient;
|
||||
hsColorRGBA fDiffuse;
|
||||
|
||||
// Calculated each invocation.
|
||||
hsColorRGBA fIntensity;
|
||||
|
||||
hsGLayer* fCurrentLayer;
|
||||
hsColorRGBA fRestoreColor;
|
||||
|
||||
void ISetIntensity(hsPoint3& pos);
|
||||
void ISetFromFog(hsPoint3& pos);
|
||||
void ISetFromClear(hsPoint3& pos);
|
||||
void ISetFromLights(hsPoint3& pos);
|
||||
hsColorRGBA ISumLights(hsPoint3& pos);
|
||||
public:
|
||||
hsSfxGlobalShade();
|
||||
virtual ~hsSfxGlobalShade();
|
||||
|
||||
virtual void ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList);
|
||||
|
||||
virtual hsBool32 BeginObject(plPipeline* pipe, plDrawable* obj);
|
||||
virtual void EndObject();
|
||||
|
||||
virtual void Read(hsStream* s);
|
||||
virtual void Write(hsStream* s);
|
||||
|
||||
virtual const char* GetLabel() const { return "hsSfxGlobalShade"; }
|
||||
|
||||
virtual ProcType GetType() const { return kTypeGlobalShade; }
|
||||
|
||||
void SetAmbient(const hsColorRGBA& col) { fAmbient = col; }
|
||||
hsColorRGBA GetAmbient() const { return fAmbient; }
|
||||
|
||||
void SetDiffuse(const hsColorRGBA& col) { fDiffuse = col; }
|
||||
hsColorRGBA GetDiffuse() const { return fDiffuse; }
|
||||
|
||||
void SetSource(UInt32 f) { fGSFlags &= ~kSourceMask; fGSFlags |= f; }
|
||||
UInt32 GetSource() { return fGSFlags & kSourceMask; }
|
||||
|
||||
void SetScalar(hsBool32 on) { if(on)fGSFlags |= kScalarIntensity; else fGSFlags &= ~kScalarIntensity; }
|
||||
hsBool32 GetScalar() { return 0 != (fGSFlags & kScalarIntensity); }
|
||||
|
||||
void SetAffectDiffuse(hsBool32 on) { if(on)fGSFlags |= kAffectDiffuse; else fGSFlags &= ~kAffectDiffuse; }
|
||||
hsBool32 GetAffectDiffuse() { return 0 != (fGSFlags & kAffectDiffuse); }
|
||||
|
||||
CLASSNAME_REGISTER( hsSfxGlobalShade );
|
||||
GETINTERFACE_ANY( hsSfxGlobalShade, hsGRenderProcs );
|
||||
|
||||
};
|
||||
|
||||
#endif // hsSfxGlobalShade_inc
|
||||
|
@ -1,65 +1,65 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsGeometry3.h"
|
||||
#include "hsSfxIntenseAlpha.h"
|
||||
#include "../plGeometry/hsTriangle3.h"
|
||||
|
||||
|
||||
hsSfxIntenseAlpha::hsSfxIntenseAlpha()
|
||||
: fMinAlpha(0)
|
||||
{
|
||||
fFlags |= kInclusive;
|
||||
}
|
||||
|
||||
hsSfxIntenseAlpha::~hsSfxIntenseAlpha()
|
||||
{
|
||||
}
|
||||
|
||||
void hsSfxIntenseAlpha::ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList)
|
||||
{
|
||||
hsScalar oScale = 1.f - fMinAlpha;
|
||||
for( vList.First(); vList.More(); vList.Plus() )
|
||||
{
|
||||
hsGShadeVertex* s = vList.Current();
|
||||
hsScalar o = hsMaximum(hsMaximum(s->fShade.r, s->fShade.g), s->fShade.b);
|
||||
o *= oScale;
|
||||
o += fMinAlpha;
|
||||
s->fShade.a *= o;
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxIntenseAlpha::Read(hsStream* s)
|
||||
{
|
||||
fMinAlpha = s->ReadSwapScalar();
|
||||
}
|
||||
|
||||
void hsSfxIntenseAlpha::Write(hsStream* s)
|
||||
{
|
||||
s->WriteSwapScalar(fMinAlpha);
|
||||
}
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsGeometry3.h"
|
||||
#include "hsSfxIntenseAlpha.h"
|
||||
#include "../plGeometry/hsTriangle3.h"
|
||||
|
||||
|
||||
hsSfxIntenseAlpha::hsSfxIntenseAlpha()
|
||||
: fMinAlpha(0)
|
||||
{
|
||||
fFlags |= kInclusive;
|
||||
}
|
||||
|
||||
hsSfxIntenseAlpha::~hsSfxIntenseAlpha()
|
||||
{
|
||||
}
|
||||
|
||||
void hsSfxIntenseAlpha::ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList)
|
||||
{
|
||||
hsScalar oScale = 1.f - fMinAlpha;
|
||||
for( vList.First(); vList.More(); vList.Plus() )
|
||||
{
|
||||
hsGShadeVertex* s = vList.Current();
|
||||
hsScalar o = hsMaximum(hsMaximum(s->fShade.r, s->fShade.g), s->fShade.b);
|
||||
o *= oScale;
|
||||
o += fMinAlpha;
|
||||
s->fShade.a *= o;
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxIntenseAlpha::Read(hsStream* s)
|
||||
{
|
||||
fMinAlpha = s->ReadSwapScalar();
|
||||
}
|
||||
|
||||
void hsSfxIntenseAlpha::Write(hsStream* s)
|
||||
{
|
||||
s->WriteSwapScalar(fMinAlpha);
|
||||
}
|
||||
|
@ -1,66 +1,66 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef hsSfxIntenseAlpha_inc
|
||||
#define hsSfxIntenseAlpha_inc
|
||||
|
||||
#include "hsGRenderProcs.h"
|
||||
#include "hsGeometry3.h"
|
||||
|
||||
class hsSfxIntenseAlpha : public hsGRenderProcs
|
||||
{
|
||||
protected:
|
||||
hsVector3 fDirViewPerp;
|
||||
hsVector3 fDirScreen;
|
||||
hsScalar fOpacityScale;
|
||||
hsScalar fOpacityMax;
|
||||
|
||||
hsScalar fMinAlpha;
|
||||
|
||||
public:
|
||||
hsSfxIntenseAlpha();
|
||||
virtual ~hsSfxIntenseAlpha();
|
||||
|
||||
void SetMinAlpha(hsScalar s) { fMinAlpha = s; }
|
||||
hsScalar GetMinAlpha() { return fMinAlpha; }
|
||||
|
||||
virtual void ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList);
|
||||
|
||||
virtual void Read(hsStream* s);
|
||||
virtual void Write(hsStream* s);
|
||||
|
||||
virtual const char* GetLabel() const { return "hsSfxIntenseAlpha"; }
|
||||
|
||||
virtual ProcType GetType() const { return kTypeIntenseAlpha; }
|
||||
|
||||
CLASSNAME_REGISTER( hsSfxIntenseAlpha );
|
||||
GETINTERFACE_ANY( hsSfxIntenseAlpha, hsGRenderProcs );
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // hsSfxIntenseAlpha_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef hsSfxIntenseAlpha_inc
|
||||
#define hsSfxIntenseAlpha_inc
|
||||
|
||||
#include "hsGRenderProcs.h"
|
||||
#include "hsGeometry3.h"
|
||||
|
||||
class hsSfxIntenseAlpha : public hsGRenderProcs
|
||||
{
|
||||
protected:
|
||||
hsVector3 fDirViewPerp;
|
||||
hsVector3 fDirScreen;
|
||||
hsScalar fOpacityScale;
|
||||
hsScalar fOpacityMax;
|
||||
|
||||
hsScalar fMinAlpha;
|
||||
|
||||
public:
|
||||
hsSfxIntenseAlpha();
|
||||
virtual ~hsSfxIntenseAlpha();
|
||||
|
||||
void SetMinAlpha(hsScalar s) { fMinAlpha = s; }
|
||||
hsScalar GetMinAlpha() { return fMinAlpha; }
|
||||
|
||||
virtual void ProcessPreInterpShadeVerts(hsExpander<hsGShadeVertex*>& vList);
|
||||
|
||||
virtual void Read(hsStream* s);
|
||||
virtual void Write(hsStream* s);
|
||||
|
||||
virtual const char* GetLabel() const { return "hsSfxIntenseAlpha"; }
|
||||
|
||||
virtual ProcType GetType() const { return kTypeIntenseAlpha; }
|
||||
|
||||
CLASSNAME_REGISTER( hsSfxIntenseAlpha );
|
||||
GETINTERFACE_ANY( hsSfxIntenseAlpha, hsGRenderProcs );
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // hsSfxIntenseAlpha_inc
|
||||
|
@ -1,304 +1,304 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsMemory.h"
|
||||
#include "hsSfxObjDistFade.h"
|
||||
#include "hsStream.h"
|
||||
//#include "hsG3DDevice.h"
|
||||
#include "../plPipeline/plPipeline.h"
|
||||
#include "../plGeometry/hsTriangle3.h"
|
||||
|
||||
#include "../plIntersect/hsBounds.h"
|
||||
#include "../plDrawable/plDrawable.h"
|
||||
|
||||
static hsScalar globalScale = 1.f;
|
||||
|
||||
hsSfxObjDistFade::hsSfxObjDistFade()
|
||||
: fMinDist(0), fMaxDist(0), fTreeCnt(0)
|
||||
{
|
||||
}
|
||||
|
||||
hsSfxObjDistFade::~hsSfxObjDistFade()
|
||||
{
|
||||
}
|
||||
|
||||
hsScalar hsSfxObjDistFade::IOpacFromDist(hsScalar dist)
|
||||
{
|
||||
if( dist <= fTable[0].fDistDel )
|
||||
return fTable[0].fOpacity;
|
||||
|
||||
int i;
|
||||
for( i = 0; (i < fTable.GetCount()) && (dist >= fTable[i].fDistDel); i++ )
|
||||
dist -= fTable[i].fDistDel;
|
||||
|
||||
if( i >= fTable.GetCount() )
|
||||
return fTable[fTable.GetCount()-1].fOpacity;
|
||||
|
||||
dist *= fTable[i-1].fDistNorm;
|
||||
hsScalar opac0 = fTable[i-1].fOpacity;
|
||||
hsScalar opac1 = fTable[i].fOpacity;
|
||||
|
||||
return opac0 + dist * (opac1 - opac0);
|
||||
}
|
||||
|
||||
hsBool32 hsSfxObjDistFade::ISetOpac(plDrawable* refObj)
|
||||
{
|
||||
hsPoint3 refPos;
|
||||
if( fFlags & kByBoundsCenter )
|
||||
{
|
||||
const hsBounds3Ext& bnd = refObj->GetWorldBounds();
|
||||
if( kBoundsNormal != bnd.GetType() )
|
||||
return true;
|
||||
refPos = bnd.GetCenter();
|
||||
}
|
||||
else
|
||||
{
|
||||
refObj->GetLocalToWorld().GetTranslate(&refPos);
|
||||
}
|
||||
|
||||
fFlags &= ~(kCulled | kNOP);
|
||||
|
||||
hsPoint3 vPos;
|
||||
if( GetObjectRef(1) )
|
||||
{
|
||||
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&vPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
vPos = fPipeline->GetViewPositionWorld();
|
||||
}
|
||||
|
||||
hsScalar dist = hsVector3(&vPos, &refPos).Magnitude();
|
||||
|
||||
if( (fFlags & kCullsBefore)
|
||||
&&(dist <= fMinDist) )
|
||||
{
|
||||
fFlags |= kCulled;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( (fFlags & kCullsBeyond)
|
||||
&&(dist > fMaxDist) )
|
||||
{
|
||||
fFlags |= kCulled;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( (fFlags & kIdleBefore)
|
||||
&&(dist < fMinIdle) )
|
||||
fFlags |= kNOP;
|
||||
else
|
||||
if( (fFlags & kIdleBeyond)
|
||||
&&(dist > fMaxIdle) )
|
||||
fFlags |= kNOP;
|
||||
else
|
||||
{
|
||||
hsScalar opac = IOpacFromDist(dist);
|
||||
hsColorRGBA col = fColorizer.GetCurrentColor();
|
||||
if( fColorizer.Alpharizing() )
|
||||
col.a *= opac;
|
||||
else
|
||||
col.a = opac;
|
||||
fColorizer.PushColorize(col, fColorizer.Colorizing());
|
||||
|
||||
if( fFlags & kNoZTrans )
|
||||
{
|
||||
if( !(fPipeline->GetMaterialOverrideOff(hsGMatState::kZ) & hsGMatState::kZNoZWrite) )
|
||||
{
|
||||
fRestoreOver = fPipeline->PushMaterialOverride(hsGMatState::kZ, hsGMatState::kZNoZWrite, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
hsBool32 hsSfxObjDistFade::BeginObject(plPipeline* pipe, plDrawable* obj)
|
||||
{
|
||||
if( Inclusive() )
|
||||
return true;
|
||||
|
||||
hsGRenderProcs::BeginObject(pipe, obj);
|
||||
|
||||
#if 0
|
||||
// This is bogus. We may want to fade something, but not fade it out entirely.
|
||||
if( !(fFlags & (kCullsBefore | kCullsBeyond | kIdleBefore | kIdleBeyond)) )
|
||||
return true;
|
||||
#endif
|
||||
|
||||
plDrawable* refObj = fFlags & kObjectRefs ? GetObjectRef(0) : nil;
|
||||
if( !refObj )
|
||||
refObj = obj;
|
||||
|
||||
return ISetOpac(refObj);
|
||||
}
|
||||
|
||||
hsBool32 hsSfxObjDistFade::BeginTree(plPipeline* pipe, plDrawable* obj)
|
||||
{
|
||||
if( !Inclusive() )
|
||||
return true;
|
||||
|
||||
if( fTreeCnt++ )
|
||||
return true;
|
||||
|
||||
hsGRenderProcs::BeginTree(pipe, obj);
|
||||
|
||||
plDrawable* refObj = fFlags & kObjectRefs ? GetObjectRef(0) : nil;
|
||||
if( !refObj )
|
||||
refObj = obj;
|
||||
|
||||
return ISetOpac(refObj);
|
||||
}
|
||||
|
||||
void hsSfxObjDistFade::EndObject()
|
||||
{
|
||||
if( !Inclusive() )
|
||||
{
|
||||
fPipeline->PopMaterialOverride(fRestoreOver, true);
|
||||
}
|
||||
hsGRenderProcs::EndObject();
|
||||
}
|
||||
|
||||
void hsSfxObjDistFade::EndTree()
|
||||
{
|
||||
if( Inclusive() )
|
||||
{
|
||||
fPipeline->PopMaterialOverride(fRestoreOver, true);
|
||||
|
||||
fTreeCnt--;
|
||||
hsAssert(fTreeCnt >= 0, "Push/Pop tree problem");
|
||||
}
|
||||
hsGRenderProcs::EndTree();
|
||||
}
|
||||
|
||||
void hsSfxObjDistFade::MakeTable(float* distList, float* opacList, int num)
|
||||
{
|
||||
fTable.Reset();
|
||||
if( !num )
|
||||
return;
|
||||
|
||||
int i;
|
||||
for( i = 0; i < num; i++ )
|
||||
{
|
||||
hsSfxDfTableEntry* t = fTable.Append();
|
||||
t->fDistDel = distList[i];
|
||||
t->fOpacity = opacList[i];
|
||||
}
|
||||
for( i = num-1; i > 0; i-- )
|
||||
fTable[i].fDistDel -= fTable[i-1].fDistDel;
|
||||
for( i = 0; i < num-1; i++ )
|
||||
fTable[i].fDistNorm = hsScalarInvert(fTable[i+1].fDistDel);
|
||||
fTable[num-1].fDistNorm = 0;
|
||||
hsAssert(fTable.GetCount() == num, "Mismatch making table");
|
||||
|
||||
if( fTable[0].fOpacity <= 0 )
|
||||
fFlags |= kCullsBefore;
|
||||
if( fTable[num-1].fOpacity <= 0 )
|
||||
fFlags |= kCullsBeyond;
|
||||
if( fTable[0].fOpacity >= 1.f )
|
||||
fFlags |= kIdleBefore;
|
||||
if( fTable[num-1].fOpacity >= 1.f )
|
||||
fFlags |= kIdleBeyond;
|
||||
|
||||
int iMin;
|
||||
for( iMin = 0; (iMin < fTable.GetCount())&&(fTable[iMin].fOpacity <= 0); iMin++ );
|
||||
fMinDist = fTable[0].fDistDel;
|
||||
for( i = 1; i < iMin; i++ )
|
||||
fMinDist += fTable[i].fDistDel;
|
||||
|
||||
for( iMin = 0; (iMin < fTable.GetCount())&&(fTable[iMin].fOpacity >= 1.f); iMin++ );
|
||||
fMinIdle = fTable[0].fDistDel;
|
||||
for( i = 1; i < iMin; i++ )
|
||||
fMinIdle += fTable[i].fDistDel;
|
||||
|
||||
int iMax;
|
||||
for( iMax = fTable.GetCount()-1; (iMax >= 0)&&(fTable[iMax].fOpacity <= 0); iMax-- );
|
||||
if( ++iMax >= fTable.GetCount() )
|
||||
iMax = fTable.GetCount()-1;
|
||||
fMaxDist = fTable[0].fDistDel;
|
||||
for( i = 1; i <= iMax; i++ )
|
||||
fMaxDist += fTable[i].fDistDel;
|
||||
|
||||
for( iMax = fTable.GetCount()-1; (iMax >= 0)&&(fTable[iMax].fOpacity >= 1.f); iMax-- );
|
||||
if( ++iMax >= fTable.GetCount() )
|
||||
iMax = fTable.GetCount()-1;
|
||||
fMaxIdle = fTable[0].fDistDel;
|
||||
for( i = 1; i <= iMax; i++ )
|
||||
fMaxIdle += fTable[i].fDistDel;
|
||||
}
|
||||
|
||||
void hsSfxObjDistFade::Read(hsStream* s)
|
||||
{
|
||||
fTable.Reset();
|
||||
|
||||
fMinDist = s->ReadSwapScalar();
|
||||
fMaxDist = s->ReadSwapScalar();
|
||||
|
||||
if( fFlags & (kIdleBefore | kIdleBeyond) )
|
||||
{
|
||||
fMinIdle = s->ReadSwapScalar();
|
||||
fMaxIdle = s->ReadSwapScalar();
|
||||
}
|
||||
|
||||
Int32 cnt = s->ReadSwap32();
|
||||
|
||||
if( cnt )
|
||||
{
|
||||
hsSfxDfTableEntry* arr = new hsSfxDfTableEntry[cnt];
|
||||
int i;
|
||||
for( i = 0; i < cnt; i++ )
|
||||
{
|
||||
arr[i].fDistDel = s->ReadSwapScalar();
|
||||
arr[i].fDistNorm = s->ReadSwapScalar();
|
||||
arr[i].fOpacity = s->ReadSwapScalar();
|
||||
}
|
||||
|
||||
fTable.SetArray(arr, cnt);
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxObjDistFade::Write(hsStream* s)
|
||||
{
|
||||
s->WriteSwapScalar(fMinDist);
|
||||
s->WriteSwapScalar(fMaxDist);
|
||||
|
||||
if( fFlags & (kIdleBefore | kIdleBeyond) )
|
||||
{
|
||||
s->WriteSwapScalar(fMinIdle);
|
||||
s->WriteSwapScalar(fMaxIdle);
|
||||
}
|
||||
|
||||
s->WriteSwap32(fTable.GetCount());
|
||||
|
||||
for( fTable.First(); fTable.More(); fTable.Plus() )
|
||||
{
|
||||
s->WriteSwapScalar(fTable.Current().fDistDel);
|
||||
s->WriteSwapScalar(fTable.Current().fDistNorm);
|
||||
s->WriteSwapScalar(fTable.Current().fOpacity);
|
||||
}
|
||||
}
|
||||
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsMemory.h"
|
||||
#include "hsSfxObjDistFade.h"
|
||||
#include "hsStream.h"
|
||||
//#include "hsG3DDevice.h"
|
||||
#include "../plPipeline/plPipeline.h"
|
||||
#include "../plGeometry/hsTriangle3.h"
|
||||
|
||||
#include "../plIntersect/hsBounds.h"
|
||||
#include "../plDrawable/plDrawable.h"
|
||||
|
||||
static hsScalar globalScale = 1.f;
|
||||
|
||||
hsSfxObjDistFade::hsSfxObjDistFade()
|
||||
: fMinDist(0), fMaxDist(0), fTreeCnt(0)
|
||||
{
|
||||
}
|
||||
|
||||
hsSfxObjDistFade::~hsSfxObjDistFade()
|
||||
{
|
||||
}
|
||||
|
||||
hsScalar hsSfxObjDistFade::IOpacFromDist(hsScalar dist)
|
||||
{
|
||||
if( dist <= fTable[0].fDistDel )
|
||||
return fTable[0].fOpacity;
|
||||
|
||||
int i;
|
||||
for( i = 0; (i < fTable.GetCount()) && (dist >= fTable[i].fDistDel); i++ )
|
||||
dist -= fTable[i].fDistDel;
|
||||
|
||||
if( i >= fTable.GetCount() )
|
||||
return fTable[fTable.GetCount()-1].fOpacity;
|
||||
|
||||
dist *= fTable[i-1].fDistNorm;
|
||||
hsScalar opac0 = fTable[i-1].fOpacity;
|
||||
hsScalar opac1 = fTable[i].fOpacity;
|
||||
|
||||
return opac0 + dist * (opac1 - opac0);
|
||||
}
|
||||
|
||||
hsBool32 hsSfxObjDistFade::ISetOpac(plDrawable* refObj)
|
||||
{
|
||||
hsPoint3 refPos;
|
||||
if( fFlags & kByBoundsCenter )
|
||||
{
|
||||
const hsBounds3Ext& bnd = refObj->GetWorldBounds();
|
||||
if( kBoundsNormal != bnd.GetType() )
|
||||
return true;
|
||||
refPos = bnd.GetCenter();
|
||||
}
|
||||
else
|
||||
{
|
||||
refObj->GetLocalToWorld().GetTranslate(&refPos);
|
||||
}
|
||||
|
||||
fFlags &= ~(kCulled | kNOP);
|
||||
|
||||
hsPoint3 vPos;
|
||||
if( GetObjectRef(1) )
|
||||
{
|
||||
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&vPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
vPos = fPipeline->GetViewPositionWorld();
|
||||
}
|
||||
|
||||
hsScalar dist = hsVector3(&vPos, &refPos).Magnitude();
|
||||
|
||||
if( (fFlags & kCullsBefore)
|
||||
&&(dist <= fMinDist) )
|
||||
{
|
||||
fFlags |= kCulled;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( (fFlags & kCullsBeyond)
|
||||
&&(dist > fMaxDist) )
|
||||
{
|
||||
fFlags |= kCulled;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( (fFlags & kIdleBefore)
|
||||
&&(dist < fMinIdle) )
|
||||
fFlags |= kNOP;
|
||||
else
|
||||
if( (fFlags & kIdleBeyond)
|
||||
&&(dist > fMaxIdle) )
|
||||
fFlags |= kNOP;
|
||||
else
|
||||
{
|
||||
hsScalar opac = IOpacFromDist(dist);
|
||||
hsColorRGBA col = fColorizer.GetCurrentColor();
|
||||
if( fColorizer.Alpharizing() )
|
||||
col.a *= opac;
|
||||
else
|
||||
col.a = opac;
|
||||
fColorizer.PushColorize(col, fColorizer.Colorizing());
|
||||
|
||||
if( fFlags & kNoZTrans )
|
||||
{
|
||||
if( !(fPipeline->GetMaterialOverrideOff(hsGMatState::kZ) & hsGMatState::kZNoZWrite) )
|
||||
{
|
||||
fRestoreOver = fPipeline->PushMaterialOverride(hsGMatState::kZ, hsGMatState::kZNoZWrite, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
hsBool32 hsSfxObjDistFade::BeginObject(plPipeline* pipe, plDrawable* obj)
|
||||
{
|
||||
if( Inclusive() )
|
||||
return true;
|
||||
|
||||
hsGRenderProcs::BeginObject(pipe, obj);
|
||||
|
||||
#if 0
|
||||
// This is bogus. We may want to fade something, but not fade it out entirely.
|
||||
if( !(fFlags & (kCullsBefore | kCullsBeyond | kIdleBefore | kIdleBeyond)) )
|
||||
return true;
|
||||
#endif
|
||||
|
||||
plDrawable* refObj = fFlags & kObjectRefs ? GetObjectRef(0) : nil;
|
||||
if( !refObj )
|
||||
refObj = obj;
|
||||
|
||||
return ISetOpac(refObj);
|
||||
}
|
||||
|
||||
hsBool32 hsSfxObjDistFade::BeginTree(plPipeline* pipe, plDrawable* obj)
|
||||
{
|
||||
if( !Inclusive() )
|
||||
return true;
|
||||
|
||||
if( fTreeCnt++ )
|
||||
return true;
|
||||
|
||||
hsGRenderProcs::BeginTree(pipe, obj);
|
||||
|
||||
plDrawable* refObj = fFlags & kObjectRefs ? GetObjectRef(0) : nil;
|
||||
if( !refObj )
|
||||
refObj = obj;
|
||||
|
||||
return ISetOpac(refObj);
|
||||
}
|
||||
|
||||
void hsSfxObjDistFade::EndObject()
|
||||
{
|
||||
if( !Inclusive() )
|
||||
{
|
||||
fPipeline->PopMaterialOverride(fRestoreOver, true);
|
||||
}
|
||||
hsGRenderProcs::EndObject();
|
||||
}
|
||||
|
||||
void hsSfxObjDistFade::EndTree()
|
||||
{
|
||||
if( Inclusive() )
|
||||
{
|
||||
fPipeline->PopMaterialOverride(fRestoreOver, true);
|
||||
|
||||
fTreeCnt--;
|
||||
hsAssert(fTreeCnt >= 0, "Push/Pop tree problem");
|
||||
}
|
||||
hsGRenderProcs::EndTree();
|
||||
}
|
||||
|
||||
void hsSfxObjDistFade::MakeTable(float* distList, float* opacList, int num)
|
||||
{
|
||||
fTable.Reset();
|
||||
if( !num )
|
||||
return;
|
||||
|
||||
int i;
|
||||
for( i = 0; i < num; i++ )
|
||||
{
|
||||
hsSfxDfTableEntry* t = fTable.Append();
|
||||
t->fDistDel = distList[i];
|
||||
t->fOpacity = opacList[i];
|
||||
}
|
||||
for( i = num-1; i > 0; i-- )
|
||||
fTable[i].fDistDel -= fTable[i-1].fDistDel;
|
||||
for( i = 0; i < num-1; i++ )
|
||||
fTable[i].fDistNorm = hsScalarInvert(fTable[i+1].fDistDel);
|
||||
fTable[num-1].fDistNorm = 0;
|
||||
hsAssert(fTable.GetCount() == num, "Mismatch making table");
|
||||
|
||||
if( fTable[0].fOpacity <= 0 )
|
||||
fFlags |= kCullsBefore;
|
||||
if( fTable[num-1].fOpacity <= 0 )
|
||||
fFlags |= kCullsBeyond;
|
||||
if( fTable[0].fOpacity >= 1.f )
|
||||
fFlags |= kIdleBefore;
|
||||
if( fTable[num-1].fOpacity >= 1.f )
|
||||
fFlags |= kIdleBeyond;
|
||||
|
||||
int iMin;
|
||||
for( iMin = 0; (iMin < fTable.GetCount())&&(fTable[iMin].fOpacity <= 0); iMin++ );
|
||||
fMinDist = fTable[0].fDistDel;
|
||||
for( i = 1; i < iMin; i++ )
|
||||
fMinDist += fTable[i].fDistDel;
|
||||
|
||||
for( iMin = 0; (iMin < fTable.GetCount())&&(fTable[iMin].fOpacity >= 1.f); iMin++ );
|
||||
fMinIdle = fTable[0].fDistDel;
|
||||
for( i = 1; i < iMin; i++ )
|
||||
fMinIdle += fTable[i].fDistDel;
|
||||
|
||||
int iMax;
|
||||
for( iMax = fTable.GetCount()-1; (iMax >= 0)&&(fTable[iMax].fOpacity <= 0); iMax-- );
|
||||
if( ++iMax >= fTable.GetCount() )
|
||||
iMax = fTable.GetCount()-1;
|
||||
fMaxDist = fTable[0].fDistDel;
|
||||
for( i = 1; i <= iMax; i++ )
|
||||
fMaxDist += fTable[i].fDistDel;
|
||||
|
||||
for( iMax = fTable.GetCount()-1; (iMax >= 0)&&(fTable[iMax].fOpacity >= 1.f); iMax-- );
|
||||
if( ++iMax >= fTable.GetCount() )
|
||||
iMax = fTable.GetCount()-1;
|
||||
fMaxIdle = fTable[0].fDistDel;
|
||||
for( i = 1; i <= iMax; i++ )
|
||||
fMaxIdle += fTable[i].fDistDel;
|
||||
}
|
||||
|
||||
void hsSfxObjDistFade::Read(hsStream* s)
|
||||
{
|
||||
fTable.Reset();
|
||||
|
||||
fMinDist = s->ReadSwapScalar();
|
||||
fMaxDist = s->ReadSwapScalar();
|
||||
|
||||
if( fFlags & (kIdleBefore | kIdleBeyond) )
|
||||
{
|
||||
fMinIdle = s->ReadSwapScalar();
|
||||
fMaxIdle = s->ReadSwapScalar();
|
||||
}
|
||||
|
||||
Int32 cnt = s->ReadSwap32();
|
||||
|
||||
if( cnt )
|
||||
{
|
||||
hsSfxDfTableEntry* arr = new hsSfxDfTableEntry[cnt];
|
||||
int i;
|
||||
for( i = 0; i < cnt; i++ )
|
||||
{
|
||||
arr[i].fDistDel = s->ReadSwapScalar();
|
||||
arr[i].fDistNorm = s->ReadSwapScalar();
|
||||
arr[i].fOpacity = s->ReadSwapScalar();
|
||||
}
|
||||
|
||||
fTable.SetArray(arr, cnt);
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxObjDistFade::Write(hsStream* s)
|
||||
{
|
||||
s->WriteSwapScalar(fMinDist);
|
||||
s->WriteSwapScalar(fMaxDist);
|
||||
|
||||
if( fFlags & (kIdleBefore | kIdleBeyond) )
|
||||
{
|
||||
s->WriteSwapScalar(fMinIdle);
|
||||
s->WriteSwapScalar(fMaxIdle);
|
||||
}
|
||||
|
||||
s->WriteSwap32(fTable.GetCount());
|
||||
|
||||
for( fTable.First(); fTable.More(); fTable.Plus() )
|
||||
{
|
||||
s->WriteSwapScalar(fTable.Current().fDistDel);
|
||||
s->WriteSwapScalar(fTable.Current().fDistNorm);
|
||||
s->WriteSwapScalar(fTable.Current().fOpacity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,100 +1,100 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef hsSfxObjDistFade_inc
|
||||
#define hsSfxObjDistFade_inc
|
||||
|
||||
#include "hsBiExpander.h"
|
||||
#include "hsGRenderProcs.h"
|
||||
#include "../plPipeline/hsGMatState.h"
|
||||
|
||||
class hsSfxObjDistFade : public hsGRenderProcs {
|
||||
public:
|
||||
enum {
|
||||
kCullsBefore = 0x10000,
|
||||
kCullsBeyond = 0x20000,
|
||||
|
||||
kDistFromView = 0x40000,
|
||||
kDistFromTarget = 0x80000,
|
||||
kDistAlongX = 0x100000,
|
||||
kZOff = 0x200000,
|
||||
kNoZTrans = 0x400000,
|
||||
kByBoundsCenter = 0x800000,
|
||||
|
||||
kPostInterp = 0x1000000,
|
||||
|
||||
kIdleBefore = 0x2000000,
|
||||
kIdleBeyond = 0x4000000,
|
||||
|
||||
kZWasOff = 0x8000000
|
||||
};
|
||||
|
||||
struct hsSfxDfTableEntry {
|
||||
hsScalar fDistDel;
|
||||
hsScalar fDistNorm;
|
||||
hsScalar fOpacity;
|
||||
};
|
||||
protected:
|
||||
|
||||
hsScalar fMinDist;
|
||||
hsScalar fMaxDist;
|
||||
|
||||
hsScalar fMinIdle;
|
||||
hsScalar fMaxIdle;
|
||||
|
||||
Int32 fTreeCnt;
|
||||
|
||||
hsExpander<hsSfxDfTableEntry> fTable;
|
||||
|
||||
hsGMatState fRestoreOver;
|
||||
|
||||
hsBool32 ISetOpac(plDrawable* refObj);
|
||||
hsScalar IOpacFromDist(hsScalar dist);
|
||||
public:
|
||||
hsSfxObjDistFade();
|
||||
virtual ~hsSfxObjDistFade();
|
||||
|
||||
virtual hsBool32 BeginTree(plPipeline* pipe, plDrawable* root);
|
||||
virtual hsBool32 BeginObject(plPipeline* pipe, plDrawable* obj);
|
||||
|
||||
virtual void EndObject();
|
||||
virtual void EndTree();
|
||||
|
||||
void MakeTable(float* distList, float* opacList, int num); // lists sorted from lowest cosine to highest
|
||||
|
||||
virtual void Read(hsStream* s);
|
||||
virtual void Write(hsStream* s);
|
||||
|
||||
virtual const char* GetLabel() const { return "hsSfxObjDistFade"; }
|
||||
|
||||
virtual ProcType GetType() const { return kTypeObjDistFade; }
|
||||
|
||||
CLASSNAME_REGISTER( hsSfxObjDistFade );
|
||||
GETINTERFACE_ANY( hsSfxObjDistFade, hsGRenderProcs );
|
||||
|
||||
};
|
||||
|
||||
#endif // hsSfxObjDistFade_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef hsSfxObjDistFade_inc
|
||||
#define hsSfxObjDistFade_inc
|
||||
|
||||
#include "hsBiExpander.h"
|
||||
#include "hsGRenderProcs.h"
|
||||
#include "../plPipeline/hsGMatState.h"
|
||||
|
||||
class hsSfxObjDistFade : public hsGRenderProcs {
|
||||
public:
|
||||
enum {
|
||||
kCullsBefore = 0x10000,
|
||||
kCullsBeyond = 0x20000,
|
||||
|
||||
kDistFromView = 0x40000,
|
||||
kDistFromTarget = 0x80000,
|
||||
kDistAlongX = 0x100000,
|
||||
kZOff = 0x200000,
|
||||
kNoZTrans = 0x400000,
|
||||
kByBoundsCenter = 0x800000,
|
||||
|
||||
kPostInterp = 0x1000000,
|
||||
|
||||
kIdleBefore = 0x2000000,
|
||||
kIdleBeyond = 0x4000000,
|
||||
|
||||
kZWasOff = 0x8000000
|
||||
};
|
||||
|
||||
struct hsSfxDfTableEntry {
|
||||
hsScalar fDistDel;
|
||||
hsScalar fDistNorm;
|
||||
hsScalar fOpacity;
|
||||
};
|
||||
protected:
|
||||
|
||||
hsScalar fMinDist;
|
||||
hsScalar fMaxDist;
|
||||
|
||||
hsScalar fMinIdle;
|
||||
hsScalar fMaxIdle;
|
||||
|
||||
Int32 fTreeCnt;
|
||||
|
||||
hsExpander<hsSfxDfTableEntry> fTable;
|
||||
|
||||
hsGMatState fRestoreOver;
|
||||
|
||||
hsBool32 ISetOpac(plDrawable* refObj);
|
||||
hsScalar IOpacFromDist(hsScalar dist);
|
||||
public:
|
||||
hsSfxObjDistFade();
|
||||
virtual ~hsSfxObjDistFade();
|
||||
|
||||
virtual hsBool32 BeginTree(plPipeline* pipe, plDrawable* root);
|
||||
virtual hsBool32 BeginObject(plPipeline* pipe, plDrawable* obj);
|
||||
|
||||
virtual void EndObject();
|
||||
virtual void EndTree();
|
||||
|
||||
void MakeTable(float* distList, float* opacList, int num); // lists sorted from lowest cosine to highest
|
||||
|
||||
virtual void Read(hsStream* s);
|
||||
virtual void Write(hsStream* s);
|
||||
|
||||
virtual const char* GetLabel() const { return "hsSfxObjDistFade"; }
|
||||
|
||||
virtual ProcType GetType() const { return kTypeObjDistFade; }
|
||||
|
||||
CLASSNAME_REGISTER( hsSfxObjDistFade );
|
||||
GETINTERFACE_ANY( hsSfxObjDistFade, hsGRenderProcs );
|
||||
|
||||
};
|
||||
|
||||
#endif // hsSfxObjDistFade_inc
|
||||
|
@ -1,201 +1,201 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsMemory.h"
|
||||
#include "hsSfxObjDistShade.h"
|
||||
#include "hsStream.h"
|
||||
#include "../plPipeline/plPipeline.h"
|
||||
#include "../plGeometry/hsTriangle3.h"
|
||||
|
||||
#include "../plIntersect/hsBounds.h"
|
||||
#include "../plDrawable/plDrawable.h"
|
||||
|
||||
static hsScalar globalScale = 1.f;
|
||||
|
||||
hsSfxObjDistShade::hsSfxObjDistShade()
|
||||
: fMinDist(0), fMaxDist(0), fTreeCnt(0)
|
||||
{
|
||||
}
|
||||
|
||||
hsSfxObjDistShade::~hsSfxObjDistShade()
|
||||
{
|
||||
}
|
||||
|
||||
hsScalar hsSfxObjDistShade::IShadeFromDist(hsScalar dist)
|
||||
{
|
||||
if( dist <= fTable[0].fDistDel )
|
||||
return fTable[0].fShade;
|
||||
|
||||
int i;
|
||||
for( i = 0; (i < fTable.GetCount()) && (dist >= fTable[i].fDistDel); i++ )
|
||||
dist -= fTable[i].fDistDel;
|
||||
|
||||
if( i >= fTable.GetCount() )
|
||||
return fTable[fTable.GetCount()-1].fShade;
|
||||
|
||||
dist *= fTable[i-1].fDistNorm;
|
||||
hsScalar shade0 = fTable[i-1].fShade;
|
||||
hsScalar shade1 = fTable[i].fShade;
|
||||
|
||||
return shade0 + dist * (shade1 - shade0);
|
||||
}
|
||||
|
||||
hsBool32 hsSfxObjDistShade::ISetShade(plDrawable* refObj)
|
||||
{
|
||||
hsPoint3 refPos;
|
||||
if( fFlags & kByBoundsCenter )
|
||||
{
|
||||
const hsBounds3Ext& bnd = refObj->GetWorldBounds();
|
||||
if( kBoundsNormal != bnd.GetType() )
|
||||
return true;
|
||||
refPos = bnd.GetCenter();
|
||||
}
|
||||
else
|
||||
{
|
||||
refObj->GetLocalToWorld().GetTranslate(&refPos);
|
||||
}
|
||||
|
||||
hsPoint3 vPos;
|
||||
if( GetObjectRef(1) )
|
||||
{
|
||||
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&vPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
vPos = fPipeline->GetViewPositionWorld();
|
||||
}
|
||||
|
||||
hsScalar dist = hsVector3(&vPos, &refPos).Magnitude();
|
||||
|
||||
hsScalar shade = IShadeFromDist(dist);
|
||||
|
||||
hsColorRGBA col = fColorizer.GetCurrentColor();
|
||||
if( fColorizer.Colorizing() )
|
||||
{
|
||||
col.r *= shade;
|
||||
col.g *= shade;
|
||||
col.b *= shade;
|
||||
}
|
||||
else
|
||||
{
|
||||
col.r = shade;
|
||||
col.g = shade;
|
||||
col.b = shade;
|
||||
}
|
||||
fColorizer.PushColorize(col, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
hsBool32 hsSfxObjDistShade::BeginObject(plPipeline* pipe, plDrawable* obj)
|
||||
{
|
||||
hsGRenderProcs::BeginObject(pipe, obj);
|
||||
|
||||
plDrawable* refObj = fFlags & kObjectRefs ? GetObjectRef(0) : nil;
|
||||
if( !refObj )
|
||||
refObj = obj;
|
||||
|
||||
return ISetShade(refObj);
|
||||
}
|
||||
|
||||
void hsSfxObjDistShade::MakeTable(float* distList, float* shadeList, int num)
|
||||
{
|
||||
fTable.Reset();
|
||||
if( !num )
|
||||
return;
|
||||
|
||||
int i;
|
||||
for( i = 0; i < num; i++ )
|
||||
{
|
||||
hsSfxDfTableEntry* t = fTable.Append();
|
||||
t->fDistDel = distList[i];
|
||||
t->fShade = shadeList[i];
|
||||
}
|
||||
for( i = num-1; i > 0; i-- )
|
||||
fTable[i].fDistDel -= fTable[i-1].fDistDel;
|
||||
for( i = 0; i < num-1; i++ )
|
||||
fTable[i].fDistNorm = hsScalarInvert(fTable[i+1].fDistDel);
|
||||
fTable[num-1].fDistNorm = 0;
|
||||
hsAssert(fTable.GetCount() == num, "Mismatch making table");
|
||||
|
||||
int iMin;
|
||||
for( iMin = 0; (iMin < fTable.GetCount())&&(fTable[iMin].fShade <= 0); iMin++ );
|
||||
fMinDist = fTable[0].fDistDel;
|
||||
for( i = 1; i < iMin; i++ )
|
||||
fMinDist += fTable[i].fDistDel;
|
||||
|
||||
int iMax;
|
||||
for( iMax = fTable.GetCount()-1; (iMax >= 0)&&(fTable[iMax].fShade <= 0); iMax-- );
|
||||
if( ++iMax >= fTable.GetCount() )
|
||||
iMax = fTable.GetCount()-1;
|
||||
fMaxDist = fTable[0].fDistDel;
|
||||
for( i = 1; i <= iMax; i++ )
|
||||
fMaxDist += fTable[i].fDistDel;
|
||||
|
||||
}
|
||||
|
||||
void hsSfxObjDistShade::Read(hsStream* s)
|
||||
{
|
||||
fTable.Reset();
|
||||
|
||||
fMinDist = s->ReadSwapScalar();
|
||||
fMaxDist = s->ReadSwapScalar();
|
||||
|
||||
Int32 cnt = s->ReadSwap32();
|
||||
|
||||
if( cnt )
|
||||
{
|
||||
hsSfxDfTableEntry* arr = new hsSfxDfTableEntry[cnt];
|
||||
int i;
|
||||
for( i = 0; i < cnt; i++ )
|
||||
{
|
||||
arr[i].fDistDel = s->ReadSwapScalar();
|
||||
arr[i].fDistNorm = s->ReadSwapScalar();
|
||||
arr[i].fShade = s->ReadSwapScalar();
|
||||
}
|
||||
|
||||
fTable.SetArray(arr, cnt);
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxObjDistShade::Write(hsStream* s)
|
||||
{
|
||||
s->WriteSwapScalar(fMinDist);
|
||||
s->WriteSwapScalar(fMaxDist);
|
||||
|
||||
s->WriteSwap32(fTable.GetCount());
|
||||
|
||||
for( fTable.First(); fTable.More(); fTable.Plus() )
|
||||
{
|
||||
s->WriteSwapScalar(fTable.Current().fDistDel);
|
||||
s->WriteSwapScalar(fTable.Current().fDistNorm);
|
||||
s->WriteSwapScalar(fTable.Current().fShade);
|
||||
}
|
||||
}
|
||||
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsMemory.h"
|
||||
#include "hsSfxObjDistShade.h"
|
||||
#include "hsStream.h"
|
||||
#include "../plPipeline/plPipeline.h"
|
||||
#include "../plGeometry/hsTriangle3.h"
|
||||
|
||||
#include "../plIntersect/hsBounds.h"
|
||||
#include "../plDrawable/plDrawable.h"
|
||||
|
||||
static hsScalar globalScale = 1.f;
|
||||
|
||||
hsSfxObjDistShade::hsSfxObjDistShade()
|
||||
: fMinDist(0), fMaxDist(0), fTreeCnt(0)
|
||||
{
|
||||
}
|
||||
|
||||
hsSfxObjDistShade::~hsSfxObjDistShade()
|
||||
{
|
||||
}
|
||||
|
||||
hsScalar hsSfxObjDistShade::IShadeFromDist(hsScalar dist)
|
||||
{
|
||||
if( dist <= fTable[0].fDistDel )
|
||||
return fTable[0].fShade;
|
||||
|
||||
int i;
|
||||
for( i = 0; (i < fTable.GetCount()) && (dist >= fTable[i].fDistDel); i++ )
|
||||
dist -= fTable[i].fDistDel;
|
||||
|
||||
if( i >= fTable.GetCount() )
|
||||
return fTable[fTable.GetCount()-1].fShade;
|
||||
|
||||
dist *= fTable[i-1].fDistNorm;
|
||||
hsScalar shade0 = fTable[i-1].fShade;
|
||||
hsScalar shade1 = fTable[i].fShade;
|
||||
|
||||
return shade0 + dist * (shade1 - shade0);
|
||||
}
|
||||
|
||||
hsBool32 hsSfxObjDistShade::ISetShade(plDrawable* refObj)
|
||||
{
|
||||
hsPoint3 refPos;
|
||||
if( fFlags & kByBoundsCenter )
|
||||
{
|
||||
const hsBounds3Ext& bnd = refObj->GetWorldBounds();
|
||||
if( kBoundsNormal != bnd.GetType() )
|
||||
return true;
|
||||
refPos = bnd.GetCenter();
|
||||
}
|
||||
else
|
||||
{
|
||||
refObj->GetLocalToWorld().GetTranslate(&refPos);
|
||||
}
|
||||
|
||||
hsPoint3 vPos;
|
||||
if( GetObjectRef(1) )
|
||||
{
|
||||
GetObjectRef(1)->GetLocalToWorld().GetTranslate(&vPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
vPos = fPipeline->GetViewPositionWorld();
|
||||
}
|
||||
|
||||
hsScalar dist = hsVector3(&vPos, &refPos).Magnitude();
|
||||
|
||||
hsScalar shade = IShadeFromDist(dist);
|
||||
|
||||
hsColorRGBA col = fColorizer.GetCurrentColor();
|
||||
if( fColorizer.Colorizing() )
|
||||
{
|
||||
col.r *= shade;
|
||||
col.g *= shade;
|
||||
col.b *= shade;
|
||||
}
|
||||
else
|
||||
{
|
||||
col.r = shade;
|
||||
col.g = shade;
|
||||
col.b = shade;
|
||||
}
|
||||
fColorizer.PushColorize(col, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
hsBool32 hsSfxObjDistShade::BeginObject(plPipeline* pipe, plDrawable* obj)
|
||||
{
|
||||
hsGRenderProcs::BeginObject(pipe, obj);
|
||||
|
||||
plDrawable* refObj = fFlags & kObjectRefs ? GetObjectRef(0) : nil;
|
||||
if( !refObj )
|
||||
refObj = obj;
|
||||
|
||||
return ISetShade(refObj);
|
||||
}
|
||||
|
||||
void hsSfxObjDistShade::MakeTable(float* distList, float* shadeList, int num)
|
||||
{
|
||||
fTable.Reset();
|
||||
if( !num )
|
||||
return;
|
||||
|
||||
int i;
|
||||
for( i = 0; i < num; i++ )
|
||||
{
|
||||
hsSfxDfTableEntry* t = fTable.Append();
|
||||
t->fDistDel = distList[i];
|
||||
t->fShade = shadeList[i];
|
||||
}
|
||||
for( i = num-1; i > 0; i-- )
|
||||
fTable[i].fDistDel -= fTable[i-1].fDistDel;
|
||||
for( i = 0; i < num-1; i++ )
|
||||
fTable[i].fDistNorm = hsScalarInvert(fTable[i+1].fDistDel);
|
||||
fTable[num-1].fDistNorm = 0;
|
||||
hsAssert(fTable.GetCount() == num, "Mismatch making table");
|
||||
|
||||
int iMin;
|
||||
for( iMin = 0; (iMin < fTable.GetCount())&&(fTable[iMin].fShade <= 0); iMin++ );
|
||||
fMinDist = fTable[0].fDistDel;
|
||||
for( i = 1; i < iMin; i++ )
|
||||
fMinDist += fTable[i].fDistDel;
|
||||
|
||||
int iMax;
|
||||
for( iMax = fTable.GetCount()-1; (iMax >= 0)&&(fTable[iMax].fShade <= 0); iMax-- );
|
||||
if( ++iMax >= fTable.GetCount() )
|
||||
iMax = fTable.GetCount()-1;
|
||||
fMaxDist = fTable[0].fDistDel;
|
||||
for( i = 1; i <= iMax; i++ )
|
||||
fMaxDist += fTable[i].fDistDel;
|
||||
|
||||
}
|
||||
|
||||
void hsSfxObjDistShade::Read(hsStream* s)
|
||||
{
|
||||
fTable.Reset();
|
||||
|
||||
fMinDist = s->ReadSwapScalar();
|
||||
fMaxDist = s->ReadSwapScalar();
|
||||
|
||||
Int32 cnt = s->ReadSwap32();
|
||||
|
||||
if( cnt )
|
||||
{
|
||||
hsSfxDfTableEntry* arr = new hsSfxDfTableEntry[cnt];
|
||||
int i;
|
||||
for( i = 0; i < cnt; i++ )
|
||||
{
|
||||
arr[i].fDistDel = s->ReadSwapScalar();
|
||||
arr[i].fDistNorm = s->ReadSwapScalar();
|
||||
arr[i].fShade = s->ReadSwapScalar();
|
||||
}
|
||||
|
||||
fTable.SetArray(arr, cnt);
|
||||
}
|
||||
}
|
||||
|
||||
void hsSfxObjDistShade::Write(hsStream* s)
|
||||
{
|
||||
s->WriteSwapScalar(fMinDist);
|
||||
s->WriteSwapScalar(fMaxDist);
|
||||
|
||||
s->WriteSwap32(fTable.GetCount());
|
||||
|
||||
for( fTable.First(); fTable.More(); fTable.Plus() )
|
||||
{
|
||||
s->WriteSwapScalar(fTable.Current().fDistDel);
|
||||
s->WriteSwapScalar(fTable.Current().fDistNorm);
|
||||
s->WriteSwapScalar(fTable.Current().fShade);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,82 +1,82 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef hsSfxObjDistShade_inc
|
||||
#define hsSfxObjDistShade_inc
|
||||
|
||||
#include "hsBiExpander.h"
|
||||
#include "hsGRenderProcs.h"
|
||||
|
||||
class hsSfxObjDistShade : public hsGRenderProcs {
|
||||
public:
|
||||
enum {
|
||||
kShadeConstant = 0x10000,
|
||||
kByBoundsCenter = 0x800000,
|
||||
|
||||
};
|
||||
|
||||
struct hsSfxDfTableEntry {
|
||||
hsScalar fDistDel;
|
||||
hsScalar fDistNorm;
|
||||
hsScalar fShade;
|
||||
};
|
||||
protected:
|
||||
|
||||
hsScalar fMinDist;
|
||||
hsScalar fMaxDist;
|
||||
|
||||
hsScalar fConstShade;
|
||||
|
||||
hsScalar fMinIdle;
|
||||
hsScalar fMaxIdle;
|
||||
|
||||
Int32 fTreeCnt;
|
||||
|
||||
hsExpander<hsSfxDfTableEntry> fTable;
|
||||
|
||||
hsBool32 ISetShade(plDrawable* refObj);
|
||||
hsScalar IShadeFromDist(hsScalar dist);
|
||||
public:
|
||||
hsSfxObjDistShade();
|
||||
virtual ~hsSfxObjDistShade();
|
||||
|
||||
virtual hsBool32 BeginObject(plPipeline* pipe, plDrawable* obj);
|
||||
|
||||
void MakeTable(float* distList, float* shadeList, int num); // lists sorted from lowest cosine to highest
|
||||
|
||||
virtual void Read(hsStream* s);
|
||||
virtual void Write(hsStream* s);
|
||||
|
||||
virtual const char* GetLabel() const { return "hsSfxObjDistShade"; }
|
||||
|
||||
virtual ProcType GetType() const { return kTypeObjDistShade; }
|
||||
|
||||
CLASSNAME_REGISTER( hsSfxObjDistShade );
|
||||
GETINTERFACE_ANY( hsSfxObjDistShade, hsGRenderProcs );
|
||||
|
||||
};
|
||||
|
||||
#endif // hsSfxObjDistShade_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef hsSfxObjDistShade_inc
|
||||
#define hsSfxObjDistShade_inc
|
||||
|
||||
#include "hsBiExpander.h"
|
||||
#include "hsGRenderProcs.h"
|
||||
|
||||
class hsSfxObjDistShade : public hsGRenderProcs {
|
||||
public:
|
||||
enum {
|
||||
kShadeConstant = 0x10000,
|
||||
kByBoundsCenter = 0x800000,
|
||||
|
||||
};
|
||||
|
||||
struct hsSfxDfTableEntry {
|
||||
hsScalar fDistDel;
|
||||
hsScalar fDistNorm;
|
||||
hsScalar fShade;
|
||||
};
|
||||
protected:
|
||||
|
||||
hsScalar fMinDist;
|
||||
hsScalar fMaxDist;
|
||||
|
||||
hsScalar fConstShade;
|
||||
|
||||
hsScalar fMinIdle;
|
||||
hsScalar fMaxIdle;
|
||||
|
||||
Int32 fTreeCnt;
|
||||
|
||||
hsExpander<hsSfxDfTableEntry> fTable;
|
||||
|
||||
hsBool32 ISetShade(plDrawable* refObj);
|
||||
hsScalar IShadeFromDist(hsScalar dist);
|
||||
public:
|
||||
hsSfxObjDistShade();
|
||||
virtual ~hsSfxObjDistShade();
|
||||
|
||||
virtual hsBool32 BeginObject(plPipeline* pipe, plDrawable* obj);
|
||||
|
||||
void MakeTable(float* distList, float* shadeList, int num); // lists sorted from lowest cosine to highest
|
||||
|
||||
virtual void Read(hsStream* s);
|
||||
virtual void Write(hsStream* s);
|
||||
|
||||
virtual const char* GetLabel() const { return "hsSfxObjDistShade"; }
|
||||
|
||||
virtual ProcType GetType() const { return kTypeObjDistShade; }
|
||||
|
||||
CLASSNAME_REGISTER( hsSfxObjDistShade );
|
||||
GETINTERFACE_ANY( hsSfxObjDistShade, hsGRenderProcs );
|
||||
|
||||
};
|
||||
|
||||
#endif // hsSfxObjDistShade_inc
|
||||
|
@ -1,64 +1,64 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef plGRenderProcsCreatable_inc
|
||||
#define plGRenderProcsCreatable_inc
|
||||
|
||||
#include "../plResMgr/plCreator.h"
|
||||
|
||||
#include "hsGRenderProcs.h"
|
||||
|
||||
REGISTER_NONCREATABLE( hsGRenderProcs );
|
||||
|
||||
#include "hsSfxAngleFade.h"
|
||||
|
||||
REGISTER_CREATABLE( hsSfxAngleFade );
|
||||
|
||||
#include "hsSfxDistFade.h"
|
||||
|
||||
REGISTER_CREATABLE( hsSfxDistFade );
|
||||
|
||||
#include "hsSfxDistShade.h"
|
||||
|
||||
REGISTER_CREATABLE( hsSfxDistShade );
|
||||
|
||||
#include "hsSfxGlobalShade.h"
|
||||
|
||||
REGISTER_CREATABLE( hsSfxGlobalShade );
|
||||
|
||||
#include "hsSfxIntenseAlpha.h"
|
||||
|
||||
REGISTER_CREATABLE( hsSfxIntenseAlpha );
|
||||
|
||||
#include "hsSfxObjDistFade.h"
|
||||
|
||||
REGISTER_CREATABLE( hsSfxObjDistFade );
|
||||
|
||||
#include "hsSfxObjDistShade.h"
|
||||
|
||||
REGISTER_CREATABLE( hsSfxObjDistShade );
|
||||
|
||||
#endif // plGRenderProcsCreatable_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef plGRenderProcsCreatable_inc
|
||||
#define plGRenderProcsCreatable_inc
|
||||
|
||||
#include "../plResMgr/plCreator.h"
|
||||
|
||||
#include "hsGRenderProcs.h"
|
||||
|
||||
REGISTER_NONCREATABLE( hsGRenderProcs );
|
||||
|
||||
#include "hsSfxAngleFade.h"
|
||||
|
||||
REGISTER_CREATABLE( hsSfxAngleFade );
|
||||
|
||||
#include "hsSfxDistFade.h"
|
||||
|
||||
REGISTER_CREATABLE( hsSfxDistFade );
|
||||
|
||||
#include "hsSfxDistShade.h"
|
||||
|
||||
REGISTER_CREATABLE( hsSfxDistShade );
|
||||
|
||||
#include "hsSfxGlobalShade.h"
|
||||
|
||||
REGISTER_CREATABLE( hsSfxGlobalShade );
|
||||
|
||||
#include "hsSfxIntenseAlpha.h"
|
||||
|
||||
REGISTER_CREATABLE( hsSfxIntenseAlpha );
|
||||
|
||||
#include "hsSfxObjDistFade.h"
|
||||
|
||||
REGISTER_CREATABLE( hsSfxObjDistFade );
|
||||
|
||||
#include "hsSfxObjDistShade.h"
|
||||
|
||||
REGISTER_CREATABLE( hsSfxObjDistShade );
|
||||
|
||||
#endif // plGRenderProcsCreatable_inc
|
||||
|
Reference in New Issue
Block a user