Merge branch 'master' of https://github.com/erwincoumans/bullet3
This commit is contained in:
@@ -238,6 +238,9 @@ end
|
|||||||
targetdir( _OPTIONS["targetdir"] or "../bin" )
|
targetdir( _OPTIONS["targetdir"] or "../bin" )
|
||||||
location("./" .. act .. postfix)
|
location("./" .. act .. postfix)
|
||||||
|
|
||||||
|
projectRootDir = os.getcwd() .. "/../"
|
||||||
|
print("Project root directory: " .. projectRootDir);
|
||||||
|
|
||||||
if not _OPTIONS["python_include_dir"] then
|
if not _OPTIONS["python_include_dir"] then
|
||||||
_OPTIONS["python_include_dir"] = default_python_include_dir
|
_OPTIONS["python_include_dir"] = default_python_include_dir
|
||||||
end
|
end
|
||||||
@@ -245,22 +248,109 @@ end
|
|||||||
if not _OPTIONS["python_lib_dir"] then
|
if not _OPTIONS["python_lib_dir"] then
|
||||||
_OPTIONS["python_lib_dir"] = default_python_lib_dir
|
_OPTIONS["python_lib_dir"] = default_python_lib_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
projectRootDir = os.getcwd() .. "/../"
|
if os.is("Linux") then
|
||||||
print("Project root directory: " .. projectRootDir);
|
default_glfw_include_dir = "usr/local/include/GLFW"
|
||||||
|
default_glfw_lib_dir = "/usr/local/lib/"
|
||||||
|
default_glfw_lib_name = "glfw3"
|
||||||
|
end
|
||||||
|
|
||||||
|
if os.is("macosx") then
|
||||||
|
default_glfw_include_dir = "/usr/local/Cellar/glfw/3.2.1/include"
|
||||||
|
default_glfw_lib_dir = "/usr/local/Cellar/glfw/3.2.1/lib"
|
||||||
|
default_glfw_lib_name = "glfw"
|
||||||
|
end
|
||||||
|
|
||||||
|
if os.is("Windows") then
|
||||||
|
default_glfw_include_dir = "c:/glfw/include"
|
||||||
|
default_glfw_lib_dir = "c:/glfw/lib"
|
||||||
|
default_glfw_lib_name = "glfw3"
|
||||||
|
end
|
||||||
|
|
||||||
|
if not _OPTIONS["glfw_lib_dir"] then
|
||||||
|
_OPTIONS["glfw_lib_dir"] = default_glfw_lib_dir
|
||||||
|
end
|
||||||
|
if not _OPTIONS["glfw_include_dir"] then
|
||||||
|
_OPTIONS["glfw_include_dir"] = default_glfw_include_dir
|
||||||
|
end
|
||||||
|
if not _OPTIONS["glfw_lib_name"] then
|
||||||
|
_OPTIONS["glfw_lib_name"] = default_glfw_lib_name
|
||||||
|
end
|
||||||
|
newoption
|
||||||
|
{
|
||||||
|
trigger = "glfw_include_dir",
|
||||||
|
value = default_glfw_include_dir,
|
||||||
|
description = "GLFW 3.x include directory"
|
||||||
|
}
|
||||||
|
|
||||||
|
newoption
|
||||||
|
{
|
||||||
|
trigger = "glfw_lib_name",
|
||||||
|
value = default_glfw_lib_name,
|
||||||
|
description = "GLFW 3.x library name (glfw, glfw3)"
|
||||||
|
}
|
||||||
|
|
||||||
|
newoption
|
||||||
|
{
|
||||||
|
trigger = "glfw_lib_dir",
|
||||||
|
value = default_glfw_lib_dir,
|
||||||
|
description = "(optional) GLFW 3.x library directory "
|
||||||
|
}
|
||||||
|
|
||||||
|
newoption
|
||||||
|
{
|
||||||
|
trigger = "enable_glfw",
|
||||||
|
value = false,
|
||||||
|
description = "(optional) use GLFW 3.x library"
|
||||||
|
}
|
||||||
|
|
||||||
|
if _OPTIONS["enable_glfw"] then
|
||||||
|
defines {"B3_USE_GLFW"}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function initOpenGL()
|
||||||
|
includedirs {
|
||||||
|
projectRootDir .. "examples/ThirdPartyLibs/glad"
|
||||||
|
}
|
||||||
|
|
||||||
|
includedirs {
|
||||||
|
_OPTIONS["glfw_include_dir"],
|
||||||
|
}
|
||||||
|
|
||||||
|
libdirs {
|
||||||
|
_OPTIONS["glfw_lib_dir"]
|
||||||
|
}
|
||||||
|
links { _OPTIONS["glfw_lib_name"]}
|
||||||
|
files { projectRootDir .. "examples/ThirdPartyLibs/glad/glad.c" }
|
||||||
|
end
|
||||||
|
function findOpenGL3()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
function initGlew()
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
dofile ("findOpenGLGlewGlut.lua")
|
||||||
|
if (not findOpenGL3()) then
|
||||||
|
defines {"NO_OPENGL3"}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dofile ("findOpenCL.lua")
|
dofile ("findOpenCL.lua")
|
||||||
dofile ("findDirectX11.lua")
|
dofile ("findDirectX11.lua")
|
||||||
dofile ("findOpenGLGlewGlut.lua")
|
|
||||||
|
|
||||||
if (not findOpenGL3()) then
|
|
||||||
defines {"NO_OPENGL3"}
|
|
||||||
end
|
|
||||||
|
|
||||||
language "C++"
|
language "C++"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if _OPTIONS["audio"] then
|
if _OPTIONS["audio"] then
|
||||||
include "../examples/TinyAudio"
|
include "../examples/TinyAudio"
|
||||||
end
|
end
|
||||||
|
|||||||
Binary file not shown.
@@ -909,7 +909,7 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
|||||||
|
|
||||||
#ifndef NO_OPENGL3
|
#ifndef NO_OPENGL3
|
||||||
SimpleOpenGL3App* simpleApp=0;
|
SimpleOpenGL3App* simpleApp=0;
|
||||||
sUseOpenGL2 =args.CheckCmdLineFlag("opengl2");
|
sUseOpenGL2 = args.CheckCmdLineFlag("opengl2");
|
||||||
#else
|
#else
|
||||||
sUseOpenGL2 = true;
|
sUseOpenGL2 = true;
|
||||||
#endif
|
#endif
|
||||||
@@ -920,10 +920,16 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
|||||||
const char* optMode = "Release build";
|
const char* optMode = "Release build";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
const char* glContext = "[glfw]";
|
||||||
|
#else
|
||||||
|
const char* glContext = "[btgl]";
|
||||||
|
#endif
|
||||||
|
|
||||||
if (sUseOpenGL2 )
|
if (sUseOpenGL2 )
|
||||||
{
|
{
|
||||||
char title[1024];
|
char title[1024];
|
||||||
sprintf(title,"%s using limited OpenGL2 fallback. %s", appTitle,optMode);
|
sprintf(title,"%s using limited OpenGL2 fallback %s %s", appTitle,glContext, optMode);
|
||||||
s_app = new SimpleOpenGL2App(title,width,height);
|
s_app = new SimpleOpenGL2App(title,width,height);
|
||||||
s_app->m_renderer = new SimpleOpenGL2Renderer(width,height);
|
s_app->m_renderer = new SimpleOpenGL2Renderer(width,height);
|
||||||
}
|
}
|
||||||
@@ -932,7 +938,7 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
char title[1024];
|
char title[1024];
|
||||||
sprintf(title,"%s using OpenGL3+. %s", appTitle,optMode);
|
sprintf(title,"%s using OpenGL3+ %s %s", appTitle,glContext, optMode);
|
||||||
simpleApp = new SimpleOpenGL3App(title,width,height, gAllowRetina);
|
simpleApp = new SimpleOpenGL3App(title,width,height, gAllowRetina);
|
||||||
s_app = simpleApp;
|
s_app = simpleApp;
|
||||||
}
|
}
|
||||||
@@ -1001,7 +1007,7 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
|||||||
|
|
||||||
if (sUseOpenGL2)
|
if (sUseOpenGL2)
|
||||||
{
|
{
|
||||||
m_internalData->m_gwenRenderer = new Gwen::Renderer::OpenGL_DebugFont();
|
m_internalData->m_gwenRenderer = new Gwen::Renderer::OpenGL_DebugFont(s_window->getRetinaScale());
|
||||||
}
|
}
|
||||||
#ifndef NO_OPENGL3
|
#ifndef NO_OPENGL3
|
||||||
else
|
else
|
||||||
@@ -1341,7 +1347,7 @@ void OpenGLExampleBrowser::update(float deltaTime)
|
|||||||
if (sUseOpenGL2)
|
if (sUseOpenGL2)
|
||||||
{
|
{
|
||||||
|
|
||||||
saveOpenGLState(s_instancingRenderer->getScreenWidth(), s_instancingRenderer->getScreenHeight());
|
saveOpenGLState(s_instancingRenderer->getScreenWidth()*s_window->getRetinaScale(), s_instancingRenderer->getScreenHeight()*s_window->getRetinaScale());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_internalData->m_gui)
|
if (m_internalData->m_gui)
|
||||||
|
|||||||
499
examples/OpenGLWindow/GLFWOpenGLWindow.cpp
Normal file
499
examples/OpenGLWindow/GLFWOpenGLWindow.cpp
Normal file
@@ -0,0 +1,499 @@
|
|||||||
|
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
#include "GLFWOpenGLWindow.h"
|
||||||
|
|
||||||
|
#include <glad/glad.h>
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "LinearMath/btScalar.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct GLFWOpenGLWindowInternalData
|
||||||
|
{
|
||||||
|
bool m_requestedExit;
|
||||||
|
bool m_hasCursorPos;
|
||||||
|
bool m_altPressed;
|
||||||
|
bool m_shiftPressed;
|
||||||
|
bool m_ctrlPressed;
|
||||||
|
float m_cursorXPos;
|
||||||
|
float m_cursorYPos;
|
||||||
|
b3MouseMoveCallback m_mouseMoveCallback;
|
||||||
|
b3MouseButtonCallback m_mouseButtonCallback;
|
||||||
|
b3ResizeCallback m_resizeCallback;
|
||||||
|
b3WheelCallback m_wheelCallback;
|
||||||
|
b3KeyboardCallback m_keyboardCallback;
|
||||||
|
b3RenderCallback m_renderCallback;
|
||||||
|
int m_width;
|
||||||
|
int m_height;
|
||||||
|
float m_retinaScaleFactor;
|
||||||
|
|
||||||
|
GLFWwindow* m_glfwWindow;
|
||||||
|
|
||||||
|
GLFWOpenGLWindowInternalData()
|
||||||
|
:m_requestedExit(false),
|
||||||
|
m_hasCursorPos(false),
|
||||||
|
m_altPressed(false),
|
||||||
|
m_shiftPressed(false),
|
||||||
|
m_ctrlPressed(false),
|
||||||
|
m_cursorXPos(0),
|
||||||
|
m_cursorYPos(0),
|
||||||
|
m_mouseMoveCallback(0),
|
||||||
|
m_mouseButtonCallback(0),
|
||||||
|
m_resizeCallback(0),
|
||||||
|
m_wheelCallback(0),
|
||||||
|
m_keyboardCallback(0),
|
||||||
|
m_renderCallback(0),
|
||||||
|
m_width(0),
|
||||||
|
m_height(0),
|
||||||
|
m_retinaScaleFactor(1),
|
||||||
|
m_glfwWindow(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void GLFWErrorCallback(int error, const char* description)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error: %s\n", description);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void GLFWMouseButtonCallback(GLFWwindow* window,int button,int glfwState,int)
|
||||||
|
{
|
||||||
|
GLFWOpenGLWindow* wnd = (GLFWOpenGLWindow*) glfwGetWindowUserPointer(window);
|
||||||
|
if (wnd && wnd->getMouseButtonCallback())
|
||||||
|
{
|
||||||
|
int state = (glfwState == GLFW_PRESS)? 1 : 0;
|
||||||
|
wnd->mouseButtonCallbackInternal(button, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void GLFWScrollCallback(GLFWwindow* window, double deltaX,double deltaY)
|
||||||
|
{
|
||||||
|
GLFWOpenGLWindow* wnd = (GLFWOpenGLWindow*) glfwGetWindowUserPointer(window);
|
||||||
|
if (wnd && wnd->getWheelCallback())
|
||||||
|
{
|
||||||
|
wnd->getWheelCallback()(deltaX*100,deltaY*100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void GLFWCursorPosCallback(GLFWwindow* window,double xPos,double yPos)
|
||||||
|
{
|
||||||
|
GLFWOpenGLWindow* wnd = (GLFWOpenGLWindow*) glfwGetWindowUserPointer(window);
|
||||||
|
if (wnd && wnd->getMouseMoveCallback())
|
||||||
|
{
|
||||||
|
wnd->mouseCursorCallbackInternal(xPos,yPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void GLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
|
{
|
||||||
|
GLFWOpenGLWindow* wnd = (GLFWOpenGLWindow*) glfwGetWindowUserPointer(window);
|
||||||
|
if (wnd)
|
||||||
|
{
|
||||||
|
wnd->keyboardCallbackInternal(key,action);
|
||||||
|
}
|
||||||
|
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
|
||||||
|
{
|
||||||
|
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void GLFWSizeCallback(GLFWwindow* window,int width,int height)
|
||||||
|
{
|
||||||
|
GLFWOpenGLWindow* wnd = (GLFWOpenGLWindow*) glfwGetWindowUserPointer(window);
|
||||||
|
{
|
||||||
|
wnd->resizeInternal(width,height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GLFWOpenGLWindow::GLFWOpenGLWindow()
|
||||||
|
{
|
||||||
|
m_data = new GLFWOpenGLWindowInternalData();
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWOpenGLWindow::~GLFWOpenGLWindow()
|
||||||
|
{
|
||||||
|
if (m_data->m_glfwWindow)
|
||||||
|
{
|
||||||
|
closeWindow();
|
||||||
|
}
|
||||||
|
delete m_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int getBulletKeyFromGLFWKeycode(int glfwKeyCode)
|
||||||
|
{
|
||||||
|
int keycode = -1;
|
||||||
|
if (glfwKeyCode >= 'A' && glfwKeyCode <= 'Z')
|
||||||
|
{
|
||||||
|
return glfwKeyCode+32;//todo: fix the ascii A vs a input
|
||||||
|
}
|
||||||
|
if (glfwKeyCode >= '0' && glfwKeyCode <= '9')
|
||||||
|
{
|
||||||
|
return glfwKeyCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (glfwKeyCode)
|
||||||
|
{
|
||||||
|
case GLFW_KEY_ENTER: {keycode = B3G_RETURN; break; };
|
||||||
|
case GLFW_KEY_ESCAPE: {keycode = B3G_ESCAPE; break; };
|
||||||
|
case GLFW_KEY_F1: {keycode = B3G_F1; break;}
|
||||||
|
case GLFW_KEY_F2: {keycode = B3G_F2; break;}
|
||||||
|
case GLFW_KEY_F3: {keycode = B3G_F3; break;}
|
||||||
|
case GLFW_KEY_F4: {keycode = B3G_F4; break;}
|
||||||
|
case GLFW_KEY_F5: {keycode = B3G_F5; break;}
|
||||||
|
case GLFW_KEY_F6: {keycode = B3G_F6; break;}
|
||||||
|
case GLFW_KEY_F7: {keycode = B3G_F7; break;}
|
||||||
|
case GLFW_KEY_F8: {keycode = B3G_F8; break;}
|
||||||
|
case GLFW_KEY_F9: {keycode = B3G_F9; break;}
|
||||||
|
case GLFW_KEY_F10: {keycode= B3G_F10; break;}
|
||||||
|
|
||||||
|
//case GLFW_KEY_SPACE: {keycode= ' '; break;}
|
||||||
|
|
||||||
|
case GLFW_KEY_PAGE_DOWN: {keycode= B3G_PAGE_DOWN; break;}
|
||||||
|
case GLFW_KEY_PAGE_UP: {keycode= B3G_PAGE_UP; break;}
|
||||||
|
|
||||||
|
case GLFW_KEY_INSERT: {keycode= B3G_INSERT; break;}
|
||||||
|
case GLFW_KEY_BACKSPACE: {keycode= B3G_BACKSPACE; break;}
|
||||||
|
case GLFW_KEY_DELETE: {keycode= B3G_DELETE; break;}
|
||||||
|
|
||||||
|
case GLFW_KEY_END:{keycode= B3G_END; break;}
|
||||||
|
case GLFW_KEY_HOME:{keycode= B3G_HOME; break;}
|
||||||
|
case GLFW_KEY_LEFT:{keycode= B3G_LEFT_ARROW; break;}
|
||||||
|
case GLFW_KEY_UP:{keycode= B3G_UP_ARROW; break;}
|
||||||
|
case GLFW_KEY_RIGHT:{keycode= B3G_RIGHT_ARROW; break;}
|
||||||
|
case GLFW_KEY_DOWN:{keycode= B3G_DOWN_ARROW; break;}
|
||||||
|
case GLFW_KEY_RIGHT_SHIFT:{keycode=B3G_SHIFT;break;}
|
||||||
|
case GLFW_KEY_LEFT_SHIFT:{keycode=B3G_SHIFT;break;}
|
||||||
|
case GLFW_KEY_MENU:{keycode=B3G_ALT;break;}
|
||||||
|
case GLFW_KEY_RIGHT_CONTROL:{keycode=B3G_CONTROL;break;}
|
||||||
|
case GLFW_KEY_LEFT_CONTROL:{keycode=B3G_CONTROL;break;}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
//keycode = MapVirtualKey( virtualKeyCode, MAPGLFW_KEY_GLFW_KEY_TO_CHAR ) & 0x0000FFFF;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return keycode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLFWOpenGLWindow::keyboardCallbackInternal(int key, int state)
|
||||||
|
{
|
||||||
|
if (getKeyboardCallback())
|
||||||
|
{
|
||||||
|
//convert keyboard codes from glfw to bullet
|
||||||
|
int btcode = getBulletKeyFromGLFWKeycode(key);
|
||||||
|
int btstate = (state == GLFW_RELEASE)? 0 : 1;
|
||||||
|
|
||||||
|
switch (btcode)
|
||||||
|
{
|
||||||
|
case B3G_SHIFT:
|
||||||
|
{
|
||||||
|
m_data->m_shiftPressed = state!=0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B3G_ALT:
|
||||||
|
{
|
||||||
|
m_data->m_altPressed = state!=0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B3G_CONTROL:
|
||||||
|
{
|
||||||
|
m_data->m_ctrlPressed = state!=0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getKeyboardCallback()(btcode,btstate);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLFWOpenGLWindow::mouseButtonCallbackInternal(int button, int state)
|
||||||
|
{
|
||||||
|
if (getMouseButtonCallback() && m_data->m_hasCursorPos)
|
||||||
|
{
|
||||||
|
getMouseButtonCallback()(button,state,m_data->m_cursorXPos,m_data->m_cursorYPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLFWOpenGLWindow::mouseCursorCallbackInternal(double xPos, double yPos)
|
||||||
|
{
|
||||||
|
if (getMouseMoveCallback())
|
||||||
|
{
|
||||||
|
m_data->m_hasCursorPos = true;
|
||||||
|
m_data->m_cursorXPos = xPos;
|
||||||
|
m_data->m_cursorYPos = yPos;
|
||||||
|
getMouseMoveCallback()(xPos,yPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLFWOpenGLWindow::resizeInternal(int width,int height)
|
||||||
|
{
|
||||||
|
|
||||||
|
glfwGetFramebufferSize(m_data->m_glfwWindow, &m_data->m_width, &m_data->m_height);
|
||||||
|
glViewport (0,0,m_data->m_width,m_data->m_height);
|
||||||
|
|
||||||
|
if (getResizeCallback())
|
||||||
|
{
|
||||||
|
getResizeCallback()(m_data->m_width/m_data->m_retinaScaleFactor,m_data->m_height / m_data->m_retinaScaleFactor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLFWOpenGLWindow::createDefaultWindow(int width, int height, const char* title)
|
||||||
|
{
|
||||||
|
b3gWindowConstructionInfo ci;
|
||||||
|
ci.m_width = width;
|
||||||
|
ci.m_height = height;
|
||||||
|
ci.m_title = title;
|
||||||
|
|
||||||
|
createWindow(ci);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLFWOpenGLWindow::createWindow(const b3gWindowConstructionInfo& ci)
|
||||||
|
{
|
||||||
|
|
||||||
|
btAssert(m_data->m_glfwWindow==0);
|
||||||
|
if (m_data->m_glfwWindow==0)
|
||||||
|
{
|
||||||
|
glfwSetErrorCallback(GLFWErrorCallback);
|
||||||
|
|
||||||
|
if (!glfwInit())
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
|
if (ci.m_openglVersion==2)
|
||||||
|
{
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||||
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
m_data->m_glfwWindow = glfwCreateWindow(ci.m_width, ci.m_height, ci.m_title, NULL, NULL);
|
||||||
|
|
||||||
|
if (!m_data->m_glfwWindow)
|
||||||
|
{
|
||||||
|
glfwTerminate();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwSetKeyCallback(m_data->m_glfwWindow,GLFWKeyCallback);
|
||||||
|
glfwSetMouseButtonCallback(m_data->m_glfwWindow,GLFWMouseButtonCallback);
|
||||||
|
|
||||||
|
glfwSetCursorPosCallback(m_data->m_glfwWindow,GLFWCursorPosCallback);
|
||||||
|
glfwSetScrollCallback(m_data->m_glfwWindow, GLFWScrollCallback);
|
||||||
|
|
||||||
|
|
||||||
|
glfwSetWindowSizeCallback(m_data->m_glfwWindow, GLFWSizeCallback);
|
||||||
|
glfwSetWindowUserPointer(m_data->m_glfwWindow,this);
|
||||||
|
|
||||||
|
glfwMakeContextCurrent(m_data->m_glfwWindow);
|
||||||
|
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
|
||||||
|
glfwSwapInterval(0);//1);
|
||||||
|
glfwGetFramebufferSize(m_data->m_glfwWindow, &m_data->m_width, &m_data->m_height);
|
||||||
|
int windowWidth, windowHeight;
|
||||||
|
glfwGetWindowSize(m_data->m_glfwWindow, &windowWidth, &windowHeight);
|
||||||
|
m_data->m_retinaScaleFactor = float(m_data->m_width)/float(windowWidth);
|
||||||
|
glViewport(0,0,m_data->m_width, m_data->m_height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLFWOpenGLWindow::closeWindow()
|
||||||
|
{
|
||||||
|
if (m_data->m_glfwWindow)
|
||||||
|
{
|
||||||
|
glfwDestroyWindow(m_data->m_glfwWindow);
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
|
m_data->m_glfwWindow = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLFWOpenGLWindow::runMainLoop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
float GLFWOpenGLWindow::getTimeInSeconds()
|
||||||
|
{
|
||||||
|
return 0.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GLFWOpenGLWindow::requestedExit() const
|
||||||
|
{
|
||||||
|
bool shouldClose = m_data->m_requestedExit;
|
||||||
|
|
||||||
|
if (m_data->m_glfwWindow)
|
||||||
|
{
|
||||||
|
shouldClose = shouldClose || glfwWindowShouldClose(m_data->m_glfwWindow);
|
||||||
|
}
|
||||||
|
return shouldClose;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLFWOpenGLWindow::setRequestExit()
|
||||||
|
{
|
||||||
|
if (m_data->m_glfwWindow)
|
||||||
|
{
|
||||||
|
glfwSetWindowShouldClose(m_data->m_glfwWindow, GLFW_TRUE);
|
||||||
|
}
|
||||||
|
m_data->m_requestedExit = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLFWOpenGLWindow::startRendering()
|
||||||
|
{
|
||||||
|
if (m_data->m_glfwWindow)
|
||||||
|
{
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLFWOpenGLWindow::endRendering()
|
||||||
|
{
|
||||||
|
glfwPollEvents();
|
||||||
|
glfwSwapBuffers(m_data->m_glfwWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GLFWOpenGLWindow::isModifierKeyPressed(int key)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case B3G_SHIFT:
|
||||||
|
{
|
||||||
|
result = m_data->m_shiftPressed;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B3G_ALT:
|
||||||
|
{
|
||||||
|
result = m_data->m_altPressed;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B3G_CONTROL:
|
||||||
|
{
|
||||||
|
result = m_data->m_ctrlPressed;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLFWOpenGLWindow::setMouseMoveCallback(b3MouseMoveCallback mouseCallback)
|
||||||
|
{
|
||||||
|
m_data->m_mouseMoveCallback = mouseCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
b3MouseMoveCallback GLFWOpenGLWindow::getMouseMoveCallback()
|
||||||
|
{
|
||||||
|
return m_data->m_mouseMoveCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLFWOpenGLWindow::setMouseButtonCallback(b3MouseButtonCallback mouseCallback)
|
||||||
|
{
|
||||||
|
m_data->m_mouseButtonCallback = mouseCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
b3MouseButtonCallback GLFWOpenGLWindow::getMouseButtonCallback()
|
||||||
|
{
|
||||||
|
return m_data->m_mouseButtonCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLFWOpenGLWindow::setResizeCallback(b3ResizeCallback resizeCallback)
|
||||||
|
{
|
||||||
|
m_data->m_resizeCallback = resizeCallback;
|
||||||
|
getResizeCallback()(m_data->m_width/getRetinaScale(),m_data->m_height/getRetinaScale());
|
||||||
|
}
|
||||||
|
|
||||||
|
b3ResizeCallback GLFWOpenGLWindow::getResizeCallback()
|
||||||
|
{
|
||||||
|
return m_data->m_resizeCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLFWOpenGLWindow::setWheelCallback(b3WheelCallback wheelCallback)
|
||||||
|
{
|
||||||
|
m_data->m_wheelCallback = wheelCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
b3WheelCallback GLFWOpenGLWindow::getWheelCallback()
|
||||||
|
{
|
||||||
|
return m_data->m_wheelCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLFWOpenGLWindow::setKeyboardCallback( b3KeyboardCallback keyboardCallback)
|
||||||
|
{
|
||||||
|
m_data->m_keyboardCallback = keyboardCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
b3KeyboardCallback GLFWOpenGLWindow::getKeyboardCallback()
|
||||||
|
{
|
||||||
|
return m_data->m_keyboardCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLFWOpenGLWindow::setRenderCallback( b3RenderCallback renderCallback)
|
||||||
|
{
|
||||||
|
m_data->m_renderCallback = renderCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLFWOpenGLWindow::setWindowTitle(const char* title)
|
||||||
|
{
|
||||||
|
if (m_data->m_glfwWindow)
|
||||||
|
{
|
||||||
|
glfwSetWindowTitle(m_data->m_glfwWindow,title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float GLFWOpenGLWindow::getRetinaScale() const
|
||||||
|
{
|
||||||
|
return m_data->m_retinaScaleFactor;
|
||||||
|
}
|
||||||
|
void GLFWOpenGLWindow::setAllowRetina(bool allow)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int GLFWOpenGLWindow::getWidth() const
|
||||||
|
{
|
||||||
|
if (m_data->m_glfwWindow)
|
||||||
|
{
|
||||||
|
glfwGetFramebufferSize(m_data->m_glfwWindow, &m_data->m_width, &m_data->m_height);
|
||||||
|
}
|
||||||
|
int width = m_data->m_width/m_data->m_retinaScaleFactor;
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
int GLFWOpenGLWindow::getHeight() const
|
||||||
|
{
|
||||||
|
if (m_data->m_glfwWindow)
|
||||||
|
{
|
||||||
|
glfwGetFramebufferSize(m_data->m_glfwWindow, &m_data->m_width, &m_data->m_height);
|
||||||
|
}
|
||||||
|
return m_data->m_height/m_data->m_retinaScaleFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GLFWOpenGLWindow::fileOpenDialog(char* fileName, int maxFileNameLength)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //B3_USE_GLFW
|
||||||
78
examples/OpenGLWindow/GLFWOpenGLWindow.h
Normal file
78
examples/OpenGLWindow/GLFWOpenGLWindow.h
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
|
||||||
|
#ifndef GLFW_OPENGL_WINDOW_H
|
||||||
|
#define GLFW_OPENGL_WINDOW_H
|
||||||
|
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
|
||||||
|
#include "../CommonInterfaces/CommonWindowInterface.h"
|
||||||
|
|
||||||
|
#define b3gDefaultOpenGLWindow GLFWOpenGLWindow
|
||||||
|
|
||||||
|
|
||||||
|
class GLFWOpenGLWindow : public CommonWindowInterface
|
||||||
|
{
|
||||||
|
struct GLFWOpenGLWindowInternalData* m_data;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
GLFWOpenGLWindow();
|
||||||
|
|
||||||
|
virtual ~GLFWOpenGLWindow();
|
||||||
|
|
||||||
|
virtual void createDefaultWindow(int width, int height, const char* title);
|
||||||
|
|
||||||
|
virtual void createWindow(const b3gWindowConstructionInfo& ci);
|
||||||
|
|
||||||
|
virtual void closeWindow();
|
||||||
|
|
||||||
|
virtual void runMainLoop();
|
||||||
|
virtual float getTimeInSeconds();
|
||||||
|
|
||||||
|
virtual bool requestedExit() const;
|
||||||
|
virtual void setRequestExit();
|
||||||
|
|
||||||
|
virtual void startRendering();
|
||||||
|
|
||||||
|
virtual void endRendering();
|
||||||
|
|
||||||
|
virtual bool isModifierKeyPressed(int key);
|
||||||
|
|
||||||
|
virtual void setMouseMoveCallback(b3MouseMoveCallback mouseCallback);
|
||||||
|
virtual b3MouseMoveCallback getMouseMoveCallback();
|
||||||
|
|
||||||
|
virtual void setMouseButtonCallback(b3MouseButtonCallback mouseCallback);
|
||||||
|
virtual b3MouseButtonCallback getMouseButtonCallback();
|
||||||
|
|
||||||
|
virtual void setResizeCallback(b3ResizeCallback resizeCallback);
|
||||||
|
virtual b3ResizeCallback getResizeCallback();
|
||||||
|
|
||||||
|
virtual void setWheelCallback(b3WheelCallback wheelCallback);
|
||||||
|
virtual b3WheelCallback getWheelCallback();
|
||||||
|
|
||||||
|
virtual void setKeyboardCallback( b3KeyboardCallback keyboardCallback);
|
||||||
|
virtual b3KeyboardCallback getKeyboardCallback();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
virtual void setRenderCallback( b3RenderCallback renderCallback);
|
||||||
|
|
||||||
|
virtual void setWindowTitle(const char* title);
|
||||||
|
|
||||||
|
virtual float getRetinaScale() const;
|
||||||
|
virtual void setAllowRetina(bool allow);
|
||||||
|
|
||||||
|
virtual int getWidth() const;
|
||||||
|
virtual int getHeight() const;
|
||||||
|
|
||||||
|
virtual int fileOpenDialog(char* fileName, int maxFileNameLength);
|
||||||
|
|
||||||
|
void keyboardCallbackInternal(int key, int state);
|
||||||
|
void mouseButtonCallbackInternal(int button, int state);
|
||||||
|
void mouseCursorCallbackInternal(double xPos, double yPos);
|
||||||
|
void resizeInternal(int width,int height);
|
||||||
|
};
|
||||||
|
#endif//B3_USE_GLFW
|
||||||
|
#endif//GLFW_OPENGL_WINDOW_H
|
||||||
@@ -28,7 +28,9 @@ float shadowMapWorldSize=10;
|
|||||||
#include "OpenGLInclude.h"
|
#include "OpenGLInclude.h"
|
||||||
#include "../CommonInterfaces/CommonWindowInterface.h"
|
#include "../CommonInterfaces/CommonWindowInterface.h"
|
||||||
//#include "Bullet3Common/b3MinMax.h"
|
//#include "Bullet3Common/b3MinMax.h"
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
|
||||||
|
#else
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
#ifndef glVertexAttribDivisor
|
#ifndef glVertexAttribDivisor
|
||||||
#ifndef NO_GLEW
|
#ifndef NO_GLEW
|
||||||
@@ -44,6 +46,7 @@ float shadowMapWorldSize=10;
|
|||||||
#endif //NO_GLEW
|
#endif //NO_GLEW
|
||||||
#endif
|
#endif
|
||||||
#endif //__APPLE__
|
#endif //__APPLE__
|
||||||
|
#endif//B3_USE_GLFW
|
||||||
#include "GLInstancingRenderer.h"
|
#include "GLInstancingRenderer.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#ifndef B3_USE_GLFW
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|
||||||
#include "MacOpenGLWindow.h"
|
#include "MacOpenGLWindow.h"
|
||||||
@@ -190,6 +191,6 @@ void MacOpenGLWindow::setAllowRetina(bool allow)
|
|||||||
|
|
||||||
|
|
||||||
#endif //__APPLE__
|
#endif //__APPLE__
|
||||||
|
#endif //B3_USE_GLFW
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#ifndef B3_USE_GLFW
|
||||||
|
|
||||||
#include "MacOpenGLWindowObjC.h"
|
#include "MacOpenGLWindowObjC.h"
|
||||||
|
|
||||||
#define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
|
#define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
|
||||||
@@ -1231,3 +1233,5 @@ b3ResizeCallback Mac_getResizeCallback(struct MacOpenGLWindowInternalData* m_int
|
|||||||
{
|
{
|
||||||
return [m_internalData->m_myview getResizeCallback];
|
return [m_internalData->m_myview getResizeCallback];
|
||||||
}
|
}
|
||||||
|
#endif //B3_USE_GLFW
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,10 @@ subject to the following restrictions:
|
|||||||
#ifndef __OPENGL_INCLUDE_H
|
#ifndef __OPENGL_INCLUDE_H
|
||||||
#define __OPENGL_INCLUDE_H
|
#define __OPENGL_INCLUDE_H
|
||||||
|
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
#include "glad/glad.h"
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
#else
|
||||||
//think different
|
//think different
|
||||||
#if defined(__APPLE__) && !defined (VMDMESA)
|
#if defined(__APPLE__) && !defined (VMDMESA)
|
||||||
#include <OpenGL/OpenGL.h>
|
#include <OpenGL/OpenGL.h>
|
||||||
@@ -45,7 +48,7 @@ subject to the following restrictions:
|
|||||||
//#include <GL/glu.h>
|
//#include <GL/glu.h>
|
||||||
#endif //_WINDOWS
|
#endif //_WINDOWS
|
||||||
#endif //APPLE
|
#endif //APPLE
|
||||||
|
#endif //B3_USE_GLFW
|
||||||
//disable glGetError
|
//disable glGetError
|
||||||
//#undef glGetError
|
//#undef glGetError
|
||||||
//#define glGetError MyGetError
|
//#define glGetError MyGetError
|
||||||
|
|||||||
@@ -17,7 +17,10 @@ subject to the following restrictions:
|
|||||||
#ifndef __OPENGL_INCLUDE_H
|
#ifndef __OPENGL_INCLUDE_H
|
||||||
#define __OPENGL_INCLUDE_H
|
#define __OPENGL_INCLUDE_H
|
||||||
|
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
#include <glad/glad.h>
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
#else
|
||||||
//think different
|
//think different
|
||||||
#if defined(__APPLE__) && !defined (VMDMESA)
|
#if defined(__APPLE__) && !defined (VMDMESA)
|
||||||
#include <OpenGL/OpenGL.h>
|
#include <OpenGL/OpenGL.h>
|
||||||
@@ -31,6 +34,7 @@ subject to the following restrictions:
|
|||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
#ifdef GLEW_STATIC
|
#ifdef GLEW_STATIC
|
||||||
#include "CustomGL/glew.h"
|
#include "CustomGL/glew.h"
|
||||||
#else
|
#else
|
||||||
@@ -52,7 +56,7 @@ subject to the following restrictions:
|
|||||||
//#include <GL/glu.h>
|
//#include <GL/glu.h>
|
||||||
#endif //_WINDOWS
|
#endif //_WINDOWS
|
||||||
#endif //APPLE
|
#endif //APPLE
|
||||||
|
#endif
|
||||||
//disable glGetError
|
//disable glGetError
|
||||||
//#undef glGetError
|
//#undef glGetError
|
||||||
//#define glGetError MyGetError
|
//#define glGetError MyGetError
|
||||||
|
|||||||
@@ -13,6 +13,11 @@
|
|||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
#include "TwFonts.h"
|
#include "TwFonts.h"
|
||||||
#include "SimpleOpenGL2Renderer.h"
|
#include "SimpleOpenGL2Renderer.h"
|
||||||
|
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
#include "GLFWOpenGLWindow.h"
|
||||||
|
#else
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include "MacOpenGLWindow.h"
|
#include "MacOpenGLWindow.h"
|
||||||
#else
|
#else
|
||||||
@@ -30,6 +35,8 @@
|
|||||||
#endif //BT_USE_EGL
|
#endif //BT_USE_EGL
|
||||||
#endif //_WIN32
|
#endif //_WIN32
|
||||||
#endif//__APPLE__
|
#endif//__APPLE__
|
||||||
|
#endif //#ifdef B3_USE_GLFW
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "../CommonInterfaces/CommonRenderInterface.h"
|
#include "../CommonInterfaces/CommonRenderInterface.h"
|
||||||
|
|
||||||
@@ -39,9 +46,9 @@ static void Simple2ResizeCallback( float widthf, float heightf)
|
|||||||
{
|
{
|
||||||
int width = (int)widthf;
|
int width = (int)widthf;
|
||||||
int height = (int)heightf;
|
int height = (int)heightf;
|
||||||
if (gApp2->m_renderer)
|
if (gApp2->m_renderer && gApp2->m_window)
|
||||||
gApp2->m_renderer->resize(width,height);
|
gApp2->m_renderer->resize(width,height);//*gApp2->m_window->getRetinaScale(),height*gApp2->m_window->getRetinaScale());
|
||||||
//gApp2->m_renderer->setScreenSize(width,height);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,11 +65,18 @@ static void Simple2KeyboardCallback(int key, int state)
|
|||||||
|
|
||||||
void Simple2MouseButtonCallback( int button, int state, float x, float y)
|
void Simple2MouseButtonCallback( int button, int state, float x, float y)
|
||||||
{
|
{
|
||||||
gApp2->defaultMouseButtonCallback(button,state,x,y);
|
if (gApp2 && gApp2->m_window)
|
||||||
|
{
|
||||||
|
gApp2->defaultMouseButtonCallback(button,state,x,y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void Simple2MouseMoveCallback( float x, float y)
|
void Simple2MouseMoveCallback( float x, float y)
|
||||||
{
|
{
|
||||||
gApp2->defaultMouseMoveCallback(x,y);
|
|
||||||
|
if (gApp2 && gApp2->m_window)
|
||||||
|
{
|
||||||
|
gApp2->defaultMouseMoveCallback(x,y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Simple2WheelCallback( float deltax, float deltay)
|
void Simple2WheelCallback( float deltax, float deltay)
|
||||||
@@ -129,7 +143,7 @@ SimpleOpenGL2App::SimpleOpenGL2App(const char* title, int width, int height)
|
|||||||
glewExperimental = GL_TRUE;
|
glewExperimental = GL_TRUE;
|
||||||
#endif //_WIN32
|
#endif //_WIN32
|
||||||
|
|
||||||
|
#ifndef B3_USE_GLFW
|
||||||
if (glewInit() != GLEW_OK)
|
if (glewInit() != GLEW_OK)
|
||||||
{
|
{
|
||||||
b3Error("glewInit failed");
|
b3Error("glewInit failed");
|
||||||
@@ -140,7 +154,7 @@ SimpleOpenGL2App::SimpleOpenGL2App(const char* title, int width, int height)
|
|||||||
b3Error("GLEW_VERSION_2_1 needs to support 2_1");
|
b3Error("GLEW_VERSION_2_1 needs to support 2_1");
|
||||||
exit(1); // or handle the error in a nicer way
|
exit(1); // or handle the error in a nicer way
|
||||||
}
|
}
|
||||||
|
#endif //B3_USE_GLFW
|
||||||
#endif //__APPLE__
|
#endif //__APPLE__
|
||||||
#endif //NO_GLEW
|
#endif //NO_GLEW
|
||||||
|
|
||||||
@@ -580,4 +594,4 @@ int SimpleOpenGL2App::registerCubeShape(float halfExtentsX,float halfExtentsY, f
|
|||||||
|
|
||||||
int shapeId = m_renderer->registerShape(&verts[0].xyzw[0],numVertices,cube_indices,numIndices,B3_GL_TRIANGLES,textureIndex);
|
int shapeId = m_renderer->registerShape(&verts[0].xyzw[0],numVertices,cube_indices,numIndices,B3_GL_TRIANGLES,textureIndex);
|
||||||
return shapeId;
|
return shapeId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
#include "SimpleOpenGL3App.h"
|
#include "SimpleOpenGL3App.h"
|
||||||
#include "ShapeData.h"
|
#include "ShapeData.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
#include "GLFWOpenGLWindow.h"
|
||||||
|
#else
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include "MacOpenGLWindow.h"
|
#include "MacOpenGLWindow.h"
|
||||||
#else
|
#else
|
||||||
@@ -19,6 +24,8 @@
|
|||||||
#endif //BT_USE_EGL
|
#endif //BT_USE_EGL
|
||||||
#endif //_WIN32
|
#endif //_WIN32
|
||||||
#endif//__APPLE__
|
#endif//__APPLE__
|
||||||
|
#endif //B3_USE_GLFW
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "GLPrimitiveRenderer.h"
|
#include "GLPrimitiveRenderer.h"
|
||||||
@@ -321,12 +328,12 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height, boo
|
|||||||
glewExperimental = GL_TRUE;
|
glewExperimental = GL_TRUE;
|
||||||
#endif //_WIN32
|
#endif //_WIN32
|
||||||
|
|
||||||
|
#ifndef B3_USE_GLFW
|
||||||
if (glewInit() != GLEW_OK)
|
if (glewInit() != GLEW_OK)
|
||||||
exit(1); // or handle the error in a nicer way
|
exit(1); // or handle the error in a nicer way
|
||||||
if (!GLEW_VERSION_2_1) // check that the machine supports the 2.1 API.
|
if (!GLEW_VERSION_2_1) // check that the machine supports the 2.1 API.
|
||||||
exit(1); // or handle the error in a nicer way
|
exit(1); // or handle the error in a nicer way
|
||||||
|
#endif //B3_USE_GLFW
|
||||||
#endif //__APPLE__
|
#endif //__APPLE__
|
||||||
#endif //NO_GLEW
|
#endif //NO_GLEW
|
||||||
glGetError();//don't remove this call, it is needed for Ubuntu
|
glGetError();//don't remove this call, it is needed for Ubuntu
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#ifndef B3_USE_GLFW
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2012 Advanced Micro Devices, Inc.
|
Copyright (c) 2012 Advanced Micro Devices, Inc.
|
||||||
@@ -196,5 +197,5 @@ int Win32OpenGLWindow::getHeight() const
|
|||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif //B3_USE_GLFW
|
||||||
@@ -53,7 +53,7 @@ b3SharedMemoryCommandHandle b3SaveWorldCommandInit(b3PhysicsClientHandle physCli
|
|||||||
return (b3SharedMemoryCommandHandle) command;
|
return (b3SharedMemoryCommandHandle) command;
|
||||||
}
|
}
|
||||||
|
|
||||||
b3SharedMemoryCommandHandle b3LoadUrdfCommandInit(b3PhysicsClientHandle physClient, const char* urdfFileName)
|
B3_SHARED_API b3SharedMemoryCommandHandle b3LoadUrdfCommandInit(b3PhysicsClientHandle physClient, const char* urdfFileName)
|
||||||
{
|
{
|
||||||
PhysicsClient* cl = (PhysicsClient* ) physClient;
|
PhysicsClient* cl = (PhysicsClient* ) physClient;
|
||||||
b3Assert(cl);
|
b3Assert(cl);
|
||||||
@@ -212,7 +212,7 @@ int b3LoadBunnySetCollisionMargin(b3SharedMemoryCommandHandle commandHandle, dou
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int b3LoadUrdfCommandSetUseMultiBody(b3SharedMemoryCommandHandle commandHandle, int useMultiBody)
|
B3_SHARED_API int b3LoadUrdfCommandSetUseMultiBody(b3SharedMemoryCommandHandle commandHandle, int useMultiBody)
|
||||||
{
|
{
|
||||||
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
|
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
|
||||||
b3Assert(command);
|
b3Assert(command);
|
||||||
@@ -223,7 +223,7 @@ int b3LoadUrdfCommandSetUseMultiBody(b3SharedMemoryCommandHandle commandHandle,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int b3LoadUrdfCommandSetGlobalScaling(b3SharedMemoryCommandHandle commandHandle, double globalScaling)
|
B3_SHARED_API int b3LoadUrdfCommandSetGlobalScaling(b3SharedMemoryCommandHandle commandHandle, double globalScaling)
|
||||||
{
|
{
|
||||||
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
|
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
|
||||||
b3Assert(command);
|
b3Assert(command);
|
||||||
@@ -259,7 +259,7 @@ int b3LoadSdfCommandSetUseGlobalScaling(b3SharedMemoryCommandHandle commandHandl
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int b3LoadUrdfCommandSetUseFixedBase(b3SharedMemoryCommandHandle commandHandle, int useFixedBase)
|
B3_SHARED_API int b3LoadUrdfCommandSetUseFixedBase(b3SharedMemoryCommandHandle commandHandle, int useFixedBase)
|
||||||
{
|
{
|
||||||
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
|
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
|
||||||
b3Assert(command);
|
b3Assert(command);
|
||||||
@@ -273,7 +273,7 @@ int b3LoadUrdfCommandSetUseFixedBase(b3SharedMemoryCommandHandle commandHandle,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int b3LoadUrdfCommandSetFlags(b3SharedMemoryCommandHandle commandHandle, int flags)
|
B3_SHARED_API int b3LoadUrdfCommandSetFlags(b3SharedMemoryCommandHandle commandHandle, int flags)
|
||||||
{
|
{
|
||||||
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
|
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
|
||||||
b3Assert(command);
|
b3Assert(command);
|
||||||
@@ -286,7 +286,7 @@ int b3LoadUrdfCommandSetFlags(b3SharedMemoryCommandHandle commandHandle, int fla
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int b3LoadUrdfCommandSetStartPosition(b3SharedMemoryCommandHandle commandHandle, double startPosX,double startPosY,double startPosZ)
|
B3_SHARED_API int b3LoadUrdfCommandSetStartPosition(b3SharedMemoryCommandHandle commandHandle, double startPosX,double startPosY,double startPosZ)
|
||||||
{
|
{
|
||||||
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
|
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
|
||||||
b3Assert(command);
|
b3Assert(command);
|
||||||
@@ -305,7 +305,7 @@ int b3LoadUrdfCommandSetStartPosition(b3SharedMemoryCommandHandle commandHandle,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int b3LoadUrdfCommandSetStartOrientation(b3SharedMemoryCommandHandle commandHandle, double startOrnX,double startOrnY,double startOrnZ, double startOrnW)
|
B3_SHARED_API int b3LoadUrdfCommandSetStartOrientation(b3SharedMemoryCommandHandle commandHandle, double startOrnX,double startOrnY,double startOrnZ, double startOrnW)
|
||||||
{
|
{
|
||||||
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
|
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
|
||||||
b3Assert(command);
|
b3Assert(command);
|
||||||
@@ -495,7 +495,7 @@ int b3PhysicsParamSetDefaultFrictionERP(b3SharedMemoryCommandHandle commandHandl
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
b3SharedMemoryCommandHandle b3InitStepSimulationCommand(b3PhysicsClientHandle physClient)
|
B3_SHARED_API b3SharedMemoryCommandHandle b3InitStepSimulationCommand(b3PhysicsClientHandle physClient)
|
||||||
{
|
{
|
||||||
PhysicsClient* cl = (PhysicsClient* ) physClient;
|
PhysicsClient* cl = (PhysicsClient* ) physClient;
|
||||||
b3Assert(cl);
|
b3Assert(cl);
|
||||||
@@ -507,7 +507,7 @@ b3SharedMemoryCommandHandle b3InitStepSimulationCommand(b3PhysicsClientHandle ph
|
|||||||
return (b3SharedMemoryCommandHandle) command;
|
return (b3SharedMemoryCommandHandle) command;
|
||||||
}
|
}
|
||||||
|
|
||||||
b3SharedMemoryCommandHandle b3InitResetSimulationCommand(b3PhysicsClientHandle physClient)
|
B3_SHARED_API b3SharedMemoryCommandHandle b3InitResetSimulationCommand(b3PhysicsClientHandle physClient)
|
||||||
{
|
{
|
||||||
PhysicsClient* cl = (PhysicsClient* ) physClient;
|
PhysicsClient* cl = (PhysicsClient* ) physClient;
|
||||||
b3Assert(cl);
|
b3Assert(cl);
|
||||||
@@ -1631,7 +1631,7 @@ int b3SubmitClientCommand(b3PhysicsClientHandle physClient, const b3SharedMemory
|
|||||||
#include "../Utils/b3Clock.h"
|
#include "../Utils/b3Clock.h"
|
||||||
|
|
||||||
|
|
||||||
b3SharedMemoryStatusHandle b3SubmitClientCommandAndWaitStatus(b3PhysicsClientHandle physClient, const b3SharedMemoryCommandHandle commandHandle)
|
B3_SHARED_API b3SharedMemoryStatusHandle b3SubmitClientCommandAndWaitStatus(b3PhysicsClientHandle physClient, const b3SharedMemoryCommandHandle commandHandle)
|
||||||
{
|
{
|
||||||
B3_PROFILE("b3SubmitClientCommandAndWaitStatus");
|
B3_PROFILE("b3SubmitClientCommandAndWaitStatus");
|
||||||
b3Clock clock;
|
b3Clock clock;
|
||||||
|
|||||||
@@ -10,6 +10,14 @@ B3_DECLARE_HANDLE(b3PhysicsClientHandle);
|
|||||||
B3_DECLARE_HANDLE(b3SharedMemoryCommandHandle);
|
B3_DECLARE_HANDLE(b3SharedMemoryCommandHandle);
|
||||||
B3_DECLARE_HANDLE(b3SharedMemoryStatusHandle);
|
B3_DECLARE_HANDLE(b3SharedMemoryStatusHandle);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define B3_SHARED_API __declspec(dllexport)
|
||||||
|
#elif defined (__GNUC__)
|
||||||
|
#define B3_SHARED_API __attribute__((visibility("default")))
|
||||||
|
#else
|
||||||
|
#define B3_SHARED_API
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///There are several connection methods, see following header files:
|
///There are several connection methods, see following header files:
|
||||||
#include "PhysicsClientSharedMemory_C_API.h"
|
#include "PhysicsClientSharedMemory_C_API.h"
|
||||||
@@ -39,7 +47,7 @@ void b3DisconnectSharedMemory(b3PhysicsClientHandle physClient);
|
|||||||
int b3CanSubmitCommand(b3PhysicsClientHandle physClient);
|
int b3CanSubmitCommand(b3PhysicsClientHandle physClient);
|
||||||
|
|
||||||
///blocking submit command and wait for status
|
///blocking submit command and wait for status
|
||||||
b3SharedMemoryStatusHandle b3SubmitClientCommandAndWaitStatus(b3PhysicsClientHandle physClient, b3SharedMemoryCommandHandle commandHandle);
|
B3_SHARED_API b3SharedMemoryStatusHandle b3SubmitClientCommandAndWaitStatus(b3PhysicsClientHandle physClient, b3SharedMemoryCommandHandle commandHandle);
|
||||||
|
|
||||||
///In general it is better to use b3SubmitClientCommandAndWaitStatus. b3SubmitClientCommand is a non-blocking submit
|
///In general it is better to use b3SubmitClientCommandAndWaitStatus. b3SubmitClientCommand is a non-blocking submit
|
||||||
///command, which requires checking for the status manually, using b3ProcessServerStatus. Also, before sending the
|
///command, which requires checking for the status manually, using b3ProcessServerStatus. Also, before sending the
|
||||||
@@ -67,7 +75,7 @@ int b3GetStatusActualState(b3SharedMemoryStatusHandle statusHandle,
|
|||||||
|
|
||||||
|
|
||||||
b3SharedMemoryCommandHandle b3RequestCollisionInfoCommandInit(b3PhysicsClientHandle physClient, int bodyUniqueId);
|
b3SharedMemoryCommandHandle b3RequestCollisionInfoCommandInit(b3PhysicsClientHandle physClient, int bodyUniqueId);
|
||||||
int b3GetStatusAABB(b3SharedMemoryStatusHandle statusHandle, int linkIndex, double aabbMin[3], double aabbMax[3]);
|
int b3GetStatusAABB(b3SharedMemoryStatusHandle statusHandle, int linkIndex, double aabbMin[/*3*/], double aabbMax[/*3*/]);
|
||||||
|
|
||||||
///If you re-connected to an existing server, or server changed otherwise, sync the body info and user constraints etc.
|
///If you re-connected to an existing server, or server changed otherwise, sync the body info and user constraints etc.
|
||||||
b3SharedMemoryCommandHandle b3InitSyncBodyInfoCommand(b3PhysicsClientHandle physClient);
|
b3SharedMemoryCommandHandle b3InitSyncBodyInfoCommand(b3PhysicsClientHandle physClient);
|
||||||
@@ -111,8 +119,8 @@ int b3GetStatusUserConstraintUniqueId(b3SharedMemoryStatusHandle statusHandle);
|
|||||||
|
|
||||||
///change parameters of an existing user constraint
|
///change parameters of an existing user constraint
|
||||||
b3SharedMemoryCommandHandle b3InitChangeUserConstraintCommand(b3PhysicsClientHandle physClient, int userConstraintUniqueId);
|
b3SharedMemoryCommandHandle b3InitChangeUserConstraintCommand(b3PhysicsClientHandle physClient, int userConstraintUniqueId);
|
||||||
int b3InitChangeUserConstraintSetPivotInB(b3SharedMemoryCommandHandle commandHandle, double jointChildPivot[3]);
|
int b3InitChangeUserConstraintSetPivotInB(b3SharedMemoryCommandHandle commandHandle, double jointChildPivot[/*3*/]);
|
||||||
int b3InitChangeUserConstraintSetFrameInB(b3SharedMemoryCommandHandle commandHandle, double jointChildFrameOrn[4]);
|
int b3InitChangeUserConstraintSetFrameInB(b3SharedMemoryCommandHandle commandHandle, double jointChildFrameOrn[/*4*/]);
|
||||||
int b3InitChangeUserConstraintSetMaxForce(b3SharedMemoryCommandHandle commandHandle, double maxAppliedForce);
|
int b3InitChangeUserConstraintSetMaxForce(b3SharedMemoryCommandHandle commandHandle, double maxAppliedForce);
|
||||||
int b3InitChangeUserConstraintSetGearRatio(b3SharedMemoryCommandHandle commandHandle, double gearRatio);
|
int b3InitChangeUserConstraintSetGearRatio(b3SharedMemoryCommandHandle commandHandle, double gearRatio);
|
||||||
int b3InitChangeUserConstraintSetGearAuxLink(b3SharedMemoryCommandHandle commandHandle, int gearAuxLink);
|
int b3InitChangeUserConstraintSetGearAuxLink(b3SharedMemoryCommandHandle commandHandle, int gearAuxLink);
|
||||||
@@ -135,18 +143,18 @@ void b3GetDebugLines(b3PhysicsClientHandle physClient, struct b3DebugLines* l
|
|||||||
///configure the 3D OpenGL debug visualizer (enable/disable GUI widgets, shadows, position camera etc)
|
///configure the 3D OpenGL debug visualizer (enable/disable GUI widgets, shadows, position camera etc)
|
||||||
b3SharedMemoryCommandHandle b3InitConfigureOpenGLVisualizer(b3PhysicsClientHandle physClient);
|
b3SharedMemoryCommandHandle b3InitConfigureOpenGLVisualizer(b3PhysicsClientHandle physClient);
|
||||||
void b3ConfigureOpenGLVisualizerSetVisualizationFlags(b3SharedMemoryCommandHandle commandHandle, int flag, int enabled);
|
void b3ConfigureOpenGLVisualizerSetVisualizationFlags(b3SharedMemoryCommandHandle commandHandle, int flag, int enabled);
|
||||||
void b3ConfigureOpenGLVisualizerSetViewMatrix(b3SharedMemoryCommandHandle commandHandle, float cameraDistance, float cameraPitch, float cameraYaw, const float cameraTargetPosition[3]);
|
void b3ConfigureOpenGLVisualizerSetViewMatrix(b3SharedMemoryCommandHandle commandHandle, float cameraDistance, float cameraPitch, float cameraYaw, const float cameraTargetPosition[/*3*/]);
|
||||||
|
|
||||||
b3SharedMemoryCommandHandle b3InitRequestOpenGLVisualizerCameraCommand(b3PhysicsClientHandle physClient);
|
b3SharedMemoryCommandHandle b3InitRequestOpenGLVisualizerCameraCommand(b3PhysicsClientHandle physClient);
|
||||||
int b3GetStatusOpenGLVisualizerCamera(b3SharedMemoryStatusHandle statusHandle, struct b3OpenGLVisualizerCameraInfo* camera);
|
int b3GetStatusOpenGLVisualizerCamera(b3SharedMemoryStatusHandle statusHandle, struct b3OpenGLVisualizerCameraInfo* camera);
|
||||||
|
|
||||||
|
|
||||||
/// Add/remove user-specific debug lines and debug text messages
|
/// Add/remove user-specific debug lines and debug text messages
|
||||||
b3SharedMemoryCommandHandle b3InitUserDebugDrawAddLine3D(b3PhysicsClientHandle physClient, double fromXYZ[3], double toXYZ[3], double colorRGB[3], double lineWidth, double lifeTime);
|
b3SharedMemoryCommandHandle b3InitUserDebugDrawAddLine3D(b3PhysicsClientHandle physClient, double fromXYZ[/*3*/], double toXYZ[/*3*/], double colorRGB[/*3*/], double lineWidth, double lifeTime);
|
||||||
|
|
||||||
b3SharedMemoryCommandHandle b3InitUserDebugDrawAddText3D(b3PhysicsClientHandle physClient, const char* txt, double positionXYZ[3], double colorRGB[3], double textSize, double lifeTime);
|
b3SharedMemoryCommandHandle b3InitUserDebugDrawAddText3D(b3PhysicsClientHandle physClient, const char* txt, double positionXYZ[/*3*/], double colorRGB[/*3*/], double textSize, double lifeTime);
|
||||||
void b3UserDebugTextSetOptionFlags(b3SharedMemoryCommandHandle commandHandle, int optionFlags);
|
void b3UserDebugTextSetOptionFlags(b3SharedMemoryCommandHandle commandHandle, int optionFlags);
|
||||||
void b3UserDebugTextSetOrientation(b3SharedMemoryCommandHandle commandHandle, double orientation[4]);
|
void b3UserDebugTextSetOrientation(b3SharedMemoryCommandHandle commandHandle, double orientation[/*4*/]);
|
||||||
|
|
||||||
void b3UserDebugItemSetParentObject(b3SharedMemoryCommandHandle commandHandle, int objectUniqueId, int linkIndex);
|
void b3UserDebugItemSetParentObject(b3SharedMemoryCommandHandle commandHandle, int objectUniqueId, int linkIndex);
|
||||||
|
|
||||||
@@ -158,7 +166,7 @@ b3SharedMemoryCommandHandle b3InitUserDebugDrawRemove(b3PhysicsClientHandle phys
|
|||||||
b3SharedMemoryCommandHandle b3InitUserDebugDrawRemoveAll(b3PhysicsClientHandle physClient);
|
b3SharedMemoryCommandHandle b3InitUserDebugDrawRemoveAll(b3PhysicsClientHandle physClient);
|
||||||
|
|
||||||
b3SharedMemoryCommandHandle b3InitDebugDrawingCommand(b3PhysicsClientHandle physClient);
|
b3SharedMemoryCommandHandle b3InitDebugDrawingCommand(b3PhysicsClientHandle physClient);
|
||||||
void b3SetDebugObjectColor(b3SharedMemoryCommandHandle commandHandle, int objectUniqueId, int linkIndex, double objectColorRGB[3]);
|
void b3SetDebugObjectColor(b3SharedMemoryCommandHandle commandHandle, int objectUniqueId, int linkIndex, double objectColorRGB[/*3*/]);
|
||||||
void b3RemoveDebugObjectColor(b3SharedMemoryCommandHandle commandHandle, int objectUniqueId, int linkIndex);
|
void b3RemoveDebugObjectColor(b3SharedMemoryCommandHandle commandHandle, int objectUniqueId, int linkIndex);
|
||||||
|
|
||||||
///All debug items unique Ids are positive: a negative unique Id means failure.
|
///All debug items unique Ids are positive: a negative unique Id means failure.
|
||||||
@@ -167,10 +175,10 @@ int b3GetDebugItemUniqueId(b3SharedMemoryStatusHandle statusHandle);
|
|||||||
|
|
||||||
///request an image from a simulated camera, using a software renderer.
|
///request an image from a simulated camera, using a software renderer.
|
||||||
b3SharedMemoryCommandHandle b3InitRequestCameraImage(b3PhysicsClientHandle physClient);
|
b3SharedMemoryCommandHandle b3InitRequestCameraImage(b3PhysicsClientHandle physClient);
|
||||||
void b3RequestCameraImageSetCameraMatrices(b3SharedMemoryCommandHandle command, float viewMatrix[16], float projectionMatrix[16]);
|
void b3RequestCameraImageSetCameraMatrices(b3SharedMemoryCommandHandle command, float viewMatrix[/*16*/], float projectionMatrix[/*16*/]);
|
||||||
void b3RequestCameraImageSetPixelResolution(b3SharedMemoryCommandHandle command, int width, int height );
|
void b3RequestCameraImageSetPixelResolution(b3SharedMemoryCommandHandle command, int width, int height );
|
||||||
void b3RequestCameraImageSetLightDirection(b3SharedMemoryCommandHandle commandHandle, const float lightDirection[3]);
|
void b3RequestCameraImageSetLightDirection(b3SharedMemoryCommandHandle commandHandle, const float lightDirection[/*3*/]);
|
||||||
void b3RequestCameraImageSetLightColor(b3SharedMemoryCommandHandle commandHandle, const float lightColor[3]);
|
void b3RequestCameraImageSetLightColor(b3SharedMemoryCommandHandle commandHandle, const float lightColor[/*3*/]);
|
||||||
void b3RequestCameraImageSetLightDistance(b3SharedMemoryCommandHandle commandHandle, float lightDistance);
|
void b3RequestCameraImageSetLightDistance(b3SharedMemoryCommandHandle commandHandle, float lightDistance);
|
||||||
void b3RequestCameraImageSetLightAmbientCoeff(b3SharedMemoryCommandHandle commandHandle, float lightAmbientCoeff);
|
void b3RequestCameraImageSetLightAmbientCoeff(b3SharedMemoryCommandHandle commandHandle, float lightAmbientCoeff);
|
||||||
void b3RequestCameraImageSetLightDiffuseCoeff(b3SharedMemoryCommandHandle commandHandle, float lightDiffuseCoeff);
|
void b3RequestCameraImageSetLightDiffuseCoeff(b3SharedMemoryCommandHandle commandHandle, float lightDiffuseCoeff);
|
||||||
@@ -180,19 +188,19 @@ void b3RequestCameraImageSelectRenderer(b3SharedMemoryCommandHandle commandHandl
|
|||||||
void b3GetCameraImageData(b3PhysicsClientHandle physClient, struct b3CameraImageData* imageData);
|
void b3GetCameraImageData(b3PhysicsClientHandle physClient, struct b3CameraImageData* imageData);
|
||||||
|
|
||||||
///compute a view matrix, helper function for b3RequestCameraImageSetCameraMatrices
|
///compute a view matrix, helper function for b3RequestCameraImageSetCameraMatrices
|
||||||
void b3ComputeViewMatrixFromPositions(const float cameraPosition[3], const float cameraTargetPosition[3], const float cameraUp[3], float viewMatrix[16]);
|
void b3ComputeViewMatrixFromPositions(const float cameraPosition[/*3*/], const float cameraTargetPosition[/*3*/], const float cameraUp[/*3*/], float viewMatrix[/*16*/]);
|
||||||
void b3ComputeViewMatrixFromYawPitchRoll(const float cameraTargetPosition[3], float distance, float yaw, float pitch, float roll, int upAxis, float viewMatrix[16]);
|
void b3ComputeViewMatrixFromYawPitchRoll(const float cameraTargetPosition[/*3*/], float distance, float yaw, float pitch, float roll, int upAxis, float viewMatrix[/*16*/]);
|
||||||
void b3ComputePositionFromViewMatrix(const float viewMatrix[16], float cameraPosition[3], float cameraTargetPosition[3], float cameraUp[3]);
|
void b3ComputePositionFromViewMatrix(const float viewMatrix[/*16*/], float cameraPosition[/*3*/], float cameraTargetPosition[/*3*/], float cameraUp[/*3*/]);
|
||||||
|
|
||||||
///compute a projection matrix, helper function for b3RequestCameraImageSetCameraMatrices
|
///compute a projection matrix, helper function for b3RequestCameraImageSetCameraMatrices
|
||||||
void b3ComputeProjectionMatrix(float left, float right, float bottom, float top, float nearVal, float farVal, float projectionMatrix[16]);
|
void b3ComputeProjectionMatrix(float left, float right, float bottom, float top, float nearVal, float farVal, float projectionMatrix[/*16*/]);
|
||||||
void b3ComputeProjectionMatrixFOV(float fov, float aspect, float nearVal, float farVal, float projectionMatrix[16]);
|
void b3ComputeProjectionMatrixFOV(float fov, float aspect, float nearVal, float farVal, float projectionMatrix[/*16*/]);
|
||||||
|
|
||||||
|
|
||||||
/* obsolete, please use b3ComputeViewProjectionMatrices */
|
/* obsolete, please use b3ComputeViewProjectionMatrices */
|
||||||
void b3RequestCameraImageSetViewMatrix(b3SharedMemoryCommandHandle command, const float cameraPosition[3], const float cameraTargetPosition[3], const float cameraUp[3]);
|
void b3RequestCameraImageSetViewMatrix(b3SharedMemoryCommandHandle command, const float cameraPosition[/*3*/], const float cameraTargetPosition[/*3*/], const float cameraUp[/*3*/]);
|
||||||
/* obsolete, please use b3ComputeViewProjectionMatrices */
|
/* obsolete, please use b3ComputeViewProjectionMatrices */
|
||||||
void b3RequestCameraImageSetViewMatrix2(b3SharedMemoryCommandHandle commandHandle, const float cameraTargetPosition[3], float distance, float yaw, float pitch, float roll, int upAxis);
|
void b3RequestCameraImageSetViewMatrix2(b3SharedMemoryCommandHandle commandHandle, const float cameraTargetPosition[/*3*/], float distance, float yaw, float pitch, float roll, int upAxis);
|
||||||
/* obsolete, please use b3ComputeViewProjectionMatrices */
|
/* obsolete, please use b3ComputeViewProjectionMatrices */
|
||||||
void b3RequestCameraImageSetProjectionMatrix(b3SharedMemoryCommandHandle command, float left, float right, float bottom, float top, float nearVal, float farVal);
|
void b3RequestCameraImageSetProjectionMatrix(b3SharedMemoryCommandHandle command, float left, float right, float bottom, float top, float nearVal, float farVal);
|
||||||
/* obsolete, please use b3ComputeViewProjectionMatrices */
|
/* obsolete, please use b3ComputeViewProjectionMatrices */
|
||||||
@@ -217,7 +225,7 @@ void b3SetClosestDistanceThreshold(b3SharedMemoryCommandHandle commandHandle, do
|
|||||||
void b3GetClosestPointInformation(b3PhysicsClientHandle physClient, struct b3ContactInformation* contactPointInfo);
|
void b3GetClosestPointInformation(b3PhysicsClientHandle physClient, struct b3ContactInformation* contactPointInfo);
|
||||||
|
|
||||||
///get all the bodies that touch a given axis aligned bounding box specified in world space (min and max coordinates)
|
///get all the bodies that touch a given axis aligned bounding box specified in world space (min and max coordinates)
|
||||||
b3SharedMemoryCommandHandle b3InitAABBOverlapQuery(b3PhysicsClientHandle physClient, const double aabbMin[3],const double aabbMax[3]);
|
b3SharedMemoryCommandHandle b3InitAABBOverlapQuery(b3PhysicsClientHandle physClient, const double aabbMin[/*3*/],const double aabbMax[/*3*/]);
|
||||||
void b3GetAABBOverlapResults(b3PhysicsClientHandle physClient, struct b3AABBOverlapData* data);
|
void b3GetAABBOverlapResults(b3PhysicsClientHandle physClient, struct b3AABBOverlapData* data);
|
||||||
|
|
||||||
//request visual shape information
|
//request visual shape information
|
||||||
@@ -230,8 +238,8 @@ int b3GetStatusTextureUniqueId(b3SharedMemoryStatusHandle statusHandle);
|
|||||||
b3SharedMemoryCommandHandle b3CreateChangeTextureCommandInit(b3PhysicsClientHandle physClient, int textureUniqueId, int width, int height, const char* rgbPixels);
|
b3SharedMemoryCommandHandle b3CreateChangeTextureCommandInit(b3PhysicsClientHandle physClient, int textureUniqueId, int width, int height, const char* rgbPixels);
|
||||||
|
|
||||||
b3SharedMemoryCommandHandle b3InitUpdateVisualShape(b3PhysicsClientHandle physClient, int bodyUniqueId, int jointIndex, int shapeIndex, int textureUniqueId);
|
b3SharedMemoryCommandHandle b3InitUpdateVisualShape(b3PhysicsClientHandle physClient, int bodyUniqueId, int jointIndex, int shapeIndex, int textureUniqueId);
|
||||||
void b3UpdateVisualShapeRGBAColor(b3SharedMemoryCommandHandle commandHandle, double rgbaColor[4]);
|
void b3UpdateVisualShapeRGBAColor(b3SharedMemoryCommandHandle commandHandle, double rgbaColor[/*4*/]);
|
||||||
void b3UpdateVisualShapeSpecularColor(b3SharedMemoryCommandHandle commandHandle, double specularColor[3]);
|
void b3UpdateVisualShapeSpecularColor(b3SharedMemoryCommandHandle commandHandle, double specularColor[/*3*/]);
|
||||||
|
|
||||||
|
|
||||||
b3SharedMemoryCommandHandle b3InitPhysicsParamCommand(b3PhysicsClientHandle physClient);
|
b3SharedMemoryCommandHandle b3InitPhysicsParamCommand(b3PhysicsClientHandle physClient);
|
||||||
@@ -262,20 +270,20 @@ int b3PhysicsParamSetRestitutionVelocityThreshold(b3SharedMemoryCommandHandle co
|
|||||||
int b3PhysicsParamSetInternalSimFlags(b3SharedMemoryCommandHandle commandHandle, int flags);
|
int b3PhysicsParamSetInternalSimFlags(b3SharedMemoryCommandHandle commandHandle, int flags);
|
||||||
|
|
||||||
|
|
||||||
b3SharedMemoryCommandHandle b3InitStepSimulationCommand(b3PhysicsClientHandle physClient);
|
B3_SHARED_API b3SharedMemoryCommandHandle b3InitStepSimulationCommand(b3PhysicsClientHandle physClient);
|
||||||
|
|
||||||
b3SharedMemoryCommandHandle b3InitResetSimulationCommand(b3PhysicsClientHandle physClient);
|
B3_SHARED_API b3SharedMemoryCommandHandle b3InitResetSimulationCommand(b3PhysicsClientHandle physClient);
|
||||||
|
|
||||||
///Load a robot from a URDF file. Status type will CMD_URDF_LOADING_COMPLETED.
|
///Load a robot from a URDF file. Status type will CMD_URDF_LOADING_COMPLETED.
|
||||||
///Access the robot from the unique body index, through b3GetStatusBodyIndex(statusHandle);
|
///Access the robot from the unique body index, through b3GetStatusBodyIndex(statusHandle);
|
||||||
b3SharedMemoryCommandHandle b3LoadUrdfCommandInit(b3PhysicsClientHandle physClient, const char* urdfFileName);
|
B3_SHARED_API b3SharedMemoryCommandHandle b3LoadUrdfCommandInit(b3PhysicsClientHandle physClient, const char* urdfFileName);
|
||||||
|
|
||||||
int b3LoadUrdfCommandSetStartPosition(b3SharedMemoryCommandHandle commandHandle, double startPosX,double startPosY,double startPosZ);
|
B3_SHARED_API int b3LoadUrdfCommandSetStartPosition(b3SharedMemoryCommandHandle commandHandle, double startPosX,double startPosY,double startPosZ);
|
||||||
int b3LoadUrdfCommandSetStartOrientation(b3SharedMemoryCommandHandle commandHandle, double startOrnX,double startOrnY,double startOrnZ, double startOrnW);
|
B3_SHARED_API int b3LoadUrdfCommandSetStartOrientation(b3SharedMemoryCommandHandle commandHandle, double startOrnX,double startOrnY,double startOrnZ, double startOrnW);
|
||||||
int b3LoadUrdfCommandSetUseMultiBody(b3SharedMemoryCommandHandle commandHandle, int useMultiBody);
|
B3_SHARED_API int b3LoadUrdfCommandSetUseMultiBody(b3SharedMemoryCommandHandle commandHandle, int useMultiBody);
|
||||||
int b3LoadUrdfCommandSetUseFixedBase(b3SharedMemoryCommandHandle commandHandle, int useFixedBase);
|
B3_SHARED_API int b3LoadUrdfCommandSetUseFixedBase(b3SharedMemoryCommandHandle commandHandle, int useFixedBase);
|
||||||
int b3LoadUrdfCommandSetFlags(b3SharedMemoryCommandHandle commandHandle, int flags);
|
B3_SHARED_API int b3LoadUrdfCommandSetFlags(b3SharedMemoryCommandHandle commandHandle, int flags);
|
||||||
int b3LoadUrdfCommandSetGlobalScaling(b3SharedMemoryCommandHandle commandHandle, double globalScaling);
|
B3_SHARED_API int b3LoadUrdfCommandSetGlobalScaling(b3SharedMemoryCommandHandle commandHandle, double globalScaling);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -300,10 +308,10 @@ int b3GetStatusJacobian(b3SharedMemoryStatusHandle statusHandle, double* linearJ
|
|||||||
|
|
||||||
///compute the joint positions to move the end effector to a desired target using inverse kinematics
|
///compute the joint positions to move the end effector to a desired target using inverse kinematics
|
||||||
b3SharedMemoryCommandHandle b3CalculateInverseKinematicsCommandInit(b3PhysicsClientHandle physClient, int bodyIndex);
|
b3SharedMemoryCommandHandle b3CalculateInverseKinematicsCommandInit(b3PhysicsClientHandle physClient, int bodyIndex);
|
||||||
void b3CalculateInverseKinematicsAddTargetPurePosition(b3SharedMemoryCommandHandle commandHandle, int endEffectorLinkIndex, const double targetPosition[3]);
|
void b3CalculateInverseKinematicsAddTargetPurePosition(b3SharedMemoryCommandHandle commandHandle, int endEffectorLinkIndex, const double targetPosition[/*3*/]);
|
||||||
void b3CalculateInverseKinematicsAddTargetPositionWithOrientation(b3SharedMemoryCommandHandle commandHandle, int endEffectorLinkIndex, const double targetPosition[3], const double targetOrientation[4]);
|
void b3CalculateInverseKinematicsAddTargetPositionWithOrientation(b3SharedMemoryCommandHandle commandHandle, int endEffectorLinkIndex, const double targetPosition[/*3*/], const double targetOrientation[/*4*/]);
|
||||||
void b3CalculateInverseKinematicsPosWithNullSpaceVel(b3SharedMemoryCommandHandle commandHandle, int numDof, int endEffectorLinkIndex, const double targetPosition[3], const double* lowerLimit, const double* upperLimit, const double* jointRange, const double* restPose);
|
void b3CalculateInverseKinematicsPosWithNullSpaceVel(b3SharedMemoryCommandHandle commandHandle, int numDof, int endEffectorLinkIndex, const double targetPosition[/*3*/], const double* lowerLimit, const double* upperLimit, const double* jointRange, const double* restPose);
|
||||||
void b3CalculateInverseKinematicsPosOrnWithNullSpaceVel(b3SharedMemoryCommandHandle commandHandle, int numDof, int endEffectorLinkIndex, const double targetPosition[3], const double targetOrientation[4], const double* lowerLimit, const double* upperLimit, const double* jointRange, const double* restPose);
|
void b3CalculateInverseKinematicsPosOrnWithNullSpaceVel(b3SharedMemoryCommandHandle commandHandle, int numDof, int endEffectorLinkIndex, const double targetPosition[/*3*/], const double targetOrientation[/*4*/], const double* lowerLimit, const double* upperLimit, const double* jointRange, const double* restPose);
|
||||||
void b3CalculateInverseKinematicsSetJointDamping(b3SharedMemoryCommandHandle commandHandle, int numDof, const double* jointDampingCoeff);
|
void b3CalculateInverseKinematicsSetJointDamping(b3SharedMemoryCommandHandle commandHandle, int numDof, const double* jointDampingCoeff);
|
||||||
int b3GetStatusInverseKinematicsJointPositions(b3SharedMemoryStatusHandle statusHandle,
|
int b3GetStatusInverseKinematicsJointPositions(b3SharedMemoryStatusHandle statusHandle,
|
||||||
int* bodyUniqueId,
|
int* bodyUniqueId,
|
||||||
@@ -345,14 +353,14 @@ int b3JointControlSetDesiredForceTorque(b3SharedMemoryCommandHandle commandHandl
|
|||||||
|
|
||||||
b3SharedMemoryCommandHandle b3CreateCollisionShapeCommandInit(b3PhysicsClientHandle physClient);
|
b3SharedMemoryCommandHandle b3CreateCollisionShapeCommandInit(b3PhysicsClientHandle physClient);
|
||||||
int b3CreateCollisionShapeAddSphere(b3SharedMemoryCommandHandle commandHandle,double radius);
|
int b3CreateCollisionShapeAddSphere(b3SharedMemoryCommandHandle commandHandle,double radius);
|
||||||
int b3CreateCollisionShapeAddBox(b3SharedMemoryCommandHandle commandHandle,double halfExtents[3]);
|
int b3CreateCollisionShapeAddBox(b3SharedMemoryCommandHandle commandHandle,double halfExtents[/*3*/]);
|
||||||
int b3CreateCollisionShapeAddCapsule(b3SharedMemoryCommandHandle commandHandle,double radius, double height);
|
int b3CreateCollisionShapeAddCapsule(b3SharedMemoryCommandHandle commandHandle,double radius, double height);
|
||||||
int b3CreateCollisionShapeAddCylinder(b3SharedMemoryCommandHandle commandHandle,double radius, double height);
|
int b3CreateCollisionShapeAddCylinder(b3SharedMemoryCommandHandle commandHandle,double radius, double height);
|
||||||
int b3CreateCollisionShapeAddPlane(b3SharedMemoryCommandHandle commandHandle, double planeNormal[3], double planeConstant);
|
int b3CreateCollisionShapeAddPlane(b3SharedMemoryCommandHandle commandHandle, double planeNormal[/*3*/], double planeConstant);
|
||||||
int b3CreateCollisionShapeAddMesh(b3SharedMemoryCommandHandle commandHandle,const char* fileName, double meshScale[3]);
|
int b3CreateCollisionShapeAddMesh(b3SharedMemoryCommandHandle commandHandle,const char* fileName, double meshScale[/*3*/]);
|
||||||
void b3CreateCollisionSetFlag(b3SharedMemoryCommandHandle commandHandle,int shapeIndex, int flags);
|
void b3CreateCollisionSetFlag(b3SharedMemoryCommandHandle commandHandle,int shapeIndex, int flags);
|
||||||
|
|
||||||
void b3CreateCollisionShapeSetChildTransform(b3SharedMemoryCommandHandle commandHandle,int shapeIndex, double childPosition[3], double childOrientation[4]);
|
void b3CreateCollisionShapeSetChildTransform(b3SharedMemoryCommandHandle commandHandle,int shapeIndex, double childPosition[/*3*/], double childOrientation[/*4*/]);
|
||||||
|
|
||||||
int b3GetStatusCollisionShapeUniqueId(b3SharedMemoryStatusHandle statusHandle);
|
int b3GetStatusCollisionShapeUniqueId(b3SharedMemoryStatusHandle statusHandle);
|
||||||
|
|
||||||
@@ -360,17 +368,17 @@ b3SharedMemoryCommandHandle b3CreateVisualShapeCommandInit(b3PhysicsClientHandle
|
|||||||
int b3GetStatusVisualShapeUniqueId(b3SharedMemoryStatusHandle statusHandle);
|
int b3GetStatusVisualShapeUniqueId(b3SharedMemoryStatusHandle statusHandle);
|
||||||
|
|
||||||
b3SharedMemoryCommandHandle b3CreateMultiBodyCommandInit(b3PhysicsClientHandle physClient);
|
b3SharedMemoryCommandHandle b3CreateMultiBodyCommandInit(b3PhysicsClientHandle physClient);
|
||||||
int b3CreateMultiBodyBase(b3SharedMemoryCommandHandle commandHandle, double mass, int collisionShapeUnique, int visualShapeUniqueId, double basePosition[3], double baseOrientation[4] , double baseInertialFramePosition[3], double baseInertialFrameOrientation[4]);
|
int b3CreateMultiBodyBase(b3SharedMemoryCommandHandle commandHandle, double mass, int collisionShapeUnique, int visualShapeUniqueId, double basePosition[/*3*/], double baseOrientation[/*4*/] , double baseInertialFramePosition[/*3*/], double baseInertialFrameOrientation[/*4*/]);
|
||||||
|
|
||||||
int b3CreateMultiBodyLink(b3SharedMemoryCommandHandle commandHandle, double linkMass, double linkCollisionShapeIndex,
|
int b3CreateMultiBodyLink(b3SharedMemoryCommandHandle commandHandle, double linkMass, double linkCollisionShapeIndex,
|
||||||
double linkVisualShapeIndex,
|
double linkVisualShapeIndex,
|
||||||
double linkPosition[3],
|
double linkPosition[/*3*/],
|
||||||
double linkOrientation[4],
|
double linkOrientation[/*4*/],
|
||||||
double linkInertialFramePosition[3],
|
double linkInertialFramePosition[/*3*/],
|
||||||
double linkInertialFrameOrientation[4],
|
double linkInertialFrameOrientation[/*4*/],
|
||||||
int linkParentIndex,
|
int linkParentIndex,
|
||||||
int linkJointType,
|
int linkJointType,
|
||||||
double linkJointAxis[3]);
|
double linkJointAxis[/*3*/]);
|
||||||
|
|
||||||
|
|
||||||
//useMaximalCoordinates are disabled by default, enabling them is experimental and not fully supported yet
|
//useMaximalCoordinates are disabled by default, enabling them is experimental and not fully supported yet
|
||||||
@@ -397,8 +405,8 @@ int b3CreateBoxCommandSetColorRGBA(b3SharedMemoryCommandHandle commandHandle, do
|
|||||||
b3SharedMemoryCommandHandle b3CreatePoseCommandInit(b3PhysicsClientHandle physClient, int bodyIndex);
|
b3SharedMemoryCommandHandle b3CreatePoseCommandInit(b3PhysicsClientHandle physClient, int bodyIndex);
|
||||||
int b3CreatePoseCommandSetBasePosition(b3SharedMemoryCommandHandle commandHandle, double startPosX,double startPosY,double startPosZ);
|
int b3CreatePoseCommandSetBasePosition(b3SharedMemoryCommandHandle commandHandle, double startPosX,double startPosY,double startPosZ);
|
||||||
int b3CreatePoseCommandSetBaseOrientation(b3SharedMemoryCommandHandle commandHandle, double startOrnX,double startOrnY,double startOrnZ, double startOrnW);
|
int b3CreatePoseCommandSetBaseOrientation(b3SharedMemoryCommandHandle commandHandle, double startOrnX,double startOrnY,double startOrnZ, double startOrnW);
|
||||||
int b3CreatePoseCommandSetBaseLinearVelocity(b3SharedMemoryCommandHandle commandHandle, double linVel[3]);
|
int b3CreatePoseCommandSetBaseLinearVelocity(b3SharedMemoryCommandHandle commandHandle, double linVel[/*3*/]);
|
||||||
int b3CreatePoseCommandSetBaseAngularVelocity(b3SharedMemoryCommandHandle commandHandle, double angVel[3]);
|
int b3CreatePoseCommandSetBaseAngularVelocity(b3SharedMemoryCommandHandle commandHandle, double angVel[/*3*/]);
|
||||||
|
|
||||||
int b3CreatePoseCommandSetJointPositions(b3SharedMemoryCommandHandle commandHandle, int numJointPositions, const double* jointPositions);
|
int b3CreatePoseCommandSetJointPositions(b3SharedMemoryCommandHandle commandHandle, int numJointPositions, const double* jointPositions);
|
||||||
int b3CreatePoseCommandSetJointPosition(b3PhysicsClientHandle physClient, b3SharedMemoryCommandHandle commandHandle, int jointIndex, double jointPosition);
|
int b3CreatePoseCommandSetJointPosition(b3PhysicsClientHandle physClient, b3SharedMemoryCommandHandle commandHandle, int jointIndex, double jointPosition);
|
||||||
@@ -434,7 +442,7 @@ b3SharedMemoryCommandHandle b3CreateRaycastCommandInit(b3PhysicsClientHandle phy
|
|||||||
double rayToWorldX, double rayToWorldY, double rayToWorldZ);
|
double rayToWorldX, double rayToWorldY, double rayToWorldZ);
|
||||||
|
|
||||||
b3SharedMemoryCommandHandle b3CreateRaycastBatchCommandInit(b3PhysicsClientHandle physClient);
|
b3SharedMemoryCommandHandle b3CreateRaycastBatchCommandInit(b3PhysicsClientHandle physClient);
|
||||||
void b3RaycastBatchAddRay(b3SharedMemoryCommandHandle commandHandle, const double rayFromWorld[3], const double rayToWorld[3]);
|
void b3RaycastBatchAddRay(b3SharedMemoryCommandHandle commandHandle, const double rayFromWorld[/*3*/], const double rayToWorld[/*3*/]);
|
||||||
|
|
||||||
void b3GetRaycastInformation(b3PhysicsClientHandle physClient, struct b3RaycastInformation* raycastInfo);
|
void b3GetRaycastInformation(b3PhysicsClientHandle physClient, struct b3RaycastInformation* raycastInfo);
|
||||||
|
|
||||||
@@ -442,8 +450,8 @@ void b3GetRaycastInformation(b3PhysicsClientHandle physClient, struct b3RaycastI
|
|||||||
|
|
||||||
/// Apply external force at the body (or link) center of mass, in world space/Cartesian coordinates.
|
/// Apply external force at the body (or link) center of mass, in world space/Cartesian coordinates.
|
||||||
b3SharedMemoryCommandHandle b3ApplyExternalForceCommandInit(b3PhysicsClientHandle physClient);
|
b3SharedMemoryCommandHandle b3ApplyExternalForceCommandInit(b3PhysicsClientHandle physClient);
|
||||||
void b3ApplyExternalForce(b3SharedMemoryCommandHandle commandHandle, int bodyUniqueId, int linkId, const double force[3], const double position[3], int flags);
|
void b3ApplyExternalForce(b3SharedMemoryCommandHandle commandHandle, int bodyUniqueId, int linkId, const double force[/*3*/], const double position[/*3*/], int flags);
|
||||||
void b3ApplyExternalTorque(b3SharedMemoryCommandHandle commandHandle, int bodyUniqueId, int linkId, const double torque[3], int flags);
|
void b3ApplyExternalTorque(b3SharedMemoryCommandHandle commandHandle, int bodyUniqueId, int linkId, const double torque[/*3*/], int flags);
|
||||||
|
|
||||||
///experiments of robots interacting with non-rigid objects (such as btSoftBody)
|
///experiments of robots interacting with non-rigid objects (such as btSoftBody)
|
||||||
b3SharedMemoryCommandHandle b3LoadBunnyCommandInit(b3PhysicsClientHandle physClient);
|
b3SharedMemoryCommandHandle b3LoadBunnyCommandInit(b3PhysicsClientHandle physClient);
|
||||||
@@ -458,8 +466,8 @@ void b3VREventsSetDeviceTypeFilter(b3SharedMemoryCommandHandle commandHandle, in
|
|||||||
void b3GetVREventsData(b3PhysicsClientHandle physClient, struct b3VREventsData* vrEventsData);
|
void b3GetVREventsData(b3PhysicsClientHandle physClient, struct b3VREventsData* vrEventsData);
|
||||||
|
|
||||||
b3SharedMemoryCommandHandle b3SetVRCameraStateCommandInit(b3PhysicsClientHandle physClient);
|
b3SharedMemoryCommandHandle b3SetVRCameraStateCommandInit(b3PhysicsClientHandle physClient);
|
||||||
int b3SetVRCameraRootPosition(b3SharedMemoryCommandHandle commandHandle, double rootPos[3]);
|
int b3SetVRCameraRootPosition(b3SharedMemoryCommandHandle commandHandle, double rootPos[/*3*/]);
|
||||||
int b3SetVRCameraRootOrientation(b3SharedMemoryCommandHandle commandHandle, double rootOrn[4]);
|
int b3SetVRCameraRootOrientation(b3SharedMemoryCommandHandle commandHandle, double rootOrn[/*4*/]);
|
||||||
int b3SetVRCameraTrackingObject(b3SharedMemoryCommandHandle commandHandle, int objectUniqueId);
|
int b3SetVRCameraTrackingObject(b3SharedMemoryCommandHandle commandHandle, int objectUniqueId);
|
||||||
int b3SetVRCameraTrackingObjectFlag(b3SharedMemoryCommandHandle commandHandle, int flag);
|
int b3SetVRCameraTrackingObjectFlag(b3SharedMemoryCommandHandle commandHandle, int flag);
|
||||||
|
|
||||||
@@ -493,8 +501,8 @@ double b3GetTimeOut(b3PhysicsClientHandle physClient);
|
|||||||
|
|
||||||
b3SharedMemoryCommandHandle b3SetAdditionalSearchPath(b3PhysicsClientHandle physClient, char* path);
|
b3SharedMemoryCommandHandle b3SetAdditionalSearchPath(b3PhysicsClientHandle physClient, char* path);
|
||||||
|
|
||||||
void b3MultiplyTransforms(const double posA[3], const double ornA[4], const double posB[3], const double ornB[4], double outPos[3], double outOrn[4]);
|
void b3MultiplyTransforms(const double posA[/*3*/], const double ornA[/*4*/], const double posB[/*3*/], const double ornB[/*4*/], double outPos[/*3*/], double outOrn[/*4*/]);
|
||||||
void b3InvertTransform(const double pos[3], const double orn[4], double outPos[3], double outOrn[4]);
|
void b3InvertTransform(const double pos[/*3*/], const double orn[/*4*/], double outPos[/*3*/], double outOrn[/*4*/]);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "PhysicsClientSharedMemory.h"
|
#include "PhysicsClientSharedMemory.h"
|
||||||
|
|
||||||
b3PhysicsClientHandle b3ConnectSharedMemory(int key)
|
B3_SHARED_API b3PhysicsClientHandle b3ConnectSharedMemory(int key)
|
||||||
{
|
{
|
||||||
PhysicsClientSharedMemory* cl = new PhysicsClientSharedMemory();
|
PhysicsClientSharedMemory* cl = new PhysicsClientSharedMemory();
|
||||||
cl->setSharedMemoryKey(key);
|
cl->setSharedMemoryKey(key);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
b3PhysicsClientHandle b3ConnectSharedMemory(int key);
|
B3_SHARED_API b3PhysicsClientHandle b3ConnectSharedMemory(int key);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMainThread(int argc, char* argv[])
|
B3_SHARED_API b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMainThread(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
InProcessPhysicsClientSharedMemoryMainThread* cl = new InProcessPhysicsClientSharedMemoryMainThread(argc, argv, 1);
|
InProcessPhysicsClientSharedMemoryMainThread* cl = new InProcessPhysicsClientSharedMemoryMainThread(argc, argv, 1);
|
||||||
cl->setSharedMemoryKey(SHARED_MEMORY_KEY+1);
|
cl->setSharedMemoryKey(SHARED_MEMORY_KEY+1);
|
||||||
@@ -91,7 +91,7 @@ b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMainThread(int arg
|
|||||||
return (b3PhysicsClientHandle ) cl;
|
return (b3PhysicsClientHandle ) cl;
|
||||||
}
|
}
|
||||||
|
|
||||||
b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMainThreadSharedMemory(int argc, char* argv[])
|
B3_SHARED_API b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMainThreadSharedMemory(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
InProcessPhysicsClientSharedMemoryMainThread* cl = new InProcessPhysicsClientSharedMemoryMainThread(argc, argv, 0);
|
InProcessPhysicsClientSharedMemoryMainThread* cl = new InProcessPhysicsClientSharedMemoryMainThread(argc, argv, 0);
|
||||||
cl->setSharedMemoryKey(SHARED_MEMORY_KEY+1);
|
cl->setSharedMemoryKey(SHARED_MEMORY_KEY+1);
|
||||||
@@ -133,7 +133,7 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnect(int argc, char* argv[])
|
B3_SHARED_API b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnect(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
InProcessPhysicsClientSharedMemory* cl = new InProcessPhysicsClientSharedMemory(argc, argv, 1);
|
InProcessPhysicsClientSharedMemory* cl = new InProcessPhysicsClientSharedMemory(argc, argv, 1);
|
||||||
@@ -141,7 +141,7 @@ b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnect(int argc, char* a
|
|||||||
cl->connect();
|
cl->connect();
|
||||||
return (b3PhysicsClientHandle ) cl;
|
return (b3PhysicsClientHandle ) cl;
|
||||||
}
|
}
|
||||||
b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectSharedMemory(int argc, char* argv[])
|
B3_SHARED_API b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectSharedMemory(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
InProcessPhysicsClientSharedMemory* cl = new InProcessPhysicsClientSharedMemory(argc, argv, 0);
|
InProcessPhysicsClientSharedMemory* cl = new InProcessPhysicsClientSharedMemory(argc, argv, 0);
|
||||||
@@ -248,7 +248,7 @@ int b3InProcessMouseButtonCallback(b3PhysicsClientHandle clientHandle, int butto
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
b3PhysicsClientHandle b3CreateInProcessPhysicsServerFromExistingExampleBrowserAndConnect(void* guiHelperPtr)
|
B3_SHARED_API b3PhysicsClientHandle b3CreateInProcessPhysicsServerFromExistingExampleBrowserAndConnect(void* guiHelperPtr)
|
||||||
{
|
{
|
||||||
GUIHelperInterface* guiHelper = (GUIHelperInterface*) guiHelperPtr;
|
GUIHelperInterface* guiHelper = (GUIHelperInterface*) guiHelperPtr;
|
||||||
InProcessPhysicsClientExistingExampleBrowser* cl = new InProcessPhysicsClientExistingExampleBrowser(guiHelper);
|
InProcessPhysicsClientExistingExampleBrowser* cl = new InProcessPhysicsClientExistingExampleBrowser(guiHelper);
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ extern "C" {
|
|||||||
|
|
||||||
|
|
||||||
///think more about naming. The b3ConnectPhysicsLoopback
|
///think more about naming. The b3ConnectPhysicsLoopback
|
||||||
b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnect(int argc, char* argv[]);
|
B3_SHARED_API b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnect(int argc, char* argv[]);
|
||||||
b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectSharedMemory(int argc, char* argv[]);
|
B3_SHARED_API b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectSharedMemory(int argc, char* argv[]);
|
||||||
|
|
||||||
b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMainThread(int argc, char* argv[]);
|
B3_SHARED_API b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMainThread(int argc, char* argv[]);
|
||||||
b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMainThreadSharedMemory(int argc, char* argv[]);
|
B3_SHARED_API b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMainThreadSharedMemory(int argc, char* argv[]);
|
||||||
|
|
||||||
b3PhysicsClientHandle b3CreateInProcessPhysicsServerFromExistingExampleBrowserAndConnect(void* guiHelperPtr);
|
B3_SHARED_API b3PhysicsClientHandle b3CreateInProcessPhysicsServerFromExistingExampleBrowserAndConnect(void* guiHelperPtr);
|
||||||
|
|
||||||
///ignore the following APIs, they are for internal use for example browser
|
///ignore the following APIs, they are for internal use for example browser
|
||||||
void b3InProcessRenderSceneInternal(b3PhysicsClientHandle clientHandle);
|
void b3InProcessRenderSceneInternal(b3PhysicsClientHandle clientHandle);
|
||||||
|
|||||||
@@ -1007,7 +1007,7 @@ void CMainApplication::RenderFrame()
|
|||||||
// We want to make sure the glFinish waits for the entire present to complete, not just the submission
|
// We want to make sure the glFinish waits for the entire present to complete, not just the submission
|
||||||
// of the command. So, we do a clear here right here so the glFinish will wait fully for the swap.
|
// of the command. So, we do a clear here right here so the glFinish will wait fully for the swap.
|
||||||
glClearColor( 0, 0, 0, 1 );
|
glClearColor( 0, 0, 0, 1 );
|
||||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
//glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush and wait for swap.
|
// Flush and wait for swap.
|
||||||
@@ -1281,9 +1281,13 @@ bool CMainApplication::SetupTexturemaps()
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
GLfloat fLargest;
|
GLfloat fLargest;
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY, &fLargest);
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, fLargest);
|
||||||
|
#else
|
||||||
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &fLargest);
|
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &fLargest);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
glBindTexture( GL_TEXTURE_2D, 0 );
|
glBindTexture( GL_TEXTURE_2D, 0 );
|
||||||
|
|
||||||
@@ -1911,7 +1915,7 @@ void CMainApplication::RenderScene( vr::Hmd_Eye nEye )
|
|||||||
{
|
{
|
||||||
B3_PROFILE("RenderScene");
|
B3_PROFILE("RenderScene");
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
if( m_bShowCubes )
|
if( m_bShowCubes )
|
||||||
@@ -2298,9 +2302,14 @@ bool CGLRenderModel::BInit( const vr::RenderModel_t & vrModel, const vr::RenderM
|
|||||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
|
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
GLfloat fLargest;
|
GLfloat fLargest;
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY, &fLargest );
|
||||||
|
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, fLargest );
|
||||||
|
#else
|
||||||
glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &fLargest );
|
glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &fLargest );
|
||||||
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest );
|
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest );
|
||||||
#endif
|
#endif //B3_USE_GLFW
|
||||||
|
#endif//_WIN32
|
||||||
glBindTexture( GL_TEXTURE_2D, 0 );
|
glBindTexture( GL_TEXTURE_2D, 0 );
|
||||||
|
|
||||||
m_unVertexCount = vrModel.unTriangleCount * 3;
|
m_unVertexCount = vrModel.unTriangleCount * 3;
|
||||||
@@ -2391,6 +2400,7 @@ int main(int argc, char *argv[])
|
|||||||
if (gVideoFileName)
|
if (gVideoFileName)
|
||||||
pMainApplication->getApp()->dumpFramesToVideo(gVideoFileName);
|
pMainApplication->getApp()->dumpFramesToVideo(gVideoFileName);
|
||||||
|
|
||||||
|
#ifndef B3_USE_GLFW
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
//request disable VSYNC
|
//request disable VSYNC
|
||||||
typedef bool (APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int);
|
typedef bool (APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int);
|
||||||
@@ -2400,7 +2410,7 @@ int main(int argc, char *argv[])
|
|||||||
if (wglSwapIntervalEXT)
|
if (wglSwapIntervalEXT)
|
||||||
wglSwapIntervalEXT(0);
|
wglSwapIntervalEXT(0);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
GLint sync = 0;
|
GLint sync = 0;
|
||||||
CGLContextObj ctx = CGLGetCurrentContext();
|
CGLContextObj ctx = CGLGetCurrentContext();
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
#include "Gwen/Texture.h"
|
#include "Gwen/Texture.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
#include "glad/glad.h"
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
#else
|
||||||
|
|
||||||
#if defined(__APPLE__) && !defined (VMDMESA)
|
#if defined(__APPLE__) && !defined (VMDMESA)
|
||||||
#include <OpenGL/OpenGL.h>
|
#include <OpenGL/OpenGL.h>
|
||||||
@@ -22,6 +26,7 @@
|
|||||||
#endif //NO_GLEW
|
#endif //NO_GLEW
|
||||||
#endif //GLEW_STATIC
|
#endif //GLEW_STATIC
|
||||||
#endif//(__APPLE__)
|
#endif//(__APPLE__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "FontData.h"
|
#include "FontData.h"
|
||||||
|
|
||||||
@@ -148,7 +153,9 @@ namespace Gwen
|
|||||||
{
|
{
|
||||||
namespace Renderer
|
namespace Renderer
|
||||||
{
|
{
|
||||||
OpenGL_DebugFont::OpenGL_DebugFont()
|
|
||||||
|
OpenGL_DebugFont::OpenGL_DebugFont(float retinaScale)
|
||||||
|
:m_retinaScale(retinaScale)
|
||||||
{
|
{
|
||||||
m_iVertNum = 0;
|
m_iVertNum = 0;
|
||||||
|
|
||||||
@@ -255,8 +262,8 @@ namespace Gwen
|
|||||||
Flush();
|
Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Vertices[ m_iVertNum ].x = (float)x;
|
m_Vertices[ m_iVertNum ].x = (float)x*m_retinaScale;
|
||||||
m_Vertices[ m_iVertNum ].y = (float)y;
|
m_Vertices[ m_iVertNum ].y = (float)y*m_retinaScale;
|
||||||
m_Vertices[ m_iVertNum ].u = u;
|
m_Vertices[ m_iVertNum ].u = u;
|
||||||
m_Vertices[ m_iVertNum ].v = v;
|
m_Vertices[ m_iVertNum ].v = v;
|
||||||
|
|
||||||
@@ -301,16 +308,19 @@ namespace Gwen
|
|||||||
Flush();
|
Flush();
|
||||||
Gwen::Rect rect = ClipRegion();
|
Gwen::Rect rect = ClipRegion();
|
||||||
|
|
||||||
// OpenGL's coords are from the bottom left
|
float retinaScale = m_retinaScale;
|
||||||
// so we need to translate them here.
|
// OpenGL's coords are from the bottom left
|
||||||
{
|
// so we need to translate them here.
|
||||||
GLint view[4];
|
{
|
||||||
glGetIntegerv( GL_VIEWPORT, &view[0] );
|
GLint view[4];
|
||||||
rect.y = view[3] - (rect.y + rect.h);
|
glGetIntegerv( GL_VIEWPORT, &view[0] );
|
||||||
}
|
rect.y = view[3]/retinaScale - (rect.y + rect.h);
|
||||||
|
}
|
||||||
glScissor( rect.x * Scale(), rect.y * Scale(), rect.w * Scale(), rect.h * Scale() );
|
|
||||||
glEnable( GL_SCISSOR_TEST );
|
glScissor( retinaScale * rect.x * Scale(), retinaScale * rect.y * Scale(), retinaScale * rect.w * Scale(), retinaScale * rect.h * Scale() );
|
||||||
|
glEnable( GL_SCISSOR_TEST );
|
||||||
|
//glDisable( GL_SCISSOR_TEST );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void OpenGL_DebugFont::EndClip()
|
void OpenGL_DebugFont::EndClip()
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ namespace Gwen
|
|||||||
|
|
||||||
class OpenGL_DebugFont : public Gwen::Renderer::Base
|
class OpenGL_DebugFont : public Gwen::Renderer::Base
|
||||||
{
|
{
|
||||||
|
float m_retinaScale;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct Vertex
|
struct Vertex
|
||||||
@@ -32,8 +34,8 @@ namespace Gwen
|
|||||||
|
|
||||||
|
|
||||||
static const int MaxVerts = 1024;
|
static const int MaxVerts = 1024;
|
||||||
|
|
||||||
OpenGL_DebugFont();
|
OpenGL_DebugFont(float retinaScale);
|
||||||
~OpenGL_DebugFont();
|
~OpenGL_DebugFont();
|
||||||
|
|
||||||
void RenderText( Gwen::Font* pFont, Gwen::Point pos, const Gwen::UnicodeString& text );
|
void RenderText( Gwen::Font* pFont, Gwen::Point pos, const Gwen::UnicodeString& text );
|
||||||
|
|||||||
284
examples/ThirdPartyLibs/glad/KHR/khrplatform.h
Normal file
284
examples/ThirdPartyLibs/glad/KHR/khrplatform.h
Normal file
@@ -0,0 +1,284 @@
|
|||||||
|
#ifndef __khrplatform_h_
|
||||||
|
#define __khrplatform_h_
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Copyright (c) 2008-2009 The Khronos Group Inc.
|
||||||
|
**
|
||||||
|
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
** copy of this software and/or associated documentation files (the
|
||||||
|
** "Materials"), to deal in the Materials without restriction, including
|
||||||
|
** without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
** distribute, sublicense, and/or sell copies of the Materials, and to
|
||||||
|
** permit persons to whom the Materials are furnished to do so, subject to
|
||||||
|
** the following conditions:
|
||||||
|
**
|
||||||
|
** The above copyright notice and this permission notice shall be included
|
||||||
|
** in all copies or substantial portions of the Materials.
|
||||||
|
**
|
||||||
|
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Khronos platform-specific types and definitions.
|
||||||
|
*
|
||||||
|
* $Revision: 32517 $ on $Date: 2016-03-11 02:41:19 -0800 (Fri, 11 Mar 2016) $
|
||||||
|
*
|
||||||
|
* Adopters may modify this file to suit their platform. Adopters are
|
||||||
|
* encouraged to submit platform specific modifications to the Khronos
|
||||||
|
* group so that they can be included in future versions of this file.
|
||||||
|
* Please submit changes by sending them to the public Khronos Bugzilla
|
||||||
|
* (http://khronos.org/bugzilla) by filing a bug against product
|
||||||
|
* "Khronos (general)" component "Registry".
|
||||||
|
*
|
||||||
|
* A predefined template which fills in some of the bug fields can be
|
||||||
|
* reached using http://tinyurl.com/khrplatform-h-bugreport, but you
|
||||||
|
* must create a Bugzilla login first.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* See the Implementer's Guidelines for information about where this file
|
||||||
|
* should be located on your system and for more details of its use:
|
||||||
|
* http://www.khronos.org/registry/implementers_guide.pdf
|
||||||
|
*
|
||||||
|
* This file should be included as
|
||||||
|
* #include <KHR/khrplatform.h>
|
||||||
|
* by Khronos client API header files that use its types and defines.
|
||||||
|
*
|
||||||
|
* The types in khrplatform.h should only be used to define API-specific types.
|
||||||
|
*
|
||||||
|
* Types defined in khrplatform.h:
|
||||||
|
* khronos_int8_t signed 8 bit
|
||||||
|
* khronos_uint8_t unsigned 8 bit
|
||||||
|
* khronos_int16_t signed 16 bit
|
||||||
|
* khronos_uint16_t unsigned 16 bit
|
||||||
|
* khronos_int32_t signed 32 bit
|
||||||
|
* khronos_uint32_t unsigned 32 bit
|
||||||
|
* khronos_int64_t signed 64 bit
|
||||||
|
* khronos_uint64_t unsigned 64 bit
|
||||||
|
* khronos_intptr_t signed same number of bits as a pointer
|
||||||
|
* khronos_uintptr_t unsigned same number of bits as a pointer
|
||||||
|
* khronos_ssize_t signed size
|
||||||
|
* khronos_usize_t unsigned size
|
||||||
|
* khronos_float_t signed 32 bit floating point
|
||||||
|
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
|
||||||
|
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
|
||||||
|
* nanoseconds
|
||||||
|
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
|
||||||
|
* khronos_boolean_enum_t enumerated boolean type. This should
|
||||||
|
* only be used as a base type when a client API's boolean type is
|
||||||
|
* an enum. Client APIs which use an integer or other type for
|
||||||
|
* booleans cannot use this as the base type for their boolean.
|
||||||
|
*
|
||||||
|
* Tokens defined in khrplatform.h:
|
||||||
|
*
|
||||||
|
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
|
||||||
|
*
|
||||||
|
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
|
||||||
|
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
|
||||||
|
*
|
||||||
|
* Calling convention macros defined in this file:
|
||||||
|
* KHRONOS_APICALL
|
||||||
|
* KHRONOS_APIENTRY
|
||||||
|
* KHRONOS_APIATTRIBUTES
|
||||||
|
*
|
||||||
|
* These may be used in function prototypes as:
|
||||||
|
*
|
||||||
|
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
|
||||||
|
* int arg1,
|
||||||
|
* int arg2) KHRONOS_APIATTRIBUTES;
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* Definition of KHRONOS_APICALL
|
||||||
|
*-------------------------------------------------------------------------
|
||||||
|
* This precedes the return type of the function in the function prototype.
|
||||||
|
*/
|
||||||
|
#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
|
||||||
|
# define KHRONOS_APICALL __declspec(dllimport)
|
||||||
|
#elif defined (__SYMBIAN32__)
|
||||||
|
# define KHRONOS_APICALL IMPORT_C
|
||||||
|
#elif defined(__ANDROID__)
|
||||||
|
# define KHRONOS_APICALL __attribute__((visibility("default")))
|
||||||
|
#else
|
||||||
|
# define KHRONOS_APICALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* Definition of KHRONOS_APIENTRY
|
||||||
|
*-------------------------------------------------------------------------
|
||||||
|
* This follows the return type of the function and precedes the function
|
||||||
|
* name in the function prototype.
|
||||||
|
*/
|
||||||
|
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
|
||||||
|
/* Win32 but not WinCE */
|
||||||
|
# define KHRONOS_APIENTRY __stdcall
|
||||||
|
#else
|
||||||
|
# define KHRONOS_APIENTRY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* Definition of KHRONOS_APIATTRIBUTES
|
||||||
|
*-------------------------------------------------------------------------
|
||||||
|
* This follows the closing parenthesis of the function prototype arguments.
|
||||||
|
*/
|
||||||
|
#if defined (__ARMCC_2__)
|
||||||
|
#define KHRONOS_APIATTRIBUTES __softfp
|
||||||
|
#else
|
||||||
|
#define KHRONOS_APIATTRIBUTES
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* basic type definitions
|
||||||
|
*-----------------------------------------------------------------------*/
|
||||||
|
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Using <stdint.h>
|
||||||
|
*/
|
||||||
|
#include <stdint.h>
|
||||||
|
typedef int32_t khronos_int32_t;
|
||||||
|
typedef uint32_t khronos_uint32_t;
|
||||||
|
typedef int64_t khronos_int64_t;
|
||||||
|
typedef uint64_t khronos_uint64_t;
|
||||||
|
#define KHRONOS_SUPPORT_INT64 1
|
||||||
|
#define KHRONOS_SUPPORT_FLOAT 1
|
||||||
|
|
||||||
|
#elif defined(__VMS ) || defined(__sgi)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Using <inttypes.h>
|
||||||
|
*/
|
||||||
|
#include <inttypes.h>
|
||||||
|
typedef int32_t khronos_int32_t;
|
||||||
|
typedef uint32_t khronos_uint32_t;
|
||||||
|
typedef int64_t khronos_int64_t;
|
||||||
|
typedef uint64_t khronos_uint64_t;
|
||||||
|
#define KHRONOS_SUPPORT_INT64 1
|
||||||
|
#define KHRONOS_SUPPORT_FLOAT 1
|
||||||
|
|
||||||
|
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Win32
|
||||||
|
*/
|
||||||
|
typedef __int32 khronos_int32_t;
|
||||||
|
typedef unsigned __int32 khronos_uint32_t;
|
||||||
|
typedef __int64 khronos_int64_t;
|
||||||
|
typedef unsigned __int64 khronos_uint64_t;
|
||||||
|
#define KHRONOS_SUPPORT_INT64 1
|
||||||
|
#define KHRONOS_SUPPORT_FLOAT 1
|
||||||
|
|
||||||
|
#elif defined(__sun__) || defined(__digital__)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sun or Digital
|
||||||
|
*/
|
||||||
|
typedef int khronos_int32_t;
|
||||||
|
typedef unsigned int khronos_uint32_t;
|
||||||
|
#if defined(__arch64__) || defined(_LP64)
|
||||||
|
typedef long int khronos_int64_t;
|
||||||
|
typedef unsigned long int khronos_uint64_t;
|
||||||
|
#else
|
||||||
|
typedef long long int khronos_int64_t;
|
||||||
|
typedef unsigned long long int khronos_uint64_t;
|
||||||
|
#endif /* __arch64__ */
|
||||||
|
#define KHRONOS_SUPPORT_INT64 1
|
||||||
|
#define KHRONOS_SUPPORT_FLOAT 1
|
||||||
|
|
||||||
|
#elif 0
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hypothetical platform with no float or int64 support
|
||||||
|
*/
|
||||||
|
typedef int khronos_int32_t;
|
||||||
|
typedef unsigned int khronos_uint32_t;
|
||||||
|
#define KHRONOS_SUPPORT_INT64 0
|
||||||
|
#define KHRONOS_SUPPORT_FLOAT 0
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generic fallback
|
||||||
|
*/
|
||||||
|
#include <stdint.h>
|
||||||
|
typedef int32_t khronos_int32_t;
|
||||||
|
typedef uint32_t khronos_uint32_t;
|
||||||
|
typedef int64_t khronos_int64_t;
|
||||||
|
typedef uint64_t khronos_uint64_t;
|
||||||
|
#define KHRONOS_SUPPORT_INT64 1
|
||||||
|
#define KHRONOS_SUPPORT_FLOAT 1
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Types that are (so far) the same on all platforms
|
||||||
|
*/
|
||||||
|
typedef signed char khronos_int8_t;
|
||||||
|
typedef unsigned char khronos_uint8_t;
|
||||||
|
typedef signed short int khronos_int16_t;
|
||||||
|
typedef unsigned short int khronos_uint16_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Types that differ between LLP64 and LP64 architectures - in LLP64,
|
||||||
|
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
|
||||||
|
* to be the only LLP64 architecture in current use.
|
||||||
|
*/
|
||||||
|
#ifdef _WIN64
|
||||||
|
typedef signed long long int khronos_intptr_t;
|
||||||
|
typedef unsigned long long int khronos_uintptr_t;
|
||||||
|
typedef signed long long int khronos_ssize_t;
|
||||||
|
typedef unsigned long long int khronos_usize_t;
|
||||||
|
#else
|
||||||
|
typedef signed long int khronos_intptr_t;
|
||||||
|
typedef unsigned long int khronos_uintptr_t;
|
||||||
|
typedef signed long int khronos_ssize_t;
|
||||||
|
typedef unsigned long int khronos_usize_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if KHRONOS_SUPPORT_FLOAT
|
||||||
|
/*
|
||||||
|
* Float type
|
||||||
|
*/
|
||||||
|
typedef float khronos_float_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if KHRONOS_SUPPORT_INT64
|
||||||
|
/* Time types
|
||||||
|
*
|
||||||
|
* These types can be used to represent a time interval in nanoseconds or
|
||||||
|
* an absolute Unadjusted System Time. Unadjusted System Time is the number
|
||||||
|
* of nanoseconds since some arbitrary system event (e.g. since the last
|
||||||
|
* time the system booted). The Unadjusted System Time is an unsigned
|
||||||
|
* 64 bit value that wraps back to 0 every 584 years. Time intervals
|
||||||
|
* may be either signed or unsigned.
|
||||||
|
*/
|
||||||
|
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
|
||||||
|
typedef khronos_int64_t khronos_stime_nanoseconds_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Dummy value used to pad enum types to 32 bits.
|
||||||
|
*/
|
||||||
|
#ifndef KHRONOS_MAX_ENUM
|
||||||
|
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Enumerated boolean type
|
||||||
|
*
|
||||||
|
* Values other than zero should be considered to be true. Therefore
|
||||||
|
* comparisons should not be made against KHRONOS_TRUE.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
KHRONOS_FALSE = 0,
|
||||||
|
KHRONOS_TRUE = 1,
|
||||||
|
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
|
||||||
|
} khronos_boolean_enum_t;
|
||||||
|
|
||||||
|
#endif /* __khrplatform_h_ */
|
||||||
2499
examples/ThirdPartyLibs/glad/glad.c
Normal file
2499
examples/ThirdPartyLibs/glad/glad.c
Normal file
File diff suppressed because it is too large
Load Diff
5208
examples/ThirdPartyLibs/glad/glad/glad.h
Normal file
5208
examples/ThirdPartyLibs/glad/glad/glad.h
Normal file
File diff suppressed because it is too large
Load Diff
574
examples/ThirdPartyLibs/glad/linmath.h
Normal file
574
examples/ThirdPartyLibs/glad/linmath.h
Normal file
@@ -0,0 +1,574 @@
|
|||||||
|
#ifndef LINMATH_H
|
||||||
|
#define LINMATH_H
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define inline __inline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LINMATH_H_DEFINE_VEC(n) \
|
||||||
|
typedef float vec##n[n]; \
|
||||||
|
static inline void vec##n##_add(vec##n r, vec##n const a, vec##n const b) \
|
||||||
|
{ \
|
||||||
|
int i; \
|
||||||
|
for(i=0; i<n; ++i) \
|
||||||
|
r[i] = a[i] + b[i]; \
|
||||||
|
} \
|
||||||
|
static inline void vec##n##_sub(vec##n r, vec##n const a, vec##n const b) \
|
||||||
|
{ \
|
||||||
|
int i; \
|
||||||
|
for(i=0; i<n; ++i) \
|
||||||
|
r[i] = a[i] - b[i]; \
|
||||||
|
} \
|
||||||
|
static inline void vec##n##_scale(vec##n r, vec##n const v, float const s) \
|
||||||
|
{ \
|
||||||
|
int i; \
|
||||||
|
for(i=0; i<n; ++i) \
|
||||||
|
r[i] = v[i] * s; \
|
||||||
|
} \
|
||||||
|
static inline float vec##n##_mul_inner(vec##n const a, vec##n const b) \
|
||||||
|
{ \
|
||||||
|
float p = 0.; \
|
||||||
|
int i; \
|
||||||
|
for(i=0; i<n; ++i) \
|
||||||
|
p += b[i]*a[i]; \
|
||||||
|
return p; \
|
||||||
|
} \
|
||||||
|
static inline float vec##n##_len(vec##n const v) \
|
||||||
|
{ \
|
||||||
|
return (float) sqrt(vec##n##_mul_inner(v,v)); \
|
||||||
|
} \
|
||||||
|
static inline void vec##n##_norm(vec##n r, vec##n const v) \
|
||||||
|
{ \
|
||||||
|
float k = 1.f / vec##n##_len(v); \
|
||||||
|
vec##n##_scale(r, v, k); \
|
||||||
|
}
|
||||||
|
|
||||||
|
LINMATH_H_DEFINE_VEC(2)
|
||||||
|
LINMATH_H_DEFINE_VEC(3)
|
||||||
|
LINMATH_H_DEFINE_VEC(4)
|
||||||
|
|
||||||
|
static inline void vec3_mul_cross(vec3 r, vec3 const a, vec3 const b)
|
||||||
|
{
|
||||||
|
r[0] = a[1]*b[2] - a[2]*b[1];
|
||||||
|
r[1] = a[2]*b[0] - a[0]*b[2];
|
||||||
|
r[2] = a[0]*b[1] - a[1]*b[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void vec3_reflect(vec3 r, vec3 const v, vec3 const n)
|
||||||
|
{
|
||||||
|
float p = 2.f*vec3_mul_inner(v, n);
|
||||||
|
int i;
|
||||||
|
for(i=0;i<3;++i)
|
||||||
|
r[i] = v[i] - p*n[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void vec4_mul_cross(vec4 r, vec4 a, vec4 b)
|
||||||
|
{
|
||||||
|
r[0] = a[1]*b[2] - a[2]*b[1];
|
||||||
|
r[1] = a[2]*b[0] - a[0]*b[2];
|
||||||
|
r[2] = a[0]*b[1] - a[1]*b[0];
|
||||||
|
r[3] = 1.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void vec4_reflect(vec4 r, vec4 v, vec4 n)
|
||||||
|
{
|
||||||
|
float p = 2.f*vec4_mul_inner(v, n);
|
||||||
|
int i;
|
||||||
|
for(i=0;i<4;++i)
|
||||||
|
r[i] = v[i] - p*n[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef vec4 mat4x4[4];
|
||||||
|
static inline void mat4x4_identity(mat4x4 M)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
for(i=0; i<4; ++i)
|
||||||
|
for(j=0; j<4; ++j)
|
||||||
|
M[i][j] = i==j ? 1.f : 0.f;
|
||||||
|
}
|
||||||
|
static inline void mat4x4_dup(mat4x4 M, mat4x4 N)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
for(i=0; i<4; ++i)
|
||||||
|
for(j=0; j<4; ++j)
|
||||||
|
M[i][j] = N[i][j];
|
||||||
|
}
|
||||||
|
static inline void mat4x4_row(vec4 r, mat4x4 M, int i)
|
||||||
|
{
|
||||||
|
int k;
|
||||||
|
for(k=0; k<4; ++k)
|
||||||
|
r[k] = M[k][i];
|
||||||
|
}
|
||||||
|
static inline void mat4x4_col(vec4 r, mat4x4 M, int i)
|
||||||
|
{
|
||||||
|
int k;
|
||||||
|
for(k=0; k<4; ++k)
|
||||||
|
r[k] = M[i][k];
|
||||||
|
}
|
||||||
|
static inline void mat4x4_transpose(mat4x4 M, mat4x4 N)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
for(j=0; j<4; ++j)
|
||||||
|
for(i=0; i<4; ++i)
|
||||||
|
M[i][j] = N[j][i];
|
||||||
|
}
|
||||||
|
static inline void mat4x4_add(mat4x4 M, mat4x4 a, mat4x4 b)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i=0; i<4; ++i)
|
||||||
|
vec4_add(M[i], a[i], b[i]);
|
||||||
|
}
|
||||||
|
static inline void mat4x4_sub(mat4x4 M, mat4x4 a, mat4x4 b)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i=0; i<4; ++i)
|
||||||
|
vec4_sub(M[i], a[i], b[i]);
|
||||||
|
}
|
||||||
|
static inline void mat4x4_scale(mat4x4 M, mat4x4 a, float k)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i=0; i<4; ++i)
|
||||||
|
vec4_scale(M[i], a[i], k);
|
||||||
|
}
|
||||||
|
static inline void mat4x4_scale_aniso(mat4x4 M, mat4x4 a, float x, float y, float z)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
vec4_scale(M[0], a[0], x);
|
||||||
|
vec4_scale(M[1], a[1], y);
|
||||||
|
vec4_scale(M[2], a[2], z);
|
||||||
|
for(i = 0; i < 4; ++i) {
|
||||||
|
M[3][i] = a[3][i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static inline void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b)
|
||||||
|
{
|
||||||
|
mat4x4 temp;
|
||||||
|
int k, r, c;
|
||||||
|
for(c=0; c<4; ++c) for(r=0; r<4; ++r) {
|
||||||
|
temp[c][r] = 0.f;
|
||||||
|
for(k=0; k<4; ++k)
|
||||||
|
temp[c][r] += a[k][r] * b[c][k];
|
||||||
|
}
|
||||||
|
mat4x4_dup(M, temp);
|
||||||
|
}
|
||||||
|
static inline void mat4x4_mul_vec4(vec4 r, mat4x4 M, vec4 v)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
for(j=0; j<4; ++j) {
|
||||||
|
r[j] = 0.f;
|
||||||
|
for(i=0; i<4; ++i)
|
||||||
|
r[j] += M[i][j] * v[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static inline void mat4x4_translate(mat4x4 T, float x, float y, float z)
|
||||||
|
{
|
||||||
|
mat4x4_identity(T);
|
||||||
|
T[3][0] = x;
|
||||||
|
T[3][1] = y;
|
||||||
|
T[3][2] = z;
|
||||||
|
}
|
||||||
|
static inline void mat4x4_translate_in_place(mat4x4 M, float x, float y, float z)
|
||||||
|
{
|
||||||
|
vec4 t = {x, y, z, 0};
|
||||||
|
vec4 r;
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 4; ++i) {
|
||||||
|
mat4x4_row(r, M, i);
|
||||||
|
M[3][i] += vec4_mul_inner(r, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static inline void mat4x4_from_vec3_mul_outer(mat4x4 M, vec3 a, vec3 b)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
for(i=0; i<4; ++i) for(j=0; j<4; ++j)
|
||||||
|
M[i][j] = i<3 && j<3 ? a[i] * b[j] : 0.f;
|
||||||
|
}
|
||||||
|
static inline void mat4x4_rotate(mat4x4 R, mat4x4 M, float x, float y, float z, float angle)
|
||||||
|
{
|
||||||
|
float s = sinf(angle);
|
||||||
|
float c = cosf(angle);
|
||||||
|
vec3 u = {x, y, z};
|
||||||
|
|
||||||
|
if(vec3_len(u) > 1e-4) {
|
||||||
|
mat4x4 T, C, S = {{0}};
|
||||||
|
|
||||||
|
vec3_norm(u, u);
|
||||||
|
mat4x4_from_vec3_mul_outer(T, u, u);
|
||||||
|
|
||||||
|
S[1][2] = u[0];
|
||||||
|
S[2][1] = -u[0];
|
||||||
|
S[2][0] = u[1];
|
||||||
|
S[0][2] = -u[1];
|
||||||
|
S[0][1] = u[2];
|
||||||
|
S[1][0] = -u[2];
|
||||||
|
|
||||||
|
mat4x4_scale(S, S, s);
|
||||||
|
|
||||||
|
mat4x4_identity(C);
|
||||||
|
mat4x4_sub(C, C, T);
|
||||||
|
|
||||||
|
mat4x4_scale(C, C, c);
|
||||||
|
|
||||||
|
mat4x4_add(T, T, C);
|
||||||
|
mat4x4_add(T, T, S);
|
||||||
|
|
||||||
|
T[3][3] = 1.;
|
||||||
|
mat4x4_mul(R, M, T);
|
||||||
|
} else {
|
||||||
|
mat4x4_dup(R, M);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static inline void mat4x4_rotate_X(mat4x4 Q, mat4x4 M, float angle)
|
||||||
|
{
|
||||||
|
float s = sinf(angle);
|
||||||
|
float c = cosf(angle);
|
||||||
|
mat4x4 R = {
|
||||||
|
{1.f, 0.f, 0.f, 0.f},
|
||||||
|
{0.f, c, s, 0.f},
|
||||||
|
{0.f, -s, c, 0.f},
|
||||||
|
{0.f, 0.f, 0.f, 1.f}
|
||||||
|
};
|
||||||
|
mat4x4_mul(Q, M, R);
|
||||||
|
}
|
||||||
|
static inline void mat4x4_rotate_Y(mat4x4 Q, mat4x4 M, float angle)
|
||||||
|
{
|
||||||
|
float s = sinf(angle);
|
||||||
|
float c = cosf(angle);
|
||||||
|
mat4x4 R = {
|
||||||
|
{ c, 0.f, s, 0.f},
|
||||||
|
{ 0.f, 1.f, 0.f, 0.f},
|
||||||
|
{ -s, 0.f, c, 0.f},
|
||||||
|
{ 0.f, 0.f, 0.f, 1.f}
|
||||||
|
};
|
||||||
|
mat4x4_mul(Q, M, R);
|
||||||
|
}
|
||||||
|
static inline void mat4x4_rotate_Z(mat4x4 Q, mat4x4 M, float angle)
|
||||||
|
{
|
||||||
|
float s = sinf(angle);
|
||||||
|
float c = cosf(angle);
|
||||||
|
mat4x4 R = {
|
||||||
|
{ c, s, 0.f, 0.f},
|
||||||
|
{ -s, c, 0.f, 0.f},
|
||||||
|
{ 0.f, 0.f, 1.f, 0.f},
|
||||||
|
{ 0.f, 0.f, 0.f, 1.f}
|
||||||
|
};
|
||||||
|
mat4x4_mul(Q, M, R);
|
||||||
|
}
|
||||||
|
static inline void mat4x4_invert(mat4x4 T, mat4x4 M)
|
||||||
|
{
|
||||||
|
float idet;
|
||||||
|
float s[6];
|
||||||
|
float c[6];
|
||||||
|
s[0] = M[0][0]*M[1][1] - M[1][0]*M[0][1];
|
||||||
|
s[1] = M[0][0]*M[1][2] - M[1][0]*M[0][2];
|
||||||
|
s[2] = M[0][0]*M[1][3] - M[1][0]*M[0][3];
|
||||||
|
s[3] = M[0][1]*M[1][2] - M[1][1]*M[0][2];
|
||||||
|
s[4] = M[0][1]*M[1][3] - M[1][1]*M[0][3];
|
||||||
|
s[5] = M[0][2]*M[1][3] - M[1][2]*M[0][3];
|
||||||
|
|
||||||
|
c[0] = M[2][0]*M[3][1] - M[3][0]*M[2][1];
|
||||||
|
c[1] = M[2][0]*M[3][2] - M[3][0]*M[2][2];
|
||||||
|
c[2] = M[2][0]*M[3][3] - M[3][0]*M[2][3];
|
||||||
|
c[3] = M[2][1]*M[3][2] - M[3][1]*M[2][2];
|
||||||
|
c[4] = M[2][1]*M[3][3] - M[3][1]*M[2][3];
|
||||||
|
c[5] = M[2][2]*M[3][3] - M[3][2]*M[2][3];
|
||||||
|
|
||||||
|
/* Assumes it is invertible */
|
||||||
|
idet = 1.0f/( s[0]*c[5]-s[1]*c[4]+s[2]*c[3]+s[3]*c[2]-s[4]*c[1]+s[5]*c[0] );
|
||||||
|
|
||||||
|
T[0][0] = ( M[1][1] * c[5] - M[1][2] * c[4] + M[1][3] * c[3]) * idet;
|
||||||
|
T[0][1] = (-M[0][1] * c[5] + M[0][2] * c[4] - M[0][3] * c[3]) * idet;
|
||||||
|
T[0][2] = ( M[3][1] * s[5] - M[3][2] * s[4] + M[3][3] * s[3]) * idet;
|
||||||
|
T[0][3] = (-M[2][1] * s[5] + M[2][2] * s[4] - M[2][3] * s[3]) * idet;
|
||||||
|
|
||||||
|
T[1][0] = (-M[1][0] * c[5] + M[1][2] * c[2] - M[1][3] * c[1]) * idet;
|
||||||
|
T[1][1] = ( M[0][0] * c[5] - M[0][2] * c[2] + M[0][3] * c[1]) * idet;
|
||||||
|
T[1][2] = (-M[3][0] * s[5] + M[3][2] * s[2] - M[3][3] * s[1]) * idet;
|
||||||
|
T[1][3] = ( M[2][0] * s[5] - M[2][2] * s[2] + M[2][3] * s[1]) * idet;
|
||||||
|
|
||||||
|
T[2][0] = ( M[1][0] * c[4] - M[1][1] * c[2] + M[1][3] * c[0]) * idet;
|
||||||
|
T[2][1] = (-M[0][0] * c[4] + M[0][1] * c[2] - M[0][3] * c[0]) * idet;
|
||||||
|
T[2][2] = ( M[3][0] * s[4] - M[3][1] * s[2] + M[3][3] * s[0]) * idet;
|
||||||
|
T[2][3] = (-M[2][0] * s[4] + M[2][1] * s[2] - M[2][3] * s[0]) * idet;
|
||||||
|
|
||||||
|
T[3][0] = (-M[1][0] * c[3] + M[1][1] * c[1] - M[1][2] * c[0]) * idet;
|
||||||
|
T[3][1] = ( M[0][0] * c[3] - M[0][1] * c[1] + M[0][2] * c[0]) * idet;
|
||||||
|
T[3][2] = (-M[3][0] * s[3] + M[3][1] * s[1] - M[3][2] * s[0]) * idet;
|
||||||
|
T[3][3] = ( M[2][0] * s[3] - M[2][1] * s[1] + M[2][2] * s[0]) * idet;
|
||||||
|
}
|
||||||
|
static inline void mat4x4_orthonormalize(mat4x4 R, mat4x4 M)
|
||||||
|
{
|
||||||
|
float s = 1.;
|
||||||
|
vec3 h;
|
||||||
|
|
||||||
|
mat4x4_dup(R, M);
|
||||||
|
vec3_norm(R[2], R[2]);
|
||||||
|
|
||||||
|
s = vec3_mul_inner(R[1], R[2]);
|
||||||
|
vec3_scale(h, R[2], s);
|
||||||
|
vec3_sub(R[1], R[1], h);
|
||||||
|
vec3_norm(R[2], R[2]);
|
||||||
|
|
||||||
|
s = vec3_mul_inner(R[1], R[2]);
|
||||||
|
vec3_scale(h, R[2], s);
|
||||||
|
vec3_sub(R[1], R[1], h);
|
||||||
|
vec3_norm(R[1], R[1]);
|
||||||
|
|
||||||
|
s = vec3_mul_inner(R[0], R[1]);
|
||||||
|
vec3_scale(h, R[1], s);
|
||||||
|
vec3_sub(R[0], R[0], h);
|
||||||
|
vec3_norm(R[0], R[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void mat4x4_frustum(mat4x4 M, float l, float r, float b, float t, float n, float f)
|
||||||
|
{
|
||||||
|
M[0][0] = 2.f*n/(r-l);
|
||||||
|
M[0][1] = M[0][2] = M[0][3] = 0.f;
|
||||||
|
|
||||||
|
M[1][1] = 2.f*n/(t-b);
|
||||||
|
M[1][0] = M[1][2] = M[1][3] = 0.f;
|
||||||
|
|
||||||
|
M[2][0] = (r+l)/(r-l);
|
||||||
|
M[2][1] = (t+b)/(t-b);
|
||||||
|
M[2][2] = -(f+n)/(f-n);
|
||||||
|
M[2][3] = -1.f;
|
||||||
|
|
||||||
|
M[3][2] = -2.f*(f*n)/(f-n);
|
||||||
|
M[3][0] = M[3][1] = M[3][3] = 0.f;
|
||||||
|
}
|
||||||
|
static inline void mat4x4_ortho(mat4x4 M, float l, float r, float b, float t, float n, float f)
|
||||||
|
{
|
||||||
|
M[0][0] = 2.f/(r-l);
|
||||||
|
M[0][1] = M[0][2] = M[0][3] = 0.f;
|
||||||
|
|
||||||
|
M[1][1] = 2.f/(t-b);
|
||||||
|
M[1][0] = M[1][2] = M[1][3] = 0.f;
|
||||||
|
|
||||||
|
M[2][2] = -2.f/(f-n);
|
||||||
|
M[2][0] = M[2][1] = M[2][3] = 0.f;
|
||||||
|
|
||||||
|
M[3][0] = -(r+l)/(r-l);
|
||||||
|
M[3][1] = -(t+b)/(t-b);
|
||||||
|
M[3][2] = -(f+n)/(f-n);
|
||||||
|
M[3][3] = 1.f;
|
||||||
|
}
|
||||||
|
static inline void mat4x4_perspective(mat4x4 m, float y_fov, float aspect, float n, float f)
|
||||||
|
{
|
||||||
|
/* NOTE: Degrees are an unhandy unit to work with.
|
||||||
|
* linmath.h uses radians for everything! */
|
||||||
|
float const a = 1.f / (float) tan(y_fov / 2.f);
|
||||||
|
|
||||||
|
m[0][0] = a / aspect;
|
||||||
|
m[0][1] = 0.f;
|
||||||
|
m[0][2] = 0.f;
|
||||||
|
m[0][3] = 0.f;
|
||||||
|
|
||||||
|
m[1][0] = 0.f;
|
||||||
|
m[1][1] = a;
|
||||||
|
m[1][2] = 0.f;
|
||||||
|
m[1][3] = 0.f;
|
||||||
|
|
||||||
|
m[2][0] = 0.f;
|
||||||
|
m[2][1] = 0.f;
|
||||||
|
m[2][2] = -((f + n) / (f - n));
|
||||||
|
m[2][3] = -1.f;
|
||||||
|
|
||||||
|
m[3][0] = 0.f;
|
||||||
|
m[3][1] = 0.f;
|
||||||
|
m[3][2] = -((2.f * f * n) / (f - n));
|
||||||
|
m[3][3] = 0.f;
|
||||||
|
}
|
||||||
|
static inline void mat4x4_look_at(mat4x4 m, vec3 eye, vec3 center, vec3 up)
|
||||||
|
{
|
||||||
|
/* Adapted from Android's OpenGL Matrix.java. */
|
||||||
|
/* See the OpenGL GLUT documentation for gluLookAt for a description */
|
||||||
|
/* of the algorithm. We implement it in a straightforward way: */
|
||||||
|
|
||||||
|
/* TODO: The negation of of can be spared by swapping the order of
|
||||||
|
* operands in the following cross products in the right way. */
|
||||||
|
vec3 f;
|
||||||
|
vec3 s;
|
||||||
|
vec3 t;
|
||||||
|
|
||||||
|
vec3_sub(f, center, eye);
|
||||||
|
vec3_norm(f, f);
|
||||||
|
|
||||||
|
vec3_mul_cross(s, f, up);
|
||||||
|
vec3_norm(s, s);
|
||||||
|
|
||||||
|
vec3_mul_cross(t, s, f);
|
||||||
|
|
||||||
|
m[0][0] = s[0];
|
||||||
|
m[0][1] = t[0];
|
||||||
|
m[0][2] = -f[0];
|
||||||
|
m[0][3] = 0.f;
|
||||||
|
|
||||||
|
m[1][0] = s[1];
|
||||||
|
m[1][1] = t[1];
|
||||||
|
m[1][2] = -f[1];
|
||||||
|
m[1][3] = 0.f;
|
||||||
|
|
||||||
|
m[2][0] = s[2];
|
||||||
|
m[2][1] = t[2];
|
||||||
|
m[2][2] = -f[2];
|
||||||
|
m[2][3] = 0.f;
|
||||||
|
|
||||||
|
m[3][0] = 0.f;
|
||||||
|
m[3][1] = 0.f;
|
||||||
|
m[3][2] = 0.f;
|
||||||
|
m[3][3] = 1.f;
|
||||||
|
|
||||||
|
mat4x4_translate_in_place(m, -eye[0], -eye[1], -eye[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef float quat[4];
|
||||||
|
static inline void quat_identity(quat q)
|
||||||
|
{
|
||||||
|
q[0] = q[1] = q[2] = 0.f;
|
||||||
|
q[3] = 1.f;
|
||||||
|
}
|
||||||
|
static inline void quat_add(quat r, quat a, quat b)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i=0; i<4; ++i)
|
||||||
|
r[i] = a[i] + b[i];
|
||||||
|
}
|
||||||
|
static inline void quat_sub(quat r, quat a, quat b)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i=0; i<4; ++i)
|
||||||
|
r[i] = a[i] - b[i];
|
||||||
|
}
|
||||||
|
static inline void quat_mul(quat r, quat p, quat q)
|
||||||
|
{
|
||||||
|
vec3 w;
|
||||||
|
vec3_mul_cross(r, p, q);
|
||||||
|
vec3_scale(w, p, q[3]);
|
||||||
|
vec3_add(r, r, w);
|
||||||
|
vec3_scale(w, q, p[3]);
|
||||||
|
vec3_add(r, r, w);
|
||||||
|
r[3] = p[3]*q[3] - vec3_mul_inner(p, q);
|
||||||
|
}
|
||||||
|
static inline void quat_scale(quat r, quat v, float s)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i=0; i<4; ++i)
|
||||||
|
r[i] = v[i] * s;
|
||||||
|
}
|
||||||
|
static inline float quat_inner_product(quat a, quat b)
|
||||||
|
{
|
||||||
|
float p = 0.f;
|
||||||
|
int i;
|
||||||
|
for(i=0; i<4; ++i)
|
||||||
|
p += b[i]*a[i];
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
static inline void quat_conj(quat r, quat q)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i=0; i<3; ++i)
|
||||||
|
r[i] = -q[i];
|
||||||
|
r[3] = q[3];
|
||||||
|
}
|
||||||
|
static inline void quat_rotate(quat r, float angle, vec3 axis) {
|
||||||
|
int i;
|
||||||
|
vec3 v;
|
||||||
|
vec3_scale(v, axis, sinf(angle / 2));
|
||||||
|
for(i=0; i<3; ++i)
|
||||||
|
r[i] = v[i];
|
||||||
|
r[3] = cosf(angle / 2);
|
||||||
|
}
|
||||||
|
#define quat_norm vec4_norm
|
||||||
|
static inline void quat_mul_vec3(vec3 r, quat q, vec3 v)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Method by Fabian 'ryg' Giessen (of Farbrausch)
|
||||||
|
t = 2 * cross(q.xyz, v)
|
||||||
|
v' = v + q.w * t + cross(q.xyz, t)
|
||||||
|
*/
|
||||||
|
vec3 t = {q[0], q[1], q[2]};
|
||||||
|
vec3 u = {q[0], q[1], q[2]};
|
||||||
|
|
||||||
|
vec3_mul_cross(t, t, v);
|
||||||
|
vec3_scale(t, t, 2);
|
||||||
|
|
||||||
|
vec3_mul_cross(u, u, t);
|
||||||
|
vec3_scale(t, t, q[3]);
|
||||||
|
|
||||||
|
vec3_add(r, v, t);
|
||||||
|
vec3_add(r, r, u);
|
||||||
|
}
|
||||||
|
static inline void mat4x4_from_quat(mat4x4 M, quat q)
|
||||||
|
{
|
||||||
|
float a = q[3];
|
||||||
|
float b = q[0];
|
||||||
|
float c = q[1];
|
||||||
|
float d = q[2];
|
||||||
|
float a2 = a*a;
|
||||||
|
float b2 = b*b;
|
||||||
|
float c2 = c*c;
|
||||||
|
float d2 = d*d;
|
||||||
|
|
||||||
|
M[0][0] = a2 + b2 - c2 - d2;
|
||||||
|
M[0][1] = 2.f*(b*c + a*d);
|
||||||
|
M[0][2] = 2.f*(b*d - a*c);
|
||||||
|
M[0][3] = 0.f;
|
||||||
|
|
||||||
|
M[1][0] = 2*(b*c - a*d);
|
||||||
|
M[1][1] = a2 - b2 + c2 - d2;
|
||||||
|
M[1][2] = 2.f*(c*d + a*b);
|
||||||
|
M[1][3] = 0.f;
|
||||||
|
|
||||||
|
M[2][0] = 2.f*(b*d + a*c);
|
||||||
|
M[2][1] = 2.f*(c*d - a*b);
|
||||||
|
M[2][2] = a2 - b2 - c2 + d2;
|
||||||
|
M[2][3] = 0.f;
|
||||||
|
|
||||||
|
M[3][0] = M[3][1] = M[3][2] = 0.f;
|
||||||
|
M[3][3] = 1.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void mat4x4o_mul_quat(mat4x4 R, mat4x4 M, quat q)
|
||||||
|
{
|
||||||
|
/* XXX: The way this is written only works for othogonal matrices. */
|
||||||
|
/* TODO: Take care of non-orthogonal case. */
|
||||||
|
quat_mul_vec3(R[0], q, M[0]);
|
||||||
|
quat_mul_vec3(R[1], q, M[1]);
|
||||||
|
quat_mul_vec3(R[2], q, M[2]);
|
||||||
|
|
||||||
|
R[3][0] = R[3][1] = R[3][2] = 0.f;
|
||||||
|
R[3][3] = 1.f;
|
||||||
|
}
|
||||||
|
static inline void quat_from_mat4x4(quat q, mat4x4 M)
|
||||||
|
{
|
||||||
|
float r=0.f;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
int perm[] = { 0, 1, 2, 0, 1 };
|
||||||
|
int *p = perm;
|
||||||
|
|
||||||
|
for(i = 0; i<3; i++) {
|
||||||
|
float m = M[i][i];
|
||||||
|
if( m < r )
|
||||||
|
continue;
|
||||||
|
m = r;
|
||||||
|
p = &perm[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
r = (float) sqrt(1.f + M[p[0]][p[0]] - M[p[1]][p[1]] - M[p[2]][p[2]] );
|
||||||
|
|
||||||
|
if(r < 1e-6) {
|
||||||
|
q[0] = 1.f;
|
||||||
|
q[1] = q[2] = q[3] = 0.f;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
q[0] = r/2.f;
|
||||||
|
q[1] = (M[p[0]][p[1]] - M[p[1]][p[0]])/(2.f*r);
|
||||||
|
q[2] = (M[p[2]][p[0]] - M[p[0]][p[2]])/(2.f*r);
|
||||||
|
q[3] = (M[p[2]][p[1]] - M[p[1]][p[2]])/(2.f*r);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
3113
examples/pybullet/unity3d/autogen/NativeMethods.cs
Normal file
3113
examples/pybullet/unity3d/autogen/NativeMethods.cs
Normal file
File diff suppressed because it is too large
Load Diff
86
examples/pybullet/unity3d/examples/NewBehaviourScript.cs
Normal file
86
examples/pybullet/unity3d/examples/NewBehaviourScript.cs
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
|
||||||
|
|
||||||
|
|
||||||
|
public class NewBehaviourScript : MonoBehaviour {
|
||||||
|
|
||||||
|
[System.Runtime.InteropServices.DllImportAttribute("pybullet_vs2010_x64_release.dll", EntryPoint = "b3ConnectSharedMemory")]
|
||||||
|
public static extern System.IntPtr b3ConnectSharedMemory(int key);
|
||||||
|
|
||||||
|
[System.Runtime.InteropServices.DllImportAttribute("pybullet_vs2010_x64_release.dll", EntryPoint = "b3CreateInProcessPhysicsServerAndConnect")]
|
||||||
|
public static extern System.IntPtr b3CreateInProcessPhysicsServerAndConnect(int argc, ref System.IntPtr argv);
|
||||||
|
|
||||||
|
[System.Runtime.InteropServices.DllImportAttribute("pybullet_vs2010_x64_release.dll", EntryPoint = "b3InitStepSimulationCommand")]
|
||||||
|
public static extern System.IntPtr b3InitStepSimulationCommand(IntPtr physClient);
|
||||||
|
|
||||||
|
|
||||||
|
[System.Runtime.InteropServices.DllImportAttribute("pybullet_vs2010_x64_release.dll", EntryPoint = "b3LoadUrdfCommandInit")]
|
||||||
|
public static extern System.IntPtr b3LoadUrdfCommandInit(IntPtr physClient, [System.Runtime.InteropServices.InAttribute()] [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)] string urdfFileName);
|
||||||
|
|
||||||
|
[System.Runtime.InteropServices.DllImportAttribute("pybullet_vs2010_x64_release.dll", EntryPoint = "b3InitResetSimulationCommand")]
|
||||||
|
public static extern System.IntPtr b3InitResetSimulationCommand(IntPtr physClient);
|
||||||
|
|
||||||
|
[System.Runtime.InteropServices.DllImportAttribute("pybullet_vs2010_x64_release.dll", EntryPoint = "b3SubmitClientCommandAndWaitStatus")]
|
||||||
|
public static extern System.IntPtr b3SubmitClientCommandAndWaitStatus(IntPtr physClient, IntPtr commandHandle);
|
||||||
|
|
||||||
|
|
||||||
|
[DllImport("TestCppPlug.dll")]
|
||||||
|
static extern int Add(int a, int b);
|
||||||
|
|
||||||
|
[DllImport("TestCppPlug.dll")]
|
||||||
|
static extern int CallMe(Action<int> action);
|
||||||
|
|
||||||
|
[DllImport("TestCppPlug.dll")]
|
||||||
|
static extern IntPtr CreateSharedAPI(int id);
|
||||||
|
|
||||||
|
[DllImport("TestCppPlug.dll")]
|
||||||
|
static extern int GetMyIdPlusTen(IntPtr api);
|
||||||
|
|
||||||
|
[DllImport("TestCppPlug.dll")]
|
||||||
|
static extern void DeleteSharedAPI(IntPtr api);
|
||||||
|
|
||||||
|
private void IWasCalled(int value)
|
||||||
|
{
|
||||||
|
text.text = value.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
Text text;
|
||||||
|
IntPtr sharedAPI;
|
||||||
|
IntPtr pybullet;
|
||||||
|
|
||||||
|
// Use this for initialization
|
||||||
|
void Start () {
|
||||||
|
text = GetComponent<Text>();
|
||||||
|
CallMe(IWasCalled);
|
||||||
|
sharedAPI = CreateSharedAPI(30);
|
||||||
|
|
||||||
|
IntPtr pybullet = b3ConnectSharedMemory(12347);
|
||||||
|
IntPtr cmd = b3InitResetSimulationCommand(pybullet);
|
||||||
|
IntPtr status = b3SubmitClientCommandAndWaitStatus(pybullet, cmd);
|
||||||
|
cmd = b3LoadUrdfCommandInit(pybullet, "plane.urdf");
|
||||||
|
status = b3SubmitClientCommandAndWaitStatus(pybullet, cmd);
|
||||||
|
//IntPtr clientPtr = b3CreateInProcessPhysicsServerAndConnect(0, ref ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update () {
|
||||||
|
IntPtr cmd = b3InitStepSimulationCommand(pybullet);
|
||||||
|
IntPtr status = b3SubmitClientCommandAndWaitStatus(pybullet, cmd);
|
||||||
|
|
||||||
|
//System.IO.Directory.GetCurrentDirectory().ToString();//
|
||||||
|
//text.text = Add(4, 5).ToString();
|
||||||
|
text.text = UnityEngine.Random.Range(0f, 1f).ToString();// GetMyIdPlusTen(sharedAPI).ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDestroy()
|
||||||
|
{
|
||||||
|
|
||||||
|
DeleteSharedAPI(sharedAPI);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6197b3a0389e92c47b7d8698e5f61f06
|
||||||
|
timeCreated: 1505961790
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
33
examples/pybullet/unity3d/readme.txt
Normal file
33
examples/pybullet/unity3d/readme.txt
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
Quick prototype to connect Unity 3D to pybullet
|
||||||
|
|
||||||
|
Generate C# Native Methods using the Microsoft PInvoke Signature Toolkit:
|
||||||
|
|
||||||
|
sigimp.exe /lang:cs e:\develop\bullet3\examples\SharedMemory\PhysicsClientC_API.h
|
||||||
|
|
||||||
|
Add some #define B3_SHARED_API __declspec(dllexport) to the exported methods,
|
||||||
|
replace [3], [4], [16] by [] to get sigimp.exe working.
|
||||||
|
|
||||||
|
This generates autogen/NativeMethods.cs
|
||||||
|
|
||||||
|
Then put pybullet.dll in the right location, so Unity finds it.
|
||||||
|
|
||||||
|
NewBehaviourScript.cs is a 1 evening prototype that works within Unity 3D:
|
||||||
|
Create a connection to pybullet, reset the world, load a urdf at startup.
|
||||||
|
Step the simulation each Update.
|
||||||
|
|
||||||
|
Now the real work can start, converting Unity objects to pybullet,
|
||||||
|
pybullet robots to Unity, synchronizing the transforms each Update.
|
||||||
|
|
||||||
|
void Start () {
|
||||||
|
IntPtr pybullet = b3ConnectSharedMemory(12347);
|
||||||
|
IntPtr cmd = b3InitResetSimulationCommand(pybullet);
|
||||||
|
IntPtr status = b3SubmitClientCommandAndWaitStatus(pybullet, cmd);
|
||||||
|
cmd = b3LoadUrdfCommandInit(pybullet, "plane.urdf");
|
||||||
|
status = b3SubmitClientCommandAndWaitStatus(pybullet, cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update ()
|
||||||
|
{
|
||||||
|
IntPtr cmd = b3InitStepSimulationCommand(pybullet);
|
||||||
|
IntPtr status = b3SubmitClientCommandAndWaitStatus(pybullet, cmd);
|
||||||
|
}
|
||||||
@@ -9,6 +9,10 @@
|
|||||||
extern unsigned char OpenSansData[];
|
extern unsigned char OpenSansData[];
|
||||||
|
|
||||||
#include "Gwen/Renderers/OpenGL_DebugFont.h"
|
#include "Gwen/Renderers/OpenGL_DebugFont.h"
|
||||||
|
|
||||||
|
#ifdef B3_USE_GLFW
|
||||||
|
#include "OpenGLWindow/GLFWOpenGLWindow.h"
|
||||||
|
#else
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include "OpenGLWindow/MacOpenGLWindow.h"
|
#include "OpenGLWindow/MacOpenGLWindow.h"
|
||||||
#else
|
#else
|
||||||
@@ -21,7 +25,7 @@ extern unsigned char OpenSansData[];
|
|||||||
#include "OpenGLWindow/X11OpenGLWindow.h"
|
#include "OpenGLWindow/X11OpenGLWindow.h"
|
||||||
#endif //_WIN32
|
#endif //_WIN32
|
||||||
#endif//__APPLE__
|
#endif//__APPLE__
|
||||||
|
#endif //B3_USE_GLFW
|
||||||
#include "OpenGLWindow/opengl_fontstashcallbacks.h"
|
#include "OpenGLWindow/opengl_fontstashcallbacks.h"
|
||||||
#ifndef NO_OPENGL3
|
#ifndef NO_OPENGL3
|
||||||
#include "OpenGLWindow/GwenOpenGL3CoreRenderer.h"
|
#include "OpenGLWindow/GwenOpenGL3CoreRenderer.h"
|
||||||
@@ -341,11 +345,13 @@ int main()
|
|||||||
sprintf(title,"Gwen with OpenGL %d\n",wci.m_openglVersion);
|
sprintf(title,"Gwen with OpenGL %d\n",wci.m_openglVersion);
|
||||||
}
|
}
|
||||||
window->setWindowTitle(title);
|
window->setWindowTitle(title);
|
||||||
|
|
||||||
|
float retinaScale = window->getRetinaScale();
|
||||||
|
|
||||||
#ifndef NO_OPENGL3
|
#ifndef NO_OPENGL3
|
||||||
if (majorGlVersion>=3 && wci.m_openglVersion>=3)
|
if (majorGlVersion>=3 && wci.m_openglVersion>=3)
|
||||||
{
|
{
|
||||||
float retinaScale = 1.f;
|
#ifndef B3_USE_GLFW
|
||||||
|
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
//we need glewExperimental on Linux
|
//we need glewExperimental on Linux
|
||||||
@@ -353,7 +359,7 @@ int main()
|
|||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
glewInit();
|
glewInit();
|
||||||
#endif
|
#endif
|
||||||
|
#endif //B3_USE_GLFW
|
||||||
//we ned to call glGetError twice, because of some Ubuntu/Intel/OpenGL issue
|
//we ned to call glGetError twice, because of some Ubuntu/Intel/OpenGL issue
|
||||||
|
|
||||||
GLuint err = glGetError();
|
GLuint err = glGetError();
|
||||||
@@ -361,8 +367,6 @@ int main()
|
|||||||
assert(err==GL_NO_ERROR);
|
assert(err==GL_NO_ERROR);
|
||||||
|
|
||||||
|
|
||||||
retinaScale = window->getRetinaScale();
|
|
||||||
|
|
||||||
primRenderer = new GLPrimitiveRenderer(sWidth,sHeight);
|
primRenderer = new GLPrimitiveRenderer(sWidth,sHeight);
|
||||||
|
|
||||||
sth_stash* font = initFont(primRenderer );
|
sth_stash* font = initFont(primRenderer );
|
||||||
@@ -374,7 +378,7 @@ int main()
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
//OpenGL 2.x
|
//OpenGL 2.x
|
||||||
gwenRenderer = new Gwen::Renderer::OpenGL_DebugFont();
|
gwenRenderer = new Gwen::Renderer::OpenGL_DebugFont(retinaScale);
|
||||||
|
|
||||||
|
|
||||||
skin.SetRender( gwenRenderer );
|
skin.SetRender( gwenRenderer );
|
||||||
|
|||||||
@@ -44,6 +44,9 @@
|
|||||||
"**.cpp",
|
"**.cpp",
|
||||||
"**.h",
|
"**.h",
|
||||||
}
|
}
|
||||||
|
files {
|
||||||
|
"../../examples/OpenGLWindow/GLFWOpenGLWindow.cpp",
|
||||||
|
}
|
||||||
if os.is("Windows") then
|
if os.is("Windows") then
|
||||||
files {
|
files {
|
||||||
"../../examples/OpenGLWindow/Win32OpenGLWindow.cpp",
|
"../../examples/OpenGLWindow/Win32OpenGLWindow.cpp",
|
||||||
@@ -62,7 +65,6 @@
|
|||||||
end
|
end
|
||||||
if os.is("MacOSX") then
|
if os.is("MacOSX") then
|
||||||
links{"Cocoa.framework"}
|
links{"Cocoa.framework"}
|
||||||
print("hello!")
|
|
||||||
files{
|
files{
|
||||||
"../../examples/OpenGLWindow/MacOpenGLWindow.cpp",
|
"../../examples/OpenGLWindow/MacOpenGLWindow.cpp",
|
||||||
"../../examples/OpenGLWindow/MacOpenGLWindow.h",
|
"../../examples/OpenGLWindow/MacOpenGLWindow.h",
|
||||||
|
|||||||
Reference in New Issue
Block a user