Browse Source

Remove obsolete components

Adam Johnson 12 years ago
parent
commit
1a5606e05c
  1. 3
      Sources/Plasma/FeatureLib/CMakeLists.txt
  2. 23
      Sources/Plasma/FeatureLib/pfLoginDialog/CMakeLists.txt
  3. 103
      Sources/Plasma/FeatureLib/pfLoginDialog/pfLoginDialog.rc
  4. 672
      Sources/Plasma/FeatureLib/pfLoginDialog/plLoginDialog.cpp
  5. 138
      Sources/Plasma/FeatureLib/pfLoginDialog/plLoginDialog.h
  6. 24
      Sources/Plasma/FeatureLib/pfLoginDialog/resource.h
  7. 4
      Sources/Plasma/PubUtilLib/CMakeLists.txt
  8. 587
      Sources/Plasma/PubUtilLib/plDeviceSelector/plDeviceSelector.cpp
  9. 160
      Sources/Plasma/PubUtilLib/plDeviceSelector/plDeviceSelector.h
  10. 1
      Sources/Plasma/PubUtilLib/plGClip/placeholder.txt
  11. 250
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsGRenderProcs.cpp
  12. 218
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsGRenderProcs.h
  13. 234
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxAngleFade.cpp
  14. 90
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxAngleFade.h
  15. 331
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxDistFade.cpp
  16. 107
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxDistFade.h
  17. 292
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxDistShade.cpp
  18. 97
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxDistShade.h
  19. 242
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxGlobalShade.cpp
  20. 120
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxGlobalShade.h
  21. 81
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxIntenseAlpha.cpp
  22. 82
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxIntenseAlpha.h
  23. 320
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxObjDistFade.cpp
  24. 116
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxObjDistFade.h
  25. 217
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxObjDistShade.cpp
  26. 98
      Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxObjDistShade.h
  27. 80
      Sources/Plasma/PubUtilLib/plGRenderProcs/plGRenderProcsCreatable.h
  28. 763
      Sources/Plasma/PubUtilLib/plGeometry/hsOscillator.cpp
  29. 180
      Sources/Plasma/PubUtilLib/plGeometry/hsOscillator.h
  30. 350
      Sources/Plasma/PubUtilLib/plGeometry/hsPerterber.cpp
  31. 107
      Sources/Plasma/PubUtilLib/plGeometry/hsPerterber.h
  32. 70
      Sources/Plasma/PubUtilLib/plGeometry/plGeometryCreatable.h

3
Sources/Plasma/FeatureLib/CMakeLists.txt

@ -16,9 +16,6 @@ add_subdirectory(pfJournalBook)
# pfKI is apparently just a historical oddity at this point
# add_subdirectory(pfKI)
add_subdirectory(pfLocalizationMgr)
# This is missing required parts in other plasma libraries.
# Also not referenced by any sln file
# add_subdirectory(pfLoginDialog)
add_subdirectory(pfMessage)
add_subdirectory(pfPython)
add_subdirectory(pfSecurePreloader)

23
Sources/Plasma/FeatureLib/pfLoginDialog/CMakeLists.txt

@ -1,23 +0,0 @@
include_directories(../../CoreLib)
include_directories(../../NucleusLib)
include_directories(../../NucleusLib/inc)
include_directories(../../PubUtilLib)
set(pfLoginDialog_SOURCES
plLoginDialog.cpp
)
set(pfLoginDialog_HEADERS
plLoginDialog.h
resource.h
)
set(pfLoginDialog_RESOURCES
pfLoginDialog.rc
)
add_library(pfLoginDialog STATIC ${pfLoginDialog_SOURCES} ${pfLoginDialog_HEADERS} ${pfLoginDialog_RESOURCES})
source_group("Source Files" FILES ${pfLoginDialog_SOURCES})
source_group("Header Files" FILES ${pfLoginDialog_HEADERS})
source_group("Resource Files" FILES ${pfLoginDialog_RESOURCES})

103
Sources/Plasma/FeatureLib/pfLoginDialog/pfLoginDialog.rc

@ -1,103 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define IDC_STATIC (-1) // all static controls
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_DIALOG_LOGIN DIALOGEX 0, 0, 186, 114
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
EXSTYLE WS_EX_CONTROLPARENT
CAPTION "Login"
FONT 8, "Tahoma"
BEGIN
EDITTEXT IDC_LOGIN_USERNAME,55,7,98,12,ES_AUTOHSCROLL
EDITTEXT IDC_LOGIN_PASSWORD,55,23,98,12,ES_PASSWORD |
ES_AUTOHSCROLL
COMBOBOX IDC_LOGIN_LOBBYLIST,55,39,98,76,CBS_DROPDOWN |
CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "Login",IDC_LOGIN_LOGIN,41,58,50,14
PUSHBUTTON "Cancel",IDC_LOGIN_CANCEL,94,58,50,14
LTEXT "Account:",IDC_STATIC,21,9,30,8,0,WS_EX_RIGHT
LTEXT "Password:",IDC_STATIC,17,25,34,8,0,WS_EX_RIGHT
LTEXT "Server:",IDC_LOGIN_STATIC_SERVER,27,41,24,8,0,
WS_EX_RIGHT
PUSHBUTTON "?",IDC_SERVER_QUERY_BTN,157,39,22,13,NOT WS_VISIBLE
CONTROL "Remember Password",IDC_REMEMBER_PASSWORD,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,18,79,119,12
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_DIALOG_LOGIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 107
END
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

672
Sources/Plasma/FeatureLib/pfLoginDialog/plLoginDialog.cpp

@ -1,672 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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 "plLoginDialog.h"
#include "resource.h"
#include "plNetCommon/plNetCommonConstants.h"
#include "plNetMessage/plNetMessage.h"
// #include "plHttpServer/plHttpResponse.h"
#include "plSDL/plSDL.h"
#include "plFile/hsFiles.h"
#include "plNetMessage/plNetCommonMessage.h"
// 'this' : used in base member initializer list
#pragma warning(disable:4355)
#define kAuthTimedOut WM_USER+2
plLoginDialog::plLoginDialog( HWND parentWnd )
: plDialog(IDD_DIALOG_LOGIN)
, fParentWnd( parentWnd )
, fLoginBtn(this, IDC_LOGIN_LOGIN, plDelegate(this,(TDelegate)ILogin))
, fCancelBtn(this, IDC_LOGIN_CANCEL, plDelegate(this,(TDelegate)IExit))
, fAccountName(this,IDC_LOGIN_USERNAME)
, fPassword(this,IDC_LOGIN_PASSWORD)
, fLobbyList(this,IDC_LOGIN_LOBBYLIST)
, fLobbyText(this, IDC_LOGIN_STATIC_SERVER)
, fRememberPassword(this, IDC_REMEMBER_PASSWORD, plDelegate(this, (TDelegate)IOnRememberPwdChanged))
, fCancelled(false)
, fAutoLogin(false)
#ifndef PLASMA_EXTERNAL_RELEASE
, fServerQueryBtn(this, IDC_SERVER_QUERY_BTN)
#endif
{
fLobbyList.fSelectionEndOkDelegate = plDelegate(this,(TDelegate)SelectedLobbyChanged);
fLobbyList.fEditUpdateDelegate = plDelegate(this,(TDelegate)SelectedLobbyTextEdited);
fLobbyList.fKillFocusDelegate = plDelegate(this,(TDelegate)OnLobbyListLostFocus);
#ifndef PLASMA_EXTERNAL_RELEASE
fServerQueryBtn.fClickDelegate = plDelegate(this,(TDelegate)ServerQueryBtnClicked);
#endif
}
std::string plLoginDialog::MakeSafeLobbyServerName(const std::string & value)
{
return "";
}
void plLoginDialog::SelectedLobbyChanged()
{
fLobbyVal.SetValue(fLobbyList.GetValue().c_str());
fLobbyList.SetEdited(false);
}
void plLoginDialog::SelectedLobbyTextEdited()
{
fLobbyVal.SetValue(fLobbyList.GetValue().c_str());
fLobbyList.SetEdited(true);
}
// Ugh
#ifdef PLASMA_EXTERNAL_RELEASE
#include <time.h>
#endif
bool plLoginDialog::RefreshLobbyList()
{
fStatusBar.SetText(L"Refreshing lobby server list...");
plStringList lobbies;
std::vector<std::wstring> wLobbies;
GetLobbyList(lobbies);
// Strip off the shard name and just leave the address
for (int i = 0; i < lobbies.size(); i++)
{
std::string& str = lobbies[i];
std::string::size_type endofname = str.find('\t');
if (endofname != std::string::npos)
str.erase(str.begin() + endofname, str.end());
wchar_t *wLobby = hsStringToWString(str.c_str());
wLobbies.push_back(wLobby);
delete [] wLobby;
}
fLobbyList.Empty();
#ifdef PLASMA_EXTERNAL_RELEASE
// In release mode, put the user in a random lobby for rudimentary load balancing
int numLobbies = lobbies.size();
if (numLobbies > 0)
{
srand(time(NULL));
int rnum = rand();
int whichLobby = rnum % numLobbies;
fLobbyList.AddString(wLobbies[whichLobby].c_str());
}
fLobbyList.SetCurrent(0);
#else
if (AllowSinglePlayerLobby())
fLobbyList.AddString(L"Single Player");
fLobbyList.AddStrings(wLobbies);
wchar_t *wLobby = hsStringToWString(fLobbyVal.GetValue().c_str());
int index = fLobbyList.FindStringExact(wLobby);
if (index==LB_ERR && fLobbyVal.GetValue().length()>0)
{
fLobbyList.AddString(wLobby);
index = fLobbyList.FindStringExact(wLobby);
}
delete [] wLobby;
fLobbyList.SetCurrent((index!=LB_ERR)?index:0);
#endif // PLASMA_EXTERNAL_RELEASE
SelectedLobbyChanged();
fStatusBar.SetText(L"");
return true;
}
void plLoginDialog::OnLobbyListLostFocus()
{
std::string value = fLobbyList.GetValue();
if (value.length()==0)
{
fLobbyList.SetCurrent(0);
fLobbyList.SetValue(MakeSafeLobbyServerName(fLobbyList.GetValue()).c_str());
SelectedLobbyChanged();
}
}
#if 0
void plLoginDialog::UpdateCtrls()
{
bool networkEnabled = IsNetworkPlayEnabled();
bool loggedIn = GetLoggedIn();
bool loggingIn = GetLoggingIn();
bool loggedOut = GetLoggedOut();
if (!networkEnabled && (loggedIn || loggingIn))
{
Logout();
// these don't do anything. need to set the vars in fMainDIalog?
loggedIn = false;
loggingIn = false;
loggedOut = true;
}
}
#endif
bool plLoginDialog::IsNetworkPlayDisabled()
{
#ifdef PLASMA_EXTERNAL_RELEASE
return false;
#else
xtl::istring tmp = fLobbyVal.GetValue().c_str();
return (tmp.compare("single player")==0);
#endif
}
bool plLoginDialog::IsNetworkPlayEnabled()
{
return !IsNetworkPlayDisabled();
}
void plLoginDialog::OnInitDialog()
{
plDialog::OnInitDialog();
if ( fParentWnd )
SetParent( Handle(), fParentWnd );
fStatusBar.OpenWindow(this,true);
#ifdef PLASMA_EXTERNAL_RELEASE
fLobbyList.Show(false);
fLobbyText.Show(false);
#endif
#ifndef PLASMA_EXTERNAL_RELEASE
fServerQueryBtn.Show(true);
#endif
bool rememberPwd = (fRememberPasswordVal.GetValue()=="true");
fAccountName.SetValue(fAccountNameVal.GetValue().c_str());
if (rememberPwd)
{
int len = atoi(fPasswordLen.GetValue().c_str());
std::string fakePwd(len, '*');
fPassword.SetValue(fakePwd.c_str());
}
fRememberPassword.Check(rememberPwd);
RefreshLobbyList();
if ( fAutoLogin )
fLoginBtn.Click();
// SetForegroundWindow(*this);
}
bool plLoginDialog::Login()
{
int ret = DoModal();
if (ret<0)
{
hsAssert(false, xtl::format("plLoginDialog failed to initialize, err code %d, GetLastError %d",
ret, GetLastError()).c_str());
}
return (ret != 0);
}
void plLoginDialog::ILogin()
{
OnLoginClicked();
fAccountNameVal.SetValue(fAccountName.GetValue().c_str());
std::string pwd = fPassword.GetValue();
int pwdSize = pwd.size();
std::string fakePwd = "*" + std::string(pwdSize-1, '*');
if (pwd != fakePwd) // user has entered a real pwd
{
fPasswordLen.SetValue(xtl::format("%d",pwd.size()).c_str());
// MD5 HASH the pwd
std::string hex;
plChallengeResponse::HashPassword(pwd.c_str(), hex);
fPasswordVal.SetValue(hex.c_str());
}
SetDataServerUserName(true, fAccountNameVal.GetValue().c_str());
SetDataServerPassword(true, fPasswordVal.GetValue().c_str());
SetDataServerUserName(false, fAccountNameVal.GetValue().c_str());
SetDataServerPassword(false, fPasswordVal.GetValue().c_str());
if (IsNetworkPlayEnabled())
StartLogin();
else
CompleteLogin();
}
void plLoginDialog::IOnRememberPwdChanged()
{
fRememberPasswordVal.SetValue(fRememberPassword.IsChecked() ? "true" : "false");
}
void plLoginDialog::IExit()
{
fAccountNameVal.SetValue(fAccountName.GetValue().c_str());
fPasswordVal.SetValue(fPassword.GetValue().c_str());
fLobbyVal.SetValue(fLobbyList.GetValue().c_str());
SetDataServerUserName(true, fAccountNameVal.GetValue().c_str());
SetDataServerPassword(true, fPasswordVal.GetValue().c_str());
SetDataServerUserName(false, fAccountNameVal.GetValue().c_str());
SetDataServerPassword(false, fPasswordVal.GetValue().c_str());
SHORT state = GetKeyState(VK_SHIFT);
if (state&0x8000)
EndDialogTrue();
else
EndDialogFalse();
fCancelled=true;
}
int plLoginDialog::ICheckNetVersion(plNetMsgAuthenticateChallenge * msg)
{
if (msg)
{
if (msg->GetVersionMajor() != plNetMessage::kVerMajor ||
msg->GetVersionMinor() != plNetMessage::kVerMinor)
{
std::string str = xtl::format("Login Failed, client/server version mismatch, client %d.%d, server %d.%d",
plNetMessage::kVerMajor, plNetMessage::kVerMinor,
msg->GetVersionMajor(),
msg->GetVersionMinor());
FailLogin(str.c_str());
return hsFail;
}
return hsOK;
}
return hsFail;
}
void plLoginDialog::HandleAuthChallenge(plNetMsgAuthenticateChallenge * msg)
{
int cnt = msg->PeekBuffer(msg->GetNetCoreMsg()->GetData(),msg->GetNetCoreMsg()->GetLen());
// check protocol version first, in case msg contents are hosed
if (ICheckNetVersion(msg) == hsFail)
return; // version err
if (msg->IsContinuing())
{
// Respond to the Challenge
std::string hex = plChallengeResponse::GetBufferAsHexStr(msg->GetChallenge().data(), msg->GetChallenge().size(), true);
fChallengeResponse.SetChallenge(hex);
fChallengeResponse.GenerateResponse(fAccountNameVal.GetValue().c_str(),fPasswordVal.GetValue().c_str());
KillTimer(*this,kAuthTimedOut);
SendAuthenticateResponse();
}
else
{
FailLogin(msg->GetHelloResult());
}
}
void plLoginDialog::HandleAccountAuthenticated(plNetMsgAccountAuthenticated * msg)
{
int cnt = msg->PeekBuffer(msg->GetNetCoreMsg()->GetData(),msg->GetNetCoreMsg()->GetLen());
if (msg->IsAuthenticated())
{
CompleteLogin();
}
else
{
FailLogin(msg->GetAuthResult());
}
}
void plLoginDialog::StartLogin()
{
fLoginBtn.SetEnabled(false);
std::string value = fLobbyList.GetValue();
if (value.length()==0)
{
fLobbyList.SetCurrent(0);
fLobbyList.SetValue(MakeSafeLobbyServerName(fLobbyList.GetValue()).c_str());
SelectedLobbyChanged();
}
fStatusBar.SetText(L"Authenticating...");
// fMainDialog->InitNetCore();
// fMainDialog->fLoginState = kLoggingIn;
// fAccountTab.UpdateCtrls();
// fPlayerTab.SetPlayerVault(nil);
SendAuthenticateHello();
}
void plLoginDialog::CompleteLogin()
{
if ( Handle() )
fLoginBtn.SetEnabled(true);
KillTimer(*this,kAuthTimedOut);
fStatusBar.SetText(L"");
if (IsNetworkPlayEnabled())
NotifyConnected();
else
NotifyDisconnected();
EndDialogTrue();
GetClientManifests();
UpdateAllCtrls();
}
void plLoginDialog::FailLogin(const char* str)
{
fLoginBtn.SetEnabled(true);
KillTimer(*this, kAuthTimedOut);
fStatusBar.SetText(L"");
hsMessageBoxWithOwner((void*)*this,str,"Error",hsMessageBoxNormal);
Logout();
}
void plLoginDialog::FailLogin(int reasonCode)
{
std::string str = xtl::format("Failed to login to lobby server %s: %s",
fLobbyVal.GetValue().c_str(), plNetMsgAccountAuthenticated::GetAuthResultString(reasonCode));
FailLogin(str.c_str());
}
void plLoginDialog::TimeoutLogin()
{
fLoginBtn.SetEnabled(true);
wchar_t *wStr = hsStringToWString(xtl::format("Timed out logging into lobby server %s.", fLobbyVal.GetValue().c_str()).c_str());
fStatusBar.SetText(wStr);
delete [] wStr;
KillTimer(*this, kAuthTimedOut);
Logout();
}
void plLoginDialog::Logout()
{
KillTimer(*this, kAuthTimedOut);
SendLobbyLeave();
//fMainDialog->ShutdownNetCore();
NotifyDisconnected();
}
void plLoginDialog::SendLobbyLeave()
{
plNetMsgLeave msg;
msg.SetReason( plPlayerUpdateConstants::kPlayerQuitting );
SendMsg(&msg,plNetAddress(fLobbyVal.GetValue().c_str(),plNetLobbyServerConstants::GetPort()));
RemoveLobbyPeer();
}
#define MSG_TIMEOUT 8000
#include "../pnNetCommon/plNetAddress.h"
void plLoginDialog::SendAuthenticateHello()
{
SetTimer(*this,kAuthTimedOut,MSG_TIMEOUT,nil);
plNetMsgAuthenticateHello msg;
msg.SetAccountName(fAccountNameVal.GetValue().c_str());
msg.SetMaxPacketSize(GetPacketSize());
SendMsg(&msg,plNetAddress(fLobbyVal.GetValue().c_str(),plNetLobbyServerConstants::GetPort()));
}
void plLoginDialog::SendAuthenticateResponse()
{
SetTimer(*this,kAuthTimedOut,MSG_TIMEOUT,nil);
plNetMsgAuthenticateResponse msg;
msg.SetResponse(fChallengeResponse.GetResponse());
SendMsg(&msg,plNetAddress(fLobbyVal.GetValue().c_str(),plNetLobbyServerConstants::GetPort()));
}
int plLoginDialog::CallDefaultProc( unsigned int message, unsigned int wParam, LONG lParam )
{
switch (message)
{
case WM_TIMER:
switch (wParam)
{
case kAuthTimedOut:
TimeoutLogin();
break;
}
}
return 0;
}
/////////////////////////////////////////////////////////////////////////////
#ifndef PLASMA_EXTERNAL_RELEASE
#define kServerInfoFilename "server_info.html"
static void StringToLines(std::string str, plStringList & lines, bool includeBlankLines=true)
{
xtl::trim(str);
if (str.length()==0)
return;
str.append("\n");
int pos;
while ((pos=str.find("\n"))!=std::string::npos)
{
std::string line = xtl::trim(str.substr(0,pos).c_str());
str.erase(0,pos+1);
if (includeBlankLines || (!includeBlankLines && line.length()>0))
lines.push_back(line);
}
}
static void GetPathElements(std::string filename, plStringList & lst)
{
int pos;
while ((pos=filename.find_first_of("\\/"))!=std::string::npos)
{
std::string element = filename.substr(0,pos);
filename.erase(0,pos+1);
if (element.length())
lst.push_back(element);
}
}
struct SDLInfoParser
{
std::string fFilename;
std::string fDescriptorName;
int fVersion;
void ParseString( const char * s )
{
std::string str = s;
int p = str.find(",");
fFilename = str.substr(0,p);
str.erase(0,p+1);
p = str.find(",");
fDescriptorName = str.substr(0,p);
str.erase(0,p+1);
fVersion = atoi(str.c_str());
p = fFilename.find_last_of("\\");
if( p!=std::string::npos )
fFilename.erase(0,p+1);
p = fFilename.find_last_of("/");
if( p!=std::string::npos )
fFilename.erase(0,p+1);
}
};
struct DescriptorReport
{
int fServerVersion; // 0 means the descriptor is missing
int fClientVersion;
DescriptorReport(): fServerVersion(0),fClientVersion(0){}
};
#define kStyleSheet \
"<style>" \
"BODY {" \
" font-size : 10pt;" \
" font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;" \
"}" \
"TD {" \
" font-size : 10pt;" \
" font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;" \
"}" \
"PRE {" \
" margin-top : 0px;" \
"}" \
".SDLFile { background-color : #FFFF99; }" \
".Title {" \
" font-weight : bold;" \
" text-align : center;" \
" text-decoration : underline;" \
"}" \
".SectionHeader {" \
" margin-bottom : 0px;" \
"}" \
"</style>"
void plLoginDialog::ServerQueryBtnClicked()
{
hsUNIXStream file;
file.Open( kServerInfoFilename, "wt" );
file.WriteString("<html>"kStyleSheet"<body>\n");
try
{
typedef std::map< std::string, DescriptorReport > DescriptorReports;
typedef std::map< std::string, DescriptorReports > FileReports;
FileReports fileReports;
/*plURL url;
plHttpRequest request;
plHttpResponse response;
// read server build date etc.
url.SetHost( fLobbyList.GetValue().c_str() );
url.SetPort( 7676 );
url.SetFile( "VersionInfo" );
request.SetUrl( url );
request.SetType( plHttpRequest::kGet );
if ( !request.MakeRequest( response ) )
throw 0;
file.WriteString("<h3 class=SectionHeader>Server Info</h3>\n" );
file.WriteString( "<pre>\n" );
file.WriteString( response.c_str() );
file.WriteString( "</pre>\n" );
// get server's SDL info
url.SetFile( "SDLInfo" );
request.SetUrl( url );
if ( !request.MakeRequest( response ) )
throw 0;
plStringList lines;
StringToLines( response, lines, false );
SDLInfoParser parser;
{for ( plStringList::iterator ii=lines.begin(); ii!=lines.end(); ++ii )
{
parser.ParseString( (*ii).c_str() );
fileReports[ parser.fFilename ][ parser.fDescriptorName ].fServerVersion = parser.fVersion;
}}
// get client's SDL info
plSDLMgr::GetInstance()->DeInit();
plSDLMgr::GetInstance()->SetSDLDir( "SDL" );
plSDLMgr::GetInstance()->Init();
const plSDL::DescriptorList * cds = plSDLMgr::GetInstance()->GetDescriptors();
{for ( plSDL::DescriptorList::const_iterator ii=cds->begin(); ii!=cds->end(); ++ii )
{
plStateDescriptor * descriptor = *ii;
std::string filename = descriptor->GetFilename();
int p = filename.find_last_of(PATH_SEPARATOR_STR);
if( p!=std::string::npos )
filename.erase(0,p+1);
fileReports[ filename ][ descriptor->GetName() ].fClientVersion = descriptor->GetVersion();
}}
// write SDL comparison report
file.WriteString("<h3 class=SectionHeader>SDL File Comparison</h3>\n" );
file.WriteString("Version=0 means descriptor doesn't exist.<br><br>\n" );
file.WriteString( "<table><tr class=Title><td>File</td><td>Server Version</td><td>Client Version</td><td>Status</td></tr>\n" );
{ for ( FileReports::iterator ii=fileReports.begin(); ii!=fileReports.end(); ++ii )
{
std::string sdlFilename = ii->first;
DescriptorReports & descrReports = ii->second;
file.WriteFmt( "<tr><td colspan=5 class=SDLFile>%s</td></tr>\n", sdlFilename.c_str() );
{ for ( DescriptorReports::iterator jj=descrReports.begin(); jj!=descrReports.end(); ++jj )
{
#define kSDLBad "<font color=red><b>Bad</b></font>"
#define kSDLOk "<font color=green><b>Ok</b></font>"
std::string descrName = jj->first;
DescriptorReport & descrReport = jj->second;
file.WriteFmt( "<tr><td>&nbsp;&nbsp;&nbsp;%s</td><td align=right>%d</td><td align=right>%d</td><td align=center>%s</td></tr>\n",
descrName.c_str(), descrReport.fServerVersion, descrReport.fClientVersion,
( descrReport.fServerVersion==descrReport.fClientVersion ) ? kSDLOk:kSDLBad );
}}
}}
file.WriteString("</table>\n");*/
}
catch (...)
{
file.WriteString("<p>An error occurred while querying the server.\n");
}
file.WriteString("</body></html>\n");
file.Close();
ShellExecute( nil, nil, kServerInfoFilename, nil, nil, SW_SHOWNORMAL );
}
#endif
/////////////////////////////////////////////////////////////////////////////

138
Sources/Plasma/FeatureLib/pfLoginDialog/plLoginDialog.h

@ -1,138 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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 plLoginDialog_h_inc
#define plLoginDialog_h_inc
#include "plWndCtrls/plWndCtrls.h"
// #include "plEncryption/plChallengeResponse.h"
#include "pnNetCommon/plNetAddress.h"
class plMainDialog;
class plNetMsgAuthenticateChallenge;
class plNetMsgAccountAuthenticated;
class plNetMessage;
class plLoginDialog : public plDialog
{
HWND fParentWnd;
public:
DECLARE_WINDOWCLASS(plLoginDialog, plDialog);
plLoginDialog( HWND parentWnd=nil );
bool Login();
void OnInitDialog();
void HandleAuthChallenge(plNetMsgAuthenticateChallenge * msg);
void HandleAccountAuthenticated(plNetMsgAccountAuthenticated * msg);
void StartLogin();
void CompleteLogin();
void FailLogin(int reasonCode);
void FailLogin(const char* str);
void TimeoutLogin();
void Logout();
void SendAuthenticateHello();
void SendAuthenticateResponse();
bool IsNetworkPlayDisabled();
bool IsNetworkPlayEnabled();
// void UpdateCtrls();
void SelectedLobbyChanged();
void SelectedLobbyTextEdited();
void OnLobbyListLostFocus();
void SendLobbyLeave();
bool RefreshLobbyList();
bool GetCancelled() const { return fCancelled; }
bool GetRememberPassword() const { return fRememberPassword.IsChecked(); }
// callbacks
virtual void GetLobbyList(plStringList& lobbies) = 0;
virtual bool AllowSinglePlayerLobby() { return true; } // checked in non external-release build
virtual void SetDataServerUserName(bool local, const char* s) {}
virtual void SetDataServerPassword(bool local, const char* s) {}
virtual void RemoveLobbyPeer() {}
virtual void NotifyConnected() {}
virtual void NotifyDisconnected() {}
virtual void GetClientManifests() {}
virtual void UpdateAllCtrls() {}
virtual unsigned int GetPacketSize() = 0;
virtual bool SendMsg(plNetMessage * msg, plNetAddress & addr) = 0;
virtual void OnLoginClicked() {}
std::string MakeSafeLobbyServerName(const std::string & value);
int CallDefaultProc( unsigned int message, unsigned int wParam, LONG lParam );
plEdit fAccountName;
plEdit fPassword;
plChallengeResponse fChallengeResponse;
plComboBox fLobbyList;
plLabel fLobbyText;
plCheckBox fRememberPassword;
#ifndef PLASMA_EXTERNAL_RELEASE
plButton fServerQueryBtn;
void ServerQueryBtnClicked();
#endif
plConfigValue fAccountNameVal;
plConfigValue fPasswordVal; // the pwd as a MD5 hash
plConfigValue fRememberPasswordVal; // the checkbox state
plConfigValue fPasswordLen; // the length of the original pwd
plConfigValue fLobbyVal;
bool fAutoLogin;
plStatusBar fStatusBar;
protected:
int ICheckNetVersion(plNetMsgAuthenticateChallenge * msg);
void ILogin();
void IExit();
void IOnRememberPwdChanged();
bool fCancelled;
plButton fLoginBtn;
plButton fCancelBtn;
};
#endif // plLoginDialog_h_inc

24
Sources/Plasma/FeatureLib/pfLoginDialog/resource.h

@ -1,24 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by pfLoginDialog.rc
//
#define IDD_DIALOG_LOGIN 326
#define IDC_LOGIN_USERNAME 3029
#define IDC_LOGIN_PASSWORD 3031
#define IDC_LOGIN_LOBBYLIST 3033
#define IDC_LOGIN_STATIC_SERVER 3127
#define IDC_LOGIN_LOGIN 3130
#define IDC_LOGIN_CANCEL 3131
#define IDC_SERVER_QUERY_BTN 3132
#define IDC_REMEMBER_PASSWORD 3133
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 327
#define _APS_NEXT_COMMAND_VALUE 42001
#define _APS_NEXT_CONTROL_VALUE 3134
#define _APS_NEXT_SYMED_VALUE 327
#endif
#endif

4
Sources/Plasma/PubUtilLib/CMakeLists.txt

@ -10,14 +10,10 @@ add_subdirectory(plClientResMgr)
add_subdirectory(plClipboard)
add_subdirectory(plCompression)
add_subdirectory(plContainer)
#add_subdirectory(plDeviceSelector) # Not being used by any current slns
add_subdirectory(plDrawable)
add_subdirectory(plFile)
#add_subdirectory(plGClip) # Not being used by any current slns
#add_subdirectory(plGeometry) # Not being used by any current slns
add_subdirectory(plGImage)
add_subdirectory(plGLight)
#add_subdirectory(plGRenderProcs) # Not being used by any current slns
add_subdirectory(plInputCore)
add_subdirectory(plInterp)
add_subdirectory(plIntersect)

587
Sources/Plasma/PubUtilLib/plDeviceSelector/plDeviceSelector.cpp

@ -1,587 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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 "plDeviceSelector.h"
#include "hsStream.h"
#include "hsUtils.h"
#include <algorithm>
DeviceSelector::DeviceSelector() :
fSelDevType(hsG3DDeviceSelector::kDevTypeUnknown),
fSelDev(0),
fSelMode(0),
fDevDesc(0),
fModeDesc(0),
fPerformance(0),
fFilterBPP(0),
fFilterWidth(0),
fFilterHeight(0),
fWindowed(false)
{
memset(fStr, 0x00, sizeof(fStr));
}
const char *DeviceSelector::GetErrorString( void )
{
return fSelector.GetErrorString();
}
hsBool DeviceSelector::Enumerate(HWND hWnd, hsBool expertMode )
{
plDemoDebugFile::Enable( true ); /// ALWAYS enable (well, for now at least)
if( !fSelector.Init() )
return false;
fSelector.Enumerate(hWnd);
// 11.25.2000 mcn - Now we are tough if we're not in expert mode
fSelector.RemoveUnusableDevModes( !expertMode );
// Sort the modes
hsTArray<hsG3DDeviceRecord> &recs = fSelector.GetDeviceRecords();
for (int32_t i = 0; i < recs.Count(); i++)
{
hsTArray<hsG3DDeviceMode> &modes = recs[i].GetModes();
std::sort(modes.FirstIter(), modes.StopIter());
}
IRefreshFilter();
return true;
}
void DeviceSelector::SetModeFilter( int bitDepth, int minWidth, int minHeight )
{
fFilterBPP = bitDepth;
fFilterWidth = minWidth;
fFilterHeight = minHeight;
IRefreshFilter();
}
void DeviceSelector::IRefreshFilter( void )
{
if (fSelDev >= fRecords.Count() )
return;
// Make sure to preserve fSelMode if possible
const hsG3DDeviceMode *oldMode = nil;
if( fSelMode < fFilteredModes.GetCount() && fFilteredModes[ fSelMode ]<fSelRec.GetModes().GetCount() )
oldMode = fSelRec.GetMode( fFilteredModes[ fSelMode ] );
fFilteredModes.Reset();
int i;
for( i = 0; i < fRecords[ fSelDev ].GetModes().Count(); i++ )
{
hsG3DDeviceMode* mode = fRecords[ fSelDev ].GetMode( i );
// Filter out modes we don't want listed
if( fFilterBPP != 0 && fFilterBPP != mode->GetColorDepth() )
continue;
if( mode->GetWidth() < fFilterWidth || mode->GetHeight() < fFilterHeight )
continue;
// Remove any non 4:3 modes
bool goodAspectRatio = (mode->GetWidth() / 4 == mode->GetHeight() / 3) &&
(mode->GetWidth() % 4 == 0) &&
(mode->GetHeight() % 3 == 0);
if (!goodAspectRatio && !(mode->GetWidth() == 1280 && mode->GetHeight() == 1024))
{
continue;
}
// Add the remaining to our filter index
fFilteredModes.Append( i );
}
if( oldMode != nil )
{
fSelMode = IFindFiltered( GetModeNum( oldMode ) );
if( fSelMode == -1 )
{
// Try w/o bpp
fSelMode = IFindFiltered( IGetModeNumNoBPP( oldMode ) );
if( fSelMode == -1 )
fSelMode = 0;
}
}
else
fSelMode = 0;
}
int DeviceSelector::IFindFiltered( int realIndex )
{
int idx = fFilteredModes.Find( realIndex );
if( idx == fFilteredModes.kMissingIndex )
return -1;
return idx;
}
hsBool DeviceSelector::CheckDeviceType(uint32_t type)
{
hsTArray<hsG3DDeviceRecord>& records = fSelector.GetDeviceRecords();
for (int32_t i = 0; i < records.Count(); i++)
{
if (type == records[i].GetG3DDeviceType())
return true;
}
return false;
}
hsBool DeviceSelector::IsDirect3DAvailable()
{
return CheckDeviceType(hsG3DDeviceSelector::kDevTypeDirect3D);
}
hsBool DeviceSelector::IsDirect3DTnLAvailable()
{
return CheckDeviceType(hsG3DDeviceSelector::kDevTypeDirect3DTnL);
}
hsBool DeviceSelector::IsGlideAvailable()
{
return CheckDeviceType(hsG3DDeviceSelector::kDevTypeGlide);
}
hsBool DeviceSelector::IsOpenGLAvailable()
{
return CheckDeviceType(hsG3DDeviceSelector::kDevTypeOpenGL);
}
void DeviceSelector::SetDirect3D()
{
SetDeviceType(hsG3DDeviceSelector::kDevTypeDirect3D);
}
void DeviceSelector::SetDirect3DTnL()
{
SetDeviceType(hsG3DDeviceSelector::kDevTypeDirect3DTnL);
}
void DeviceSelector::SetGlide()
{
SetDeviceType(hsG3DDeviceSelector::kDevTypeGlide);
}
void DeviceSelector::SetOpenGL()
{
SetDeviceType(hsG3DDeviceSelector::kDevTypeOpenGL);
}
void DeviceSelector::SetDeviceType (uint32_t type)
{
int32_t i;
for(i = 0; i < fRecords.GetCount(); i++)
fRecords[i].Clear();
fRecords.Reset();
hsTArray<hsG3DDeviceRecord>& records = fSelector.GetDeviceRecords();
for (i = 0; i < records.Count(); i++)
{
if (records[i].GetG3DDeviceType() == type)
fRecords.Push(records[i]);
}
fSelDevType = type;
fSelDev = 0;
fDevDesc = 0;
fModeDesc = 0;
IRefreshFilter();
}
hsBool DeviceSelector::IsDirect3D()
{
if (fSelDevType == hsG3DDeviceSelector::kDevTypeDirect3D)
return true;
else
return false;
}
hsBool DeviceSelector::IsDirect3DTnL()
{
return ( fSelDevType == hsG3DDeviceSelector::kDevTypeDirect3DTnL ) ? true : false;
}
hsBool DeviceSelector::IsGlide()
{
if (fSelDevType == hsG3DDeviceSelector::kDevTypeGlide)
return true;
else
return false;
}
hsBool DeviceSelector::IsOpenGL()
{
if (fSelDevType == hsG3DDeviceSelector::kDevTypeOpenGL)
return true;
else
return false;
}
hsBool DeviceSelector::SetDevice(uint32_t index)
{
if (index < fRecords.Count())
{
fSelDev = index;
fSelMode = 0;
fSelRec = fRecords[index];
fSelRec.SetMaxAnisotropicSamples(0);
IRefreshFilter();
return true;
}
return false;
}
hsBool DeviceSelector::SetMode(uint32_t index)
{
if (fSelDev >= fRecords.Count())
return false;
if (index < fFilteredModes.GetCount())
{
fSelMode = index;
return true;
}
return false;
}
char* DeviceSelector::GetDeviceDescription()
{
if (fDevDesc == fRecords.Count())
{
fDevDesc = 0;
return nil;
}
sprintf(fStr, "%s [%s]", fRecords[fDevDesc].GetDriverDesc(), fRecords[fDevDesc].GetDeviceDesc());
fDevDesc++;
return fStr;
}
char* DeviceSelector::GetModeDescription( void )
{
if (fSelDev >= fRecords.Count() )
return nil;
if (fModeDesc == fFilteredModes.GetCount())
{
fModeDesc = 0;
return nil;
}
hsG3DDeviceMode* mode = fRecords[fSelDev].GetMode( fFilteredModes[ fModeDesc ] );
fModeDesc++;
if( fFilterBPP != 0 )
sprintf( fStr, "%ux%u", mode->GetWidth(), mode->GetHeight() );
else
sprintf(fStr, "%ux%u %u bit", mode->GetWidth(), mode->GetHeight(), mode->GetColorDepth());
return fStr;
}
uint32_t DeviceSelector::GetNumModes()
{
return fFilteredModes.GetCount();
}
void DeviceSelector::GetMode(uint32_t i, int& width, int& height, int& depth)
{
if (i >= fFilteredModes.GetCount())
return;
hsG3DDeviceMode* mode = fRecords[fSelDev].GetMode(fFilteredModes[i]);
width = mode->GetWidth();
height = mode->GetHeight();
depth = mode->GetColorDepth();
}
hsBool DeviceSelector::SetDefault()
{
hsG3DDeviceModeRecord dmr;
if (fSelector.GetDefault(&dmr))
{
SetDeviceType(dmr.GetDevice()->GetG3DDeviceType());
fSelDev = GetDeviceNum(dmr.GetDevice());
fSelMode = IFindFiltered( GetModeNum(dmr.GetMode()) );
fSelRec = fRecords[fSelDev];
fSelRec.SetMaxAnisotropicSamples( 0 ); // Also off unless explicitly requested
// Set a default detail level based on the available memory
if (hsMemorySpec() == kBlows)
fPerformance = 25;
else
fPerformance = 100;
IRefreshFilter();
return true;
}
return false;
}
hsBool DeviceSelector::Save()
{
hsUNIXStream stream;
if (!stream.Open(DEV_MODE_DAT, "wb"))
return false;
hsG3DDeviceRecord selRec = fSelRec;
hsG3DDeviceMode selMode = *(selRec.GetMode( fFilteredModes[ fSelMode ] ));
selRec.ClearModes();
selRec.Write(&stream);
if (fWindowed)
selMode.SetColorDepth(0);
selMode.Write(&stream);
stream.WriteSwap16(fPerformance);
stream.Close();
return true;
}
hsBool DeviceSelector::Load()
{
hsUNIXStream stream;
if (!stream.Open(DEV_MODE_DAT, "rb"))
return false;
hsG3DDeviceRecord LoadRec; // Device copy for reading/writing
hsG3DDeviceMode LoadMode; // Modes copy for reading/writing
LoadRec.Read(&stream);
if (LoadRec.IsInvalid())
{
stream.Close();
return false;
}
LoadMode.Read(&stream);
fPerformance = stream.ReadSwap16();
stream.Close();
// If selected device is available use it, otherwise return false
if ((LoadRec.GetG3DDeviceType() == hsG3DDeviceSelector::kDevTypeDirect3D) && IsDirect3DAvailable())
SetDirect3D();
else if ((LoadRec.GetG3DDeviceType() == hsG3DDeviceSelector::kDevTypeDirect3DTnL) && IsDirect3DTnLAvailable())
SetDirect3DTnL();
else if ((LoadRec.GetG3DDeviceType() == hsG3DDeviceSelector::kDevTypeGlide) && IsGlideAvailable())
SetGlide();
else
return false;
////////////////////////////////////////////////////////////////////////////
// Attempt to match the saved device and mode to the ones that are currently
// available.
////////////////////////////////////////////////////////////////////////////
int num = GetDeviceNum(&LoadRec);
if (num == -1)
return false;
SetDevice(num);
// Copy the flags
fSelRec.SetCap(hsG3DDeviceSelector::kCapsCompressTextures,
LoadRec.GetCap(hsG3DDeviceSelector::kCapsCompressTextures));
fSelRec.SetAASetting( LoadRec.GetAASetting() );
fSelRec.SetMaxAnisotropicSamples( LoadRec.GetMaxAnisotropicSamples() );
if (LoadMode.GetColorDepth() == 0)
{
fWindowed = true;
LoadMode.SetColorDepth(32);
}
num = GetModeNum(&LoadMode);
if (num == -1)
return false;
SetMode(IFindFiltered(num));
return true;
}
int DeviceSelector::GetDeviceNum(const hsG3DDeviceRecord *pLoadRec)
{
hsTArray<hsG3DDeviceRecord>& records = fRecords;
for (int i = 0; i < records.Count(); i++)
{
if (!strcmp(records[i].GetDriverDesc(), pLoadRec->GetDriverDesc()) &&
!strcmp(records[i].GetDriverName(), pLoadRec->GetDriverName()) &&
!strcmp(records[i].GetDriverVersion(), pLoadRec->GetDriverVersion()) &&
!strcmp(records[i].GetDeviceDesc(), pLoadRec->GetDeviceDesc()))
return i;
}
return -1;
}
int DeviceSelector::IGetModeNumNoBPP( const hsG3DDeviceMode *pLoadMode )
{
hsTArray<hsG3DDeviceMode>& modes = fRecords[fSelDev].GetModes();
for (int i = 0; i < modes.Count(); i++)
{
if ((modes[i].GetWidth() == pLoadMode->GetWidth()) &&
(modes[i].GetHeight() == pLoadMode->GetHeight())
)
{
if( fFilteredModes.Find( i ) != fFilteredModes.kMissingIndex )
{
#ifndef M3DRELEASE
if (pLoadMode->GetColorDepth() == 0)
fSelRec.GetMode( i )->SetColorDepth(0);
#endif
return i;
}
}
}
return -1;
}
int DeviceSelector::GetModeNum(const hsG3DDeviceMode *pLoadMode)
{
hsTArray<hsG3DDeviceMode>& modes = fRecords[fSelDev].GetModes();
for (int i = 0; i < modes.Count(); i++)
{
if ((modes[i].GetWidth() == pLoadMode->GetWidth()) &&
(modes[i].GetHeight() == pLoadMode->GetHeight()) &&
(modes[i].GetColorDepth() == pLoadMode->GetColorDepth()))
{
return i;
}
}
return -1;
}
uint8_t DeviceSelector::CanAntiAlias()
{
hsG3DDeviceMode *mode = fRecords[ fSelDev ].GetMode( fFilteredModes[ fSelMode ] );
return mode->GetNumFSAATypes();
}
uint8_t DeviceSelector::IsAntiAliased()
{
return fSelRec.GetAASetting();
}
void DeviceSelector::SetAntiAlias(uint8_t numSamples)
{
fSelRec.SetAASetting( numSamples );
}
uint8_t DeviceSelector::CanAnisotropicFilter()
{
uint8_t hi = fRecords[ fSelDev ].GetMaxAnisotropicSamples();
if( hi > 1 )
return hi;
return 0;
}
uint8_t DeviceSelector::GetAnisotropicLevel()
{
return fSelRec.GetMaxAnisotropicSamples();
}
void DeviceSelector::SetAnisotropicLevel( uint8_t level )
{
fSelRec.SetMaxAnisotropicSamples( level );
}
bool DeviceSelector::CanWindow ()
{
return !fSelRec.GetCap(hsG3DDeviceSelector::kCapsNoWindow);
}
bool DeviceSelector::IsWindowed()
{
return fWindowed;
}
void DeviceSelector::SetWindowed(bool state)
{
fWindowed = state;
}
hsBool DeviceSelector::CanCompress ()
{
return fRecords[fSelDev].GetCap(hsG3DDeviceSelector::kCapsCompressTextures);
}
hsBool DeviceSelector::IsCompressed()
{
return fSelRec.GetCap(hsG3DDeviceSelector::kCapsCompressTextures);
}
void DeviceSelector::SetCompressed(hsBool state)
{
fSelRec.SetCap(hsG3DDeviceSelector::kCapsCompressTextures, state);
}
bool DeviceSelector::GetCap(uint32_t cap)
{
return fSelRec.GetCap(cap) != 0;
}

160
Sources/Plasma/PubUtilLib/plDeviceSelector/plDeviceSelector.h

@ -1,160 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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 DEVICESELECTOR_H
#define DEVICESELECTOR_H
#include "HeadSpin.h"
//#include "plRender.h"
#include "../../PubUtilLib/plPipeline/hsG3DDeviceSelector.h"
#define DEV_MODE_DAT "dev_mode.dat"
//
// A wrapper class to simplify hsG3DDeviceSelector.
// Make sure to call Enumerate before doing anything else.
//
class DeviceSelector
{
protected:
uint32_t fSelDevType; // Current type of driver. Set by the SetDirect3D/Glide/OpenGL functions
uint32_t fSelDev; // Index of selected device. Set by SetDevice() or
uint32_t fSelMode; // Index of selected mode for current device
int fDevDesc; // Used by GetDeviceDescription() to store index of current device
int fModeDesc; // Used by GetModeDescription() to store index of current mode
char fStr[1024]; // Used to return text
uint16_t fPerformance; // Performance level (0-100)
int fFilterBPP, fFilterWidth, fFilterHeight;
bool fWindowed;
hsG3DDeviceSelector fSelector;
hsTArray<hsG3DDeviceRecord> fRecords; // Copy of all records for the current device type
hsG3DDeviceRecord fSelRec; // Device copy for reading/writing
hsTArray<int> fFilteredModes;
void IRefreshFilter( void );
int IFindFiltered( int realIndex );
int IGetModeNumNoBPP( const hsG3DDeviceMode *pLoadMode ); // Returns index of passed in mode
public:
DeviceSelector();
hsBool Enumerate(HWND hWnd, hsBool expertMode); // Enumerates all devices
const char *GetErrorString( void );
// Determines if any devices of the specified type are available
hsBool IsDirect3DAvailable();
hsBool IsGlideAvailable();
hsBool IsOpenGLAvailable();
hsBool IsDirect3DTnLAvailable();
// Set current device type
void SetDirect3D();
void SetGlide();
void SetOpenGL();
void SetDirect3DTnL();
// Returns true if current device is of the specified type
hsBool IsDirect3D();
hsBool IsDirect3DTnL();
hsBool IsGlide();
hsBool IsOpenGL();
// Gets and sets the current device or mode.
uint32_t GetSelectedDevice() { return fSelDev; }
uint32_t GetSelectedMode() { return fSelMode; }
hsBool SetDevice(uint32_t index);
hsBool SetMode(uint32_t index);
// Returns the device or mode descriptions. Call repeatedly until nil is returned.
char* GetDeviceDescription();
char* GetModeDescription( void );
uint32_t GetNumModes();
void GetMode(uint32_t i, int& width, int& height, int& depth);
void SetModeFilter( int bitDepth = 0, int minWidth = 0, int minHeight = 0 );
void SetPerformance (uint16_t value) { fPerformance = value; }
uint16_t GetPerformance () { return fPerformance; }
// Returns max number of samples allowed for AA
uint8_t CanAntiAlias ();
// Returns current # of samples selected for AA, 0 if none
uint8_t IsAntiAliased ();
void SetAntiAlias (uint8_t numSamples);
uint8_t CanAnisotropicFilter();
uint8_t GetAnisotropicLevel();
void SetAnisotropicLevel( uint8_t level );
bool CanWindow();
bool IsWindowed();
void SetWindowed(bool state);
hsBool CanCompress ();
hsBool IsCompressed ();
void SetCompressed (hsBool state);
// Caps from hsG3DDeviceSelector
bool GetCap(uint32_t cap);
// Save and load
hsBool Save(); // Returns false if output file can't be opened
hsBool Load(); // Returns false if input file can't be opened
hsBool SetDefault(); // Returns false if no suitable renderers are found
protected:
hsBool CheckDeviceType(uint32_t type); // Used by the Is*Available() functions
void SetDeviceType(uint32_t type); // Used by SetDirect3D/Glide/OpenGL
// Helpers for LoadDeviceMode()
int GetDeviceNum(const hsG3DDeviceRecord *pLoadRec); // Returns index of passed in device
int GetModeNum(const hsG3DDeviceMode *pLoadMode); // Returns index of passed in mode
};
#endif //DEVICESELECTOR_H

1
Sources/Plasma/PubUtilLib/plGClip/placeholder.txt

@ -1 +0,0 @@
What do you see? An empty folder.

250
Sources/Plasma/PubUtilLib/plGRenderProcs/hsGRenderProcs.cpp

@ -1,250 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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;
}

218
Sources/Plasma/PubUtilLib/plGRenderProcs/hsGRenderProcs.h

@ -1,218 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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_t fLinkCount;
hsGRenderProcs* fNext;
hsGRenderProcs** fBack;
hsGRenderProcs** IOneBeforeMe(hsGRenderProcs** base);
void IInsert(hsGRenderProcs** beforeMe);
void IDetach();
protected:
uint32_t 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_t 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_t GetFlags() { return fFlags; }
void SetFlags(uint32_t f) { fFlags = f; }
CLASSNAME_REGISTER( hsGRenderProcs );
GETINTERFACE_ANY( hsGRenderProcs, plCreatable );
};
#endif // hsGRenderProcs_inc

234
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxAngleFade.cpp

@ -1,234 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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_t 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);
}
}

90
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxAngleFade.h

@ -1,90 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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

331
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxDistFade.cpp

@ -1,331 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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_t 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);
}
}

107
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxDistFade.h

@ -1,107 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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

292
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxDistShade.cpp

@ -1,292 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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_t 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 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);
}
}

97
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxDistShade.h

@ -1,97 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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

242
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxGlobalShade.cpp

@ -1,242 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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_t 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
}

120
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxGlobalShade.h

@ -1,120 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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_t 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_t f) { fGSFlags &= ~kSourceMask; fGSFlags |= f; }
uint32_t 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

81
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxIntenseAlpha.cpp

@ -1,81 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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);
}

82
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxIntenseAlpha.h

@ -1,82 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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

320
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxObjDistFade.cpp

@ -1,320 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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_t 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);
}
}

116
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxObjDistFade.h

@ -1,116 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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_t 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

217
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxObjDistShade.cpp

@ -1,217 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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_t 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);
}
}

98
Sources/Plasma/PubUtilLib/plGRenderProcs/hsSfxObjDistShade.h

@ -1,98 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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_t 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

80
Sources/Plasma/PubUtilLib/plGRenderProcs/plGRenderProcsCreatable.h

@ -1,80 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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

763
Sources/Plasma/PubUtilLib/plGeometry/hsOscillator.cpp

@ -1,763 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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 "hsStream.h"
#include "hsOscillator.h"
#include "../plMath/hsFastMath.h"
#include "hsGTriMesh.h"
#include "hsTriangle3.h"
#include "../plPipeline/plPipeline.h"
#if defined(__MWERKS__) && !defined(HS_DEBUGGING)
#pragma optimization_level 0
#endif
static hsScalar rnd0_1()
{
return hsScalar(rand()) / hsScalar(RAND_MAX);
}
void hsWave::Save(hsStream* s, hsScalar secs)
{
fWorldCenter.Write(s);
s->WriteSwapScalar(fWorldFrequency);
s->WriteSwapScalar(fWorldAmplitude);
s->WriteSwapScalar(fPhase);
s->WriteSwapScalar(fRate);
s->WriteSwapScalar(secs - fStartSecs);
s->WriteSwapScalar(fSecsToLive);
}
void hsWave::Load(hsStream* s, hsScalar secs)
{
fWorldCenter.Read(s);
fWorldFrequency = s->ReadSwapScalar();
fWorldAmplitude = s->ReadSwapScalar();
fPhase = s->ReadSwapScalar();
fRate = s->ReadSwapScalar();
fStartSecs = s->ReadSwapScalar();
fStartSecs = secs - fStartSecs;
fSecsToLive = s->ReadSwapScalar();
}
void hsWave::Init(hsScalar secs, hsPoint3& center, hsScalar per, hsScalar amp, hsScalar rate, hsScalar life, hsBool32 attenOut)
{
fStartSecs = secs;
fWorldCenter = center;
fWorldFrequency = hsScalarInvert(per);
fWorldAmplitude = amp;
fRate = rate;
fSecsToLive = life;
AttenuateOut(attenOut);
}
hsBool32 hsWave::IsSpent(hsScalar secs) const
{
return secs - fStartSecs > fSecsToLive;
}
void hsWave::Accumulate(const hsPoint3& pos, const hsVector3& localZ, hsVector3& accum, hsVector3& accumNorm) const
{
hsVector3 del(&pos, &fLocalCenter);
hsScalar dot = del.InnerProduct(localZ);
dot *= -2.f;
del += localZ * dot;
hsScalar dist = del.MagnitudeSquared();
dist = hsFastMath::InvSqrtAppr(dist);
del *= dist;
dist = hsScalarInvert(dist);
hsScalar ampl = fLocalAmplitude;
if( fAttenuateOutScale > 0 )
{
if( dist > fInnerRadius )
{
if( dist > fOuterRadius )
return;
ampl *= fOuterRadius - dist;
ampl *= fAttenuateOutScale;
}
}
dist *= fLocalFrequency;
dist += fPhase;
hsScalar s, c;
hsFastMath::SinCosAppr(dist, s, c);
s *= ampl;
s += ampl;
c *= ampl * fLocalFrequency;
// accum += s * localZ;
accum.fZ += s / localZ.fZ;
hsVector3 norm;
norm = localZ;
norm += del * -c;
accumNorm += norm;
return;
}
void hsWave::Update(hsScalar secs, const hsMatrix44& l2w, const hsMatrix44& w2l)
{
if( l2w.fFlags & hsMatrix44::kIsIdent )
{
fLocalCenter = fWorldCenter;
fLocalFrequency = fWorldFrequency;
fLocalAmplitude = fWorldAmplitude;
}
else
{
hsVector3 ax;
ax.Set(w2l.fMap[0][2], w2l.fMap[1][2], w2l.fMap[2][2]);
hsScalar ooScale = ax.MagnitudeSquared();
ooScale = hsFastMath::InvSqrtAppr(ooScale);
fLocalCenter = w2l * fWorldCenter;
fLocalFrequency = fWorldFrequency * ooScale;
hsScalar scale = 1.f / ooScale;
fLocalAmplitude = fWorldAmplitude * scale;
}
fLocalAmplitude *= AgeScale(secs);
if( fAttenuateOutScale > 0 )
{
fInnerRadius = fRate * (secs - fStartSecs) * hsScalarPI * 2.f;
fOuterRadius = fInnerRadius * (5.f/4.f);
fAttenuateOutScale = hsScalarInvert(fOuterRadius - fInnerRadius);
}
fPhase = -(secs - fStartSecs) * fRate * hsScalarPI * 2.f;
}
hsScalar hsWave::ScaledAmplitude(hsScalar secs) const
{
return fWorldAmplitude * AgeScale(secs);
}
hsScalar hsWave::AgeScale(hsScalar secs) const
{
hsScalar age = secs - fStartSecs;
extern int dbgCurrentTest;
if( dbgCurrentTest )
{
age *= 4.f;
age -= 2.f * fSecsToLive;
if( age < 0 )
age = -age;
age -= fSecsToLive;
}
else
{
age *= 2.f;
age -= fSecsToLive;
if( age < 0 )
age = -age;
}
hsScalar ageScale = 1.f - age / fSecsToLive;
if( ageScale < 0 )
ageScale = 0;
else if( ageScale > 1.f )
ageScale = 1.f;
return ageScale;
}
hsOscillator::hsOscillator()
{
}
hsOscillator::~hsOscillator()
{
}
hsWave& hsOscillator::GetWeakestWave(hsScalar secs)
{
hsAssert(!GetDisabled(), "Shouldn't be messing with disabled oscillator system");
int weakest = 0;
hsScalar amp = fWaves[0].ScaledAmplitude(secs);
int i;
for( i = 0; i < fWaves.GetCount(); i++ )
{
hsScalar tAmp = fWaves[i].ScaledAmplitude(secs);
if( tAmp < amp )
{
weakest = i;
amp = tAmp;
}
}
return fWaves[weakest];
}
hsWave& hsOscillator::GetTempWave(hsScalar secs)
{
int i;
for( i = 0; i < fTempWaves.GetCount(); i++ )
{
if( fTempWaves[i].IsSpent(secs) )
return fTempWaves[i];
}
fTempWaves.Push();
return fTempWaves[fTempWaves.GetCount()-1];
}
void hsOscillator::ISpawnWave(hsScalar secs, int i)
{
hsPoint3 corner;
fWorldCenterBounds.GetCorner(&corner);
hsVector3 ax[3];
fWorldCenterBounds.GetAxes(ax+0, ax+1, ax+2);
hsScalar r;
r = rnd0_1();
ax[0] *= r;
corner += ax[0];
r = rnd0_1();
ax[1] *= r;
corner += ax[1];
r = rnd0_1();
ax[2] *= r;
corner += ax[2];
hsScalar per = fMinPeriod;
r = rnd0_1();
hsScalar rr = r;
r *= fMaxPeriod - fMinPeriod;
per += r;
hsScalar amp = fMinAmplitude;
r = rr * rnd0_1();
r *= fMaxAmplitude - fMinAmplitude;
amp += r;
hsScalar life = fMinLife;
r = rnd0_1();
r *= fMaxLife - fMinLife;
life += r;
hsScalar rate = fMinRate;
r = rnd0_1();
r *= fMaxRate - fMinRate;
rate += r;
fWaves[i].Init(secs, corner, per, amp, rate, life);
}
void hsOscillator::IUpdate(hsScalar secs, plPipeline* pipe, const hsMatrix44& l2w, const hsMatrix44& w2l)
{
if( GetDisabled() )
return;
fWorldCenter = pipe->GetViewPositionWorld();
fWorldCenter.fZ = (fWorldCenterBounds.GetMins().fZ + fWorldCenterBounds.GetMaxs().fZ) * 0.5f;
fLocalCenter = w2l * fWorldCenter;
fLocalToWorld = l2w;
fWorldToLocal = w2l;
fLocalX.Set(w2l.fMap[0][0],w2l.fMap[1][0],w2l.fMap[2][0]);
fLocalX.Normalize();
fLocalY.Set(w2l.fMap[0][1],w2l.fMap[1][1],w2l.fMap[2][1]);
fLocalY.Normalize();
fLocalZ.Set(w2l.fMap[0][2],w2l.fMap[1][2],w2l.fMap[2][2]);
fLocalZ.Normalize();
hsVector3 ax;
hsScalar ooScale;
ax.Set(w2l.fMap[0][0], w2l.fMap[1][0], w2l.fMap[2][0]);
ooScale = ax.MagnitudeSquared();
ooScale = hsFastMath::InvSqrtAppr(ooScale);
fLocalAttenScale.fX = fWorldAttenScale.fX * ooScale;
ax.Set(w2l.fMap[0][1], w2l.fMap[1][1], w2l.fMap[2][1]);
ooScale = ax.MagnitudeSquared();
ooScale = hsFastMath::InvSqrtAppr(ooScale);
fLocalAttenScale.fY = fWorldAttenScale.fY * ooScale;
fLocalAttenScale.fZ = 0;
int i;
for( i = 0; i < fWaves.GetCount(); i++ )
{
if( fWaves[i].IsSpent(secs) )
ISpawnWave(secs, i);
fWaves[i].Update(secs, l2w, w2l);
}
for( i = 0; i < fTempWaves.GetCount(); i++ )
{
while( (i < fTempWaves.GetCount()) && fTempWaves[i].IsSpent(secs) )
fTempWaves.Remove(i, 1);
if( i < fTempWaves.GetCount() )
fTempWaves[i].Update(secs, l2w, w2l);
}
}
hsScalar hsOscillator::IAttenuate(const hsPoint3& in) const
{
const hsPoint3& cen = fLocalCenter;
hsVector3 del(&in, &cen);
hsScalar atX = del.InnerProduct(fLocalX);
atX *= fLocalAttenScale.fX;
if( atX > 0 )
atX = -atX;
atX += 1.f;
if( atX < 0 )
atX = 0;
hsScalar atY = del.InnerProduct(fLocalY);
atY *= fLocalAttenScale.fY;
if( atY > 0 )
atY = -atY;
atY += 1.f;
if( atY < 0 )
atY = 0;
hsScalar at = atX * atY;
return at;
}
void hsOscillator::AdjustWorldBounds(const hsMatrix44& l2w, const hsMatrix44& w2l, hsBounds3Ext& bnd) const
{
if( GetDisabled() )
return;
hsVector3 adj;
adj.Set(0,1.f/fLocalZ.fZ,0);
adj = l2w * adj;
adj *= fMaxAmplitude * fWaves.GetCount();
bnd.Union(&adj);
adj = -adj;
bnd.Union(&adj);
}
void hsOscillator::IPerterb(const hsPoint3& in, hsGVertex3& out) const
{
hsPoint3 pos = in;
hsVector3 del(&pos, &fLocalCenter);
hsScalar dot = del.InnerProduct(fLocalZ);
pos += fLocalZ * -dot;
hsVector3 accum;
hsVector3 accumNorm;
accum.Set(0,0,0);
accumNorm.Set(0,0,0);
int i;
for( i = 0; i < fWaves.GetCount(); i++ )
{
fWaves[i].Accumulate(pos, fLocalZ, accum, accumNorm);
}
for( i = 0; i < fTempWaves.GetCount(); i++ )
{
fTempWaves[i].Accumulate(pos, fLocalZ, accum, accumNorm);
}
hsScalar atten = IAttenuate(pos);
static int attenuating = 1;
if( attenuating ) // nuke me
accum *= atten;
out.fLocalPos = in + accum;
hsScalar invNorm = hsFastMath::InvSqrtAppr(accumNorm.MagnitudeSquared());
accumNorm *= invNorm;
out.fNormal = accumNorm;
}
void hsOscillator::Read(hsStream* s)
{
int n = s->ReadSwap32();
SetNumWaves(n);
fWorldAttenScale.Read(s);
fWorldCenterBounds.Read(s);
fMinPeriod = s->ReadSwapScalar();
fMaxPeriod = s->ReadSwapScalar();
fMinAmplitude = s->ReadSwapScalar();
fMaxAmplitude = s->ReadSwapScalar();
fMinRate = s->ReadSwapScalar();
fMaxRate = s->ReadSwapScalar();
fMinLife = s->ReadSwapScalar();
fMaxLife = s->ReadSwapScalar();
int i;
for( i = 0; i < fWaves.GetCount(); i++ )
fWaves[i].Kill();
fTempWaves.Reset();
}
void hsOscillator::Load(hsStream* s, hsScalar secs)
{
Read(s);
int i;
for( i = 0; i < fWaves.GetCount(); i++ )
fWaves[i].Load(s, secs);
fTempWaves.Reset();
}
void hsOscillator::Write(hsStream* s)
{
s->WriteSwap32(fWaves.GetCount());
fWorldAttenScale.Write(s);
fWorldCenterBounds.Write(s);
s->WriteSwapScalar(fMinPeriod);
s->WriteSwapScalar(fMaxPeriod);
s->WriteSwapScalar(fMinAmplitude);
s->WriteSwapScalar(fMaxAmplitude);
s->WriteSwapScalar(fMinRate);
s->WriteSwapScalar(fMaxRate);
s->WriteSwapScalar(fMinLife);
s->WriteSwapScalar(fMaxLife);
}
void hsOscillator::Save(hsStream* s, hsScalar secs)
{
Write(s);
int i;
for( i = 0; i < fWaves.GetCount(); i++ )
fWaves[i].Save(s, secs);
}
void hsOscillator::SetNumWaves(int n)
{
fWaves.SetCount(n);
int i;
for( i = 0; i < n; i++ )
fWaves[i].Kill();
}
void hsOscillator::Init(int32_t nParams, hsScalar* params)
{
// NumWaves = 1
// AttenScale = 2
// WorldCenterBounds = 6
// Period = 2
// Amp = 2
// Rate = 2
// Life = 2
hsAssert(17 == nParams, "Parameter input mismatch");
SetNumWaves(int(*params++));
fWorldAttenScale.fX = *params++;
fWorldAttenScale.fY = *params++;
fWorldAttenScale.fZ = 0;
hsPoint3 pt;
hsBounds3Ext bnd;
pt.fX = *params++;
pt.fY = *params++;
pt.fZ = *params++;
bnd.Reset(&pt);
pt.fX = *params++;
pt.fY = *params++;
pt.fZ = *params++;
bnd.Union(&pt);
SetWorldCenterBounds(bnd);
SetPeriodRange(params[0], params[1]);
params += 2;
SetAmplitudeRange(params[0], params[1]);
params += 2;
SetRateRange(params[0], params[1]);
params += 2;
SetLifeRange(params[0], params[1]);
fTempWaves.Reset();
}
#if 1
hsGTriMesh* hsOscillator::MakeWaveMesh(int nSpokes, const hsPoint3& center, hsScalar minRad, hsScalar maxRad, hsScalar uRange, hsScalar vRange, hsScalar attenStartFrac, hsBool32 stitch)
{
hsGTriMesh* triMesh = new hsGTriMesh;
hsTArray<hsScalar> radii;
hsScalar cRad = 0;
while( cRad < maxRad )
{
// OOPS - for the half circle, this should be PI*R/n, not 2PI. Don't fix until we've corrected the callers. Or we might want to leave it like
// this anyway, since we're looking obliquely at these faces anyway, and this error stretches the side that perspective compresses. May
// want to make the unstitched version wrong in the same way.
hsScalar tRad = 2.f * hsScalarPI * cRad / nSpokes;
if( tRad < minRad )
tRad = minRad;
cRad += tRad;
radii.Append(cRad);
}
int nShell = radii.GetCount();
int nTris = stitch
? 2 * nSpokes * (nShell-1) + nSpokes
: 2 * (nSpokes-1) * (nShell-1) + (nSpokes-1);
int nVerts = nSpokes * nShell + 1;
triMesh->AllocatePointers(nTris, nVerts, nVerts, nVerts);
triMesh->SetNumTriVertex(nVerts);
triMesh->SetNumPoints(nVerts);
triMesh->SetNumUvs(nVerts);
triMesh->SetHasColors(true);
*triMesh->GetPoint(0) = center;
triMesh->GetNormal(0)->Set(0,1.f,0);
triMesh->GetColor(0)->Set(0,0,0,1.f);
triMesh->GetUvs(0)->fX = triMesh->GetUvs(0)->fY = triMesh->GetUvs(0)->fZ = 0;
hsScalar iToRadians = stitch
? 2.f * hsScalarPI / nSpokes
: hsScalarPI / nSpokes;
hsScalar attenStart = maxRad * attenStartFrac;
hsScalar attenEnd = maxRad;
hsScalar attenScale = hsScalarInvert(attenEnd - attenStart);
int i, j;
for( i = 0; i < nSpokes; i++ )
{
hsScalar s = hsSine(i * iToRadians);
hsScalar c = hsCosine(i * iToRadians);
for( j = 0; j < nShell; j++ )
{
hsAssert(1 + i*nShell + j < nVerts, "Going out of range on verts");
hsGVertex3* vtx = triMesh->GetVertex(1 + i*nShell + j);
hsColorRGBA* col = triMesh->GetColor(1 + i*nShell + j);
hsGUv* uv = triMesh->GetUvs(1 + i*nShell + j);
hsScalar x = c * radii[j];
hsScalar y = s * radii[j];
hsScalar u = x / uRange;
hsScalar v = y / vRange;
vtx->fLocalPos.fX = center.fX + x;
vtx->fLocalPos.fY = center.fY + y;
vtx->fLocalPos.fZ = 0.f;
vtx->fNormal.Set(0,0,1.f);
uv->fX = u;
uv->fY = v;
uv->fZ = 0.f;
if( radii[j] > attenStart )
{
hsScalar a = (attenEnd - radii[j]) * attenScale;
if( a < 0 )
a = 0;
else if( a > 1.f )
a = 1.f;
col->Set(0,0,0,a);
}
else
col->Set(0,0,0,1.f);
}
}
int spokeEnd = stitch ? nSpokes : nSpokes-1;
int nextTri = 0;
for( i = 0; i < spokeEnd; i++ )
{
hsTriangle3* tri = triMesh->GetTriFromPool(nextTri);
tri->Zero();
tri->fOrigTri = tri;
triMesh->SetTriangle(nextTri++, tri);
tri->fVert[0] = triMesh->GetTriVertex(0);
tri->fVert[0]->fVtx = triMesh->GetVertex(0);
tri->fVert[0]->SetNumUvChannels(1);
tri->fVert[0]->fUvChan[0] = triMesh->GetUvs(0);
tri->fVert[0]->fVtxColor = triMesh->GetColor(0);
int iv0 = 1 + i * nShell;
int iv1 = i < nSpokes - 1 ? 1 + (i+1)*nShell : 1;
hsAssert((iv0 < nVerts)&&(iv1 < nVerts), "Out of range on triverts");
tri->fVert[1] = triMesh->GetTriVertex(iv0);
tri->fVert[1]->fVtx = triMesh->GetVertex(iv0);
tri->fVert[1]->SetNumUvChannels(1);
tri->fVert[1]->fUvChan[0] = triMesh->GetUvs(iv0);
tri->fVert[1]->fVtxColor = triMesh->GetColor(iv0);
tri->fVert[2] = triMesh->GetTriVertex(iv1);
tri->fVert[2]->fVtx = triMesh->GetVertex(iv1);
tri->fVert[2]->SetNumUvChannels(1);
tri->fVert[2]->fUvChan[0] = triMesh->GetUvs(iv1);
tri->fVert[2]->fVtxColor = triMesh->GetColor(iv1);
tri->fVert[0]->fFlags = hsGTriVertex::kHasPointers
| hsGTriVertex::kHasVertexUvs
| hsGTriVertex::kHasVertexColors;
tri->fVert[1]->fFlags = hsGTriVertex::kHasPointers
| hsGTriVertex::kHasVertexUvs
| hsGTriVertex::kHasVertexColors;
tri->fVert[2]->fFlags = hsGTriVertex::kHasPointers
| hsGTriVertex::kHasVertexUvs
| hsGTriVertex::kHasVertexColors;
tri->fFlags |= hsTriangle3::kHasVertexPosNorms
| hsTriangle3::kHasVertexUvs
| hsTriangle3::kHasVertexColors
| hsTriangle3::kHasPointers;
int iv2 = iv0 + 1;
int iv3 = iv1 + 1;
hsAssert((iv1 < nVerts)&&(iv2 < nVerts), "Out of range on triverts");
for( j = 0; j < nShell-1; j++ )
{
tri = triMesh->GetTriFromPool(nextTri);
tri->Zero();
tri->fOrigTri = tri;
triMesh->SetTriangle(nextTri++, tri);
tri->fVert[0] = triMesh->GetTriVertex(iv0);
tri->fVert[0]->fVtx = triMesh->GetVertex(iv0);
tri->fVert[0]->SetNumUvChannels(1);
tri->fVert[0]->fUvChan[0] = triMesh->GetUvs(iv0);
tri->fVert[0]->fVtxColor = triMesh->GetColor(iv0);
tri->fVert[1] = triMesh->GetTriVertex(iv2);
tri->fVert[1]->fVtx = triMesh->GetVertex(iv2);
tri->fVert[1]->SetNumUvChannels(1);
tri->fVert[1]->fUvChan[1] = triMesh->GetUvs(iv2);
tri->fVert[1]->fVtxColor = triMesh->GetColor(iv2);
tri->fVert[2] = triMesh->GetTriVertex(iv3);
tri->fVert[2]->fVtx = triMesh->GetVertex(iv3);
tri->fVert[2]->SetNumUvChannels(1);
tri->fVert[2]->fUvChan[0] = triMesh->GetUvs(iv3);
tri->fVert[2]->fVtxColor = triMesh->GetColor(iv3);
tri->fVert[0]->fFlags = hsGTriVertex::kHasPointers
| hsGTriVertex::kHasVertexUvs
| hsGTriVertex::kHasVertexColors;
tri->fVert[1]->fFlags = hsGTriVertex::kHasPointers
| hsGTriVertex::kHasVertexUvs
| hsGTriVertex::kHasVertexColors;
tri->fVert[2]->fFlags = hsGTriVertex::kHasPointers
| hsGTriVertex::kHasVertexUvs
| hsGTriVertex::kHasVertexColors;
tri->fFlags |= hsTriangle3::kHasVertexPosNorms
| hsTriangle3::kHasVertexUvs
| hsTriangle3::kHasVertexColors
| hsTriangle3::kHasPointers;
tri = triMesh->GetTriFromPool(nextTri);
tri->Zero();
tri->fOrigTri = tri;
triMesh->SetTriangle(nextTri++, tri);
tri->fVert[0] = triMesh->GetTriVertex(iv0);
tri->fVert[0]->fVtx = triMesh->GetVertex(iv0);
tri->fVert[0]->SetNumUvChannels(1);
tri->fVert[0]->fUvChan[0] = triMesh->GetUvs(iv0);
tri->fVert[0]->fVtxColor = triMesh->GetColor(iv0);
tri->fVert[1] = triMesh->GetTriVertex(iv3);
tri->fVert[1]->fVtx = triMesh->GetVertex(iv3);
tri->fVert[1]->SetNumUvChannels(1);
tri->fVert[1]->fUvChan[0] = triMesh->GetUvs(iv3);
tri->fVert[1]->fVtxColor = triMesh->GetColor(iv3);
tri->fVert[2] = triMesh->GetTriVertex(iv1);
tri->fVert[2]->fVtx = triMesh->GetVertex(iv1);
tri->fVert[2]->SetNumUvChannels(1);
tri->fVert[2]->fUvChan[0] = triMesh->GetUvs(iv1);
tri->fVert[2]->fVtxColor = triMesh->GetColor(iv1);
tri->fVert[0]->fFlags = hsGTriVertex::kHasPointers
| hsGTriVertex::kHasVertexUvs
| hsGTriVertex::kHasVertexColors;
tri->fVert[1]->fFlags = hsGTriVertex::kHasPointers
| hsGTriVertex::kHasVertexUvs
| hsGTriVertex::kHasVertexColors;
tri->fVert[2]->fFlags = hsGTriVertex::kHasPointers
| hsGTriVertex::kHasVertexUvs
| hsGTriVertex::kHasVertexColors;
tri->fFlags |= hsTriangle3::kHasVertexPosNorms
| hsTriangle3::kHasVertexUvs
| hsTriangle3::kHasVertexColors
| hsTriangle3::kHasPointers;
iv0++;
iv1++;
iv2++;
iv3++;
}
}
hsAssert(nextTri <= nTris, "Out of range on tris");
triMesh->StoreOrigPoints();
return triMesh;
}
#endif

180
Sources/Plasma/PubUtilLib/plGeometry/hsOscillator.h

@ -1,180 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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 hsOscillator_inc
#define hsOscillator_inc
#include "hsPerterber.h"
#include "hsTemplates.h"
#include "hsGeometry3.h"
#include "../plIntersect/hsBounds.h"
class hsStream;
class plPipeline;
class hsWave
{
protected:
hsPoint3 fWorldCenter;
hsPoint3 fLocalCenter;
hsScalar fWorldFrequency; // 1.0 / Period
hsScalar fLocalFrequency;
hsScalar fWorldAmplitude;
hsScalar fLocalAmplitude;
hsScalar fPhase;
hsScalar fRate; // how long a crest takes to reach next crest
hsScalar fStartSecs;
hsScalar fSecsToLive;
hsScalar fInnerRadius;
hsScalar fOuterRadius;
hsScalar fAttenuateOutScale;
hsScalar AgeScale(hsScalar secs) const;
public:
void Accumulate(const hsPoint3& pos, const hsVector3& localZ, hsVector3& accum, hsVector3& accumNorm) const;
hsScalar ScaledAmplitude(hsScalar secs) const;
void Init(hsScalar secs, hsPoint3& center, hsScalar per, hsScalar amp, hsScalar rate, hsScalar life, hsBool32 attenOut=false);
void Update(hsScalar secs, const hsMatrix44& l2w, const hsMatrix44& w2l);
hsBool32 IsSpent(hsScalar secs) const;
void Kill() { fStartSecs = fSecsToLive = 0; }
void AttenuateOut(hsBool32 on) { fAttenuateOutScale = (on ? 1.f : 0); }
hsBool32 GetAttenuateOut() { return fAttenuateOutScale > 0; }
void Save(hsStream* s, hsScalar secs);
void Load(hsStream* s, hsScalar secs);
};
class hsOscillator : public hsPerterber
{
protected:
hsTArray<hsWave> fWaves;
hsTArray<hsWave> fTempWaves;
hsMatrix44 fLocalToWorld;
hsMatrix44 fWorldToLocal;
hsPoint3 fWorldCenter;
hsPoint3 fLocalCenter;
hsVector3 fWorldAttenScale;
hsVector3 fLocalAttenScale;
hsBounds3Ext fWorldCenterBounds;
hsScalar fMinPeriod;
hsScalar fMaxPeriod;
hsScalar fMinAmplitude;
hsScalar fMaxAmplitude;
hsScalar fMinRate;
hsScalar fMaxRate;
hsScalar fMinLife;
hsScalar fMaxLife;
hsVector3 fLocalX;
hsVector3 fLocalY;
hsVector3 fLocalZ;
hsScalar IAttenuate(const hsPoint3& in) const;
void ISpawnWave(hsScalar secs, int i);
virtual void IUpdate(hsScalar secs, plPipeline* pipe, const hsMatrix44& l2w, const hsMatrix44& w2l);
virtual void IPerterb(const hsPoint3& in, hsGVertex3& out) const;
public:
hsOscillator();
virtual ~hsOscillator();
virtual void AdjustWorldBounds(const hsMatrix44& l2w, const hsMatrix44& w2l, hsBounds3Ext& bnd) const;
virtual uint32_t GetType() const { return kTypeOscillator; }
// Don't call these, use base class LabelAndWrite() and CreateAndRead()
virtual void Read(hsStream* s);
virtual void Write(hsStream* s);
virtual void Load(hsStream* s, hsScalar secs);
virtual void Save(hsStream* s, hsScalar secs);
void SetPeriodRange(hsScalar lo, hsScalar hi) { fMinPeriod = lo; fMaxPeriod = hi; }
void SetAmplitudeRange(hsScalar lo, hsScalar hi) { fMinAmplitude = lo; fMaxAmplitude = hi; }
void SetRateRange(hsScalar lo, hsScalar hi) { fMinRate = lo; fMaxRate = hi; }
void SetLifeRange(hsScalar lo, hsScalar hi) { fMinLife = lo; fMaxLife = hi; }
hsScalar GetMinPeriod() const { return fMinPeriod; }
hsScalar GetMaxPeriod() const { return fMaxPeriod; }
hsScalar GetMinAmplitude() const { return fMinAmplitude; }
hsScalar GetMaxAmplitude() const { return fMaxAmplitude; }
hsScalar GetMinRate() const { return fMinRate; }
hsScalar GetMaxRate() const { return fMaxRate; }
hsScalar GetMinLife() const { return fMinLife; }
hsScalar GetMaxLife() const { return fMaxLife; }
void SetWorldAttenScale(const hsVector3& s) { fWorldAttenScale = s; }
void SetWorldCenterBounds(const hsBounds3Ext& bnd) { fWorldCenterBounds = bnd; }
const hsVector3& GetWorldAttenScale() const { return fWorldAttenScale; }
const hsBounds3Ext& GetWorldCenterBounds() const { return fWorldCenterBounds; }
void SetNumWaves(int n);
uint32_t GetNumWaves() const { return fWaves.GetCount(); }
hsWave& GetWeakestWave(hsScalar secs);
hsWave& GetTempWave(hsScalar secs);
virtual void Init(int32_t nParams, hsScalar* params);
static hsGTriMesh* MakeWaveMesh(int nSpokes, const hsPoint3& center, hsScalar minRad, hsScalar maxRad, hsScalar uRange, hsScalar vRange, hsScalar attenStartFrac, hsBool32 stitch);
};
#endif // hsOscillator_inc

350
Sources/Plasma/PubUtilLib/plGeometry/hsPerterber.cpp

@ -1,350 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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 "hsStream.h"
#include "hsPerterber.h"
#include "hsOscillator.h"
#include "hsGMesh.h"
#if 0 // GET_RID_OF_SHAPE_LAYER_DEFER
#include "hsGShape3.h"
#include "hsGShape3MegaMesh.h"
#endif// GET_RID_OF_SHAPE_LAYER_DEFER
#include "../plResMgr/plKey.h"
#include "../plSurface/hsGMaterial.h"
#include "hsTimer.h"
#include "../plPipeline/plPipeline.h"
hsBool32 hsPerterber::fDisabled = false;
hsPerterber::hsPerterber()
{
}
hsPerterber::~hsPerterber()
{
}
void hsPerterber::IUpdate(hsScalar secs, plPipeline* pipe, const hsMatrix44& l2w, const hsMatrix44& w2l)
{
}
void hsPerterber::TimeStampAndSave(hsStream* s)
{
hsScalar secs = hsTimer::GetSeconds();
hsKeyedObject::Save(s, nil);
Save(s, secs);
}
void hsPerterber::TimeStampAndLoad(hsStream* s)
{
hsScalar secs = hsTimer::GetSeconds();
hsKeyedObject::Load(s, nil);
Load(s, secs);
}
void hsPerterber::LabelAndWrite(hsStream* s)
{
s->WriteSwap32(GetType());
Write(s);
}
hsPerterber* hsPerterber::CreateAndRead(hsStream* s)
{
hsPerterber* retVal = nil;
uint32_t t = s->ReadSwap32();
switch( t )
{
case kTypeOscillator:
retVal = new hsOscillator;
break;
default:
hsAssert(false, "Unknown perterber type");
return nil;
}
retVal->Read(s);
return retVal;
}
hsGMesh* hsPerterber::IGetMesh(hsGShape3* shape)
{
hsGMesh* mesh = nil;
#if 0 // GET_RID_OF_SHAPE_LAYER_DEFER
if( shape->GetShapeType() == hsGShape3::kTypeTriMesh )
{
hsGShape3TriMesh* shp = (hsGShape3TriMesh*)shape;
mesh = shp->GetMesh();
#if 0 // move to export
if( mesh->GetKey() && strstr(mesh->GetKey()->GetName(), "create") )
{
hsTArray<hsGMaterial*> matList;
shp->AppendMaterials(matList);
hsGTriMesh* newMesh = hsOscillator::MakeWaveMesh(40, hsPoint3(0,0,0), 4.f, 75.f, 1200.f, 1200.f, 0.75f, false);
newMesh->SetMaterial(matList[0]);
hsRefCnt_SafeUnRef(matList[0]);
shp->SetMesh(newMesh);
hsRefCnt_SafeUnRef(newMesh);
mesh = newMesh;
}
else if( mesh->GetKey() && strstr(mesh->GetKey()->GetName(), "destroy") )
{
hsTArray<hsGMaterial*> matList;
shp->AppendMaterials(matList);
hsGTriMesh* newMesh = hsOscillator::MakeWaveMesh(50, hsPoint3(0,0,0), 1.5f, 30.f, 600.f, 600.f, 0.6f, true);
newMesh->SetMaterial(matList[0]);
hsRefCnt_SafeUnRef(matList[0]);
shp->SetMesh(newMesh);
hsRefCnt_SafeUnRef(newMesh);
mesh = newMesh;
}
else
#endif // move to export
{
hsGTriMesh* triMesh = (hsGTriMesh*)shp->GetMesh();
if( triMesh->GetTriangle(0)->fFlags & hsTriangle3::kHasFacePlane )
triMesh->TrashPlanes();
mesh = triMesh;
}
}
else if( shape->GetShapeType() == hsGShape3::kTypeMegaMesh )
{
hsGShape3MegaMesh* mega = (hsGShape3MegaMesh*)shape;
hsGMegaMesh* megaMesh = (hsGMegaMesh*)mega->GetMegaMesh();
hsGTriMesh* triMesh = (hsGTriMesh*)megaMesh->GetMesh(0);
if( triMesh->GetTriangle(0)->fFlags & hsTriangle3::kHasFacePlane )
{
int iMesh;
for( iMesh = 0; iMesh < megaMesh->GetMeshCount(); iMesh++ )
{
triMesh = (hsGTriMesh*)megaMesh->GetMesh(iMesh);
triMesh->TrashPlanes();
}
}
mesh = mega->GetMegaMesh();
}
#endif // GET_RID_OF_SHAPE_LAYER_DEFER
return mesh;
}
void hsPerterber::Perterb(hsScalar secs, plPipeline* pipe, const hsMatrix44& l2w, const hsMatrix44& w2l, hsGShape3* shape)
{
if( GetDisabled() )
return;
hsGMesh* mesh = IGetMesh(shape);
IUpdate(secs, pipe, l2w, w2l);
if( !mesh->HasOrigPoints() )
mesh->StoreOrigPoints();
int i;
for( i = 0; i < mesh->GetNumPoints(); i++ )
{
IPerterb(*mesh->GetOrigPoint(i), *mesh->GetVertex(i));
}
}
const int kPertCount = 6;
const int kMaxPertParams = 32;
struct hsPertDesc
{
char fName[256];
uint32_t fType;
uint32_t fNumParams;
hsScalar fParams[kMaxPertParams];
};
// NumWaves = 1
// AttenScale = 2
// WorldCenterBounds = 6
// Period = 2
// Amp = 2
// Rate = 2
// Life = 2
//
hsPertDesc sPertTable[kPertCount] =
{
{
"mystocean",
hsPerterber::kTypeOscillator,
17,
{
5.f,
1.f/100.f, 1.f/100.f,
-100.f, 100.f, 0, 100.f, 150.f, 0,
2.f, 5.f,
0.5, 0.75f,
0.68f, 0.68f,
5.f, 10.f
}
},
{
"stoneocean",
hsPerterber::kTypeOscillator,
17,
{
5.f,
1.f/100.f, 1.f/100.f,
-100.f, 100.f, 0, 100.f, 150.f, 0,
2.f, 5.f,
0.5, 0.75f,
0.68f, 0.68f,
5.f, 10.f
}
},
{
"seleniticocean",
hsPerterber::kTypeOscillator,
17,
{
5.f,
1.f/100.f, 1.f/100.f,
-100.f, 100.f, 0, 100.f, 150.f, 0,
2.f, 5.f,
0.25, 0.45f,
0.6f, 0.6f,
5.f, 10.f
}
},
{
"channelocean",
hsPerterber::kTypeOscillator,
17,
{
5.f,
1.f/30.f, 1.f/30.f,
-100.f, -100.f, 0, 100.f, 100.f, 0,
0.25f, 0.5f,
0.1, 0.2f,
0.4f, 0.8f,
5.f, 10.f
}
},
{
"mechocean",
hsPerterber::kTypeOscillator,
17,
{
5.f,
1.f/100.f, 1.f/100.f,
-100.f, 100.f, 0, 100.f, 150.f, 0,
2.f, 5.f,
0.5, 0.4f,
0.68f, 0.68f,
5.f, 10.f
}
},
{
"rimeocean",
hsPerterber::kTypeOscillator,
17,
{
5.f,
1.f/100.f, 1.f/100.f,
-100.f, 100.f, 0, 100.f, 150.f, 0,
2.f, 5.f,
0.5, 0.75,
0.68f, 0.68f,
5.f, 10.f
}
}
};
#if 0 // Used Registry...need to change paulg
void hsPerterber::InitSystem(hsRegistry* reg)
{
if( GetDisabled() )
return;
int i;
for( i = 0; i < kPertCount; i++ )
{
switch( sPertTable[i].fType )
{
case kTypeOscillator:
{
hsOscillator* oscar = new hsOscillator;
oscar->Init(sPertTable[i].fNumParams, sPertTable[i].fParams);
#ifdef PAULFIX
oscar->Register(reg, sPertTable[i].fName, 0, true);
#endif
}
break;
default:
hsAssert(false, "Unknown perterber type");
break;
}
}
}
void hsPerterber::Shutdown(hsRegistry* reg)
{
#ifdef PAULFIX
int i;
for( i = 0; i < reg->GetNumKeys(); i++ )
{
hsPerterber* pert = (hsPerterber*)(reg->GetKey(i)->GetObjectPtr());
delete pert;
}
#endif
}
#endif

107
Sources/Plasma/PubUtilLib/plGeometry/hsPerterber.h

@ -1,107 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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 hsPerterber_inc
#define hsPerterber_inc
#include "../plResMgr/hsKeyedObject.h"
#include "hsGeometry3.h"
class hsStream;
class hsGShape3;
class hsBounds3Ext;
class hsGMesh;
class plPipeline;
struct hsMatrix44;
struct hsGVertex3;
class hsPerterber : public hsKeyedObject
{
public:
enum {
kTypeUndefined = 0x0,
kTypeOscillator = 0x1
};
protected:
static hsBool32 fDisabled;
virtual void IUpdate(hsScalar secs, plPipeline* pipe, const hsMatrix44& l2w, const hsMatrix44& w2l);
virtual void IPerterb(const hsPoint3& in, hsGVertex3& out) const = 0;
hsGMesh* IGetMesh(hsGShape3* shape);
public:
hsPerterber();
virtual ~hsPerterber();
static void SetDisabled(hsBool32 on) { fDisabled = on; }
static void ToggleDisabled() { fDisabled = !fDisabled; }
static hsBool32 GetDisabled() { return fDisabled; }
virtual void Perterb(hsScalar secs, plPipeline* pipe, const hsMatrix44& l2w, const hsMatrix44& w2l, hsGShape3* shape);
virtual void AdjustWorldBounds(const hsMatrix44& l2w, const hsMatrix44& w2l, hsBounds3Ext& bnd) const = 0;
virtual uint32_t GetType() const = 0;
virtual void Write(hsStream* s) = 0;
virtual void Read(hsStream* s) = 0;
virtual void Save(hsStream* s, hsScalar secs) = 0;
virtual void Load(hsStream* s, hsScalar secs) = 0;
void TimeStampAndSave(hsStream* s);
void TimeStampAndLoad(hsStream* s);
void LabelAndWrite(hsStream* s);
static hsPerterber* CreateAndRead(hsStream* s);
virtual void Init(int32_t nParams, hsScalar* params) = 0;
#if 0 // Used Registry...need to change paulg
static void InitSystem(plResMgr* reg);
static void Shutdown(plResMgr* reg);
#endif
};
#endif hsPerterber_inc

70
Sources/Plasma/PubUtilLib/plGeometry/plGeometryCreatable.h

@ -1,70 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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 plGeometryCreatable_inc
#define plGeometryCreatable_inc
#include "../pnFactory/plCreator.h"
/* Taken out 6.12.2001 mcn - You can remove this file entirely if you wish, I just left
it in in case we wanted to use it in the future...
#include "hsGVertexPool.h"
REGISTER_CREATABLE( hsGVertexPool );
#include "hsGMesh.h"
REGISTER_NONCREATABLE( hsGMesh );
#include "hsGTriMesh.h"
REGISTER_CREATABLE( hsGTriMesh );
#include "hsGMegaMesh.h"
REGISTER_CREATABLE( hsGMegaMesh );
*/
#endif plGeometryCreatable_inc
Loading…
Cancel
Save