Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Merge branch 'gltf-failed'
Browse files Browse the repository at this point in the history
It turns out having GLTF available separately is still useful if I
want to load things straight from GLB to bullet.

I also updated .gitignore to exclude some Ogre stuff.
  • Loading branch information
makuto committed Oct 4, 2019
2 parents 1842f1a + 3decc77 commit 3b82e66
Show file tree
Hide file tree
Showing 36 changed files with 1,393 additions and 121 deletions.
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,21 @@
*.exe
*.out
*.app
spargus_vehicle_prototype
spargus_vehicle_prototype_ogre
spargus_vehicle_prototype_opengl

# Blender backups
*.blend1

# Emacs stuff
TAGS

# Ogre stuff
*.cache
Ogre.log
hlmsDiskCache*
100000000PixelShader_ps.glsl
100000000VertexShader_vs.glsl
300000000PixelShader_ps.glsl
300000000VertexShader_vs.glsl
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "base2.0"]
path = base2.0
url = https://github.com/makuto/base2.0
[submodule "tinygltf"]
path = tinygltf
url = https://github.com/syoyo/tinygltf.git
4 changes: 3 additions & 1 deletion Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ SubDir . ;

Main spargus_vehicle_prototype : src/Main.cpp
src/Camera.cpp
src/ModelUtilities/ModelLoader.cpp
src/ModelUtilities/ModelToBullet.cpp
src/PhysicsVehicle.cpp
src/PhysicsWorld.cpp
src/DebugDraw.cpp
;
;

# LinkLibraries spargus_vehicle_prototype : libBase20 ;

Expand Down
3 changes: 2 additions & 1 deletion Jamrules
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ LINK = clang++ ;
# BT_USE_DOUBLE_PRECISION solves the Dantzig LCP missing definition
C++FLAGS = -std=c++11 -Wall -Wextra -Wno-unused-parameter -DBT_USE_DOUBLE_PRECISION -g ;

HDRS = src bullet3/src base2.0 ;
HDRS = src bullet3/src base2.0 tinygltf ;

if $(DEBUG_BUILD)
{ BULLET3_BUILD_DIR = bullet3/build_cmake_debug ; }
Expand All @@ -39,6 +39,7 @@ LINKLIBS =
# OpenGL
-lGL
-lGLU
-lGLEW

# Base
-Lbase2.0 -lBase20
Expand Down
5 changes: 4 additions & 1 deletion ReadMe.org
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ Clone and init submodules for dependencies:
git clone --recurse-submodules https://github.com/makuto/spargus-vehicle-prototype
#+END_SRC

Install Jam. (*TODO:* add instructions)
Jam is used to build the project. Install Jam:
#+BEGIN_SRC sh
sudo apt install jam
#+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...)
Expand Down
Binary file added assets/BasicBuggy.blend
Binary file not shown.
Binary file added assets/Plane.blend
Binary file not shown.
Binary file added assets/Plane.glb
Binary file not shown.
49 changes: 49 additions & 0 deletions assets/ScaleNotes.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
* Dimensions

| Thing | Dimension | Size (meters) |
|-------------+----------------+---------------|
| Jak | Height | 1.799 |
| Car | Width | 3.61509 |
| Chassis | Width | 1.418 |
| | Length | 4.42349 |
| | Height (front) | 0.5 |
| | Height (rear) | 2.2447 |
| Rear wheel | Diameter | 1.6439 |
| | Width (tread) | 0.54 |
| Front wheel | Diameter | 1.29046 |
| | Width (tread) | 0.419 |

** DesertScreamer_Rear
Jak is 664 pixels tall
1.799m
(from [[https://msis.jsc.nasa.gov/sections/section03.htm#3.3.1%20Body%20Size][NASA body size]])

Car is 1236 pixels wide (including wheels)
0.53 Jak height to car width (or vise versa)

Actual car width (had to eyeball due to perspective): 3.61509m

Chassis width 485px 0.39 of total car width (1.418m). Roll cage referenced.
It would be a smart idea to roll the car and look at its skidplate...

Chassis height is eyeballed. It is top of seat, not top of frame.

** DesertScreamer_Side
Rear wheel has 713 pixel diameter
From front of rear wheel to back of front wheel = 641px (0.899 of 1 wheel)

Front wheel is 0.785 of 1 wheel

* Mass
Average dune buggy ~1000lbs (453kg)

[[https://en.wikipedia.org/wiki/Dune_buggy][Wikipedia on dune buggies]]

* Screen position
Camera pulls out and pitches a bit upwards when moving.
** Moving
Front of car to bottom of screen: 373px
to top of screen: 490px

Car takes up bottom 43%

Binary file added assets/ScaleReference.blend
Binary file not shown.
Binary file added assets/World.blend
Binary file not shown.
Binary file added assets/World.glb
Binary file not shown.
Binary file added references/Jak3MovingScreenPos.xcf
Binary file not shown.
Binary file added references/Jak3Reference1.zip
Binary file not shown.
Binary file added references/Jak3Reference1/20190928_122409.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added references/Jak3Reference1/20190928_122417.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added references/Jak3Reference1/20190928_122430.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added references/Jak3Reference1/20190928_122436.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added references/Jak3Reference1/20190928_122444.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added references/Jak3Reference1/20190928_122455.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added references/Jak3Reference1/20190928_122503.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added references/Jak3Reference1/20190928_122518.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 9 additions & 58 deletions src/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,71 +99,22 @@ void Camera::UpdateStart()

void Camera::ChaseCamera(double* openGlMatrix)
{
const double cameraHeight = 15.0;
const double cameraPullback = -15.0;
const double cameraPitch = 30.0;
const double cameraHeight = 4.0;
const double cameraPullback = 15.0;
// const double cameraPitch = 30.0;

// Undo old matrix
glPopMatrix();

glLoadIdentity();

// Look at method
// if (true)
// {
// // double position[] = {openGlMatrix[12], openGlMatrix[13] + cameraHeight,
// // openGlMatrix[14]};
// double position[] = {openGlMatrix[12], openGlMatrix[13] + cameraHeight,
// 0.}; // openGlMatrix[14] + cameraPullback};
// // Offset position
// // Look at target
// double targetPosition[] = {openGlMatrix[12], openGlMatrix[13], openGlMatrix[14]};
// // double targetPosition[] = {0., 0., 0.};
// gluLookAt(
// /*Position=*/position[0], position[1], position[2],
// /*Look at (world space)=*/targetPosition[0], targetPosition[1], targetPosition[2],
// /*Up vector=*/0, 1, 0);
// }

// Look at method 2
if (false)
{
// double position[] = {openGlMatrix[12], openGlMatrix[13] + cameraHeight,
// openGlMatrix[14]};
double position[] = {openGlMatrix[12], openGlMatrix[13], openGlMatrix[14]};
// Offset position
// Look at target
double targetPosition[] = {openGlMatrix[12], openGlMatrix[13], openGlMatrix[14]};
// double targetPosition[] = {0., 0., 0.};
gluLookAt(
/*Position=*/position[0], position[1], position[2],
/*Look at (world space)=*/targetPosition[0], targetPosition[1], targetPosition[2],
/*Up vector=*/0, 1, 0);

// glTranslatef(0.f, cameraHeight, cameraPullback);
}
glRotatef(180.f, 0, 1, 0);
glTranslatef(0.f, -cameraHeight, cameraPullback);

// Manual method
if (true)
{
glRotatef(180.f, 0, 1, 0);
// glTranslatef(0.f, -cameraHeight, cameraPullback);
glTranslatef(0.f, -4.f, 8.f);
// double rotMatNoTransform[][4] = {
// {openGlMatrix[0], openGlMatrix[1], openGlMatrix[2], 0},
// {openGlMatrix[4], openGlMatrix[5], openGlMatrix[6], 0},
// {openGlMatrix[7], openGlMatrix[8], openGlMatrix[9], 0},
// {0., 0., 0., 1.},
// };

glMultMatrixd(openGlMatrix);
// glMultMatrixd(rotMatNoTransform);
// glRotatef(camRot[0], 1, 0, 0);
// glRotatef(camRot[2], 0, 0, 1);

// Pitch camera
// glRotated(cameraPitch, 1, 0, 0);
}
glMultMatrixd(openGlMatrix);

// Pitch camera
// glRotated(cameraPitch, 1, 0, 0);

glPushMatrix();
}
Expand Down
31 changes: 28 additions & 3 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <map>

#include "Camera.hpp"
#include "ModelUtilities/ModelLoader.hpp"
#include "ModelUtilities/ModelToBullet.hpp"
#include "PhysicsVehicle.hpp"
#include "PhysicsWorld.hpp"

Expand Down Expand Up @@ -119,8 +121,29 @@ int main()

inputManager input(&mainWindow);

// Ground mesh from GLTF
{
// if (!LoadModelFromGltf("assets/World.glb", groundModel))
std::vector<gltf::Mesh<float>> meshes;
std::vector<gltf::Material> materials;
std::vector<gltf::Texture> textures;
bool debugOutput = false;
if (!gltf::LoadGLTF("assets/World.glb", /*scale=*/1.f, &meshes, &materials, &textures,
debugOutput))
// if (!gltf::LoadGLTF("assets/Plane.glb", /*scale=*/50.f, &meshes, &materials, &textures,
// debugOutput))
return 1;
for (const gltf::Mesh<float>& mesh : meshes)
BulletMeshFromGltfMesh(mesh, physicsWorld);
}

// initModel(groundModel);

// GLCallListIndex groundModelCallList = buildCallListFromModel(groundModel);
// GLCallListIndex groundModelCallList = buildCallListFromModel2(groundModel);

// OpenGL world setup
GLuint groundCallList = -1;
int groundCallList = -1;
{
glEnable(GL_DEPTH_TEST);
// glEnable(GL_LIGHTING);
Expand All @@ -132,7 +155,8 @@ int main()
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

gluPerspective(60, mainWindow.getWidth() / mainWindow.getHeight(), 1, 500);
float fieldOfView = 60.f;
gluPerspective(fieldOfView, mainWindow.getWidth() / mainWindow.getHeight(), 1, 500);
glRotatef(0, 0, 1, 0);

// Floor
Expand Down Expand Up @@ -185,6 +209,7 @@ int main()

Camera cam(mainWindow);
bool useChaseCam = true;
// bool useChaseCam = false;

while (!mainWindow.shouldClose() && !input.isPressed(inputCode::Escape))
{
Expand All @@ -209,7 +234,7 @@ int main()
cam.ChaseCamera(vehicleMat);
}

glCallList(groundCallList);
// glCallList(groundCallList);

physicsWorld.DebugRender();

Expand Down
Loading

0 comments on commit 3b82e66

Please sign in to comment.