Fixing dependency issues

This commit is contained in:
2019-12-08 21:12:21 +02:00
parent c0be7e1680
commit 32cd3c2037
7 changed files with 5304 additions and 35 deletions
+13 -26
View File
@@ -1,35 +1,22 @@
#include "ColladaModel.h"
string trim(const string& str)
{
size_t first = str.find_first_not_of(' ');
if (string::npos == first)
{
return str;
}
size_t last = str.find_last_not_of(' ');
return str.substr(first, (last - first + 1));
}
ColladaModel::ColladaModel(const char* filename) : positions_(), triangles_() ,normals_()
{
XMLDocument doc;
doc.LoadFile("resources/face.dae");
tinyxml2::XMLDocument doc;
doc.LoadFile(filename);
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
XMLElement* xml_triangle_count = doc.FirstChildElement("COLLADA")->FirstChildElement("library_geometries")->FirstChildElement("geometry")->FirstChildElement("mesh")->FirstChildElement("triangles");
tinyxml2::XMLElement* xml_triangle_count = doc.FirstChildElement("COLLADA")->FirstChildElement("library_geometries")->FirstChildElement("geometry")->FirstChildElement("mesh")->FirstChildElement("triangles");
int triangle_count = 0;
xml_triangle_count->QueryIntAttribute("count", &triangle_count);
XMLElement* xml_triangle = doc.FirstChildElement("COLLADA")->FirstChildElement("library_geometries")->FirstChildElement("geometry")->FirstChildElement("mesh")->FirstChildElement("triangles")->FirstChildElement("p");
tinyxml2::XMLElement* xml_triangle = doc.FirstChildElement("COLLADA")->FirstChildElement("library_geometries")->FirstChildElement("geometry")->FirstChildElement("mesh")->FirstChildElement("triangles")->FirstChildElement("p");
const char* xml2_triangle = xml_triangle->GetText();
stringstream str_triangle(xml2_triangle);
std::stringstream str_triangle(xml2_triangle);
vector<vector<Vec3i>> triangle(triangle_count, vector<Vec3i>(3, Vec3i(0, 0, 0)));
std::vector<std::vector<Vec3i>> triangle(triangle_count, std::vector<Vec3i>(3, Vec3i(0, 0, 0)));
for (int i = 0; i < triangle_count; i++)
{
int x = 0;
@@ -69,14 +56,14 @@ ColladaModel::ColladaModel(const char* filename) : positions_(), triangles_() ,n
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
XMLElement* xml_vertice = doc.FirstChildElement("COLLADA")->FirstChildElement("library_geometries")->FirstChildElement("geometry")->FirstChildElement("mesh")->FirstChildElement("source")->FirstChildElement("float_array");
tinyxml2::XMLElement* xml_vertice = doc.FirstChildElement("COLLADA")->FirstChildElement("library_geometries")->FirstChildElement("geometry")->FirstChildElement("mesh")->FirstChildElement("source")->FirstChildElement("float_array");
int vertice_count = 0;
xml_vertice->QueryIntAttribute("count", &vertice_count);
const char* xml2_vertice = xml_vertice->GetText();
stringstream str_vertice(xml2_vertice);
std::stringstream str_vertice(xml2_vertice);
vector<Vec3f> vertice(vertice_count / 3);
std::vector<Vec3f> vertice(vertice_count / 3);
for (int i = 0; i < vertice_count / 3; i++)
{
float x = 0;
@@ -94,14 +81,14 @@ ColladaModel::ColladaModel(const char* filename) : positions_(), triangles_() ,n
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
XMLElement* xml_normal_count = doc.FirstChildElement("COLLADA")->FirstChildElement("library_geometries")->FirstChildElement("geometry")->FirstChildElement("mesh")->FirstChildElement("source")->NextSiblingElement()->FirstChildElement("float_array");
tinyxml2::XMLElement* xml_normal_count = doc.FirstChildElement("COLLADA")->FirstChildElement("library_geometries")->FirstChildElement("geometry")->FirstChildElement("mesh")->FirstChildElement("source")->NextSiblingElement()->FirstChildElement("float_array");
int normal_count = 0;
xml_normal_count->QueryIntAttribute("count", &normal_count);
XMLElement* xml_normal = doc.FirstChildElement("COLLADA")->FirstChildElement("library_geometries")->FirstChildElement("geometry")->FirstChildElement("mesh")->FirstChildElement("source")->NextSiblingElement()->FirstChildElement("float_array");
tinyxml2::XMLElement* xml_normal = doc.FirstChildElement("COLLADA")->FirstChildElement("library_geometries")->FirstChildElement("geometry")->FirstChildElement("mesh")->FirstChildElement("source")->NextSiblingElement()->FirstChildElement("float_array");
const char* xml2_normal = xml_normal->GetText();
stringstream str_normal(xml2_normal);
std::stringstream str_normal(xml2_normal);
vector<Vec3f> normal(normal_count / 3);
std::vector<Vec3f> normal(normal_count / 3);
for (int i = 0; i < normal_count / 3; i++)
{
float x = 0;
-3
View File
@@ -17,9 +17,6 @@
#include <vector>
using namespace tinyxml2;
using namespace std;
class ColladaModel {
private:
std::vector<Vec3f> positions_;
+4
View File
@@ -115,18 +115,22 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="ColladaModel.cpp" />
<ClCompile Include="geometry.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="model.cpp" />
<ClCompile Include="renderer.cpp" />
<ClCompile Include="tgaimage.cpp" />
<ClCompile Include="tinyxml2.cpp" />
<ClCompile Include="util_window.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="ColladaModel.h" />
<ClInclude Include="geometry.h" />
<ClInclude Include="model.h" />
<ClInclude Include="renderer.h" />
<ClInclude Include="tgaimage.h" />
<ClInclude Include="tinyxml2.h" />
<ClInclude Include="util_window.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+12
View File
@@ -33,6 +33,12 @@
<ClCompile Include="renderer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ColladaModel.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="tinyxml2.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="util_window.h">
@@ -50,5 +56,11 @@
<ClInclude Include="renderer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ColladaModel.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="tinyxml2.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
-6
View File
@@ -195,12 +195,6 @@ void render()
Projection[3][2] = -1.f / (eye - center).norm();
model->rotate(Vec3f(0, 0, 90));
model->scale(Vec3f(0.5, 0.5, 0.5));
model->translate(Vec3f(0.5, 0.5, -1));
model->ApplyTransform();
Matrix z = ViewPort * Projection * ModelView * model->Transform;
init_zbuffer();
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff