From 0a3efbe349e17f00771339ea154ecb29581bbb17 Mon Sep 17 00:00:00 2001 From: erwin coumans Date: Fri, 6 May 2016 13:57:48 -0700 Subject: [PATCH] make standalone versions (console, tinyrender, opengl) of InverseDynamics/InverseDynamicsExample --- build3/premake4.lua | 2 +- examples/ExampleBrowser/OpenGLGuiHelper.cpp | 1 + .../ImportColladaDemo/LoadMeshFromCollada.cpp | 2 +- .../ImportColladaDemo/LoadMeshFromCollada.h | 2 +- .../ImportObjDemo/LoadMeshFromObj.cpp | 4 +- .../Wavefront2GLInstanceGraphicsShape.cpp | 10 +- .../Wavefront2GLInstanceGraphicsShape.h | 2 +- .../Importers/ImportSTLDemo/LoadMeshFromSTL.h | 2 +- .../ImportURDFDemo/BulletUrdfImporter.cpp | 2 +- .../ImportURDFDemo/MyMultiBodyCreator.cpp | 2 +- .../Importers/ImportURDFDemo/UrdfParser.cpp | 2 +- .../InverseDynamicsExample.cpp | 56 +++--- examples/InverseDynamics/premake4.lua | 162 ++++++++++++++++++ .../RenderingExamples/TimeSeriesCanvas.cpp | 15 +- .../main_console_single_example.cpp | 6 +- .../main_opengl_single_example.cpp | 13 +- .../main_sw_tinyrenderer_single_example.cpp | 12 +- examples/TinyRenderer/TinyRenderer.cpp | 4 +- 18 files changed, 246 insertions(+), 53 deletions(-) create mode 100644 examples/InverseDynamics/premake4.lua diff --git a/build3/premake4.lua b/build3/premake4.lua index 062c08443..31ca45afa 100644 --- a/build3/premake4.lua +++ b/build3/premake4.lua @@ -193,7 +193,7 @@ include "../examples/HelloWorld" include "../examples/BasicDemo" - + include "../examples/InverseDynamics" include "../examples/SharedMemory" include "../examples/MultiThreading" diff --git a/examples/ExampleBrowser/OpenGLGuiHelper.cpp b/examples/ExampleBrowser/OpenGLGuiHelper.cpp index ec88c0c78..5dd62fcdd 100644 --- a/examples/ExampleBrowser/OpenGLGuiHelper.cpp +++ b/examples/ExampleBrowser/OpenGLGuiHelper.cpp @@ -501,6 +501,7 @@ CommonParameterInterface* OpenGLGuiHelper::getParameterInterface() void OpenGLGuiHelper::setUpAxis(int axis) { m_data->m_glApp->setUpAxis(axis); + } void OpenGLGuiHelper::resetCamera(float camDist, float pitch, float yaw, float camPosX,float camPosY, float camPosZ) diff --git a/examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp b/examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp index f5a70a0cf..b9a9479e0 100644 --- a/examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp +++ b/examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp @@ -20,7 +20,7 @@ subject to the following restrictions: #include //fopen #include "Bullet3Common/b3AlignedObjectArray.h" #include -#include "tinyxml/tinyxml.h" +#include "../../ThirdPartyLibs/tinyxml/tinyxml.h" #include "Bullet3Common/b3FileUtils.h" #include "LinearMath/btHashMap.h" diff --git a/examples/Importers/ImportColladaDemo/LoadMeshFromCollada.h b/examples/Importers/ImportColladaDemo/LoadMeshFromCollada.h index c65666f8b..2e939b575 100644 --- a/examples/Importers/ImportColladaDemo/LoadMeshFromCollada.h +++ b/examples/Importers/ImportColladaDemo/LoadMeshFromCollada.h @@ -21,7 +21,7 @@ subject to the following restrictions: #include "LinearMath/btAlignedObjectArray.h" #include "LinearMath/btTransform.h" -#include "../OpenGLWindow/GLInstanceGraphicsShape.h" +#include "../../OpenGLWindow/GLInstanceGraphicsShape.h" #include "ColladaGraphicsInstance.h" diff --git a/examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp b/examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp index 4988fb877..d90bedfe2 100644 --- a/examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp +++ b/examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp @@ -1,6 +1,6 @@ #include "LoadMeshFromObj.h" -#include"Wavefront/tiny_obj_loader.h" -#include "../OpenGLWindow/GLInstanceGraphicsShape.h" +#include"../../ThirdPartyLibs/Wavefront/tiny_obj_loader.h" +#include "../../OpenGLWindow/GLInstanceGraphicsShape.h" #include //fopen #include "Bullet3Common/b3AlignedObjectArray.h" #include diff --git a/examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp b/examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp index c1b417ec9..c57dabf8b 100644 --- a/examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp +++ b/examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp @@ -1,12 +1,12 @@ #include "Wavefront2GLInstanceGraphicsShape.h" -#include "../OpenGLWindow/GLInstancingRenderer.h" -#include "../OpenGLWindow/GLInstanceGraphicsShape.h" +#include "../../OpenGLWindow/GLInstancingRenderer.h" +#include "../../OpenGLWindow/GLInstanceGraphicsShape.h" #include "btBulletDynamicsCommon.h" -#include "../OpenGLWindow/SimpleOpenGL3App.h" +#include "../../OpenGLWindow/SimpleOpenGL3App.h" #include "Wavefront2GLInstanceGraphicsShape.h" -#include "../OpenGLWindow/GLInstancingRenderer.h" -#include "../OpenGLWindow/GLInstanceGraphicsShape.h" +#include "../../OpenGLWindow/GLInstancingRenderer.h" +#include "../../OpenGLWindow/GLInstanceGraphicsShape.h" GLInstanceGraphicsShape* btgCreateGraphicsShapeFromWavefrontObj(std::vector& shapes) { diff --git a/examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.h b/examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.h index c93d1c465..a2b129bea 100644 --- a/examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.h +++ b/examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.h @@ -1,7 +1,7 @@ #ifndef WAVEFRONT2GRAPHICS_H #define WAVEFRONT2GRAPHICS_H -#include"Wavefront/tiny_obj_loader.h" +#include"../../ThirdPartyLibs/Wavefront/tiny_obj_loader.h" #include struct GLInstanceGraphicsShape* btgCreateGraphicsShapeFromWavefrontObj(std::vector& shapes); diff --git a/examples/Importers/ImportSTLDemo/LoadMeshFromSTL.h b/examples/Importers/ImportSTLDemo/LoadMeshFromSTL.h index a44781221..f670dfeec 100644 --- a/examples/Importers/ImportSTLDemo/LoadMeshFromSTL.h +++ b/examples/Importers/ImportSTLDemo/LoadMeshFromSTL.h @@ -2,7 +2,7 @@ #ifndef LOAD_MESH_FROM_STL_H #define LOAD_MESH_FROM_STL_H -#include "../OpenGLWindow/GLInstanceGraphicsShape.h" +#include "../../OpenGLWindow/GLInstanceGraphicsShape.h" #include //fopen #include "Bullet3Common/b3AlignedObjectArray.h" diff --git a/examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp b/examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp index 1639e3b36..77d11953b 100644 --- a/examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp +++ b/examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp @@ -21,7 +21,7 @@ subject to the following restrictions: #include "../ImportSTLDemo/LoadMeshFromSTL.h" #include "../ImportColladaDemo/LoadMeshFromCollada.h" #include "BulletCollision/CollisionShapes/btShapeHull.h"//to create a tesselation of a generic btConvexShape -#include "../CommonInterfaces/CommonGUIHelperInterface.h" +#include "../../CommonInterfaces/CommonGUIHelperInterface.h" #include "Bullet3Common/b3FileUtils.h" #include #include "../../Utils/b3ResourcePath.h" diff --git a/examples/Importers/ImportURDFDemo/MyMultiBodyCreator.cpp b/examples/Importers/ImportURDFDemo/MyMultiBodyCreator.cpp index dd36baa76..28e9023d8 100644 --- a/examples/Importers/ImportURDFDemo/MyMultiBodyCreator.cpp +++ b/examples/Importers/ImportURDFDemo/MyMultiBodyCreator.cpp @@ -1,6 +1,6 @@ #include "MyMultiBodyCreator.h" -#include "../CommonInterfaces/CommonGUIHelperInterface.h" +#include "../../CommonInterfaces/CommonGUIHelperInterface.h" #include "BulletDynamics/Featherstone/btMultiBodyLinkCollider.h" #include "BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h" diff --git a/examples/Importers/ImportURDFDemo/UrdfParser.cpp b/examples/Importers/ImportURDFDemo/UrdfParser.cpp index 81df76996..d0b064bfb 100644 --- a/examples/Importers/ImportURDFDemo/UrdfParser.cpp +++ b/examples/Importers/ImportURDFDemo/UrdfParser.cpp @@ -1,6 +1,6 @@ #include "UrdfParser.h" -#include "tinyxml/tinyxml.h" +#include "../../ThirdPartyLibs/tinyxml/tinyxml.h" #include "urdfStringSplit.h" #include "urdfLexicalCast.h" diff --git a/examples/InverseDynamics/InverseDynamicsExample.cpp b/examples/InverseDynamics/InverseDynamicsExample.cpp index e062e1717..a2ac8f1d6 100644 --- a/examples/InverseDynamics/InverseDynamicsExample.cpp +++ b/examples/InverseDynamics/InverseDynamicsExample.cpp @@ -129,13 +129,15 @@ void InverseDynamicsExample::initPhysics() SliderParams slider("Kp",&kp); slider.m_minVal=0; slider.m_maxVal=2000; - m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider); + if (m_guiHelper->getParameterInterface()) + m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider); } { SliderParams slider("Kd",&kd); slider.m_minVal=0; slider.m_maxVal=50; - m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider); + if (m_guiHelper->getParameterInterface()) + m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider); } if (m_option == BT_ID_PROGRAMMATICALLY) @@ -148,6 +150,7 @@ void InverseDynamicsExample::initPhysics() switch (m_option) { + case 0: case BT_ID_LOAD_URDF: { BulletURDFImporter u2b(m_guiHelper); @@ -189,9 +192,11 @@ void InverseDynamicsExample::initPhysics() if(m_multiBody) { { - m_timeSeriesCanvas = new TimeSeriesCanvas(m_guiHelper->getAppInterface()->m_2dCanvasInterface,512,230, "Joint Space Trajectory"); - m_timeSeriesCanvas ->setupTimeSeries(3,100, 0); - + if (m_guiHelper->getAppInterface() && m_guiHelper->getParameterInterface()) + { + m_timeSeriesCanvas = new TimeSeriesCanvas(m_guiHelper->getAppInterface()->m_2dCanvasInterface,512,230, "Joint Space Trajectory"); + m_timeSeriesCanvas ->setupTimeSeries(3,100, 0); + } } // construct inverse model @@ -203,23 +208,30 @@ void InverseDynamicsExample::initPhysics() } // add joint target controls qd.resize(m_multiBody->getNumDofs()); + qd[3]=B3_HALF_PI; qd_name.resize(m_multiBody->getNumDofs()); q_name.resize(m_multiBody->getNumDofs()); - for(std::size_t dof=0;dofgetParameterInterface()->registerSliderFloatParameter(slider); - btVector4 color = sJointCurveColors[dof&7]; - m_timeSeriesCanvas->addDataSource(q_name[dof].c_str(), color[0]*255,color[1]*255,color[2]*255); - } - + + if (m_timeSeriesCanvas && m_guiHelper->getParameterInterface()) + { + for(std::size_t dof=0;dofgetParameterInterface()->registerSliderFloatParameter(slider); + btVector4 color = sJointCurveColors[dof&7]; + m_timeSeriesCanvas->addDataSource(q_name[dof].c_str(), color[0]*255,color[1]*255,color[2]*255); + + } + } } @@ -246,7 +258,8 @@ void InverseDynamicsExample::stepSimulation(float deltaTime) const btScalar qd_dot=0; const btScalar qd_ddot=0; - m_timeSeriesCanvas->insertDataAtCurrentTime(q[dof],dof,true); + if (m_timeSeriesCanvas) + m_timeSeriesCanvas->insertDataAtCurrentTime(q[dof],dof,true); // pd_control is either desired joint torque for pd control, // or the feedback contribution to nu @@ -330,3 +343,4 @@ CommonExampleInterface* InverseDynamicsExampleCreateFunc(CommonExampleOptions +B3_STANDALONE_EXAMPLE(InverseDynamicsExampleCreateFunc) \ No newline at end of file diff --git a/examples/InverseDynamics/premake4.lua b/examples/InverseDynamics/premake4.lua new file mode 100644 index 000000000..1114283ef --- /dev/null +++ b/examples/InverseDynamics/premake4.lua @@ -0,0 +1,162 @@ + +project "App_InverseDynamicsExample" + +if _OPTIONS["ios"] then + kind "WindowedApp" +else + kind "ConsoleApp" +end +defines {"B3_USE_STANDALONE_EXAMPLE"} +includedirs {"../../src"} + +links { + "BulletInverseDynamicsUtils", "BulletInverseDynamics","Bullet3Common","BulletDynamics","BulletCollision", "LinearMath" +} + +language "C++" + +files { + "**.cpp", + "**.h", + "../StandaloneMain/main_console_single_example.cpp", + "../Utils/b3ResourcePath.cpp", + "../Utils/b3ResourcePath.h", + "../RenderingExamples/TimeSeriesCanvas.cpp", + "../RenderingExamples/TimeSeriesFontData.cpp", + "../MultiBody/InvertedPendulumPDControl.cpp", + "../ThirdPartyLibs/tinyxml/tinystr.cpp", + "../ThirdPartyLibs/tinyxml/tinyxml.cpp", + "../ThirdPartyLibs/tinyxml/tinyxmlerror.cpp", + "../ThirdPartyLibs/tinyxml/tinyxmlparser.cpp", + "../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp", + "../ThirdPartyLibs/Wavefront/tiny_obj_loader.h", + "../Importers/ImportColladaDemo/LoadMeshFromCollada.cpp", + "../Importers/ImportObjDemo/LoadMeshFromObj.cpp", + "../Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp", + "../Importers/ImportURDFDemo/BulletUrdfImporter.cpp", + "../Importers/ImportURDFDemo/MyMultiBodyCreator.cpp", + "../Importers/ImportURDFDemo/URDF2Bullet.cpp", + "../Importers/ImportURDFDemo/UrdfParser.cpp", + "../Importers/ImportURDFDemo/urdfStringSplit.cpp", + +} + + +project "App_InverseDynamicsExampleGui" + +if _OPTIONS["ios"] then + kind "WindowedApp" +else + kind "ConsoleApp" +end +defines {"B3_USE_STANDALONE_EXAMPLE"} + +includedirs {"../../src"} + +links { + "BulletInverseDynamicsUtils", "BulletInverseDynamics","BulletDynamics","BulletCollision", "LinearMath", "OpenGL_Window","Bullet3Common" +} + + initOpenGL() + initGlew() + + +language "C++" + +files { + "InverseDynamicsExample.cpp", + "*.h", + "../StandaloneMain/main_opengl_single_example.cpp", + "../ExampleBrowser/OpenGLGuiHelper.cpp", + "../ExampleBrowser/GL_ShapeDrawer.cpp", + "../Utils/b3ResourcePath.cpp", + "../Utils/b3ResourcePath.h", + "../RenderingExamples/TimeSeriesCanvas.cpp", + "../RenderingExamples/TimeSeriesFontData.cpp", + "../MultiBody/InvertedPendulumPDControl.cpp", + "../ThirdPartyLibs/tinyxml/tinystr.cpp", + "../ThirdPartyLibs/tinyxml/tinyxml.cpp", + "../ThirdPartyLibs/tinyxml/tinyxmlerror.cpp", + "../ThirdPartyLibs/tinyxml/tinyxmlparser.cpp", + "../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp", + "../ThirdPartyLibs/Wavefront/tiny_obj_loader.h", + "../Importers/ImportColladaDemo/LoadMeshFromCollada.cpp", + "../Importers/ImportObjDemo/LoadMeshFromObj.cpp", + "../Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp", + "../Importers/ImportURDFDemo/BulletUrdfImporter.cpp", + "../Importers/ImportURDFDemo/MyMultiBodyCreator.cpp", + "../Importers/ImportURDFDemo/URDF2Bullet.cpp", + "../Importers/ImportURDFDemo/UrdfParser.cpp", + "../Importers/ImportURDFDemo/urdfStringSplit.cpp", + +} + +if os.is("Linux") then initX11() end + +if os.is("MacOSX") then + links{"Cocoa.framework"} +end + + + +project "App_InverseDynamicsExampleGuiWithSoftwareRenderer" + +if _OPTIONS["ios"] then + kind "WindowedApp" +else + kind "ConsoleApp" +end +defines {"B3_USE_STANDALONE_EXAMPLE"} + +includedirs {"../../src"} + +links { + "BulletInverseDynamicsUtils", "BulletInverseDynamics","BulletDynamics","BulletCollision", "LinearMath", "OpenGL_Window","Bullet3Common" +} + + initOpenGL() + initGlew() + + +language "C++" + +files { + "InverseDynamicsExample.cpp", + "*.h", + "../StandaloneMain/main_sw_tinyrenderer_single_example.cpp", + "../ExampleBrowser/OpenGLGuiHelper.cpp", + "../ExampleBrowser/GL_ShapeDrawer.cpp", + "../TinyRenderer/geometry.cpp", + "../TinyRenderer/model.cpp", + "../TinyRenderer/tgaimage.cpp", + "../TinyRenderer/our_gl.cpp", + "../TinyRenderer/TinyRenderer.cpp", + "../Utils/b3ResourcePath.cpp", + "../Utils/b3ResourcePath.cpp", + "../Utils/b3ResourcePath.h", + "../RenderingExamples/TimeSeriesCanvas.cpp", + "../RenderingExamples/TimeSeriesFontData.cpp", + "../MultiBody/InvertedPendulumPDControl.cpp", + "../ThirdPartyLibs/tinyxml/tinystr.cpp", + "../ThirdPartyLibs/tinyxml/tinyxml.cpp", + "../ThirdPartyLibs/tinyxml/tinyxmlerror.cpp", + "../ThirdPartyLibs/tinyxml/tinyxmlparser.cpp", + "../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp", + "../ThirdPartyLibs/Wavefront/tiny_obj_loader.h", + "../Importers/ImportColladaDemo/LoadMeshFromCollada.cpp", + "../Importers/ImportObjDemo/LoadMeshFromObj.cpp", + "../Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp", + "../Importers/ImportURDFDemo/BulletUrdfImporter.cpp", + "../Importers/ImportURDFDemo/MyMultiBodyCreator.cpp", + "../Importers/ImportURDFDemo/URDF2Bullet.cpp", + "../Importers/ImportURDFDemo/UrdfParser.cpp", + "../Importers/ImportURDFDemo/urdfStringSplit.cpp", + +} + +if os.is("Linux") then initX11() end + +if os.is("MacOSX") then + links{"Cocoa.framework"} +end + \ No newline at end of file diff --git a/examples/RenderingExamples/TimeSeriesCanvas.cpp b/examples/RenderingExamples/TimeSeriesCanvas.cpp index 5bed56a5b..31bc28c23 100644 --- a/examples/RenderingExamples/TimeSeriesCanvas.cpp +++ b/examples/RenderingExamples/TimeSeriesCanvas.cpp @@ -72,13 +72,14 @@ struct TimeSeriesInternalData TimeSeriesCanvas::TimeSeriesCanvas(struct Common2dCanvasInterface* canvasInterface, int width, int height, const char* windowTitle) { - btAssert(canvasInterface); - m_internalData = new TimeSeriesInternalData(width,height); m_internalData->m_canvasInterface = canvasInterface; - - m_internalData->m_canvasIndex = m_internalData->m_canvasInterface->createCanvas(windowTitle,m_internalData->m_width,m_internalData->m_height); + + if (canvasInterface) + { + m_internalData->m_canvasIndex = m_internalData->m_canvasInterface->createCanvas(windowTitle,m_internalData->m_width,m_internalData->m_height); + } } void TimeSeriesCanvas::addDataSource(const char* dataSourceLabel, unsigned char red,unsigned char green,unsigned char blue) @@ -105,6 +106,9 @@ void TimeSeriesCanvas::addDataSource(const char* dataSourceLabel, unsigned char } void TimeSeriesCanvas::setupTimeSeries(float yScale, int ticksPerSecond, int startTime) { + if (0==m_internalData->m_canvasInterface) + return; + m_internalData->m_pixelsPerUnit = -(m_internalData->m_height/3.f)/yScale; m_internalData->m_ticksPerSecond = ticksPerSecond; m_internalData->m_yScale = yScale; @@ -282,6 +286,9 @@ void TimeSeriesCanvas::shift1PixelToLeft() void TimeSeriesCanvas::insertDataAtCurrentTime(float orgV, int dataSourceIndex, bool connectToPrevious) { + if (0==m_internalData->m_canvasInterface) + return; + btAssert(dataSourceIndex < m_internalData->m_dataSources.size()); float zero = m_internalData->m_zero; diff --git a/examples/StandaloneMain/main_console_single_example.cpp b/examples/StandaloneMain/main_console_single_example.cpp index e1f5b6dd8..c29ebcd79 100644 --- a/examples/StandaloneMain/main_console_single_example.cpp +++ b/examples/StandaloneMain/main_console_single_example.cpp @@ -35,7 +35,11 @@ int main(int argc, char* argv[]) CommonExampleInterface* example = StandaloneExampleCreateFunc(options); example->initPhysics(); - example->stepSimulation(1.f/60.f); + for (int i=0;i<1000;i++) + { + printf("Simulating step %d\n",i); + example->stepSimulation(1.f/60.f); + } example->exitPhysics(); delete example; diff --git a/examples/StandaloneMain/main_opengl_single_example.cpp b/examples/StandaloneMain/main_opengl_single_example.cpp index 4fd1ff422..6205020f4 100644 --- a/examples/StandaloneMain/main_opengl_single_example.cpp +++ b/examples/StandaloneMain/main_opengl_single_example.cpp @@ -41,19 +41,22 @@ int main(int argc, char* argv[]) CommonExampleOptions options(&gui); CommonExampleInterface* example = StandaloneExampleCreateFunc(options); - - example->initPhysics(); - + example->initPhysics(); + example->resetCamera(); + do { app->m_instancingRenderer->init(); - app->m_instancingRenderer->updateCamera(); + app->m_instancingRenderer->updateCamera(app->getUpAxis()); example->stepSimulation(1./60.); example->renderScene(); - app->drawGrid(); + DrawGridData dg; + dg.upAxis = app->getUpAxis(); + app->drawGrid(dg); + app->swapBuffer(); } while (!app->m_window->requestedExit()); diff --git a/examples/StandaloneMain/main_sw_tinyrenderer_single_example.cpp b/examples/StandaloneMain/main_sw_tinyrenderer_single_example.cpp index 230f5e651..1819c44cf 100644 --- a/examples/StandaloneMain/main_sw_tinyrenderer_single_example.cpp +++ b/examples/StandaloneMain/main_sw_tinyrenderer_single_example.cpp @@ -111,8 +111,8 @@ public: if (shapeIndex>=0) { TinyRenderObjectData* swObj = new TinyRenderObjectData(m_swWidth,m_swHeight,m_rgbColorBuffer,m_depthBuffer); - //swObj->registerMeshShape(vertices,numvertices,indices,numIndices); - swObj->createCube(1,1,1);//MeshShape(vertices,numvertices,indices,numIndices); + swObj->registerMeshShape(vertices,numvertices,indices,numIndices); + //swObj->createCube(1,1,1);//MeshShape(vertices,numvertices,indices,numIndices); m_swRenderObjects.insert(shapeIndex,swObj); } return shapeIndex; @@ -242,18 +242,20 @@ int main(int argc, char* argv[]) CommonExampleInterface* example = StandaloneExampleCreateFunc(options); example->initPhysics(); - + example->resetCamera(); do { app->m_instancingRenderer->init(); - app->m_instancingRenderer->updateCamera(); + app->m_instancingRenderer->updateCamera(app->getUpAxis()); example->stepSimulation(1./60.); example->renderScene(); - app->drawGrid(); + DrawGridData dg; + dg.upAxis = app->getUpAxis(); + app->drawGrid(dg); app->swapBuffer(); } while (!app->m_window->requestedExit()); diff --git a/examples/TinyRenderer/TinyRenderer.cpp b/examples/TinyRenderer/TinyRenderer.cpp index a78e9d6ac..7130f84db 100644 --- a/examples/TinyRenderer/TinyRenderer.cpp +++ b/examples/TinyRenderer/TinyRenderer.cpp @@ -69,8 +69,8 @@ struct Shader : public IShader { Vec3f n = (B*m_model->normal(uv)).normalize(); - //float diff = b3Min(b3Max(0.f, n*m_light_dir_local+0.3f),1.f); - float diff = b3Max(0.f, n*m_light_dir_local); + float diff = b3Min(b3Max(0.f, n*m_light_dir_local+0.3f),1.f); + //float diff = b3Max(0.f, n*m_light_dir_local); color = m_model->diffuse(uv)*diff; return false;