first step in refactoring/cleaning up demos
This commit is contained in:
@@ -20,17 +20,8 @@ Very basic raytracer, rendering into a texture.
|
||||
#include "SimdQuaternion.h"
|
||||
#include "SimdTransform.h"
|
||||
#include "GL_ShapeDrawer.h"
|
||||
#ifdef WIN32 //needed for glut.h
|
||||
#include <windows.h>
|
||||
#endif
|
||||
//think different
|
||||
#if defined(__APPLE__) && !defined (VMDMESA)
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glu.h>
|
||||
#include <GLUT/glut.h>
|
||||
#else
|
||||
#include <GL/glut.h>
|
||||
#endif>
|
||||
|
||||
#include "Raytracer.h"
|
||||
#include "GlutStuff.h"
|
||||
|
||||
#include "NarrowPhaseCollision/VoronoiSimplexSolver.h"
|
||||
@@ -85,6 +76,17 @@ MinkowskiSumShape myMink(&myCylinder,&myBox);
|
||||
///
|
||||
///
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
Raytracer* raytraceDemo = new Raytracer();
|
||||
|
||||
raytraceDemo->initPhysics();
|
||||
|
||||
raytraceDemo->setCameraDistance(6.f);
|
||||
|
||||
return glutmain(argc, argv,screenWidth,screenHeight,"Minkowski-Sum Raytracer Demo",raytraceDemo);
|
||||
}
|
||||
|
||||
void Raytracer::initPhysics()
|
||||
{
|
||||
raytracePicture = new RenderTexture(screenWidth,screenHeight);
|
||||
|
||||
@@ -110,38 +112,36 @@ int main(int argc,char** argv)
|
||||
};
|
||||
SimdScalar radi[NUM_SPHERES] = { 0.35f,0.35f,0.45f,0.40f,0.40f };
|
||||
|
||||
MultiSphereShape multiSphereShape(inertiaHalfExtents,positions,radi,NUM_SPHERES);
|
||||
|
||||
ConvexHullShape convexHullShape(positions,3);
|
||||
MultiSphereShape* multiSphereShape = new MultiSphereShape(inertiaHalfExtents,positions,radi,NUM_SPHERES);
|
||||
ConvexHullShape* convexHullShape = new ConvexHullShape(positions,3);
|
||||
|
||||
|
||||
//choose shape
|
||||
shapePtr[0] = &myCone;
|
||||
shapePtr[1] =&simplex;
|
||||
shapePtr[2] =&convexHullShape;
|
||||
shapePtr[3] =&myMink;//myBox;
|
||||
shapePtr[2] =convexHullShape;
|
||||
shapePtr[3] =&myMink;//myBox;//multiSphereShape
|
||||
|
||||
simplex.SetMargin(0.3f);
|
||||
|
||||
setCameraDistance(6.f);
|
||||
|
||||
return glutmain(argc, argv,screenWidth,screenHeight,"Minkowski-Sum Raytracer Demo");
|
||||
}
|
||||
|
||||
//to be implemented by the demo
|
||||
|
||||
void clientMoveAndDisplay()
|
||||
void Raytracer::clientMoveAndDisplay()
|
||||
{
|
||||
|
||||
clientDisplay();
|
||||
displayCallback();
|
||||
}
|
||||
|
||||
int once = 1;
|
||||
extern float eye[3];
|
||||
|
||||
void clientDisplay(void)
|
||||
|
||||
void Raytracer::displayCallback()
|
||||
{
|
||||
|
||||
updateCamera();
|
||||
|
||||
for (int i=0;i<numObjects;i++)
|
||||
{
|
||||
transforms[i].setIdentity();
|
||||
@@ -194,8 +194,8 @@ void clientDisplay(void)
|
||||
float fov = 2.0 * atanf (tanFov);
|
||||
|
||||
|
||||
SimdVector3 rayFrom(eye[0],eye[1],eye[2]);
|
||||
SimdVector3 rayForward = -rayFrom;
|
||||
SimdVector3 rayFrom = getCameraPosition();
|
||||
SimdVector3 rayForward = getCameraTargetPosition()-getCameraPosition();
|
||||
rayForward.normalize();
|
||||
float farPlane = 600.f;
|
||||
rayForward*= farPlane;
|
||||
@@ -401,25 +401,3 @@ void clientDisplay(void)
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
void clientResetScene()
|
||||
{
|
||||
}
|
||||
|
||||
void clientSpecialKeyboard(int key, int x, int y)
|
||||
{
|
||||
defaultSpecialKeyboard(key,x,y);
|
||||
}
|
||||
|
||||
void clientKeyboard(unsigned char key, int x, int y)
|
||||
{
|
||||
defaultKeyboard(key, x, y);
|
||||
}
|
||||
|
||||
|
||||
void clientMouseFunc(int button, int state, int x, int y)
|
||||
{
|
||||
|
||||
}
|
||||
void clientMotionFunc(int x,int y)
|
||||
{
|
||||
}
|
||||
|
||||
36
Demos/Raytracer/Raytracer.h
Normal file
36
Demos/Raytracer/Raytracer.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#ifndef RAYTRACER_H
|
||||
#define RAYTRACER_H
|
||||
|
||||
#include "DemoApplication.h"
|
||||
|
||||
///Raytracer shows the inner working of the ray casting, using ray tracing rendering into a texture.
|
||||
class Raytracer : public DemoApplication
|
||||
{
|
||||
public:
|
||||
|
||||
void initPhysics();
|
||||
|
||||
virtual void clientMoveAndDisplay();
|
||||
|
||||
virtual void displayCallback();
|
||||
|
||||
virtual void clientResetScene()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif //RAYTRACER_H
|
||||
Reference in New Issue
Block a user