Browse Source

Added skeleton build

* Not yet building due to linking issues
* I copied from the ForkLift bullet example for the basic world initialization
ogre-integration
Macoy Madson 1 year ago
parent
commit
d5821d7b7f
9 changed files with 257 additions and 1 deletions
  1. +22
    -0
      .clang-format
  2. +5
    -0
      .dir-locals.el
  3. +3
    -0
      .gitmodules
  4. +10
    -0
      BuildDependencies.sh
  5. +8
    -0
      Jamfile
  6. +85
    -0
      Jamrules
  7. +22
    -1
      ReadMe.org
  8. +1
    -0
      base2.0
  9. +101
    -0
      src/Main.cpp

+ 22
- 0
.clang-format View File

@ -0,0 +1,22 @@
# http://releases.llvm.org/6.0.0/tools/clang/docs/ClangFormatStyleOptions.html
BasedOnStyle: Google
AccessModifierOffset: -4
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
BreakBeforeBraces: Allman
BraceWrapping:
AfterNamespace: false
BreakBeforeTernaryOperators: false
ColumnLimit: 100
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
IndentWidth: 4
Standard: Cpp11
TabWidth: 4
UseTab: ForIndentation
DerivePointerAlignment: false
PointerAlignment: Left
NamespaceIndentation: None
IndentCaseLabels: true

+ 5
- 0
.dir-locals.el View File

@ -0,0 +1,5 @@
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
((c++-mode . ((compile-command . "cd /home/macoy/Development/code/repositories/spargus-vehicle-prototype && jam -j4 && ./spargus_vehicle_prototype")))
(c-or-c++-mode . ((codesearch-dir-to-index . "/home/macoy/Development/code/repositories/spargus-vehicle-prototype"))))

+ 3
- 0
.gitmodules View File

@ -1,3 +1,6 @@
[submodule "bullet3"]
path = bullet3
url = https://github.com/bulletphysics/bullet3
[submodule "base2.0"]
path = base2.0
url = https://github.com/makuto/base2.0

+ 10
- 0
BuildDependencies.sh View File

@ -0,0 +1,10 @@
#!/bin/sh
echo Building Bullet3...
cd bullet3 && ./build_cmake_pybullet_double.sh
echo Finished building Bullet3!
echo
echo Building Base2.0...
# TODO: Fix this foolishness
cd ../base2.0 && jam -j4 && jam -j4 libBase20
echo Finished building Base2.0!

+ 8
- 0
Jamfile View File

@ -0,0 +1,8 @@
SubDir . ;
Main spargus_vehicle_prototype : src/Main.cpp ;
# LinkLibraries spargus_vehicle_prototype : libBase20 ;
# SubInclude . base2.0 ;

+ 85
- 0
Jamrules View File

@ -0,0 +1,85 @@
# Building Tests:
# jam clean
# jam -j4 -q
# (if building the same target repeatedly, don't clean, if that wasn't obvious)
##
## Compiler
##
C++ = clang++ ;
LINK = clang++ ;
# LINKFLAGS = -shared ;
if $(UNIX) { SUFSHR = .so ; }
else if $(NT) { SUFSHR = .dll ; }
##
## Compiler arguments
##
# Arguments used on all projects, regardless of any variables
C++FLAGS = -std=c++11 -Wall -Wextra -Wno-unused-parameter ;
# Enable debug symbols
ALLLIBSC++FLAGS = -g ;
# Required arguments for linux
# LINUXC++FLAGS = -g ;
LINKLIBS = -lsfml-audio -lsfml-graphics -lsfml-window -lsfml-system
-lpthread -ldl
-Lbase2.0 -lBase20
-Lbullet3/build_cmake/src/Bullet3Dynamics
-Lbullet3/build_cmake/src/Bullet3Collision
-Lbullet3/build_cmake/src/Bullet3Common
-Lbullet3/build_cmake/src/BulletDynamics
-Lbullet3/build_cmake/src/BulletCollision
-Lbullet3/build_cmake/examples/ThirdPartyLibs/clsocket
# -Lbullet3/build_cmake/src/BulletCommon
-lclsocket
-Lbullet3/build_cmake/src/LinearMath
-lBullet3Common
-lBullet3Dynamics
-lBullet3Collision
# -lBulletCommon
-lBulletDynamics
-lBulletCollision
-lLinearMath ;
LINKFLAGS = -Wl,-rpath,. ;
KEEPOBJS = true ; # This doesn't actually fix anything, though it seems like it should
NOARSCAN = true ; # This actually fixes the problem
#AR = ar rUu ; # I was thinking maybe the AR command was wrong (always outputting deterministically)
# It doesn't seem like this is the problem though
AR = ar cr ;
OPTIM = -O0 ;
HDRS = src bullet3/src base2.0 ;
# E.g.
# jam -j4 -q -sCROSS_COMPILE_WINDOWS=true
if $(CROSS_COMPILE_WINDOWS)
{
CC = x86_64-w64-mingw32-gcc ;
LINK = x86_64-w64-mingw32-gcc ;
AR = x86_64-w64-mingw32-ar ;
SUFSHR = .dll ;
}
# Some helpful Jam commands
# -q : stop on failed target
# -jN : use N cores
# -sVAR=VAL : Set VAR to VAL. Note that setting WINDOWS=false is the same as setting UNREAL=true,
# frustratingly
# -dx : print commands being used
# -n : don't actually run commands

+ 22
- 1
ReadMe.org View File

@ -2,8 +2,29 @@
This is a 3D vehicle game prototype inspired by the gameplay and feel of the dune buggies in [[https://en.wikipedia.org/wiki/Jak_3][Jak 3]].
** Setup
Spargus Vehicle Prototype uses [[https://github.com/bulletphysics/bullet3][Bullet3]] for physics.
Clone and init submodules for dependencies:
#+BEGIN_SRC sh
git clone --recurse-submodules https://github.com/makuto/spargus-vehicle-prototype
#+END_SRC
*** SFML Setup
SFML is used for graphics, window, and input. I used my old [[https://github.com/makuto/base2.0][base2.0]] library to wrap SFML if I ever want to switch to SDL (I should dump base2.0 eventually...)
Running ~BuildDependencies.sh~ will build base2.0. You will need to have installed SFML 2 already. (*TODO:* Add instructions on how to do this)
*** Bullet3 Setup
Spargus Vehicle Prototype uses [[https://github.com/bulletphysics/bullet3][Bullet3]] for physics.
Build bullet3:
#+BEGIN_SRC sh
cd spargus-vehicle-prototype
./BuildDependencies.sh
#+END_SRC
/Optional:/ Test the examples:
#+BEGIN_SRC sh
./bullet3/build_cmake/examples/ExampleBrowser/App_ExampleBrowser
#+END_SRC

+ 1
- 0
base2.0

@ -0,0 +1 @@
Subproject commit 56a5468d755653ad69b696c57d86be65c1a17453

+ 101
- 0
src/Main.cpp View File

@ -0,0 +1,101 @@
#include <iostream>
#include "btBulletDynamicsCommon.h"
#include "BulletDynamics/MLCPSolvers/btDantzigLCP.h"
#include "BulletDynamics/MLCPSolvers/btDantzigSolver.h"
#include "BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h"
#include "BulletDynamics/MLCPSolvers/btMLCPSolver.h"
#include "BulletDynamics/Vehicle/btRaycastVehicle.h"
#include "graphics/graphics.hpp"
#include "input/input.hpp"
// TODO: Find out what this means
bool bulletUseMCLPSolver = true;
// Window variables
int WindowWidth = 1200;
int WindowHeight = 700;
#define WIN_BACKGROUND_COLOR 34, 34, 34, 255
struct BulletWorld
{
btDefaultCollisionConfiguration* collisionConfiguration;
btCollisionDispatcher* collisionDispatcher;
btBroadphaseInterface* overlappingPairCache;
btConstraintSolver* constraintSolver;
btDiscreteDynamicsWorld* world;
BulletWorld()
{
// btVector3 groundExtents(50, 50, 50);
// groundExtents[upAxis] = 3;
// btCollisionShape* groundShape = new btBoxShape(groundExtents);
// m_collisionShapes.push_back(groundShape);
collisionConfiguration = new btDefaultCollisionConfiguration();
collisionDispatcher = new btCollisionDispatcher(collisionConfiguration);
btVector3 worldMin(-1000, -1000, -1000);
btVector3 worldMax(1000, 1000, 1000);
overlappingPairCache = new btAxisSweep3(worldMin, worldMax);
if (bulletUseMCLPSolver)
{
btDantzigSolver* mlcp = new btDantzigSolver();
// btSolveProjectedGaussSeidel* mlcp = new btSolveProjectedGaussSeidel;
btMLCPSolver* sol = new btMLCPSolver(mlcp);
constraintSolver = sol;
}
else
{
constraintSolver = new btSequentialImpulseConstraintSolver();
}
world = new btDiscreteDynamicsWorld(collisionDispatcher, overlappingPairCache,
constraintSolver, collisionConfiguration);
if (bulletUseMCLPSolver)
{
// for direct solver it is better to have a small A matrix
world->getSolverInfo().m_minimumSolverBatchSize = 1;
}
else
{
// for direct solver, it is better to solve multiple objects together, small batches
// have high overhead
world->getSolverInfo().m_minimumSolverBatchSize = 128;
}
world->getSolverInfo().m_globalCfm = 0.00001;
}
};
void initializeWindow(window& win)
{
win.setBackgroundColor(WIN_BACKGROUND_COLOR);
// shouldClose manages some state
win.shouldClose();
win.update();
win.shouldClear(true);
win.getBase()->setVerticalSyncEnabled(true);
win.getBase()->setFramerateLimit(30);
}
void windowResizeCB(float width, float height)
{
WindowWidth = width;
WindowHeight = height;
}
int main()
{
std::cout << "Spargus Vehicle Prototype\n";
BulletWorld physicsWorld;
window mainWindow(WindowWidth, WindowHeight, "Spargus Vehicle Prototype", &windowResizeCB);
initializeWindow(mainWindow);
inputManager input(&mainWindow);
}

Loading…
Cancel
Save