improve usability of ExampleBrowser
store command-line arguments in bulletDemo.txt save/load of configuration, save demo name instead of index add setBackgroundColor as example (background_color_red) and mouse move/wheel speed config (mouse_wheel_multiplier and mouse_move_multiplier) (saved after changing the demo) default btIDebugDraw colors can be changed b3CommandLineArgs::GetCmdLineArgument returns bool, and b3CommandLineArgs::addArgs added fix copy/paste
This commit is contained in:
@@ -42,6 +42,7 @@ struct CommonGraphicsApp
|
|||||||
float m_mouseXpos;
|
float m_mouseXpos;
|
||||||
float m_mouseYpos;
|
float m_mouseYpos;
|
||||||
bool m_mouseInitialized;
|
bool m_mouseInitialized;
|
||||||
|
float m_backgroundColorRGB[3];
|
||||||
|
|
||||||
CommonGraphicsApp()
|
CommonGraphicsApp()
|
||||||
:m_window(0),
|
:m_window(0),
|
||||||
@@ -57,6 +58,9 @@ struct CommonGraphicsApp
|
|||||||
m_mouseYpos(0.f),
|
m_mouseYpos(0.f),
|
||||||
m_mouseInitialized(false)
|
m_mouseInitialized(false)
|
||||||
{
|
{
|
||||||
|
m_backgroundColorRGB[0] = 0.9;
|
||||||
|
m_backgroundColorRGB[1] = 0.9;
|
||||||
|
m_backgroundColorRGB[2] = 1;
|
||||||
}
|
}
|
||||||
virtual ~CommonGraphicsApp()
|
virtual ~CommonGraphicsApp()
|
||||||
{
|
{
|
||||||
@@ -64,6 +68,41 @@ struct CommonGraphicsApp
|
|||||||
|
|
||||||
virtual void dumpNextFrameToPng(const char* pngFilename){}
|
virtual void dumpNextFrameToPng(const char* pngFilename){}
|
||||||
virtual void dumpFramesToVideo(const char* mp4Filename){}
|
virtual void dumpFramesToVideo(const char* mp4Filename){}
|
||||||
|
virtual void getBackgroundColor(float* red, float* green, float* blue) const
|
||||||
|
{
|
||||||
|
if (red)
|
||||||
|
*red = m_backgroundColorRGB[0];
|
||||||
|
if (green)
|
||||||
|
*green = m_backgroundColorRGB[1];
|
||||||
|
if (blue)
|
||||||
|
*blue = m_backgroundColorRGB[2];
|
||||||
|
}
|
||||||
|
virtual void setBackgroundColor(float red, float green, float blue)
|
||||||
|
{
|
||||||
|
m_backgroundColorRGB[0] = red;
|
||||||
|
m_backgroundColorRGB[1] = green;
|
||||||
|
m_backgroundColorRGB[2] = blue;
|
||||||
|
}
|
||||||
|
virtual void setMouseWheelMultiplier(float mult)
|
||||||
|
{
|
||||||
|
m_wheelMultiplier = mult;
|
||||||
|
}
|
||||||
|
virtual float getMouseWheelMultiplier() const
|
||||||
|
{
|
||||||
|
return m_wheelMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void setMouseMoveMultiplier(float mult)
|
||||||
|
{
|
||||||
|
m_mouseMoveMultiplier = mult;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual float getMouseMoveMultiplier() const
|
||||||
|
{
|
||||||
|
return m_mouseMoveMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual void drawGrid(DrawGridData data=DrawGridData()) = 0;
|
virtual void drawGrid(DrawGridData data=DrawGridData()) = 0;
|
||||||
virtual void setUpAxis(int axis) = 0;
|
virtual void setUpAxis(int axis) = 0;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#include "gwenUserInterface.h"
|
#include "gwenUserInterface.h"
|
||||||
#include "gwenInternalData.h"
|
#include "gwenInternalData.h"
|
||||||
#include "Gwen/Controls/ImagePanel.h"
|
#include "Gwen/Controls/ImagePanel.h"
|
||||||
|
#include "Gwen/Controls/ColorPicker.h"
|
||||||
|
//#include "Gwen/Controls/HSVColorPicker.h"
|
||||||
|
|
||||||
class MyGraphWindow* graphWindow = 0;
|
class MyGraphWindow* graphWindow = 0;
|
||||||
|
|
||||||
@@ -365,10 +367,13 @@ void GwenUserInterface::init(int width, int height,Gwen::Renderer::Base* rendere
|
|||||||
|
|
||||||
Gwen::UnicodeString explorerStr1(L"Explorer");
|
Gwen::UnicodeString explorerStr1(L"Explorer");
|
||||||
m_data->m_explorerPage = explorerTab->AddPage(explorerStr1);
|
m_data->m_explorerPage = explorerTab->AddPage(explorerStr1);
|
||||||
Gwen::UnicodeString shapesStr1(L"Shapes");
|
Gwen::UnicodeString shapesStr1(L"Test");
|
||||||
explorerTab->AddPage(shapesStr1);
|
Gwen::Controls::TabButton* shapes = explorerTab->AddPage(shapesStr1);
|
||||||
Gwen::UnicodeString testStr1(L"Test");
|
|
||||||
explorerTab->AddPage(testStr1);
|
///todo(erwincoumans) figure out why the HSV color picker is extremely slow
|
||||||
|
//Gwen::Controls::HSVColorPicker* color = new Gwen::Controls::HSVColorPicker(shapes->GetPage());
|
||||||
|
Gwen::Controls::ColorPicker* color = new Gwen::Controls::ColorPicker(shapes->GetPage());
|
||||||
|
color->SetKeyboardInputEnabled(true);
|
||||||
|
|
||||||
Gwen::Controls::TreeControl* ctrl = new Gwen::Controls::TreeControl(m_data->m_explorerPage->GetPage());
|
Gwen::Controls::TreeControl* ctrl = new Gwen::Controls::TreeControl(m_data->m_explorerPage->GetPage());
|
||||||
m_data->m_explorerTreeCtrl = ctrl;
|
m_data->m_explorerTreeCtrl = ctrl;
|
||||||
@@ -517,30 +522,63 @@ bool GwenUserInterface::mouseMoveCallback( float x, float y)
|
|||||||
|
|
||||||
bool GwenUserInterface::keyboardCallback(int bulletKey, int state)
|
bool GwenUserInterface::keyboardCallback(int bulletKey, int state)
|
||||||
{
|
{
|
||||||
int key = -1;
|
int gwenKey = -1;
|
||||||
if (m_data->pCanvas)
|
if (m_data->pCanvas)
|
||||||
{
|
{
|
||||||
//convert 'Bullet' keys into 'Gwen' keys
|
//convert 'Bullet' keys into 'Gwen' keys
|
||||||
switch (bulletKey)
|
switch (bulletKey)
|
||||||
{
|
{
|
||||||
case B3G_RETURN:
|
case B3G_LEFT_ARROW:
|
||||||
{
|
{
|
||||||
key = Gwen::Key::Return;
|
gwenKey = Gwen::Key::Left;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B3G_LEFT_ARROW:
|
|
||||||
key = Gwen::Key::Left;
|
|
||||||
break;
|
|
||||||
case B3G_RIGHT_ARROW:
|
case B3G_RIGHT_ARROW:
|
||||||
key = Gwen::Key::Right;
|
{
|
||||||
|
gwenKey = Gwen::Key::Right;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case B3G_UP_ARROW:
|
case B3G_UP_ARROW:
|
||||||
key = Gwen::Key::Up;
|
{
|
||||||
|
gwenKey = Gwen::Key::Up;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case B3G_DOWN_ARROW:
|
case B3G_DOWN_ARROW:
|
||||||
key = Gwen::Key::Down;
|
{
|
||||||
|
gwenKey = Gwen::Key::Down;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case B3G_BACKSPACE:
|
||||||
|
{
|
||||||
|
gwenKey = Gwen::Key::Backspace;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B3G_DELETE:
|
||||||
|
{
|
||||||
|
gwenKey = Gwen::Key::Delete;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B3G_HOME:
|
||||||
|
{
|
||||||
|
gwenKey = Gwen::Key::Home;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B3G_END:
|
||||||
|
{
|
||||||
|
gwenKey = Gwen::Key::End;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B3G_SHIFT:
|
||||||
|
{
|
||||||
|
gwenKey = Gwen::Key::Shift;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B3G_CONTROL:
|
||||||
|
{
|
||||||
|
gwenKey = Gwen::Key::Control;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -548,7 +586,19 @@ bool GwenUserInterface::keyboardCallback(int bulletKey, int state)
|
|||||||
};
|
};
|
||||||
bool bDown = (state == 1);
|
bool bDown = (state == 1);
|
||||||
|
|
||||||
return m_data->pCanvas->InputKey(key, bDown);
|
if (gwenKey>=0)
|
||||||
|
{
|
||||||
|
return m_data->pCanvas->InputKey(gwenKey,state==1);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
if (bulletKey<256 && state)
|
||||||
|
{
|
||||||
|
Gwen::UnicodeChar c = ( Gwen::UnicodeChar ) bulletKey;
|
||||||
|
return m_data->pCanvas->InputCharacter(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ extern bool useShadowMap;
|
|||||||
static bool visualWireframe=false;
|
static bool visualWireframe=false;
|
||||||
static bool renderVisualGeometry=true;
|
static bool renderVisualGeometry=true;
|
||||||
static bool renderGrid = true;
|
static bool renderGrid = true;
|
||||||
|
static bool enable_experimental_opencl = false;
|
||||||
|
|
||||||
int gDebugDrawFlags = 0;
|
int gDebugDrawFlags = 0;
|
||||||
static bool pauseSimulation=false;
|
static bool pauseSimulation=false;
|
||||||
int midiBaseIndex = 176;
|
int midiBaseIndex = 176;
|
||||||
@@ -101,6 +103,10 @@ void deleteDemo()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* gPngFileName = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
b3KeyboardCallback prevKeyboardCallback = 0;
|
b3KeyboardCallback prevKeyboardCallback = 0;
|
||||||
|
|
||||||
@@ -172,6 +178,29 @@ void MyKeyboardCallback(int key, int state)
|
|||||||
useShadowMap=!useShadowMap;
|
useShadowMap=!useShadowMap;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (key==B3G_F1)
|
||||||
|
{
|
||||||
|
static int count=0;
|
||||||
|
if (state)
|
||||||
|
{
|
||||||
|
b3Printf("F1 pressed %d", count++);
|
||||||
|
|
||||||
|
if (gPngFileName)
|
||||||
|
{
|
||||||
|
b3Printf("disable image dump");
|
||||||
|
|
||||||
|
gPngFileName=0;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
gPngFileName = gAllExamples->getExampleName(sCurrentDemoIndex);
|
||||||
|
b3Printf("enable image dump %s",gPngFileName);
|
||||||
|
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
b3Printf("F1 released %d",count++);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (key==B3G_ESCAPE && s_window)
|
if (key==B3G_ESCAPE && s_window)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -182,6 +211,7 @@ void MyKeyboardCallback(int key, int state)
|
|||||||
prevKeyboardCallback(key,state);
|
prevKeyboardCallback(key,state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
b3MouseMoveCallback prevMouseMoveCallback = 0;
|
b3MouseMoveCallback prevMouseMoveCallback = 0;
|
||||||
static void MyMouseMoveCallback( float x, float y)
|
static void MyMouseMoveCallback( float x, float y)
|
||||||
{
|
{
|
||||||
@@ -313,31 +343,59 @@ void selectDemo(int demoIndex)
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
static void saveCurrentDemoEntry(int currentEntry,const char* startFileName)
|
static void saveCurrentSettings(int currentEntry,const char* startFileName)
|
||||||
{
|
{
|
||||||
FILE* f = fopen(startFileName,"w");
|
FILE* f = fopen(startFileName,"w");
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
fprintf(f,"%d\n",currentEntry);
|
fprintf(f,"--start_demo_name=%s\n", gAllExamples->getExampleName(sCurrentDemoIndex));
|
||||||
|
fprintf(f,"--mouse_move_multiplier=%f\n", s_app->getMouseMoveMultiplier());
|
||||||
|
fprintf(f,"--mouse_wheel_multiplier=%f\n", s_app->getMouseWheelMultiplier());
|
||||||
|
float red,green,blue;
|
||||||
|
s_app->getBackgroundColor(&red,&green,&blue);
|
||||||
|
fprintf(f,"--background_color_red= %f\n", red);
|
||||||
|
fprintf(f,"--background_color_green= %f\n", green);
|
||||||
|
fprintf(f,"--background_color_blue= %f\n", blue);
|
||||||
|
|
||||||
|
if (enable_experimental_opencl)
|
||||||
|
{
|
||||||
|
fprintf(f,"--enable_experimental_opencl\n");
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
fprintf(f,"//enable_experimental_opencl\n");
|
||||||
|
}
|
||||||
|
if (sUseOpenGL2 )
|
||||||
|
{
|
||||||
|
fprintf(f,"--opengl2\n");
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
fprintf(f,"//opengl2\n");
|
||||||
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int loadCurrentDemoEntry(const char* startFileName)
|
static void loadCurrentSettings(const char* startFileName, b3CommandLineArgs& args)
|
||||||
{
|
{
|
||||||
int currentEntry= 0;
|
int currentEntry= 0;
|
||||||
FILE* f = fopen(startFileName,"r");
|
FILE* f = fopen(startFileName,"r");
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
result = fscanf(f,"%d",¤tEntry);
|
char oneline[1024];
|
||||||
if (result)
|
char* argv[] = {0,&oneline[0]};
|
||||||
|
|
||||||
|
while( fgets (oneline, 1024, f)!=NULL )
|
||||||
{
|
{
|
||||||
return currentEntry;
|
char *pos;
|
||||||
|
if ((pos=strchr(oneline, '\n')) != NULL)
|
||||||
|
*pos = '\0';
|
||||||
|
args.addArgs(2,argv);
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void MyComboBoxCallback(int comboId, const char* item)
|
void MyComboBoxCallback(int comboId, const char* item)
|
||||||
@@ -351,7 +409,7 @@ void MyComboBoxCallback(int comboId, const char* item)
|
|||||||
if (strcmp(item,allNames[i])==0)
|
if (strcmp(item,allNames[i])==0)
|
||||||
{
|
{
|
||||||
selectDemo(i);
|
selectDemo(i);
|
||||||
saveCurrentDemoEntry(sCurrentDemoIndex,startFileName);
|
saveCurrentSettings(sCurrentDemoIndex,startFileName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -429,7 +487,7 @@ struct MyMenuItemHander :public Gwen::Event::Handler
|
|||||||
|
|
||||||
|
|
||||||
selectDemo(sCurrentHightlighted);
|
selectDemo(sCurrentHightlighted);
|
||||||
saveCurrentDemoEntry(sCurrentDemoIndex, startFileName);
|
saveCurrentSettings(sCurrentDemoIndex, startFileName);
|
||||||
}
|
}
|
||||||
void onButtonC(Gwen::Controls::Base* pControl)
|
void onButtonC(Gwen::Controls::Base* pControl)
|
||||||
{
|
{
|
||||||
@@ -452,7 +510,7 @@ struct MyMenuItemHander :public Gwen::Event::Handler
|
|||||||
|
|
||||||
// printf("onKeyReturn ! \n");
|
// printf("onKeyReturn ! \n");
|
||||||
selectDemo(sCurrentHightlighted);
|
selectDemo(sCurrentHightlighted);
|
||||||
saveCurrentDemoEntry(sCurrentDemoIndex, startFileName);
|
saveCurrentSettings(sCurrentDemoIndex, startFileName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -607,6 +665,8 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
b3CommandLineArgs args(argc,argv);
|
b3CommandLineArgs args(argc,argv);
|
||||||
|
|
||||||
|
loadCurrentSettings(startFileName, args);
|
||||||
|
|
||||||
|
|
||||||
///The OpenCL rigid body pipeline is experimental and
|
///The OpenCL rigid body pipeline is experimental and
|
||||||
///most OpenCL drivers and OpenCL compilers have issues with our kernels.
|
///most OpenCL drivers and OpenCL compilers have issues with our kernels.
|
||||||
@@ -615,6 +675,7 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
|||||||
///Note that several old OpenCL physics examples still have to be ported over to this new Example Browser
|
///Note that several old OpenCL physics examples still have to be ported over to this new Example Browser
|
||||||
if (args.CheckCmdLineFlag("enable_experimental_opencl"))
|
if (args.CheckCmdLineFlag("enable_experimental_opencl"))
|
||||||
{
|
{
|
||||||
|
enable_experimental_opencl = true;
|
||||||
gAllExamples->initOpenCLExampleEntries();
|
gAllExamples->initOpenCLExampleEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -671,6 +732,27 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
|||||||
s_app->m_renderer->getActiveCamera()->setCameraPitch(0);
|
s_app->m_renderer->getActiveCamera()->setCameraPitch(0);
|
||||||
s_app->m_renderer->getActiveCamera()->setCameraTargetPosition(0,0,0);
|
s_app->m_renderer->getActiveCamera()->setCameraTargetPosition(0,0,0);
|
||||||
|
|
||||||
|
float mouseMoveMult= s_app->getMouseMoveMultiplier();
|
||||||
|
if (args.GetCmdLineArgument("mouse_move_multiplier", mouseMoveMult))
|
||||||
|
{
|
||||||
|
s_app->setMouseMoveMultiplier(mouseMoveMult);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float mouseWheelMult= s_app->getMouseWheelMultiplier();
|
||||||
|
if (args.GetCmdLineArgument("mouse_wheel_multiplier",mouseWheelMult))
|
||||||
|
{
|
||||||
|
s_app->setMouseWheelMultiplier(mouseWheelMult);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float red,green,blue;
|
||||||
|
s_app->getBackgroundColor(&red,&green,&blue);
|
||||||
|
args.GetCmdLineArgument("background_color_red",red);
|
||||||
|
args.GetCmdLineArgument("background_color_green",green);
|
||||||
|
args.GetCmdLineArgument("background_color_blue",blue);
|
||||||
|
s_app->setBackgroundColor(red,green,blue);
|
||||||
|
|
||||||
b3SetCustomWarningMessageFunc(MyGuiPrintf);
|
b3SetCustomWarningMessageFunc(MyGuiPrintf);
|
||||||
b3SetCustomPrintfFunc(MyGuiPrintf);
|
b3SetCustomPrintfFunc(MyGuiPrintf);
|
||||||
b3SetCustomErrorMessageFunc(MyStatusBarError);
|
b3SetCustomErrorMessageFunc(MyStatusBarError);
|
||||||
@@ -725,12 +807,12 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
|||||||
|
|
||||||
//char nodeText[1024];
|
//char nodeText[1024];
|
||||||
//int curDemo = 0;
|
//int curDemo = 0;
|
||||||
int selectedDemo = loadCurrentDemoEntry(startFileName);
|
int selectedDemo = 0;
|
||||||
Gwen::Controls::TreeNode* curNode = tree;
|
Gwen::Controls::TreeNode* curNode = tree;
|
||||||
MyMenuItemHander* handler2 = new MyMenuItemHander(-1);
|
MyMenuItemHander* handler2 = new MyMenuItemHander(-1);
|
||||||
|
|
||||||
char* demoNameFromCommandOption = 0;
|
char* demoNameFromCommandOption = 0;
|
||||||
args.GetCmdLineArgument("demo-name", demoNameFromCommandOption);
|
args.GetCmdLineArgument("start_demo_name", demoNameFromCommandOption);
|
||||||
if (demoNameFromCommandOption) {
|
if (demoNameFromCommandOption) {
|
||||||
selectedDemo = -1;
|
selectedDemo = -1;
|
||||||
}
|
}
|
||||||
@@ -770,10 +852,17 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (demoNameFromCommandOption && strcmp(gAllExamples->getExampleName(d), demoNameFromCommandOption) == 0) {
|
|
||||||
|
if (demoNameFromCommandOption )
|
||||||
|
{
|
||||||
|
const char* demoName = gAllExamples->getExampleName(d);
|
||||||
|
int res = strcmp(demoName, demoNameFromCommandOption);
|
||||||
|
if (res==0)
|
||||||
|
{
|
||||||
firstAvailableDemoIndex = d;
|
firstAvailableDemoIndex = d;
|
||||||
firstNode = pNode;
|
firstNode = pNode;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MyMenuItemHander* handler = new MyMenuItemHander(d);
|
MyMenuItemHander* handler = new MyMenuItemHander(d);
|
||||||
pNode->onNamePress.Add(handler, &MyMenuItemHander::onButtonA);
|
pNode->onNamePress.Add(handler, &MyMenuItemHander::onButtonA);
|
||||||
@@ -883,6 +972,25 @@ void OpenGLExampleBrowser::update(float deltaTime)
|
|||||||
//printf("---------------------------------------------------\n");
|
//printf("---------------------------------------------------\n");
|
||||||
//printf("Framecount = %d\n",frameCount);
|
//printf("Framecount = %d\n",frameCount);
|
||||||
|
|
||||||
|
if (gPngFileName)
|
||||||
|
{
|
||||||
|
|
||||||
|
static int skip = 0;
|
||||||
|
skip++;
|
||||||
|
if (skip>10)
|
||||||
|
{
|
||||||
|
skip=0;
|
||||||
|
//printf("gPngFileName=%s\n",gPngFileName);
|
||||||
|
static int s_frameCount = 0;
|
||||||
|
char fileName[1024];
|
||||||
|
sprintf(fileName,"%s%d.png",gPngFileName,s_frameCount++);
|
||||||
|
b3Printf("Made screenshot %s",fileName);
|
||||||
|
s_app->dumpNextFrameToPng(fileName);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sCurrentDemo->stepSimulation(deltaTime);//1./60.f);
|
sCurrentDemo->stepSimulation(deltaTime);//1./60.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -937,6 +1045,10 @@ void OpenGLExampleBrowser::update(float deltaTime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
toggle=1-toggle;
|
toggle=1-toggle;
|
||||||
{
|
{
|
||||||
BT_PROFILE("Sync Parameters");
|
BT_PROFILE("Sync Parameters");
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class MyDebugDrawer : public btIDebugDraw
|
|||||||
btAlignedObjectArray<MyDebugVec3> m_linePoints;
|
btAlignedObjectArray<MyDebugVec3> m_linePoints;
|
||||||
btAlignedObjectArray<unsigned int> m_lineIndices;
|
btAlignedObjectArray<unsigned int> m_lineIndices;
|
||||||
btVector3 m_currentLineColor;
|
btVector3 m_currentLineColor;
|
||||||
|
DefaultColors m_ourColors;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -45,7 +46,19 @@ public:
|
|||||||
m_currentLineColor(-1,-1,-1)
|
m_currentLineColor(-1,-1,-1)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
virtual DefaultColors getDefaultColors() const
|
||||||
|
{
|
||||||
|
return m_ourColors;
|
||||||
|
}
|
||||||
|
///the default implementation for setDefaultColors has no effect. A derived class can implement it and store the colors.
|
||||||
|
virtual void setDefaultColors(const DefaultColors& colors)
|
||||||
|
{
|
||||||
|
m_ourColors = colors;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void drawLine(const btVector3& from1,const btVector3& to1,const btVector3& color1)
|
virtual void drawLine(const btVector3& from1,const btVector3& to1,const btVector3& color1)
|
||||||
{
|
{
|
||||||
//float from[4] = {from1[0],from1[1],from1[2],from1[3]};
|
//float from[4] = {from1[0],from1[1],from1[2],from1[3]};
|
||||||
@@ -174,7 +187,8 @@ void OpenGLGuiHelper::createCollisionObjectGraphicsObject(btCollisionObject* bod
|
|||||||
if (graphicsShapeId>=0)
|
if (graphicsShapeId>=0)
|
||||||
{
|
{
|
||||||
// btAssert(graphicsShapeId >= 0);
|
// btAssert(graphicsShapeId >= 0);
|
||||||
btVector3 localScaling = shape->getLocalScaling();
|
//the graphics shape is already scaled
|
||||||
|
btVector3 localScaling(1,1,1);
|
||||||
int graphicsInstanceId = m_data->m_glApp->m_renderer->registerGraphicsInstance(graphicsShapeId, startTransform.getOrigin(), startTransform.getRotation(), color, localScaling);
|
int graphicsInstanceId = m_data->m_glApp->m_renderer->registerGraphicsInstance(graphicsShapeId, startTransform.getOrigin(), startTransform.getRotation(), color, localScaling);
|
||||||
body->setUserIndex(graphicsInstanceId);
|
body->setUserIndex(graphicsInstanceId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,7 +137,11 @@ SimpleOpenGL2App::SimpleOpenGL2App(const char* title, int width, int height)
|
|||||||
|
|
||||||
|
|
||||||
glGetError();//don't remove this call, it is needed for Ubuntu
|
glGetError();//don't remove this call, it is needed for Ubuntu
|
||||||
glClearColor(0.9,0.9,1,1);
|
glClearColor( m_backgroundColorRGB[0],
|
||||||
|
m_backgroundColorRGB[1],
|
||||||
|
m_backgroundColorRGB[2],
|
||||||
|
1.f);
|
||||||
|
|
||||||
|
|
||||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||||
|
|
||||||
@@ -168,6 +172,12 @@ SimpleOpenGL2App::~SimpleOpenGL2App()
|
|||||||
delete m_data;
|
delete m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleOpenGL2App::setBackgroundColor(float red, float green, float blue)
|
||||||
|
{
|
||||||
|
CommonGraphicsApp::setBackgroundColor(red,green,blue);
|
||||||
|
glClearColor(m_backgroundColorRGB[0],m_backgroundColorRGB[1],m_backgroundColorRGB[2],1.f);
|
||||||
|
}
|
||||||
|
|
||||||
void SimpleOpenGL2App::drawGrid(DrawGridData data)
|
void SimpleOpenGL2App::drawGrid(DrawGridData data)
|
||||||
{
|
{
|
||||||
int gridSize = data.gridSize;
|
int gridSize = data.gridSize;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public:
|
|||||||
|
|
||||||
virtual void swapBuffer();
|
virtual void swapBuffer();
|
||||||
virtual void drawText( const char* txt, int posX, int posY);
|
virtual void drawText( const char* txt, int posX, int posY);
|
||||||
|
virtual void setBackgroundColor(float red, float green, float blue);
|
||||||
virtual int registerCubeShape(float halfExtentsX,float halfExtentsY, float halfExtentsZ)
|
virtual int registerCubeShape(float halfExtentsX,float halfExtentsY, float halfExtentsZ)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -133,7 +133,11 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height)
|
|||||||
|
|
||||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||||
|
|
||||||
glClearColor(0.9,0.9,1,1);
|
glClearColor( m_backgroundColorRGB[0],
|
||||||
|
m_backgroundColorRGB[1],
|
||||||
|
m_backgroundColorRGB[2],
|
||||||
|
1.f);
|
||||||
|
|
||||||
m_window->startRendering();
|
m_window->startRendering();
|
||||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||||
|
|
||||||
@@ -609,6 +613,12 @@ void SimpleOpenGL3App::drawGrid(DrawGridData data)
|
|||||||
m_instancingRenderer->drawPoint(b3MakeVector3(0,0,1),b3MakeVector3(0,0,1),6);
|
m_instancingRenderer->drawPoint(b3MakeVector3(0,0,1),b3MakeVector3(0,0,1),6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleOpenGL3App::setBackgroundColor(float red, float green, float blue)
|
||||||
|
{
|
||||||
|
CommonGraphicsApp::setBackgroundColor(red,green,blue);
|
||||||
|
glClearColor(m_backgroundColorRGB[0],m_backgroundColorRGB[1],m_backgroundColorRGB[2],1.f);
|
||||||
|
}
|
||||||
|
|
||||||
SimpleOpenGL3App::~SimpleOpenGL3App()
|
SimpleOpenGL3App::~SimpleOpenGL3App()
|
||||||
{
|
{
|
||||||
delete m_primRenderer ;
|
delete m_primRenderer ;
|
||||||
@@ -692,7 +702,7 @@ void SimpleOpenGL3App::swapBuffer()
|
|||||||
writeTextureToFile((int)m_window->getRetinaScale()*m_instancingRenderer->getScreenWidth(),
|
writeTextureToFile((int)m_window->getRetinaScale()*m_instancingRenderer->getScreenWidth(),
|
||||||
(int) m_window->getRetinaScale()*this->m_instancingRenderer->getScreenHeight(),m_data->m_frameDumpPngFileName,
|
(int) m_window->getRetinaScale()*this->m_instancingRenderer->getScreenHeight(),m_data->m_frameDumpPngFileName,
|
||||||
m_data->m_ffmpegFile);
|
m_data->m_ffmpegFile);
|
||||||
//m_data->m_renderTexture->disable();
|
m_data->m_renderTexture->disable();
|
||||||
//if (m_data->m_ffmpegFile==0)
|
//if (m_data->m_ffmpegFile==0)
|
||||||
//{
|
//{
|
||||||
m_data->m_frameDumpPngFileName = 0;
|
m_data->m_frameDumpPngFileName = 0;
|
||||||
@@ -755,7 +765,7 @@ void SimpleOpenGL3App::dumpNextFrameToPng(const char* filename)
|
|||||||
//glTexImage2D(GL_TEXTURE_2D, 0,GL_RGB, g_OpenGLWidth,g_OpenGLHeight, 0,GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
//glTexImage2D(GL_TEXTURE_2D, 0,GL_RGB, g_OpenGLWidth,g_OpenGLHeight, 0,GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
||||||
//glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA32F, g_OpenGLWidth,g_OpenGLHeight, 0,GL_RGBA, GL_FLOAT, 0);
|
//glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA32F, g_OpenGLWidth,g_OpenGLHeight, 0,GL_RGBA, GL_FLOAT, 0);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA32F,
|
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA32F,
|
||||||
m_instancingRenderer->getScreenWidth(),m_instancingRenderer->getScreenHeight()
|
m_instancingRenderer->getScreenWidth()*m_window->getRetinaScale(),m_instancingRenderer->getScreenHeight()*m_window->getRetinaScale()
|
||||||
, 0,GL_RGBA, GL_FLOAT, 0);
|
, 0,GL_RGBA, GL_FLOAT, 0);
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
@@ -763,7 +773,7 @@ void SimpleOpenGL3App::dumpNextFrameToPng(const char* filename)
|
|||||||
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
m_data->m_renderTexture->init(m_instancingRenderer->getScreenWidth(),this->m_instancingRenderer->getScreenHeight(),renderTextureId, RENDERTEXTURE_COLOR);
|
m_data->m_renderTexture->init(m_instancingRenderer->getScreenWidth()*m_window->getRetinaScale(),this->m_instancingRenderer->getScreenHeight()*m_window->getRetinaScale(),renderTextureId, RENDERTEXTURE_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_data->m_renderTexture->enable();
|
m_data->m_renderTexture->enable();
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ struct SimpleOpenGL3App : public CommonGraphicsApp
|
|||||||
|
|
||||||
class GLPrimitiveRenderer* m_primRenderer;
|
class GLPrimitiveRenderer* m_primRenderer;
|
||||||
class GLInstancingRenderer* m_instancingRenderer;
|
class GLInstancingRenderer* m_instancingRenderer;
|
||||||
|
virtual void setBackgroundColor(float red, float green, float blue);
|
||||||
|
|
||||||
SimpleOpenGL3App(const char* title, int width,int height);
|
SimpleOpenGL3App(const char* title, int width,int height);
|
||||||
virtual ~SimpleOpenGL3App();
|
virtual ~SimpleOpenGL3App();
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ void RollingFrictionDemo::initPhysics()
|
|||||||
for(int j = 0;j<ARRAY_SIZE_Z;j++)
|
for(int j = 0;j<ARRAY_SIZE_Z;j++)
|
||||||
{
|
{
|
||||||
startTransform.setOrigin(SCALING*btVector3(
|
startTransform.setOrigin(SCALING*btVector3(
|
||||||
btScalar(2.0*i + start_x)+25,
|
btScalar(2.0*i + start_x),
|
||||||
btScalar(2.0*j + start_z),
|
btScalar(2.0*j + start_z),
|
||||||
btScalar(20+2.0*k + start_y)));
|
btScalar(20+2.0*k + start_y)));
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ using namespace Gwen::ControlsInternal;
|
|||||||
GWEN_CONTROL_CONSTRUCTOR( ColorPicker )
|
GWEN_CONTROL_CONSTRUCTOR( ColorPicker )
|
||||||
{
|
{
|
||||||
SetMouseInputEnabled( true );
|
SetMouseInputEnabled( true );
|
||||||
|
SetKeyboardInputEnabled(true);
|
||||||
SetSize( 256, 150 );
|
SetSize( 256, 150 );
|
||||||
CreateControls();
|
CreateControls();
|
||||||
SetColor( Gwen::Color( 50, 60, 70, 255 ) );
|
SetColor( Gwen::Color( 50, 60, 70, 255 ) );
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ bool Gwen::Platform::SetClipboardText( const Gwen::UnicodeString& str )
|
|||||||
|
|
||||||
// Copy the string into the buffer
|
// Copy the string into the buffer
|
||||||
wchar_t* buffer = (wchar_t*) GlobalLock( clipbuffer );
|
wchar_t* buffer = (wchar_t*) GlobalLock( clipbuffer );
|
||||||
wcscpy_s( buffer, iDataSize, str.c_str() );
|
//wcscpy_s( buffer, iDataSize, str.c_str() );
|
||||||
|
memcpy( buffer, str.c_str() ,iDataSize);
|
||||||
GlobalUnlock(clipbuffer);
|
GlobalUnlock(clipbuffer);
|
||||||
|
|
||||||
// Place it on the clipboard
|
// Place it on the clipboard
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ public:
|
|||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
b3CommandLineArgs(int argc, char **argv)
|
b3CommandLineArgs(int argc, char **argv)
|
||||||
|
{
|
||||||
|
addArgs(argc,argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
void addArgs(int argc, char**argv)
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -39,9 +44,14 @@ public:
|
|||||||
key = string(arg, 2, pos - 2);
|
key = string(arg, 2, pos - 2);
|
||||||
val = string(arg, pos + 1, arg.length() - 1);
|
val = string(arg, pos + 1, arg.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//only add new keys, don't replace existing
|
||||||
|
if(pairs.find(key) == pairs.end())
|
||||||
|
{
|
||||||
pairs[key] = val;
|
pairs[key] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool CheckCmdLineFlag(const char* arg_name)
|
bool CheckCmdLineFlag(const char* arg_name)
|
||||||
{
|
{
|
||||||
@@ -54,7 +64,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void GetCmdLineArgument(const char *arg_name, T &val);
|
bool GetCmdLineArgument(const char *arg_name, T &val);
|
||||||
|
|
||||||
int ParsedArgc()
|
int ParsedArgc()
|
||||||
{
|
{
|
||||||
@@ -63,18 +73,20 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void b3CommandLineArgs::GetCmdLineArgument(const char *arg_name, T &val)
|
inline bool b3CommandLineArgs::GetCmdLineArgument(const char *arg_name, T &val)
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
map<string, string>::iterator itr;
|
map<string, string>::iterator itr;
|
||||||
if ((itr = pairs.find(arg_name)) != pairs.end()) {
|
if ((itr = pairs.find(arg_name)) != pairs.end()) {
|
||||||
istringstream strstream(itr->second);
|
istringstream strstream(itr->second);
|
||||||
strstream >> val;
|
strstream >> val;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void b3CommandLineArgs::GetCmdLineArgument<char*>(const char* arg_name, char* &val)
|
inline bool b3CommandLineArgs::GetCmdLineArgument<char*>(const char* arg_name, char* &val)
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
map<string, string>::iterator itr;
|
map<string, string>::iterator itr;
|
||||||
@@ -83,10 +95,11 @@ inline void b3CommandLineArgs::GetCmdLineArgument<char*>(const char* arg_name, c
|
|||||||
string s = itr->second;
|
string s = itr->second;
|
||||||
val = (char*) malloc(sizeof(char) * (s.length() + 1));
|
val = (char*) malloc(sizeof(char) * (s.length() + 1));
|
||||||
std::strcpy(val, s.c_str());
|
std::strcpy(val, s.c_str());
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
val = NULL;
|
val = NULL;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1427,12 +1427,18 @@ void btCollisionWorld::debugDrawObject(const btTransform& worldTransform, const
|
|||||||
|
|
||||||
void btCollisionWorld::debugDrawWorld()
|
void btCollisionWorld::debugDrawWorld()
|
||||||
{
|
{
|
||||||
if (getDebugDrawer() && getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints)
|
if (getDebugDrawer())
|
||||||
{
|
{
|
||||||
|
btIDebugDraw::DefaultColors defaultColors = getDebugDrawer()->getDefaultColors();
|
||||||
|
|
||||||
|
if ( getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
if (getDispatcher())
|
if (getDispatcher())
|
||||||
{
|
{
|
||||||
int numManifolds = getDispatcher()->getNumManifolds();
|
int numManifolds = getDispatcher()->getNumManifolds();
|
||||||
btVector3 color(1,1,0);
|
|
||||||
for (int i=0;i<numManifolds;i++)
|
for (int i=0;i<numManifolds;i++)
|
||||||
{
|
{
|
||||||
btPersistentManifold* contactManifold = getDispatcher()->getManifoldByIndexInternal(i);
|
btPersistentManifold* contactManifold = getDispatcher()->getManifoldByIndexInternal(i);
|
||||||
@@ -1443,13 +1449,13 @@ void btCollisionWorld::debugDrawWorld()
|
|||||||
for (int j=0;j<numContacts;j++)
|
for (int j=0;j<numContacts;j++)
|
||||||
{
|
{
|
||||||
btManifoldPoint& cp = contactManifold->getContactPoint(j);
|
btManifoldPoint& cp = contactManifold->getContactPoint(j);
|
||||||
getDebugDrawer()->drawContactPoint(cp.m_positionWorldOnB,cp.m_normalWorldOnB,cp.getDistance(),cp.getLifeTime(),color);
|
getDebugDrawer()->drawContactPoint(cp.m_positionWorldOnB,cp.m_normalWorldOnB,cp.getDistance(),cp.getLifeTime(),defaultColors.m_contactPoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getDebugDrawer() && (getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe | btIDebugDraw::DBG_DrawAabb)))
|
if ((getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe | btIDebugDraw::DBG_DrawAabb)))
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -1460,22 +1466,23 @@ void btCollisionWorld::debugDrawWorld()
|
|||||||
{
|
{
|
||||||
if (getDebugDrawer() && (getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawWireframe))
|
if (getDebugDrawer() && (getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawWireframe))
|
||||||
{
|
{
|
||||||
btVector3 color(btScalar(1.),btScalar(1.),btScalar(1.));
|
btVector3 color(btScalar(0.4),btScalar(0.4),btScalar(0.4));
|
||||||
|
|
||||||
switch(colObj->getActivationState())
|
switch(colObj->getActivationState())
|
||||||
{
|
{
|
||||||
case ACTIVE_TAG:
|
case ACTIVE_TAG:
|
||||||
color = btVector3(btScalar(1.),btScalar(1.),btScalar(1.)); break;
|
color = defaultColors.m_activeObject; break;
|
||||||
case ISLAND_SLEEPING:
|
case ISLAND_SLEEPING:
|
||||||
color = btVector3(btScalar(0.),btScalar(1.),btScalar(0.));break;
|
color = defaultColors.m_deactivatedObject;break;
|
||||||
case WANTS_DEACTIVATION:
|
case WANTS_DEACTIVATION:
|
||||||
color = btVector3(btScalar(0.),btScalar(1.),btScalar(1.));break;
|
color = defaultColors.m_wantsDeactivationObject;break;
|
||||||
case DISABLE_DEACTIVATION:
|
case DISABLE_DEACTIVATION:
|
||||||
color = btVector3(btScalar(1.),btScalar(0.),btScalar(0.));break;
|
color = defaultColors.m_disabledDeactivationObject;break;
|
||||||
case DISABLE_SIMULATION:
|
case DISABLE_SIMULATION:
|
||||||
color = btVector3(btScalar(1.),btScalar(1.),btScalar(0.));break;
|
color = defaultColors.m_disabledSimulationObject;break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
color = btVector3(btScalar(1),btScalar(0.),btScalar(0.));
|
color = btVector3(btScalar(.3),btScalar(0.3),btScalar(0.3));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1484,7 +1491,7 @@ void btCollisionWorld::debugDrawWorld()
|
|||||||
if (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawAabb))
|
if (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawAabb))
|
||||||
{
|
{
|
||||||
btVector3 minAabb,maxAabb;
|
btVector3 minAabb,maxAabb;
|
||||||
btVector3 colorvec(1,0,0);
|
btVector3 colorvec = defaultColors.m_aabb;
|
||||||
colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
|
colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
|
||||||
btVector3 contactThreshold(gContactBreakingThreshold,gContactBreakingThreshold,gContactBreakingThreshold);
|
btVector3 contactThreshold(gContactBreakingThreshold,gContactBreakingThreshold,gContactBreakingThreshold);
|
||||||
minAabb -= contactThreshold;
|
minAabb -= contactThreshold;
|
||||||
@@ -1504,7 +1511,7 @@ void btCollisionWorld::debugDrawWorld()
|
|||||||
m_debugDrawer->drawAabb(minAabb,maxAabb,colorvec);
|
m_debugDrawer->drawAabb(minAabb,maxAabb,colorvec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ subject to the following restrictions:
|
|||||||
#include "btTransform.h"
|
#include "btTransform.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
|
///The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
|
||||||
///Typical use case: create a debug drawer object, and assign it to a btCollisionWorld or btDynamicsWorld using setDebugDrawer and call debugDrawWorld.
|
///Typical use case: create a debug drawer object, and assign it to a btCollisionWorld or btDynamicsWorld using setDebugDrawer and call debugDrawWorld.
|
||||||
///A class that implements the btIDebugDraw interface has to implement the drawLine method at a minimum.
|
///A class that implements the btIDebugDraw interface has to implement the drawLine method at a minimum.
|
||||||
@@ -29,6 +30,29 @@ class btIDebugDraw
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
ATTRIBUTE_ALIGNED16(struct) DefaultColors
|
||||||
|
{
|
||||||
|
btVector3 m_activeObject;
|
||||||
|
btVector3 m_deactivatedObject;
|
||||||
|
btVector3 m_wantsDeactivationObject;
|
||||||
|
btVector3 m_disabledDeactivationObject;
|
||||||
|
btVector3 m_disabledSimulationObject;
|
||||||
|
btVector3 m_aabb;
|
||||||
|
btVector3 m_contactPoint;
|
||||||
|
|
||||||
|
DefaultColors()
|
||||||
|
: m_activeObject(1,1,1),
|
||||||
|
m_deactivatedObject(0,1,0),
|
||||||
|
m_wantsDeactivationObject(0,1,1),
|
||||||
|
m_disabledDeactivationObject(1,0,0),
|
||||||
|
m_disabledSimulationObject(1,1,0),
|
||||||
|
m_aabb(1,0,0),
|
||||||
|
m_contactPoint(1,1,0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
enum DebugDrawModes
|
enum DebugDrawModes
|
||||||
{
|
{
|
||||||
DBG_NoDebug=0,
|
DBG_NoDebug=0,
|
||||||
@@ -53,6 +77,11 @@ class btIDebugDraw
|
|||||||
|
|
||||||
virtual ~btIDebugDraw() {};
|
virtual ~btIDebugDraw() {};
|
||||||
|
|
||||||
|
|
||||||
|
virtual DefaultColors getDefaultColors() const { DefaultColors colors; return colors; }
|
||||||
|
///the default implementation for setDefaultColors has no effect. A derived class can implement it and store the colors.
|
||||||
|
virtual void setDefaultColors(const DefaultColors& /*colors*/) {}
|
||||||
|
|
||||||
virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color)=0;
|
virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color)=0;
|
||||||
|
|
||||||
virtual void drawLine(const btVector3& from,const btVector3& to, const btVector3& fromColor, const btVector3& toColor)
|
virtual void drawLine(const btVector3& from,const btVector3& to, const btVector3& fromColor, const btVector3& toColor)
|
||||||
|
|||||||
Reference in New Issue
Block a user