diff --git a/.gitignore b/.gitignore index 9491a2f..a54ca13 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,8 @@ # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs +StandfordDragon.obj + # Mono auto generated files mono_crash.* @@ -360,4 +362,5 @@ MigrationBackup/ .ionide/ # Fody - auto-generated XML schema -FodyWeavers.xsd \ No newline at end of file +FodyWeavers.xsd +/Lighting/StandfordDragon.mtl diff --git a/Lighting/Dolphin_HighPolyUV.png b/Lighting/Dolphin_HighPolyUV.png new file mode 100644 index 0000000..35fb907 Binary files /dev/null and b/Lighting/Dolphin_HighPolyUV.png differ diff --git a/Lighting/ImportedModel.cpp b/Lighting/ImportedModel.cpp index ee6df67..1483582 100644 --- a/Lighting/ImportedModel.cpp +++ b/Lighting/ImportedModel.cpp @@ -16,7 +16,9 @@ ImportedModel::ImportedModel(const char *filePath) { for (int i = 0; i < numVertices; i++) { vertices.push_back(glm::vec3(verts[i*3], verts[i*3+1], verts[i*3+2])); - texCoords.push_back(glm::vec2(tcs[i*2], tcs[i*2+1])); + if(texCoords.size()>0){ + texCoords.push_back(glm::vec2(tcs[i*2], tcs[i*2+1])); + } normalVecs.push_back(glm::vec3(normals[i*3], normals[i*3+1], normals[i*3+2])); } } @@ -68,15 +70,17 @@ void ModelImporter::parseOBJ(const char *filePath) { getline(oneCornerSS, n, '/'); int vertRef = (stoi(v) - 1) * 3; - int tcRef = (stoi(t) - 1) * 2; int normRef = (stoi(n) - 1) * 3; triangleVerts.push_back(vertVals[vertRef]); triangleVerts.push_back(vertVals[vertRef + 1]); triangleVerts.push_back(vertVals[vertRef + 2]); - - textureCoords.push_back(stVals[tcRef]); - textureCoords.push_back(stVals[tcRef + 1]); + + if(t.length()>0){ + int tcRef = (stoi(t) - 1) * 2; + textureCoords.push_back(stVals[tcRef]); + textureCoords.push_back(stVals[tcRef + 1]); + } normals.push_back(normVals[normRef]); normals.push_back(normVals[normRef + 1]); diff --git a/Lighting/main.cpp b/Lighting/main.cpp index 38ec787..aa8974b 100644 --- a/Lighting/main.cpp +++ b/Lighting/main.cpp @@ -33,10 +33,10 @@ float lightAmbient[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; float lightDiffuse[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; float lightSpecular[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; -float* matAmb = utils::silverAmbient(); -float* matDif = utils::silverDiffuse(); -float* matSpe = utils::silverSpecular(); -float matShi = utils::silverShininess(); +float* matAmb = utils::goldAmbient(); +float* matDif = utils::goldDiffuse(); +float* matSpe = utils::goldSpecular(); +float matShi = utils::goldShininess(); float* matAmb2 = utils::jadeAmbient(); float* matDif2 = utils::jadeDiffuse(); @@ -50,7 +50,7 @@ GLuint pyrTex; Sphere sphere(48); Torus torus(1.0,0.5,48); -ImportedModel shuttle("shuttle.obj"); +ImportedModel shuttle("StanfordDragon.obj"); void setupVertices(void) { glGenVertexArrays(1, vao); @@ -130,8 +130,10 @@ void setupVertices(void) { pvalues.push_back(vertices[i].x); pvalues.push_back(vertices[i].y); pvalues.push_back(vertices[i].z); - tvalues.push_back(uvs[i].s); - tvalues.push_back(uvs[i].t); + if(uvs.size()>0){ + tvalues.push_back(uvs[i].s); + tvalues.push_back(uvs[i].t); + } nvalues.push_back(normals[i].x); nvalues.push_back(normals[i].y); nvalues.push_back(normals[i].z); @@ -274,9 +276,9 @@ void display(GLFWwindow* window, double currentTime) { //vMat=glm::lookAt(glm::vec3{camera.x,camera.y,camera.z},{0,-3,0},{0,1,0}); - mMat=glm::translate(glm::mat4(1.0f),{0.f,-2.f,0.f}); - mMat=glm::rotate(mMat,float(currentTime/4),{0.f,1.f,0.2f}); - mMat=glm::scale(mMat,{7,7,7}); + mMat=glm::translate(glm::mat4(1.0f),{0.f,-8.f,0.f}); + mMat=glm::rotate(mMat,float(currentTime/4),{0.f,1.f,0.f}); + mMat=glm::scale(mMat,{60,60,60}); mvMat=vMat*mMat; invTrMat=glm::transpose(glm::inverse(mvMat)); @@ -298,7 +300,7 @@ void display(GLFWwindow* window, double currentTime) { invTrMat=glm::transpose(glm::inverse(mvMat)); - DrawTorus(); + //DrawTorus(); } int main(void) {