Permalink
Browse files

Near finish

  • Loading branch information...
leonardteo committed Dec 10, 2010
1 parent 2de3593 commit 61b2de3c27b97224e5c911248e3e37d4a1409f30
View
@@ -35,6 +35,8 @@ void NPC::rotateHeading(float angle)
//Rotate the model
//this->rotationNode->rotateBall(axis, angle);
this->meshNode->rotate->y += angle;
+ this->exclamation->rotate->y += angle;
+ this->shadow->rotate->y += angle;
Vector3 axis(0.0f, 1.0f, 0.0f);
View
1 NPC.h
@@ -28,6 +28,7 @@ class NPC : public TransformNode
PolyMeshNode* exclamation;
PolyMeshNode* leftFoot;
PolyMeshNode* rightFoot;
+ PolyMeshNode* shadow;
TransformNode* wobbleNode;
float animationT; //Artificial coefficient for helping with animation
View
@@ -81,6 +81,7 @@ void Node::modelTransform()
//glScalef(this->scale->x, this->scale->y, this->scale->z);
}
+
//Abstract method for rendering - must be overloaded by child classes
void Node::render(RenderType renderType)
{
View
1 Node.h
@@ -67,6 +67,7 @@ class Node
Vector3 getPosition();
void modelTransform();
void attachShader(Shader* shader);
+
private:
void init();
View
@@ -100,6 +100,17 @@ void PolyMeshNode::draw()
if (this->shader != NULL)
{
glUseProgram(this->shader->shaderProgram);
+
+ //Pass projection matrix to shader
+ GLfloat projectionMatrix[16];
+ glGetFloatv(GL_PROJECTION_MATRIX, projectionMatrix);
+ glUniformMatrix4fv(this->shader->projectionMatrix, 1, false, projectionMatrix);
+
+ //Pass current modelview matrix to shader
+ GLfloat modelViewMatrix[16];
+ glGetFloatv(GL_MODELVIEW_MATRIX, modelViewMatrix);
+ glUniformMatrix4fv(this->shader->modelViewMatrix, 1, false, modelViewMatrix);
+
} else {
glUseProgram(NULL);
}
@@ -113,6 +124,13 @@ void PolyMeshNode::draw()
glVertexPointer(3, GL_FLOAT, 0, BUFFER_OFFSET(0));
glEnableClientState(GL_VERTEX_ARRAY);
+ if (this->shader != NULL)
+ {
+ //Pass vertices to the shader
+ glVertexAttribPointer(this->shader->vertices, 3, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
+ glEnableVertexAttribArray(this->shader->vertices);
+ }
+
//Load normals
glBindBuffer(GL_ARRAY_BUFFER, this->mesh->vbo_normals);
glNormalPointer(GL_FLOAT, 0, BUFFER_OFFSET(0));
View
@@ -114,7 +114,22 @@ bool Shader::compile()
return false;
}
- cout << "Successfully compiled and linked shaders: " << endl;
+ //cout << "Successfully compiled and linked shaders." << endl;
+
+ //Get Uniform Locations
+ this->vertices = glGetAttribLocation(shaderProgram, "vertex");
+ this->modelViewMatrix = glGetUniformLocation(shaderProgram, "modelViewMatrix");
+ this->projectionMatrix = glGetUniformLocation(shaderProgram, "projectionMatrix");
+ this->shadowMap = glGetUniformLocation(shaderProgram, "shadowMap");
+
+ /*
+ cout << endl << "Uniform Locations: " << endl;
+ cout << "Shadow Map: " << this->shadowMap << endl;
+ cout << "MV Matrix: " << this->modelViewMatrix << endl;
+ cout << "Proj Matrix: " << this->projectionMatrix << endl;
+ cout << "Vertices: " << this->vertices << endl;
+ */
+
return true;
}
View
@@ -45,6 +45,11 @@ class Shader
//Compilation and linking
bool compile();
+ //Uniforms and varying shader vars
+ GLint modelViewMatrix;
+ GLint projectionMatrix;
+ GLint shadowMap;
+ GLint vertices;
private:
char* readTextFile(char* filename);
View
@@ -19,6 +19,7 @@ Texture::~Texture(void)
void Texture::loadTexture(const char* filename)
{
+ /*
this->textureMap = new MyBitmap(filename);
if (!this->textureMap->loaded){
cout << "Could not load texture. Error: " << this->textureMap->error << endl;
@@ -32,5 +33,12 @@ void Texture::loadTexture(const char* filename)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, this->textureMap->width, this->textureMap->height, 0, GL_RGB, GL_UNSIGNED_BYTE, this->textureMap->data);
-
+ */
+ //SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
+ this->textureID = SOIL_load_OGL_texture(filename, SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y );
+ if( this->textureID == 0 )
+ {
+ printf( "SOIL loading error: '%s'\n", SOIL_last_result() );
+ }
+
}
View
@@ -15,6 +15,7 @@ Texture class for holding any textures
#endif
#include "MyBitmap.h"
+#include <SOIL.h>
class Texture
{
View
@@ -0,0 +1,16 @@
+# This file uses centimeters as units for non-parametric coordinates.
+
+v -5.000000 -0.000000 5.000000
+v 5.000000 -0.000000 5.000000
+v -5.000000 0.000000 -5.000000
+v 5.000000 0.000000 -5.000000
+vt 0.000000 0.000000
+vt 1.000000 0.000000
+vt 0.000000 1.000000
+vt 1.000000 1.000000
+vn 0.000000 1.000000 0.000000
+vn 0.000000 1.000000 0.000000
+vn 0.000000 1.000000 0.000000
+vn 0.000000 1.000000 0.000000
+f 1/1/1 2/2/2 3/3/3
+f 3/3/3 2/2/2 4/4/4
Oops, something went wrong.

0 comments on commit 61b2de3

Please sign in to comment.