2015-07-15 16:07:47 +00:00
|
|
|
|
|
|
|
#include "TimeSeriesExample.h"
|
|
|
|
|
|
|
|
#include "../CommonInterfaces/CommonGraphicsAppInterface.h"
|
|
|
|
#include "../CommonInterfaces/CommonRenderInterface.h"
|
|
|
|
|
|
|
|
#include "../CommonInterfaces/Common2dCanvasInterface.h"
|
|
|
|
#include "../CommonInterfaces/CommonExampleInterface.h"
|
|
|
|
#include "LinearMath/btAlignedObjectArray.h"
|
|
|
|
#include "btBulletCollisionCommon.h"
|
|
|
|
#include "../CommonInterfaces/CommonGUIHelperInterface.h"
|
|
|
|
|
2015-08-07 20:17:33 +00:00
|
|
|
#include "TimeSeriesCanvas.h"
|
|
|
|
|
2015-07-15 16:07:47 +00:00
|
|
|
struct TimeSeriesExample : public CommonExampleInterface
|
|
|
|
{
|
|
|
|
struct CommonGraphicsApp* m_app;
|
|
|
|
struct TimeSeriesExampleInternalData* m_internalData;
|
|
|
|
|
|
|
|
TimeSeriesExample(struct CommonGraphicsApp* app);
|
|
|
|
|
|
|
|
virtual ~TimeSeriesExample();
|
|
|
|
|
|
|
|
virtual void initPhysics();
|
|
|
|
|
|
|
|
virtual void exitPhysics();
|
|
|
|
|
|
|
|
virtual void stepSimulation(float deltaTime);
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void physicsDebugDraw(int debugFlags);
|
2015-07-15 16:07:47 +00:00
|
|
|
|
|
|
|
virtual void syncPhysicsToGraphics(struct GraphicsPhysicsBridge& gfxBridge);
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual bool mouseMoveCallback(float x, float y);
|
2015-07-15 16:07:47 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual bool mouseButtonCallback(int button, int state, float x, float y);
|
2015-07-15 16:07:47 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual bool keyboardCallback(int key, int state);
|
2015-07-15 16:07:47 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void renderScene()
|
2015-07-15 16:07:47 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TimeSeriesExampleInternalData
|
|
|
|
{
|
2015-08-07 20:17:33 +00:00
|
|
|
TimeSeriesCanvas* m_timeSeriesCanvas;
|
2015-07-15 16:07:47 +00:00
|
|
|
|
|
|
|
TimeSeriesExampleInternalData()
|
2018-09-23 21:17:31 +00:00
|
|
|
: m_timeSeriesCanvas(0)
|
2015-07-15 16:07:47 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TimeSeriesExample::TimeSeriesExample(struct CommonGraphicsApp* app)
|
|
|
|
{
|
|
|
|
m_app = app;
|
|
|
|
m_internalData = new TimeSeriesExampleInternalData;
|
|
|
|
}
|
|
|
|
|
|
|
|
TimeSeriesExample::~TimeSeriesExample()
|
|
|
|
{
|
2015-08-07 20:17:33 +00:00
|
|
|
delete m_internalData->m_timeSeriesCanvas;
|
2015-07-15 16:07:47 +00:00
|
|
|
delete m_internalData;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TimeSeriesExample::initPhysics()
|
|
|
|
{
|
|
|
|
//request a visual bitma/texture we can render to
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
m_internalData->m_timeSeriesCanvas = new TimeSeriesCanvas(m_app->m_2dCanvasInterface, 512, 512, "Test");
|
|
|
|
m_internalData->m_timeSeriesCanvas->setupTimeSeries(3, 100, 0);
|
|
|
|
m_internalData->m_timeSeriesCanvas->addDataSource("Some sine wave", 255, 0, 0);
|
|
|
|
m_internalData->m_timeSeriesCanvas->addDataSource("Some cosine wave", 0, 255, 0);
|
|
|
|
m_internalData->m_timeSeriesCanvas->addDataSource("Delta Time (*10)", 0, 0, 255);
|
|
|
|
m_internalData->m_timeSeriesCanvas->addDataSource("Tan", 255, 0, 255);
|
|
|
|
m_internalData->m_timeSeriesCanvas->addDataSource("Some cosine wave2", 255, 255, 0);
|
|
|
|
m_internalData->m_timeSeriesCanvas->addDataSource("Empty source2", 255, 0, 255);
|
|
|
|
}
|
2015-07-15 16:07:47 +00:00
|
|
|
|
|
|
|
void TimeSeriesExample::exitPhysics()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void TimeSeriesExample::stepSimulation(float deltaTime)
|
|
|
|
{
|
2015-08-07 20:17:33 +00:00
|
|
|
float time = m_internalData->m_timeSeriesCanvas->getCurrentTime();
|
|
|
|
float v = sinf(time);
|
2018-09-23 21:17:31 +00:00
|
|
|
m_internalData->m_timeSeriesCanvas->insertDataAtCurrentTime(v, 0, true);
|
2015-08-07 20:17:33 +00:00
|
|
|
v = cosf(time);
|
2018-09-23 21:17:31 +00:00
|
|
|
m_internalData->m_timeSeriesCanvas->insertDataAtCurrentTime(v, 1, true);
|
2015-08-07 20:17:33 +00:00
|
|
|
v = tanf(time);
|
2018-09-23 21:17:31 +00:00
|
|
|
m_internalData->m_timeSeriesCanvas->insertDataAtCurrentTime(v, 3, true);
|
|
|
|
m_internalData->m_timeSeriesCanvas->insertDataAtCurrentTime(deltaTime * 10, 2, true);
|
2015-07-15 16:07:47 +00:00
|
|
|
|
2015-08-07 20:17:33 +00:00
|
|
|
m_internalData->m_timeSeriesCanvas->nextTick();
|
2015-07-15 16:07:47 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
void TimeSeriesExample::physicsDebugDraw(int debugDrawFlags)
|
2015-07-15 16:07:47 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
bool TimeSeriesExample::mouseMoveCallback(float x, float y)
|
2015-07-15 16:07:47 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
bool TimeSeriesExample::mouseButtonCallback(int button, int state, float x, float y)
|
2015-07-15 16:07:47 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
bool TimeSeriesExample::keyboardCallback(int key, int state)
|
2015-07-15 16:07:47 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TimeSeriesExample::syncPhysicsToGraphics(GraphicsPhysicsBridge& gfxBridge)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
CommonExampleInterface* TimeSeriesCreateFunc(struct CommonExampleOptions& options)
|
|
|
|
{
|
|
|
|
return new TimeSeriesExample(options.m_guiHelper->getAppInterface());
|
|
|
|
}
|