Init
This commit is contained in:
294
DependentExtensions/Ogre3DInterpDemo/App3D.cpp
Normal file
294
DependentExtensions/Ogre3DInterpDemo/App3D.cpp
Normal file
@ -0,0 +1,294 @@
|
||||
/*
|
||||
* Original work: Copyright (c) 2014, Oculus VR, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
|
||||
*
|
||||
*
|
||||
* Modified work: Copyright (c) 2016-2017, SLikeSoft UG (haftungsbeschränkt)
|
||||
*
|
||||
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
|
||||
* license found in the license.txt file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "App3D.h"
|
||||
|
||||
#include "Ogre.h"
|
||||
#include "slikenet/assert.h"
|
||||
#include "slikenet/FormatString.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include "OgreRenderSystemCapabilities.h"
|
||||
#include "slikenet/linux_adapter.h"
|
||||
#include "slikenet/osx_adapter.h"
|
||||
|
||||
static const char *defaultCameraName = "DefaultCamera";
|
||||
static const char *defaultSceneManagerName = "DefaultSceneManager";
|
||||
|
||||
App3D::App3D()
|
||||
{
|
||||
root=0;
|
||||
camera=0;
|
||||
sceneManager=0;
|
||||
window=0;
|
||||
viewport=0;
|
||||
math=0;
|
||||
isVisible=true;
|
||||
//statsOverlay=0;
|
||||
}
|
||||
App3D::~App3D()
|
||||
{
|
||||
}
|
||||
void App3D::Update(AppTime curTimeMS,AppTime elapsedTimeMS)
|
||||
{
|
||||
AppInterface::Update(curTimeMS, elapsedTimeMS);
|
||||
UpdateDefault(curTimeMS, elapsedTimeMS);
|
||||
}
|
||||
void App3D::Render(AppTime curTimeMS)
|
||||
{
|
||||
if (isVisible)
|
||||
{
|
||||
///
|
||||
/// SINCE WE ARE CALLING OGRE EXCEPTIONS ARE POSSIBLE HERE
|
||||
///
|
||||
#ifdef _DEBUG
|
||||
try
|
||||
{
|
||||
#endif
|
||||
if (window->isActive())
|
||||
{
|
||||
root->renderOneFrame();
|
||||
}
|
||||
else if (window->isVisible()) // Need this isVisible check or it crashes like hell when alt-tabbing
|
||||
{
|
||||
window->update();
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
}
|
||||
catch (Ogre::Exception &)
|
||||
{
|
||||
RakAssert(0 && "Something has happened to the Ogre rendering state. Recovery is possible. The cause needs to be fixed.");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
void App3D::SetVisible(bool _isVisible)
|
||||
{
|
||||
isVisible=_isVisible;
|
||||
}
|
||||
bool App3D::IsVisible(void) const
|
||||
{
|
||||
return isVisible;
|
||||
}
|
||||
void App3D::UpdateDefault(AppTime curTimeMS,AppTime elapsedTimeMS)
|
||||
{
|
||||
}
|
||||
void App3D::PreConfigure(void)
|
||||
{
|
||||
#ifdef WIN32
|
||||
::GetCurrentDirectory(sizeof(workingDirectory)-1, workingDirectory);
|
||||
#else
|
||||
// TODO - Get the current directory in linux
|
||||
RakAssert(0);
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
// If it throws an exception, change project properties / configuration properties / debugging / working directory to $(ProjectDir)
|
||||
#ifdef WIN32
|
||||
#ifdef _DEBUG
|
||||
root = new Ogre::Root("PluginsDebug.cfg", "Graphics.cfg", "Graphics.log");
|
||||
#else
|
||||
root = new Ogre::Root("Plugins.cfg", "Graphics.cfg", "Graphics.log");
|
||||
#endif
|
||||
#else
|
||||
#ifdef _DEBUG
|
||||
root = new Ogre::Root("PluginsDebugL.cfg", "Graphics.cfg", "Graphics.log");
|
||||
#else
|
||||
root = new Ogre::Root("PluginsL.cfg", "Graphics.cfg", "Graphics.log");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
catch (Ogre::Exception* e)
|
||||
{
|
||||
e->getFullDescription();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
bool App3D::Configure(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(root->restoreConfig() || root->showConfigDialog())
|
||||
{
|
||||
// If returned true, user clicked OK so initialise
|
||||
// Here we choose to let the system create a default rendering window by passing 'true'
|
||||
window = root->initialise(true, GetWindowTitle());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Ogre::InvalidParametersException &)
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
void App3D::PostConfigure(const char *defaultResourceConfigurationPath, bool recursive)
|
||||
{
|
||||
// Instantiate the math class to build the trig tables.
|
||||
math = new Ogre::Math;
|
||||
|
||||
// Load resource paths from config file
|
||||
Ogre::ConfigFile cf;
|
||||
cf.load(defaultResourceConfigurationPath);
|
||||
|
||||
// Go through all sections & settings in the file
|
||||
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
|
||||
|
||||
Ogre::String secName, typeName, archName;
|
||||
while (seci.hasMoreElements())
|
||||
{
|
||||
secName = seci.peekNextKey();
|
||||
// Seems like General is created automatically going by ogre.log
|
||||
if (secName!="General")
|
||||
{
|
||||
try
|
||||
{
|
||||
Ogre::ResourceGroupManager::getSingleton().createResourceGroup(secName);
|
||||
}
|
||||
catch (Ogre::Exception& e)
|
||||
{
|
||||
e;
|
||||
}
|
||||
}
|
||||
|
||||
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
|
||||
Ogre::ConfigFile::SettingsMultiMap::iterator i;
|
||||
for (i = settings->begin(); i != settings->end(); ++i)
|
||||
{
|
||||
typeName = i->first;
|
||||
archName = i->second;
|
||||
|
||||
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
|
||||
archName, typeName, secName, recursive);
|
||||
}
|
||||
}
|
||||
|
||||
// Window should have been created in Configure, or created here in a derived class
|
||||
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap");
|
||||
Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("General");
|
||||
|
||||
const Ogre::RenderSystemCapabilities* cap = root->getRenderSystem()->getCapabilities();
|
||||
// + (*cap).mMaxFragmentProgramVersion "ps_2_b" std::basic_string<char,std::char_traits<char>,std::allocator<char> >
|
||||
// if (cap->getMaxFragmentProgramVersion().c_str()[3]>='2')
|
||||
hasPixelShader2=true;
|
||||
// else
|
||||
// hasPixelShader2=false;
|
||||
}
|
||||
void App3D::InitSceneManager(Ogre::SceneManager *sm)
|
||||
{
|
||||
if (sm)
|
||||
sceneManager=sm;
|
||||
else
|
||||
sceneManager = root->createSceneManager(Ogre::ST_GENERIC, defaultSceneManagerName);
|
||||
|
||||
// Normal object visibility is mask 1.
|
||||
Ogre::MovableObject::setDefaultVisibilityFlags(1);
|
||||
sceneManager->setVisibilityMask(1);
|
||||
}
|
||||
// Must be called after InitSceneManager
|
||||
void App3D::InitGUIManager(void)
|
||||
{
|
||||
|
||||
}
|
||||
void App3D::InitCamera(Ogre::Camera *cam)
|
||||
{
|
||||
RakAssert(sceneManager);
|
||||
|
||||
if (cam)
|
||||
camera=cam;
|
||||
else
|
||||
camera = sceneManager->createCamera(defaultCameraName);
|
||||
|
||||
camera->setFOVy(Ogre::Radian(3.1415927f/4.0f));
|
||||
|
||||
}
|
||||
void App3D::InitViewport(Ogre::Viewport *vp)
|
||||
{
|
||||
// Create one viewport, entire window
|
||||
if (vp==0)
|
||||
{
|
||||
if (viewport==0)
|
||||
{
|
||||
viewport = window->addViewport(camera);
|
||||
viewport->setBackgroundColour(Ogre::ColourValue(0,0,0));
|
||||
}
|
||||
}
|
||||
else
|
||||
viewport=vp;
|
||||
|
||||
// Alter the camera aspect ratio to match the viewport
|
||||
camera->setAspectRatio(
|
||||
(float)viewport->getActualWidth() / (float)viewport->getActualHeight());
|
||||
}
|
||||
|
||||
void App3D::OnAppShutdown(void)
|
||||
{
|
||||
if (window)
|
||||
window->removeAllViewports();
|
||||
|
||||
delete root;
|
||||
delete math;
|
||||
|
||||
camera=0;
|
||||
sceneManager=0;
|
||||
}
|
||||
bool App3D::ShouldQuit(void) const
|
||||
{
|
||||
return window->isClosed();
|
||||
}
|
||||
void App3D::SetState(int stateType, RunnableState* state)
|
||||
{
|
||||
AppInterface::SetState(stateType, state);
|
||||
}
|
||||
Ogre::SceneManager* App3D::GetSceneManager(void) const
|
||||
{
|
||||
return sceneManager;
|
||||
}
|
||||
const TCHAR* App3D::GetWorkingDirectory(void) const
|
||||
{
|
||||
return workingDirectory;
|
||||
}
|
||||
bool App3D::HasPixelShader2(void) const
|
||||
{
|
||||
return hasPixelShader2;
|
||||
}
|
||||
const char * App3D::TakeScreenshot(const char *prefix, const char *suffix)
|
||||
{
|
||||
time_t aclock;
|
||||
time( &aclock ); // Get time in seconds
|
||||
tm newtime;
|
||||
localtime_s( &newtime, &aclock ); // Convert time to struct tm form
|
||||
char text[1024];
|
||||
strcpy_s(text, asctime( &newtime ));
|
||||
text[strlen(text)-1]=0;
|
||||
|
||||
// ':' character is not allowed for file names
|
||||
size_t len=strlen(text);
|
||||
for (size_t i=0;i<len;i++)
|
||||
{
|
||||
if (text[i]==':') text[i]='_';
|
||||
}
|
||||
|
||||
char *str = FormatString("%s%s%s", prefix, text, suffix);
|
||||
window->writeContentsToFile(str);
|
||||
return str;
|
||||
}
|
||||
84
DependentExtensions/Ogre3DInterpDemo/App3D.h
Normal file
84
DependentExtensions/Ogre3DInterpDemo/App3D.h
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Original work: Copyright (c) 2014, Oculus VR, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
|
||||
*
|
||||
*
|
||||
* Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
|
||||
*
|
||||
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
|
||||
* license found in the license.txt file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef __APP_3D_H
|
||||
#define __APP_3D_H
|
||||
|
||||
#include "AppInterface.h"
|
||||
#include <tchar.h> // used for TCHAR
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
class Root;
|
||||
class Camera;
|
||||
class SceneManager;
|
||||
class RenderWindow;
|
||||
class Viewport;
|
||||
class SceneNode;
|
||||
class Math;
|
||||
class Overlay;
|
||||
class Viewport;
|
||||
}
|
||||
|
||||
class FadingTextList;
|
||||
|
||||
class App3D : public AppInterface
|
||||
{
|
||||
public:
|
||||
App3D();
|
||||
virtual ~App3D();
|
||||
virtual void PreConfigure(void);
|
||||
//virtual void StartupSound(int maxchannels, unsigned int flags, void *extradriverdata, unsigned logType, bool logActive=false);
|
||||
virtual bool Configure(void);
|
||||
// Note that Ogre is bugged - setting recursive to true just crashes
|
||||
virtual void PostConfigure(const char *defaultResourceConfigurationPath, bool recursive);
|
||||
virtual void InitSceneManager(Ogre::SceneManager *sm=0);
|
||||
virtual void InitGUIManager(void);
|
||||
virtual void InitCamera(Ogre::Camera *cam=0);
|
||||
virtual void InitViewport(Ogre::Viewport *vp=0);
|
||||
virtual void Update(AppTime curTimeMS,AppTime elapsedTimeMS);
|
||||
virtual void Render(AppTime curTimeMS);
|
||||
virtual void SetVisible(bool _isVisible);
|
||||
virtual bool IsVisible(void) const;
|
||||
virtual bool ShouldQuit(void) const;
|
||||
virtual void OnAppShutdown(void);
|
||||
virtual void SetState(int stateType, RunnableState* state);
|
||||
bool HasPixelShader2(void) const;
|
||||
// Returns filename written
|
||||
const char * TakeScreenshot(const char *prefix, const char *suffix);
|
||||
|
||||
Ogre::SceneManager* GetSceneManager(void) const;
|
||||
const TCHAR* GetWorkingDirectory(void) const;
|
||||
|
||||
Ogre::Root *root;
|
||||
Ogre::Camera* camera;
|
||||
Ogre::RenderWindow* window;
|
||||
Ogre::Viewport* viewport;
|
||||
// This is here because the math trig tables don't get initialize until Math is instantiated, even though the tables are static.
|
||||
Ogre::Math *math;
|
||||
//Ogre::SceneNode *gameplayNode;
|
||||
|
||||
protected:
|
||||
|
||||
Ogre::SceneManager* sceneManager;
|
||||
void UpdateDefault(AppTime curTimeMS,AppTime elapsedTimeMS);
|
||||
virtual char * GetWindowTitle(void) const=0;
|
||||
|
||||
bool isVisible;
|
||||
TCHAR workingDirectory[512];
|
||||
bool hasPixelShader2;
|
||||
};
|
||||
|
||||
#endif
|
||||
167
DependentExtensions/Ogre3DInterpDemo/AppInterface.cpp
Normal file
167
DependentExtensions/Ogre3DInterpDemo/AppInterface.cpp
Normal file
@ -0,0 +1,167 @@
|
||||
/*
|
||||
* Original work: Copyright (c) 2014, Oculus VR, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
|
||||
*
|
||||
*
|
||||
* Modified work: Copyright (c) 2016-2017, SLikeSoft UG (haftungsbeschränkt)
|
||||
*
|
||||
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
|
||||
* license found in the license.txt file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "AppInterface.h"
|
||||
#include "slikenet/assert.h"
|
||||
#include "FSM.h"
|
||||
#include "RunnableState.h"
|
||||
#include "slikenet/linux_adapter.h"
|
||||
#include "slikenet/osx_adapter.h"
|
||||
|
||||
#ifdef _CONSOLE
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#endif
|
||||
|
||||
AppInterface::AppInterface()
|
||||
{
|
||||
hasFocus=false;
|
||||
primaryFSM=0;
|
||||
primaryStates=0;
|
||||
quit=false;
|
||||
primaryStatesLength=0;
|
||||
lastElapsedTimeMS=0;
|
||||
lastCurTimeMS=0;
|
||||
}
|
||||
AppInterface::~AppInterface()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
void AppInterface::PreConfigure(void)
|
||||
{
|
||||
primaryFSM = new FSM;
|
||||
}
|
||||
void AppInterface::PostConfigure(const char *defaultResourceConfigurationPath)
|
||||
{
|
||||
// unused parameters
|
||||
(void)defaultResourceConfigurationPath;
|
||||
}
|
||||
void AppInterface::Update(AppTime curTimeMS,AppTime elapsedTimeMS)
|
||||
{
|
||||
lastCurTimeMS=curTimeMS;
|
||||
lastElapsedTimeMS=elapsedTimeMS;
|
||||
}
|
||||
void AppInterface::OnAppShutdown(void)
|
||||
{
|
||||
delete primaryFSM;
|
||||
if (primaryStates)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < primaryStatesLength; i++)
|
||||
delete primaryStates[i];
|
||||
delete [] primaryStates;
|
||||
}
|
||||
}
|
||||
void AppInterface::DebugOut(unsigned int lifetimeMS, const char *format, ...)
|
||||
{
|
||||
#ifdef _CONSOLE
|
||||
char text[8096];
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vsnprintf_s(text, 8095, format, ap);
|
||||
va_end(ap);
|
||||
strcat(text, "\n");
|
||||
text[8095]=0;
|
||||
printf(text);
|
||||
#else
|
||||
// unused parameters
|
||||
(void)lifetimeMS;
|
||||
(void)format;
|
||||
|
||||
// Don't call this without an implementation. Perhaps you meant to use MainApp() instead
|
||||
RakAssert(0);
|
||||
#endif
|
||||
}
|
||||
bool AppInterface::HasFocus(void) const
|
||||
{
|
||||
return hasFocus;
|
||||
}
|
||||
void AppInterface::SetFocus(bool focus)
|
||||
{
|
||||
if (hasFocus!=focus)
|
||||
{
|
||||
if (primaryFSM->CurrentState())
|
||||
((RunnableState*)(primaryFSM->CurrentState()))->SetFocus(focus);
|
||||
hasFocus=focus;
|
||||
}
|
||||
}
|
||||
void AppInterface::PushState(RunnableState* state)
|
||||
{
|
||||
if (hasFocus && primaryFSM->CurrentState())
|
||||
((RunnableState*)(primaryFSM->CurrentState()))->SetFocus(false);
|
||||
primaryFSM->AddState(state);
|
||||
if (hasFocus)
|
||||
((RunnableState*)(primaryFSM->CurrentState()))->SetFocus(true);
|
||||
else
|
||||
((RunnableState*)(primaryFSM->CurrentState()))->SetFocus(false);
|
||||
}
|
||||
void AppInterface::PushState(int stateType)
|
||||
{
|
||||
PushState(primaryStates[stateType]);
|
||||
}
|
||||
void AppInterface::PopState(int popCount)
|
||||
{
|
||||
RakAssert(popCount>=1);
|
||||
RakAssert(primaryFSM->GetStateHistorySize()>=1+popCount);
|
||||
if (hasFocus && primaryFSM->CurrentState())
|
||||
((RunnableState*)(primaryFSM->CurrentState()))->SetFocus(false);
|
||||
primaryFSM->SetPriorState(primaryFSM->GetStateHistorySize()-1-popCount);
|
||||
if (hasFocus)
|
||||
((RunnableState*)(primaryFSM->CurrentState()))->SetFocus(true);
|
||||
}
|
||||
RunnableState* AppInterface::GetCurrentState(void) const
|
||||
{
|
||||
return (RunnableState*) primaryFSM->CurrentState();
|
||||
}
|
||||
int AppInterface::GetStateHistorySize(void) const
|
||||
{
|
||||
return primaryFSM->GetStateHistorySize();
|
||||
}
|
||||
void AppInterface::AllocateStates(int numStates)
|
||||
{
|
||||
RakAssert(primaryStates==0);
|
||||
primaryStates = new RunnableState*[numStates];
|
||||
|
||||
primaryStatesLength=numStates;
|
||||
}
|
||||
void AppInterface::SetState(int stateType, RunnableState* state)
|
||||
{
|
||||
primaryStates[stateType] = state;
|
||||
state->SetParentApp(this);
|
||||
state->OnStateReady();
|
||||
}
|
||||
RunnableState* AppInterface::GetState(int stateType) const
|
||||
{
|
||||
return primaryStates[stateType];
|
||||
}
|
||||
bool AppInterface::ShouldQuit(void) const
|
||||
{
|
||||
return quit;
|
||||
}
|
||||
void AppInterface::Quit(void)
|
||||
{
|
||||
quit=true;
|
||||
}
|
||||
AppTime AppInterface::GetLastCurrentTime(void) const
|
||||
{
|
||||
return lastCurTimeMS;
|
||||
}
|
||||
AppTime AppInterface::GetLastElapsedTime(void) const
|
||||
{
|
||||
return lastElapsedTimeMS;
|
||||
}
|
||||
71
DependentExtensions/Ogre3DInterpDemo/AppInterface.h
Normal file
71
DependentExtensions/Ogre3DInterpDemo/AppInterface.h
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oculus VR, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
|
||||
*
|
||||
* Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschr<68>nkt)
|
||||
*
|
||||
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
|
||||
* license found in the license.txt file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef __APP_INTERFACE_H
|
||||
#define __APP_INTERFACE_H
|
||||
|
||||
#include "AppTypes.h"
|
||||
|
||||
|
||||
class FSM;
|
||||
class RunnableState;
|
||||
class AppInterface
|
||||
{
|
||||
public:
|
||||
AppInterface();
|
||||
virtual ~AppInterface();
|
||||
// Called first to initialize memory
|
||||
virtual void PreConfigure(void);
|
||||
// Called after LoadDefaultResources. Return false to quit.
|
||||
virtual bool Configure(void)=0;
|
||||
// Called to do startup required after Configuration
|
||||
virtual void PostConfigure(const char *defaultResourceConfigurationPath);
|
||||
virtual void Update(AppTime curTimeMS,AppTime elapsedTimeMS);
|
||||
virtual void OnAppShutdown(void);
|
||||
|
||||
// Logging, lifetime may be ignored
|
||||
virtual void DebugOut(unsigned int lifetimeMS, const char *format, ...);
|
||||
|
||||
// Like focus in windows - start and stop rendering but don't necessarily stop running.
|
||||
bool HasFocus(void) const;
|
||||
virtual void SetFocus(bool focus);
|
||||
|
||||
// Built-in state machine
|
||||
void AllocateStates(int numStates);
|
||||
virtual void SetState(int stateType, RunnableState* state);
|
||||
RunnableState* GetState(int stateType) const;
|
||||
RunnableState* GetCurrentState(void) const;
|
||||
void PushState(RunnableState* state);
|
||||
void PushState(int stateType);
|
||||
void PopState(int popCount=1);
|
||||
int GetStateHistorySize(void) const;
|
||||
|
||||
// Just setting a flag
|
||||
virtual bool ShouldQuit(void) const;
|
||||
void Quit(void);
|
||||
AppTime GetLastCurrentTime(void) const;
|
||||
AppTime GetLastElapsedTime(void) const;
|
||||
|
||||
protected:
|
||||
// Allocated in PostConfigure
|
||||
FSM *primaryFSM;
|
||||
// Up to the derived class to allocate this using allocateStates
|
||||
RunnableState **primaryStates;
|
||||
AppTime lastElapsedTimeMS, lastCurTimeMS;
|
||||
int primaryStatesLength;
|
||||
bool hasFocus;
|
||||
bool quit;
|
||||
};
|
||||
|
||||
#endif
|
||||
16
DependentExtensions/Ogre3DInterpDemo/AppTypes.h
Normal file
16
DependentExtensions/Ogre3DInterpDemo/AppTypes.h
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oculus VR, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __APP_TYPES_H
|
||||
#define __APP_TYPES_H
|
||||
|
||||
typedef unsigned int AppTime;
|
||||
|
||||
#endif
|
||||
34
DependentExtensions/Ogre3DInterpDemo/CMakeLists.txt
Normal file
34
DependentExtensions/Ogre3DInterpDemo/CMakeLists.txt
Normal file
@ -0,0 +1,34 @@
|
||||
#
|
||||
# This file was taken from RakNet 4.082.
|
||||
# Please see licenses/RakNet license.txt for the underlying license and related copyright.
|
||||
#
|
||||
#
|
||||
# Modified work: Copyright (c) 2019, SLikeSoft UG (haftungsbeschr<68>nkt)
|
||||
#
|
||||
# This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
|
||||
# license found in the license.txt file in the root directory of this source tree.
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
GETCURRENTFOLDER()
|
||||
|
||||
IF(UNIX AND USEOIS AND NOT DISABLEDEPENDENCIES)
|
||||
project(${current_folder})
|
||||
FINDOGRE3D()
|
||||
FINDOIS()
|
||||
FILE(GLOB ALL_CPP_SRCS *.cpp)
|
||||
FILE(GLOB ALL_HEADER_SRCS *.h)
|
||||
FIXCOMPILEOPTIONS()
|
||||
include_directories(${SLIKENET_HEADER_FILES} ./ ${OGRE_INCLUDE_DIR} ${OIS_INCLUDE_DIR})
|
||||
add_executable(${current_folder} ${ALL_CPP_SRCS} ${ALL_HEADER_SRCS})
|
||||
target_link_libraries(${current_folder} ${SLIKENET_COMMON_LIBS} ${OGRE_LIBRARIES} ${OIS_LIBRARIES})
|
||||
file(GLOB OGRE_RenderSystem_GL_LIBRARY_DBG_MOD "/usr/lib/debug/usr/lib/OGRE/RenderSystem_GL.so")
|
||||
IF (NOT OGRE_RenderSystem_GL_LIBRARY_DBG_MOD)
|
||||
set(OGRE_RenderSystem_GL_LIBRARY_DBG_MOD ${OGRE_RenderSystem_GL_LIBRARY_DBG})
|
||||
ENDIF(NOT OGRE_RenderSystem_GL_LIBRARY_DBG_MOD)
|
||||
ADD_CUSTOM_COMMAND(TARGET ${current_folder} POST_BUILD COMMAND "cp" ARGS "-f" "${OGRE_RenderSystem_GL_LIBRARY_REL}" ./RenderSystem_GL.so)
|
||||
ADD_CUSTOM_COMMAND(TARGET ${current_folder} POST_BUILD COMMAND "cp" ARGS "-f" "${OGRE_RenderSystem_GL_LIBRARY_DBG_MOD}" ./RenderSystem_GL_D.so)
|
||||
ENDIF(UNIX AND USEOIS AND NOT DISABLEDEPENDENCIES)
|
||||
|
||||
|
||||
|
||||
103
DependentExtensions/Ogre3DInterpDemo/FSM.cpp
Normal file
103
DependentExtensions/Ogre3DInterpDemo/FSM.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oculus VR, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
|
||||
*
|
||||
*
|
||||
* Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
|
||||
*
|
||||
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
|
||||
* license found in the license.txt file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "FSM.h"
|
||||
#include "State.h"
|
||||
#include "slikenet/assert.h"
|
||||
|
||||
|
||||
|
||||
FSM::FSM()
|
||||
{
|
||||
|
||||
}
|
||||
FSM::~FSM()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
void FSM::Clear(void)
|
||||
{
|
||||
unsigned i;
|
||||
if (stateHistory.Size())
|
||||
stateHistory[stateHistory.Size()-1]->OnLeave(this, true);
|
||||
for (i=0; i < stateHistory.Size(); i++)
|
||||
stateHistory[i]->FSMRemoveRef(this);
|
||||
stateHistory.Clear(false, _FILE_AND_LINE_);
|
||||
}
|
||||
State *FSM::CurrentState(void) const
|
||||
{
|
||||
if (stateHistory.Size()==0)
|
||||
return 0;
|
||||
return stateHistory[stateHistory.Size()-1];
|
||||
}
|
||||
State *FSM::GetState(int index) const
|
||||
{
|
||||
RakAssert(index>=0 && index < (int) stateHistory.Size());
|
||||
return stateHistory[(unsigned) index];
|
||||
}
|
||||
int FSM::GetStateIndex(State *state) const
|
||||
{
|
||||
return (int) stateHistory.GetIndexOf(state);
|
||||
}
|
||||
int FSM::GetStateHistorySize(void) const
|
||||
{
|
||||
return stateHistory.Size();
|
||||
}
|
||||
// #med - change index parameter to unsigned int
|
||||
void FSM::RemoveState(const int index)
|
||||
{
|
||||
RakAssert(index>=0 && index < (int) stateHistory.Size());
|
||||
if (static_cast<unsigned int>(index)==stateHistory.Size()-1)
|
||||
stateHistory[index]->OnLeave(this, true);
|
||||
stateHistory[index]->FSMRemoveRef(this);
|
||||
stateHistory.RemoveAtIndex((const unsigned int)index);
|
||||
if (static_cast<unsigned int>(index)==stateHistory.Size())
|
||||
stateHistory[stateHistory.Size()-1]->OnEnter(this, false);
|
||||
}
|
||||
void FSM::AddState(State *state)
|
||||
{
|
||||
if (stateHistory.Size())
|
||||
stateHistory[stateHistory.Size()-1]->OnLeave(this, false);
|
||||
state->FSMAddRef(this);
|
||||
state->OnEnter(this, true);
|
||||
stateHistory.Insert(state, _FILE_AND_LINE_ );
|
||||
}
|
||||
// #med - change index parameter to unsigned int
|
||||
void FSM::ReplaceState(const int index, State *state)
|
||||
{
|
||||
RakAssert(index>=0 && index < (int) stateHistory.Size());
|
||||
if (state!=stateHistory[index])
|
||||
{
|
||||
if (static_cast<unsigned int>(index)==stateHistory.Size()-1)
|
||||
stateHistory[index]->OnLeave(this, true);
|
||||
stateHistory[index]->FSMRemoveRef(this);
|
||||
state->FSMAddRef(this);
|
||||
if (static_cast<unsigned int>(index)==stateHistory.Size()-1)
|
||||
state->OnEnter(this, true);
|
||||
stateHistory[index]=state;
|
||||
}
|
||||
}
|
||||
// #med - change index parameter to unsigned int
|
||||
void FSM::SetPriorState(const int index)
|
||||
{
|
||||
RakAssert(index>=0 && index < (int) stateHistory.Size());
|
||||
stateHistory[stateHistory.Size()-1]->OnLeave(this, true);
|
||||
for (unsigned i=stateHistory.Size()-1; i > (unsigned) index; --i)
|
||||
{
|
||||
stateHistory[i]->FSMRemoveRef(this);
|
||||
stateHistory.RemoveFromEnd();
|
||||
}
|
||||
stateHistory[index]->OnEnter(this, false);
|
||||
}
|
||||
46
DependentExtensions/Ogre3DInterpDemo/FSM.h
Normal file
46
DependentExtensions/Ogre3DInterpDemo/FSM.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oculus VR, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
|
||||
*
|
||||
* Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
|
||||
*
|
||||
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
|
||||
* license found in the license.txt file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef __FINITE_STATE_MACHINE_H
|
||||
#define __FINITE_STATE_MACHINE_H
|
||||
|
||||
#include "slikenet/DS_List.h"
|
||||
|
||||
class State;
|
||||
|
||||
// Finite state machine
|
||||
// Stores a stack of states
|
||||
// The top of the stack is the current state. There is only one current state. The stack contains the state history.
|
||||
// OnEnter, OnLeave, FSMAddRef, FSMRemoveRef of class State is called as appropriate.
|
||||
class FSM
|
||||
{
|
||||
public:
|
||||
FSM();
|
||||
~FSM();
|
||||
void Clear(void);
|
||||
State *CurrentState(void) const;
|
||||
State *GetState(const int index) const;
|
||||
int GetStateIndex(State *state) const;
|
||||
int GetStateHistorySize(void) const;
|
||||
void RemoveState(const int index);
|
||||
void AddState(State *state);
|
||||
void ReplaceState(const int index, State *state);
|
||||
void SetPriorState(const int index);
|
||||
|
||||
protected:
|
||||
DataStructures::List<State*> stateHistory;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
311
DependentExtensions/Ogre3DInterpDemo/Ogre3DInterpDemo.vcxproj
Normal file
311
DependentExtensions/Ogre3DInterpDemo/Ogre3DInterpDemo.vcxproj
Normal file
@ -0,0 +1,311 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug - Unicode|Win32">
|
||||
<Configuration>Debug - Unicode</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release - Unicode|Win32">
|
||||
<Configuration>Release - Unicode</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Retail - Unicode|Win32">
|
||||
<Configuration>Retail - Unicode</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Retail|Win32">
|
||||
<Configuration>Retail</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{FA98E1BC-2724-4BBA-8A2C-D8E27313638B}</ProjectGuid>
|
||||
<RootNamespace>Ogre3DInterpDemo</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Retail|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Retail - Unicode|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Retail|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Retail - Unicode|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Configuration)\</OutDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'">$(ProjectDir)$(Configuration)\</OutDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Configuration)\</OutDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Retail|Win32'">$(ProjectDir)$(Configuration)\</OutDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'">$(ProjectDir)$(Configuration)\</OutDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Retail - Unicode|Win32'">$(ProjectDir)$(Configuration)\</OutDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Retail|Win32'">false</LinkIncremental>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'">false</LinkIncremental>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Retail - Unicode|Win32'">false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>./;./../../Source/include;$(OGRE_HOME)\include\OGRE;$(OGRE_HOME)\boost_1_48\;$(OGRE_HOME)\include\OIS;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>./../../lib/SLikeNet_DLL_Debug_Win32.lib;ws2_32.lib;OgreMain_d.lib;OIS_d.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OGRE_HOME)\lib\$(Configuration);$(OGRE_HOME)\boost_1_48\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy $(OGRE_HOME)\bin\debug\*.dll $(ProjectDir)
|
||||
copy ".\..\..\Lib\SLikeNet_DLL_$(Configuration)_$(Platform).dll" $(ProjectDir)
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>./;./../../Source/include;$(OGRE_HOME)\include\OGRE;$(OGRE_HOME)\boost_1_48\;$(OGRE_HOME)\include\OIS;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>./../../lib/SLikeNet_DLL_Debug - Unicode_Win32.lib;ws2_32.lib;OgreMain_d.lib;OIS_d.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OGRE_HOME)\lib\$(Configuration);$(OGRE_HOME)\boost_1_48\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy $(OGRE_HOME)\bin\debug\*.dll $(ProjectDir)
|
||||
copy ".\..\..\Lib\SLikeNet_DLL_$(Configuration)_$(Platform).dll" $(ProjectDir)
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>./;./../../Source/include;$(OGRE_HOME)\include\OGRE;$(OGRE_HOME)\boost_1_48\;$(OGRE_HOME)\include\OIS;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>./../../lib/SLikeNet_DLL_Release_Win32.lib;ws2_32.lib;OgreMain.lib;OIS.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OGRE_HOME)\lib\$(Configuration);$(OGRE_HOME)\boost_1_48\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy $(OGRE_HOME)\bin\release\*.dll $(ProjectDir)
|
||||
copy ".\..\..\Lib\SLikeNet_DLL_$(Configuration)_$(Platform).dll" $(ProjectDir)
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Retail|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>./;./../../Source/include;$(OGRE_HOME)\include\OGRE;$(OGRE_HOME)\boost_1_48\;$(OGRE_HOME)\include\OIS;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_RETAIL;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>./../../lib/SLikeNet_DLL_Retail_Win32.lib;ws2_32.lib;OgreMain.lib;OIS.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OGRE_HOME)\lib\$(Configuration);$(OGRE_HOME)\boost_1_48\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy $(OGRE_HOME)\bin\release\*.dll $(ProjectDir)
|
||||
copy ".\..\..\Lib\SLikeNet_DLL_$(Configuration)_$(Platform).dll" $(ProjectDir)
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>./;./../../Source/include;$(OGRE_HOME)\include\OGRE;$(OGRE_HOME)\boost_1_48\;$(OGRE_HOME)\include\OIS;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>./../../lib/SLikeNet_DLL_Release - Unicode_Win32.lib;ws2_32.lib;OgreMain.lib;OIS.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OGRE_HOME)\lib\$(Configuration);$(OGRE_HOME)\boost_1_48\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy $(OGRE_HOME)\bin\release\*.dll $(ProjectDir)
|
||||
copy ".\..\..\Lib\SLikeNet_DLL_$(Configuration)_$(Platform).dll" $(ProjectDir)
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Retail - Unicode|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>./;./../../Source/include;$(OGRE_HOME)\include\OGRE;$(OGRE_HOME)\boost_1_48\;$(OGRE_HOME)\include\OIS;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_RETAIL;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>./../../lib/SLikeNet_DLL_Retail - Unicode_Win32.lib;ws2_32.lib;OgreMain.lib;OIS.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OGRE_HOME)\lib\$(Configuration);$(OGRE_HOME)\boost_1_48\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy $(OGRE_HOME)\bin\release\*.dll $(ProjectDir)
|
||||
copy ".\..\..\Lib\SLikeNet_DLL_$(Configuration)_$(Platform).dll" $(ProjectDir)</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="TransformationHistory.cpp" />
|
||||
<ClCompile Include="WinMain.cpp" />
|
||||
<ClCompile Include="App3D.cpp" />
|
||||
<ClCompile Include="AppInterface.cpp" />
|
||||
<ClCompile Include="FSM.cpp" />
|
||||
<ClCompile Include="OverlayHelper.cpp" />
|
||||
<ClCompile Include="RunnableState.cpp" />
|
||||
<ClCompile Include="State.cpp" />
|
||||
<ClCompile Include="..\..\Source\src\FormatString.cpp" />
|
||||
<ClCompile Include="..\..\Source\src\RakSleep.cpp" />
|
||||
<ClCompile Include="..\..\Source\src\Rand.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="TransformationHistory.h" />
|
||||
<ClInclude Include="App3D.h" />
|
||||
<ClInclude Include="AppInterface.h" />
|
||||
<ClInclude Include="AppTypes.h" />
|
||||
<ClInclude Include="FSM.h" />
|
||||
<ClInclude Include="OverlayHelper.h" />
|
||||
<ClInclude Include="RunnableState.h" />
|
||||
<ClInclude Include="State.h" />
|
||||
<ClInclude Include="..\..\Source\include\slikesoft\FormatString.h" />
|
||||
<ClInclude Include="..\..\Source\include\slikesoft\sleep.h" />
|
||||
<ClInclude Include="..\..\Source\include\slikesoft\Rand.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Lib\DLL\DLL.vcxproj">
|
||||
<Project>{bc75cd23-cb75-4233-a305-b7328825a9a5}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="App3D">
|
||||
<UniqueIdentifier>{c2068a7a-7dfb-4c19-9ab5-c8e9bb2fd374}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="SLikeNet">
|
||||
<UniqueIdentifier>{2e913c0b-b295-44aa-bbba-10a26bd2279c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="TransformationHistory.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="WinMain.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="App3D.cpp">
|
||||
<Filter>App3D</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="AppInterface.cpp">
|
||||
<Filter>App3D</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FSM.cpp">
|
||||
<Filter>App3D</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="OverlayHelper.cpp">
|
||||
<Filter>App3D</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RunnableState.cpp">
|
||||
<Filter>App3D</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="State.cpp">
|
||||
<Filter>App3D</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Source\src\FormatString.cpp">
|
||||
<Filter>SLikeNet</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Source\src\RakSleep.cpp">
|
||||
<Filter>SLikeNet</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Source\src\Rand.cpp">
|
||||
<Filter>SLikeNet</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="TransformationHistory.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="App3D.h">
|
||||
<Filter>App3D</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="AppInterface.h">
|
||||
<Filter>App3D</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="AppTypes.h">
|
||||
<Filter>App3D</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FSM.h">
|
||||
<Filter>App3D</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="OverlayHelper.h">
|
||||
<Filter>App3D</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RunnableState.h">
|
||||
<Filter>App3D</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="State.h">
|
||||
<Filter>App3D</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Source\include\slikesoft\FormatString.h">
|
||||
<Filter>SLikeNet</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Source\include\slikesoft\sleep.h">
|
||||
<Filter>SLikeNet</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Source\include\slikesoft\Rand.h">
|
||||
<Filter>SLikeNet</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Binary file not shown.
BIN
DependentExtensions/Ogre3DInterpDemo/OgreResources/OgreCore.zip
Normal file
BIN
DependentExtensions/Ogre3DInterpDemo/OgreResources/OgreCore.zip
Normal file
Binary file not shown.
Binary file not shown.
@ -0,0 +1,21 @@
|
||||
|
||||
material PopcornKernelMaterial
|
||||
{
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
ambient 0 0 0 1
|
||||
specular 0 0 0 1 10
|
||||
alpha_rejection greater 128
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture_alias 0
|
||||
texture KernelTexture.dds
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1,21 @@
|
||||
|
||||
material PopcornPoppedMaterial
|
||||
{
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
ambient 0 0 0 1
|
||||
specular 0 0 0 1 10
|
||||
alpha_rejection greater 128
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture_alias 0
|
||||
texture PoppedTexture.dds
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,17 @@
|
||||
material Examples/SteveCubeSkyBox
|
||||
{
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
lighting off
|
||||
depth_write off
|
||||
|
||||
texture_unit
|
||||
{
|
||||
cubic_texture stevecube.jpg separateUV
|
||||
tex_address_mode clamp
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
OgreMeshUpgrade.exe -d3d -b -t %1
|
||||
BIN
DependentExtensions/Ogre3DInterpDemo/OgreResources/skybox.zip
Normal file
BIN
DependentExtensions/Ogre3DInterpDemo/OgreResources/skybox.zip
Normal file
Binary file not shown.
160
DependentExtensions/Ogre3DInterpDemo/OverlayHelper.cpp
Normal file
160
DependentExtensions/Ogre3DInterpDemo/OverlayHelper.cpp
Normal file
@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oculus VR, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "OverlayHelper.h"
|
||||
#include "OgreTextAreaOverlayElement.h"
|
||||
#include "OgrePanelOverlayElement.h"
|
||||
#include "OgreOverlayManager.h"
|
||||
#include "OgreOverlayElementFactory.h"
|
||||
|
||||
|
||||
using namespace Ogre;
|
||||
|
||||
OverlayHelper::TimedOverlay::TimedOverlay()
|
||||
{
|
||||
}
|
||||
OverlayHelper::TimedOverlay::~TimedOverlay()
|
||||
{
|
||||
}
|
||||
OverlayHelper::TimedOverlay::TimedOverlay(OverlayElement *overlayElement, unsigned int totalTime, unsigned int fadeTimeMS, float finalAlpha, bool deleteAfterFade)
|
||||
{
|
||||
startFadeAlpha=-1.0f;
|
||||
this->overlayElement=overlayElement;
|
||||
this->remainingTimeMS=totalTime;
|
||||
this->fadeTimeMS=fadeTimeMS;
|
||||
this->finalAlpha=finalAlpha;
|
||||
this->deleteAfterFade=deleteAfterFade;
|
||||
}
|
||||
OverlayHelper::OverlayHelper()
|
||||
{
|
||||
globalOverlay=0;
|
||||
}
|
||||
OverlayHelper::~OverlayHelper()
|
||||
{
|
||||
|
||||
}
|
||||
void OverlayHelper::Startup(void)
|
||||
{
|
||||
globalOverlay = OverlayManager::getSingleton().create("OverlayHelperRoot");
|
||||
globalOverlay->show();
|
||||
}
|
||||
void OverlayHelper::Shutdown(void)
|
||||
{
|
||||
timedOverlays.Clear(false, _FILE_AND_LINE_ );
|
||||
if (globalOverlay)
|
||||
OverlayManager::getSingleton().destroy(globalOverlay);
|
||||
}
|
||||
void OverlayHelper::Update(unsigned int elapsedTimeMS)
|
||||
{
|
||||
unsigned i;
|
||||
i=0;
|
||||
while (i < timedOverlays.Size())
|
||||
{
|
||||
if (timedOverlays[i].remainingTimeMS < elapsedTimeMS)
|
||||
{
|
||||
if (timedOverlays[i].deleteAfterFade)
|
||||
{
|
||||
SafeDestroyOverlayElement(timedOverlays[i].overlayElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
const ColourValue &color = timedOverlays[i].overlayElement->getColour();
|
||||
ColourValue newColor = color;
|
||||
newColor.a=timedOverlays[i].finalAlpha;
|
||||
timedOverlays[i].overlayElement->setColour(newColor);
|
||||
timedOverlays.RemoveAtIndex(i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
timedOverlays[i].remainingTimeMS-=elapsedTimeMS;
|
||||
if (timedOverlays[i].remainingTimeMS < timedOverlays[i].fadeTimeMS)
|
||||
{
|
||||
const ColourValue &color = timedOverlays[i].overlayElement->getColour();
|
||||
if (timedOverlays[i].startFadeAlpha==-1.0f)
|
||||
timedOverlays[i].startFadeAlpha=color.a;
|
||||
ColourValue newColor = color;
|
||||
newColor.a=timedOverlays[i].finalAlpha - (timedOverlays[i].finalAlpha-timedOverlays[i].startFadeAlpha) * (float) timedOverlays[i].remainingTimeMS / (float) timedOverlays[i].fadeTimeMS;
|
||||
timedOverlays[i].overlayElement->setColour(newColor);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Overlay* OverlayHelper::GetGlobalOverlay(void) const
|
||||
{
|
||||
return globalOverlay;
|
||||
}
|
||||
void OverlayHelper::FadeOverlayElement(OverlayElement* element, unsigned int totalTime, unsigned int fadeTimeMS, float finalAlpha, bool deleteAfterFade)
|
||||
{
|
||||
timedOverlays.Insert(TimedOverlay(element, totalTime, fadeTimeMS, finalAlpha,deleteAfterFade), _FILE_AND_LINE_ );
|
||||
}
|
||||
OverlayContainer* OverlayHelper::CreatePanel(const char *instanceName, bool addToGlobalOverlay)
|
||||
{
|
||||
OverlayContainer* element = (OverlayContainer*) OverlayManager::getSingleton().createOverlayElement("Panel", instanceName);
|
||||
if (addToGlobalOverlay)
|
||||
globalOverlay->add2D(element);
|
||||
return element;
|
||||
}
|
||||
TextAreaOverlayElement *OverlayHelper::CreateTextArea(const char *instanceName, const char *fontName, OverlayContainer* parent)
|
||||
{
|
||||
TextAreaOverlayElement *element = (TextAreaOverlayElement *) OverlayManager::getSingleton().createOverlayElement("TextArea", instanceName);
|
||||
if (parent)
|
||||
parent->addChild(element);
|
||||
element->setFontName(fontName);
|
||||
return element;
|
||||
}
|
||||
BorderPanelOverlayElement *OverlayHelper::CreateBorderPanel(const char *instanceName, OverlayContainer* parent)
|
||||
{
|
||||
BorderPanelOverlayElement *element = (BorderPanelOverlayElement *) OverlayManager::getSingleton().createOverlayElement("BorderPanel", instanceName);
|
||||
if (parent)
|
||||
parent->addChild(element);
|
||||
return element;
|
||||
}
|
||||
void OverlayHelper::SafeDestroyOverlayElement(OverlayElement *item)
|
||||
{
|
||||
if (item->isContainer())
|
||||
{
|
||||
OverlayContainer *container = (OverlayContainer*) item;
|
||||
|
||||
// Arrggghh the variable is protected
|
||||
// ((OverlayContainer*)item)->mOverlay->remove2D((OverlayContainer*)item);
|
||||
OverlayManager::OverlayMapIterator iter1 = OverlayManager::getSingleton().getOverlayIterator();
|
||||
while (iter1.hasMoreElements())
|
||||
{
|
||||
iter1.getNext()->remove2D(container);
|
||||
}
|
||||
|
||||
OverlayContainer::ChildIterator iter2 = container->getChildIterator();
|
||||
while (iter2.hasMoreElements())
|
||||
{
|
||||
iter2.getNext()->_setParent(0);
|
||||
}
|
||||
|
||||
OverlayContainer::ChildContainerIterator iter3 = container->getChildContainerIterator();
|
||||
while (iter3.hasMoreElements())
|
||||
{
|
||||
iter3.getNext()->_setParent(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (item->getParent())
|
||||
item->getParent()->removeChild(item->getName());
|
||||
OverlayManager::getSingleton().destroyOverlayElement(item);
|
||||
unsigned i;
|
||||
i=0;
|
||||
while (i < timedOverlays.Size())
|
||||
{
|
||||
if (timedOverlays[i].overlayElement==item)
|
||||
timedOverlays.RemoveAtIndex(i);
|
||||
else
|
||||
i++;
|
||||
}
|
||||
}
|
||||
83
DependentExtensions/Ogre3DInterpDemo/OverlayHelper.h
Normal file
83
DependentExtensions/Ogre3DInterpDemo/OverlayHelper.h
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oculus VR, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
|
||||
*
|
||||
* Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
|
||||
*
|
||||
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
|
||||
* license found in the license.txt file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef __OVERLAY_HELPER_H
|
||||
#define __OVERLAY_HELPER_H
|
||||
|
||||
#include "slikenet/DS_List.h"
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
class RenderWindow;
|
||||
class SceneManager;
|
||||
class OverlayContainer;
|
||||
class TextAreaOverlayElement;
|
||||
class BorderPanelOverlayElement;
|
||||
class OverlayElement;
|
||||
class Overlay;
|
||||
}
|
||||
|
||||
// This classe makes it easier to use Ogre's overlay system. It provides the ability to fade overlays in and out and to automatically delete them
|
||||
// after time
|
||||
class OverlayHelper
|
||||
{
|
||||
public:
|
||||
OverlayHelper();
|
||||
~OverlayHelper();
|
||||
void Startup(void);
|
||||
void Shutdown(void);
|
||||
void Update(unsigned int elapsedTimeMS);
|
||||
|
||||
// Just returns a global overlay that I store. Useful functions on it are hide() and show()
|
||||
Ogre::Overlay* GetGlobalOverlay(void) const;
|
||||
|
||||
// Fades an overlay element to some designated final alpha. You can autodelete the overlay after fading as well.
|
||||
void FadeOverlayElement(Ogre::OverlayElement* element, unsigned int totalTime, unsigned int fadeTimeMS, float finalAlpha, bool deleteAfterFade);
|
||||
|
||||
// Equivalent to Ogre's function. All OverlayElements must be a child of a panel.
|
||||
Ogre::OverlayContainer* CreatePanel(const char *instanceName, bool addToGlobalOverlay=true);
|
||||
|
||||
// Displays a single line of text. Doesn't handle text clipping or wrapping.
|
||||
Ogre::TextAreaOverlayElement *CreateTextArea(const char *instanceName, const char *fontName, Ogre::OverlayContainer* parent);
|
||||
|
||||
// Equivalent to Ogre's function.
|
||||
Ogre::BorderPanelOverlayElement *CreateBorderPanel(const char *instanceName, Ogre::OverlayContainer* parent);
|
||||
|
||||
// Destroy any overlay created with the above.
|
||||
// Safer because it removes the element from its children and parent.
|
||||
void SafeDestroyOverlayElement(Ogre::OverlayElement *item);
|
||||
|
||||
// For internal use
|
||||
struct TimedOverlay
|
||||
{
|
||||
TimedOverlay();
|
||||
~TimedOverlay();
|
||||
TimedOverlay(Ogre::OverlayElement *overlayElement, unsigned int totalTime, unsigned int fadeTimeMS, float finalAlpha, bool deleteAfterFade);
|
||||
Ogre::OverlayElement *overlayElement;
|
||||
unsigned int remainingTimeMS;
|
||||
unsigned int fadeTimeMS;
|
||||
float finalAlpha;
|
||||
float startFadeAlpha;
|
||||
bool deleteAfterFade;
|
||||
};
|
||||
|
||||
protected:
|
||||
// A list of timed text elements with fade.
|
||||
// setColour
|
||||
DataStructures::List<TimedOverlay> timedOverlays;
|
||||
Ogre::Overlay* globalOverlay;
|
||||
unsigned int fadeTimeMSMS;
|
||||
};
|
||||
|
||||
#endif
|
||||
7
DependentExtensions/Ogre3DInterpDemo/Plugins.cfg
Normal file
7
DependentExtensions/Ogre3DInterpDemo/Plugins.cfg
Normal file
@ -0,0 +1,7 @@
|
||||
# Defines plugins to load
|
||||
|
||||
# Define plugin folder
|
||||
PluginFolder=./
|
||||
|
||||
# Define plugins
|
||||
Plugin=RenderSystem_Direct3D9.dll
|
||||
7
DependentExtensions/Ogre3DInterpDemo/PluginsDebug.cfg
Normal file
7
DependentExtensions/Ogre3DInterpDemo/PluginsDebug.cfg
Normal file
@ -0,0 +1,7 @@
|
||||
# Defines plugins to load
|
||||
|
||||
# Define plugin folder
|
||||
PluginFolder=./
|
||||
|
||||
# Define plugins
|
||||
Plugin=RenderSystem_Direct3D9_d.dll
|
||||
7
DependentExtensions/Ogre3DInterpDemo/PluginsDebugL.cfg
Normal file
7
DependentExtensions/Ogre3DInterpDemo/PluginsDebugL.cfg
Normal file
@ -0,0 +1,7 @@
|
||||
# Defines plugins to load
|
||||
|
||||
# Define plugin folder
|
||||
PluginFolder=./
|
||||
|
||||
# Define plugins
|
||||
Plugin=RenderSystem_GL_d.so
|
||||
7
DependentExtensions/Ogre3DInterpDemo/PluginsL.cfg
Normal file
7
DependentExtensions/Ogre3DInterpDemo/PluginsL.cfg
Normal file
@ -0,0 +1,7 @@
|
||||
# Defines plugins to load
|
||||
|
||||
# Define plugin folder
|
||||
PluginFolder=./
|
||||
|
||||
# Define plugins
|
||||
Plugin=RenderSystem_GL.so
|
||||
27
DependentExtensions/Ogre3DInterpDemo/RunnableState.cpp
Normal file
27
DependentExtensions/Ogre3DInterpDemo/RunnableState.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* This file was taken from RakNet 4.082.
|
||||
* Please see licenses/RakNet license.txt for the underlying license and related copyright.
|
||||
*
|
||||
* Modified work: Copyright (c) 2017-2018, SLikeSoft UG (haftungsbeschr<68>nkt)
|
||||
*
|
||||
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
|
||||
* license found in the license.txt file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "RunnableState.h"
|
||||
|
||||
|
||||
// #med - better rename member variable (parent) --- then revert local parameter to parent
|
||||
void RunnableState::SetParentApp(AppInterface *newparent)
|
||||
{
|
||||
parent=newparent;
|
||||
}
|
||||
void RunnableState::SetFocus(bool hasFocus)
|
||||
{
|
||||
// unused parameters
|
||||
(void)hasFocus;
|
||||
}
|
||||
void RunnableState::OnStateReady(void)
|
||||
{
|
||||
|
||||
}
|
||||
50
DependentExtensions/Ogre3DInterpDemo/RunnableState.h
Normal file
50
DependentExtensions/Ogre3DInterpDemo/RunnableState.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oculus VR, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
|
||||
*
|
||||
*
|
||||
* Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschr<68>nkt)
|
||||
*
|
||||
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
|
||||
* license found in the license.txt file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef __RUNNABLE_STATE_H
|
||||
#define __RUNNABLE_STATE_H
|
||||
|
||||
#include "AppTypes.h"
|
||||
#include "State.h"
|
||||
|
||||
class AppInterface;
|
||||
|
||||
class RunnableState : public State
|
||||
{
|
||||
public:
|
||||
virtual void Update(AppTime curTimeMS, AppTime elapsedTimeMS)=0;
|
||||
virtual void UpdateEnd(AppTime curTimeMS, AppTime elapsedTimeMS)
|
||||
{
|
||||
// unused parameters
|
||||
(void)curTimeMS;
|
||||
(void)elapsedTimeMS;
|
||||
}
|
||||
virtual void Render(AppTime curTimeMS)=0;
|
||||
void SetParentApp(AppInterface *newparent);
|
||||
// Call when internal variables set and the state is ready to use
|
||||
virtual void OnStateReady(void);
|
||||
|
||||
// Don't do this so I can override by return type in derived classes
|
||||
//virtual AppInterface *GetParentApp(void) const;
|
||||
|
||||
virtual void SetFocus(bool hasFocus);
|
||||
|
||||
protected:
|
||||
AppInterface *parent;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
68
DependentExtensions/Ogre3DInterpDemo/State.cpp
Normal file
68
DependentExtensions/Ogre3DInterpDemo/State.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oculus VR, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
|
||||
*
|
||||
*
|
||||
* Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
|
||||
*
|
||||
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
|
||||
* license found in the license.txt file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "slikenet/assert.h"
|
||||
#include "State.h"
|
||||
|
||||
|
||||
|
||||
State::State()
|
||||
{
|
||||
fsmRefCount=0;
|
||||
}
|
||||
State::~State()
|
||||
{
|
||||
|
||||
}
|
||||
void State::OnEnter(const FSM *caller, bool loadResources)
|
||||
{
|
||||
// unused parameters
|
||||
(void)caller;
|
||||
(void)loadResources;
|
||||
}
|
||||
void State::OnLeave(const FSM *caller, bool unloadResources)
|
||||
{
|
||||
// unused parameters
|
||||
(void)caller;
|
||||
(void)unloadResources;
|
||||
}
|
||||
void State::FSMAddRef(const FSM *caller)
|
||||
{
|
||||
// unused parameters
|
||||
(void)caller;
|
||||
|
||||
++fsmRefCount;
|
||||
}
|
||||
void State::FSMRemoveRef(const FSM *caller)
|
||||
{
|
||||
// unused parameters
|
||||
(void)caller;
|
||||
|
||||
RakAssert(fsmRefCount!=0);
|
||||
--fsmRefCount;
|
||||
}
|
||||
unsigned State::FSMRefCount(void) const
|
||||
{
|
||||
return fsmRefCount;
|
||||
}
|
||||
void ManagedState::FSMRemoveRef(const FSM *caller)
|
||||
{
|
||||
// unused parameters
|
||||
(void)caller;
|
||||
|
||||
RakAssert(fsmRefCount!=0);
|
||||
if (--fsmRefCount)
|
||||
delete this;
|
||||
}
|
||||
47
DependentExtensions/Ogre3DInterpDemo/State.h
Normal file
47
DependentExtensions/Ogre3DInterpDemo/State.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oculus VR, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __STATE_H
|
||||
#define __STATE_H
|
||||
|
||||
class FSM;
|
||||
|
||||
// States are stored in the FSM class (Finite state machine)
|
||||
// The FSM only has one active state at a time and stores the state history stack
|
||||
// State data can be held in this class - however data which is used between states is best stored elsewhere.
|
||||
class State
|
||||
{
|
||||
public:
|
||||
State();
|
||||
~State();
|
||||
// OnEnter is called when this state will not be the current state
|
||||
// loadResources true means this state is now in the history stack and was not there before
|
||||
virtual void OnEnter(const FSM *caller, bool loadResources);
|
||||
// OnLeave is called when this state is currently the current state and will no longer be the current state
|
||||
// unloadResources true means this state is no longer in the history stack and we will probably not be entering it again via the back button
|
||||
virtual void OnLeave(const FSM *caller, bool unloadResources);
|
||||
// Called once for every time this state is added to the FSM history stack
|
||||
virtual void FSMAddRef(const FSM *caller);
|
||||
// Called once for every time this state is removed from the FSM history stack.
|
||||
virtual void FSMRemoveRef(const FSM *caller);
|
||||
// The number of times this state is in the FSM history stack.
|
||||
unsigned FSMRefCount(void) const;
|
||||
protected:
|
||||
unsigned fsmRefCount;
|
||||
};
|
||||
|
||||
// Same as State, but self-deletes when fsmRefCount==0
|
||||
class ManagedState : public State
|
||||
{
|
||||
public:
|
||||
virtual void FSMRemoveRef(const FSM *caller);
|
||||
};
|
||||
|
||||
#endif
|
||||
150
DependentExtensions/Ogre3DInterpDemo/TransformationHistory.cpp
Normal file
150
DependentExtensions/Ogre3DInterpDemo/TransformationHistory.cpp
Normal file
@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Original work: Copyright (c) 2014, Oculus VR, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
|
||||
*
|
||||
*
|
||||
* Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
|
||||
*
|
||||
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
|
||||
* license found in the license.txt file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "slikenet/assert.h"
|
||||
#include "slikenet/memoryoverride.h"
|
||||
#include "TransformationHistory.h"
|
||||
|
||||
TransformationHistoryCell::TransformationHistoryCell()
|
||||
{
|
||||
|
||||
}
|
||||
TransformationHistoryCell::TransformationHistoryCell(SLNet::TimeMS t, const Ogre::Vector3& pos, const Ogre::Vector3& vel, const Ogre::Quaternion& quat ) :
|
||||
time(t),
|
||||
velocity(vel),
|
||||
position(pos),
|
||||
orientation(quat)
|
||||
{
|
||||
}
|
||||
|
||||
void TransformationHistory::Init(SLNet::TimeMS maxWriteInterval, SLNet::TimeMS maxHistoryTime)
|
||||
{
|
||||
writeInterval=maxWriteInterval;
|
||||
maxHistoryLength = maxHistoryTime/maxWriteInterval+1;
|
||||
history.ClearAndForceAllocation(maxHistoryLength+1, _FILE_AND_LINE_ );
|
||||
RakAssert(writeInterval>0);
|
||||
}
|
||||
void TransformationHistory::Write(const Ogre::Vector3 &position, const Ogre::Vector3 &velocity, const Ogre::Quaternion &orientation, SLNet::TimeMS curTimeMS)
|
||||
{
|
||||
if (history.Size()==0)
|
||||
{
|
||||
history.Push(TransformationHistoryCell(curTimeMS,position,velocity,orientation), _FILE_AND_LINE_ );
|
||||
}
|
||||
else
|
||||
{
|
||||
const TransformationHistoryCell &lastCell = history.PeekTail();
|
||||
if (curTimeMS-lastCell.time>=writeInterval)
|
||||
{
|
||||
history.Push(TransformationHistoryCell(curTimeMS,position,velocity,orientation), _FILE_AND_LINE_ );
|
||||
if (history.Size()>maxHistoryLength)
|
||||
history.Pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
void TransformationHistory::Overwrite(const Ogre::Vector3 &position, const Ogre::Vector3 &velocity, const Ogre::Quaternion &orientation, SLNet::TimeMS when)
|
||||
{
|
||||
int historySize = history.Size();
|
||||
if (historySize==0)
|
||||
{
|
||||
history.Push(TransformationHistoryCell(when,position,velocity,orientation), _FILE_AND_LINE_ );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Find the history matching this time, and change the values.
|
||||
int i;
|
||||
for (i=historySize-1; i>=0; i--)
|
||||
{
|
||||
TransformationHistoryCell &cell = history[i];
|
||||
if (when >= cell.time)
|
||||
{
|
||||
if (i==historySize-1 && when-cell.time>=writeInterval)
|
||||
{
|
||||
// Not an overwrite at all, but a new cell
|
||||
history.Push(TransformationHistoryCell(when,position,velocity,orientation), _FILE_AND_LINE_ );
|
||||
if (history.Size()>maxHistoryLength)
|
||||
history.Pop();
|
||||
return;
|
||||
}
|
||||
|
||||
cell.time=when;
|
||||
cell.position=position;
|
||||
cell.velocity=velocity;
|
||||
cell.orientation=orientation;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TransformationHistory::ReadResult TransformationHistory::Read(Ogre::Vector3 *position, Ogre::Vector3 *velocity, Ogre::Quaternion *orientation,
|
||||
SLNet::TimeMS when, SLNet::TimeMS curTime)
|
||||
{
|
||||
int historySize = history.Size();
|
||||
if (historySize==0)
|
||||
{
|
||||
return VALUES_UNCHANGED;
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i=historySize-1; i>=0; i--)
|
||||
{
|
||||
const TransformationHistoryCell &cell = history[i];
|
||||
if (when >= cell.time)
|
||||
{
|
||||
if (i==historySize-1)
|
||||
{
|
||||
if (curTime<=cell.time)
|
||||
return VALUES_UNCHANGED;
|
||||
|
||||
float divisor = (float)(curTime-cell.time);
|
||||
RakAssert(divisor!=0.0f);
|
||||
float lerp = (float)(when - cell.time) / divisor;
|
||||
if (position)
|
||||
*position=cell.position + (*position-cell.position) * lerp;
|
||||
if (velocity)
|
||||
*velocity=cell.velocity + (*velocity-cell.velocity) * lerp;
|
||||
if (orientation)
|
||||
*orientation = Ogre::Quaternion::Slerp(lerp, cell.orientation, *orientation,true);
|
||||
}
|
||||
else
|
||||
{
|
||||
const TransformationHistoryCell &nextCell = history[i+1];
|
||||
float divisor = (float)(nextCell.time-cell.time);
|
||||
RakAssert(divisor!=0.0f);
|
||||
float lerp = (float)(when - cell.time) / divisor;
|
||||
if (position)
|
||||
*position=cell.position + (nextCell.position-cell.position) * lerp;
|
||||
if (velocity)
|
||||
*velocity=cell.velocity + (nextCell.velocity-cell.velocity) * lerp;
|
||||
if (orientation)
|
||||
*orientation = Ogre::Quaternion::Slerp(lerp, cell.orientation, nextCell.orientation,true);
|
||||
}
|
||||
return INTERPOLATED;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the oldest one
|
||||
const TransformationHistoryCell &cell = history.Peek();
|
||||
if (position)
|
||||
*position=cell.position;
|
||||
if (orientation)
|
||||
*orientation=cell.orientation;
|
||||
if (velocity)
|
||||
*velocity=cell.velocity;
|
||||
return READ_OLDEST;
|
||||
}
|
||||
void TransformationHistory::Clear(void)
|
||||
{
|
||||
history.Clear(_FILE_AND_LINE_);
|
||||
}
|
||||
89
DependentExtensions/Ogre3DInterpDemo/TransformationHistory.h
Normal file
89
DependentExtensions/Ogre3DInterpDemo/TransformationHistory.h
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Original work: Copyright (c) 2014, Oculus VR, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
|
||||
*
|
||||
*
|
||||
* Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
|
||||
*
|
||||
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
|
||||
* license found in the license.txt file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef __TRANFORMATION_HISTORY_H
|
||||
#define __TRANFORMATION_HISTORY_H
|
||||
|
||||
#include "slikenet/types.h"
|
||||
#include "OgreVector3.h"
|
||||
#include "OgreQuaternion.h"
|
||||
#include "slikenet/DS_Queue.h"
|
||||
#include "slikenet/memoryoverride.h"
|
||||
|
||||
struct TransformationHistoryCell
|
||||
{
|
||||
TransformationHistoryCell();
|
||||
TransformationHistoryCell(SLNet::TimeMS t, const Ogre::Vector3& pos, const Ogre::Vector3& vel, const Ogre::Quaternion& quat );
|
||||
|
||||
SLNet::TimeMS time;
|
||||
Ogre::Vector3 position;
|
||||
Ogre::Quaternion orientation;
|
||||
Ogre::Vector3 velocity;
|
||||
};
|
||||
|
||||
/// \brief This class stores a series of data points consisting of position, orientation, and velocity
|
||||
/// Data points are written using Write(). The number of points stored is determined by the values passed to Init()
|
||||
/// Points are read out using Read(). Read() will interpolate between two known points given a time between those points, or between the last known and current point.
|
||||
/// For smooth interpolation, render entities by reading their past positions by whatever amount of time your update interval is.
|
||||
class TransformationHistory
|
||||
{
|
||||
public:
|
||||
/// \brief Call to setup this class with required parameters
|
||||
/// maxWriteInterval should be equal to or less than the interval between updates for a given entity
|
||||
/// maxHistoryTime is the maximum amount of time you want to read in the past
|
||||
/// \param[in] maxWriteInterval Minimum amount of time that must elapse between new data points added with Write.
|
||||
/// \param[in] maxHistoryTime How long to store data points before they expire
|
||||
void Init(SLNet::TimeMS maxWriteInterval, SLNet::TimeMS maxHistoryTime);
|
||||
|
||||
/// \brief Adds a new data point to the end of the queue
|
||||
/// If less than maxWriteInterval has elapsed since the last call, the Write() call is ignored.
|
||||
/// \param[in] position Position to write
|
||||
/// \param[in] velocity Velocity to write
|
||||
/// \param[in] orientation Orientation to write
|
||||
/// \param[in] curTimeMS Time when data point was generated, which should generally increment each call
|
||||
void Write(const Ogre::Vector3 &position, const Ogre::Vector3 &velocity, const Ogre::Quaternion &orientation, SLNet::TimeMS curTimeMS);
|
||||
|
||||
/// \brief Same as Write(), except that if the point is in the past, an older point updated
|
||||
void Overwrite(const Ogre::Vector3 &position, const Ogre::Vector3 &velocity, const Ogre::Quaternion &orientation, SLNet::TimeMS when);
|
||||
|
||||
enum ReadResult
|
||||
{
|
||||
// We are reading so far in the past there is no data yet
|
||||
READ_OLDEST,
|
||||
// We are not reading in the past, so the input parameters stay the same
|
||||
VALUES_UNCHANGED,
|
||||
// We are reading in the past
|
||||
INTERPOLATED
|
||||
};
|
||||
/// \brief Read an interpolated point in the psast
|
||||
/// Parameters are in/out, modified to reflect the history.
|
||||
/// \param[in/out] position As input, the current position of the object at \a curTime. As output, the position of the object at \when. Pass 0 to ignore.
|
||||
/// \param[in/out] velocity As input, the current velocity of the object at \a curTime. As output, the velocity of the object at \when. Pass 0 to ignore.
|
||||
/// \param[in/out] orientation As input, the current orientation of the object at \a curTime. As output, the orientation of the object at \when. Pass 0 to ignore.
|
||||
/// \param[in] when The time at which you want to read.
|
||||
/// \param[in] curTime Right now
|
||||
/// \return What method was used to calculate outputs
|
||||
ReadResult Read(Ogre::Vector3 *position, Ogre::Vector3 *velocity, Ogre::Quaternion *orientation,
|
||||
SLNet::TimeMS when, SLNet::TimeMS curTime);
|
||||
|
||||
/// \brief Clear all values in the history
|
||||
void Clear(void);
|
||||
protected:
|
||||
DataStructures::Queue<TransformationHistoryCell> history;
|
||||
unsigned maxHistoryLength;
|
||||
SLNet::TimeMS writeInterval;
|
||||
};
|
||||
|
||||
#endif
|
||||
693
DependentExtensions/Ogre3DInterpDemo/WinMain.cpp
Normal file
693
DependentExtensions/Ogre3DInterpDemo/WinMain.cpp
Normal file
@ -0,0 +1,693 @@
|
||||
/*
|
||||
* Original work: Copyright (c) 2014, Oculus VR, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
|
||||
*
|
||||
*
|
||||
* Modified work: Copyright (c) 2017-2020, SLikeSoft UG (haftungsbeschränkt)
|
||||
*
|
||||
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
|
||||
* license found in the license.txt file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// Demonstrates how to lag a client in the past using the interpolation history class,
|
||||
// in order to get smooth visuals despite choppy input.
|
||||
// Start two instances on the same computer, press 's' on one instance, 'c' on the other.
|
||||
// Hold down space to see the actual networking.
|
||||
// Change SERVER_IP_ADDRESS to connect over the internet
|
||||
|
||||
#ifdef WIN32
|
||||
#include "slikenet/WindowsIncludes.h"
|
||||
#else
|
||||
#define HWND void*
|
||||
#endif
|
||||
|
||||
// Ogre includes
|
||||
#include "OgreTextAreaOverlayElement.h"
|
||||
#include "Ogre.h"
|
||||
#include <OIS.h>
|
||||
|
||||
// Stuff to help run ogre
|
||||
#include "OverlayHelper.h"
|
||||
#include "App3D.h"
|
||||
|
||||
// RakNet includes
|
||||
#include "slikenet/GetTime.h"
|
||||
#include "slikenet/sleep.h"
|
||||
#include "slikenet/assert.h"
|
||||
#include "slikenet/StringTable.h"
|
||||
#include "slikenet/peerinterface.h"
|
||||
|
||||
#include "slikenet/BitStream.h"
|
||||
#include "slikenet/MessageIdentifiers.h"
|
||||
#include "slikenet/ReplicaManager3.h"
|
||||
#include "slikenet/NetworkIDManager.h"
|
||||
#include "slikenet/sleep.h"
|
||||
#include "slikenet/FormatString.h"
|
||||
#include "slikenet/StringCompressor.h"
|
||||
#include "slikenet/Rand.h"
|
||||
#include "TransformationHistory.h"
|
||||
|
||||
using namespace Ogre;
|
||||
using namespace DataStructures;
|
||||
using namespace OIS;
|
||||
using namespace SLNet;
|
||||
|
||||
class Popcorn;
|
||||
|
||||
// Network variables
|
||||
static const char *SERVER_IP_ADDRESS="127.0.0.1";
|
||||
static const unsigned short SERVER_PORT=12345;
|
||||
// How often the server sends position updates to the client
|
||||
static const int DEFAULT_SERVER_MILLISECONDS_BETWEEN_UPDATES=250;
|
||||
|
||||
// Demo variables
|
||||
static const int MIN_KERNELS=100;
|
||||
static const int KERNELS_VARIANCE=60;
|
||||
static const SLNet::TimeMS POP_COUNTDOWN_MIN_DELAY_MS=1000;
|
||||
static const SLNet::TimeMS POP_COUNTDOWN_VARIANCE_MS=5000;
|
||||
static const SLNet::TimeMS RESTART_TIMER_MS=14000;
|
||||
static const float POSITION_VARIANCE=100.0f;
|
||||
static const float PLANE_VELOCITY_VARIANCE=30.0f;
|
||||
static const float UPWARD_VELOCITY_MINIMUM=35.0f;
|
||||
static const float UPWARD_VELOCITY_VARIANCE=25.0f;
|
||||
static const float DOWNWARD_ACCELERATION = -15.0f;
|
||||
|
||||
bool isServer;
|
||||
Ogre::Entity *popcornKernel, *popcornPopped;
|
||||
SLNet::RakPeerInterface *rakPeer;
|
||||
DataStructures::List<Popcorn*> popcornList;
|
||||
bool enableInterpolation;
|
||||
|
||||
App3D *app;
|
||||
|
||||
// This class represents a kernel of popcorn, which pops after a short delay
|
||||
// When to pop, and the physics the popcorn takes is entirely controlled by the server
|
||||
// Every DEFAULT_SERVER_MILLISECONDS_BETWEEN_UPDATES the server will send an update
|
||||
// The client intentionally lags this far behind, so it always has a recent position to interpolate to
|
||||
class Popcorn : public Replica3
|
||||
{
|
||||
public:
|
||||
Popcorn() {
|
||||
// Buffer up for 3 seconds if we were to get 30 updates per second
|
||||
transformationHistory.Init(30,3000);
|
||||
|
||||
position=Ogre::Vector3::ZERO;
|
||||
orientation=Ogre::Quaternion::IDENTITY;
|
||||
// Visible position is where we are interpolating at, which is behind the real position
|
||||
visiblePosition=Ogre::Vector3::ZERO;
|
||||
visibleOrientation=Ogre::Quaternion::IDENTITY;
|
||||
isKernel=true;
|
||||
}
|
||||
virtual ~Popcorn()
|
||||
{
|
||||
if (isServer)
|
||||
BroadcastDestruction();
|
||||
|
||||
app->GetSceneManager()->destroyEntity(sceneNode->getAttachedObject(0)->getName());
|
||||
app->GetSceneManager()->getRootSceneNode()->removeAndDestroyChild(sceneNode->getName());
|
||||
popcornList.RemoveAtIndex(popcornList.GetIndexOf(this));
|
||||
}
|
||||
|
||||
bool isKernel;
|
||||
Ogre::Vector3 position;
|
||||
Ogre::Quaternion orientation;
|
||||
Ogre::Quaternion rotationalVelocity;
|
||||
Ogre::Vector3 velocity;
|
||||
Ogre::SceneNode *sceneNode;
|
||||
SLNet::TimeMS popCountdown;
|
||||
Ogre::Vector3 visiblePosition;
|
||||
Ogre::Quaternion visibleOrientation;
|
||||
TransformationHistory transformationHistory;
|
||||
|
||||
virtual void WriteAllocationID(SLNet::Connection_RM3 *destinationConnection, SLNet::BitStream *allocationIdBitstream) const
|
||||
{
|
||||
StringTable::Instance()->EncodeString("Popcorn", 128, allocationIdBitstream);
|
||||
}
|
||||
virtual RM3ConstructionState QueryConstruction(SLNet::Connection_RM3 *destinationConnection, ReplicaManager3 *replicaManager3)
|
||||
{
|
||||
if (isServer)
|
||||
return QueryConstruction_ServerConstruction(destinationConnection, isServer);
|
||||
else
|
||||
return QueryConstruction_ClientConstruction(destinationConnection, isServer);
|
||||
}
|
||||
virtual bool QueryRemoteConstruction(SLNet::Connection_RM3 *sourceConnection){
|
||||
if (isServer)
|
||||
return QueryRemoteConstruction_ServerConstruction(sourceConnection, isServer);
|
||||
else
|
||||
return QueryRemoteConstruction_ClientConstruction(sourceConnection, isServer);
|
||||
}
|
||||
virtual void SerializeConstruction(SLNet::BitStream *constructionBitstream, SLNet::Connection_RM3 *destinationConnection){}
|
||||
virtual bool DeserializeConstruction(SLNet::BitStream *constructionBitstream, SLNet::Connection_RM3 *sourceConnection){return true;}
|
||||
virtual void SerializeDestruction(SLNet::BitStream *destructionBitstream, SLNet::Connection_RM3 *destinationConnection){}
|
||||
virtual bool DeserializeDestruction(SLNet::BitStream *destructionBitstream, SLNet::Connection_RM3 *sourceConnection){return true;}
|
||||
virtual RM3ActionOnPopConnection QueryActionOnPopConnection(SLNet::Connection_RM3 *droppedConnection) const
|
||||
{
|
||||
if (isServer)
|
||||
return QueryActionOnPopConnection_Server(droppedConnection);
|
||||
else
|
||||
return QueryActionOnPopConnection_Client(droppedConnection);
|
||||
}
|
||||
virtual void DeallocReplica(SLNet::Connection_RM3 *sourceConnection) {delete this;}
|
||||
virtual RM3QuerySerializationResult QuerySerialization(SLNet::Connection_RM3 *destinationConnection)
|
||||
{
|
||||
if (isServer)
|
||||
return QuerySerialization_ServerSerializable(destinationConnection, isServer);
|
||||
else
|
||||
return QuerySerialization_ClientSerializable(destinationConnection, isServer);
|
||||
}
|
||||
virtual RM3SerializationResult Serialize(SLNet::SerializeParameters *serializeParameters)
|
||||
{
|
||||
// Autoserialize causes a network packet to go out when any of these member variables change.
|
||||
RakAssert(isServer==true);
|
||||
serializeParameters->outputBitstream[0].Write(isKernel);
|
||||
serializeParameters->outputBitstream[0].WriteAlignedBytes((const unsigned char*)&position,sizeof(position));
|
||||
serializeParameters->outputBitstream[0].WriteAlignedBytes((const unsigned char*)&velocity,sizeof(velocity));
|
||||
serializeParameters->outputBitstream[0].WriteAlignedBytes((const unsigned char*)&orientation,sizeof(orientation));
|
||||
return RM3SR_BROADCAST_IDENTICALLY;
|
||||
}
|
||||
virtual void Deserialize(SLNet::DeserializeParameters *deserializeParameters)
|
||||
{
|
||||
bool lastIsKernel = isKernel;
|
||||
|
||||
// Doing this because we are also lagging position and orientation behind by DEFAULT_SERVER_MILLISECONDS_BETWEEN_UPDATES
|
||||
// Without it, the kernel would pop immediately but would not start moving
|
||||
deserializeParameters->serializationBitstream[0].Read(isKernel);
|
||||
if (isKernel==false && lastIsKernel==true)
|
||||
popCountdown=DEFAULT_SERVER_MILLISECONDS_BETWEEN_UPDATES;
|
||||
|
||||
deserializeParameters->serializationBitstream[0].ReadAlignedBytes((unsigned char*)&position,sizeof(position));
|
||||
deserializeParameters->serializationBitstream[0].ReadAlignedBytes((unsigned char*)&velocity,sizeof(velocity));
|
||||
deserializeParameters->serializationBitstream[0].ReadAlignedBytes((unsigned char*)&orientation,sizeof(orientation));
|
||||
|
||||
// Scene node starts invisible until we deserialize the intial startup data
|
||||
// This data could also have been passed in SerializeConstruction()
|
||||
sceneNode->setVisible(true,true);
|
||||
|
||||
// Every time we get a network packet, we write it to the transformation history class.
|
||||
// This class, given a time in the past, can then return to us an interpolated position of where we should be in at that time
|
||||
transformationHistory.Write(position,velocity,orientation, SLNet::GetTimeMS());
|
||||
}
|
||||
|
||||
virtual void SetToPopped(void)
|
||||
{
|
||||
// Change the mesh, and add some velocity.
|
||||
isKernel=false;
|
||||
if (sceneNode->getAttachedObject(0))
|
||||
app->GetSceneManager()->destroyEntity(sceneNode->getAttachedObject(0)->getName());
|
||||
sceneNode->detachAllObjects();
|
||||
sceneNode->attachObject(popcornPopped->clone(FormatString("%p",this)));
|
||||
if (isServer)
|
||||
{
|
||||
velocity.x=-PLANE_VELOCITY_VARIANCE/2.0f+frandomMT()*PLANE_VELOCITY_VARIANCE;
|
||||
velocity.y=UPWARD_VELOCITY_MINIMUM+frandomMT()*UPWARD_VELOCITY_VARIANCE;
|
||||
velocity.z=-PLANE_VELOCITY_VARIANCE/2.0f+frandomMT()*PLANE_VELOCITY_VARIANCE;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Update(SLNet::TimeMS timeElapsedMs)
|
||||
{
|
||||
visiblePosition=position;
|
||||
visibleOrientation=orientation;
|
||||
|
||||
if (isKernel==false)
|
||||
{
|
||||
if (isServer)
|
||||
{
|
||||
// Only the server is doing physics
|
||||
float timeElapsedSec = timeElapsedMs * .001f;
|
||||
position += velocity * timeElapsedSec + .5f * Ogre::Vector3(0.0f, DOWNWARD_ACCELERATION, 0.0f) * timeElapsedSec*timeElapsedSec;;
|
||||
velocity += Ogre::Vector3(0.0f, DOWNWARD_ACCELERATION, 0.0f) * timeElapsedSec;
|
||||
orientation = Quaternion::Slerp(timeElapsedSec, orientation, orientation * rotationalVelocity, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// See above - delay the pop until we start moving
|
||||
if (popCountdown <= timeElapsedMs)
|
||||
{
|
||||
SetToPopped();
|
||||
// #med - use unsigned short max?
|
||||
popCountdown= static_cast<SLNet::TimeMS>(-1);
|
||||
}
|
||||
else
|
||||
popCountdown-=timeElapsedMs;
|
||||
|
||||
// interpolate visible position, lagging behind by a small amount so where know where to update to
|
||||
if (enableInterpolation)
|
||||
{
|
||||
// Important: the first 3 parameters are in/out parameters, so set their values to the known current values before calling Read()
|
||||
// We are subtracting DEFAULT_SERVER_MILLISECONDS_BETWEEN_UPDATES from the current time to get an interpolated position in the past
|
||||
// Without this we wouldn't have a node to interpolate to, and wouldn't know where to go
|
||||
transformationHistory.Read(&visiblePosition, 0, &visibleOrientation, SLNet::GetTimeMS()-DEFAULT_SERVER_MILLISECONDS_BETWEEN_UPDATES, SLNet::GetTimeMS());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isServer)
|
||||
{
|
||||
if (popCountdown <= timeElapsedMs)
|
||||
{
|
||||
// Only the server controls when to pop
|
||||
SetToPopped();
|
||||
}
|
||||
else
|
||||
popCountdown-=timeElapsedMs;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sceneNode->setPosition(visiblePosition);
|
||||
sceneNode->setOrientation(visibleOrientation);
|
||||
}
|
||||
|
||||
|
||||
static void ClearPopcorn()
|
||||
{
|
||||
// Destructor removes itself from this list
|
||||
while (popcornList.Size())
|
||||
delete popcornList[popcornList.Size()-1];
|
||||
}
|
||||
static Popcorn * CreateKernel(ReplicaManager3 *replicaManager3)
|
||||
{
|
||||
Popcorn *p = new Popcorn;
|
||||
// Tell the replication system about this new Replica instance.
|
||||
replicaManager3->Reference(p);
|
||||
static int count=0;
|
||||
count++;
|
||||
popcornList.Insert(p, _FILE_AND_LINE_ );
|
||||
p->sceneNode = app->GetSceneManager()->getRootSceneNode()->createChildSceneNode();
|
||||
p->sceneNode->attachObject(popcornKernel->clone(FormatString("%p",p)));
|
||||
|
||||
// Only server sets up initial positions, etc.
|
||||
if (isServer)
|
||||
{
|
||||
p->position.x=-POSITION_VARIANCE/2.0f+frandomMT()*POSITION_VARIANCE;
|
||||
p->position.y=0.0f;
|
||||
p->position.z=-POSITION_VARIANCE/2.0f+frandomMT()*POSITION_VARIANCE;
|
||||
p->velocity=Ogre::Vector3::ZERO;
|
||||
p->popCountdown=POP_COUNTDOWN_MIN_DELAY_MS + randomMT() % POP_COUNTDOWN_VARIANCE_MS;
|
||||
p->orientation.FromAngleAxis(Ogre::Radian(frandomMT()*6.28f), Ogre::Vector3(-1.0f+frandomMT()*2.0f,-1.0f+frandomMT()*2.0f,-1.0f+frandomMT()*2.0f).normalisedCopy());
|
||||
p->rotationalVelocity.FromAngleAxis(Ogre::Radian(frandomMT()*6.28f), Ogre::Vector3(-1.0f+frandomMT()*2.0f,-1.0f+frandomMT()*2.0f,-1.0f+frandomMT()*2.0f).normalisedCopy());
|
||||
p->visiblePosition=p->position;
|
||||
p->visibleOrientation=p->orientation;
|
||||
}
|
||||
else
|
||||
p->sceneNode->setVisible(false,true);
|
||||
|
||||
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
// One instance of Connection_RM2 is implicitly created per connection that uses ReplicaManager2. The most important function to implement is Construct() as this creates your game objects.
|
||||
// It is designed this way so you can override per-connection behavior in your own game classes
|
||||
class PopcornSampleConnection : public Connection_RM3
|
||||
{
|
||||
public:
|
||||
PopcornSampleConnection(const SystemAddress &_systemAddress, RakNetGUID _guid) : Connection_RM3(_systemAddress,_guid) {}
|
||||
virtual ~PopcornSampleConnection() {}
|
||||
|
||||
// Callback used to create objects
|
||||
// See Connection_RM2::Construct in ReplicaManager2.h for a full explanation of each parameter
|
||||
virtual Replica3 *AllocReplica(SLNet::BitStream *allocationIdBitstream, ReplicaManager3 *replicaManager3)
|
||||
{
|
||||
char objectName[128];
|
||||
StringTable::Instance()->DecodeString(objectName,128,allocationIdBitstream);
|
||||
if (strcmp(objectName,"Popcorn")==0)
|
||||
{
|
||||
return Popcorn::CreateKernel(replicaManager3);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
class PopcornDemoRM3 : public ReplicaManager3
|
||||
{
|
||||
virtual Connection_RM3* AllocConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID) const {return new PopcornSampleConnection(systemAddress,rakNetGUID);}
|
||||
virtual void DeallocConnection(Connection_RM3 *connection) const {delete connection;}
|
||||
};
|
||||
PopcornDemoRM3 popcornReplicaManager3;
|
||||
class ExampleApp : public App3D
|
||||
{
|
||||
public:
|
||||
ExampleApp()
|
||||
{
|
||||
quit=false;
|
||||
}
|
||||
|
||||
~ExampleApp()
|
||||
{
|
||||
}
|
||||
|
||||
void OnAppShutdown( void )
|
||||
{
|
||||
Popcorn::ClearPopcorn();
|
||||
|
||||
App3D::OnAppShutdown();
|
||||
|
||||
if( mInputManager )
|
||||
{
|
||||
mInputManager->destroyInputObject( mKeyboard );
|
||||
OIS::InputManager::destroyInputSystem(mInputManager);
|
||||
mInputManager = 0;
|
||||
}
|
||||
|
||||
SLNet::RakPeerInterface::DestroyInstance(rakPeer);
|
||||
|
||||
}
|
||||
|
||||
void Render(AppTime curTimeMS)
|
||||
{
|
||||
App3D::Render(curTimeMS);
|
||||
}
|
||||
|
||||
bool ShouldQuit(void) const {return quit || window->isClosed();}
|
||||
|
||||
void Update(AppTime curTimeMS, AppTime elapsedTimeMS)
|
||||
{
|
||||
#ifndef WIN32
|
||||
WindowEventUtilities::messagePump();
|
||||
#endif
|
||||
|
||||
// Update all subsystems
|
||||
App3D::Update(curTimeMS, elapsedTimeMS);
|
||||
overlayHelper.Update(elapsedTimeMS);
|
||||
|
||||
mKeyboard->capture();
|
||||
|
||||
Ogre::Vector3 mTranslateVector = Ogre::Vector3::ZERO;
|
||||
|
||||
float mMoveSpeed=50.0f;
|
||||
float mRotateSpeed=1.0f;
|
||||
float mMoveScale = mMoveSpeed * elapsedTimeMS * .001f;
|
||||
// Take about 10 seconds for full rotation
|
||||
Ogre::Radian mRotScale(mRotateSpeed * elapsedTimeMS * .001f);
|
||||
|
||||
if(mKeyboard->isKeyDown(KC_A))
|
||||
mTranslateVector.x = -mMoveScale; // Move camera left
|
||||
|
||||
if(mKeyboard->isKeyDown(KC_D))
|
||||
mTranslateVector.x = mMoveScale; // Move camera RIGHT
|
||||
|
||||
if(mKeyboard->isKeyDown(KC_UP) || mKeyboard->isKeyDown(KC_W) )
|
||||
mTranslateVector.z = -mMoveScale; // Move camera forward
|
||||
|
||||
if(mKeyboard->isKeyDown(KC_DOWN) || mKeyboard->isKeyDown(KC_S) )
|
||||
mTranslateVector.z = mMoveScale; // Move camera backward
|
||||
|
||||
if(mKeyboard->isKeyDown(KC_PGUP))
|
||||
mTranslateVector.y = mMoveScale; // Move camera up
|
||||
|
||||
if(mKeyboard->isKeyDown(KC_PGDOWN))
|
||||
mTranslateVector.y = -mMoveScale; // Move camera down
|
||||
|
||||
if(mKeyboard->isKeyDown(KC_RIGHT))
|
||||
camera->yaw(-mRotScale);
|
||||
|
||||
if(mKeyboard->isKeyDown(KC_LEFT))
|
||||
camera->yaw(mRotScale);
|
||||
|
||||
// Hold down space to see what it looks like without interpolation
|
||||
if(mKeyboard->isKeyDown(KC_SPACE))
|
||||
enableInterpolation=false;
|
||||
else
|
||||
enableInterpolation=true;
|
||||
|
||||
static bool didUpdateDelayLastTick=false;
|
||||
bool didUpdateDelayThisTick=false;
|
||||
|
||||
if (isStarted==false)
|
||||
{
|
||||
SLNet::SocketDescriptor sd;
|
||||
|
||||
if(mKeyboard->isKeyDown(KC_S))
|
||||
{
|
||||
// Start server
|
||||
isStarted=true;
|
||||
isServer=true;
|
||||
ShowMessage("Server started");
|
||||
sd.port=SERVER_PORT;
|
||||
|
||||
}
|
||||
|
||||
if(mKeyboard->isKeyDown(KC_C))
|
||||
{
|
||||
isStarted=true;
|
||||
ShowMessage(FormatString("Client started, connecting to %s", SERVER_IP_ADDRESS));
|
||||
// Start server
|
||||
isStarted=true;
|
||||
isServer=false;
|
||||
sd.port=0;
|
||||
}
|
||||
|
||||
if (isStarted)
|
||||
{
|
||||
// Start RakNet, up to 32 connections if the server
|
||||
rakPeer = SLNet::RakPeerInterface::GetInstance();
|
||||
StartupResult sr = rakPeer->Startup(isServer ? 32 : 1,&sd,1);
|
||||
RakAssert(sr==RAKNET_STARTED);
|
||||
rakPeer->AttachPlugin(&popcornReplicaManager3);
|
||||
popcornReplicaManager3.SetNetworkIDManager(&networkIdManager);
|
||||
//rakPeer->SetNetworkIDManager(&networkIdManager);
|
||||
// The server should allow systems to connect. Clients do not need to unless you want to use RakVoice or for some other reason want to transmit directly between systems.
|
||||
if (isServer)
|
||||
{
|
||||
rakPeer->SetMaximumIncomingConnections(32);
|
||||
}
|
||||
else
|
||||
{
|
||||
ConnectionAttemptResult car = rakPeer->Connect(SERVER_IP_ADDRESS,SERVER_PORT,0,0);
|
||||
RakAssert(car==CONNECTION_ATTEMPT_STARTED);
|
||||
|
||||
}
|
||||
popcornReplicaManager3.SetAutoSerializeInterval(DEFAULT_SERVER_MILLISECONDS_BETWEEN_UPDATES);
|
||||
|
||||
// StringTable has to be called after RakPeer started, or else first call StringTable::AddRef() yourself
|
||||
StringTable::Instance()->AddString("Popcorn",false);
|
||||
}
|
||||
}
|
||||
|
||||
if (isStarted)
|
||||
{
|
||||
SLNet::Packet *packet;
|
||||
for (packet = rakPeer->Receive(); packet; rakPeer->DeallocatePacket(packet), packet = rakPeer->Receive())
|
||||
{
|
||||
switch (packet->data[0])
|
||||
{
|
||||
case ID_CONNECTION_ATTEMPT_FAILED:
|
||||
ShowMessage("ID_CONNECTION_ATTEMPT_FAILED\n");
|
||||
break;
|
||||
case ID_NO_FREE_INCOMING_CONNECTIONS:
|
||||
ShowMessage("ID_NO_FREE_INCOMING_CONNECTIONS\n");
|
||||
break;
|
||||
case ID_CONNECTION_REQUEST_ACCEPTED:
|
||||
ShowMessage("ID_CONNECTION_REQUEST_ACCEPTED\n");
|
||||
break;
|
||||
case ID_NEW_INCOMING_CONNECTION:
|
||||
ShowMessage(FormatString("ID_NEW_INCOMING_CONNECTION from %s\n", packet->systemAddress.ToString()));
|
||||
break;
|
||||
case ID_DISCONNECTION_NOTIFICATION:
|
||||
ShowMessage("ID_DISCONNECTION_NOTIFICATION\n");
|
||||
break;
|
||||
case ID_CONNECTION_LOST:
|
||||
ShowMessage("ID_CONNECTION_LOST\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isServer)
|
||||
{
|
||||
// Restart the demo every RESTART_TIMER_MS milliseconds
|
||||
if (popcornLifetimeCountdown<=elapsedTimeMS)
|
||||
{
|
||||
Popcorn::ClearPopcorn();
|
||||
CreateKernels(&popcornReplicaManager3);
|
||||
popcornLifetimeCountdown=RESTART_TIMER_MS;
|
||||
}
|
||||
popcornLifetimeCountdown-=elapsedTimeMS;
|
||||
}
|
||||
|
||||
|
||||
unsigned i;
|
||||
for (i=0; i < popcornList.Size(); i++)
|
||||
{
|
||||
popcornList[i]->Update(elapsedTimeMS);
|
||||
}
|
||||
}
|
||||
|
||||
camera->moveRelative(mTranslateVector);
|
||||
|
||||
if( mKeyboard->isKeyDown(KC_ESCAPE) || mKeyboard->isKeyDown(KC_Q) )
|
||||
quit=true;
|
||||
}
|
||||
|
||||
// Just Ogre startup stuff
|
||||
virtual void PostConfigure(const char *defaultResourceConfigurationPath, bool recursive)
|
||||
{
|
||||
App3D::PostConfigure(defaultResourceConfigurationPath, false);
|
||||
App3D::InitSceneManager(0);
|
||||
App3D::InitGUIManager();
|
||||
App3D::InitCamera(0);
|
||||
App3D::InitViewport(0);
|
||||
|
||||
ParamList pl;
|
||||
size_t windowHnd = 0;
|
||||
std::ostringstream windowHndStr;
|
||||
|
||||
window->getCustomAttribute("WINDOW", &windowHnd);
|
||||
windowHndStr << windowHnd;
|
||||
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
|
||||
|
||||
mInputManager = InputManager::createInputSystem( pl );
|
||||
//Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse)
|
||||
mKeyboard = static_cast<Keyboard*>(mInputManager->createInputObject( OISKeyboard, false ));
|
||||
|
||||
// Start the overlay helper class, which handles fading of overlays and other stuff
|
||||
overlayHelper.Startup();
|
||||
|
||||
sceneManager->setAmbientLight( ColourValue( .5, .5, .5 ) );
|
||||
|
||||
mainLight = sceneManager->createLight("MainLight");
|
||||
mainLightNode = sceneManager->getRootSceneNode()->createChildSceneNode( "MainLightNode" );
|
||||
mainLightNode->attachObject(mainLight);
|
||||
mainLight->setType(Light::LT_POINT);
|
||||
mainLight->setPosition(200.0f, 200.0f, 200.0f);
|
||||
|
||||
camera->setPosition(150.0f, 150.0f, 70.0f);
|
||||
camera->lookAt(0.0f,50.0f,0.0f);
|
||||
camera->setNearClipDistance(1.0f);
|
||||
|
||||
popcornKernel = sceneManager->createEntity("PopcornKernel", "PopcornKernel.mesh");
|
||||
popcornPopped = sceneManager->createEntity("PopcornPopped", "PopcornPopped.mesh");
|
||||
popcornLifetimeCountdown=0;
|
||||
|
||||
sceneManager->setSkyBox(true, "Examples/SteveCubeSkyBox");
|
||||
isStarted=false;
|
||||
enableInterpolation=true;
|
||||
|
||||
|
||||
// Bug: Since updating to ogre OgreSDK_vc8_v1-7-1 from Ogre 3D 1.6.2, the first call to ShowMessage doesn't show up anymore
|
||||
ShowMessage("'S'erver. 'C'lient. Hold ' ' to disable interp.");
|
||||
ShowMessage("'S'erver. 'C'lient. Hold ' ' to disable interp.");
|
||||
}
|
||||
|
||||
virtual void CreateKernels(ReplicaManager3 *replicaManager3)
|
||||
{
|
||||
RakAssert(isServer);
|
||||
unsigned int kernelCount;
|
||||
// #med - consider using a template function instead of the if/else construct and/or introduce a cleaner/simpler macro
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4127) // conditional expression is constant
|
||||
#endif
|
||||
if (KERNELS_VARIANCE!=0)
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
kernelCount = MIN_KERNELS + randomMT() % KERNELS_VARIANCE;
|
||||
else
|
||||
kernelCount = MIN_KERNELS;
|
||||
for (unsigned int i=0; i < kernelCount; i++)
|
||||
Popcorn::CreateKernel(replicaManager3);
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual char * GetWindowTitle(void) const {return (char *)"Popcorn popper";}
|
||||
void ShowMessage(const char *msg, float timescale=1.0f)
|
||||
{
|
||||
// Create a panel
|
||||
static int count=0;
|
||||
OverlayContainer* panel =overlayHelper.CreatePanel(FormatString("%i",count++));
|
||||
panel->setMetricsMode(Ogre::GMM_PIXELS);
|
||||
panel->setPosition(10, 10);
|
||||
panel->setDimensions(100, 100);
|
||||
//panel->setMaterialName("MaterialName"); // Optional background material
|
||||
|
||||
// Create a text area
|
||||
TextAreaOverlayElement *textArea = overlayHelper.CreateTextArea(FormatString("%i",count++), "BlueHighway", panel);
|
||||
textArea->setMetricsMode(Ogre::GMM_PIXELS);
|
||||
textArea->setPosition(10, 10);
|
||||
textArea->setDimensions(200, 200);
|
||||
textArea->setCaption(msg);
|
||||
textArea->setCharHeight(32);
|
||||
textArea->setColourBottom(ColourValue(0.3f, 0.5f, 0.3f));
|
||||
textArea->setColourTop(ColourValue(0.5f, 0.7f, 0.5f));
|
||||
|
||||
// Destroy the children (the text area) before destroying the parents.
|
||||
overlayHelper.FadeOverlayElement(textArea, static_cast<unsigned int>(3000*timescale), static_cast<unsigned int>(1000 * timescale), 0.0f, true);
|
||||
overlayHelper.FadeOverlayElement(panel, static_cast<unsigned int>(3000 * timescale), static_cast<unsigned int>(1000 * timescale), 0.0f, true);
|
||||
}
|
||||
|
||||
// Our major systems. Note the base class ExampleApplication has all the Ogre 3D systems
|
||||
OverlayHelper overlayHelper;
|
||||
bool quit;
|
||||
|
||||
SceneNode *mainLightNode;
|
||||
Light *mainLight;
|
||||
|
||||
OIS::InputManager* mInputManager;
|
||||
OIS::Keyboard* mKeyboard;
|
||||
|
||||
NetworkIDManager networkIdManager;
|
||||
bool isStarted;
|
||||
SLNet::TimeMS popcornLifetimeCountdown;
|
||||
};
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||
#else
|
||||
int main (int argc, char** argv)
|
||||
#endif
|
||||
{
|
||||
|
||||
HWND hWnd;
|
||||
SLNet::TimeMS curTime, lastTime, elapsed;
|
||||
app = new ExampleApp;
|
||||
app->PreConfigure();
|
||||
if (app->Configure()==false)
|
||||
{
|
||||
delete app;
|
||||
return 0;
|
||||
}
|
||||
#ifdef WIN32
|
||||
app->window->getCustomAttribute("HWND", &hWnd);
|
||||
MSG msg;
|
||||
#else
|
||||
app->window->getCustomAttribute("GLXWINDOW", &hWnd);
|
||||
#endif
|
||||
|
||||
app->PostConfigure("resources.cfg",false);
|
||||
lastTime= SLNet::GetTimeMS();
|
||||
|
||||
while (app->ShouldQuit()==false)
|
||||
{
|
||||
curTime= SLNet::GetTimeMS();
|
||||
elapsed = curTime-lastTime;
|
||||
if (elapsed > 100)
|
||||
elapsed=100; // Spike limiter
|
||||
app->Update(curTime, elapsed);
|
||||
lastTime=curTime;
|
||||
app->Render(curTime);
|
||||
#ifdef WIN32
|
||||
if (PeekMessage( &msg, nullptr, 0U, 0U, PM_REMOVE )>0)
|
||||
{
|
||||
TranslateMessage( &msg );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
#endif
|
||||
// Make sure the RakNet thread runs
|
||||
RakSleep(0);
|
||||
}
|
||||
|
||||
app->OnAppShutdown();
|
||||
|
||||
delete app;
|
||||
|
||||
return 0;
|
||||
}
|
||||
8
DependentExtensions/Ogre3DInterpDemo/resources.cfg
Normal file
8
DependentExtensions/Ogre3DInterpDemo/resources.cfg
Normal file
@ -0,0 +1,8 @@
|
||||
# Resource locations to be added to the 'boostrap' path
|
||||
[Bootstrap]
|
||||
Zip=./OgreResources/OgreCore.zip
|
||||
Zip=./OgreResources/skybox.zip
|
||||
|
||||
# Resource locations to be added to the default path
|
||||
[General]
|
||||
FileSystem=./OgreResources
|
||||
Reference in New Issue
Block a user