add Tutorial.cpp files

load textured sphere8.obj by default as a test
tiny_obj_loader don't crash when mtl is not found
fix camera perspectives for some examples
This commit is contained in:
erwin coumans
2015-08-05 19:22:48 -07:00
parent a5669d2ffd
commit 6d8ad72d68
5 changed files with 22 additions and 12 deletions

View File

@@ -27,6 +27,8 @@ SET(App_ExampleBrowser_SRCS
../BasicDemo/BasicExample.h ../BasicDemo/BasicExample.h
../ForkLift/ForkLiftDemo.cpp ../ForkLift/ForkLiftDemo.cpp
../ForkLift/ForkLiftDemo.h ../ForkLift/ForkLiftDemo.h
../Tutorial/Tutorial.cpp
../Tutorial/Tutorial.h
../GyroscopicDemo/GyroscopicSetup.cpp ../GyroscopicDemo/GyroscopicSetup.cpp
../GyroscopicDemo/GyroscopicSetup.h ../GyroscopicDemo/GyroscopicSetup.h
../Planar2D/Planar2D.cpp ../Planar2D/Planar2D.cpp
@@ -41,6 +43,7 @@ SET(App_ExampleBrowser_SRCS
../FractureDemo/btFractureDynamicsWorld.h ../FractureDemo/btFractureDynamicsWorld.h
../DynamicControlDemo/MotorDemo.cpp ../DynamicControlDemo/MotorDemo.cpp
../DynamicControlDemo/MotorDemo.h ../DynamicControlDemo/MotorDemo.h
../RenderingExamples/CoordinateSystemDemo.cpp ../RenderingExamples/CoordinateSystemDemo.cpp
../RenderingExamples/CoordinateSystemDemo.h ../RenderingExamples/CoordinateSystemDemo.h
../RenderingExamples/RaytracerSetup.cpp ../RenderingExamples/RaytracerSetup.cpp
@@ -118,6 +121,9 @@ SET(App_ExampleBrowser_SRCS
../Constraints/ConstraintPhysicsSetup.h ../Constraints/ConstraintPhysicsSetup.h
../ThirdPartyLibs/stb_image/stb_image.cpp
../ThirdPartyLibs/stb_image/stb_image.h
../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp ../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp
../ThirdPartyLibs/tinyxml/tinystr.cpp ../ThirdPartyLibs/tinyxml/tinystr.cpp
../ThirdPartyLibs/tinyxml/tinyxml.cpp ../ThirdPartyLibs/tinyxml/tinyxml.cpp

View File

@@ -76,9 +76,7 @@ struct ExampleEntry
static ExampleEntry gDefaultExamples[]= static ExampleEntry gDefaultExamples[]=
{ {
ExampleEntry(0,"Tutorial"),
ExampleEntry(1,"Free Rigid Body","Free moving rigid body, without external or constraint forces", TutorialCreateFunc,0),
ExampleEntry(0,"API"), ExampleEntry(0,"API"),
@@ -110,6 +108,10 @@ static ExampleEntry gDefaultExamples[]=
ExampleEntry(1,"Constraint Feedback", "The example shows how to receive joint reaction forces in a btMultiBody. Also the applied impulse is available for a btMultiBodyJointMotor", MultiBodyConstraintFeedbackCreateFunc), ExampleEntry(1,"Constraint Feedback", "The example shows how to receive joint reaction forces in a btMultiBody. Also the applied impulse is available for a btMultiBodyJointMotor", MultiBodyConstraintFeedbackCreateFunc),
ExampleEntry(1,"Inverted Pendulum PD","Keep an inverted pendulum up using open loop PD control", InvertedPendulumPDControlCreateFunc), ExampleEntry(1,"Inverted Pendulum PD","Keep an inverted pendulum up using open loop PD control", InvertedPendulumPDControlCreateFunc),
ExampleEntry(0,"Tutorial"),
ExampleEntry(1,"Free Rigid Body","(Preliminary work in progress) Free moving rigid body, without external or constraint forces", TutorialCreateFunc,0),
#ifdef INCLUDE_CLOTH_DEMOS #ifdef INCLUDE_CLOTH_DEMOS
ExampleEntry(0,"Soft Body"), ExampleEntry(0,"Soft Body"),
ExampleEntry(1,"Cloth","Simulate a patch of cloth.", SoftDemoCreateFunc,0), ExampleEntry(1,"Cloth","Simulate a patch of cloth.", SoftDemoCreateFunc,0),

View File

@@ -8,6 +8,7 @@
#include "Wavefront2GLInstanceGraphicsShape.h" #include "Wavefront2GLInstanceGraphicsShape.h"
#include "../../Utils/b3ResourcePath.h" #include "../../Utils/b3ResourcePath.h"
#include "Bullet3Common/b3FileUtils.h" #include "Bullet3Common/b3FileUtils.h"
#include "stb_image/stb_image.h" #include "stb_image/stb_image.h"
#include "../CommonInterfaces/CommonRigidBodyBase.h" #include "../CommonInterfaces/CommonRigidBodyBase.h"
@@ -24,10 +25,10 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 50; float dist = 18;
float pitch = 61; float pitch = 120;
float yaw = 18; float yaw = 46;
float targetPos[3]={-15,-15,47}; float targetPos[3]={-2,-2,-2};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
} }
@@ -58,7 +59,7 @@ void ImportObjSetup::initPhysics()
m_dynamicsWorld->getDebugDrawer()->setDebugMode(btIDebugDraw::DBG_DrawWireframe); m_dynamicsWorld->getDebugDrawer()->setDebugMode(btIDebugDraw::DBG_DrawWireframe);
const char* fileName = "sphere8.obj"; const char* fileName = "sphere8.obj";//sponza_closed.obj";//sphere8.obj";
char relativeFileName[1024]; char relativeFileName[1024];
if (b3ResourcePath::findResourcePath(fileName, relativeFileName, 1024)) if (b3ResourcePath::findResourcePath(fileName, relativeFileName, 1024))
{ {

View File

@@ -606,8 +606,8 @@ LoadObj(
std::string err_mtl = LoadMtl(material_map, namebuf, mtl_basepath); std::string err_mtl = LoadMtl(material_map, namebuf, mtl_basepath);
if (!err_mtl.empty()) { if (!err_mtl.empty()) {
faceGroup.resize(0); // for safety //faceGroup.resize(0); // for safety
return err_mtl; //return err_mtl;
} }
continue; continue;
} }

View File

@@ -5,10 +5,11 @@
#include "../CommonInterfaces/CommonExampleInterface.h" #include "../CommonInterfaces/CommonExampleInterface.h"
#include "LinearMath/btTransform.h" #include "LinearMath/btTransform.h"
#include "stb_image/stb_image.h"
#include "../CommonInterfaces/CommonGUIHelperInterface.h" #include "../CommonInterfaces/CommonGUIHelperInterface.h"
#include "stb_image/stb_image.h"
struct LWPose struct LWPose
{ {
btVector3 m_worldPosition; btVector3 m_worldPosition;
@@ -227,7 +228,7 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 3.5; float dist = 10.5;
float pitch = 136; float pitch = 136;
float yaw = 32; float yaw = 32;
float targetPos[3]={0,0,0}; float targetPos[3]={0,0,0};