diff --git a/light.cpp b/light.cpp index a76e4cc..ed81648 100755 --- a/light.cpp +++ b/light.cpp @@ -52,6 +52,7 @@ namespace vb01{ Root *root=Root::getSingleton(); Node *rootNode=root->getRootNode(); std::vector descendants; + rootNode->getDescendants(rootNode, descendants); std::vector materials; Camera *cam=root->getCamera(); int thisId=-1; @@ -143,16 +144,9 @@ namespace vb01{ shader->setVec3(color,"light["+to_string(thisId)+"].color"); shader->setFloat(nearPlane,"light["+to_string(thisId)+"].near"); shader->setFloat(farPlane,"light["+to_string(thisId)+"].far"); - shader->setInt(0,"diffuseMap"); - shader->setInt(1,"normalMap"); - shader->setInt(2,"specularMap"); - shader->setInt(3,"parallaxMap"); - shader->setInt(4,"environmentMap"); shader->setInt(5,"light["+to_string(thisId)+"].depthMapCube"); shader->setInt(6,"light["+to_string(thisId)+"].depthMap"); depthMap->select(type==POINT?5:6); - /* - */ switch(type){ case POINT: diff --git a/main.cpp b/main.cpp index 7af145a..ade4548 100755 --- a/main.cpp +++ b/main.cpp @@ -1,23 +1,3 @@ -#include"box.h" -#include"camera.h" -#include"light.h" -#include"material.h" -#include"mesh.h" -#include"model.h" -#include"node.h" -#include"particleEmitter.h" -#include"quad.h" -#include"quaternion.h" -#include"rectangle.h" -#include"root.h" -#include"shader.h" -#include"stb_image.h" -#include"text.h" -#include"texture.h" -#include"util.h" -#include"vector.h" -#include"waterPlane.h" - int main(){ return 0; } diff --git a/material.cpp b/material.cpp index 103fb77..6777e50 100755 --- a/material.cpp +++ b/material.cpp @@ -61,6 +61,12 @@ namespace vb01{ shader->setVec4(diffuseColor,"diffuseColor"); } if(texturingEnabled){ + shader->setInt(0,"diffuseMap"); + shader->setInt(1,"normalMap"); + shader->setInt(2,"specularMap"); + shader->setInt(3,"parallaxMap"); + shader->setInt(4,"environmentMap"); + for(Texture *t : diffuseMapTextures) t->update(0); for(Texture *t : normalMapTextures) diff --git a/vbModelReader.cpp b/vbModelReader.cpp index 7fc7a99..bd0a672 100644 --- a/vbModelReader.cpp +++ b/vbModelReader.cpp @@ -74,8 +74,8 @@ namespace vb01{ VbModelReader::~VbModelReader(){ } - void VbModelReader::readBones(vector &meshData, Skeleton *skeleton, int boneStartLine, int numBones){ - meshData.clear(); + void VbModelReader::readBones(Skeleton *skeleton, int boneStartLine, int numBones){ + vector meshData; readFile(path, meshData, boneStartLine, boneStartLine + numBones); vector ikRelationships; @@ -131,12 +131,12 @@ namespace vb01{ } } - void VbModelReader::readAnimations(vector &meshData, Skeleton *skeleton, int animationStartLine, int endLine){ + void VbModelReader::readAnimations(Skeleton *skeleton, int animationStartLine, int endLine){ AnimationController *controller = skeleton->getAnimationController(); string animName = ""; Bone *animBone = nullptr; Animation::KeyframeGroup::KeyframeChannel::Type type; - meshData.clear(); + vector meshData; readFile(path, meshData, animationStartLine, endLine + 1); for(string l : meshData){ @@ -225,14 +225,13 @@ namespace vb01{ Skeleton *skeleton = new Skeleton(name); skeletons.push_back(skeleton); - readBones(meshData, skeleton, boneStartLine, numBones); + readBones(skeleton, boneStartLine, numBones); - readAnimations(meshData, skeleton, animationStartLine, endLine); + readAnimations(skeleton, animationStartLine, endLine); } void VbModelReader::readVertices( - vector &meshData, vector &vertPos, vector &vertNorm, vector &vertWeights, @@ -240,7 +239,7 @@ namespace vb01{ int numVertices, int numBones ){ - meshData.clear(); + vector meshData; readFile(path, meshData, vertexStartLine, vertexStartLine + numVertices); for(string line : meshData){ int numData = 6 + numBones; @@ -257,7 +256,6 @@ namespace vb01{ } void VbModelReader::readFaces( - vector &meshData, vector &vertPos, vector &vertNorm, vector &vertWeights, @@ -269,7 +267,7 @@ namespace vb01{ u32 *indices ){ int i = 0; - meshData.clear(); + vector meshData; readFile(path, meshData, faceStartLine, faceStartLine + numFaces * numVertsPerFace); for(string line : meshData){ int numData = 9; @@ -352,11 +350,11 @@ namespace vb01{ groups[i] = meshData[i]; } - readVertices(meshData, vertPos, vertNorm, vertWeights, vertexGroupStartLine, numVertices, numBones); - readFaces(meshData, vertPos, vertNorm, vertWeights, faceStartLine, numFaces, numVertsPerFace, numBones, vertices, indices); + readVertices(vertPos, vertNorm, vertWeights, vertexStartLine, numVertices, numBones); + + readFaces(vertPos, vertNorm, vertWeights, faceStartLine, numFaces, numVertsPerFace, numBones, vertices, indices); meshData.clear(); - readFile(path, meshData, shapeKeyStartLine, shapeKeyStartLine + numShapes); for(int i = 0; i < numShapes; i++){ } diff --git a/vbModelReader.h b/vbModelReader.h index 6fd7e83..3951e67 100644 --- a/vbModelReader.h +++ b/vbModelReader.h @@ -17,11 +17,11 @@ namespace vb01{ VbModelReader(Model*, std::string); ~VbModelReader(); private: - void readBones(std::vector&, Skeleton*, int, int); - void readAnimations(std::vector&, Skeleton*, int, int); + void readBones(Skeleton*, int, int); + void readAnimations(Skeleton*, int, int); void readSkeletons(int, int); - void readVertices(std::vector&, std::vector&, std::vector&, std::vector&, int, int, int); - void readFaces(std::vector&, std::vector&, std::vector&, std::vector&, int, int, int, int, Mesh::Vertex*, u32*); + void readVertices(std::vector&, std::vector&, std::vector&, int, int, int); + void readFaces(std::vector&, std::vector&, std::vector&, int, int, int, int, Mesh::Vertex*, u32*); void readMeshes(int, int); void readLights(int, int);