Replaced OpenGL bullet debug view with irrlicht bullet debug view.

Debug view can now be switch on and off during a race (ctl-F11),
but currenlty does not display as much information as the 
original debug view (more to be implemented here).
Removed glut dependency.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4794 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-02-22 12:02:13 +00:00
parent 83b5de120b
commit f41150eae7
37 changed files with 213 additions and 4351 deletions

View File

@ -90,7 +90,7 @@ case "${host}" in
AC_DEFINE([WIN32], 1, [Define for Win32 platforms])
AC_DEFINE([NOMINMAX], 1, [Define for Win32 platforms])
opengl_LIBS="-lglut32 -lglu32 -lopengl32 -luser32 -lgdi32 -lm -lwinmm"
opengl_LIBS="-lopengl32 -luser32 -lgdi32 -lm -lwinmm"
joystick_LIBS="$joystick_LIBS -lwinmm"
LDFLAGS="$LDFLAGS -mwindows"
@ -313,58 +313,13 @@ if test x$have_svnversion != xno; then
AC_DEFINE_UNQUOTED([SVNVERSION],"$SVNVERSION",["SVN revision number"])
fi
# ==============================================
# Glut (optional), used by bullet debugging only
# ==============================================
save_LIBS=$LIBS
save_LDFLAGS=$LDFLAGS
save_CXXFLAGS=$CXXFLAGS
case "${host}" in
*darwin*|*macosx*)
# Apparently -framework is needed for include files and libraries
CXXFLAGS="$CXXFLAGS -framework GLUT"
LDFLAGS="$LDFLAGS -framework GLUT"
esac
AC_SEARCH_LIBS(glutInit, [glut], have_glut_lib=yes)
if test x$have_glut_lib = xyes; then
# Apple has the headers in GLUT/glut.h instead of GL/glut.h
AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h], have_glut_hdr=yes)
fi
if test x$have_glut_hdr = xyes; then
AC_DEFINE(HAVE_GLUT)
SUMMARY="$SUMMARY\nGlut found, enabling optional bullet debug"
else
SUMMARY="$SUMMARY\nNo glut found, disabling bullet debug"
# Remove the unnecessary -framework GLUT on Macs (no impact
# of this on any other platforms)
CXXFLAGS=$save_CSSFLAGS
LDFLAGS=$save_LDFLAGS
fi
case "${host}" in
*darwin*|*macosx*)
glut_LIBS="$LIBS"
;;
*)
glut_LIBS="$LIBS -lGLU"
;;
esac
LIBS=$save_LIBS
# ==============
# Bullet physics
# ==============
AC_DEFINE([BT_NO_PROFILE], [], [Disable bullet internal profiling])
SUMMARY="$SUMMARY\nUsing bullet physics."
BULLETTREE="src/bullet"
bullet_LIBS=""
if test x$have_glut_hdr = xyes; then
bullet_LIBS="-Lbullet/Demos/OpenGL -lbulletopenglsupport"
fi
bullet_LIBS="$bullet_LIBS -Lbullet/src -lbulletdynamics -lbulletcollision -lbulletmath"
bullet_LIBS="-Lbullet/src -lbulletdynamics -lbulletcollision -lbulletmath"
# ====
@ -410,7 +365,6 @@ AC_SUBST(enet_LIBS)
AC_SUBST(opengl_LIBS)
AC_SUBST(openal_LIBS)
AC_SUBST(oggvorbis_LIBS)
AC_SUBST(glut_LIBS)
AC_SUBST(BULLETTREE)
AC_SUBST(ENETTREE)

View File

@ -227,6 +227,8 @@ supertuxkart_SOURCES = \
physics/btKart.hpp \
physics/btUprightConstraint.cpp \
physics/btUprightConstraint.hpp \
physics/irr_debug_drawer.cpp \
physics/irr_debug_drawer.hpp \
physics/kart_motion_state.hpp \
physics/physical_object.cpp \
physics/physical_object.hpp \
@ -354,7 +356,7 @@ supertuxkart_SOURCES = \
# Link in the specific gcc 4.1 bug work around
supertuxkart_LDADD = \
$(irrlicht_LIBS) $(bullet_LIBS) $(enet_LIBS) $(glut_LIBS) \
$(irrlicht_LIBS) $(bullet_LIBS) $(enet_LIBS) \
$(opengl_LIBS) $(openal_LIBS) $(oggvorbis_LIBS) \
$(INTLLIBS)

View File

@ -1,162 +0,0 @@
/**
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU bteral Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU bteral Public License for more details.
*
* You should have received a copy of the GNU bteral Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/**
* Copyright (C) 2001 NaN Technologies B.V.
*
* Implementation of the API of the OpenGL bitmap font library.
*/
#include "BMF_Api.h"
#include "BMF_BitmapFont.h"
#if BMF_INCLUDE_HELV10
extern BMF_FontData BMF_font_helv10;
static BMF_BitmapFont bmfHelv10(&BMF_font_helv10);
#endif // BMF_INCLUDE_HELV10
#if BMF_INCLUDE_HELV12
extern BMF_FontData BMF_font_helv12;
static BMF_BitmapFont bmfHelv12(&BMF_font_helv12);
#endif // BMF_INCLUDE_HELV12
#if BMF_INCLUDE_HELVB8
extern BMF_FontData BMF_font_helvb8;
static BMF_BitmapFont bmfHelvb8(&BMF_font_helvb8);
#endif // BMF_INCLUDE_HELVB8
#if BMF_INCLUDE_HELVB10
extern BMF_FontData BMF_font_helvb10;
static BMF_BitmapFont bmfHelvb10(&BMF_font_helvb10);
#endif // BMF_INCLUDE_HELVB10
#if BMF_INCLUDE_HELVB12
extern BMF_FontData BMF_font_helvb12;
static BMF_BitmapFont bmfHelvb12(&BMF_font_helvb12);
#endif // BMF_INCLUDE_HELVB12
#if BMF_INCLUDE_HELVB14
extern BMF_FontData BMF_font_helvb14;
static BMF_BitmapFont bmfHelvb14(&BMF_font_helvb14);
#endif // BMF_INCLUDE_HELVB14
#if BMF_INCLUDE_SCR12
extern BMF_FontData BMF_font_scr12;
static BMF_BitmapFont bmfScreen12(&BMF_font_scr12);
#endif // BMF_INCLUDE_SCR12
#if BMF_INCLUDE_SCR14
extern BMF_FontData BMF_font_scr14;
static BMF_BitmapFont bmfScreen14(&BMF_font_scr14);
#endif // BMF_INCLUDE_SCR14
#if BMF_INCLUDE_SCR15
extern BMF_FontData BMF_font_scr15;
static BMF_BitmapFont bmfScreen15(&BMF_font_scr15);
#endif // BMF_INCLUDE_SCR15
BMF_Font* BMF_GetFont(BMF_FontType font)
{
switch (font)
{
#if BMF_INCLUDE_HELV10
case BMF_kHelvetica10: return (BMF_Font*) &bmfHelv10;
#endif // BMF_INCLUDE_HELV10
#if BMF_INCLUDE_HELV12
case BMF_kHelvetica12: return (BMF_Font*) &bmfHelv12;
#endif // BMF_INCLUDE_HELV12
#if BMF_INCLUDE_HELVB8
case BMF_kHelveticaBold8: return (BMF_Font*) &bmfHelvb8;
#endif // BMF_INCLUDE_HELVB8
#if BMF_INCLUDE_HELVB10
case BMF_kHelveticaBold10: return (BMF_Font*) &bmfHelvb10;
#endif // BMF_INCLUDE_HELVB10
#if BMF_INCLUDE_HELVB12
case BMF_kHelveticaBold12: return (BMF_Font*) &bmfHelvb12;
#endif // BMF_INCLUDE_HELVB12
#if BMF_INCLUDE_HELVB14
case BMF_kHelveticaBold14: return (BMF_Font*) &bmfHelvb14;
#endif // BMF_INCLUDE_HELVB12
#if BMF_INCLUDE_SCR12
case BMF_kScreen12: return (BMF_Font*) &bmfScreen12;
#endif // BMF_INCLUDE_SCR12
#if BMF_INCLUDE_SCR14
case BMF_kScreen14: return (BMF_Font*) &bmfScreen14;
#endif // BMF_INCLUDE_SCR14
#if BMF_INCLUDE_SCR15
case BMF_kScreen15: return (BMF_Font*) &bmfScreen15;
#endif // BMF_INCLUDE_SCR15
default:
break;
}
return 0;
}
int BMF_DrawCharacter(BMF_Font* font, char c)
{
char str[2] = {c, '\0'};
return BMF_DrawString(font, str);
}
int BMF_DrawString(BMF_Font* font, const char* str)
{
if (!font) return 0;
((BMF_BitmapFont*)font)->drawString(str);
return 1;
}
int BMF_GetCharacterWidth(BMF_Font* font, char c)
{
char str[2] = {c, '\0'};
return BMF_GetStringWidth(font, str);
}
int BMF_GetStringWidth(BMF_Font* font, char* str)
{
if (!font) return 0;
return ((BMF_BitmapFont*)font)->getStringWidth(str);
}
void BMF_GetBoundingBox(BMF_Font* font, int *xmin_r, int *ymin_r, int *xmax_r, int *ymax_r)
{
if (!font) return;
((BMF_BitmapFont*)font)->getBoundingBox(*xmin_r, *ymin_r, *xmax_r, *ymax_r);
}
int BMF_GetFontTexture(BMF_Font* font) {
if (!font) return -1;
return ((BMF_BitmapFont*)font)->getTexture();
}
void BMF_DrawStringTexture(BMF_Font* font, char *string, float x, float y, float z) {
if (!font) return;
((BMF_BitmapFont*)font)->drawStringTexture(string, x, y, z);
}

View File

@ -1,128 +0,0 @@
/**
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU bteral Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU bteral Public License for more details.
*
* You should have received a copy of the GNU bteral Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/**
* Copyright (C) 2001 NaN Technologies B.V.
*
* API of the OpenGL bitmap font library.
* Currently draws fonts using the glBitmap routine.
* This implies that drawing speed is heavyly dependant on
* the 2D capabilities of the graphics card.
*/
#ifndef __BMF_API_H
#define __BMF_API_H
#ifdef __cplusplus
extern "C" {
#endif
#include "BMF_Fonts.h"
/**
* Returns the font for a given font type.
* @param font The font to retrieve.
* @return The font (or nil if not found).
*/
BMF_Font* BMF_GetFont(BMF_FontType font);
/**
* Draws a character at the current raster position.
* @param font The font to use.
* @param c The character to draw.
* @return Indication of success (0 == error).
*/
int BMF_DrawCharacter(BMF_Font* font, char c);
/**
* Draws a string at the current raster position.
* @param font The font to use.
* @param str The string to draw.
* @return Indication of success (0 == error).
*/
int BMF_DrawString(BMF_Font* font, const char* str);
/**
* Returns the width of a character in pixels.
* @param font The font to use.
* @param c The character.
* @return The length.
*/
int BMF_GetCharacterWidth(BMF_Font* font, char c);
/**
* Returns the width of a string of characters.
* @param font The font to use.
* @param str The string.
* @return The length.
*/
int BMF_GetStringWidth(BMF_Font* font, char* str);
/**
* Returns the bounding box of the font. The width and
* height represent the bounding box of the union of
* all glyps. The minimum and maximum values of the
* box represent the extent of the font and its positioning
* about the origin.
*/
void BMF_GetBoundingBox(BMF_Font* font, int *xmin_r, int *ymin_r, int *xmax_r, int *ymax_r);
/**
* Convert the given @a font to a texture, and return the GL texture
* ID of the texture. If the texture ID is bound, text can
* be drawn using the texture by calling drawStringTexture.
*
* @param font The font to create the texture from.
* @return The GL texture ID of the new texture, or -1 if unable
* to create.
*/
int BMF_GetFontTexture(BMF_Font* font);
/**
* Draw the given @a str at the point @a x, @a y, @a z, using
* texture coordinates. This assumes that an appropriate texture
* has been bound, see BMF_BitmapFont::getTexture(). The string
* is drawn along the positive X axis.
*
* @param font The font to draw with.
* @param string The c-string to draw.
* @param x The x coordinate to start drawing at.
* @param y The y coordinate to start drawing at.
* @param z The z coordinate to start drawing at.
*/
void BMF_DrawStringTexture(BMF_Font* font, char* string, float x, float y, float z);
#ifdef __cplusplus
}
#endif
#endif /* __BMF_API_H */

View File

@ -1,208 +0,0 @@
/**
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU bteral Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU bteral Public License for more details.
*
* You should have received a copy of the GNU bteral Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/**
* Copyright (C) 2001 NaN Technologies B.V.
*/
#include <string.h>
#if defined(WIN32) || defined(__APPLE__)
#ifdef WIN32
#if !defined(__CYGWIN32__)
#pragma warning(disable:4244)
#endif /* __CYGWIN32__ */
#include <windows.h>
#include <GL/gl.h>
#else // WIN32
// __APPLE__ is defined
#include <AGL/gl.h>
#endif // WIN32
#else // defined(WIN32) || defined(__APPLE__)
#include <GL/gl.h>
#endif // defined(WIN32) || defined(__APPLE__)
#include "BMF_BitmapFont.h"
BMF_BitmapFont::BMF_BitmapFont(BMF_FontData* fontData)
: m_fontData(fontData)
{
}
BMF_BitmapFont::~BMF_BitmapFont(void)
{
}
void BMF_BitmapFont::drawString(const char* str)
{
if (!str)
return;
GLint alignment;
unsigned char c;
glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
while ((c = (unsigned char) *str++)) {
BMF_CharData & cd = m_fontData->chars[c];
if (cd.data_offset==-1) {
GLubyte nullBitmap = 0;
glBitmap(1, 1, 0, 0, cd.advance, 0, &nullBitmap);
} else {
GLubyte *bitmap = &m_fontData->bitmap_data[cd.data_offset];
glBitmap(cd.width, cd.height, cd.xorig, cd.yorig, cd.advance, 0, bitmap);
}
}
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
}
int BMF_BitmapFont::getStringWidth(char* str)
{
unsigned char c;
int length = 0;
while ((c = (unsigned char) *str++)) {
length += m_fontData->chars[c].advance;
}
return length;
}
void BMF_BitmapFont::getBoundingBox(int & xMin, int & yMin, int & xMax, int & yMax)
{
xMin = m_fontData->xmin;
yMin = m_fontData->ymin;
xMax = m_fontData->xmax;
yMax = m_fontData->ymax;
}
int BMF_BitmapFont::getTexture()
{
int fWidth = m_fontData->xmax - m_fontData->xmin;
int fHeight = m_fontData->ymax - m_fontData->ymin;
if (fWidth>=16 || fHeight>=16) {
return -1;
}
int cRows = 16, cCols = 16;
int cWidth = 16, cHeight = 16;
int iWidth = cCols*cWidth;
int iHeight = cRows*cHeight;
GLubyte *img = new GLubyte [iHeight*iWidth];
GLuint texId;
int baseLine = -(m_fontData->ymin);
memset(img, 0, iHeight*iWidth);
for (int i = 0; i<256; i++) {
BMF_CharData & cd = m_fontData->chars[i];
if (cd.data_offset != -1) {
int cellX = i%16;
int cellY = i/16;
for (int y = 0; y<cd.height; y++) {
GLubyte* imgRow = &img[(cellY*cHeight + y + baseLine - cd.yorig)*iWidth];
GLubyte* chrRow = &m_fontData->bitmap_data[cd.data_offset + ((cd.width+7)/8)*y];
for (int x = 0; x<cd.width; x++) {
GLubyte* imgPxl = &imgRow[(cellX*cWidth + x - cd.xorig)];
int byteIdx = x/8;
int bitIdx = 7 - (x%8);
if (chrRow[byteIdx]&(1<<bitIdx)) {
imgPxl[0] = 255;
}
}
}
}
}
glGenTextures(1, &texId);
glBindTexture(GL_TEXTURE_2D, texId);
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA4, iWidth, iHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, img);
if (glGetError()) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE4_ALPHA4, iWidth, iHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, img);
}
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
delete [] img;
return texId;
}
void BMF_BitmapFont::drawStringTexture(char *str, float x, float y, float z)
{
unsigned char c;
float pos = 0;
int baseLine = -(m_fontData->ymin);
glBegin(GL_QUADS);
while ((c = (unsigned char) *str++)) {
BMF_CharData & cd = m_fontData->chars[c];
if (cd.data_offset != -1) {
float cellX = (c%16)/16.0;
float cellY = (c/16)/16.0;
glTexCoord2f(cellX + 1.0/16.0, cellY);
glVertex3f(x + pos + 16.0, -baseLine + y + 0.0, z);
glTexCoord2f(cellX + 1.0/16.0, cellY + 1.0/16.0);
glVertex3f(x + pos + 16.0, -baseLine + y + 16.0, z);
glTexCoord2f(cellX, cellY + 1.0/16.0);
glVertex3f(x + pos + 0.0, -baseLine + y + 16.0, z);
glTexCoord2f(cellX, cellY);
glVertex3f(x + pos + 0.0, -baseLine + y + 0.0, z);
}
pos += cd.advance;
}
glEnd();
}

View File

@ -1,111 +0,0 @@
/**
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU bteral Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU bteral Public License for more details.
*
* You should have received a copy of the GNU bteral Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/**
* Copyright (C) 2001 NaN Technologies B.V.
*/
#ifndef __BMF_BITMAP_FONT_H
#define __BMF_BITMAP_FONT_H
#include "BMF_FontData.h"
/**
* Base class for OpenGL bitmap fonts.
*/
class BMF_BitmapFont
{
public:
/**
* Default constructor.
*/
BMF_BitmapFont(BMF_FontData* fontData);
/**
* Destructor.
*/
virtual ~BMF_BitmapFont(void);
/**
* Draws a string at the current raster position.
* @param str The string to draw.
*/
void drawString(const char* str);
void drawStringMemory(char* str);
/**
* Draws a string at the current raster position.
* @param str The string to draw.
* @return The width of the string.
*/
int getStringWidth(char* str);
/**
* Returns the bounding box of the font. The width and
* height represent the bounding box of the union of
* all glyps. The minimum and maximum values of the
* box represent the extent of the font and its positioning
* about the origin.
*/
void getBoundingBox(int & xMin, int & yMin, int & xMax, int & yMax);
/**
* Convert the font to a texture, and return the GL texture
* ID of the texture. If the texture ID is bound, text can
* be drawn using the texture by calling drawStringTexture.
*
* @return The GL texture ID of the new texture, or -1 if unable
* to create.
*/
int getTexture();
/**
* Draw the given @a string at the point @a x, @a y, @a z, using
* texture coordinates. This assumes that an appropriate texture
* has been bound, see BMF_BitmapFont::getTexture(). The string
* is drawn along the positive X axis.
*
* @param string The c-string to draw.
* @param x The x coordinate to start drawing at.
* @param y The y coordinate to start drawing at.
* @param z The z coordinate to start drawing at.
*/
void drawStringTexture(char* string, float x, float y, float z);
protected:
/** Pointer to the font data. */
BMF_FontData* m_fontData;
};
#endif // __BMF_BITMAP_FONT_H

View File

@ -1,56 +0,0 @@
/**
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU bteral Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU bteral Public License for more details.
*
* You should have received a copy of the GNU bteral Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/**
* Copyright (C) 2001 NaN Technologies B.V.
*/
#ifndef __BMF_FONTDATA_H__
#define __BMF_FONTDATA_H__
typedef struct {
signed char width, height;
signed char xorig, yorig;
signed char advance;
short data_offset;
} BMF_CharData;
typedef struct {
int xmin, ymin;
int xmax, ymax;
BMF_CharData chars[256];
unsigned char* bitmap_data;
} BMF_FontData;
#endif

View File

@ -1,75 +0,0 @@
/**
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU bteral Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU bteral Public License for more details.
*
* You should have received a copy of the GNU bteral Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/**
* Copyright (C) 2001 NaN Technologies B.V.
* Defines the names of the fonts in the library.
*/
#ifndef __BMF_FONTS_H
#define __BMF_FONTS_H
#include "BMF_Settings.h"
typedef enum
{
BMF_kHelvetica10 = 0,
#if BMF_INCLUDE_HELV12
BMF_kHelvetica12,
#endif
#if BMF_INCLUDE_HELVB8
BMF_kHelveticaBold8,
#endif
#if BMF_INCLUDE_HELVB10
BMF_kHelveticaBold10,
#endif
#if BMF_INCLUDE_HELVB12
BMF_kHelveticaBold12,
#endif
#if BMF_INCLUDE_HELVB14
BMF_kHelveticaBold14,
#endif
#if BMF_INCLUDE_SCR12
BMF_kScreen12,
#endif
#if BMF_INCLUDE_SCR14
BMF_kScreen14,
#endif
#if BMF_INCLUDE_SCR15
BMF_kScreen15,
#endif
BMF_kNumFonts
} BMF_FontType;
typedef struct BMF_Font BMF_Font;
#endif /* __BMF_FONTS_H */

View File

@ -1,52 +0,0 @@
/**
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU bteral Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU bteral Public License for more details.
*
* You should have received a copy of the GNU bteral Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/**
* Copyright (C) 2001 NaN Technologies B.V.
* Allows you to determine which fonts to include in the library.
*/
#ifndef __BMF_SETTINGS_H
#define __BMF_SETTINGS_H
#define BMF_INCLUDE_HELV12 0
#define BMF_INCLUDE_HELVB8 0
#define BMF_INCLUDE_HELVB10 0
#define BMF_INCLUDE_HELVB12 0
#define BMF_INCLUDE_HELVB14 0
#define BMF_INCLUDE_SCR12 0
#define BMF_INCLUDE_SCR14 0
#define BMF_INCLUDE_SCR15 0
#define BMF_INCLUDE_HELV10 1
#endif /* __BMF_SETTINGS_H */

View File

@ -1,491 +0,0 @@
/**
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU bteral Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU bteral Public License for more details.
*
* You should have received a copy of the GNU bteral Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include "BMF_FontData.h"
#include "BMF_Settings.h"
#if BMF_INCLUDE_HELV10
static unsigned char bitmap_data[]= {
0x80,0x00,0x80,0x80,0x80,0x80,0x80,0x80,
0xa0,0xa0,0x50,0x50,0xf8,0x28,0x7c,0x28,
0x28,0x20,0x70,0xa8,0x28,0x70,0xa0,0xa8,
0x70,0x20,0x26,0x29,0x16,0x10,0x08,0x68,
0x94,0x64,0x64,0x98,0x98,0xa4,0x60,0x50,
0x50,0x20,0x80,0x40,0x40,0x20,0x40,0x40,
0x80,0x80,0x80,0x80,0x40,0x40,0x20,0x80,
0x40,0x40,0x20,0x20,0x20,0x20,0x40,0x40,
0x80,0xa0,0x40,0xa0,0x20,0x20,0xf8,0x20,
0x20,0x80,0x40,0x40,0xf8,0x80,0x80,0x80,
0x40,0x40,0x40,0x40,0x20,0x20,0x70,0x88,
0x88,0x88,0x88,0x88,0x88,0x70,0x40,0x40,
0x40,0x40,0x40,0x40,0xc0,0x40,0xf8,0x80,
0x40,0x30,0x08,0x08,0x88,0x70,0x70,0x88,
0x08,0x08,0x30,0x08,0x88,0x70,0x10,0x10,
0xf8,0x90,0x50,0x50,0x30,0x10,0x70,0x88,
0x08,0x08,0xf0,0x80,0x80,0xf8,0x70,0x88,
0x88,0xc8,0xb0,0x80,0x88,0x70,0x40,0x40,
0x20,0x20,0x10,0x10,0x08,0xf8,0x70,0x88,
0x88,0x88,0x70,0x88,0x88,0x70,0x70,0x88,
0x08,0x68,0x98,0x88,0x88,0x70,0x80,0x00,
0x00,0x00,0x00,0x80,0x80,0x40,0x40,0x00,
0x00,0x00,0x00,0x40,0x20,0x40,0x80,0x40,
0x20,0xf0,0x00,0xf0,0x80,0x40,0x20,0x40,
0x80,0x40,0x00,0x40,0x40,0x20,0x10,0x90,
0x60,0x3e,0x00,0x40,0x00,0x9b,0x00,0xa4,
0x80,0xa4,0x80,0xa2,0x40,0x92,0x40,0x4d,
0x40,0x20,0x80,0x1f,0x00,0x82,0x82,0x7c,
0x44,0x28,0x28,0x10,0x10,0xf0,0x88,0x88,
0x88,0xf0,0x88,0x88,0xf0,0x78,0x84,0x80,
0x80,0x80,0x80,0x84,0x78,0xf0,0x88,0x84,
0x84,0x84,0x84,0x88,0xf0,0xf8,0x80,0x80,
0x80,0xf8,0x80,0x80,0xf8,0x80,0x80,0x80,
0x80,0xf0,0x80,0x80,0xf8,0x74,0x8c,0x84,
0x8c,0x80,0x80,0x84,0x78,0x84,0x84,0x84,
0x84,0xfc,0x84,0x84,0x84,0x80,0x80,0x80,
0x80,0x80,0x80,0x80,0x80,0x60,0x90,0x10,
0x10,0x10,0x10,0x10,0x10,0x88,0x88,0x90,
0x90,0xe0,0xa0,0x90,0x88,0xf0,0x80,0x80,
0x80,0x80,0x80,0x80,0x80,0x92,0x92,0x92,
0xaa,0xaa,0xc6,0xc6,0x82,0x8c,0x8c,0x94,
0x94,0xa4,0xa4,0xc4,0xc4,0x78,0x84,0x84,
0x84,0x84,0x84,0x84,0x78,0x80,0x80,0x80,
0x80,0xf0,0x88,0x88,0xf0,0x02,0x7c,0x8c,
0x94,0x84,0x84,0x84,0x84,0x78,0x88,0x88,
0x88,0x88,0xf0,0x88,0x88,0xf0,0x70,0x88,
0x88,0x08,0x70,0x80,0x88,0x70,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0xf8,0x78,0x84,
0x84,0x84,0x84,0x84,0x84,0x84,0x10,0x28,
0x28,0x44,0x44,0x44,0x82,0x82,0x22,0x00,
0x22,0x00,0x22,0x00,0x55,0x00,0x49,0x00,
0x49,0x00,0x88,0x80,0x88,0x80,0x88,0x88,
0x50,0x50,0x20,0x50,0x88,0x88,0x10,0x10,
0x10,0x28,0x28,0x44,0x44,0x82,0xf8,0x80,
0x40,0x20,0x20,0x10,0x08,0xf8,0xc0,0x80,
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0,
0x20,0x20,0x40,0x40,0x40,0x40,0x80,0x80,
0xc0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
0x40,0xc0,0x88,0x50,0x50,0x20,0x20,0xfc,
0x80,0x80,0x40,0x68,0x90,0x90,0x70,0x10,
0xe0,0xb0,0xc8,0x88,0x88,0xc8,0xb0,0x80,
0x80,0x60,0x90,0x80,0x80,0x90,0x60,0x68,
0x98,0x88,0x88,0x98,0x68,0x08,0x08,0x60,
0x90,0x80,0xf0,0x90,0x60,0x40,0x40,0x40,
0x40,0x40,0xe0,0x40,0x30,0x70,0x08,0x68,
0x98,0x88,0x88,0x98,0x68,0x88,0x88,0x88,
0x88,0xc8,0xb0,0x80,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,0x80,0x00,0x80,0x90,0x90,
0xa0,0xc0,0xa0,0x90,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,0x80,0x80,0x80,0x92,0x92,
0x92,0x92,0x92,0xec,0x88,0x88,0x88,0x88,
0xc8,0xb0,0x70,0x88,0x88,0x88,0x88,0x70,
0x80,0x80,0xb0,0xc8,0x88,0x88,0xc8,0xb0,
0x08,0x08,0x68,0x98,0x88,0x88,0x98,0x68,
0x80,0x80,0x80,0x80,0xc0,0xa0,0x60,0x90,
0x10,0x60,0x90,0x60,0x60,0x40,0x40,0x40,
0x40,0xe0,0x40,0x40,0x70,0x90,0x90,0x90,
0x90,0x90,0x20,0x20,0x50,0x50,0x88,0x88,
0x28,0x28,0x54,0x54,0x92,0x92,0x88,0x88,
0x50,0x20,0x50,0x88,0x80,0x40,0x40,0x60,
0xa0,0xa0,0x90,0x90,0xf0,0x80,0x40,0x20,
0x10,0xf0,0x20,0x40,0x40,0x40,0x40,0x80,
0x40,0x40,0x40,0x20,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x40,
0x40,0x40,0x40,0x20,0x40,0x40,0x40,0x80,
0x98,0x64,0x80,0x80,0x80,0x80,0x80,0x80,
0x00,0x80,0x40,0x70,0xa8,0xa0,0xa0,0xa8,
0x70,0x10,0xb0,0x48,0x40,0x40,0xe0,0x40,
0x48,0x30,0x90,0x60,0x90,0x90,0x60,0x90,
0x20,0xf8,0x20,0xf8,0x50,0x50,0x88,0x88,
0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x80,
0x80,0x80,0x70,0x88,0x18,0x70,0xc8,0x98,
0x70,0xc0,0x88,0x70,0xa0,0x38,0x44,0x9a,
0xa2,0x9a,0x44,0x38,0xe0,0x00,0xa0,0x20,
0xe0,0x28,0x50,0xa0,0x50,0x28,0x08,0x08,
0xf8,0xe0,0x38,0x44,0xaa,0xb2,0xba,0x44,
0x38,0xe0,0x60,0x90,0x90,0x60,0xf8,0x00,
0x20,0x20,0xf8,0x20,0x20,0xe0,0x40,0xa0,
0x60,0xc0,0x20,0x40,0xe0,0x80,0x40,0x80,
0x80,0xf0,0x90,0x90,0x90,0x90,0x90,0x28,
0x28,0x28,0x28,0x28,0x68,0xe8,0xe8,0xe8,
0x7c,0xc0,0xc0,0x40,0x40,0x40,0xc0,0x40,
0xe0,0x00,0xe0,0xa0,0xe0,0xa0,0x50,0x28,
0x50,0xa0,0x21,0x00,0x17,0x80,0x13,0x00,
0x09,0x00,0x48,0x00,0x44,0x00,0xc4,0x00,
0x42,0x00,0x27,0x12,0x15,0x0b,0x48,0x44,
0xc4,0x42,0x21,0x00,0x17,0x80,0x13,0x00,
0x09,0x00,0xc8,0x00,0x24,0x00,0x44,0x00,
0xe2,0x00,0x60,0x90,0x80,0x40,0x20,0x20,
0x00,0x20,0x82,0x82,0x7c,0x44,0x28,0x28,
0x10,0x10,0x00,0x10,0x20,0x82,0x82,0x7c,
0x44,0x28,0x28,0x10,0x10,0x00,0x10,0x08,
0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,
0x00,0x28,0x10,0x82,0x82,0x7c,0x44,0x28,
0x28,0x10,0x10,0x00,0x28,0x14,0x82,0x82,
0x7c,0x44,0x28,0x28,0x10,0x10,0x00,0x28,
0x82,0x82,0x7c,0x44,0x28,0x28,0x10,0x10,
0x10,0x28,0x10,0x8f,0x80,0x88,0x00,0x78,
0x00,0x48,0x00,0x2f,0x80,0x28,0x00,0x18,
0x00,0x1f,0x80,0x30,0x10,0x78,0x84,0x80,
0x80,0x80,0x80,0x84,0x78,0xf8,0x80,0x80,
0x80,0xf8,0x80,0x80,0xf8,0x00,0x20,0x40,
0xf8,0x80,0x80,0x80,0xf8,0x80,0x80,0xf8,
0x00,0x20,0x10,0xf8,0x80,0x80,0xf8,0x80,
0x80,0x80,0xf8,0x00,0x50,0x20,0xf8,0x80,
0x80,0x80,0xf8,0x80,0x80,0xf8,0x00,0x50,
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
0x00,0x40,0x80,0x80,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,0x00,0x80,0x40,0x40,0x40,
0x40,0x40,0x40,0x40,0x40,0x40,0x00,0xa0,
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
0x40,0x00,0xa0,0x78,0x44,0x42,0x42,0xf2,
0x42,0x44,0x78,0x8c,0x8c,0x94,0x94,0xa4,
0xa4,0xc4,0xc4,0x00,0x50,0x28,0x78,0x84,
0x84,0x84,0x84,0x84,0x84,0x78,0x00,0x10,
0x20,0x78,0x84,0x84,0x84,0x84,0x84,0x84,
0x78,0x00,0x10,0x08,0x78,0x84,0x84,0x84,
0x84,0x84,0x84,0x78,0x00,0x28,0x10,0x78,
0x84,0x84,0x84,0x84,0x84,0x84,0x78,0x00,
0x50,0x28,0x78,0x84,0x84,0x84,0x84,0x84,
0x84,0x78,0x00,0x48,0x88,0x50,0x20,0x50,
0x88,0x80,0x78,0xc4,0xa4,0xa4,0x94,0x94,
0x8c,0x78,0x04,0x78,0x84,0x84,0x84,0x84,
0x84,0x84,0x84,0x00,0x10,0x20,0x78,0x84,
0x84,0x84,0x84,0x84,0x84,0x84,0x00,0x20,
0x10,0x78,0x84,0x84,0x84,0x84,0x84,0x84,
0x84,0x00,0x28,0x10,0x78,0x84,0x84,0x84,
0x84,0x84,0x84,0x84,0x00,0x48,0x10,0x10,
0x10,0x28,0x28,0x44,0x44,0x82,0x00,0x10,
0x08,0x80,0x80,0xf0,0x88,0x88,0xf0,0x80,
0x80,0xa0,0x90,0x90,0x90,0xa0,0x90,0x90,
0x60,0x68,0x90,0x90,0x70,0x10,0xe0,0x00,
0x20,0x40,0x68,0x90,0x90,0x70,0x10,0xe0,
0x00,0x20,0x10,0x68,0x90,0x90,0x70,0x10,
0xe0,0x00,0x50,0x20,0x68,0x90,0x90,0x70,
0x10,0xe0,0x00,0xa0,0x50,0x68,0x90,0x90,
0x70,0x10,0xe0,0x00,0x50,0x68,0x90,0x90,
0x70,0x10,0xe0,0x20,0x50,0x20,0x6c,0x92,
0x90,0x7e,0x12,0xec,0x60,0x20,0x60,0x90,
0x80,0x80,0x90,0x60,0x60,0x90,0x80,0xf0,
0x90,0x60,0x00,0x20,0x40,0x60,0x90,0x80,
0xf0,0x90,0x60,0x00,0x40,0x20,0x60,0x90,
0x80,0xf0,0x90,0x60,0x00,0x50,0x20,0x60,
0x90,0x80,0xf0,0x90,0x60,0x00,0x50,0x40,
0x40,0x40,0x40,0x40,0x40,0x00,0x40,0x80,
0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x80,
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,
0xa0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
0x00,0xa0,0x70,0x88,0x88,0x88,0x88,0x78,
0x90,0x60,0x50,0x90,0x90,0x90,0x90,0x90,
0xe0,0x00,0xa0,0x50,0x70,0x88,0x88,0x88,
0x88,0x70,0x00,0x20,0x40,0x70,0x88,0x88,
0x88,0x88,0x70,0x00,0x20,0x10,0x70,0x88,
0x88,0x88,0x88,0x70,0x00,0x50,0x20,0x70,
0x88,0x88,0x88,0x88,0x70,0x00,0x50,0x28,
0x70,0x88,0x88,0x88,0x88,0x70,0x00,0x50,
0x20,0x00,0xf8,0x00,0x20,0x70,0x88,0xc8,
0xa8,0x98,0x74,0x70,0x90,0x90,0x90,0x90,
0x90,0x00,0x20,0x40,0x70,0x90,0x90,0x90,
0x90,0x90,0x00,0x40,0x20,0x70,0x90,0x90,
0x90,0x90,0x90,0x00,0x50,0x20,0x70,0x90,
0x90,0x90,0x90,0x90,0x00,0x50,0x80,0x40,
0x40,0x60,0xa0,0xa0,0x90,0x90,0x00,0x20,
0x10,0x80,0x80,0xb0,0xc8,0x88,0x88,0xc8,
0xb0,0x80,0x80,0x80,0x40,0x40,0x60,0xa0,
0xa0,0x90,0x90,0x00,0x50,
};
BMF_FontData BMF_font_helv10 = {
-1, -2,
10, 11,
{
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0, 0, 0, 0, 12, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0, 0, 0, 0, 3, -1},
{1, 8, -1, 0, 3, 0},
{3, 2, -1, -6, 4, 8},
{6, 7, 0, 0, 6, 10},
{5, 9, 0, 1, 6, 17},
{8, 8, 0, 0, 9, 26},
{6, 8, -1, 0, 8, 34},
{2, 3, -1, -5, 3, 42},
{3, 10, 0, 2, 4, 45},
{3, 10, -1, 2, 4, 55},
{3, 3, 0, -5, 4, 65},
{5, 5, 0, -1, 6, 68},
{2, 3, 0, 2, 3, 73},
{5, 1, -1, -3, 7, 76},
{1, 1, -1, 0, 3, 77},
{3, 8, 0, 0, 3, 78},
{5, 8, 0, 0, 6, 86},
{2, 8, -1, 0, 6, 94},
{5, 8, 0, 0, 6, 102},
{5, 8, 0, 0, 6, 110},
{5, 8, 0, 0, 6, 118},
{5, 8, 0, 0, 6, 126},
{5, 8, 0, 0, 6, 134},
{5, 8, 0, 0, 6, 142},
{5, 8, 0, 0, 6, 150},
{5, 8, 0, 0, 6, 158},
{1, 6, -1, 0, 3, 166},
{2, 8, 0, 2, 3, 172},
{3, 5, -1, -1, 6, 180},
{4, 3, 0, -2, 5, 185},
{3, 5, -1, -1, 6, 188},
{4, 8, -1, 0, 6, 193},
{10, 10, 0, 2, 11, 201},
{7, 8, 0, 0, 7, 221},
{5, 8, -1, 0, 7, 229},
{6, 8, -1, 0, 8, 237},
{6, 8, -1, 0, 8, 245},
{5, 8, -1, 0, 7, 253},
{5, 8, -1, 0, 6, 261},
{6, 8, -1, 0, 8, 269},
{6, 8, -1, 0, 8, 277},
{1, 8, -1, 0, 3, 285},
{4, 8, 0, 0, 5, 293},
{5, 8, -1, 0, 7, 301},
{4, 8, -1, 0, 6, 309},
{7, 8, -1, 0, 9, 317},
{6, 8, -1, 0, 8, 325},
{6, 8, -1, 0, 8, 333},
{5, 8, -1, 0, 7, 341},
{7, 9, -1, 1, 8, 349},
{5, 8, -1, 0, 7, 358},
{5, 8, -1, 0, 7, 366},
{5, 8, 0, 0, 5, 374},
{6, 8, -1, 0, 8, 382},
{7, 8, 0, 0, 7, 390},
{9, 8, 0, 0, 9, 398},
{5, 8, -1, 0, 7, 414},
{7, 8, 0, 0, 7, 422},
{5, 8, -1, 0, 7, 430},
{2, 10, -1, 2, 3, 438},
{3, 8, 0, 0, 3, 448},
{2, 10, 0, 2, 3, 456},
{5, 5, 0, -3, 6, 466},
{6, 1, 0, 2, 6, 471},
{2, 3, 0, -5, 3, 472},
{5, 6, 0, 0, 5, 475},
{5, 8, 0, 0, 6, 481},
{4, 6, 0, 0, 5, 489},
{5, 8, 0, 0, 6, 495},
{4, 6, 0, 0, 5, 503},
{4, 8, 0, 0, 4, 509},
{5, 8, 0, 2, 6, 517},
{5, 8, 0, 0, 6, 525},
{1, 8, 0, 0, 2, 533},
{1, 9, 0, 1, 2, 541},
{4, 8, 0, 0, 5, 550},
{1, 8, 0, 0, 2, 558},
{7, 6, 0, 0, 8, 566},
{5, 6, 0, 0, 6, 572},
{5, 6, 0, 0, 6, 578},
{5, 8, 0, 2, 6, 584},
{5, 8, 0, 2, 6, 592},
{3, 6, 0, 0, 4, 600},
{4, 6, 0, 0, 5, 606},
{3, 8, 0, 0, 4, 612},
{4, 6, 0, 0, 5, 620},
{5, 6, 0, 0, 6, 626},
{7, 6, 0, 0, 8, 632},
{5, 6, 0, 0, 6, 638},
{4, 8, 0, 2, 5, 644},
{4, 6, 0, 0, 5, 652},
{3, 10, 0, 2, 3, 658},
{1, 10, -1, 2, 3, 668},
{3, 10, 0, 2, 3, 678},
{6, 2, 0, -3, 7, 688},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0,0,0,0,0, -1},
{0, 0, 0, 0, 3, -1},
{1, 8, -1, 2, 3, 690},
{5, 8, 0, 1, 6, 698},
{5, 8, 0, 0, 6, 706},
{4, 6, 0, -1, 5, 714},
{5, 8, 0, 0, 6, 720},
{1, 10, -1, 2, 3, 728},
{5, 10, 0, 2, 6, 738},
{3, 1, 0, -7, 3, 748},
{7, 7, -1, 0, 9, 749},
{3, 5, 0, -3, 4, 756},
{5, 5, 0, 0, 6, 761},
{5, 3, -1, -2, 7, 766},
{3, 1, 0, -3, 4, 769},
{7, 7, -1, 0, 9, 770},
{3, 1, 0, -7, 3, 777},
{4, 4, 0, -3, 4, 778},
{5, 7, 0, 0, 6, 782},
{3, 4, 0, -3, 3, 789},
{3, 4, 0, -3, 3, 793},
{2, 2, 0, -6, 3, 797},
{4, 8, 0, 2, 5, 799},
{6, 10, 0, 2, 6, 807},
{2, 1, 0, -3, 3, 817},
{2, 2, 0, 2, 3, 818},
{2, 4, 0, -3, 3, 820},
{3, 5, 0, -3, 4, 824},
{5, 5, 0, 0, 6, 829},
{9, 8, 0, 0, 9, 834},
{8, 8, 0, 0, 9, 850},
{9, 8, 0, 0, 9, 858},
{4, 8, -1, 2, 6, 874},
{7, 11, 0, 0, 7, 882},
{7, 11, 0, 0, 7, 893},
{7, 11, 0, 0, 7, 904},
{7, 11, 0, 0, 7, 915},
{7, 10, 0, 0, 7, 926},
{7, 11, 0, 0, 7, 936},
{9, 8, 0, 0, 10, 947},
{6, 10, -1, 2, 8, 963},
{5, 11, -1, 0, 7, 973},
{5, 11, -1, 0, 7, 984},
{5, 11, -1, 0, 7, 995},
{5, 10, -1, 0, 7, 1006},
{2, 11, 0, 0, 3, 1016},
{2, 11, -1, 0, 3, 1027},
{3, 11, 0, 0, 3, 1038},
{3, 10, 0, 0, 3, 1049},
{7, 8, 0, 0, 8, 1059},
{6, 11, -1, 0, 8, 1067},
{6, 11, -1, 0, 8, 1078},
{6, 11, -1, 0, 8, 1089},
{6, 11, -1, 0, 8, 1100},
{6, 11, -1, 0, 8, 1111},
{6, 10, -1, 0, 8, 1122},
{5, 5, 0, -1, 6, 1132},
{6, 10, -1, 1, 8, 1137},
{6, 11, -1, 0, 8, 1147},
{6, 11, -1, 0, 8, 1158},
{6, 11, -1, 0, 8, 1169},
{6, 10, -1, 0, 8, 1180},
{7, 11, 0, 0, 7, 1190},
{5, 8, -1, 0, 7, 1201},
{4, 8, 0, 0, 5, 1209},
{5, 9, 0, 0, 5, 1217},
{5, 9, 0, 0, 5, 1226},
{5, 9, 0, 0, 5, 1235},
{5, 9, 0, 0, 5, 1244},
{5, 8, 0, 0, 5, 1253},
{5, 9, 0, 0, 5, 1261},
{7, 6, 0, 0, 8, 1270},
{4, 8, 0, 2, 5, 1276},
{4, 9, 0, 0, 5, 1284},
{4, 9, 0, 0, 5, 1293},
{4, 9, 0, 0, 5, 1302},
{4, 8, 0, 0, 5, 1311},
{2, 9, 1, 0, 2, 1319},
{2, 9, 0, 0, 2, 1328},
{3, 9, 1, 0, 2, 1337},
{3, 8, 0, 0, 2, 1346},
{5, 9, 0, 0, 6, 1354},
{4, 9, 0, 0, 5, 1363},
{5, 9, 0, 0, 6, 1372},
{5, 9, 0, 0, 6, 1381},
{5, 9, 0, 0, 6, 1390},
{5, 9, 0, 0, 6, 1399},
{5, 8, 0, 0, 6, 1408},
{5, 5, 0, -1, 6, 1416},
{6, 6, 0, 0, 6, 1421},
{4, 9, 0, 0, 5, 1427},
{4, 9, 0, 0, 5, 1436},
{4, 9, 0, 0, 5, 1445},
{4, 8, 0, 0, 5, 1454},
{4, 11, 0, 2, 5, 1462},
{5, 10, 0, 2, 6, 1473},
{4, 10, 0, 2, 5, 1483},
},
bitmap_data
};
#endif

View File

@ -1,83 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef DEBUG_CAST_RESULT_H
#define DEBUG_CAST_RESULT_H
#include "BulletCollision/NarrowPhaseCollision/btConvexCast.h"
#include "LinearMath/btTransform.h"
#include "GL_ShapeDrawer.h"
#include "GlutStuff.h"
#ifdef WIN32
#include <windows.h>
#endif
//think different
#if defined(__APPLE__) && !defined (VMDMESA)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else
#include <GL/gl.h>
#endif
struct btDebugCastResult : public btConvexCast::CastResult
{
btTransform m_fromTrans;
const btPolyhedralConvexShape* m_shape;
btVector3 m_linVel;
btVector3 m_angVel;
GL_ShapeDrawer* m_shapeDrawer;
btDebugCastResult(const btTransform& fromTrans,const btPolyhedralConvexShape* shape,
const btVector3& linVel,const btVector3& angVel,GL_ShapeDrawer* drawer)
:m_fromTrans(fromTrans),
m_shape(shape),
m_linVel(linVel),
m_angVel(angVel)
{
}
virtual void drawCoordSystem(const btTransform& tr)
{
btScalar m[16];
tr.getOpenGLMatrix(m);
glPushMatrix();
btglLoadMatrix(m);
glBegin(GL_LINES);
btglColor3(1, 0, 0);
btglVertex3(0, 0, 0);
btglVertex3(1, 0, 0);
btglColor3(0, 1, 0);
btglVertex3(0, 0, 0);
btglVertex3(0, 1, 0);
btglColor3(0, 0, 1);
btglVertex3(0, 0, 0);
btglVertex3(0, 0, 1);
glEnd();
glPopMatrix();
}
virtual void DebugDraw(btScalar fraction)
{
btScalar m[16];
btTransform hitTrans;
btTransformUtil::integrateTransform(m_fromTrans,m_linVel,m_angVel,fraction,hitTrans);
hitTrans.getOpenGLMatrix(m);
m_shapeDrawer->drawOpenGL(m,m_shape,btVector3(1,0,0),btIDebugDraw::DBG_NoDebug);
}
};
#endif //DEBUG_CAST_RESULT_H

File diff suppressed because it is too large Load Diff

View File

@ -1,201 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef DEMO_APPLICATION_H
#define DEMO_APPLICATION_H
#include "GlutStuff.h"
#include "GL_ShapeDrawer.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "LinearMath/btVector3.h"
#include "LinearMath/btMatrix3x3.h"
#include "LinearMath/btTransform.h"
#include "LinearMath/btQuickprof.h"
#include "LinearMath/btAlignedObjectArray.h"
class btCollisionShape;
class btDynamicsWorld;
class btRigidBody;
class btTypedConstraint;
class DemoApplication
{
void displayProfileString(int xOffset,int yStart,char* message);
class CProfileIterator* m_profileIterator;
protected:
#ifdef USE_BT_CLOCK
btClock m_clock;
#endif //USE_BT_CLOCK
///this is the most important class
btDynamicsWorld* m_dynamicsWorld;
///constraint for mouse picking
btTypedConstraint* m_pickConstraint;
btCollisionShape* m_shootBoxShape;
float m_cameraDistance;
int m_debugMode;
float m_ele;
float m_azi;
btVector3 m_cameraPosition;
btVector3 m_cameraTargetPosition;//look at
float m_scaleBottom;
float m_scaleFactor;
btVector3 m_cameraUp;
int m_forwardAxis;
int m_glutScreenWidth;
int m_glutScreenHeight;
float m_ShootBoxInitialSpeed;
bool m_stepping;
bool m_singleStep;
bool m_idle;
int m_lastKey;
void showProfileInfo(float& xOffset,float& yStart, float yIncr);
GL_ShapeDrawer m_shapeDrawer;
public:
DemoApplication();
virtual ~DemoApplication();
btDynamicsWorld* getDynamicsWorld()
{
return m_dynamicsWorld;
}
void setOrthographicProjection();
void resetPerspectiveProjection();
int getDebugMode()
{
return m_debugMode ;
}
void setDebugMode(int mode);
void setCameraUp(const btVector3& camUp)
{
m_cameraUp = camUp;
}
void setCameraForwardAxis(int axis)
{
m_forwardAxis = axis;
}
void myinit();
void toggleIdle();
virtual void updateCamera();
btVector3 getCameraPosition()
{
return m_cameraPosition;
}
btVector3 getCameraTargetPosition()
{
return m_cameraTargetPosition;
}
btScalar getDeltaTimeMicroseconds()
{
#ifdef USE_BT_CLOCK
btScalar dt = m_clock.getTimeMicroseconds();
m_clock.reset();
return dt;
#else
return btScalar(16666.);
#endif
}
///glut callbacks
float getCameraDistance();
void setCameraDistance(float dist);
void moveAndDisplay();
virtual void clientMoveAndDisplay() = 0;
virtual void clientResetScene();
///Demo functions
void shootBox(const btVector3& destination);
btVector3 getRayTo(int x,int y);
btRigidBody* localCreateRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape);
///callback methods by glut
virtual void keyboardCallback(unsigned char key, int x, int y);
virtual void specialKeyboard(int key, int x, int y);
virtual void specialKeyboardUp(int key, int x, int y);
virtual void reshape(int w, int h);
virtual void mouseFunc(int button, int state, int x, int y);
virtual void mouseMotionFunc(int x,int y);
virtual void displayCallback();
virtual void renderme();
void stepLeft();
void stepRight();
void stepFront();
void stepBack();
void zoomIn();
void zoomOut();
bool isIdle() const
{
return m_idle;
}
void setIdle(bool idle)
{
m_idle = idle;
}
};
#endif //DEMO_APPLICATION_H

View File

@ -1,78 +0,0 @@
#ifdef HAVE_GLUT
#include "GLDebugDrawer.h"
#include "LinearMath/btPoint3.h"
#ifdef WIN32 //needed for glut.h
#include <windows.h>
#endif
//think different
#if defined(__APPLE__) && !defined (VMDMESA)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include "BMF_Api.h"
#include <stdio.h> //printf debugging
GLDebugDrawer::GLDebugDrawer()
:m_debugMode(0)
{
}
void GLDebugDrawer::drawLine(const btVector3& from,const btVector3& to,const btVector3& color)
{
// if (m_debugMode > 0)
{
glBegin(GL_LINES);
glColor3f(color.getX(), color.getY(), color.getZ());
glVertex3d(from.getX(), from.getY(), from.getZ());
glVertex3d(to.getX(), to.getY(), to.getZ());
glEnd();
}
}
void GLDebugDrawer::setDebugMode(int debugMode)
{
m_debugMode = debugMode;
}
void GLDebugDrawer::draw3dText(const btVector3& location,const char* textString)
{
glRasterPos3f(location.x(), location.y(), location.z());
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),textString);
}
void GLDebugDrawer::reportErrorWarning(const char* warningString)
{
printf("%s", warningString);
}
void GLDebugDrawer::drawContactPoint(const btVector3& pointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color)
{
if (m_debugMode & btIDebugDraw::DBG_DrawContactPoints)
{
btVector3 to=pointOnB+normalOnB*distance;
const btVector3&from = pointOnB;
glBegin(GL_LINES);
glColor3f(color.getX(), color.getY(), color.getZ());
glVertex3d(from.getX(), from.getY(), from.getZ());
glVertex3d(to.getX(), to.getY(), to.getZ());
glEnd();
glRasterPos3f(from.x(), from.y(), from.z());
char buf[12];
sprintf(buf," %d",lifeTime);
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
}
}
#endif

View File

@ -1,31 +0,0 @@
#ifndef GL_DEBUG_DRAWER_H
#define GL_DEBUG_DRAWER_H
#include "LinearMath/btIDebugDraw.h"
class GLDebugDrawer : public btIDebugDraw
{
int m_debugMode;
public:
GLDebugDrawer();
virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color);
virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color);
virtual void reportErrorWarning(const char* warningString);
virtual void draw3dText(const btVector3& location,const char* textString);
virtual void setDebugMode(int debugMode);
virtual int getDebugMode() const { return m_debugMode;}
};
#endif//GL_DEBUG_DRAWER_H

View File

@ -1,683 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifdef HAVE_GLUT
#ifdef WIN32 //needed for glut.h
#include <windows.h>
#endif
//think different
#if defined(__APPLE__) && !defined (VMDMESA)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include "GlutStuff.h"
#include "GL_ShapeDrawer.h"
#include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h"
#include "BulletCollision/CollisionShapes/btTriangleMeshShape.h"
#include "BulletCollision/CollisionShapes/btBoxShape.h"
#include "BulletCollision/CollisionShapes/btSphereShape.h"
#include "BulletCollision/CollisionShapes/btConeShape.h"
#include "BulletCollision/CollisionShapes/btCylinderShape.h"
#include "BulletCollision/CollisionShapes/btTetrahedronShape.h"
#include "BulletCollision/CollisionShapes/btCompoundShape.h"
#include "BulletCollision/CollisionShapes/btCapsuleShape.h"
#include "BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h"
#include "BulletCollision/CollisionShapes/btUniformScalingShape.h"
#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
///
#include "BulletCollision/CollisionShapes/btShapeHull.h"
#include "LinearMath/btTransformUtil.h"
#include "LinearMath/btIDebugDraw.h"
//for debugmodes
#include "BMF_Api.h"
#include <stdio.h> //printf debugging
//#define USE_DISPLAY_LISTS 1
#ifdef USE_DISPLAY_LISTS
#include <map>
using namespace std;
//Set for storing Display list per trimesh
struct TRIMESH_KEY
{
btCollisionShape* m_shape;
GLuint m_dlist;//OpenGL display list
};
typedef map<unsigned long,TRIMESH_KEY> TRIMESH_KEY_MAP;
typedef pair<unsigned long,TRIMESH_KEY> TRIMESH_KEY_PAIR;
TRIMESH_KEY_MAP g_display_lists;
class GlDisplaylistDrawcallback : public btTriangleCallback
{
public:
virtual void processTriangle(btVector3* triangle,int partId, int triangleIndex)
{
btVector3 diff1 = triangle[1] - triangle[0];
btVector3 diff2 = triangle[2] - triangle[0];
btVector3 normal = diff1.cross(diff2);
normal.normalize();
glBegin(GL_TRIANGLES);
glColor3f(0, 1, 0);
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
glColor3f(0, 1, 0);
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
glColor3f(0, 1, 0);
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
glEnd();
/*glBegin(GL_LINES);
glColor3f(1, 1, 0);
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
glColor3f(1, 1, 0);
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
glColor3f(1, 1, 0);
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
glNormal3d(normal.getX(),normal.getY(),normal.getZ());
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
glEnd();*/
}
};
GLuint OGL_get_displaylist_for_shape(btCollisionShape * shape)
{
TRIMESH_KEY_MAP::iterator map_iter;
unsigned long key = (unsigned long)shape;
map_iter = g_display_lists.find(key);
if(map_iter!=g_display_lists.end())
{
return map_iter->second.m_dlist;
}
return 0;
}
void OGL_displaylist_clean()
{
TRIMESH_KEY_MAP::iterator map_iter,map_itend;
map_iter = g_display_lists.begin();
while(map_iter!=map_itend)
{
glDeleteLists(map_iter->second.m_dlist,1);
map_iter++;
}
g_display_lists.clear();
}
void OGL_displaylist_register_shape(btCollisionShape * shape)
{
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
btVector3 aabbMin(-btScalar(1e30),-btScalar(1e30),-btScalar(1e30));
GlDisplaylistDrawcallback drawCallback;
TRIMESH_KEY dlist;
dlist.m_dlist = glGenLists(1);
dlist.m_shape = shape;
unsigned long key = (unsigned long)shape;
g_display_lists.insert(TRIMESH_KEY_PAIR(key,dlist));
glNewList(dlist.m_dlist,GL_COMPILE);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
if (shape->isConcave())
{
btConcaveShape* concaveMesh = (btConcaveShape*) shape;
//todo pass camera, for some culling
concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
}
glDisable(GL_CULL_FACE);
glEndList();
}
#endif //USE_DISPLAY_LISTS
void GL_ShapeDrawer::drawCoordSystem() {
glBegin(GL_LINES);
glColor3f(1, 0, 0);
glVertex3d(0, 0, 0);
glVertex3d(1, 0, 0);
glColor3f(0, 1, 0);
glVertex3d(0, 0, 0);
glVertex3d(0, 1, 0);
glColor3f(0, 0, 1);
glVertex3d(0, 0, 0);
glVertex3d(0, 0, 1);
glEnd();
}
class GlDrawcallback : public btTriangleCallback
{
public:
bool m_wireframe;
GlDrawcallback()
:m_wireframe(false)
{
}
virtual void processTriangle(btVector3* triangle,int partId, int triangleIndex)
{
(void)triangleIndex;
(void)partId;
if (m_wireframe)
{
glBegin(GL_LINES);
glColor3f(1, 0, 0);
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
glColor3f(0, 1, 0);
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
glColor3f(0, 0, 1);
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
glEnd();
} else
{
glBegin(GL_TRIANGLES);
glColor3f(1, 0, 0);
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
glColor3f(0, 1, 0);
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
glColor3f(0, 0, 1);
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
glEnd();
}
}
};
class TriangleGlDrawcallback : public btInternalTriangleIndexCallback
{
public:
virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex)
{
(void)triangleIndex;
(void)partId;
glBegin(GL_TRIANGLES);//LINES);
glColor3f(1, 0, 0);
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
glColor3f(0, 1, 0);
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
glColor3f(0, 0, 1);
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
glEnd();
}
};
void GL_ShapeDrawer::drawCylinder(float radius,float halfHeight, int upAxis)
{
glPushMatrix();
switch (upAxis)
{
case 0:
glRotatef(-90.0, 0.0, 1.0, 0.0);
glTranslatef(0.0, 0.0, -halfHeight);
break;
case 1:
glRotatef(-90.0, 1.0, 0.0, 0.0);
glTranslatef(0.0, 0.0, -halfHeight);
break;
case 2:
glTranslatef(0.0, 0.0, -halfHeight);
break;
default:
{
assert(0);
}
}
GLUquadricObj *quadObj = gluNewQuadric();
//The gluCylinder subroutine draws a cylinder that is oriented along the z axis.
//The base of the cylinder is placed at z = 0; the top of the cylinder is placed at z=height.
//Like a sphere, the cylinder is subdivided around the z axis into slices and along the z axis into stacks.
gluQuadricDrawStyle(quadObj, (GLenum)GLU_FILL);
gluQuadricNormals(quadObj, (GLenum)GLU_SMOOTH);
gluDisk(quadObj,0,radius,15, 10);
gluCylinder(quadObj, radius, radius, 2.f*halfHeight, 15, 10);
glTranslatef(0.0, 0.0, 2.*halfHeight);
glRotatef(-180.0, 0.0, 1.0, 0.0);
gluDisk(quadObj,0,radius,15, 10);
glPopMatrix();
gluDeleteQuadric(quadObj);
}
void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, const btVector3& color,int debugMode)
{
glPushMatrix();
btglMultMatrix(m);
if (shape->getShapeType() == UNIFORM_SCALING_SHAPE_PROXYTYPE)
{
const btUniformScalingShape* scalingShape = static_cast<const btUniformScalingShape*>(shape);
const btConvexShape* convexShape = scalingShape->getChildShape();
float scalingFactor = (float)scalingShape->getUniformScalingFactor();
{
btScalar tmpScaling[4][4]={{scalingFactor,0,0,0},
{0,scalingFactor,0,0},
{0,0,scalingFactor,0},
{0,0,0,1}};
drawOpenGL( (btScalar*)tmpScaling,convexShape,color,debugMode);
}
glPopMatrix();
return;
}
if (shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE)
{
const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(shape);
for (int i=compoundShape->getNumChildShapes()-1;i>=0;i--)
{
btTransform childTrans = compoundShape->getChildTransform(i);
const btCollisionShape* colShape = compoundShape->getChildShape(i);
btScalar childMat[16];
childTrans.getOpenGLMatrix(childMat);
drawOpenGL(childMat,colShape,color,debugMode);
}
} else
{
//drawCoordSystem();
//glPushMatrix();
glEnable(GL_COLOR_MATERIAL);
glColor3f(color.x(),color.y(), color.z());
bool useWireframeFallback = true;
if (!(debugMode & btIDebugDraw::DBG_DrawWireframe))
{
///you can comment out any of the specific cases, and use the default
///the benefit of 'default' is that it approximates the actual collision shape including collision margin
switch (shape->getShapeType())
{
case BOX_SHAPE_PROXYTYPE:
{
const btBoxShape* boxShape = static_cast<const btBoxShape*>(shape);
btVector3 halfExtent = boxShape->getHalfExtentsWithMargin();
glScaled(2*halfExtent[0], 2*halfExtent[1], 2*halfExtent[2]);
glutSolidCube(1.0);
useWireframeFallback = false;
break;
}
case SPHERE_SHAPE_PROXYTYPE:
{
const btSphereShape* sphereShape = static_cast<const btSphereShape*>(shape);
float radius = sphereShape->getMargin();//radius doesn't include the margin, so draw with margin
glutSolidSphere(radius,10,10);
useWireframeFallback = false;
break;
}
case CONE_SHAPE_PROXYTYPE:
{
const btConeShape* coneShape = static_cast<const btConeShape*>(shape);
int upIndex = coneShape->getConeUpIndex();
float radius = coneShape->getRadius();//+coneShape->getMargin();
float height = coneShape->getHeight();//+coneShape->getMargin();
switch (upIndex)
{
case 0:
glRotatef(90.0, 0.0, 1.0, 0.0);
break;
case 1:
glRotatef(-90.0, 1.0, 0.0, 0.0);
break;
case 2:
break;
default:
{
}
};
glTranslatef(0.0, 0.0, -0.5*height);
glutSolidCone(radius,height,10,10);
useWireframeFallback = false;
break;
}
case STATIC_PLANE_PROXYTYPE:
{
const btStaticPlaneShape* staticPlaneShape = static_cast<const btStaticPlaneShape*>(shape);
btScalar planeConst = staticPlaneShape->getPlaneConstant();
const btVector3& planeNormal = staticPlaneShape->getPlaneNormal();
btVector3 planeOrigin = planeNormal * planeConst;
btVector3 vec0,vec1;
btPlaneSpace1(planeNormal,vec0,vec1);
btScalar vecLen = 100.f;
btVector3 pt0 = planeOrigin + vec0*vecLen;
btVector3 pt1 = planeOrigin - vec0*vecLen;
btVector3 pt2 = planeOrigin + vec1*vecLen;
btVector3 pt3 = planeOrigin - vec1*vecLen;
glBegin(GL_LINES);
glVertex3f(pt0.getX(),pt0.getY(),pt0.getZ());
glVertex3f(pt1.getX(),pt1.getY(),pt1.getZ());
glVertex3f(pt2.getX(),pt2.getY(),pt2.getZ());
glVertex3f(pt3.getX(),pt3.getY(),pt3.getZ());
glEnd();
break;
}
case CYLINDER_SHAPE_PROXYTYPE:
{
const btCylinderShape* cylinder = static_cast<const btCylinderShape*>(shape);
int upAxis = cylinder->getUpAxis();
float radius = cylinder->getRadius();
float halfHeight = cylinder->getHalfExtentsWithMargin()[upAxis];
drawCylinder(radius,halfHeight,upAxis);
break;
}
default:
{
if (shape->isConvex())
{
btConvexShape* convexShape = (btConvexShape*)shape;
if (!shape->getUserPointer())
{
//create a hull approximation
void* mem = btAlignedAlloc(sizeof(btShapeHull),16);
btShapeHull* hull = new(mem) btShapeHull(convexShape);
///cleanup memory
m_shapeHulls.push_back(hull);
btScalar margin = shape->getMargin();
hull->buildHull(margin);
convexShape->setUserPointer(hull);
// printf("numTriangles = %d\n", hull->numTriangles ());
// printf("numIndices = %d\n", hull->numIndices ());
// printf("numVertices = %d\n", hull->numVertices ());
}
if (shape->getUserPointer())
{
//glutSolidCube(1.0);
btShapeHull* hull = (btShapeHull*)shape->getUserPointer();
if (hull->numTriangles () > 0)
{
int index = 0;
const unsigned int* idx = hull->getIndexPointer();
const btVector3* vtx = hull->getVertexPointer();
glBegin (GL_TRIANGLES);
for (int i = 0; i < hull->numTriangles (); i++)
{
int i1 = index++;
int i2 = index++;
int i3 = index++;
btAssert(i1 < hull->numIndices () &&
i2 < hull->numIndices () &&
i3 < hull->numIndices ());
int index1 = idx[i1];
int index2 = idx[i2];
int index3 = idx[i3];
btAssert(index1 < hull->numVertices () &&
index2 < hull->numVertices () &&
index3 < hull->numVertices ());
btVector3 v1 = vtx[index1];
btVector3 v2 = vtx[index2];
btVector3 v3 = vtx[index3];
btVector3 normal = (v3-v1).cross(v2-v1);
normal.normalize ();
glNormal3f(normal.getX(),normal.getY(),normal.getZ());
glVertex3f (v1.x(), v1.y(), v1.z());
glVertex3f (v2.x(), v2.y(), v2.z());
glVertex3f (v3.x(), v3.y(), v3.z());
}
glEnd ();
}
} else
{
// printf("unhandled drawing\n");
}
}
}
}
}
/// for polyhedral shapes
if (debugMode==btIDebugDraw::DBG_DrawFeaturesText && (shape->isPolyhedral()))
{
btPolyhedralConvexShape* polyshape = (btPolyhedralConvexShape*) shape;
{
glRasterPos3f(0.0, 0.0, 0.0);
//BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),polyshape->getExtraDebugInfo());
glColor3f(1.f, 1.f, 1.f);
int i;
for (i=0;i<polyshape->getNumVertices();i++)
{
btPoint3 vtx;
polyshape->getVertex(i,vtx);
glRasterPos3f(vtx.x(), vtx.y(), vtx.z());
char buf[12];
sprintf(buf," %d",i);
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
}
for (i=0;i<polyshape->getNumPlanes();i++)
{
btVector3 normal;
btPoint3 vtx;
polyshape->getPlane(normal,vtx,i);
btScalar d = vtx.dot(normal);
glRasterPos3f(normal.x()*d, normal.y()*d, normal.z()*d);
char buf[12];
sprintf(buf," plane %d",i);
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
}
}
}
#ifdef USE_DISPLAY_LISTS
if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE||shape->getShapeType() == GIMPACT_SHAPE_PROXYTYPE)
{
GLuint dlist = OGL_get_displaylist_for_shape((btCollisionShape * )shape);
if (dlist)
{
glCallList(dlist);
}
else
{
#else
if (shape->isConcave())//>getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE||shape->getShapeType() == GIMPACT_SHAPE_PROXYTYPE)
// if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
{
btConcaveShape* concaveMesh = (btConcaveShape*) shape;
//btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
//btVector3 aabbMax(100,100,100);//btScalar(1e30),btScalar(1e30),btScalar(1e30));
//todo pass camera, for some culling
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
btVector3 aabbMin(-btScalar(1e30),-btScalar(1e30),-btScalar(1e30));
GlDrawcallback drawCallback;
drawCallback.m_wireframe = (debugMode & btIDebugDraw::DBG_DrawWireframe)!=0;
concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
}
#endif
#ifdef USE_DISPLAY_LISTS
}
}
#endif
/*
if (shape->getShapeType() == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE)
{
btConvexTriangleMeshShape* convexMesh = (btConvexTriangleMeshShape*) shape;
//todo: pass camera for some culling
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
btVector3 aabbMin(-btScalar(1e30),-btScalar(1e30),-btScalar(1e30));
TriangleGlDrawcallback drawCallback;
convexMesh->getMeshInterface()->InternalProcessAllTriangles(&drawCallback,aabbMin,aabbMax);
}
*/
glDisable(GL_DEPTH_BUFFER_BIT);
glRasterPos3f(0,0,0);//mvtx.x(), vtx.y(), vtx.z());
if (debugMode&btIDebugDraw::DBG_DrawText)
{
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),shape->getName());
}
if (debugMode& btIDebugDraw::DBG_DrawFeaturesText)
{
//BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),shape->getExtraDebugInfo());
}
glEnable(GL_DEPTH_BUFFER_BIT);
// glPopMatrix();
}
glPopMatrix();
}
GL_ShapeDrawer::GL_ShapeDrawer()
{
}
GL_ShapeDrawer::~GL_ShapeDrawer()
{
int i;
for (i=0;i<m_shapeHulls.size();i++)
{
btShapeHull* hull = m_shapeHulls[i];
hull->~btShapeHull();
btAlignedFree(hull);
m_shapeHulls[i] = 0;
}
m_shapeHulls.clear();
}
#endif

View File

@ -1,44 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef GL_SHAPE_DRAWER_H
#define GL_SHAPE_DRAWER_H
class btCollisionShape;
class btShapeHull;
#include "LinearMath/btAlignedObjectArray.h"
#include "LinearMath/btVector3.h"
/// OpenGL shape drawing
class GL_ShapeDrawer
{
//clean-up memory of dynamically created shape hulls
btAlignedObjectArray<btShapeHull*> m_shapeHulls;
public:
GL_ShapeDrawer();
virtual ~GL_ShapeDrawer();
///drawOpenGL might allocate temporary memoty, stores pointer in shape userpointer
void drawOpenGL(btScalar* m, const btCollisionShape* shape, const btVector3& color,int debugMode);
static void drawCylinder(float radius,float halfHeight, int upAxis);
static void drawCoordSystem();
};
void OGL_displaylist_register_shape(btCollisionShape * shape);
void OGL_displaylist_clean();
#endif //GL_SHAPE_DRAWER_H

View File

@ -1,79 +0,0 @@
#ifdef HAVE_GLUT
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "GL_Simplex1to4.h"
#include "BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h"
#include "GL_ShapeDrawer.h"
#ifdef WIN32
#include <windows.h>
#endif
//think different
#if defined(__APPLE__) && !defined (VMDMESA)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else
#include <GL/gl.h>
#endif
#include "GlutStuff.h"
#include "LinearMath/btTransform.h"
GL_Simplex1to4::GL_Simplex1to4()
:m_simplexSolver(0)
{
}
///
/// Debugging method calcClosest calculates the closest point to the origin, using m_simplexSolver
///
void GL_Simplex1to4::calcClosest(btScalar* m)
{
btTransform tr;
tr.setFromOpenGLMatrix(m);
GL_ShapeDrawer::drawCoordSystem();
if (m_simplexSolver)
{
m_simplexSolver->reset();
bool res;
btVector3 v;
for (int i=0;i<m_numVertices;i++)
{
v = tr(m_vertices[i]);
m_simplexSolver->addVertex(v,v,btPoint3(0.f,0.f,0.f));
res = m_simplexSolver->closest(v);
}
//draw v?
glDisable(GL_LIGHTING);
glBegin(GL_LINES);
btglColor3(1.f, 0.f, 0.f);
btglVertex3(0.f, 0.f, 0.f);
btglVertex3(v.x(),v.y(),v.z());
glEnd();
glEnable(GL_LIGHTING);
}
}
#endif

View File

@ -1,40 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef GL_SIMPLEX_1TO4_H
#define GL_SIMPLEX_1TO4_H
#include "BulletCollision/CollisionShapes/btTetrahedronShape.h"
#include "BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h"
///GL_Simplex1to4 is a class to debug a Simplex Solver with 1 to 4 points.
///Can be used by GJK.
class GL_Simplex1to4 : public btBU_Simplex1to4
{
btSimplexSolverInterface* m_simplexSolver;
public:
GL_Simplex1to4();
void calcClosest(btScalar* m);
void setSimplexSolver(btSimplexSolverInterface* simplexSolver) {
m_simplexSolver = simplexSolver;
}
};
#endif //GL_SIMPLEX_1TO4_H

View File

@ -1,101 +0,0 @@
#ifdef HAVE_GLUT
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "DemoApplication.h"
//glut is C code, this global gDemoApplication links glut to the C++ demo
static DemoApplication* gDemoApplication = 0;
#include "GlutStuff.h"
static void glutKeyboardCallback(unsigned char key, int x, int y)
{
gDemoApplication->keyboardCallback(key,x,y);
}
static void glutSpecialKeyboardCallback(int key, int x, int y)
{
gDemoApplication->specialKeyboard(key,x,y);
}
static void glutSpecialKeyboardUpCallback(int key, int x, int y)
{
gDemoApplication->specialKeyboardUp(key,x,y);
}
static void glutReshapeCallback(int w, int h)
{
gDemoApplication->reshape(w,h);
}
static void glutMoveAndDisplayCallback()
{
gDemoApplication->moveAndDisplay();
}
static void glutMouseFuncCallback(int button, int state, int x, int y)
{
gDemoApplication->mouseFunc(button,state,x,y);
}
static void glutMotionFuncCallback(int x,int y)
{
gDemoApplication->mouseMotionFunc(x,y);
}
static void glutDisplayCallback(void)
{
gDemoApplication->displayCallback();
}
int glutmain(int argc, char **argv,int width,int height,const char* title,DemoApplication* demoApp) {
gDemoApplication = demoApp;
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowPosition(0, 0);
glutInitWindowSize(width, height);
glutCreateWindow(title);
#ifdef BT_USE_FREEGLUT
glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
#endif
gDemoApplication->myinit();
glutKeyboardFunc(glutKeyboardCallback);
glutSpecialFunc(glutSpecialKeyboardCallback);
glutSpecialUpFunc(glutSpecialKeyboardUpCallback);
glutReshapeFunc(glutReshapeCallback);
//createMenu();
glutIdleFunc(glutMoveAndDisplayCallback);
glutMouseFunc(glutMouseFuncCallback);
glutMotionFunc(glutMotionFuncCallback);
glutDisplayFunc( glutDisplayCallback );
glutMoveAndDisplayCallback();
glutMainLoop();
return 0;
}
#endif

View File

@ -1,52 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef GLUT_STUFF_H
#define GLUT_STUFF_H
#ifdef WIN32//for glut.h
#include <windows.h>
#endif
//think different
#if defined(__APPLE__) && !defined (VMDMESA)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#if BT_USE_FREEGLUT
#include "GL/freeglut_ext.h" //to be able to return from glutMainLoop()
#endif
class DemoApplication;
int glutmain(int argc, char **argv,int width,int height,const char* title,DemoApplication* demoApp);
#if defined(BT_USE_DOUBLE_PRECISION)
#define btglLoadMatrix glLoadMatrixd
#define btglMultMatrix glMultMatrixd
#define btglColor3 glColor3d
#define btglVertex3 glVertex3d
#else
#define btglLoadMatrix glLoadMatrixf
#define btglMultMatrix glMultMatrixf
#define btglColor3 glColor3f
#define btglVertex3 glVertex3d
#endif
#endif //GLUT_STUFF_H

View File

@ -1,12 +0,0 @@
noinst_LIBRARIES = libbulletopenglsupport.a
libbulletopenglsupport_a_SOURCES = \
BMF_Api.cpp BMF_BitmapFont.h BMF_Fonts.h \
DemoApplication.cpp GLDebugDrawer.h GL_Simplex1to4.cpp \
GlutStuff.h BMF_Api.h BMF_FontData.h \
BMF_Settings.h DemoApplication.h GL_ShapeDrawer.cpp \
GL_Simplex1to4.h RenderTexture.cpp BMF_BitmapFont.cpp \
BMF_font_helv10.cpp DebugCastResult.h GLDebugDrawer.cpp \
GL_ShapeDrawer.h GlutStuff.cpp RenderTexture.h
AM_CPPFLAGS=-I$(srcdir)/../../src

View File

@ -1,73 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "RenderTexture.h"
#include <memory.h>
#include "BMF_FontData.h"
renderTexture::renderTexture(int width,int height)
:m_height(height),m_width(width)
{
m_buffer = new unsigned char[m_width*m_height*4];
//clear screen
memset(m_buffer,0,m_width*m_height*4);
//clear screen version 2
for (int x=0;x<m_width;x++)
{
for (int y=0;y<m_height;y++)
{
setPixel(x,y,btVector4(float(x),float(y),0.f,1.f));
}
}
}
void renderTexture::grapicalPrintf(char* str, BMF_FontData* fontData, int startx,int starty)
{
unsigned char c;
int rasterposx = startx;
int rasterposy = starty;
while ((c = (unsigned char) *str++)) {
BMF_CharData & cd = fontData->chars[c];
if (cd.data_offset!=-1) {
unsigned char* bitmap = &fontData->bitmap_data[cd.data_offset];
for (int y=0;y<cd.height;y++)
{
int bit = 128;
for (int x=0;x<cd.width;x++)
{
char packedColor = bitmap[y];
float colorf = packedColor & bit ? 0.f : 1.f;
btVector4 rgba(colorf,colorf,colorf,1.f);
setPixel(rasterposx+x,rasterposy+8-y-1,rgba);
bit >>=1;
}
}
}
rasterposx+= cd.advance;
}
}
renderTexture::~renderTexture()
{
delete [] m_buffer;
}

View File

@ -1,63 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef RENDER_TEXTURE_H
#define RENDER_TEXTURE_H
#include "LinearMath/btVector3.h"
#include "BMF_FontData.h"
///
///renderTexture provides a software-render context (setpixel/printf)
///
class renderTexture
{
int m_height;
int m_width;
unsigned char* m_buffer;
public:
renderTexture(int width,int height);
~renderTexture();
inline void setPixel(int x,int y,const btVector4& rgba)
{
unsigned char* pixel = &m_buffer[ (x+y*m_width) * 4];
pixel[0] = (unsigned char)(255*rgba.getX());
pixel[1] = (unsigned char)(255*rgba.getY());
pixel[2] = (unsigned char)(255*rgba.getZ());
pixel[3] = (unsigned char)(255*rgba.getW());
}
inline btVector4 getPixel(int x,int y)
{
unsigned char* pixel = &m_buffer[ (x+y*m_width) * 4];
return btVector4(pixel[0]*1.f/255.f,
pixel[1]*1.f/255.f,
pixel[2]*1.f/255.f,
pixel[3]*1.f/255.f);
}
const unsigned char* getBuffer() const { return m_buffer;}
int getWidth() const { return m_width;}
int getHeight() const { return m_height;}
void grapicalPrintf(char* str, BMF_FontData* fontData, int startx = 0,int starty=0);
};
#endif //RENDER_TEXTURE_H

View File

@ -19,14 +19,6 @@
#include "graphics/irr_driver.hpp"
#ifdef HAVE_GLUT
# ifdef __APPLE__
# include <GLUT/glut.h>
# else
# include <GL/glut.h>
# endif
#endif
#include "config/user_config.hpp"
#include "graphics/camera.hpp"
#include "graphics/material_manager.hpp"
@ -202,7 +194,7 @@ void IrrDriver::initDevice()
material2D.TextureLayer[n].TextureWrapU = ETC_CLAMP_TO_EDGE;
material2D.TextureLayer[n].TextureWrapV = ETC_CLAMP_TO_EDGE;
material2D.TextureLayer[n].LODBias = 8.0f;
material2D.TextureLayer[n].LODBias = 8;
}
material2D.AntiAliasing=video::EAAM_FULL_BASIC;
//m_video_driver->enableMaterial2D();
@ -525,7 +517,8 @@ scene::IMesh *IrrDriver::createQuadMesh(const video::SMaterial *material,
/** Creates a quad mesh buffer
*/
scene::IMesh *IrrDriver::createTexturedQuadMesh(const video::SMaterial *material, const double w, const double h)
scene::IMesh *IrrDriver::createTexturedQuadMesh(const video::SMaterial *material,
const double w, const double h)
{
scene::SMeshBuffer *buffer = new scene::SMeshBuffer();
@ -535,17 +528,17 @@ scene::IMesh *IrrDriver::createTexturedQuadMesh(const video::SMaterial *material
v1.TCoords = core::vector2d<f32>(0,1);
video::S3DVertex v2;
v2.Pos = core::vector3df(w,0,0);
v2.Pos = core::vector3df((float)w,0,0);
v2.Normal = core::vector3df(1/sqrt(2.0f), 1/sqrt(2.0f), 0);
v2.TCoords = core::vector2d<f32>(1,1);
video::S3DVertex v3;
v3.Pos = core::vector3df(w,h,0);
v3.Pos = core::vector3df((float)w,(float)h,0);
v3.Normal = core::vector3df(1/sqrt(2.0f), 1/sqrt(2.0f), 0);
v3.TCoords = core::vector2d<f32>(1,0);
video::S3DVertex v4;
v4.Pos = core::vector3df(0,h,0);
v4.Pos = core::vector3df(0,(float)h,0);
v4.Normal = core::vector3df(1/sqrt(2.0f), 1/sqrt(2.0f), 0);
v4.TCoords = core::vector2d<f32>(0,0);
@ -705,67 +698,6 @@ void IrrDriver::setAmbientLight(const video::SColor &light)
m_scene_manager->setAmbientLight(light);
} // setAmbientLight
// ----------------------------------------------------------------------------
/** Renders the bullet debug view using glut.
*/
void IrrDriver::renderBulletDebugView()
{
#ifdef HAVE_GLUT
// Use bullets debug drawer
GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };
/* light_position is NOT default value */
GLfloat light_position0[] = { 1.0, 1.0, 1.0, 0.0 };
GLfloat light_position1[] = { -1.0, -1.0, -1.0, 0.0 };
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
glLightfv(GL_LIGHT1, GL_POSITION, light_position1);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glClearColor(0.8f,0.8f,0.8f,0);
glCullFace(GL_BACK);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
float f=2.0f;
glFrustum(-f, f, -f, f, 1.0, 1000.0);
World *world = World::getWorld();
const Kart *kart = world->getKart(world->getNumKarts()-1);
Vec3 xyz = kart->getXYZ();
// Compute the camera position 5 units behind and 4 units higher than the kart
Vec3 cam_pos= kart->getTrans()(Vec3(0, -5, 4));
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(cam_pos.getX(), cam_pos.getY(), cam_pos.getZ(),
xyz.getX(), xyz.getY(), xyz.getZ(),
0.0f, 0.0f, 1.0f );
for (unsigned int i = 0 ; i < world->getNumKarts(); ++i)
{
Kart *kart=world->getKart((int)i);
if(!kart->isEliminated()) kart->draw();
}
world->getPhysics()->draw();
#endif
} // renderBulletDebugView
// ----------------------------------------------------------------------------
/** Displays the FPS on the screen.
*/
@ -847,34 +779,32 @@ void IrrDriver::update(float dt)
if (inRace)
{
if (UserConfigParams::m_bullet_debug)
RaceGUI *rg = world->getRaceGUI();
for(unsigned int i=0; i<world->getNumKarts(); i++)
{
renderBulletDebugView();
}
else
Kart *kart=world->getKart(i);
if(kart->getCamera())
{
kart->getCamera()->activate();
m_scene_manager->drawAll();
// Note that drawAll must be called before rendering
// the bullet debug view, since otherwise the camera
// is not set up properly.
if (UserConfigParams::m_bullet_debug)
World::getWorld()->getPhysics()->draw();
} // if kart->Camera
} // for i<world->getNumKarts()
// To draw the race gui we set the viewport back to the full
// screen.
m_video_driver->setViewPort(core::recti(0, 0,
UserConfigParams::m_width,
UserConfigParams::m_height));
for(unsigned int i=0; i<world->getNumKarts(); i++)
{
RaceGUI *rg = world->getRaceGUI();
for(unsigned int i=0; i<world->getNumKarts(); i++)
{
Kart *kart=world->getKart(i);
if(kart->getCamera())
{
kart->getCamera()->activate();
m_scene_manager->drawAll();
} // if kart->Camera
} // for i<world->getNumKarts()
// To draw the race gui we set the viewport back to the full
// screen.
m_video_driver->setViewPort(core::recti(0, 0,
UserConfigParams::m_width,
UserConfigParams::m_height));
for(unsigned int i=0; i<world->getNumKarts(); i++)
{
Kart *kart = world->getKart(i);
if(kart->getCamera())
rg->renderPlayerView(kart);
} // for i<getNumKarts
} // !bullet_debug
Kart *kart = world->getKart(i);
if(kart->getCamera())
rg->renderPlayerView(kart);
} // for i<getNumKarts
}
else
{
@ -884,7 +814,7 @@ void IrrDriver::update(float dt)
// The render and displayFPS calls interfere with bullet debug
// rendering, so they can not be called.
if(!inRace || !UserConfigParams::m_bullet_debug)
//FIXME if(!inRace || !UserConfigParams::m_bullet_debug)
{
// Either render the gui, or the global elements of the race gui.
GUIEngine::render(dt);

View File

@ -58,7 +58,6 @@ private:
void setAllMaterialFlags(scene::IAnimatedMesh *mesh) const;
std::vector<VideoMode> m_modes;
void renderBulletDebugView();
void displayFPS();
void setupViewports();
video::E_DRIVER_TYPE getEngineDriverType(int index);

View File

@ -673,50 +673,6 @@
>
</File>
</Filter>
<Filter
Name="Demos"
>
<Filter
Name="OpenGL"
>
<File
RelativePath="..\..\bullet\Demos\OpenGL\BMF_Api.cpp"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\BMF_BitmapFont.cpp"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\BMF_font_helv10.cpp"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\DemoApplication.cpp"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\GL_ShapeDrawer.cpp"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\GL_Simplex1to4.cpp"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\GLDebugDrawer.cpp"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\GlutStuff.cpp"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\RenderTexture.cpp"
>
</File>
</Filter>
</Filter>
</Filter>
<Filter
Name="Header Files"
@ -1251,62 +1207,6 @@
</File>
</Filter>
</Filter>
<Filter
Name="Demos"
>
<Filter
Name="OpenGL"
>
<File
RelativePath="..\..\bullet\Demos\OpenGL\BMF_Api.h"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\BMF_BitmapFont.h"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\BMF_FontData.h"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\BMF_Fonts.h"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\BMF_Settings.h"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\DebugCastResult.h"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\DemoApplication.h"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\GL_ShapeDrawer.h"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\GL_Simplex1to4.h"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\GLDebugDrawer.h"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\GlutStuff.h"
>
</File>
<File
RelativePath="..\..\bullet\Demos\OpenGL\RenderTexture.h"
>
</File>
</Filter>
</Filter>
</Filter>
<Filter
Name="Resource Files"

View File

@ -640,6 +640,10 @@
RelativePath="..\..\physics\btUprightConstraint.cpp"
>
</File>
<File
RelativePath="..\..\physics\irr_debug_drawer.cpp"
>
</File>
<File
RelativePath="..\..\physics\physical_object.cpp"
>
@ -1004,6 +1008,10 @@
RelativePath="..\..\states_screens\feature_unlocked.cpp"
>
</File>
<File
RelativePath="..\..\states_screens\grand_prix_over.cpp"
>
</File>
<File
RelativePath="..\..\states_screens\help_screen_1.cpp"
>
@ -1466,6 +1474,10 @@
RelativePath="..\..\physics\btUprightConstraint.hpp"
>
</File>
<File
RelativePath="..\..\physics\irr_debug_drawer.hpp"
>
</File>
<File
RelativePath="..\..\physics\kart_motion_state.hpp"
>
@ -1814,6 +1826,10 @@
RelativePath="..\..\states_screens\feature_unlocked.hpp"
>
</File>
<File
RelativePath="..\..\states_screens\grand_prix_over.hpp"
>
</File>
<File
RelativePath="..\..\states_screens\help_screen_1.hpp"
>

View File

@ -130,11 +130,14 @@ void InputManager::handleStaticAction(int key, int value)
}
break;
case KEY_F11:
// FIXME: at this stage you can only switch back from debug view to normal
// view, if switching again you noly get a grey screen - some opengl settings
// are missing.
if(value && control_is_pressed)
{
UserConfigParams::m_bullet_debug = !UserConfigParams::m_bullet_debug;
if(UserConfigParams::m_bullet_debug)
world->getPhysics()->activateDebug();
else
world->getPhysics()->deactivateDebug();
}
break;
case KEY_F5:
if (race_manager->getNumPlayers() ==1 )

View File

@ -23,8 +23,6 @@
#include <math.h>
#include <iostream>
#include "bullet/Demos/OpenGL/GL_ShapeDrawer.h"
#include "audio/sound_manager.hpp"
#include "audio/sfx_manager.hpp"
#include "audio/sfx_base.hpp"
@ -815,29 +813,6 @@ void Kart::handleZipper()
m_controller->handleZipper();
} // handleZipper
//-----------------------------------------------------------------------------
void Kart::draw()
{
float m[16];
btTransform t=getTrans();
t.getOpenGLMatrix(m);
btVector3 wire_color(0.5f, 0.5f, 0.5f);
//RaceManager::getWorld()->getPhysics()->debugDraw(m, m_body->getCollisionShape(),
// wire_color);
btCylinderShapeX wheelShape( btVector3(0.1f,
m_kart_properties->getWheelRadius(),
m_kart_properties->getWheelRadius()));
btVector3 wheelColor(0,0,1);
for(int i=0; i<m_vehicle->getNumWheels(); i++)
{
m_vehicle->updateWheelTransform(i, true);
float m[16];
m_vehicle->getWheelInfo(i).m_worldTransform.getOpenGLMatrix(m);
World::getWorld()->getPhysics()->debugDraw(m, &wheelShape, wheelColor);
}
} // draw
// -----------------------------------------------------------------------------
/** Returned an additional engine power boost when using nitro.
* \param dt Time step size.

View File

@ -329,7 +329,6 @@ public:
btKart *getVehicle () const {return m_vehicle; }
btUprightConstraint *getUprightConstraint() const {return m_uprightConstraint;}
void createPhysics ();
void draw ();
bool isInRest () const;
//have to use this instead of moveable getVelocity to get velocity for bullet rigid body
float getSpeed () const {return m_speed; }

View File

@ -69,15 +69,6 @@
#include "tracks/track_manager.hpp"
#include "utils/translation.hpp"
// Only needed for bullet debug!
#ifdef HAVE_GLUT
# ifdef __APPLE__
# include <GLUT/glut.h>
# else
# include <GL/glut.h>
# endif
#endif
void cmdLineHelp (char* invocation)
{
fprintf ( stdout,
@ -254,12 +245,10 @@ int handleCmdLine(int argc, char **argv)
{
UserConfigParams::m_track_debug=1;
}
#ifdef HAVE_GLUT
else if(!strcmp(argv[i], "--bullet-debug"))
{
UserConfigParams::m_bullet_debug=1;
}
#endif
else if(!strcmp(argv[i], "--kartsize-debug"))
{
UserConfigParams::m_print_kart_sizes=true;
@ -441,7 +430,7 @@ int handleCmdLine(int argc, char **argv)
else
{
printf("Profiling: %d seconds.\n", n);
ProfileWorld::setProfileModeTime(n);
ProfileWorld::setProfileModeTime((float)n);
race_manager->setNumLaps(999999); // profile end depends on time
}
}
@ -572,10 +561,6 @@ void cleanTuxKart()
int main(int argc, char *argv[] )
{
try {
#ifdef HAVE_GLUT
// only needed for bullet debugging.
glutInit(&argc, argv);
#endif
// Init the minimum managers so that user config exists, then
// handle all command line options that do not need (or must
// not have) other managers initialised:

View File

@ -0,0 +1,71 @@
// $Id: irr_debug_drawer.cpp 839 2006-10-24 00:01:56Z hiker $
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2010 Joerg Henrichs
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "physics/irr_debug_drawer.hpp"
#include "modes/world.hpp"
IrrDebugDrawer::IrrDebugDrawer()
{
m_debug_mode = DBG_DrawAabb;
} // IrrDebugDrawer
// -----------------------------------------------------------------------------
/** Activates the debug view. It makes all karts invisible (in irrlicht), so
* that the bullet view can be seen.
*/
void IrrDebugDrawer::activate()
{
World *world = World::getWorld();
unsigned int num_karts = world->getNumKarts();
for(unsigned int i=0; i<num_karts; i++)
{
Kart *kart = world->getKart(i);
if(kart->isEliminated()) continue;
kart->getNode()->setVisible(false);
}
} // activate
// -----------------------------------------------------------------------------
/** Deactivates the bullet debug view, and makes all karts visible again.
*/
void IrrDebugDrawer::deactivate()
{
World *world = World::getWorld();
unsigned int num_karts = world->getNumKarts();
for(unsigned int i=0; i<num_karts; i++)
{
Kart *kart = world->getKart(i);
if(kart->isEliminated()) continue;
kart->getNode()->setVisible(true);
}
} // deactivate
// -----------------------------------------------------------------------------
void IrrDebugDrawer::drawLine(const btVector3& from, const btVector3& to,
const btVector3& color)
{
Vec3 f(from);
Vec3 t(to);
video::SColor c(255, (int)(color.getX()*255), (int)(color.getY()*255),
(int)(color.getZ()*255) );
irr_driver->getVideoDriver()->draw3DLine(f.toIrrVector(),
t.toIrrVector(), c);
}
/* EOF */

View File

@ -0,0 +1,59 @@
// $Id: irr_debug_drawer.hpp 839 2006-10-24 00:01:56Z hiker $
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2006 Joerg Henrichs
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_IRR_DEBUG_DRAWER_HPP
#define HEADER_IRR_DEBUG_DRAWER_HPP
#include "irrlicht.h"
using namespace irr;
#include "btBulletDynamicsCommon.h"
#include "graphics/irr_driver.hpp"
#include "utils/vec3.hpp"
class IrrDebugDrawer : public btIDebugDraw
{
/** The drawing mode to use. */
int m_debug_mode;
public:
IrrDebugDrawer();
void render(float dt);
/** Draws a line. */
virtual void drawLine(const btVector3& from, const btVector3& to,
const btVector3& color);
///optional debug methods
virtual void drawContactPoint(const btVector3& Point_on_b,
const btVector3& normal_on_b,
btScalar distance,int life_time,
const btVector3& color) {}
virtual void reportErrorWarning(const char* warningString) {}
virtual void draw3dText(const btVector3& location,
const char* textString) {}
virtual void setDebugMode(int debug_mode) { m_debug_mode = debug_mode; }
virtual int getDebugMode() const { return m_debug_mode; }
void activate();
void deactivate();
}; // IrrDebugDrawer
#endif
/* EOF */

View File

@ -23,6 +23,7 @@
#include "network/race_state.hpp"
#include "physics/btKart.hpp"
#include "physics/btUprightConstraint.hpp"
#include "physics/irr_debug_drawer.hpp"
#include "tracks/track.hpp"
// ----------------------------------------------------------------------------
@ -49,22 +50,15 @@ void Physics::init(const Vec3 &world_min, const Vec3 &world_max)
m_collision_conf);
m_dynamics_world->setGravity(btVector3(0.0f, 0.0f,
-World::getWorld()->getTrack()->getGravity()));
#ifdef HAVE_GLUT
if(UserConfigParams::m_bullet_debug)
{
m_debug_drawer = new GLDebugDrawer();
m_debug_drawer->setDebugMode(btIDebugDraw::DBG_DrawWireframe);
m_dynamics_world->setDebugDrawer(m_debug_drawer);
}
#endif
m_debug_drawer = new IrrDebugDrawer();
m_debug_drawer->setDebugMode(btIDebugDraw::DBG_DrawWireframe);
m_dynamics_world->setDebugDrawer(m_debug_drawer);
} // init
//-----------------------------------------------------------------------------
Physics::~Physics()
{
#ifdef HAVE_GLUT
if(UserConfigParams::m_bullet_debug) delete m_debug_drawer;
#endif
delete m_dynamics_world;
delete m_axis_sweep;
delete m_dispatcher;
@ -349,44 +343,21 @@ btScalar Physics::solveGroup(btCollisionObject** bodies, int numBodies,
/** A debug draw function to show the track and all karts. */
void Physics::draw()
{
int num_objects = m_dynamics_world->getNumCollisionObjects();
for(int i=0; i<num_objects; i++)
{
btCollisionObject *obj = m_dynamics_world->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
if(!body) continue;
float m[16];
btVector3 wireColor(1,0,0);
btDefaultMotionState *myMotion = (btDefaultMotionState*)body->getMotionState();
if(myMotion)
{
myMotion->m_graphicsWorldTrans.getOpenGLMatrix(m);
// Karts need culling GL_FRONT (not sure why), otherwise they appear to
// rotate incorrectly due to incorrect culling
UserPointer *up = (UserPointer*)body->getUserPointer();
if(up->is(UserPointer::UP_KART))
glCullFace(GL_FRONT);
debugDraw(m, obj->getCollisionShape(), wireColor);
}
} // for i
video::SColor color(77,179,0,0);
video::SMaterial material;
material.Thickness = 2;
material.AmbientColor = color;
material.DiffuseColor = color;
material.EmissiveColor= color;
material.BackfaceCulling = false;
material.setFlag(video::EMF_LIGHTING, false);
irr_driver->getVideoDriver()->setMaterial(material);
irr_driver->getVideoDriver()->setTransform(video::ETS_WORLD,
core::IdentityMatrix);
m_dynamics_world->debugDrawWorld();
return;
} // draw
// -----------------------------------------------------------------------------
/** Helper function for Physics::draw(). It calls the shape drawer from
* bullet to render the actual object.
* \param m OpenGL matrix to apply.
* \param s Collision shape to drwa.
* \param color Colour to use.
*/
void Physics::debugDraw(float m[16], btCollisionShape *s, const btVector3 color)
{
#ifdef HAVE_GLUT
m_shape_drawer.drawOpenGL(m, s, color, 0);
// btIDebugDraw::DBG_DrawWireframe);
// btIDebugDraw::DBG_DrawAabb);
#endif
} // debugDraw
// -----------------------------------------------------------------------------
/* EOF */

View File

@ -24,9 +24,8 @@
#include <vector>
#include "btBulletDynamicsCommon.h"
#include "bullet/Demos/OpenGL/GLDebugDrawer.h"
#include "bullet/Demos/OpenGL/GL_ShapeDrawer.h"
#include "Physics/irr_debug_drawer.hpp"
#include "physics/user_pointer.hpp"
class Vec3;
@ -83,10 +82,7 @@ private:
}; // CollisionList
btDynamicsWorld *m_dynamics_world;
#ifdef HAVE_GLUT
GLDebugDrawer *m_debug_drawer;
GL_ShapeDrawer m_shape_drawer;
#endif
IrrDebugDrawer *m_debug_drawer;
btCollisionDispatcher *m_dispatcher;
btBroadphaseInterface *m_axis_sweep;
btDefaultCollisionConfiguration *m_collision_conf;
@ -106,6 +102,10 @@ public:
btDynamicsWorld*
getPhysicsWorld () const {return m_dynamics_world;}
void debugDraw (float m[16], btCollisionShape *s, const btVector3 color);
/** Activates the debug drawer. */
void activateDebug () {m_debug_drawer->activate(); }
/** Deactivates the debug drawer. */
void deactivateDebug () {m_debug_drawer->deactivate(); }
bool projectKartDownwards(const Kart *k);
virtual btScalar solveGroup(btCollisionObject** bodies, int numBodies,
btPersistentManifold** manifold,int numManifolds,

View File

@ -290,7 +290,7 @@ void GrandPrixOver::setKarts(const std::string idents_arg[3])
kart_main_node = irr_driver->addMesh(kartModel->getModel());
kart_main_node->setPosition( core::vector3df(m_kart_x[n], m_kart_y[n], m_kart_z[n]) );
kart_main_node->setScale( core::vector3df(0.4f, 0.4, 0.4f) );
kart_main_node->setScale( core::vector3df(0.4f, 0.4f, 0.4f) );
kart_main_node->updateAbsolutePosition();
for (int wheel=0; wheel<4; wheel++)