Panagiotis Christopoulos Charitos 15 лет назад
Родитель
Сommit
8c67a73620

Разница между файлами не показана из-за своего большого размера
+ 1 - 2
build/debug/Makefile


+ 2 - 8
build/debug/gen.cfg.py

@@ -1,13 +1,7 @@
 sourcePaths = ["../../src"]
+sourcePaths.extend(list(walkDir("../../src")))
 
-for top, dirs, files in os.walk("../../src"):
-	for nm in dirs:
-		dir_ = os.path.join(top, nm)
-		if dir_.find(".svn") == -1:
-			sourcePaths.append(dir_)
-
-includePaths = []
-includePaths.append("./")
+includePaths = ["./"]
 includePaths.extend(list(sourcePaths))
 includePaths.extend(["../../extern/include", "../../extern/include/bullet", "/usr/include/python2.6"])
 

+ 9 - 1
src/Core/App.cpp

@@ -4,6 +4,7 @@
 #include <iostream>
 #include <iomanip>
 #include <boost/filesystem.hpp>
+#include <boost/algorithm/string.hpp>
 #include "App.h"
 #include "Scene.h"
 #include "MainRenderer.h"
@@ -25,7 +26,14 @@ bool App::isCreated = false;
 //======================================================================================================================
 void App::handleMessageHanlderMsgs(const char* file, int line, const char* func, const std::string& msg)
 {
-	std::cout << "(" << file << ":" << line << " "<< func << ") " << msg << std::endl;
+	if(boost::find_first(msg, "Warning") || boost::find_first(msg, "Error"))
+	{
+		std::cerr << "(" << file << ":" << line << " "<< func << ") " << msg << std::endl;
+	}
+	else
+	{
+		std::cout << "(" << file << ":" << line << " "<< func << ") " << msg << std::endl;
+	}
 }
 
 

+ 5 - 3
src/Renderer/MainRenderer.cpp

@@ -7,6 +7,7 @@
 #include "MainRenderer.h"
 #include "App.h"
 #include "RendererInitializer.h"
+#include "Messaging.h"
 
 
 //======================================================================================================================
@@ -42,12 +43,13 @@ void MainRenderer::initGl()
 	}
 
 	// print GL info
-	//INFO("OpenGL info: OGL " << glGetString(GL_VERSION) << ", GLSL " << glGetString(GL_SHADING_LANGUAGE_VERSION));
+	INFO("OpenGL info: OGL " + reinterpret_cast<const char*>(glGetString(GL_VERSION)) + ", GLSL " +
+	     reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
 
-	/*if(!glewIsSupported("GL_VERSION_3_1"))
+	if(!glewIsSupported("GL_VERSION_3_1"))
 	{
 		WARNING("OpenGL ver 3.1 not supported. The application may crash (and burn)");
-	}*/
+	}
 
 	// get max texture units
 	glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &Texture::textureUnitsNum);

+ 5 - 4
src/Resources/ShaderProg.cpp

@@ -6,6 +6,7 @@
 #include "Texture.h" // For certain setters
 #include "App.h" // To get cache dir
 #include "GlException.h"
+#include "Messaging.h"
 
 
 #define SPROG_EXCEPTION(x) EXCEPTION("Shader prog \"" + getRsrcName() + "\": " + x)
@@ -190,14 +191,14 @@ void ShaderProg::getUniAndAttribVars()
 	attribVars.reserve(num);
 	for(int i=0; i<num; i++) // loop all attributes
 	{
-		glGetActiveAttrib(glId, i, sizeof(name_)/sizeof(char), &length, &size, &type, name_);
+		glGetActiveAttrib(glId, i, sizeof(name_) / sizeof(char), &length, &size, &type, name_);
 		name_[length] = '\0';
 
 		// check if its FFP location
 		int loc = glGetAttribLocation(glId, name_);
 		if(loc == -1) // if -1 it means that its an FFP var
 		{
-			std::cout << "You are using FFP vertex attributes (\"" << name_ << "\")" << std::endl; /// @todo fix this
+			WARNING("You are using FFP vertex attributes (\"" + name_ + "\")");
 			continue;
 		}
 
@@ -211,14 +212,14 @@ void ShaderProg::getUniAndAttribVars()
 	uniVars.reserve(num);
 	for(int i=0; i<num; i++) // loop all uniforms
 	{
-		glGetActiveUniform(glId, i, sizeof(name_)/sizeof(char), &length, &size, &type, name_);
+		glGetActiveUniform(glId, i, sizeof(name_) / sizeof(char), &length, &size, &type, name_);
 		name_[length] = '\0';
 
 		// check if its FFP location
 		int loc = glGetUniformLocation(glId, name_);
 		if(loc == -1) // if -1 it means that its an FFP var
 		{
-			std::cout << "You are using FFP uniforms (\"" << name_ << "\")" << std::endl;
+			WARNING("You are using FFP vertex uniforms (\"" + name_ + "\")");
 			continue;
 		}
 

Разница между файлами не показана из-за своего большого размера
+ 0 - 1
tools/shredder/build/Makefile


+ 4 - 4
tools/shredder/build/gen.cfg.py

@@ -1,8 +1,8 @@
-sourcePaths = ["../../../src/Scripting/", "../../../src/Math/", "../../../src/Misc/", "../src/", "../../../src/Renderer/", "../../../src/Scene/", "../../../src/Ui/", "../../../src/Resources/", "../../../src/Util/", "../../../src/Scene/Controllers/", "../../../src/Physics/", "../../../src/Renderer/BufferObjects/", "../../../src/Resources/Helpers/", "../../../src/Resources/Core/", "../../../src/Core/", "../../../src/Scripting/Math", "../../../src/Scripting/Util", "../../../src/Scripting/Core", "../../../src/Scripting/Scene", "../../../src/Scripting/Renderer", "../../../src/Input", "../../../src/Collision"]
+sourcePaths = walkDir("../../../src")
+sourceFiles = ["../src/Main.cpp"]
 
-includePaths = []
-includePaths.append("./")
-includePaths.extend(list(sourcePaths))
+includePaths = ["./"]
+includePaths.extend(list(walkDir("../../../src")))
 includePaths.extend(["../../../extern/include", "../../../extern/include/bullet", "/usr/include/python2.6"])
 
 executableName = "shredder"

+ 99 - 56
tools/shredder/src/Main.cpp

@@ -1,6 +1,9 @@
 #include <iostream>
+#include <GL/glew.h>
 #include "MeshData.h"
 #include "Collision.h"
+#include "App.h"
+#include "Shredder.h"
 
 
 struct TempMesh
@@ -12,7 +15,7 @@ struct TempMesh
 };
 
 
-void shredMesh(const Plane& plane, const TempMesh& in, TempMesh& fMesh, TempMesh& bMesh)
+void cutMesh(const Plane& plane, const TempMesh& in, TempMesh& fMesh, TempMesh& bMesh)
 {
 	for(uint i = 0; i < in.tris.size(); i++)
 	{
@@ -33,76 +36,116 @@ void shredMesh(const Plane& plane, const TempMesh& in, TempMesh& fMesh, TempMesh
 }
 
 
-int main(int argc, char** argv)
+//======================================================================================================================
+//                                                                                                                     =
+//======================================================================================================================
+void shredMesh(const char* filename, float octreeMinSize)
 {
-	MeshData md("/home/godlike/src/anki/maps/sponza/walls.mesh");	
-
-	//
-	// Get min max
-	//
-	const Vec<Vec3>& vc = md.getVertCoords();
-	Vec3 min(vc[0]), max(vc[0]);
-	for(uint i = 1; i < vc.size(); i++)
-	{
-		for(uint j = 0; j < 3; j++)
+	MeshData md(filename);
+
+		//
+		// Get min max
+		//
+		const Vec<Vec3>& vc = md.getVertCoords();
+		Vec3 min(vc[0]), max(vc[0]);
+		for(uint i = 1; i < vc.size(); i++)
 		{
-			if(vc[i][j] < min[j])
-			{
-				min[j] = vc[i][j];
-			}
-
-			if(vc[i][j] > max[j])
+			for(uint j = 0; j < 3; j++)
 			{
-				max[j] = vc[i][j];
+				if(vc[i][j] < min[j])
+				{
+					min[j] = vc[i][j];
+				}
+
+				if(vc[i][j] > max[j])
+				{
+					max[j] = vc[i][j];
+				}
 			}
 		}
-	}
-	std::cout << "min(" << min << "), max(" << max << ")" << std::endl;
-
-	//
-	// Calc planes
-	//
-	float octreeMinSize = 1.0;
-	Vec<Plane> planes;
-	// Planes in x
-	for(float dist = floor(min.x / octreeMinSize) * octreeMinSize; dist < max.x; dist += octreeMinSize)
-	{
-		planes.push_back(Plane(Vec3(1, 0, 0), dist));
-	}
-	std::cout << "Planes num: " << planes.size() << std::endl;
+		std::cout << "min(" << min << "), max(" << max << ")" << std::endl;
+
+		//
+		// Calc planes
+		//
+		Vec<Plane> planes;
+		// Planes in x
+		for(float dist = floor(min.x / octreeMinSize) * octreeMinSize; dist < max.x; dist += octreeMinSize)
+		{
+			planes.push_back(Plane(Vec3(1, 0, 0), dist));
+		}
+		std::cout << "Planes num: " << planes.size() << std::endl;
 
-	//
-	//
-	//
-	//Vec<TempMesh> meshes;
+		//
+		//
+		//
+		//Vec<TempMesh> meshes;
 
-	/*for(Vec<Plane>::iterator plane = planes.begin(); plane != planes.end(); ++plane)
-	{
-		for(uint i = 0; i < md.getTris().size(); i++)
+		/*for(Vec<Plane>::iterator plane = planes.begin(); plane != planes.end(); ++plane)
 		{
-			const MeshData::Triangle& tri = md.getTris()[i];
-			float testA = plane->test(md.getVertCoords()[tri.vertIds[0]]);
-			float testB = plane->test(md.getVertCoords()[tri.vertIds[1]]);
-			float testC = plane->test(md.getVertCoords()[tri.vertIds[2]]);
+			for(uint i = 0; i < md.getTris().size(); i++)
+			{
+				const MeshData::Triangle& tri = md.getTris()[i];
+				float testA = plane->test(md.getVertCoords()[tri.vertIds[0]]);
+				float testB = plane->test(md.getVertCoords()[tri.vertIds[1]]);
+				float testC = plane->test(md.getVertCoords()[tri.vertIds[2]]);
 
-			TempMesh* backMesh;
+				TempMesh* backMesh;
 
-			if(testA < 0.0 && testB < 0.0 && testC < 0.0)
-			{
+				if(testA < 0.0 && testB < 0.0 && testC < 0.0)
+				{
 
-			}
-			else if(testA >= 0.0 && testB >= 0.0 && testC >= 0.0)
-			{
+				}
+				else if(testA >= 0.0 && testB >= 0.0 && testC >= 0.0)
+				{
 
+				}
 			}
-		}
-		float dist0 = plane.getDistance();
-		float db;
-		float s =
-	}*/
+			float dist0 = plane.getDistance();
+			float db;
+			float s =
+		}*/
+}
+
+
+//======================================================================================================================
+// main                                                                                                                =
+//======================================================================================================================
+int main(int argc, char** argv)
+{
+	try
+	{
+		new App(argc, argv);
+		app->initWindow();
 
+		Camera* cam = new Camera(app->getMainRenderer().getAspectRatio()*toRad(60.0), toRad(60.0), 0.5, 200.0);
+		cam->moveLocalY(3.0);
+		cam->moveLocalZ(5.7);
+		cam->moveLocalX(-0.3);
+		app->setActiveCam(cam);
 
+		Shredder shredder("/home/godlike/src/anki/maps/sponza/walls.mesh", 1.0);
 
-	std::cout << "End" << std::endl;
+		while(true)
+		{
+			glClear(GL_COLOR_BUFFER_BIT);
+
+			glColor3fv(&Vec3(1.0)[0]);
+
+			// Draw
+			glEnableClientState(GL_VERTEX_ARRAY);
+			glVertexPointer(3, GL_FLOAT, 0, &(shredder.getOriginalMesh().getVertCoords()[0]));
+			glDrawElements(GL_QUADS, shredder.getOriginalMesh().getVertIndeces().size(), GL_UNSIGNED_BYTE, &shredder.getOriginalMesh().getVertIndeces()[0]);
+			glDisableClientState(GL_VERTEX_ARRAY);
+
+			app->swapBuffers();
+			app->waitForNextFrame();
+		}
+	}
+	catch(std::exception& e)
+	{
+		std::cerr << "Error: " << e.what() << std::endl;
+		return 1;
+	}
 	return 0;
 }

+ 24 - 0
tools/shredder/src/Shredder.h

@@ -0,0 +1,24 @@
+#ifndef SHREDDER_H
+#define SHREDDER_H
+
+#include "MeshData.h"
+
+
+class Shredder
+{
+	public:
+		Shredder(const char* filename, float octreeMinSize);
+
+		const MeshData& getOriginalMesh() const {return originalMesh;}
+
+	private:
+		MeshData originalMesh;
+};
+
+
+inline Shredder::Shredder(const char* filename, float octreeMinSize):
+	originalMesh(filename)
+{}
+
+
+#endif

Некоторые файлы не были показаны из-за большого количества измененных файлов