Fixing dependency issues
This commit is contained in:
+13
-26
@@ -1,35 +1,22 @@
|
|||||||
#include "ColladaModel.h"
|
#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_()
|
ColladaModel::ColladaModel(const char* filename) : positions_(), triangles_() ,normals_()
|
||||||
{
|
{
|
||||||
XMLDocument doc;
|
tinyxml2::XMLDocument doc;
|
||||||
doc.LoadFile("resources/face.dae");
|
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;
|
int triangle_count = 0;
|
||||||
xml_triangle_count->QueryIntAttribute("count", &triangle_count);
|
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();
|
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++)
|
for (int i = 0; i < triangle_count; i++)
|
||||||
{
|
{
|
||||||
int x = 0;
|
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;
|
int vertice_count = 0;
|
||||||
xml_vertice->QueryIntAttribute("count", &vertice_count);
|
xml_vertice->QueryIntAttribute("count", &vertice_count);
|
||||||
|
|
||||||
const char* xml2_vertice = xml_vertice->GetText();
|
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++)
|
for (int i = 0; i < vertice_count / 3; i++)
|
||||||
{
|
{
|
||||||
float x = 0;
|
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;
|
int normal_count = 0;
|
||||||
xml_normal_count->QueryIntAttribute("count", &normal_count);
|
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();
|
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++)
|
for (int i = 0; i < normal_count / 3; i++)
|
||||||
{
|
{
|
||||||
float x = 0;
|
float x = 0;
|
||||||
|
|||||||
@@ -17,9 +17,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
using namespace tinyxml2;
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class ColladaModel {
|
class ColladaModel {
|
||||||
private:
|
private:
|
||||||
std::vector<Vec3f> positions_;
|
std::vector<Vec3f> positions_;
|
||||||
|
|||||||
@@ -115,18 +115,22 @@
|
|||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="ColladaModel.cpp" />
|
||||||
<ClCompile Include="geometry.cpp" />
|
<ClCompile Include="geometry.cpp" />
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
<ClCompile Include="model.cpp" />
|
<ClCompile Include="model.cpp" />
|
||||||
<ClCompile Include="renderer.cpp" />
|
<ClCompile Include="renderer.cpp" />
|
||||||
<ClCompile Include="tgaimage.cpp" />
|
<ClCompile Include="tgaimage.cpp" />
|
||||||
|
<ClCompile Include="tinyxml2.cpp" />
|
||||||
<ClCompile Include="util_window.cpp" />
|
<ClCompile Include="util_window.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="ColladaModel.h" />
|
||||||
<ClInclude Include="geometry.h" />
|
<ClInclude Include="geometry.h" />
|
||||||
<ClInclude Include="model.h" />
|
<ClInclude Include="model.h" />
|
||||||
<ClInclude Include="renderer.h" />
|
<ClInclude Include="renderer.h" />
|
||||||
<ClInclude Include="tgaimage.h" />
|
<ClInclude Include="tgaimage.h" />
|
||||||
|
<ClInclude Include="tinyxml2.h" />
|
||||||
<ClInclude Include="util_window.h" />
|
<ClInclude Include="util_window.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|||||||
@@ -33,6 +33,12 @@
|
|||||||
<ClCompile Include="renderer.cpp">
|
<ClCompile Include="renderer.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="ColladaModel.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tinyxml2.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="util_window.h">
|
<ClInclude Include="util_window.h">
|
||||||
@@ -50,5 +56,11 @@
|
|||||||
<ClInclude Include="renderer.h">
|
<ClInclude Include="renderer.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="ColladaModel.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="tinyxml2.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -195,12 +195,6 @@ void render()
|
|||||||
|
|
||||||
Projection[3][2] = -1.f / (eye - center).norm();
|
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;
|
Matrix z = ViewPort * Projection * ModelView * model->Transform;
|
||||||
|
|
||||||
init_zbuffer();
|
init_zbuffer();
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user