2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 02:27:40 -04:00

Initial Commit of CyanWorlds.com Engine Open Source Client/Plugin

This commit is contained in:
JWPlatt
2011-03-12 12:34:52 -05:00
commit a20a222fc2
3976 changed files with 1301356 additions and 0 deletions

View File

@ -0,0 +1,56 @@
/*==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 pfSurfaceCreatable_inc
#define pfSurfaceCreatable_inc
#include "../pnFactory/plCreator.h"
#include "plLayerMovie.h"
REGISTER_NONCREATABLE( plLayerMovie );
#include "plLayerBink.h"
REGISTER_CREATABLE( plLayerBink );
#include "plLayerAVI.h"
REGISTER_CREATABLE( plLayerAVI );
#include "plFadeOpacityLay.h"
REGISTER_CREATABLE( plFadeOpacityLay );
#include "plFadeOpacityMod.h"
REGISTER_CREATABLE( plFadeOpacityMod );
#include "plDistOpacityMod.h"
REGISTER_CREATABLE( plDistOpacityMod );
#endif // pfSurfaceCreatable_inc

View File

@ -0,0 +1,296 @@
/*==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 "plDistOpacityMod.h"
#include "plFadeOpacityLay.h"
#include "../plSurface/hsGMaterial.h"
#include "../plDrawable/plAccessGeometry.h"
#include "../plDrawable/plAccessSpan.h"
#include "../plMessage/plMatRefMsg.h"
// If we're tracking the camera
#include "../plMessage/plRenderMsg.h"
#include "plPipeline.h"
// If we're tracking the avater
#include "../plMessage/plAvatarMsg.h"
#include "../plAvatar/plArmatureMod.h"
#include "plgDispatch.h"
#include "hsResMgr.h"
#include "hsQuat.h"
plDistOpacityMod::plDistOpacityMod()
: fSetup(false)
{
fDists[kNearTrans] = 0;
fDists[kNearOpaq] = 0;
fDists[kFarOpaq] = 0;
fDists[kFarTrans] = 0;
fRefPos.Set(0, 0, 0);
}
plDistOpacityMod::~plDistOpacityMod()
{
}
void plDistOpacityMod::SetKey(plKey k)
{
plSingleModifier::SetKey(k);
plgDispatch::Dispatch()->RegisterForExactType(plRenderMsg::Index(), GetKey());
plgDispatch::Dispatch()->RegisterForExactType(plArmatureUpdateMsg::Index(), GetKey());
}
hsScalar plDistOpacityMod::ICalcOpacity(const hsPoint3& targPos, const hsPoint3& refPos) const
{
hsScalar dist = hsVector3(&targPos, &refPos).Magnitude();
if( dist > fDists[kFarTrans] )
return 0;
if( dist < fDists[kNearTrans] )
return 0;
if( dist > fDists[kFarOpaq] )
{
dist -= fDists[kFarOpaq];
dist /= (fDists[kFarTrans] - fDists[kFarOpaq]);
hsAssert(dist >= 0, "unexpected interpolation param - neg");
hsAssert(dist <= 1.f, "unexpected interpolation param - > one");
return 1.f - dist;
}
if( dist < fDists[kNearOpaq] )
{
dist -= fDists[kNearTrans];
dist /= (fDists[kNearOpaq] - fDists[kNearTrans]);
hsAssert(dist >= 0, "unexpected interpolation param - neg");
hsAssert(dist <= 1.f, "unexpected interpolation param - > one");
return dist;
}
return 1.f;
}
void plDistOpacityMod::ISetOpacity()
{
if( !GetTarget() )
return;
if( !fSetup )
ISetup();
hsScalar opacity = ICalcOpacity(GetTarget()->GetLocalToWorld().GetTranslate(), fRefPos);
const int num = fFadeLays.GetCount();
int i;
for( i = 0; i < num; i++ )
fFadeLays[i]->SetOpacity(opacity);
}
hsBool plDistOpacityMod::MsgReceive(plMessage* msg)
{
plArmatureUpdateMsg* arm = plArmatureUpdateMsg::ConvertNoRef(msg);
if( arm && arm->IsLocal() )
{
arm->fArmature->GetPositionAndRotationSim(&fRefPos, nil);
return true;
}
plRenderMsg* rend = plRenderMsg::ConvertNoRef(msg);
if( rend )
{
if( HasFlag(kTrackCamera) )
fRefPos = rend->Pipeline()->GetViewPositionWorld();
ISetOpacity();
return true;
}
plGenRefMsg* ref = plGenRefMsg::ConvertNoRef(msg);
if( ref )
{
switch(ref->fType)
{
case kRefFadeLay:
if( ref->GetContext() & (plRefMsg::kOnDestroy|plRefMsg::kOnRemove) )
{
plFadeOpacityLay* lay = plFadeOpacityLay::ConvertNoRef(ref->GetRef());
int idx = fFadeLays.Find(lay);
if( idx != fFadeLays.kMissingIndex )
fFadeLays.Remove(idx);
}
break;
};
return true;
}
return plSingleModifier::MsgReceive(msg);
}
void plDistOpacityMod::Read(hsStream* s, hsResMgr* mgr)
{
plSingleModifier::Read(s, mgr);
int i;
for( i = 0; i < kNumDists; i++ )
fDists[i] = s->ReadSwapScalar();
ICheckDists();
fSetup = false;
}
void plDistOpacityMod::Write(hsStream* s, hsResMgr* mgr)
{
plSingleModifier::Write(s, mgr);
int i;
for( i = 0; i < kNumDists; i++ )
s->WriteSwapScalar(fDists[i]);
}
void plDistOpacityMod::SetTarget(plSceneObject* so)
{
plSingleModifier::SetTarget(so);
fSetup = false;
}
void plDistOpacityMod::SetFarDist(hsScalar opaque, hsScalar transparent)
{
fDists[kFarOpaq] = opaque;
fDists[kFarTrans] = transparent;
ICheckDists();
}
void plDistOpacityMod::SetNearDist(hsScalar transparent, hsScalar opaque)
{
fDists[kNearOpaq] = opaque;
fDists[kNearTrans] = transparent;
ICheckDists();
}
class MatLayer
{
public:
hsGMaterial* fMat;
plLayerInterface* fLay;
};
void plDistOpacityMod::ISetup()
{
fFadeLays.Reset();
plSceneObject* so = GetTarget();
if( !so )
return;
const plDrawInterface* di = so->GetDrawInterface();
if( !di )
return;
hsTArray<MatLayer> todo;
hsTArray<plAccessSpan> src;
plAccessGeometry::Instance()->OpenRO(di, src, false);
// We are guaranteed that each Max object will be given a unique
// copy of materials and associated layers. But within an object,
// a given layer may be shared across materials.
// So we'll build a list of the layers that need a FadeOpacityLay applied,
// making sure we don't include any layer more than once (strip repeats).
// This would be grossly inefficient if the numbers involved weren't all
// very small. So an n^2 search isn't bad if n <= 2.
int i;
for( i = 0; i < src.GetCount(); i++ )
{
hsGMaterial* mat = src[i].GetMaterial();
int j;
for( j = 0; j < mat->GetNumLayers(); j++ )
{
plLayerInterface* lay = mat->GetLayer(j);
if( !j || !(lay->GetZFlags() & hsGMatState::kZNoZWrite) || (lay->GetMiscFlags() & hsGMatState::kMiscRestartPassHere) )
{
int k;
for( k = 0; k < todo.GetCount(); k++ )
{
if( lay == todo[k].fLay )
break;
}
if( k == todo.GetCount() )
{
MatLayer* push = todo.Push();
push->fMat = mat;
push->fLay = lay;
}
}
}
}
plAccessGeometry::Instance()->Close(src);
for( i = 0; i < todo.GetCount(); i++ )
{
hsGMaterial* mat = todo[i].fMat;
plLayerInterface* lay = todo[i].fLay;
plFadeOpacityLay* fade = TRACKED_NEW plFadeOpacityLay;
hsgResMgr::ResMgr()->NewKey(lay->GetKey()->GetName(), fade, lay->GetKey()->GetUoid().GetLocation());
fade->AttachViaNotify(lay);
// We should add a ref or something here if we're going to hold on to this (even though we created and "own" it).
fFadeLays.Append(fade);
plMatRefMsg* msg = TRACKED_NEW plMatRefMsg(mat->GetKey(), plRefMsg::kOnReplace, i, plMatRefMsg::kLayer);
msg->SetOldRef(lay);
hsgResMgr::ResMgr()->SendRef(fade, msg, plRefFlags::kActiveRef);
plGenRefMsg* toMe = TRACKED_NEW plGenRefMsg(GetKey(), plRefMsg::kOnRequest, 0, kRefFadeLay);
hsgResMgr::ResMgr()->SendRef(fade, toMe, plRefFlags::kPassiveRef);
}
fSetup = true;
}

View File

@ -0,0 +1,112 @@
/*==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 plDistOpacityMod_inc
#define plDistOpacityMod_inc
#include "hsGeometry3.h"
#include "../pnModifier/plSingleModifier.h"
#include "hsTemplates.h"
class plPipeline;
class plRenderMsg;
class plFadeOpacityLay;
class plDistOpacityMod : public plSingleModifier
{
public:
enum {
kTrackAvatar,
kTrackCamera
};
protected:
enum {
kRefFadeLay
};
// Volatile flag, whether we're setup yet or not.
UInt8 fSetup;
enum {
kNearTrans,
kNearOpaq,
kFarOpaq,
kFarTrans,
kNumDists
};
hsScalar fDists[kNumDists];
hsPoint3 fRefPos;
hsTArray<plFadeOpacityLay*> fFadeLays;
// We only act in response to messages.
virtual hsBool IEval(double secs, hsScalar del, UInt32 dirty) { return false; }
hsScalar ICalcOpacity(const hsPoint3& targPos, const hsPoint3& refPos) const;
void ISetOpacity();
void ISetup();
void ICheckDists()
{
hsAssert(fDists[kNearTrans] <= fDists[kNearOpaq], "Bad transition values");
hsAssert(fDists[kNearOpaq] <= fDists[kFarOpaq], "Bad transition values");
hsAssert(fDists[kFarOpaq] <= fDists[kFarTrans], "Bad transition values");
}
public:
plDistOpacityMod();
virtual ~plDistOpacityMod();
CLASSNAME_REGISTER( plDistOpacityMod );
GETINTERFACE_ANY( plDistOpacityMod, plSingleModifier );
virtual void SetKey(plKey k);
virtual hsBool MsgReceive(plMessage* msg);
virtual void Read(hsStream* s, hsResMgr* mgr);
virtual void Write(hsStream* s, hsResMgr* mgr);
virtual void SetTarget(plSceneObject* so);
// Rules are:
// NearTrans <= NearOpaq <= FarOpaque <= FarTrans
void SetFarDist(hsScalar opaque, hsScalar transparent);
void SetNearDist(hsScalar transparent, hsScalar opaque);
hsScalar GetFarTransparent() const { return fDists[kFarTrans]; }
hsScalar GetNearTransparent() const { return fDists[kNearTrans]; }
hsScalar GetFarOpaque() const { return fDists[kFarOpaq]; }
hsScalar GetNearOpaque() const { return fDists[kNearOpaq]; }
};
#endif // plDistOpacityMod_inc

View File

@ -0,0 +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==*/
#include "hsTypes.h"
#include "plFadeOpacityLay.h"
plFadeOpacityLay::plFadeOpacityLay()
: fOpScale(1.f)
{
fOwnedChannels |= kOpacity;
fOpacity = TRACKED_NEW hsScalar;
}
plFadeOpacityLay::~plFadeOpacityLay()
{
}
UInt32 plFadeOpacityLay::Eval(double secs, UInt32 frame, UInt32 ignore)
{
UInt32 ret = plLayerInterface::Eval(secs, frame, ignore);
if( fUnderLay )
{
if( GetBlendFlags() & hsGMatState::kBlendAdd )
{
*fRuntimeColor = fUnderLay->GetRuntimeColor() * fOpScale;
}
else
{
*fOpacity = fUnderLay->GetOpacity() * fOpScale;
}
}
return ret;
}
void plFadeOpacityLay::Read(hsStream* s, hsResMgr* mgr)
{
plLayerInterface::Read(s, mgr);
fOpScale = s->ReadSwapScalar();
}
void plFadeOpacityLay::Write(hsStream* s, hsResMgr* mgr)
{
plLayerInterface::Write(s, mgr);
s->WriteSwapScalar(fOpScale);
}

View File

@ -0,0 +1,55 @@
/*==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 plFadeOpacityLay_inc
#define plFadeOpacityLay_inc
#include "../plSurface/plLayerInterface.h"
class plFadeOpacityLay : public plLayerInterface
{
protected:
hsScalar fOpScale;
public:
plFadeOpacityLay();
virtual ~plFadeOpacityLay();
CLASSNAME_REGISTER( plFadeOpacityLay );
GETINTERFACE_ANY( plFadeOpacityLay, plLayerInterface );
virtual UInt32 Eval(double secs, UInt32 frame, UInt32 ignore);
virtual void Read(hsStream* s, hsResMgr* mgr);
virtual void Write(hsStream* s, hsResMgr* mgr);
void SetOpacity(hsScalar f) { fOpScale = f; }
hsScalar GetOpacity() const { return fOpScale; }
};
#endif // plFadeOpacityLay_inc

View File

@ -0,0 +1,376 @@
/*==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 "plFadeOpacityMod.h"
#include "plFadeOpacityLay.h"
#include "../plMessage/plRenderMsg.h"
#include "../plMessage/plMatRefMsg.h"
#include "../plSurface/hsGMaterial.h"
#include "../plDrawable/plVisLOSMgr.h"
#include "../plDrawable/plAccessGeometry.h"
#include "../plDrawable/plAccessSpan.h"
#include "../plDrawable/plDrawableSpans.h"
#include "../pnSceneObject/plSceneObject.h"
#include "../pnSceneObject/plDrawInterface.h"
#include "../plScene/plVisMgr.h"
#include "plgDispatch.h"
#include "plPipeline.h"
#include "hsBounds.h"
#include "hsTimer.h"
#include "hsResMgr.h"
/*
curr = (t - t0) / fadeUp;
curr = 1. - (t - t0) / fadeDown;
switch from fadeUp to fadeDown
curr = 1 - (t - t0) / fadeDown;
t - t0 = (1 - curr) * fadeDown
t0 = t - (1 - curr) * fadeDown;
switch from fadeDown to fadeUp
curr = (t - t0) / fadeUp;
curr * fadeUp = t - t0;
t0 = t - curr * fadeUp;
*/
hsBool plFadeOpacityMod::fLOSCheckDisabled = false;
const hsScalar kDefFadeUp(5.f);
const hsScalar kDefFadeDown(1.f);
plFadeOpacityMod::plFadeOpacityMod()
: fFadeUp(kDefFadeUp),
fFadeDown(kDefFadeDown),
fOpCurrent(1.f),
fStart(0),
fFade(kImmediate),
fLastEye(0.f, 0.f, 0.f),
fSetup(false)
{
}
plFadeOpacityMod::~plFadeOpacityMod()
{
}
hsBool plFadeOpacityMod::MsgReceive(plMessage* msg)
{
plRenderMsg* rend = plRenderMsg::ConvertNoRef(msg);
if( rend )
{
IOnRenderMsg(rend);
return true;
}
return plSingleModifier::MsgReceive(msg);
}
void plFadeOpacityMod::SetKey(plKey k)
{
hsKeyedObject::SetKey(k);
if( k )
{
plgDispatch::Dispatch()->RegisterForExactType(plRenderMsg::Index(), GetKey());
}
}
void plFadeOpacityMod::Read(hsStream* s, hsResMgr* mgr)
{
plSingleModifier::Read(s, mgr);
fFadeUp = s->ReadSwapScalar();
fFadeDown = s->ReadSwapScalar();
}
void plFadeOpacityMod::Write(hsStream* s, hsResMgr* mgr)
{
plSingleModifier::Write(s, mgr);
s->WriteSwapScalar(fFadeUp);
s->WriteSwapScalar(fFadeDown);
}
void plFadeOpacityMod::SetTarget(plSceneObject* so)
{
plSingleModifier::SetTarget(so);
fSetup = false;
}
hsBool plFadeOpacityMod::IShouldCheck(plPipeline* pipe)
{
if (pipe->TestVisibleWorld(GetTarget()))
return true;
fFade = kImmediate;
return false;
}
void plFadeOpacityMod::IOnRenderMsg(plRenderMsg* rend)
{
// Okay, are we set up enough to proceed?
if( !IReady() )
return;
// Okay, we're going to check.
hsBool hit = false;
if( !fLOSCheckDisabled )
{
// Should we check to see if we're visible before anything else?
if( !IShouldCheck(rend->Pipeline()) )
return;
hsPoint3 eyePos = rend->Pipeline()->GetViewPositionWorld();
hsPoint3 ourPos = IGetOurPos();
if( fFade != kImmediate )
{
// If we've moved more than 3 feet in a frame, we'll consider this a
// camera cut. In that case, don't fade up or down, just go there.
const hsScalar kCutMagSquared = 3.f * 3.f;
if( hsVector3(&eyePos, &fLastEye).MagnitudeSquared() > kCutMagSquared )
fFade = kImmediate;
}
fLastEye = eyePos;
// Cast the ray from eye to us.
plVisHit hitInfo;
hit = plVisLOSMgr::Instance()->Check(eyePos, ourPos, hitInfo);
}
// If the ray made it, fade us up
// Else fade us down.
if( !hit )
IFadeUp();
else
IFadeDown();
ISetOpacity();
}
hsBool plFadeOpacityMod::IReady()
{
plSceneObject* so = GetTarget();
if( !so )
return false;
if( !so->GetDrawInterface() )
return false;
if( !fSetup )
ISetup(so);
if( !fFadeLays.GetCount() )
return false;
return true;
}
hsPoint3 plFadeOpacityMod::IGetOurPos()
{
hsAssert(GetTarget(), "Weed out target-less earlier");
if( HasFlag(kBoundsCenter) )
{
return GetTarget()->GetDrawInterface()->GetWorldBounds().GetCenter();
}
else
{
return GetTarget()->GetLocalToWorld().GetTranslate();
}
}
void plFadeOpacityMod::ICalcOpacity()
{
double t = hsTimer::GetSysSeconds();
switch( fFade )
{
case kFadeUp:
fOpCurrent = (hsScalar)(t - fStart);
if( fOpCurrent > fFadeUp )
{
fOpCurrent = 1.f;
fFade = kUp;
}
else
{
fOpCurrent /= fFadeUp;
}
break;
case kFadeDown:
fOpCurrent = (hsScalar)(t - fStart);
if( fOpCurrent > fFadeDown )
{
fOpCurrent = 0.f;
fFade = kDown;
}
else
{
fOpCurrent = 1.f - fOpCurrent / fFadeDown;
}
break;
case kUp:
case kDown:
break;
case kImmediate:
default:
hsAssert(false, "Invalid state");
break;
};
}
void plFadeOpacityMod::ISetOpacity()
{
ICalcOpacity();
const int num = fFadeLays.GetCount();
int i;
for( i = 0; i < num; i++ )
fFadeLays[i]->SetOpacity(fOpCurrent);
}
void plFadeOpacityMod::IFadeUp()
{
const double t = hsTimer::GetSysSeconds();
switch( fFade )
{
case kImmediate:
fOpCurrent = 1.f;
fFade = kUp;
break;
case kFadeDown:
{
fStart = t - fOpCurrent * fFadeUp;
fFade = kFadeUp;
}
break;
case kDown:
{
fStart = t;
fFade = kFadeUp;
}
break;
case kUp:
case kFadeUp:
break;
default:
hsAssert(false, "Bad State");
break;
};
}
void plFadeOpacityMod::IFadeDown()
{
const double t = hsTimer::GetSysSeconds();
switch( fFade )
{
case kImmediate:
fOpCurrent = 0.f;
fFade = kDown;
break;
case kFadeUp:
{
fStart = t - (1.f - fOpCurrent) * fFadeDown;
fFade = kFadeDown;
}
break;
case kUp:
{
fStart = t;
fFade = kFadeDown;
}
case kFadeDown:
case kDown:
break;
default:
hsAssert(false, "Bad State");
break;
};
}
void plFadeOpacityMod::ISetup(plSceneObject* so)
{
fFadeLays.Reset();
if( !so )
return;
const plDrawInterface* di = so->GetDrawInterface();
if( !di )
return;
hsTArray<plAccessSpan> src;
plAccessGeometry::Instance()->OpenRO(di, src, false);
int i;
for( i = 0; i < src.GetCount(); i++ )
{
hsGMaterial* mat = src[i].GetMaterial();
int j;
for( j = 0; j < mat->GetNumLayers(); j++ )
{
plLayerInterface* lay = mat->GetLayer(j);
if( !j || !(lay->GetZFlags() & hsGMatState::kZNoZWrite) || (lay->GetMiscFlags() & hsGMatState::kMiscRestartPassHere) )
{
plFadeOpacityLay* fade = NEW(plFadeOpacityLay);
hsgResMgr::ResMgr()->NewKey(lay->GetKey()->GetName(), fade, lay->GetKey()->GetUoid().GetLocation());
fade->AttachViaNotify(lay);
// We should add a ref or something here if we're going to hold on to this (even though we created and "own" it).
fFadeLays.Append(fade);
plMatRefMsg* msg = NEW(plMatRefMsg)(mat->GetKey(), plRefMsg::kOnReplace, i, plMatRefMsg::kLayer);
msg->SetOldRef(lay);
hsgResMgr::ResMgr()->SendRef(fade, msg, plRefFlags::kActiveRef);
plGenRefMsg* toMe = NEW(plGenRefMsg)(GetKey(), plRefMsg::kOnRequest, 0, kRefFadeLay);
hsgResMgr::ResMgr()->SendRef(fade, toMe, plRefFlags::kPassiveRef);
}
}
}
plAccessGeometry::Instance()->Close(src);
fSetup = true;
fFade = kImmediate;
}

View File

@ -0,0 +1,120 @@
/*==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 plFadeOpacityMod_inc
#define plFadeOpacityMod_inc
#include "hsGeometry3.h"
#include "../pnModifier/plSingleModifier.h"
#include "hsTemplates.h"
class plPipeline;
class plRenderMsg;
class plFadeOpacityLay;
class plFadeOpacityMod : public plSingleModifier
{
public:
enum {
kBoundsCenter = 1
};
protected:
enum {
kRefFadeLay
};
// Input parameters
hsScalar fFadeUp;
hsScalar fFadeDown;
// Internal fade state
enum FadeState {
kUp = 0,
kDown = 1,
kFadeUp = 2,
kFadeDown = 3,
kImmediate = 4
};
hsScalar fOpCurrent;
double fStart;
FadeState fFade;
UInt8 fSetup;
hsPoint3 fLastEye;
// The target layers
hsTArray<plFadeOpacityLay*> fFadeLays;
// A global to turn the whole thing off for debug/perf
static hsBool fLOSCheckDisabled;
void IOnRenderMsg(plRenderMsg* rend);
hsBool IReady();
hsBool IShouldCheck(plPipeline* pipe);
hsPoint3 IGetOurPos();
void ICalcOpacity();
void ISetOpacity();
void IFadeUp();
void IFadeDown();
void ISetup(plSceneObject* so);
// We only act in response to messages.
virtual hsBool IEval(double secs, hsScalar del, UInt32 dirty) { return false; }
public:
plFadeOpacityMod();
virtual ~plFadeOpacityMod();
CLASSNAME_REGISTER( plFadeOpacityMod );
GETINTERFACE_ANY( plFadeOpacityMod, plSingleModifier );
virtual void SetKey(plKey k);
virtual hsBool MsgReceive(plMessage* msg);
virtual void Read(hsStream* s, hsResMgr* mgr);
virtual void Write(hsStream* s, hsResMgr* mgr);
virtual void SetTarget(plSceneObject* so);
void FadeUp();
void FadeDown();
void Fade(hsBool up) { if( up ) FadeUp(); else FadeDown(); }
void SetFadeUp(hsScalar f) { fFadeUp = f; }
hsScalar GetFadeUp() const { return fFadeUp; }
void SetFadeDown(hsScalar f) { fFadeDown = f; }
hsScalar GetFadeDown() const { return fFadeDown; }
static hsBool GetLOSCheckDisabled() { return fLOSCheckDisabled; }
static void SetLOSCheckDisabled(hsBool on) { fLOSCheckDisabled = on; }
};
#endif // plFadeOpacityMod_inc

View File

@ -0,0 +1,150 @@
/*==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 "plGrabCubeMap.h"
#include "plPipeline.h"
#include "plDrawable.h"
#include "hsMatrix44.h"
#include "hsGeometry3.h"
#include "hsColorRGBA.h"
#include "hsBounds.h"
#include "../pnSceneObject/plSceneObject.h"
#include "../pnSceneObject/plDrawInterface.h"
#include "../plGImage/plMipmap.h"
#include "../plJPEG/plJPEG.h"
#include "../plMessage/plRenderRequestMsg.h"
plGrabCubeRenderRequest::plGrabCubeRenderRequest()
: fQuality(75)
{
}
void plGrabCubeRenderRequest::Render(plPipeline* pipe, plPageTreeMgr* pageMgr)
{
if( !fFileName[0] )
return;
plRenderRequest::Render(pipe, pageMgr);
pipe->EndRender();
plMipmap mipmap;
if( pipe->CaptureScreen(&mipmap) )
{
plJPEG::Instance().SetWriteQuality(fQuality);
plJPEG::Instance().WriteToFile(fFileName, &mipmap);
}
pipe->BeginRender();
}
void plGrabCubeMap::GrabCube(plPipeline* pipe, plSceneObject* obj, const char* pref, const hsColorRGBA& clearColor, UInt8 q)
{
hsPoint3 center;
if( obj && !(obj->GetLocalToWorld().fFlags & hsMatrix44::kIsIdent) )
{
center = obj->GetLocalToWorld().GetTranslate();
}
else if( obj && obj->GetDrawInterface() )
{
center = obj->GetDrawInterface()->GetWorldBounds().GetCenter();
}
else
{
center = pipe->GetCameraToWorld().GetTranslate();
}
ISetupRenderRequests(pipe, center, pref, clearColor, q);
}
void plGrabCubeMap::GrabCube(plPipeline* pipe, const hsPoint3& center, const char* pref, const hsColorRGBA& clearColor, UInt8 q)
{
ISetupRenderRequests(pipe, center, pref, clearColor, q);
}
void plGrabCubeMap::ISetupRenderRequests(plPipeline* pipe, const hsPoint3& center, const char* pref, const hsColorRGBA& clearColor, UInt8 q) const
{
hsMatrix44 worldToCameras[6];
hsMatrix44 cameraToWorlds[6];
hsMatrix44::MakeEnvMapMatrices(center, worldToCameras, cameraToWorlds);
UInt32 renderState
= plPipeline::kRenderNormal
| plPipeline::kRenderClearColor
| plPipeline::kRenderClearDepth;
float hither;
float yon;
pipe->GetDepth(hither, yon);
const char* suff[6] = {
"LF",
"RT",
"BK",
"FR",
"UP",
"DN" };
int i;
for( i = 0; i < 6; i++ )
{
plGrabCubeRenderRequest* req = TRACKED_NEW plGrabCubeRenderRequest;
req->SetRenderState(renderState);
req->SetDrawableMask(plDrawable::kNormal);
req->SetSubDrawableMask(plDrawable::kSubAllTypes);
req->SetHither(hither);
req->SetYon(yon);
req->SetFovX(90.f);
req->SetFovY(90.f);
req->SetClearColor(clearColor);
req->SetClearDepth(1.f);
req->SetClearDrawable(nil);
req->SetRenderTarget(nil);
req->SetCameraTransform(worldToCameras[i], cameraToWorlds[i]);
req->fQuality = q;
sprintf(req->fFileName, "%s_%s.jpg", pref, suff[i]);
plRenderRequestMsg* reqMsg = TRACKED_NEW plRenderRequestMsg(nil, req);
reqMsg->Send();
hsRefCnt_SafeUnRef(req);
}
}

View File

@ -0,0 +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 plGrabCubeMap_inc
#define plGrabCubeMap_inc
#include "../plScene/plRenderRequest.h"
class plSceneObject;
class plPipeline;
class plPageTreeMgr;
struct hsMatrix44;
struct hsPoint3;
struct hsColorRGBA;
class plGrabCubeRenderRequest : public plRenderRequest
{
public:
plGrabCubeRenderRequest();
char fFileName[256];
UInt8 fQuality;
// This function is called after the render request is processed by the client
virtual void Render(plPipeline* pipe, plPageTreeMgr* pageMgr);
};
class plGrabCubeMap
{
protected:
void ISetupRenderRequests(plPipeline* pipe, const hsPoint3& center, const char* pref, const hsColorRGBA& clearColor, UInt8 q) const;
public:
plGrabCubeMap() {}
void GrabCube(plPipeline* pipe, plSceneObject* obj, const char* pref, const hsColorRGBA& clearColor, UInt8 q=75);
void GrabCube(plPipeline* pipe, const hsPoint3& pos, const char* pref, const hsColorRGBA& clearColor, UInt8 q=75);
};
#endif // plGrabCubeMap_inc

View File

@ -0,0 +1,232 @@
/*==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 "hsConfig.h"
#if HS_BUILD_FOR_WIN32
#define WIN32_EXTRA_LEAN
#define WIN32_LEAN_AND_MEAN
#ifndef _WINDOWS_H_ // redundant include guard to minimize compile times
#define _WINDOWS_H_
#include <windows.h>
#endif // _WINDOWS_H_
#include "vfw.h"
#endif // HS_BUILD_FOR_WIN32
#include "hsTypes.h"
#include "plLayerAVI.h"
#include "../plGImage/plMipmap.h"
#if HS_BUILD_FOR_WIN32
class plAVIFileInfo
{
public:
plAVIFileInfo() : fAVIStream(nil), fGetFrame(0) {}
IAVIStream* fAVIStream;
AVISTREAMINFO fAVIStreamInfo;
PGETFRAME fGetFrame; // Where in the stream to get the next frame
};
#else // HS_BUILD_FOR_WIN32
struct plAVIFileInfo
{
};
#endif // HS_BUILD_FOR_WIN32
static hsBool ICopySourceToTexture24(BITMAPINFO* bmi, plMipmap* t);
static hsBool ICopySourceToTexture16(BITMAPINFO* bmi, plMipmap* t);
plLayerAVI::plLayerAVI()
{
fAVIInfo = TRACKED_NEW plAVIFileInfo;
}
plLayerAVI::~plLayerAVI()
{
ICloseMovie();
delete fAVIInfo;
}
hsBool plLayerAVI::IInit()
{
#if HS_BUILD_FOR_WIN32
int ret = AVIStreamOpenFromFile( &fAVIInfo->fAVIStream,
fMovieName,
streamtypeVIDEO,
0,
OF_READ,
NULL);
if (ret)
return ISetFault("Error opening AVI");
if( !(fAVIInfo->fGetFrame = AVIStreamGetFrameOpen(fAVIInfo->fAVIStream, NULL)) )
return ISetFault("Error positioning AVI");
if( AVIStreamInfo(fAVIInfo->fAVIStream, &fAVIInfo->fAVIStreamInfo, sizeof(AVISTREAMINFO)) )
return ISetFault("Error getting AVI info");
BITMAPINFO* bmi;
if( !(bmi = (BITMAPINFO*)AVIStreamGetFrame(fAVIInfo->fGetFrame, fCurrentFrame >= 0 ? fCurrentFrame : 0)) )
return ISetFault("Can't get first frame");
ISetSize(bmi->bmiHeader.biWidth, bmi->bmiHeader.biHeight);
Int32 endFrame = fAVIInfo->fAVIStreamInfo.dwLength-1;
hsScalar length = float(endFrame) * float(fAVIInfo->fAVIStreamInfo.dwScale)
/ float(fAVIInfo->fAVIStreamInfo.dwRate);
ISetLength(length);
#endif
return false;
}
Int32 plLayerAVI::ISecsToFrame(hsScalar secs)
{
float timeScale = float(fAVIInfo->fAVIStreamInfo.dwRate) / float(fAVIInfo->fAVIStreamInfo.dwScale);
return Int32(secs * timeScale + 0.5f);
}
hsBool plLayerAVI::IGetCurrentFrame()
{
if( !fAVIInfo->fAVIStream )
IInit();
ICheckBitmap();
BITMAPINFO* bmi;
if( !(bmi = (BITMAPINFO*)AVIStreamGetFrame(fAVIInfo->fGetFrame, fCurrentFrame)) )
return ISetFault("Can't get frame");
switch(bmi->bmiHeader.biBitCount)
{
case 16:
return ICopySourceToTexture16(bmi, plMipmap::ConvertNoRef(GetTexture()));
break;
case 24:
return ICopySourceToTexture24(bmi, plMipmap::ConvertNoRef(GetTexture()));
break;
default:
return ISetFault("Unknown AVI color depth");
}
return true;
}
static hsBool ICopySourceToTexture16(BITMAPINFO* bmi, plMipmap* b)
{
hsAssert( b != nil, "nil mipmap passed to ICopySourceToTexture16()" );
UInt16* pSrc = (UInt16*)( bmi->bmiHeader.biSize + (BYTE*)bmi );
UInt32* pix = (UInt32*)b->GetImage();
pix += b->GetWidth() * b->GetHeight();
int width = bmi->bmiHeader.biWidth;
int height = bmi->bmiHeader.biHeight;
int useHeight = hsMinimum(height, b->GetHeight());
int useWidth = hsMinimum(width, b->GetWidth());
int i;
for( i = 0; i < useHeight; i++ )
{
UInt16* src = pSrc;
pSrc += width;
pix -= b->GetWidth();
UInt32* tPix = pix;
int j;
for( j = 0; j < useWidth; j++ )
{
*tPix = ((*src & 0x001f) << 3) // up 3
| ((*src & 0x03e0) << 6) // down 5 up 3 up 8
| ((*src & 0x7c00) << 9) // down 10 up 3 up 16
| (0xff << 24); // alpha
src++;
++tPix;
}
}
return false;
}
static hsBool ICopySourceToTexture24(BITMAPINFO* bmi, plMipmap* b)
{
hsAssert( b != nil, "nil mipmap passed to ICopySourceToTexture24()" );
unsigned char* pSrc = (unsigned char*)( bmi->bmiHeader.biSize + (BYTE*)bmi );
hsRGBAColor32* pix = (hsRGBAColor32*)b->GetImage();
pix += b->GetWidth() * b->GetHeight();
int width = bmi->bmiHeader.biWidth;
int height = bmi->bmiHeader.biHeight;
int useHeight = hsMinimum(height, b->GetHeight());
int useWidth = hsMinimum(width, b->GetWidth());
int i;
for( i = 0; i < useHeight; i++ )
{
unsigned char* src = pSrc;
pSrc += width * 3;
pix -= b->GetWidth();
hsRGBAColor32* tPix = pix;
int j;
for( j = 0; j < useWidth; j++ )
{
tPix->b = *src++;
tPix->g = *src++;
tPix->r = *src++;
++tPix;
}
}
return false;
}
hsBool plLayerAVI::ICloseMovie()
{
if( fAVIInfo->fGetFrame )
AVIStreamGetFrameClose(fAVIInfo->fGetFrame);
fAVIInfo->fGetFrame = 0;
if( fAVIInfo->fAVIStream )
AVIStreamRelease(fAVIInfo->fAVIStream);
fAVIInfo->fAVIStream = nil;
return false;
}
hsBool plLayerAVI::IRelease()
{
ICloseMovie();
return false;
}

View File

@ -0,0 +1,58 @@
/*==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 plLayerAVI_inc
#define plLayerAVI_inc
#include "plLayerMovie.h"
class plAVIFileInfo;
class plLayerAVI : public plLayerMovie
{
protected:
plAVIFileInfo* fAVIInfo;
hsBool ICloseMovie();
virtual Int32 ISecsToFrame(hsScalar secs);
virtual hsBool IInit();
virtual hsBool IGetCurrentFrame();
virtual hsBool IRelease();
public:
plLayerAVI();
virtual ~plLayerAVI();
CLASSNAME_REGISTER( plLayerAVI );
GETINTERFACE_ANY( plLayerAVI, plLayerMovie );
};
#endif // plLayerAVI_inc

View File

@ -0,0 +1,209 @@
/*==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 "plLayerMovie.h"
#include "hsStream.h"
#include "hsResMgr.h"
#include "hsUtils.h"
#include "../plMessage/plAnimCmdMsg.h"
#include "../plGImage/plMipmap.h"
#include "../plPipeline/hsGDeviceRef.h"
plLayerMovie::plLayerMovie()
: fMovieName(nil),
fCurrentFrame(-1),
fLength(0),
fWidth(32),
fHeight(32)
{
fOwnedChannels |= kTexture;
fTexture = TRACKED_NEW plBitmap*;
*fTexture = nil;
// fTimeConvert.SetOwner(this);
}
plLayerMovie::~plLayerMovie()
{
delete [] fMovieName;
delete *fTexture;
}
hsBool plLayerMovie::ISetFault(const char* errStr)
{
#ifdef HS_DEBUGGING
char buff[256];
sprintf(buff, "ERROR %s: %s\n", fMovieName, errStr);
hsStatusMessage(buff);
#endif // HS_DEBUGGING
*fMovieName = 0;
return true;
}
hsBool plLayerMovie::ISetLength(hsScalar secs)
{
fLength = secs;
return false;
}
int plLayerMovie::GetWidth() const
{
plMipmap *mip = plMipmap::ConvertNoRef( GetTexture() );
return mip ? mip->GetWidth() : 0;
}
int plLayerMovie::GetHeight() const
{
plMipmap *mip = plMipmap::ConvertNoRef( GetTexture() );
return mip ? mip->GetHeight() : 0;
}
hsBool plLayerMovie::ISetSize(int width, int height)
{
fWidth = width;
fHeight = height;
return false;
}
hsBool plLayerMovie::ISetupBitmap()
{
if( !GetTexture() )
{
plMipmap* b = TRACKED_NEW plMipmap( fWidth, fHeight, plMipmap::kARGB32Config, 1 );
memset(b->GetImage(), 0x10, b->GetHeight() * b->GetRowBytes() );
b->SetFlags( b->GetFlags() | plMipmap::kDontThrowAwayImage );
char name[ 256 ];
sprintf( name, "%s_BMap", fMovieName );
hsgResMgr::ResMgr()->NewKey( name, b, plLocation::kGlobalFixedLoc );
*fTexture = (plBitmap *)b;
}
return false;
}
hsBool plLayerMovie::ICheckBitmap()
{
if( !GetTexture() )
ISetupBitmap();
return false;
}
hsBool plLayerMovie::IMovieIsIdle()
{
IRelease();
return false;
}
hsBool plLayerMovie::ICurrentFrameDirty(double wSecs)
{
hsScalar secs = fTimeConvert.WorldToAnimTime(wSecs);
UInt32 frame = ISecsToFrame(secs);
if( frame == fCurrentFrame )
return false;
fCurrentFrame = frame;
return true;
}
UInt32 plLayerMovie::Eval(double wSecs, UInt32 frame, UInt32 ignore)
{
UInt32 dirty = plLayerAnimation::Eval(wSecs, frame, ignore);
if( !IGetFault() && !(ignore & kTexture) )
{
if( ICurrentFrameDirty(wSecs) )
{
if( IGetCurrentFrame() )
ISetFault("Getting current frame");
if( GetTexture() )
{
hsGDeviceRef* ref = GetTexture()->GetDeviceRef();
if( ref )
ref->SetDirty(true);
}
}
else
if( IsStopped() )
{
IMovieIsIdle();
}
dirty |= kTexture;
}
return dirty;
}
void plLayerMovie::Read(hsStream* s, hsResMgr* mgr)
{
plLayerAnimation::Read(s, mgr);
delete [] fMovieName;
int len = s->ReadSwap32();
if( len )
{
fMovieName = TRACKED_NEW char[len+1];
s->Read(len, fMovieName);
fMovieName[len] = 0;
}
else
{
hsAssert(false, "Reading empty string for movie name");
fMovieName = nil;
}
}
void plLayerMovie::Write(hsStream* s, hsResMgr* mgr)
{
plLayerAnimation::Write(s, mgr);
int len = hsStrlen(fMovieName);
s->WriteSwap32(len);
if( len )
s->Write(len, fMovieName);
}
void plLayerMovie::SetMovieName(const char* n)
{
delete [] fMovieName;
fMovieName = hsStrcpy(n);
}
hsBool plLayerMovie::MsgReceive(plMessage* msg)
{
return plLayerAnimation::MsgReceive(msg);
}
void plLayerMovie::DefaultMovie()
{
}

View File

@ -0,0 +1,89 @@
/*==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 plLayerMovie_inc
#define plLayerMovie_inc
#include "../plSurface/plLayerAnimation.h"
#include "../plInterp/plAnimTimeConvert.h"
class plMessage;
class hsStream;
class hsResMgr;
class plLayerMovie : public plLayerAnimation
{
protected:
char* fMovieName;
// plAnimTimeConvert fTimeConvert;
Int32 fCurrentFrame;
hsScalar fLength;
UInt32 fWidth, fHeight;
virtual Int32 ISecsToFrame(hsScalar secs) = 0;
hsBool IGetFault() const { return !(fMovieName && *fMovieName); }
hsBool ISetFault(const char* errStr);
hsBool ICheckBitmap();
hsBool IMovieIsIdle(); // will call IRelease();
hsBool ISetupBitmap();
hsBool ISetSize(int w, int h);
hsBool ISetLength(hsScalar secs);
hsBool ICurrentFrameDirty(double wSecs);
virtual hsBool IInit() = 0; // Load header etc, must call ISetSize(w, h), ISetLength(s)
virtual hsBool IGetCurrentFrame() = 0; // Load fCurrentFrame into bitmap
virtual hsBool IRelease() = 0; // release any system resources.
public:
plLayerMovie();
virtual ~plLayerMovie();
CLASSNAME_REGISTER( plLayerMovie );
GETINTERFACE_ANY( plLayerMovie, plLayerAnimation );
virtual UInt32 Eval(double secs, UInt32 frame, UInt32 ignore);
virtual void Read(hsStream* s, hsResMgr* mgr);
virtual void Write(hsStream* s, hsResMgr* mgr);
hsBool IsStopped() { return fTimeConvert.IsStopped(); }
void SetMovieName(const char* n);
const char* GetMovieName() const { return fMovieName; }
virtual hsBool MsgReceive(plMessage* msg);
// Movie specific
int GetWidth() const;
int GetHeight() const;
hsScalar GetLength() const { return fLength; }
virtual void DefaultMovie();
};
#endif // plLayerMovie_inc