minor cleanup of btgui/demo3 stuff, much more demo cleanup is needed
moved some files in btgui/Bullet3AppSupport
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#ifndef BULLET_DEMO_ENTRIES_H
|
||||
#define BULLET_DEMO_ENTRIES_H
|
||||
|
||||
#include "BulletDemoInterface.h"
|
||||
#include "Bullet3AppSupport/BulletDemoInterface.h"
|
||||
#include "../bullet2/BasicDemo/BasicDemo.h"
|
||||
#include "../bullet2/BasicDemo/HingeDemo.h"
|
||||
#include "../bullet2/BasicDemo/HingeDemo.h"
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
#ifndef DEMO_INTERFACE_H
|
||||
#define DEMO_INTERFACE_H
|
||||
|
||||
struct SimpleOpenGL3App;
|
||||
|
||||
class BulletDemoInterface
|
||||
{
|
||||
public:
|
||||
|
||||
typedef class BulletDemoInterface* (CreateFunc)(SimpleOpenGL3App* app);
|
||||
|
||||
virtual ~BulletDemoInterface()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void initPhysics()=0;
|
||||
virtual void exitPhysics()=0;
|
||||
virtual void stepSimulation(float deltaTime)=0;
|
||||
virtual void renderScene()=0;
|
||||
virtual void physicsDebugDraw()=0;
|
||||
virtual bool mouseMoveCallback(float x,float y)=0;
|
||||
virtual bool mouseButtonCallback(int button, int state, float x, float y)=0;
|
||||
virtual bool keyboardCallback(int key, int state)=0;
|
||||
|
||||
};
|
||||
|
||||
class EmptyBulletDemo : public BulletDemoInterface
|
||||
{
|
||||
public:
|
||||
static BulletDemoInterface* MyCreateFunc(SimpleOpenGL3App* app)
|
||||
{
|
||||
return new EmptyBulletDemo();
|
||||
}
|
||||
|
||||
virtual void initPhysics()
|
||||
{
|
||||
}
|
||||
virtual void exitPhysics()
|
||||
{
|
||||
}
|
||||
virtual void stepSimulation(float deltaTime)
|
||||
{
|
||||
}
|
||||
virtual void renderScene()
|
||||
{
|
||||
}
|
||||
virtual void physicsDebugDraw()
|
||||
{
|
||||
}
|
||||
virtual bool mouseMoveCallback(float x,float y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool mouseButtonCallback(int button, int state, float x, float y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool keyboardCallback(int key, int state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif //DEMO_INTERFACE_H
|
||||
|
||||
@@ -8,19 +8,7 @@ INCLUDE_DIRECTORIES(
|
||||
|
||||
SET(App_AllBullet2Demos_SRCS
|
||||
main.cpp
|
||||
BulletDemoInterface.h
|
||||
BulletDemoEntries.h
|
||||
GwenParameterInterface.cpp
|
||||
GwenParameterInterface.h
|
||||
GraphingTexture.h
|
||||
GwenParameterInterface.h
|
||||
GwenProfileWindow.h
|
||||
GwenTextureWindow.h
|
||||
GraphingTexture.cpp
|
||||
GwenProfileWindow.cpp
|
||||
GwenTextureWindow.cpp
|
||||
../bullet2/BasicDemo/Bullet2RigidBodyDemo.cpp
|
||||
../bullet2/BasicDemo/Bullet2RigidBodyDemo.h
|
||||
../../Demos/BasicDemo/BasicDemoPhysicsSetup.cpp
|
||||
../../Demos/BasicDemo/BasicDemoPhysicsSetup.h
|
||||
../../Demos/CcdPhysicsDemo/CcdPhysicsSetup.cpp
|
||||
@@ -51,16 +39,14 @@ SET(App_AllBullet2Demos_SRCS
|
||||
# ../bullet2/RagdollDemo/RagdollDemo.h
|
||||
../bullet2/LuaDemo/LuaPhysicsSetup.cpp
|
||||
../bullet2/LuaDemo/LuaPhysicsSetup.h
|
||||
../GpuDemos/gwenUserInterface.cpp
|
||||
../GpuDemos/gwenUserInterface.h
|
||||
../ImportURDFDemo/ImportURDFSetup.cpp
|
||||
../ImportURDFDemo/ImportURDFSetup.h
|
||||
../ImportObjDemo/ImportObjSetup.cpp
|
||||
../ImportSTLDemo/ImportSTLSetup.cpp
|
||||
../Wavefront/tiny_obj_loader.cpp
|
||||
../Wavefront/tiny_obj_loader.h
|
||||
../../btgui/Timing/b3Clock.cpp
|
||||
../../btgui/Timing/b3Clock.h
|
||||
../../btgui/Bullet3AppSupport/b3Clock.cpp
|
||||
../../btgui/Bullet3AppSupport/b3Clock.h
|
||||
../../btgui/urdf/urdfdom/urdf_parser/src/pose.cpp
|
||||
../../btgui/urdf/urdfdom/urdf_parser/src/model.cpp
|
||||
../../btgui/urdf/urdfdom/urdf_parser/src/link.cpp
|
||||
@@ -85,7 +71,7 @@ SET(App_AllBullet2Demos_SRCS
|
||||
)
|
||||
|
||||
LINK_LIBRARIES(
|
||||
lua-5.2.3 Bullet3Common BulletSoftBody BulletDynamics BulletCollision LinearMath OpenGLWindow gwen ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
|
||||
Bullet3AppSupport lua-5.2.3 Bullet3Common BulletSoftBody BulletDynamics BulletCollision LinearMath OpenGLWindow gwen ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
|
||||
)
|
||||
|
||||
IF (WIN32)
|
||||
|
||||
@@ -1,189 +0,0 @@
|
||||
#include "GraphingTexture.h"
|
||||
#include "OpenGLWindow/OpenGLInclude.h"
|
||||
#include <assert.h>
|
||||
|
||||
GraphingTexture::GraphingTexture()
|
||||
:m_textureId(0),
|
||||
m_width(0),
|
||||
m_height(0)
|
||||
{
|
||||
}
|
||||
|
||||
GraphingTexture::~GraphingTexture()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
void GraphingTexture::destroy()
|
||||
{
|
||||
//TODO(erwincoumans) release memory etc...
|
||||
m_width = 0;
|
||||
m_height=0;
|
||||
glDeleteTextures(1,(GLuint*)&m_textureId);
|
||||
m_textureId=0;
|
||||
}
|
||||
|
||||
bool GraphingTexture::create(int texWidth, int texHeight)
|
||||
{
|
||||
m_width = texWidth;
|
||||
m_height = texHeight;
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
m_imageData.resize(texWidth*texHeight*4);
|
||||
for(int y=0;y<texHeight;++y)
|
||||
{
|
||||
// const int t=y>>5;
|
||||
GLubyte* pi=&m_imageData[y*texWidth*4];
|
||||
for(int x=0;x<texWidth;++x)
|
||||
{
|
||||
if (x>=y)//x<2||y<2||x>253||y>253)
|
||||
{
|
||||
pi[0]=0;
|
||||
pi[1]=0;
|
||||
pi[2]=255;
|
||||
pi[3]=255;
|
||||
} else
|
||||
{
|
||||
pi[0]=255;
|
||||
pi[1]=0;
|
||||
pi[2]=0;
|
||||
pi[3]=255;
|
||||
}
|
||||
|
||||
pi+=4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
glGenTextures(1,(GLuint*)&m_textureId);
|
||||
|
||||
uploadImageData();
|
||||
return true;
|
||||
}
|
||||
|
||||
void GraphingTexture::uploadImageData()
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D,m_textureId);
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_width,m_height,0,GL_RGBA,GL_UNSIGNED_BYTE,&m_imageData[0]);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#if 0
|
||||
//shift the image one pixel
|
||||
for(int y=0;y<texHeight;++y)
|
||||
{
|
||||
// const int t=y>>5;
|
||||
for(int x=1;x<texWidth;++x)
|
||||
{
|
||||
GLubyte* org=image+(x+y*texWidth)*4;
|
||||
|
||||
GLubyte* dst=image+(x-1+y*texWidth)*4;
|
||||
|
||||
dst[0] = org[0];
|
||||
dst[1] = org[1];
|
||||
dst[2] = org[2];
|
||||
dst[3] = org[3];
|
||||
}
|
||||
}
|
||||
//render a new row at the right
|
||||
for(int y=0;y<texHeight;++y)
|
||||
{
|
||||
GLubyte* pi=image+(texWidth-1+y*texWidth)*4;
|
||||
pi[0]=255;
|
||||
pi[1]=255;
|
||||
pi[2]=255;
|
||||
pi[3]=255;
|
||||
if (y==texHeight*0.5)
|
||||
{
|
||||
pi[0]=200;
|
||||
pi[1]=200;
|
||||
pi[2]=200;
|
||||
pi[3]=255;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
static float timer = 0.f;
|
||||
static int prevValue=0;
|
||||
timer+= 0.01;
|
||||
float value = 128+100*sinf(timer);
|
||||
MyClamp(value,0.f,float(texHeight-1));
|
||||
GLubyte* org=image+(texWidth-1+(int)value*texWidth)*4;
|
||||
org[0] = 0;
|
||||
org[1] = 0;
|
||||
org[2] = 0;
|
||||
org[3] = 255;
|
||||
|
||||
if (prevValue<value)
|
||||
{
|
||||
|
||||
} else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
static float timer = 1.4f;
|
||||
timer+= 0.04;
|
||||
float value = 128+150*sinf(timer);
|
||||
MyClamp(value,0.f,float(texHeight-1));
|
||||
|
||||
GLubyte* org=image+(texWidth-1+(int)value*texWidth)*4;
|
||||
org[0] = 0;
|
||||
org[1] = 255;
|
||||
org[2] = 0;
|
||||
org[3] = 255;
|
||||
}
|
||||
|
||||
{
|
||||
static float timer = 1.4f;
|
||||
timer+= 0.02;
|
||||
float value =256+400*sinf(timer);
|
||||
MyClamp(value,0.f,float(texHeight-1));
|
||||
static int prevValue = 0;
|
||||
|
||||
GLubyte* org=image+(texWidth-1+(int)value*texWidth)*4;
|
||||
org[0] = 0;
|
||||
org[1] = 0;
|
||||
org[2] = 255;
|
||||
org[3] = 255;
|
||||
|
||||
if (prevValue<value)
|
||||
{
|
||||
for (int i=prevValue;i<value;i++)
|
||||
{
|
||||
GLubyte* org=image+(texHeight-1+(int)i*texWidth)*4;
|
||||
org[0] = 0;
|
||||
org[1] = 0;
|
||||
org[2] = 255;
|
||||
org[3] = 255;
|
||||
}
|
||||
} else
|
||||
{
|
||||
for (int i=value;i<prevValue;i++)
|
||||
{
|
||||
GLubyte* org=image+(texHeight-1+(int)i*texWidth)*4;
|
||||
org[0] = 0;
|
||||
org[1] = 0;
|
||||
org[2] = 255;
|
||||
org[3] = 255;
|
||||
}
|
||||
}
|
||||
prevValue = value;
|
||||
}
|
||||
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth,texHeight,0,GL_RGBA,GL_UNSIGNED_BYTE,image);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#ifndef GRAPHING_TEXTURE_H
|
||||
#define GRAPHING_TEXTURE_H
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
|
||||
struct GraphingTexture
|
||||
{
|
||||
int m_textureId;
|
||||
//assume rgba (8 bit per component, total of 32bit per pixel, for m_width*m_height pixels)
|
||||
btAlignedObjectArray<unsigned char> m_imageData;
|
||||
int m_width;
|
||||
int m_height;
|
||||
|
||||
GraphingTexture();
|
||||
virtual ~GraphingTexture();
|
||||
|
||||
bool create(int texWidth, int texHeight);
|
||||
void destroy();
|
||||
|
||||
void setPixel(int x, int y, unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
|
||||
{
|
||||
m_imageData[x*4+y*4*m_width+0] = red;
|
||||
m_imageData[x*4+y*4*m_width+1] = green;
|
||||
m_imageData[x*4+y*4*m_width+2] = blue;
|
||||
m_imageData[x*4+y*4*m_width+3] = alpha;
|
||||
}
|
||||
|
||||
void uploadImageData();
|
||||
|
||||
int getTextureId()
|
||||
{
|
||||
return m_textureId;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //GRAPHING_TEXTURE_H
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
#include "GwenParameterInterface.h"
|
||||
#include "../GpuDemos/gwenInternalData.h"
|
||||
|
||||
|
||||
|
||||
template<typename T>
|
||||
struct MySliderEventHandler : public Gwen::Event::Handler
|
||||
{
|
||||
Gwen::Controls::TextBox* m_label;
|
||||
Gwen::Controls::Slider* m_pSlider;
|
||||
char m_variableName[1024];
|
||||
T* m_targetValue;
|
||||
|
||||
MySliderEventHandler(const char* varName, Gwen::Controls::TextBox* label, Gwen::Controls::Slider* pSlider,T* target)
|
||||
:m_label(label),
|
||||
m_pSlider(pSlider),
|
||||
m_targetValue(target)
|
||||
{
|
||||
memcpy(m_variableName,varName,strlen(varName)+1);
|
||||
}
|
||||
|
||||
|
||||
void SliderMoved( Gwen::Controls::Base* pControl )
|
||||
{
|
||||
Gwen::Controls::Slider* pSlider = (Gwen::Controls::Slider*)pControl;
|
||||
//printf("value = %f\n", pSlider->GetValue());//UnitPrint( Utility::Format( L"Slider Value: %.2f", pSlider->GetValue() ) );
|
||||
float bla = pSlider->GetValue();
|
||||
T v = T(bla);
|
||||
SetValue(v);
|
||||
|
||||
}
|
||||
|
||||
void SetValue(T v)
|
||||
{
|
||||
if (v < m_pSlider->GetRangeMin())
|
||||
{
|
||||
printf("?\n");
|
||||
}
|
||||
|
||||
if (v > m_pSlider->GetRangeMax())
|
||||
{
|
||||
printf("?\n");
|
||||
|
||||
}
|
||||
m_pSlider->SetValue(v,true);
|
||||
(*m_targetValue) = v;
|
||||
float val = float(v);//todo: specialize on template type
|
||||
char txt[1024];
|
||||
sprintf(txt,"%s : %.3f", m_variableName,val);
|
||||
m_label->SetText(txt);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct GwenParameters
|
||||
{
|
||||
b3AlignedObjectArray<MySliderEventHandler<btScalar>*> m_sliderEventHandlers;
|
||||
b3AlignedObjectArray<Gwen::Controls::HorizontalSlider*> m_sliders;
|
||||
b3AlignedObjectArray<Gwen::Controls::TextBox*> m_textLabels;
|
||||
int m_savedYposition;
|
||||
};
|
||||
|
||||
GwenParameterInterface::GwenParameterInterface(GwenInternalData* gwenInternalData)
|
||||
:m_gwenInternalData(gwenInternalData)
|
||||
{
|
||||
m_paramInternalData = new GwenParameters;
|
||||
m_paramInternalData->m_savedYposition = m_gwenInternalData->m_curYposition;
|
||||
|
||||
}
|
||||
|
||||
GwenParameterInterface::~GwenParameterInterface()
|
||||
{
|
||||
|
||||
removeAllParameters();
|
||||
delete m_paramInternalData;
|
||||
}
|
||||
|
||||
|
||||
void GwenParameterInterface::setSliderValue(int sliderIndex, double sliderValue)
|
||||
{
|
||||
int sliderCapped = sliderValue+4;
|
||||
sliderCapped /= 8;
|
||||
sliderCapped *= 8;
|
||||
|
||||
if (sliderIndex>=0 && sliderIndex<m_paramInternalData->m_sliders.size())
|
||||
{
|
||||
m_paramInternalData->m_sliders[sliderIndex]->GetRangeMin();
|
||||
|
||||
m_paramInternalData->m_sliders[sliderIndex]->GetRangeMax();
|
||||
float mappedValue =m_paramInternalData->m_sliders[sliderIndex]->GetRangeMin()+
|
||||
(m_paramInternalData->m_sliders[sliderIndex]->GetRangeMax()-
|
||||
m_paramInternalData->m_sliders[sliderIndex]->GetRangeMin())*sliderCapped/128.f;
|
||||
printf("mappedValue = %f\n",mappedValue);
|
||||
m_paramInternalData->m_sliders[sliderIndex]->SetValue(mappedValue);
|
||||
}
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
void GwenParameterInterface::registerSliderFloatParameter(SliderParams& params)
|
||||
{
|
||||
Gwen::Controls::TextBox* label = new Gwen::Controls::TextBox(m_gwenInternalData->m_demoPage->GetPage());
|
||||
m_paramInternalData->m_textLabels.push_back(label);
|
||||
//m_data->m_myControls.push_back(label);
|
||||
label->SetText( params.m_name);
|
||||
label->SetPos( 10, 10 + 25 );
|
||||
label->SetWidth(110);
|
||||
label->SetPos(10,m_gwenInternalData->m_curYposition);
|
||||
m_gwenInternalData->m_curYposition+=22;
|
||||
|
||||
Gwen::Controls::HorizontalSlider* pSlider = new Gwen::Controls::HorizontalSlider( m_gwenInternalData->m_demoPage->GetPage());
|
||||
m_paramInternalData->m_sliders.push_back(pSlider);
|
||||
//m_data->m_myControls.push_back(pSlider);
|
||||
pSlider->SetPos( 10, m_gwenInternalData->m_curYposition );
|
||||
pSlider->SetSize( 100, 20 );
|
||||
pSlider->SetRange( params.m_minVal, params.m_maxVal);
|
||||
pSlider->SetNotchCount(128);//float(params.m_maxVal-params.m_minVal)/100.f);
|
||||
pSlider->SetClampToNotches( params.m_clampToNotches );
|
||||
pSlider->SetValue( *params.m_paramValuePointer);//dimensions[i] );
|
||||
char labelName[1024];
|
||||
sprintf(labelName,"%s",params.m_name);//axisNames[0]);
|
||||
MySliderEventHandler<btScalar>* handler = new MySliderEventHandler<btScalar>(labelName,label,pSlider,params.m_paramValuePointer);
|
||||
m_paramInternalData->m_sliderEventHandlers.push_back(handler);
|
||||
|
||||
pSlider->onValueChanged.Add( handler, &MySliderEventHandler<btScalar>::SliderMoved );
|
||||
handler->SliderMoved(pSlider);
|
||||
// float v = pSlider->GetValue();
|
||||
m_gwenInternalData->m_curYposition+=22;
|
||||
}
|
||||
|
||||
void GwenParameterInterface::syncParameters()
|
||||
{
|
||||
for (int i=0;i<m_paramInternalData->m_sliderEventHandlers.size();i++)
|
||||
{
|
||||
MySliderEventHandler<btScalar>* handler = m_paramInternalData->m_sliderEventHandlers[i];
|
||||
handler->m_pSlider->SetValue(*handler->m_targetValue,true);
|
||||
}
|
||||
}
|
||||
|
||||
void GwenParameterInterface::removeAllParameters()
|
||||
{
|
||||
for (int i=0;i<m_paramInternalData->m_sliders.size();i++)
|
||||
{
|
||||
delete m_paramInternalData->m_sliders[i];
|
||||
}
|
||||
m_paramInternalData->m_sliders.clear();
|
||||
|
||||
for (int i=0;i<m_paramInternalData->m_sliderEventHandlers.size();i++)
|
||||
{
|
||||
delete m_paramInternalData->m_sliderEventHandlers[i];
|
||||
}
|
||||
m_paramInternalData->m_sliderEventHandlers.clear();
|
||||
|
||||
for (int i=0;i<m_paramInternalData->m_textLabels.size();i++)
|
||||
{
|
||||
delete m_paramInternalData->m_textLabels[i];
|
||||
}
|
||||
m_paramInternalData->m_textLabels.clear();
|
||||
|
||||
m_gwenInternalData->m_curYposition = this->m_paramInternalData->m_savedYposition;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef GWEN_PARAMETER_INTERFACE_H
|
||||
#define GWEN_PARAMETER_INTERFACE_H
|
||||
|
||||
#include "../../Demos/CommonParameterInterface.h"
|
||||
|
||||
struct GwenParameterInterface : public CommonParameterInterface
|
||||
{
|
||||
struct GwenInternalData* m_gwenInternalData;
|
||||
|
||||
struct GwenParameters* m_paramInternalData;
|
||||
|
||||
GwenParameterInterface(struct GwenInternalData* gwenInternalData);
|
||||
virtual ~GwenParameterInterface();
|
||||
virtual void registerSliderFloatParameter(SliderParams& params);
|
||||
virtual void setSliderValue(int sliderIndex, double sliderValue);
|
||||
virtual void syncParameters();
|
||||
virtual void removeAllParameters();
|
||||
|
||||
};
|
||||
|
||||
#endif//GWEN_PARAMETER_INTERFACE_H
|
||||
@@ -1,292 +0,0 @@
|
||||
#include "GwenProfileWindow.h"
|
||||
#include "../GpuDemos/gwenUserInterface.h"
|
||||
#include "../GpuDemos/gwenInternalData.h"
|
||||
#include "LinearMath/btQuickprof.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class MyProfileWindow : public Gwen::Controls::WindowControl
|
||||
{
|
||||
|
||||
// Gwen::Controls::TabControl* m_TabControl;
|
||||
//Gwen::Controls::ListBox* m_TextOutput;
|
||||
unsigned int m_iFrames;
|
||||
float m_fLastSecond;
|
||||
|
||||
Gwen::Controls::TreeNode* m_node;
|
||||
Gwen::Controls::TreeControl* m_ctrl;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
void onButtonA( Gwen::Controls::Base* pControl )
|
||||
{
|
||||
// OpenTissue::glut::toggleIdle();
|
||||
}
|
||||
|
||||
void SliderMoved(Gwen::Controls::Base* pControl )
|
||||
{
|
||||
// Gwen::Controls::Slider* pSlider = (Gwen::Controls::Slider*)pControl;
|
||||
//this->m_app->scaleYoungModulus(pSlider->GetValue());
|
||||
// printf("Slider Value: %.2f", pSlider->GetValue() );
|
||||
}
|
||||
|
||||
|
||||
void OnCheckChangedStiffnessWarping (Gwen::Controls::Base* pControl)
|
||||
{
|
||||
// Gwen::Controls::CheckBox* labeled = (Gwen::Controls::CheckBox* )pControl;
|
||||
// bool checked = labeled->IsChecked();
|
||||
//m_app->m_stiffness_warp_on = checked;
|
||||
}
|
||||
public:
|
||||
|
||||
|
||||
CProfileIterator* profIter;
|
||||
|
||||
MyProfileWindow ( Gwen::Controls::Base* pParent)
|
||||
: Gwen::Controls::WindowControl( pParent ),
|
||||
profIter(0)
|
||||
{
|
||||
SetTitle( L"Time Profiler" );
|
||||
|
||||
SetSize( 450, 450 );
|
||||
this->SetPos(10,400);
|
||||
|
||||
// this->Dock( Gwen::Pos::Bottom);
|
||||
|
||||
|
||||
|
||||
{
|
||||
m_ctrl = new Gwen::Controls::TreeControl( this );
|
||||
m_node = m_ctrl->AddNode( L"Total Parent Time" );
|
||||
|
||||
|
||||
//Gwen::Controls::TreeNode* pNode = ctrl->AddNode( L"Node Two" );
|
||||
//pNode->AddNode( L"Node Two Inside" );
|
||||
//pNode->AddNode( L"Eyes" );
|
||||
//pNode->AddNode( L"Brown" )->AddNode( L"Node Two Inside" )->AddNode( L"Eyes" )->AddNode( L"Brown" );
|
||||
//Gwen::Controls::TreeNode* node = ctrl->AddNode( L"Node Three" );
|
||||
|
||||
|
||||
|
||||
//m_ctrl->Dock(Gwen::Pos::Bottom);
|
||||
|
||||
m_ctrl->ExpandAll();
|
||||
m_ctrl->SetKeyboardInputEnabled(true);
|
||||
m_ctrl->SetBounds( this->GetInnerBounds().x,this->GetInnerBounds().y,this->GetInnerBounds().w,this->GetInnerBounds().h);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
float dumpRecursive(CProfileIterator* profileIterator, Gwen::Controls::TreeNode* parentNode)
|
||||
{
|
||||
profileIterator->First();
|
||||
if (profileIterator->Is_Done())
|
||||
return 0.f;
|
||||
|
||||
float accumulated_time=0,parent_time = profileIterator->Is_Root() ? CProfileManager::Get_Time_Since_Reset() : profileIterator->Get_Current_Parent_Total_Time();
|
||||
int i;
|
||||
int frames_since_reset = CProfileManager::Get_Frame_Count_Since_Reset();
|
||||
|
||||
//printf("Profiling: %s (total running time: %.3f ms) ---\n", profileIterator->Get_Current_Parent_Name(), parent_time );
|
||||
float totalTime = 0.f;
|
||||
|
||||
|
||||
int numChildren = 0;
|
||||
Gwen::UnicodeString txt;
|
||||
std::vector<Gwen::Controls::TreeNode*> nodes;
|
||||
|
||||
for (i = 0; !profileIterator->Is_Done(); i++,profileIterator->Next())
|
||||
{
|
||||
numChildren++;
|
||||
float current_total_time = profileIterator->Get_Current_Total_Time();
|
||||
accumulated_time += current_total_time;
|
||||
double fraction = parent_time > SIMD_EPSILON ? (current_total_time / parent_time) * 100 : 0.f;
|
||||
|
||||
Gwen::String name(profileIterator->Get_Current_Name());
|
||||
#ifdef _WIN32
|
||||
Gwen::UnicodeString uname = Gwen::Utility::StringToUnicode(name);
|
||||
|
||||
txt = Gwen::Utility::Format(L"%s (%.2f %%) :: %.3f ms / frame (%d calls)",uname.c_str(), fraction,(current_total_time / (double)frames_since_reset),profileIterator->Get_Current_Total_Calls());
|
||||
|
||||
#else
|
||||
txt = Gwen::Utility::Format(L"%s (%.2f %%) :: %.3f ms / frame (%d calls)",name.c_str(), fraction,(current_total_time / (double)frames_since_reset),profileIterator->Get_Current_Total_Calls());
|
||||
|
||||
#endif
|
||||
|
||||
Gwen::Controls::TreeNode* childNode = (Gwen::Controls::TreeNode*)profileIterator->Get_Current_UserPointer();
|
||||
if (!childNode)
|
||||
{
|
||||
childNode = parentNode->AddNode(L"");
|
||||
profileIterator->Set_Current_UserPointer(childNode);
|
||||
}
|
||||
childNode->SetText(txt);
|
||||
nodes.push_back(childNode);
|
||||
|
||||
totalTime += current_total_time;
|
||||
//recurse into children
|
||||
}
|
||||
|
||||
for (i=0;i<numChildren;i++)
|
||||
{
|
||||
profileIterator->Enter_Child(i);
|
||||
Gwen::Controls::TreeNode* curNode = nodes[i];
|
||||
|
||||
dumpRecursive(profileIterator, curNode);
|
||||
|
||||
profileIterator->Enter_Parent();
|
||||
}
|
||||
return accumulated_time;
|
||||
|
||||
}
|
||||
|
||||
void UpdateText(CProfileIterator* profileIterator, bool idle)
|
||||
{
|
||||
|
||||
// static bool update=true;
|
||||
|
||||
m_ctrl->SetBounds(0,0,this->GetInnerBounds().w,this->GetInnerBounds().h);
|
||||
|
||||
// if (!update)
|
||||
// return;
|
||||
// update=false;
|
||||
|
||||
|
||||
static int test = 1;
|
||||
test++;
|
||||
|
||||
static double time_since_reset = 0.f;
|
||||
if (!idle)
|
||||
{
|
||||
time_since_reset = CProfileManager::Get_Time_Since_Reset();
|
||||
}
|
||||
|
||||
//Gwen::UnicodeString txt = Gwen::Utility::Format( L"FEM Settings %i fps", test );
|
||||
{
|
||||
//recompute profiling data, and store profile strings
|
||||
|
||||
// char blockTime[128];
|
||||
|
||||
// double totalTime = 0;
|
||||
|
||||
// int frames_since_reset = CProfileManager::Get_Frame_Count_Since_Reset();
|
||||
|
||||
profileIterator->First();
|
||||
|
||||
double parent_time = profileIterator->Is_Root() ? time_since_reset : profileIterator->Get_Current_Parent_Total_Time();
|
||||
|
||||
|
||||
// Gwen::Controls::TreeNode* curParent = m_node;
|
||||
|
||||
double accumulated_time = dumpRecursive(profileIterator,m_node);
|
||||
|
||||
const char* name = profileIterator->Get_Current_Parent_Name();
|
||||
#ifdef _WIN32
|
||||
Gwen::UnicodeString uname = Gwen::Utility::StringToUnicode(name);
|
||||
Gwen::UnicodeString txt = Gwen::Utility::Format( L"Profiling: %s total time: %.3f ms, unaccounted %.3f %% :: %.3f ms", uname.c_str(), parent_time ,
|
||||
parent_time > SIMD_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time);
|
||||
#else
|
||||
Gwen::UnicodeString txt = Gwen::Utility::Format( L"Profiling: %s total time: %.3f ms, unaccounted %.3f %% :: %.3f ms", name, parent_time ,
|
||||
parent_time > SIMD_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time);
|
||||
#endif
|
||||
//sprintf(blockTime,"--- Profiling: %s (total running time: %.3f ms) ---", profileIterator->Get_Current_Parent_Name(), parent_time );
|
||||
//displayProfileString(xOffset,yStart,blockTime);
|
||||
m_node->SetText(txt);
|
||||
|
||||
|
||||
//printf("%s (%.3f %%) :: %.3f ms\n", "Unaccounted:",);
|
||||
|
||||
|
||||
}
|
||||
|
||||
static int counter=10;
|
||||
if (counter)
|
||||
{
|
||||
counter--;
|
||||
m_ctrl->ExpandAll();
|
||||
}
|
||||
|
||||
}
|
||||
void PrintText( const Gwen::UnicodeString& str )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Render( Gwen::Skin::Base* skin )
|
||||
{
|
||||
m_iFrames++;
|
||||
|
||||
if ( m_fLastSecond < Gwen::Platform::GetTimeInSeconds() )
|
||||
{
|
||||
SetTitle( Gwen::Utility::Format( L"Profiler %i fps", m_iFrames ) );
|
||||
|
||||
m_fLastSecond = Gwen::Platform::GetTimeInSeconds() + 1.0f;
|
||||
m_iFrames = 0;
|
||||
}
|
||||
|
||||
Gwen::Controls::WindowControl::Render( skin );
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
class MyMenuItems : public Gwen::Controls::Base
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
class MyProfileWindow* m_profWindow;
|
||||
MyMenuItems() :Gwen::Controls::Base(0)
|
||||
{
|
||||
}
|
||||
|
||||
void MenuItemSelect(Gwen::Controls::Base* pControl)
|
||||
{
|
||||
if (m_profWindow->Hidden())
|
||||
{
|
||||
m_profWindow->SetHidden(false);
|
||||
} else
|
||||
{
|
||||
m_profWindow->SetHidden(true);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
MyProfileWindow* setupProfileWindow(GwenInternalData* data)
|
||||
{
|
||||
MyMenuItems* menuItems = new MyMenuItems;
|
||||
MyProfileWindow* profWindow = new MyProfileWindow(data->pCanvas);
|
||||
//profWindow->SetHidden(true);
|
||||
profWindow->profIter = CProfileManager::Get_Iterator();
|
||||
data->m_viewMenu->GetMenu()->AddItem( L"Profiler", menuItems,(Gwen::Event::Handler::Function)&MyMenuItems::MenuItemSelect);
|
||||
menuItems->m_profWindow = profWindow;
|
||||
return profWindow;
|
||||
}
|
||||
|
||||
|
||||
void processProfileData( MyProfileWindow* profWindow, bool idle)
|
||||
{
|
||||
if (profWindow)
|
||||
{
|
||||
|
||||
profWindow->UpdateText(profWindow->profIter, idle);
|
||||
}
|
||||
}
|
||||
|
||||
void profileWindowSetVisible(MyProfileWindow* window, bool visible)
|
||||
{
|
||||
window->SetHidden(!visible);
|
||||
}
|
||||
void destroyProfileWindow(MyProfileWindow* window)
|
||||
{
|
||||
delete window;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef GWEN_PROFILE_WINDOW_H
|
||||
#define GWEN_PROFILE_WINDOW_H
|
||||
|
||||
class MyProfileWindow* setupProfileWindow(struct GwenInternalData* data);
|
||||
void processProfileData(MyProfileWindow* window, bool idle);
|
||||
void profileWindowSetVisible(MyProfileWindow* window, bool visible);
|
||||
void destroyProfileWindow(MyProfileWindow* window);
|
||||
|
||||
#endif//GWEN_PROFILE_WINDOW_H
|
||||
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
#include "GwenTextureWindow.h"
|
||||
#include "../GpuDemos/gwenUserInterface.h"
|
||||
#include "../GpuDemos/gwenInternalData.h"
|
||||
#include "Gwen/Controls/ImagePanel.h"
|
||||
|
||||
|
||||
|
||||
class MyGraphWindow : public Gwen::Controls::WindowControl
|
||||
{
|
||||
Gwen::Controls::ImagePanel* m_imgPanel;
|
||||
|
||||
public:
|
||||
|
||||
class MyMenuItems2* m_menuItems;
|
||||
|
||||
MyGraphWindow ( const MyGraphInput& input)
|
||||
: Gwen::Controls::WindowControl( input.m_data->pCanvas ),
|
||||
m_menuItems(0)
|
||||
{
|
||||
Gwen::UnicodeString str = Gwen::Utility::StringToUnicode(input.m_name);
|
||||
SetTitle( str );
|
||||
|
||||
|
||||
SetPos(input.m_xPos,input.m_yPos);
|
||||
SetSize( 12+input.m_width+2*input.m_borderWidth, 30+input.m_height+2*input.m_borderWidth );
|
||||
|
||||
m_imgPanel = new Gwen::Controls::ImagePanel( this );
|
||||
if (input.m_texName)
|
||||
{
|
||||
Gwen::UnicodeString texName = Gwen::Utility::StringToUnicode(input.m_texName);
|
||||
m_imgPanel->SetImage( texName );
|
||||
}
|
||||
m_imgPanel->SetBounds( input.m_borderWidth, input.m_borderWidth,
|
||||
input.m_width,
|
||||
input.m_height );
|
||||
// this->Dock( Gwen::Pos::Bottom);
|
||||
}
|
||||
virtual ~MyGraphWindow()
|
||||
{
|
||||
delete m_imgPanel;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
class MyMenuItems2 : public Gwen::Controls::Base
|
||||
{
|
||||
MyGraphWindow* m_graphWindow;
|
||||
|
||||
public:
|
||||
|
||||
Gwen::Controls::MenuItem* m_item;
|
||||
|
||||
MyMenuItems2(MyGraphWindow* graphWindow)
|
||||
:Gwen::Controls::Base(0),
|
||||
m_graphWindow(graphWindow),
|
||||
m_item(0)
|
||||
{
|
||||
}
|
||||
|
||||
void MenuItemSelect(Gwen::Controls::Base* pControl)
|
||||
{
|
||||
if (m_graphWindow->Hidden())
|
||||
{
|
||||
m_graphWindow->SetHidden(false);
|
||||
//@TODO(erwincoumans) setCheck/SetCheckable drawing is broken, need to see what's wrong
|
||||
// if (m_item)
|
||||
// m_item->SetCheck(false);
|
||||
|
||||
} else
|
||||
{
|
||||
m_graphWindow->SetHidden(true);
|
||||
// if (m_item)
|
||||
// m_item->SetCheck(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
MyGraphWindow* setupTextureWindow(const MyGraphInput& input)
|
||||
{
|
||||
MyGraphWindow* graphWindow = new MyGraphWindow(input);
|
||||
MyMenuItems2* menuItems = new MyMenuItems2(graphWindow);
|
||||
graphWindow->m_menuItems = menuItems;
|
||||
|
||||
Gwen::UnicodeString str = Gwen::Utility::StringToUnicode(input.m_name);
|
||||
menuItems->m_item = input.m_data->m_viewMenu->GetMenu()->AddItem( str, menuItems,(Gwen::Event::Handler::Function)&MyMenuItems2::MenuItemSelect);
|
||||
// menuItems->m_item->SetCheckable(true);
|
||||
|
||||
return graphWindow;
|
||||
|
||||
}
|
||||
|
||||
void destroyTextureWindow(MyGraphWindow* window)
|
||||
{
|
||||
delete window->m_menuItems->m_item;
|
||||
delete window->m_menuItems;
|
||||
delete window;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
|
||||
|
||||
#ifndef GWEN_TEXTURE_WINDOW_H
|
||||
#define GWEN_TEXTURE_WINDOW_H
|
||||
|
||||
struct MyGraphInput
|
||||
{
|
||||
struct GwenInternalData* m_data;
|
||||
int m_xPos;
|
||||
int m_yPos;
|
||||
int m_width;
|
||||
int m_height;
|
||||
int m_borderWidth;
|
||||
const char* m_name;
|
||||
const char* m_texName;
|
||||
MyGraphInput(struct GwenInternalData* data)
|
||||
:m_data(data),
|
||||
m_xPos(0),
|
||||
m_yPos(0),
|
||||
m_width(400),
|
||||
m_height(400),
|
||||
m_borderWidth(0),
|
||||
m_name("GraphWindow"),
|
||||
m_texName(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
class MyGraphWindow* setupTextureWindow(const MyGraphInput& input);
|
||||
void destroyTextureWindow(MyGraphWindow* window);
|
||||
|
||||
|
||||
#endif //GWEN_TEXTURE_WINDOW_H
|
||||
@@ -1,16 +1,16 @@
|
||||
|
||||
#include "../../btgui/OpenGLWindow/SimpleOpenGL3App.h"
|
||||
#include "OpenGLWindow/SimpleOpenGL3App.h"
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
#include "assert.h"
|
||||
#include <stdio.h>
|
||||
#include "../GpuDemos/gwenInternalData.h"
|
||||
#include "../GpuDemos/gwenUserInterface.h"
|
||||
#include "Bullet3AppSupport/gwenInternalData.h"
|
||||
#include "Bullet3AppSupport/gwenUserInterface.h"
|
||||
#include "BulletDemoEntries.h"
|
||||
#include "../../btgui/Timing/b3Clock.h"
|
||||
#include "GwenParameterInterface.h"
|
||||
#include "GwenProfileWindow.h"
|
||||
#include "GwenTextureWindow.h"
|
||||
#include "GraphingTexture.h"
|
||||
#include "Bullet3AppSupport/b3Clock.h"
|
||||
#include "Bullet3AppSupport/GwenParameterInterface.h"
|
||||
#include "Bullet3AppSupport/GwenProfileWindow.h"
|
||||
#include "Bullet3AppSupport/GwenTextureWindow.h"
|
||||
#include "Bullet3AppSupport/GraphingTexture.h"
|
||||
|
||||
|
||||
#define DEMO_SELECTION_COMBOBOX 13
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
}
|
||||
|
||||
|
||||
links{"gwen", "OpenGL_Window","BulletDynamics","BulletCollision","LinearMath","Bullet3Common","lua-5.2.3"}
|
||||
links{"Bullet3AppSupport","gwen", "OpenGL_Window","BulletDynamics","BulletCollision","LinearMath","Bullet3Common","lua-5.2.3"}
|
||||
initOpenGL()
|
||||
initGlew()
|
||||
|
||||
@@ -39,8 +39,6 @@
|
||||
files {
|
||||
"**.cpp",
|
||||
"**.h",
|
||||
"../bullet2/BasicDemo/Bullet2RigidBodyDemo.cpp",
|
||||
"../bullet2/BasicDemo/Bullet2RigidBodyDemo.h",
|
||||
"../bullet2/LuaDemo/LuaPhysicsSetup.cpp",
|
||||
"../bullet2/LuaDemo/LuaPhysicsSetup.h",
|
||||
"../bullet2/MultiBodyDemo/TestJointTorqueSetup.cpp",
|
||||
@@ -102,10 +100,6 @@
|
||||
-- "../bullet2/LuaDemo/LuaDemo.h",
|
||||
|
||||
|
||||
"../../btgui/Timing/b3Clock.cpp",
|
||||
"../../btgui/Timing/b3Clock.h",
|
||||
"../GpuDemos/gwenUserInterface.cpp",
|
||||
"../GpuDemos/gwenUserInterface.h"
|
||||
}
|
||||
|
||||
if os.is("Linux") then
|
||||
|
||||
Reference in New Issue
Block a user