Skip to content

Commit

Permalink
vecmath is now a submodule.
Browse files Browse the repository at this point in the history
  • Loading branch information
sherbondy committed Sep 30, 2012
0 parents commit 055c754
Show file tree
Hide file tree
Showing 36 changed files with 215,336 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.o
a2
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vecmath"]
path = vecmath
url = https://github.com/sherbondy/vecmath
1 change: 1 addition & 0 deletions Joint.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "Joint.h"
19 changes: 19 additions & 0 deletions Joint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef JOINT_H
#define JOINT_H

#include <vector>
#include <vecmath.h>

struct Joint
{
Matrix4f transform; // transform relative to its parent
std::vector< Joint* > children; // list of children

// This matrix transforms world space into joint space for the initial ("bind") configuration of the joints.
Matrix4f bindWorldToJointTransform;

// This matrix maps joint space into world space for the *current* configuration of the joints.
Matrix4f currentJointToWorldTransform;
};

#endif
52 changes: 52 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
UNAME := $(shell uname)

ifeq ($(UNAME),Darwin)
INCFLAGS = -I vecmath/include/

FRAMEWORKS = -framework Glut
FRAMEWORKS += -framework OpenGL
FRAMEWORKS += -framework Cocoa
FRAMEWORKS += -framework AGL
FRAMEWORKS += -framework Carbon

LINKFLAGS += -L vecmath/lib/ -lvecmath
else
INCFLAGS = -I /usr/include/GL
INCFLAGS += -I /mit/6.837/public/include/vecmath

LINKFLAGS = -lglut -lGL -lGLU
LINKFLAGS += -L /mit/6.837/public/lib -lvecmath
endif

LINKFLAGS += -lfltk -lfltk_gl

CFLAGS = -g
CFLAGS += -DSOLN
CC = g++
SRCS = bitmap.cpp camera.cpp MatrixStack.cpp modelerapp.cpp modelerui.cpp ModelerView.cpp Joint.cpp SkeletalModel.cpp Mesh.cpp main.cpp
OBJS = $(SRCS:.cpp=.o)
PROG = a2

all: $(SRCS) $(PROG)

$(PROG): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $@ $(LINKFLAGS) $(FRAMEWORKS)

.cpp.o:
$(CC) $(CFLAGS) $< -c -o $@ $(INCFLAGS)

depend:
makedepend $(INCFLAGS) -Y $(SRCS)

clean:
rm $(OBJS) $(PROG)

bitmap.o: bitmap.h
camera.o: camera.h
Mesh.o: Mesh.h
MatrixStack.o: MatrixStack.h
modelerapp.o: modelerapp.h ModelerView.h modelerui.h bitmap.h camera.h
modelerui.o: modelerui.h ModelerView.h bitmap.h camera.h modelerapp.h
ModelerView.o: ModelerView.h camera.h
SkeletalModel.o: MatrixStack.h ModelerView.h Joint.h modelerapp.h

28 changes: 28 additions & 0 deletions MatrixStack.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "MatrixStack.h"

MatrixStack::MatrixStack()
{
// Initialize the matrix stack with the identity matrix.
}

void MatrixStack::clear()
{
// Revert to just containing the identity matrix.
}

Matrix4f MatrixStack::top()
{
// Return the top of the stack
}

void MatrixStack::push( const Matrix4f& m )
{
// Push m onto the stack.
// Your stack should have OpenGL semantics:
// the new top should be the old top multiplied by m
}

void MatrixStack::pop()
{
// Remove the top element from the stack
}
22 changes: 22 additions & 0 deletions MatrixStack.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef MATRIX_STACK_H
#define MATRIX_STACK_H

#include <vector>
#include <vecmath.h>

class MatrixStack
{
public:
MatrixStack();
void clear();
Matrix4f top();
void push( const Matrix4f& m );
void pop();

private:

std::vector< Matrix4f > m_matrices;

};

#endif // MATRIX_STACK_H
28 changes: 28 additions & 0 deletions Mesh.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "Mesh.h"

using namespace std;

void Mesh::load( const char* filename )
{
// 2.1.1. load() should populate bindVertices, currentVertices, and faces

// Add your code here.

// make a copy of the bind vertices as the current vertices
currentVertices = bindVertices;
}

void Mesh::draw()
{
// Since these meshes don't have normals
// be sure to generate a normal per triangle.
// Notice that since we have per-triangle normals
// rather than the analytical normals from
// assignment 1, the appearance is "faceted".
}

void Mesh::loadAttachments( const char* filename, int numJoints )
{
// 2.2. Implement this method to load the per-vertex attachment weights
// this method should update m_mesh.attachments
}
49 changes: 49 additions & 0 deletions Mesh.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#ifndef MESH_H
#define MESH_H

#include <vector>
#include <vecmath.h>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include "tuple.h"

#ifdef __APPLE__
# include <GLUT/glut.h>
#else
# include <GL/glut.h>
#endif

typedef tuple< unsigned, 3 > Tuple3u;

struct Mesh
{
// list of vertices from the OBJ file
// in the "bind pose"
std::vector< Vector3f > bindVertices;

// each face has 3 indices
// referencing 3 vertices
std::vector< Tuple3u > faces;

// current vertex positions after animation
std::vector< Vector3f > currentVertices;

// list of vertex to joint attachments
// each element of attachments is a vector< float > containing
// one attachment weight per joint
std::vector< std::vector< float > > attachments;

// 2.1.1. load() should populate bindVertices, currentVertices, and faces
void load(const char *filename);

// 2.1.2. draw the current mesh.
void draw();

// 2.2. Implement this method to load the per-vertex attachment weights
// this method should update m_mesh.attachments
void loadAttachments( const char* filename, int numJoints );
};

#endif
Loading

0 comments on commit 055c754

Please sign in to comment.