created new Bullet 2 CPU BasicDemo, using the OpenGL 3 rendering. I will add picking soon. Hold ctrl/alt + mouse to move/zoom camera
remove reference to btGImpact (it is removed now)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include "SimpleOpenGL3App.h"
|
||||
|
||||
#include "ShapeData.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "OpenGLWindow/MacOpenGLWindow.h"
|
||||
@@ -171,8 +171,15 @@ void SimpleOpenGL3App::drawText( const char* txt, int posX, int posY)
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
void SimpleOpenGL3App::drawGrid(int gridSize)
|
||||
int SimpleOpenGL3App::registerCubeShape()
|
||||
{
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
int shapeId = m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
return shapeId;
|
||||
}
|
||||
void SimpleOpenGL3App::drawGrid(int gridSize, float yOffset)
|
||||
{
|
||||
|
||||
b3Vector3 gridColor = b3MakeVector3(0.5,0.5,0.5);
|
||||
@@ -182,12 +189,12 @@ void SimpleOpenGL3App::drawGrid(int gridSize)
|
||||
GLint err = glGetError();
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
m_instancingRenderer->drawLine(b3MakeVector3(float(i),0,float(-gridSize)),b3MakeVector3(float(i),0,float(gridSize)),gridColor);
|
||||
m_instancingRenderer->drawLine(b3MakeVector3(float(i),yOffset,float(-gridSize)),b3MakeVector3(float(i),yOffset,float(gridSize)),gridColor);
|
||||
|
||||
err = glGetError();
|
||||
b3Assert(err==GL_NO_ERROR);
|
||||
|
||||
m_instancingRenderer->drawLine(b3MakeVector3(float(-gridSize),0,float(i)),b3MakeVector3(float(gridSize),0,float(i)),gridColor);
|
||||
m_instancingRenderer->drawLine(b3MakeVector3(float(-gridSize),yOffset,float(i)),b3MakeVector3(float(gridSize),yOffset,float(i)),gridColor);
|
||||
}
|
||||
|
||||
m_instancingRenderer->drawLine(b3MakeVector3(0,0,0),b3MakeVector3(1,0,0),b3MakeVector3(1,0,0),3);
|
||||
|
||||
@@ -16,7 +16,9 @@ struct SimpleOpenGL3App
|
||||
SimpleOpenGL3App(const char* title, int width,int height);
|
||||
virtual ~SimpleOpenGL3App();
|
||||
|
||||
void drawGrid(int gridSize=10);
|
||||
int registerCubeShape();
|
||||
|
||||
void drawGrid(int gridSize=10, float yOffset=0.001);
|
||||
void swapBuffer();
|
||||
void drawText( const char* txt, int posX, int posY);
|
||||
|
||||
|
||||
@@ -1,375 +0,0 @@
|
||||
|
||||
#include "gwenWindow.h"
|
||||
|
||||
|
||||
#include "Gwen/Platform.h"
|
||||
#include "Gwen/Controls/TreeControl.h"
|
||||
#include "Gwen/Controls/RadioButtonController.h"
|
||||
#include "Gwen/Controls/VerticalSlider.h"
|
||||
#include "Gwen/Controls/HorizontalSlider.h"
|
||||
#include "Gwen/Controls/GroupBox.h"
|
||||
#include "Gwen/Controls/CheckBox.h"
|
||||
#include "Gwen/Controls/MenuStrip.h"
|
||||
|
||||
|
||||
#include "Gwen/Gwen.h"
|
||||
#include "Gwen/Align.h"
|
||||
#include "Gwen/Utility.h"
|
||||
#include "Gwen/Controls/WindowControl.h"
|
||||
#include "Gwen/Controls/TabControl.h"
|
||||
#include "Gwen/Controls/ListBox.h"
|
||||
|
||||
#include "Bullet3Common/b3Quickprof.h"
|
||||
#include "GwenOpenGL3CoreRenderer.h"
|
||||
#include "GLPrimitiveRenderer.h"
|
||||
|
||||
GLPrimitiveRenderer* primRenderer=0;
|
||||
GwenOpenGL3CoreRenderer* pRenderer = 0;
|
||||
//Gwen::Renderer::OpenGL_DebugFont * pRenderer =0;
|
||||
Gwen::Skin::Simple skin;
|
||||
Gwen::Controls::Canvas* pCanvas =0;
|
||||
class MyProfileWindow* profWindow = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
/*struct MyHander :public Gwen::Event::Handler
|
||||
{
|
||||
|
||||
MyHander (Application* app)
|
||||
:m_app(app)
|
||||
{
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
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:
|
||||
|
||||
void MenuItemSelect(Gwen::Controls::Base* pControl)
|
||||
{
|
||||
if (Hidden())
|
||||
{
|
||||
SetHidden(false);
|
||||
} else
|
||||
{
|
||||
SetHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MyProfileWindow ( Gwen::Controls::Base* pParent)
|
||||
: Gwen::Controls::WindowControl( pParent )
|
||||
{
|
||||
SetTitle( L"FEM Settings" );
|
||||
|
||||
SetSize( 450, 150 );
|
||||
this->SetPos(10,40);
|
||||
|
||||
// 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->SetBounds( this->GetInnerBounds().x,this->GetInnerBounds().y,this->GetInnerBounds().w,this->GetInnerBounds().h);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
float dumpRecursive(b3ProfileIterator* profileIterator, Gwen::Controls::TreeNode* parentNode)
|
||||
{
|
||||
profileIterator->First();
|
||||
if (profileIterator->Is_Done())
|
||||
return 0.f;
|
||||
|
||||
float accumulated_time=0,parent_time = profileIterator->Is_Root() ? b3ProfileManager::Get_Time_Since_Reset() : profileIterator->Get_Current_Parent_Total_Time();
|
||||
int i;
|
||||
int frames_since_reset = b3ProfileManager::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 > B3_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(b3ProfileIterator* 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 = b3ProfileManager::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 = b3ProfileManager::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 > B3_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 > B3_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 bool once1 = true;
|
||||
if (once1)
|
||||
{
|
||||
once1 = false;
|
||||
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 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
struct MyTestMenuBar : public Gwen::Controls::MenuStrip
|
||||
{
|
||||
MyProfileWindow* m_profileWindow;
|
||||
|
||||
|
||||
MyTestMenuBar(Gwen::Controls::Base* pParent, MyProfileWindow* profileWindow)
|
||||
:Gwen::Controls::MenuStrip(pParent),
|
||||
m_profileWindow(profileWindow)
|
||||
{
|
||||
// Gwen::Controls::MenuStrip* menu = new Gwen::Controls::MenuStrip( pParent );
|
||||
{
|
||||
Gwen::Controls::MenuItem* pRoot = AddItem( L"File" );
|
||||
|
||||
pRoot = AddItem( L"View" );
|
||||
// Gwen::Event::Handler* handler = GWEN_MCALL(&MyTestMenuBar::MenuItemSelect );
|
||||
pRoot->GetMenu()->AddItem( L"Profiler",m_profileWindow,(Gwen::Event::Handler::Function)&MyProfileWindow::MenuItemSelect);
|
||||
|
||||
/* pRoot->GetMenu()->AddItem( L"New", L"test16.png", GWEN_MCALL( ThisClass::MenuItemSelect ) );
|
||||
pRoot->GetMenu()->AddItem( L"Load", L"test16.png", GWEN_MCALL( ThisClass::MenuItemSelect ) );
|
||||
pRoot->GetMenu()->AddItem( L"Save", GWEN_MCALL( ThisClass::MenuItemSelect ) );
|
||||
pRoot->GetMenu()->AddItem( L"Save As..", GWEN_MCALL( ThisClass::MenuItemSelect ) );
|
||||
pRoot->GetMenu()->AddItem( L"Quit", GWEN_MCALL( ThisClass::MenuItemSelect ) );
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void setupGUI(int width, int height, sth_stash* font, float retinaScale,GLPrimitiveRenderer* primRender)
|
||||
{
|
||||
primRenderer = primRender;
|
||||
pRenderer = new GwenOpenGL3CoreRenderer(primRenderer,font,width,height, retinaScale);
|
||||
if (primRenderer)
|
||||
primRenderer->setScreenSize(width,height);
|
||||
|
||||
// pRenderer = new Gwen::Renderer::OpenGL_DebugFont();
|
||||
skin.SetRender( pRenderer );
|
||||
|
||||
pCanvas = new Gwen::Controls::Canvas( &skin );
|
||||
pCanvas->SetSize( width,height);
|
||||
pCanvas->SetDrawBackground( false);
|
||||
pCanvas->SetBackgroundColor( Gwen::Color( 150, 170, 170, 255 ) );
|
||||
// pCanvas->SetScale(.5);
|
||||
//MyWindow* window = new MyWindow(pCanvas);
|
||||
profWindow = new MyProfileWindow(pCanvas);
|
||||
|
||||
MyTestMenuBar* menubar = new MyTestMenuBar(pCanvas, profWindow);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void resizeGUI(int width, int height)
|
||||
{
|
||||
pCanvas->SetSize(width,height);
|
||||
pRenderer->resize(width,height);
|
||||
primRenderer->setScreenSize(width,height);
|
||||
}
|
||||
|
||||
void processProfileData(b3ProfileIterator* iterator, bool idle)
|
||||
{
|
||||
if (profWindow)
|
||||
{
|
||||
|
||||
profWindow->UpdateText(iterator, idle);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
|
||||
#ifndef MY_GWEN_WINDOW_H
|
||||
#define MY_GWEN_WINDOW_H
|
||||
|
||||
|
||||
#include "Gwen/Gwen.h"
|
||||
#include "Gwen/Controls/Button.h"
|
||||
#include "Gwen/Skins/Simple.h"
|
||||
#include "Gwen/Renderers/OpenGL_DebugFont.h"
|
||||
|
||||
struct sth_stash;
|
||||
|
||||
extern class GwenOpenGL3CoreRenderer* pRenderer;
|
||||
//extern Gwen::Renderer::OpenGL_DebugFont * pRenderer;
|
||||
extern Gwen::Skin::Simple skin;
|
||||
extern Gwen::Controls::Canvas* pCanvas;
|
||||
|
||||
class GLPrimitiveRenderer;
|
||||
|
||||
void setupGUI(int width, int height, sth_stash* font, float retinaScale,GLPrimitiveRenderer* primRender);
|
||||
void processProfileData(class b3ProfileIterator* iterator, bool idle);
|
||||
void resizeGUI(int width, int height);
|
||||
|
||||
#endif //MY_GWEN_WINDOW_H
|
||||
@@ -1,516 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2012 Advanced Micro Devices, Inc.
|
||||
|
||||
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.
|
||||
*/
|
||||
//Originally written by Erwin Coumans
|
||||
|
||||
//
|
||||
//#include "vld.h"
|
||||
#ifndef __APPLE__
|
||||
#include <GL/glew.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
#include "GLInstancingRenderer.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "MacOpenGLWindow.h"
|
||||
#elif _WIN32
|
||||
#include "Win32OpenGLWindow.h"
|
||||
#elif __linux
|
||||
#include "X11OpenGLWindow.h"
|
||||
#endif
|
||||
|
||||
#include "GLPrimitiveRenderer.h"
|
||||
|
||||
extern char OpenSansData[];
|
||||
|
||||
#include "renderscene.h"
|
||||
|
||||
|
||||
#include "Bullet3Common/b3Quickprof.h"
|
||||
#include "Bullet3Common/b3Quaternion.h"
|
||||
|
||||
#include "Bullet3Common/b3CommandLineArgs.h"
|
||||
|
||||
#include "../OpenGLTrueTypeFont/fontstash.h"
|
||||
#include "../OpenGLTrueTypeFont/opengl_fontstashcallbacks.h"
|
||||
|
||||
bool printStats = false;
|
||||
bool pauseSimulation = false;
|
||||
bool shootObject = false;
|
||||
|
||||
|
||||
bool useInterop = false;
|
||||
|
||||
extern int NUM_OBJECTS_X;
|
||||
extern int NUM_OBJECTS_Y;
|
||||
extern int NUM_OBJECTS_Z;
|
||||
extern bool keepStaticObjects;
|
||||
extern float X_GAP;
|
||||
extern float Y_GAP;
|
||||
extern float Z_GAP;
|
||||
|
||||
const char* fileName="../../bin/1000 stack.bullet";
|
||||
void Usage()
|
||||
{
|
||||
printf("\nprogram.exe [--pause_simulation=<0 or 1>] [--load_bulletfile=test.bullet] [--enable_interop=<0 or 1>] [--enable_gpusap=<0 or 1>] [--enable_convexheightfield=<0 or 1>] [--enable_static=<0 or 1>] [--x_dim=<int>] [--y_dim=<num>] [--z_dim=<int>] [--x_gap=<float>] [--y_gap=<float>] [--z_gap=<float>]\n");
|
||||
};
|
||||
|
||||
|
||||
#include "gwenWindow.h"
|
||||
|
||||
|
||||
void MyMouseButtonCallback(int button, int state, float x, float y)
|
||||
{
|
||||
//b3DefaultMouseCallback(button,state,x,y);
|
||||
|
||||
if (pCanvas)
|
||||
{
|
||||
bool handled = pCanvas->InputMouseMoved(x,y,x, y);
|
||||
|
||||
if (button>=0)
|
||||
{
|
||||
handled = pCanvas->InputMouseButton(button,state);
|
||||
if (handled)
|
||||
{
|
||||
if (!state)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int g_OpenGLWidth = 1024;//650;
|
||||
int g_OpenGLHeight =800;
|
||||
|
||||
void MyResizeCallback(float width, float height)
|
||||
{
|
||||
g_OpenGLWidth = width;
|
||||
g_OpenGLHeight = height;
|
||||
if (pCanvas)
|
||||
{
|
||||
pCanvas->SetSize(width,height);
|
||||
resizeGUI(width,height);
|
||||
}
|
||||
}
|
||||
|
||||
void MyMouseMoveCallback( float x, float y)
|
||||
{
|
||||
//b3DefaultMouseCallback(button,state,x,y);
|
||||
|
||||
static int m_lastmousepos[2] = {0,0};
|
||||
static bool isInitialized = false;
|
||||
if (pCanvas)
|
||||
{
|
||||
if (!isInitialized)
|
||||
{
|
||||
isInitialized = true;
|
||||
m_lastmousepos[0] = x+1;
|
||||
m_lastmousepos[1] = y+1;
|
||||
}
|
||||
bool handled = pCanvas->InputMouseMoved(x,y,m_lastmousepos[0],m_lastmousepos[1]);
|
||||
}
|
||||
}
|
||||
|
||||
int droidRegular;//, droidItalic, droidBold, droidJapanese, dejavu;
|
||||
|
||||
sth_stash* initFont(GLPrimitiveRenderer* primRender)
|
||||
{
|
||||
GLint err;
|
||||
|
||||
struct sth_stash* stash = 0;
|
||||
int datasize;
|
||||
|
||||
float sx,sy,dx,dy,lh;
|
||||
GLuint texture;
|
||||
OpenGL2RenderCallbacks* renderCallbacks = new OpenGL2RenderCallbacks(primRender);
|
||||
stash = sth_create(512,512,renderCallbacks);//256,256);//,1024);//512,512);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
if (!stash)
|
||||
{
|
||||
fprintf(stderr, "Could not create stash.\n");
|
||||
return 0;
|
||||
}
|
||||
#ifdef LOAD_FONT_FROM_FILE
|
||||
unsigned char* data;
|
||||
const char* fontPaths[]={
|
||||
"./",
|
||||
"../../bin/",
|
||||
"../bin/",
|
||||
"bin/"
|
||||
};
|
||||
|
||||
int numPaths=sizeof(fontPaths)/sizeof(char*);
|
||||
|
||||
// Load the first truetype font from memory (just because we can).
|
||||
|
||||
FILE* fp = 0;
|
||||
const char* fontPath ="./";
|
||||
char fullFontFileName[1024];
|
||||
|
||||
for (int i=0;i<numPaths;i++)
|
||||
{
|
||||
|
||||
fontPath = fontPaths[i];
|
||||
//sprintf(fullFontFileName,"%s%s",fontPath,"OpenSans.ttf");//"DroidSerif-Regular.ttf");
|
||||
sprintf(fullFontFileName,"%s%s",fontPath,"DroidSerif-Regular.ttf");//OpenSans.ttf");//"DroidSerif-Regular.ttf");
|
||||
fp = fopen(fullFontFileName, "rb");
|
||||
if (fp)
|
||||
break;
|
||||
}
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
assert(fp);
|
||||
if (fp)
|
||||
{
|
||||
fseek(fp, 0, SEEK_END);
|
||||
datasize = (int)ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
data = (unsigned char*)malloc(datasize);
|
||||
if (data == NULL)
|
||||
{
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
fread(data, 1, datasize, fp);
|
||||
fclose(fp);
|
||||
fp = 0;
|
||||
}
|
||||
if (!(droidRegular = sth_add_font_from_memory(stash, data)))
|
||||
{
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
// Load the remaining truetype fonts directly.
|
||||
sprintf(fullFontFileName,"%s%s",fontPath,"DroidSerif-Italic.ttf");
|
||||
|
||||
if (!(droidItalic = sth_add_font(stash,fullFontFileName)))
|
||||
{
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
sprintf(fullFontFileName,"%s%s",fontPath,"DroidSerif-Bold.ttf");
|
||||
|
||||
if (!(droidBold = sth_add_font(stash,fullFontFileName)))
|
||||
{
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
sprintf(fullFontFileName,"%s%s",fontPath,"DroidSansJapanese.ttf");
|
||||
if (!(droidJapanese = sth_add_font(stash,fullFontFileName)))
|
||||
{
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
#else//LOAD_FONT_FROM_FILE
|
||||
char* data2 = OpenSansData;
|
||||
unsigned char* data = (unsigned char*) data2;
|
||||
if (!(droidRegular = sth_add_font_from_memory(stash, data)))
|
||||
{
|
||||
printf("error!\n");
|
||||
}
|
||||
#endif//LOAD_FONT_FROM_FILE
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
return stash;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
b3CommandLineArgs args(argc,argv);
|
||||
|
||||
if (args.CheckCmdLineFlag("help"))
|
||||
{
|
||||
Usage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
args.GetCmdLineArgument("enable_interop", useInterop);
|
||||
printf("useInterop=%d\n",useInterop);
|
||||
|
||||
|
||||
|
||||
args.GetCmdLineArgument("pause_simulation", pauseSimulation);
|
||||
printf("pause_simulation=%d\n",pauseSimulation);
|
||||
args.GetCmdLineArgument("x_dim", NUM_OBJECTS_X);
|
||||
args.GetCmdLineArgument("y_dim", NUM_OBJECTS_Y);
|
||||
args.GetCmdLineArgument("z_dim", NUM_OBJECTS_Z);
|
||||
|
||||
args.GetCmdLineArgument("x_gap", X_GAP);
|
||||
args.GetCmdLineArgument("y_gap", Y_GAP);
|
||||
args.GetCmdLineArgument("z_gap", Z_GAP);
|
||||
printf("x_dim=%d, y_dim=%d, z_dim=%d\n",NUM_OBJECTS_X,NUM_OBJECTS_Y,NUM_OBJECTS_Z);
|
||||
printf("x_gap=%f, y_gap=%f, z_gap=%f\n",X_GAP,Y_GAP,Z_GAP);
|
||||
|
||||
args.GetCmdLineArgument("enable_static", keepStaticObjects);
|
||||
printf("enable_static=%d\n",keepStaticObjects);
|
||||
|
||||
|
||||
char* tmpfile = 0;
|
||||
args.GetCmdLineArgument("load_bulletfile", tmpfile );
|
||||
if (tmpfile)
|
||||
fileName = tmpfile;
|
||||
|
||||
printf("load_bulletfile=%s\n",fileName);
|
||||
|
||||
|
||||
printf("\n");
|
||||
b3gDefaultOpenGLWindow* window = new b3gDefaultOpenGLWindow();
|
||||
b3gWindowConstructionInfo wci;
|
||||
wci.m_width = g_OpenGLWidth;
|
||||
wci.m_height = g_OpenGLHeight;
|
||||
|
||||
window->createWindow(wci);
|
||||
window->setWindowTitle("render test");
|
||||
|
||||
|
||||
|
||||
float retinaScale = 1;
|
||||
|
||||
#ifndef __APPLE__
|
||||
GLenum err = glewInit();
|
||||
#else
|
||||
retinaScale = window->getRetinaScale();
|
||||
#endif
|
||||
|
||||
window->runMainLoop();
|
||||
window->startRendering();
|
||||
window->endRendering();
|
||||
|
||||
int maxObjectCapacity=128*1024;
|
||||
GLInstancingRenderer render(maxObjectCapacity);
|
||||
|
||||
GLPrimitiveRenderer* primRenderer = new GLPrimitiveRenderer(g_OpenGLWidth,g_OpenGLHeight);
|
||||
|
||||
sth_stash* stash = initFont(primRenderer);
|
||||
|
||||
render.InitShaders();
|
||||
|
||||
|
||||
createSceneProgrammatically(render);
|
||||
|
||||
|
||||
render.writeTransforms();
|
||||
|
||||
window->runMainLoop();
|
||||
|
||||
window->setMouseButtonCallback(MyMouseButtonCallback);
|
||||
window->setMouseMoveCallback(MyMouseMoveCallback);
|
||||
window->setResizeCallback(MyResizeCallback);
|
||||
window->setKeyboardCallback(b3DefaultKeyboardCallback);
|
||||
window->setWheelCallback(b3DefaultWheelCallback);
|
||||
|
||||
|
||||
//GLPrimitiveRenderer* pprender = new GLPrimitiveRenderer(g_OpenGLWidth,g_OpenGLHeight);
|
||||
|
||||
glUseProgram(0);
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
/////////////////////////////////////
|
||||
|
||||
|
||||
if (pCanvas)
|
||||
{
|
||||
pCanvas->SetSize(g_OpenGLWidth,g_OpenGLHeight);
|
||||
}
|
||||
setupGUI(g_OpenGLWidth,g_OpenGLHeight,stash,retinaScale,primRenderer);
|
||||
class b3ProfileIterator* m_profileIterator;
|
||||
m_profileIterator = b3ProfileManager::Get_Iterator();
|
||||
|
||||
glClearColor(1,1,1,1);
|
||||
while (!window->requestedExit())
|
||||
{
|
||||
b3ProfileManager::Reset();
|
||||
|
||||
{
|
||||
B3_PROFILE("loop");
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
B3_PROFILE("startRendering");
|
||||
window->startRendering();
|
||||
}
|
||||
render.RenderScene();
|
||||
glFinish();
|
||||
float col[4]={0,1,0,1};
|
||||
// pprender->drawRect(10,50,120,60,col);
|
||||
// glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
||||
//glEnable(GL_TEXTURE_2D);
|
||||
|
||||
float x = 10;
|
||||
float y=220;
|
||||
float dx=0;
|
||||
if (1)
|
||||
{
|
||||
B3_PROFILE("font sth_draw_text");
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
GLint err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
sth_begin_draw(stash);
|
||||
sth_flush_draw(stash);
|
||||
sth_draw_text(stash, droidRegular,20.f, x, y, "Non-retina font rendering !@#$", &dx,g_OpenGLWidth,g_OpenGLHeight,0,1);//retinaScale);
|
||||
if (retinaScale!=1.f)
|
||||
sth_draw_text(stash, droidRegular,20.f*retinaScale, x, y+20, "Retina font rendering!@#$", &dx,g_OpenGLWidth,g_OpenGLHeight,0,retinaScale);
|
||||
sth_flush_draw(stash);
|
||||
|
||||
sth_end_draw(stash);
|
||||
}
|
||||
|
||||
if (1)
|
||||
{
|
||||
B3_PROFILE("gwen RenderCanvas");
|
||||
|
||||
if (pCanvas)
|
||||
{
|
||||
glEnable(GL_BLEND);
|
||||
GLint err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
//glColor4ub(255,0,0,255);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
// saveOpenGLState(width,height);//m_glutScreenWidth,m_glutScreenHeight);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
|
||||
|
||||
pCanvas->RenderCanvas();
|
||||
//restoreOpenGLState();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
window->endRendering();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
b3ProfileManager::Increment_Frame_Counter();
|
||||
|
||||
|
||||
|
||||
static bool printStats = true;
|
||||
|
||||
|
||||
if (printStats && !pauseSimulation)
|
||||
{
|
||||
static int count = 0;
|
||||
count--;
|
||||
if (count<0)
|
||||
{
|
||||
count = 100;
|
||||
{
|
||||
//B3_PROFILE("processProfileData");
|
||||
processProfileData(m_profileIterator,false);
|
||||
}
|
||||
//b3ProfileManager::dumpAll();
|
||||
//printStats = false;
|
||||
} else
|
||||
{
|
||||
// printf(".");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//delete pprender;
|
||||
// render.CleanupShaders();
|
||||
window->closeWindow();
|
||||
|
||||
delete window;
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,14 +1,11 @@
|
||||
|
||||
|
||||
project "OpenGL_rendertest"
|
||||
|
||||
project "OpenGL_Window"
|
||||
|
||||
language "C++"
|
||||
|
||||
kind "ConsoleApp"
|
||||
kind "StaticLib"
|
||||
targetdir "../../bin"
|
||||
|
||||
|
||||
initOpenGL()
|
||||
initGlew()
|
||||
|
||||
@@ -17,61 +14,36 @@
|
||||
"../../src",
|
||||
}
|
||||
|
||||
links {
|
||||
"gwen"
|
||||
}
|
||||
--links {
|
||||
--}
|
||||
|
||||
files {
|
||||
"main.cpp",
|
||||
"renderscene.cpp",
|
||||
"renderscene.h",
|
||||
"GLInstancingRenderer.cpp",
|
||||
"GLInstancingRenderer.h",
|
||||
"GLPrimitiveRenderer.h",
|
||||
"GLPrimitiveRenderer.cpp",
|
||||
"SimpleOpenGL3App.cpp",
|
||||
"SimpleOpenGL3App.h",
|
||||
"LoadShader.cpp",
|
||||
"LoadShader.h",
|
||||
"gwenWindow.cpp",
|
||||
"gwenWindow.h",
|
||||
"TwFonts.cpp",
|
||||
"TwFonts.h",
|
||||
"GwenOpenGL3CoreRenderer.h",
|
||||
"../FontFiles/OpenSans.cpp",
|
||||
"../OpenGLTrueTypeFont/fontstash.cpp",
|
||||
"../OpenGLTrueTypeFont/fontstash.h",
|
||||
"../OpenGLTrueTypeFont/opengl_fontstashcallbacks.cpp",
|
||||
"../OpenGLTrueTypeFont/opengl_fontstashcallbacks.h",
|
||||
"../../src/Bullet3Geometry/b3ConvexHullComputer.cpp",
|
||||
"../../src/Bullet3Geometry/b3ConvexHullComputer.h",
|
||||
"../../src/Bullet3Common/b3AlignedAllocator.cpp",
|
||||
"../Timing/b3Quickprof.cpp",
|
||||
"../Timing/b3Quickprof.h",
|
||||
"../Timing/b3Clock.cpp",
|
||||
"../Timing/b3Clock.h",
|
||||
"**.cpp",
|
||||
"**.h",
|
||||
"**.c"
|
||||
}
|
||||
|
||||
if os.is("Windows") then
|
||||
files{
|
||||
if not os.is("Windows") then
|
||||
excludes {
|
||||
"Win32OpenGLWindow.cpp",
|
||||
"Win32OpenGLWindow.h",
|
||||
"Win32Window.cpp",
|
||||
"Win32Window.h",
|
||||
}
|
||||
end
|
||||
if os.is("Linux") then
|
||||
files {
|
||||
if not os.is("Linux") then
|
||||
excludes {
|
||||
"X11OpenGLWindow.cpp",
|
||||
"X11OpenGLWindows.h"
|
||||
}
|
||||
end
|
||||
if os.is("MacOSX") then
|
||||
links{"Cocoa.framework"}
|
||||
files
|
||||
else
|
||||
excludes
|
||||
{
|
||||
"../OpenGLWindow/MacOpenGLWindow.h",
|
||||
"../OpenGLWindow/MacOpenGLWindow.mm",
|
||||
}
|
||||
"../OpenGLWindow/MacOpenGLWindow.h",
|
||||
"../OpenGLWindow/MacOpenGLWindow.mm",
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -1,199 +0,0 @@
|
||||
int NUM_OBJECTS_X = 35;
|
||||
int NUM_OBJECTS_Y = 35;
|
||||
int NUM_OBJECTS_Z = 35;
|
||||
|
||||
|
||||
float X_GAP = 2.3f;
|
||||
float Y_GAP = 2.f;
|
||||
float Z_GAP = 2.3f;
|
||||
|
||||
bool keepStaticObjects = false;
|
||||
#include <stdio.h>
|
||||
|
||||
#include "OpenGLInclude.h"
|
||||
|
||||
#include "renderscene.h"
|
||||
|
||||
#include "GLInstancingRenderer.h"
|
||||
//#include "LinearMath/b3Quickprof.h"
|
||||
#include "Bullet3Common/b3Quaternion.h"
|
||||
#include "Bullet3Common/b3Matrix3x3.h"
|
||||
//#include "../opencl/gpu_rigidbody_pipeline/b3ConvexUtility.h"
|
||||
#include "ShapeData.h"
|
||||
///work-in-progress
|
||||
///This ReadBulletSample is kept as simple as possible without dependencies to the Bullet SDK.
|
||||
///It can be used to load .bullet data for other physics SDKs
|
||||
///For a more complete example how to load and convert Bullet data using the Bullet SDK check out
|
||||
///the Bullet/Demos/SerializeDemo and Bullet/Serialize/BulletWorldImporter
|
||||
|
||||
|
||||
//using namespace Bullet;
|
||||
|
||||
struct GraphicsVertex
|
||||
{
|
||||
float xyzw[4];
|
||||
float normal[3];
|
||||
float uv[2];
|
||||
};
|
||||
struct GraphicsShape
|
||||
{
|
||||
const float* m_vertices;
|
||||
int m_numvertices;
|
||||
const int* m_indices;
|
||||
int m_numIndices;
|
||||
float m_scaling[4];
|
||||
};
|
||||
|
||||
struct InstanceGroup
|
||||
{
|
||||
// Bullet::b3CollisionShapeData* m_shape;
|
||||
int m_collisionShapeIndex;
|
||||
|
||||
// b3AlignedObjectArray<bParse::bStructHandle*> m_rigidBodies;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#define MY_UNITSPHERE_POINTS 42
|
||||
|
||||
static b3Vector3 sUnitSpherePoints[MY_UNITSPHERE_POINTS] =
|
||||
{
|
||||
b3Vector3(b3Scalar(0.000000) , b3Scalar(-0.000000),b3Scalar(-1.000000)),
|
||||
b3Vector3(b3Scalar(0.723608) , b3Scalar(-0.525725),b3Scalar(-0.447219)),
|
||||
b3Vector3(b3Scalar(-0.276388) , b3Scalar(-0.850649),b3Scalar(-0.447219)),
|
||||
b3Vector3(b3Scalar(-0.894426) , b3Scalar(-0.000000),b3Scalar(-0.447216)),
|
||||
b3Vector3(b3Scalar(-0.276388) , b3Scalar(0.850649),b3Scalar(-0.447220)),
|
||||
b3Vector3(b3Scalar(0.723608) , b3Scalar(0.525725),b3Scalar(-0.447219)),
|
||||
b3Vector3(b3Scalar(0.276388) , b3Scalar(-0.850649),b3Scalar(0.447220)),
|
||||
b3Vector3(b3Scalar(-0.723608) , b3Scalar(-0.525725),b3Scalar(0.447219)),
|
||||
b3Vector3(b3Scalar(-0.723608) , b3Scalar(0.525725),b3Scalar(0.447219)),
|
||||
b3Vector3(b3Scalar(0.276388) , b3Scalar(0.850649),b3Scalar(0.447219)),
|
||||
b3Vector3(b3Scalar(0.894426) , b3Scalar(0.000000),b3Scalar(0.447216)),
|
||||
b3Vector3(b3Scalar(-0.000000) , b3Scalar(0.000000),b3Scalar(1.000000)),
|
||||
b3Vector3(b3Scalar(0.425323) , b3Scalar(-0.309011),b3Scalar(-0.850654)),
|
||||
b3Vector3(b3Scalar(-0.162456) , b3Scalar(-0.499995),b3Scalar(-0.850654)),
|
||||
b3Vector3(b3Scalar(0.262869) , b3Scalar(-0.809012),b3Scalar(-0.525738)),
|
||||
b3Vector3(b3Scalar(0.425323) , b3Scalar(0.309011),b3Scalar(-0.850654)),
|
||||
b3Vector3(b3Scalar(0.850648) , b3Scalar(-0.000000),b3Scalar(-0.525736)),
|
||||
b3Vector3(b3Scalar(-0.525730) , b3Scalar(-0.000000),b3Scalar(-0.850652)),
|
||||
b3Vector3(b3Scalar(-0.688190) , b3Scalar(-0.499997),b3Scalar(-0.525736)),
|
||||
b3Vector3(b3Scalar(-0.162456) , b3Scalar(0.499995),b3Scalar(-0.850654)),
|
||||
b3Vector3(b3Scalar(-0.688190) , b3Scalar(0.499997),b3Scalar(-0.525736)),
|
||||
b3Vector3(b3Scalar(0.262869) , b3Scalar(0.809012),b3Scalar(-0.525738)),
|
||||
b3Vector3(b3Scalar(0.951058) , b3Scalar(0.309013),b3Scalar(0.000000)),
|
||||
b3Vector3(b3Scalar(0.951058) , b3Scalar(-0.309013),b3Scalar(0.000000)),
|
||||
b3Vector3(b3Scalar(0.587786) , b3Scalar(-0.809017),b3Scalar(0.000000)),
|
||||
b3Vector3(b3Scalar(0.000000) , b3Scalar(-1.000000),b3Scalar(0.000000)),
|
||||
b3Vector3(b3Scalar(-0.587786) , b3Scalar(-0.809017),b3Scalar(0.000000)),
|
||||
b3Vector3(b3Scalar(-0.951058) , b3Scalar(-0.309013),b3Scalar(-0.000000)),
|
||||
b3Vector3(b3Scalar(-0.951058) , b3Scalar(0.309013),b3Scalar(-0.000000)),
|
||||
b3Vector3(b3Scalar(-0.587786) , b3Scalar(0.809017),b3Scalar(-0.000000)),
|
||||
b3Vector3(b3Scalar(-0.000000) , b3Scalar(1.000000),b3Scalar(-0.000000)),
|
||||
b3Vector3(b3Scalar(0.587786) , b3Scalar(0.809017),b3Scalar(-0.000000)),
|
||||
b3Vector3(b3Scalar(0.688190) , b3Scalar(-0.499997),b3Scalar(0.525736)),
|
||||
b3Vector3(b3Scalar(-0.262869) , b3Scalar(-0.809012),b3Scalar(0.525738)),
|
||||
b3Vector3(b3Scalar(-0.850648) , b3Scalar(0.000000),b3Scalar(0.525736)),
|
||||
b3Vector3(b3Scalar(-0.262869) , b3Scalar(0.809012),b3Scalar(0.525738)),
|
||||
b3Vector3(b3Scalar(0.688190) , b3Scalar(0.499997),b3Scalar(0.525736)),
|
||||
b3Vector3(b3Scalar(0.525730) , b3Scalar(0.000000),b3Scalar(0.850652)),
|
||||
b3Vector3(b3Scalar(0.162456) , b3Scalar(-0.499995),b3Scalar(0.850654)),
|
||||
b3Vector3(b3Scalar(-0.425323) , b3Scalar(-0.309011),b3Scalar(0.850654)),
|
||||
b3Vector3(b3Scalar(-0.425323) , b3Scalar(0.309011),b3Scalar(0.850654)),
|
||||
b3Vector3(b3Scalar(0.162456) , b3Scalar(0.499995),b3Scalar(0.850654))
|
||||
};
|
||||
|
||||
|
||||
void createSceneProgrammatically(GLInstancingRenderer& renderer)
|
||||
{
|
||||
int strideInBytes = sizeof(float)*9;
|
||||
|
||||
bool noHeightField = false;
|
||||
int barrelShapeIndex = -1;
|
||||
int cubeShapeIndex = -1;
|
||||
int tetraShapeIndex = -1;
|
||||
|
||||
float position[4]={0,0,0,0};
|
||||
b3Quaternion born(b3Vector3(1,0,0),B3_PI*0.25*0.5);
|
||||
|
||||
float orn[4] = {0,0,0,1};
|
||||
// float rotOrn[4] = {born.getX(),born.getY(),born.getZ(),born.getW()};//
|
||||
float rotOrn[4] ={0,0,0,1};
|
||||
|
||||
|
||||
float color[4] = {1,1,1,1};
|
||||
int index=0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
float cubeScaling[4] = {1,1,1,1};
|
||||
{
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
cubeShapeIndex = renderer.registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (1)
|
||||
for (int i=0;i<NUM_OBJECTS_X;i++)
|
||||
{
|
||||
for (int j=0;j<NUM_OBJECTS_Y;j++)
|
||||
{
|
||||
int k=0;
|
||||
|
||||
for (;k<NUM_OBJECTS_Z;k++)
|
||||
{
|
||||
|
||||
float mass = 1.f;//j? 1.f : 0.f;
|
||||
|
||||
position[0]=(i*X_GAP-NUM_OBJECTS_X/2)+(j&1);
|
||||
position[1]=1+(j*Y_GAP);//-NUM_OBJECTS_Y/2);
|
||||
position[2]=(k*Z_GAP-NUM_OBJECTS_Z/2)+(j&1);
|
||||
position[3] = 0.f;
|
||||
|
||||
renderer.registerGraphicsInstance(cubeShapeIndex,position,rotOrn,color,cubeScaling);
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
|
||||
{
|
||||
int numVertices = sizeof(tetra_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(tetra_indices)/sizeof(int);
|
||||
tetraShapeIndex = renderer.registerShape(&tetra_vertices[0],numVertices,tetra_indices,numIndices);
|
||||
}
|
||||
|
||||
{
|
||||
float groundScaling[4] = {2.5,2,2.5,1};
|
||||
|
||||
for (int i=0;i<50;i++)
|
||||
for (int j=0;j<50;j++)
|
||||
if (1)
|
||||
{
|
||||
void* ptr = (void*) index;
|
||||
float posnew[4];
|
||||
posnew[0] = i*5.0-120;
|
||||
posnew[1] = 0;
|
||||
posnew[2] = j*5.0-120;
|
||||
posnew[3] = 1.f;
|
||||
|
||||
color[0] = 1.f;
|
||||
color[1] = 0.f;
|
||||
color[2] = 0.f;
|
||||
renderer.registerGraphicsInstance(tetraShapeIndex,posnew,orn,color,groundScaling);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
|
||||
#ifndef RENDER_SCENE_H
|
||||
#define RENDER_SCENE_H
|
||||
|
||||
void createSceneProgrammatically(class GLInstancingRenderer& renderer);
|
||||
|
||||
#endif//
|
||||
Reference in New Issue
Block a user