Ver Fonte

Skinning

Panagiotis Christopoulos Charitos há 15 anos atrás
pai
commit
2115739623

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 1
build/debug/Makefile


Diff do ficheiro suprimidas por serem muito extensas
+ 4 - 6
build/release/Makefile


+ 5 - 5
build/release/gen.cfg.py

@@ -1,7 +1,7 @@
-sourcePaths = ["../../src/Scripting/", "../../src/Math/", "../../src/Util/Tokenizer/", "../../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"]
+sourcePaths = ["../../src"]
+sourcePaths.extend(list(walkDir("../../src")))
 
 
-includePaths = []
-includePaths.append("./")
+includePaths = ["./"]
 includePaths.extend(list(sourcePaths))
 includePaths.extend(list(sourcePaths))
 includePaths.extend(["../../extern/include", "../../extern/include/bullet", "/usr/include/python2.6"])
 includePaths.extend(["../../extern/include", "../../extern/include/bullet", "/usr/include/python2.6"])
 
 
@@ -9,6 +9,6 @@ executableName = "anki"
 
 
 compiler = "g++"
 compiler = "g++"
 
 
-compilerFlags = "-DDEBUG_ENABLED=0 -DPLATFORM_LINUX -DREVISION=\\\"`svnversion -c ../..`\\\" -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -s -msse4 -O3 -mtune=core2 -ffast-math -fsingle-precision-constant"
+compilerFlags = "-DDEBUG_ENABLED=0 -DPLATFORM_LINUX -DMATH_INTEL_SIMD -DREVISION=\\\"`svnversion -c ../..`\\\" -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -fsingle-precision-constant -msse4 -s -msse4 -O3 -mtune=core2 -ffast-math"
 
 
-linkerFlags = "-rdynamic -L../../extern/lib-x86-64-linux -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lGLU -Wl,-Bdynamic -lGL -ljpeg -lSDL -lpng -lpython2.6 -lboost_system -lboost_python -lboost_filesystem -lboost_thread"
+linkerFlags = "-rdynamic -pg -L../../extern/lib-x86-64-linux -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lGLU -Wl,-Bdynamic -lGL -ljpeg -lSDL -lpng -lpython2.6 -lboost_system -lboost_python -lboost_filesystem -lboost_thread"

+ 3 - 3
shaders/TfHwSkinningGeneric.glsl

@@ -16,9 +16,9 @@ layout(location = 0) in vec3 position;
 #if defined(TANGENT_ENABLED)
 #if defined(TANGENT_ENABLED)
 	layout(location = 2) in vec4 tangent;
 	layout(location = 2) in vec4 tangent;
 #endif
 #endif
-in float vertWeightBonesNum;
-in vec4 vertWeightBoneIds;
-in vec4 vertWeightWeights;
+layout(location = 3) in float vertWeightBonesNum;
+layout(location = 4) in vec4 vertWeightBoneIds;
+layout(location = 5) in vec4 vertWeightWeights;
 
 
 
 
 //
 //

+ 2 - 2
src/Core/App.cpp

@@ -60,8 +60,8 @@ void App::parseCommandLineArgs(int argc, char* argv[])
 //======================================================================================================================
 //======================================================================================================================
 void App::init(int argc, char* argv[])
 void App::init(int argc, char* argv[])
 {
 {
-	windowW = 1700;
-	windowH = 1000;
+	windowW = 1280;
+	windowH = 720;
 	terminalColoringEnabled = true,
 	terminalColoringEnabled = true,
 	fullScreenFlag = false;
 	fullScreenFlag = false;
 
 

+ 6 - 2
src/Core/App.h

@@ -25,8 +25,6 @@ class App
 	PROPERTY_R(boost::filesystem::path, cachePath, getCachePath)
 	PROPERTY_R(boost::filesystem::path, cachePath, getCachePath)
 
 
 	public:
 	public:
-		uint timerTick;
-
 		App() {}
 		App() {}
 		~App() {}
 		~App() {}
 		void init(int argc, char* argv[]);
 		void init(int argc, char* argv[]);
@@ -47,14 +45,20 @@ class App
 		/// @name Accessors
 		/// @name Accessors
 		/// @{
 		/// @{
 		bool isTerminalColoringEnabled() const;
 		bool isTerminalColoringEnabled() const;
+
 		Camera* getActiveCam() {return activeCam;}
 		Camera* getActiveCam() {return activeCam;}
 		void setActiveCam(Camera* cam) {activeCam = cam;}
 		void setActiveCam(Camera* cam) {activeCam = cam;}
+
+		uint getTimerTick() const {return timerTick;}
+		uint& getTimerTick() {return timerTick;}
+		void setTimerTick(uint t) {timerTick = t;}
 		/// @}
 		/// @}
 
 
 		/// @return Returns the number of milliseconds since SDL library initialization
 		/// @return Returns the number of milliseconds since SDL library initialization
 		static uint getTicks();
 		static uint getTicks();
 
 
 	private:
 	private:
+		uint timerTick;
 		bool terminalColoringEnabled; ///< Terminal coloring for Unix terminals. Default on
 		bool terminalColoringEnabled; ///< Terminal coloring for Unix terminals. Default on
 		uint time;
 		uint time;
 		SDL_WindowID windowId;
 		SDL_WindowID windowId;

+ 2 - 0
src/Core/Logger.cpp

@@ -92,6 +92,8 @@ void Logger::execCommonConstructionCode()
 //======================================================================================================================
 //======================================================================================================================
 void Logger::append(const char* cstr, int len)
 void Logger::append(const char* cstr, int len)
 {
 {
+	boost::mutex::scoped_lock lock(mutex);
+
 	if(len > STREAM_SIZE - 1)
 	if(len > STREAM_SIZE - 1)
 	{
 	{
 		return;
 		return;

+ 5 - 2
src/Core/Logger.h

@@ -4,13 +4,15 @@
 #include <boost/array.hpp>
 #include <boost/array.hpp>
 #include <boost/signals2.hpp>
 #include <boost/signals2.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/lexical_cast.hpp>
+#include <boost/thread/mutex.hpp>
 #include "Singleton.h"
 #include "Singleton.h"
 
 
 
 
 struct LoggerSender;
 struct LoggerSender;
 
 
 
 
-/// The logger singleton class. The logger cannot print errors or throw exceptions, it has to recover somehow
+/// The logger singleton class. The logger cannot print errors or throw exceptions, it has to recover somehow. Its
+/// thread safe
 class Logger
 class Logger
 {
 {
 	public:
 	public:
@@ -55,6 +57,7 @@ class Logger
 		const char* func; ///< Sender info
 		const char* func; ///< Sender info
 		const char* file; ///< Sender info
 		const char* file; ///< Sender info
 		int line; ///< Sender info
 		int line; ///< Sender info
+		boost::mutex mutex; ///< For thread safety
 
 
 		/// Called by all the constructors
 		/// Called by all the constructors
 		void execCommonConstructionCode();
 		void execCommonConstructionCode();
@@ -132,7 +135,7 @@ inline LoggerSender setSender(const char* file, int line, const char* func)
 //======================================================================================================================
 //======================================================================================================================
 
 
 #define LOGGER_MESSAGE(x) \
 #define LOGGER_MESSAGE(x) \
-	LoggerSingleton::getInstance()  << setSender(__FILE__, __LINE__, __func__) << x << endl;
+	LoggerSingleton::getInstance()  << setSender(__FILE__, __LINE__, __PRETTY_FUNCTION__) << x << endl;
 
 
 #define INFO(x) LOGGER_MESSAGE("Info: " << x)
 #define INFO(x) LOGGER_MESSAGE("Info: " << x)
 
 

+ 108 - 94
src/Main.cpp

@@ -34,10 +34,14 @@
 #include "Model.h"
 #include "Model.h"
 #include "Logger.h"
 #include "Logger.h"
 #include "Util.h"
 #include "Util.h"
+#include "HighRezTimer.h"
+#include "SkinNode.h"
+#include "Skin.h"
 
 
 
 
 // map (hard coded)
 // map (hard coded)
-ModelNode* floor__,* sarge,* horse,* crate, *imp;
+ModelNode* floor__,* sarge,* horse,* crate;
+SkinNode* imp;
 //SkelModelNode* imp;
 //SkelModelNode* imp;
 PointLight* point_lights[10];
 PointLight* point_lights[10];
 SpotLight* spot_lights[2];
 SpotLight* spot_lights[2];
@@ -142,9 +146,9 @@ void init()
 
 
 
 
 	// horse
 	// horse
-	/*horse = new ModelNode();
+	horse = new ModelNode();
 	horse->init("meshes/horse/horse.mdl");
 	horse->init("meshes/horse/horse.mdl");
-	horse->setLocalTransform(Transform(Vec3(-2, 0, 1), Mat3::getIdentity(), 1.0));*/
+	horse->setLocalTransform(Transform(Vec3(-2, 0, 0), Mat3::getIdentity(), 1.0));
 
 
 	// Sponza
 	// Sponza
 	ModelNode* sponza = new ModelNode();
 	ModelNode* sponza = new ModelNode();
@@ -152,16 +156,17 @@ void init()
 
 
 
 
 	// Pentagram
 	// Pentagram
-	/*ModelNode* pentagram = new ModelNode();
-	pentagram->init("models/pentagram/pentagram.mdl");
-	pentagram->setLocalTransform(Transform(Vec3(2, 0, 0), Mat3::getIdentity(), 1.0));*/
+	ModelNode* pentagram = new ModelNode();
+	//pentagram->init("models/pentagram/pentagram.mdl");
+	pentagram->init("models/imp/imp.mdl");
+	pentagram->setLocalTransform(Transform(Vec3(2, 0, 0), Mat3::getIdentity(), 1.0));
 
 
 
 
 	// Imp
 	// Imp
-	/*imp = new ModelNode();
-	imp->init("models/imp/imp.mdl");
+	/*imp = new SkinNode();
+	imp->init("models/imp/imp.skin");
 	imp->skelAnimModelNodeCtrl = new SkelAnimModelNodeCtrl(*imp);
 	imp->skelAnimModelNodeCtrl = new SkelAnimModelNodeCtrl(*imp);
-	imp->skelAnimModelNodeCtrl->set(imp->getModel().getSkelAnims()[0].get());
+	imp->skelAnimModelNodeCtrl->set(imp->getSkin().getSkelAnims()[0].get());
 	imp->skelAnimModelNodeCtrl->setStep(0.8);*/
 	imp->skelAnimModelNodeCtrl->setStep(0.8);*/
 
 
 	return;
 	return;
@@ -235,119 +240,128 @@ void init()
 
 
 
 
 //======================================================================================================================
 //======================================================================================================================
-// mainLoop                                                                                                            =
+//                                                                                                                     =
 //======================================================================================================================
 //======================================================================================================================
-void mainLoop()
+void mainLoopExtra()
 {
 {
-	INFO("Entering main loop");
+	InputSingleton::getInstance().handleEvents();
+
+	float dist = 0.2;
+	float ang = toRad(3.0);
+	float scale = 0.01;
+
+	// move the camera
+	static SceneNode* mover = AppSingleton::getInstance().getActiveCam();
+
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_1)) mover = AppSingleton::getInstance().getActiveCam();
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_2)) mover = point_lights[0];
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_3)) mover = spot_lights[0];
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_4)) mover = point_lights[1];
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_5)) mover = spot_lights[1];
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_6)) mover = horse;
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_M) == 1) InputSingleton::getInstance().warpMouse = !InputSingleton::getInstance().warpMouse;
+
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_A)) mover->moveLocalX(-dist);
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_D)) mover->moveLocalX(dist);
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_LSHIFT)) mover->moveLocalY(dist);
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_SPACE)) mover->moveLocalY(-dist);
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_W)) mover->moveLocalZ(-dist);
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_S)) mover->moveLocalZ(dist);
+	if(!InputSingleton::getInstance().warpMouse)
+	{
+		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_UP)) mover->rotateLocalX(ang);
+		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_DOWN)) mover->rotateLocalX(-ang);
+		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_LEFT)) mover->rotateLocalY(ang);
+		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_RIGHT)) mover->rotateLocalY(-ang);
+	}
+	else
+	{
+		float accel = 44.0;
+		mover->rotateLocalX(ang * InputSingleton::getInstance().mouseVelocity.y() * accel);
+		mover->rotateLocalY(-ang * InputSingleton::getInstance().mouseVelocity.x() * accel);
+	}
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_Q)) mover->rotateLocalZ(ang);
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_E)) mover->rotateLocalZ(-ang);
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_PAGEUP)) mover->getLocalTransform().getScale() += scale ;
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_PAGEDOWN)) mover->getLocalTransform().getScale() -= scale ;
 
 
-	int ticks = App::getTicks();
-	do
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_K)) AppSingleton::getInstance().getActiveCam()->lookAtPoint(point_lights[0]->getWorldTransform().getOrigin());
+
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_I))
+		character->moveForward(0.1);
+
+
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_O) == 1)
 	{
 	{
-		float crntTime = App::getTicks() / 1000.0;
-		InputSingleton::getInstance().handleEvents();
-
-		float dist = 0.2;
-		float ang = toRad(3.0);
-		float scale = 0.01;
-
-		// move the camera
-		static SceneNode* mover = AppSingleton::getInstance().getActiveCam();
-
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_1)) mover = AppSingleton::getInstance().getActiveCam();
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_2)) mover = point_lights[0];
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_3)) mover = spot_lights[0];
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_4)) mover = point_lights[1];
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_5)) mover = spot_lights[1];
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_6)) mover = horse;
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_M) == 1) InputSingleton::getInstance().warpMouse = !InputSingleton::getInstance().warpMouse;
-
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_A)) mover->moveLocalX(-dist);
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_D)) mover->moveLocalX(dist);
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_LSHIFT)) mover->moveLocalY(dist);
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_SPACE)) mover->moveLocalY(-dist);
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_W)) mover->moveLocalZ(-dist);
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_S)) mover->moveLocalZ(dist);
-		if(!InputSingleton::getInstance().warpMouse)
-		{
-			if(InputSingleton::getInstance().getKey(SDL_SCANCODE_UP)) mover->rotateLocalX(ang);
-			if(InputSingleton::getInstance().getKey(SDL_SCANCODE_DOWN)) mover->rotateLocalX(-ang);
-			if(InputSingleton::getInstance().getKey(SDL_SCANCODE_LEFT)) mover->rotateLocalY(ang);
-			if(InputSingleton::getInstance().getKey(SDL_SCANCODE_RIGHT)) mover->rotateLocalY(-ang);
-		}
-		else
-		{
-			float accel = 44.0;
-			mover->rotateLocalX(ang * InputSingleton::getInstance().mouseVelocity.y() * accel);
-			mover->rotateLocalY(-ang * InputSingleton::getInstance().mouseVelocity.x() * accel);
-		}
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_Q)) mover->rotateLocalZ(ang);
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_E)) mover->rotateLocalZ(-ang);
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_PAGEUP)) mover->getLocalTransform().getScale() += scale ;
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_PAGEDOWN)) mover->getLocalTransform().getScale() -= scale ;
+		btRigidBody* body = static_cast<btRigidBody*>(boxes[0]);
+		//body->getMotionState()->setWorldTransform(toBt(Mat4(Vec3(0.0, 10.0, 0.0), Mat3::getIdentity(), 1.0)));
+		body->setWorldTransform(toBt(Mat4(Vec3(0.0, 10.0, 0.0), Mat3::getIdentity(), 1.0)));
+		//body->clearForces();
+		body->forceActivationState(ACTIVE_TAG);
+	}
 
 
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_K)) AppSingleton::getInstance().getActiveCam()->lookAtPoint(point_lights[0]->getWorldTransform().getOrigin());
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_Y) == 1)
+	{
+		INFO("Exec script");
+		ScriptingEngineSingleton::getInstance().execScript(Util::readFile("test.py").c_str());
+	}
 
 
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_I))
-			character->moveForward(0.1);
+	mover->getLocalTransform().getRotation().reorthogonalize();
+}
 
 
 
 
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_O) == 1)
-		{
-			btRigidBody* body = static_cast<btRigidBody*>(boxes[0]);
-			//body->getMotionState()->setWorldTransform(toBt(Mat4(Vec3(0.0, 10.0, 0.0), Mat3::getIdentity(), 1.0)));
-			body->setWorldTransform(toBt(Mat4(Vec3(0.0, 10.0, 0.0), Mat3::getIdentity(), 1.0)));
-			//body->clearForces();
-			body->forceActivationState(ACTIVE_TAG);
-		}
+//======================================================================================================================
+// mainLoop                                                                                                            =
+//======================================================================================================================
+void mainLoop()
+{
+	INFO("Entering main loop");
 
 
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_Y) == 1)
-		{
-			INFO("Exec script");
-			ScriptingEngineSingleton::getInstance().execScript(Util::readFile("test.py").c_str());
-		}
+	int ticks = App::getTicks();
+	do
+	{
+		HighRezTimer timer;
+		timer.start();
 
 
-		mover->getLocalTransform().getRotation().reorthogonalize();
+		mainLoopExtra();
 
 
 		AppSingleton::getInstance().execStdinScpripts();
 		AppSingleton::getInstance().execStdinScpripts();
-		SceneSingleton::getInstance().getPhysics().update(crntTime);
+		SceneSingleton::getInstance().getPhysics().update(timer.getCrntTime());
 		SceneSingleton::getInstance().updateAllControllers();
 		SceneSingleton::getInstance().updateAllControllers();
 		SceneSingleton::getInstance().updateAllWorldStuff();
 		SceneSingleton::getInstance().updateAllWorldStuff();
 		SceneSingleton::getInstance().doVisibilityTests(*AppSingleton::getInstance().getActiveCam());
 		SceneSingleton::getInstance().doVisibilityTests(*AppSingleton::getInstance().getActiveCam());
 
 
 		MainRendererSingleton::getInstance().render(*AppSingleton::getInstance().getActiveCam());
 		MainRendererSingleton::getInstance().render(*AppSingleton::getInstance().getActiveCam());
 
 
-		ResourceManagerSingleton::getInstance().serveFinishedRequests(1000);
-
-		//map.octree.root->bounding_box.render();
-
-		// print some debug stuff
-		/*Ui::setColor(Vec4(1.0, 1.0, 1.0, 1.0));
-		Ui::setPos(-0.98, 0.95);
-		Ui::setFontWidth(0.03);*/
-		//Ui::printf("frame:%d fps:%dms\n", AppSingleton::getInstance().getMainRenderer().getFramesNum(), (App::getTicks()-ticks_));
-		//Ui::print("Movement keys: arrows,w,a,s,d,q,e,shift,space\nSelect objects: keys 1 to 5\n");
-		/*Ui::printf("Mover: Pos(%.2f %.2f %.2f) Angs(%.2f %.2f %.2f)", mover->translationWspace.x, mover->translationWspace.y, mover->translationWspace.z,
-								 toDegrees(Euler(mover->rotationWspace).x), toDegrees(Euler(mover->rotationWspace).y), toDegrees(Euler(mover->rotationWspace).z));*/
-
 		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_ESCAPE))
 		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_ESCAPE))
+		{
 			break;
 			break;
+		}
+
 		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_F11))
 		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_F11))
+		{
 			AppSingleton::getInstance().togleFullScreen();
 			AppSingleton::getInstance().togleFullScreen();
+		}
+
 		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_F12) == 1)
 		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_F12) == 1)
+		{
 			MainRendererSingleton::getInstance().takeScreenshot("gfx/screenshot.jpg");
 			MainRendererSingleton::getInstance().takeScreenshot("gfx/screenshot.jpg");
+		}
 
 
-		/*char str[128];
-		static string scrFile = (AppSingleton::getInstance().getSettingsPath() / "capt" / "%06d.jpg").string();
-		sprintf(str, scrFile.c_str(), AppSingleton::getInstance().getMainRenderer().getFramesNum());
-		AppSingleton::getInstance().getMainRenderer().takeScreenshot(str);*/
-
-		// std stuff follow
 		AppSingleton::getInstance().swapBuffers();
 		AppSingleton::getInstance().swapBuffers();
+
+		uint timeToSpendForRsrcPostProcess = AppSingleton::getInstance().getTimerTick() - timer.getElapsedTime();
+		ResourceManagerSingleton::getInstance().postProcessFinishedLoadingRequests(timeToSpendForRsrcPostProcess);
+
 		if(1)
 		if(1)
 		{
 		{
-			//if(AppSingleton::getInstance().getMainRenderer().getFramesNum() == 100) AppSingleton::getInstance().getMainRenderer().takeScreenshot("gfx/screenshot.tga");
-			AppSingleton::getInstance().waitForNextFrame();
+			//AppSingleton::getInstance().waitForNextFrame();
+
+			timer.stop();
+			if(timer.getElapsedTime() < AppSingleton::getInstance().getTimerTick())
+			{
+				SDL_Delay(AppSingleton::getInstance().getTimerTick() - timer.getElapsedTime());
+			}
 		}
 		}
 		else
 		else
 		{
 		{

+ 18 - 0
src/Renderer/SceneDbgDrawer.cpp

@@ -3,6 +3,7 @@
 #include "Camera.h"
 #include "Camera.h"
 #include "Light.h"
 #include "Light.h"
 #include "ParticleEmitter.h"
 #include "ParticleEmitter.h"
+#include "SkinNode.h"
 
 
 
 
 //======================================================================================================================
 //======================================================================================================================
@@ -56,3 +57,20 @@ void SceneDbgDrawer::drawParticleEmitter(const ParticleEmitter& pe) const
 	dbg.setModelMat(Mat4(pe.getWorldTransform()));
 	dbg.setModelMat(Mat4(pe.getWorldTransform()));
 	dbg.drawCube();
 	dbg.drawCube();
 }
 }
+
+
+//======================================================================================================================
+// drawSkinNodeSkeleton                                                                                                =
+//======================================================================================================================
+void SceneDbgDrawer::drawSkinNodeSkeleton(const SkinNode& sn) const
+{
+	dbg.setModelMat(Mat4(sn.getWorldTransform()));
+
+	for(uint i = 0; i < sn.getHeads().size(); i++)
+	{
+		dbg.setColor(Vec4(1.0, 0.0, 0.0, 1.0));
+		dbg.pushBackVertex(sn.getHeads()[i]);
+		dbg.setColor(Vec4(1.0));
+		dbg.pushBackVertex(sn.getTails()[i]);
+	}
+}

+ 4 - 0
src/Renderer/SceneDbgDrawer.h

@@ -6,6 +6,7 @@ class Dbg;
 class Camera;
 class Camera;
 class Light;
 class Light;
 class ParticleEmitter;
 class ParticleEmitter;
+class SkinNode;
 
 
 
 
 /// This is a drawer for some scene nodes that need debug
 /// This is a drawer for some scene nodes that need debug
@@ -24,6 +25,9 @@ class SceneDbgDrawer
 		/// Draw a ParticleEmitter
 		/// Draw a ParticleEmitter
 		virtual void drawParticleEmitter(const ParticleEmitter& pe) const;
 		virtual void drawParticleEmitter(const ParticleEmitter& pe) const;
 
 
+		/// Draw a skeleton
+		virtual void drawSkinNodeSkeleton(const SkinNode& pe) const;
+
 	private:
 	private:
 		Dbg& dbg; ///< The debug stage
 		Dbg& dbg; ///< The debug stage
 };
 };

+ 4 - 9
src/Renderer/SkinsDeformer.cpp

@@ -14,18 +14,13 @@ void SkinsDeformer::init()
 	                                                   "#define NORMAL_ENABLED\n#define TANGENT_ENABLED\n",
 	                                                   "#define NORMAL_ENABLED\n#define TANGENT_ENABLED\n",
 	                                                   "pnt");
 	                                                   "pnt");
 
 
-	std::string pn = ShaderProg::createSrcCodeToCache("shaders/TfHwSkinningGeneric.glsl",
-	                                                  "#define NORMAL_ENABLED\n",
-	                                                  "pn");
-
-	std::string pt = ShaderProg::createSrcCodeToCache("shaders/TfHwSkinningGeneric.glsl",
-	                                                  "\n#define TANGENT_ENABLED\n",
-	                                                  "pt");
+	std::string p = ShaderProg::createSrcCodeToCache("shaders/TfHwSkinningGeneric.glsl",
+	                                                 "",
+	                                                 "p");
 
 
 
 
 	tfHwSkinningAllSProg.loadRsrc(all.c_str());
 	tfHwSkinningAllSProg.loadRsrc(all.c_str());
-	tfHwSkinningPosNormSProg.loadRsrc(pn.c_str());
-	tfHwSkinningPosTangentSProg.loadRsrc(pt.c_str());
+	tfHwSkinningPosSProg.loadRsrc(p.c_str());
 }
 }
 
 
 
 

+ 17 - 2
src/Renderer/SkinsDeformer.h

@@ -11,13 +11,28 @@ class ShaderProg;
 class SkinsDeformer
 class SkinsDeformer
 {
 {
 	public:
 	public:
+		enum TfShaderProgAttrib
+		{
+			TFSPA_POSITION,
+			TFSPA_NORMAL,
+			TFSPA_TANGENT,
+			TFSPA_VERT_WEIGHT_BONES_NUM,
+			TFSPA_VERT_WEIGHT_BONE_IDS,
+			TFSPA_VERT_WEIGHT_WEIGHTS
+		};
+
+		/// @name Accessors
+		/// @{
+		/*const ShaderProg& allSProg() const {return *tfHwSkinningAllSProg;}
+		const ShaderProg& posSProg() const {return *tfHwSkinningAllSProg;}*/
+		/// @}
+
 		void init();
 		void init();
 		void run();
 		void run();
 
 
 	private:
 	private:
 		RsrcPtr<ShaderProg> tfHwSkinningAllSProg;
 		RsrcPtr<ShaderProg> tfHwSkinningAllSProg;
-		RsrcPtr<ShaderProg> tfHwSkinningPosNormSProg;
-		RsrcPtr<ShaderProg> tfHwSkinningPosTangentSProg;
+		RsrcPtr<ShaderProg> tfHwSkinningPosSProg;
 };
 };
 
 
 
 

+ 20 - 3
src/Resources/Core/ResourceManager.cpp

@@ -52,16 +52,33 @@ SPECIALIZE_TEMPLATE_STUFF(DummyRsrc, dummies)
 template<>
 template<>
 void ResourceManager::allocAndLoadRsrc(const char* filename, Texture*& ptr)
 void ResourceManager::allocAndLoadRsrc(const char* filename, Texture*& ptr)
 {
 {
-	// Load the dummy
+	// Load the dummys
 	if(dummyTex.get() == NULL)
 	if(dummyTex.get() == NULL)
 	{
 	{
 		dummyTex.reset(new Texture);
 		dummyTex.reset(new Texture);
-		dummyTex->load("gfx/default.png");
+		dummyTex->load("gfx/dummy.png");
 	}
 	}
 	
 	
+	if(dummyNormTex.get() == NULL)
+	{
+		dummyNormTex.reset(new Texture);
+		dummyNormTex->load("gfx/dummy.norm.png");
+	}
+
 	// Send a loading request
 	// Send a loading request
 	rsrcAsyncLoadingReqsHandler.sendNewLoadingRequest(filename, &ptr);
 	rsrcAsyncLoadingReqsHandler.sendNewLoadingRequest(filename, &ptr);
 
 
-	ptr = dummyTex.get();
+	// Point to the dummy for now
+	std::string fname(filename);
+
+	size_t found = fname.find("norm.");
+	if(found != std::string::npos)
+	{
+		ptr = dummyNormTex.get();
+	}
+	else
+	{
+		ptr = dummyTex.get();
+	}
 }
 }
 
 

+ 10 - 2
src/Resources/Core/ResourceManager.h

@@ -52,8 +52,8 @@ class ResourceManager
 		template<typename Type>
 		template<typename Type>
 		void unload(const typename Types<Type>::Hook& info);
 		void unload(const typename Types<Type>::Hook& info);
 		
 		
-		/// See RsrcAsyncLoadingReqsHandler::serveFinishedRequests
-		void serveFinishedRequests(uint maxTime) {rsrcAsyncLoadingReqsHandler.serveFinishedRequests(maxTime);}
+		/// See RsrcAsyncLoadingReqsHandler::postProcessFinishedRequests
+		void postProcessFinishedLoadingRequests(uint maxTime);
 
 
 	private:
 	private:
 		/// @name Containers
 		/// @name Containers
@@ -78,6 +78,8 @@ class ResourceManager
 		/// texture. Its initialized when its first needed so that we wont have conflicts with opengl initialization.
 		/// texture. Its initialized when its first needed so that we wont have conflicts with opengl initialization.
 		std::auto_ptr<Texture> dummyTex;
 		std::auto_ptr<Texture> dummyTex;
 
 
+		std::auto_ptr<Texture> dummyNormTex; ///< The same as dummyTex but for normals
+
 		/// Find a resource using the filename
 		/// Find a resource using the filename
 		template<typename Type>
 		template<typename Type>
 		typename Types<Type>::Iterator find(const char* filename, typename Types<Type>::Container& container);
 		typename Types<Type>::Iterator find(const char* filename, typename Types<Type>::Container& container);
@@ -102,6 +104,12 @@ class ResourceManager
 };
 };
 
 
 
 
+inline void ResourceManager::postProcessFinishedLoadingRequests(uint maxTime)
+{
+	rsrcAsyncLoadingReqsHandler.postProcessFinishedRequests(maxTime);
+}
+
+
 #include "ResourceManager.inl.h"
 #include "ResourceManager.inl.h"
 
 
 
 

+ 3 - 0
src/Resources/Core/ResourceManager.inl.h

@@ -1,4 +1,5 @@
 #include "Exception.h"
 #include "Exception.h"
+#include "Logger.h"
 
 
 
 
 //======================================================================================================================
 //======================================================================================================================
@@ -16,6 +17,8 @@ void ResourceManager::allocAndLoadRsrc(const char* filename, Type*& newInstance)
 	}
 	}
 	catch(std::exception& e)
 	catch(std::exception& e)
 	{
 	{
+		ERROR("fuckkkkkkkkkk " << e.what());
+
 		if(newInstance != NULL)
 		if(newInstance != NULL)
 		{
 		{
 			delete newInstance;
 			delete newInstance;

+ 3 - 3
src/Resources/Core/RsrcAsyncLoadingReqsHandler.cpp

@@ -17,9 +17,9 @@ void RsrcAsyncLoadingReqsHandler::sendNewLoadingRequest<Texture>(const char* fil
 
 
 
 
 //======================================================================================================================
 //======================================================================================================================
-// serveFinishedRequests                                                                                               =
+// postProcessFinishedRequests                                                                                         =
 //======================================================================================================================
 //======================================================================================================================
-void RsrcAsyncLoadingReqsHandler::serveFinishedRequests(uint maxTime)
+void RsrcAsyncLoadingReqsHandler::postProcessFinishedRequests(uint maxTime)
 {
 {
 	HighRezTimer t;
 	HighRezTimer t;
 	t.start();
 	t.start();
@@ -72,6 +72,6 @@ void RsrcAsyncLoadingReqsHandler::loadImageCallback(const char* filename, void*
 {
 {
 	Image* img = (Image*)img_;
 	Image* img = (Image*)img_;
 	img->load(filename);
 	img->load(filename);
-	sleep(2);
+	//sleep(2);
 }
 }
 
 

+ 1 - 1
src/Resources/Core/RsrcAsyncLoadingReqsHandler.h

@@ -30,7 +30,7 @@ class RsrcAsyncLoadingReqsHandler
 		/// @param maxTime The max time to spend serving finished requests. If for example there are many that need more
 		/// @param maxTime The max time to spend serving finished requests. If for example there are many that need more
 		/// time than the max the method will return. The pending requests will be served when it will be called again.
 		/// time than the max the method will return. The pending requests will be served when it will be called again.
 		/// In ms
 		/// In ms
-		void serveFinishedRequests(uint maxTime);
+		void postProcessFinishedRequests(uint maxTime);
 		
 		
 	
 	
 	private:
 	private:

+ 5 - 1
src/Resources/Skin.h

@@ -29,15 +29,19 @@ class Skin
 
 
 		/// @name Accessors
 		/// @name Accessors
 		/// @{
 		/// @{
+		const Model& getModel() const {return *model;}
 		const boost::ptr_vector<ModelPatch>& getModelPatches() const {return model->getModelPatches();}
 		const boost::ptr_vector<ModelPatch>& getModelPatches() const {return model->getModelPatches();}
-		const Skeleton& getSkeleton() const;
+		const Skeleton& getSkeleton() const {return *skeleton;}
 		const Vec<RsrcPtr<SkelAnim> >& getSkelAnims() const {return skelAnims;}
 		const Vec<RsrcPtr<SkelAnim> >& getSkelAnims() const {return skelAnims;}
 		/// @}
 		/// @}
 
 
 	private:
 	private:
+		/// @name The resources
+		/// @{
 		RsrcPtr<Model> model;
 		RsrcPtr<Model> model;
 		RsrcPtr<Skeleton> skeleton; ///< The skeleton
 		RsrcPtr<Skeleton> skeleton; ///< The skeleton
 		Vec<RsrcPtr<SkelAnim> > skelAnims; ///< The standard skeleton animations
 		Vec<RsrcPtr<SkelAnim> > skelAnims; ///< The standard skeleton animations
+		/// @}
 };
 };
 
 
 
 

+ 13 - 12
src/Scene/Controllers/SkelAnimModelNodeCtrl.cpp

@@ -1,19 +1,19 @@
 #include "SkelAnimModelNodeCtrl.h"
 #include "SkelAnimModelNodeCtrl.h"
 #include "SkelAnim.h"
 #include "SkelAnim.h"
 #include "Skeleton.h"
 #include "Skeleton.h"
-#include "App.h"
-#include "ModelNode.h"
+#include "SkinNode.h"
 #include "Model.h"
 #include "Model.h"
 #include "MainRenderer.h"
 #include "MainRenderer.h"
+#include "Skin.h"
 
 
 
 
 //======================================================================================================================
 //======================================================================================================================
 // SkelAnimModelNodeCtrl                                                                                               =
 // SkelAnimModelNodeCtrl                                                                                               =
 //======================================================================================================================
 //======================================================================================================================
-SkelAnimModelNodeCtrl::SkelAnimModelNodeCtrl(ModelNode& modelNode_):
+SkelAnimModelNodeCtrl::SkelAnimModelNodeCtrl(SkinNode& skinNode_):
 	Controller(CT_SKEL_ANIM),
 	Controller(CT_SKEL_ANIM),
-	modelNode(modelNode_),
-	frame(0.0)
+	frame(0.0),
+	skinNode(skinNode_)
 {}
 {}
 
 
 
 
@@ -156,17 +156,18 @@ void SkelAnimModelNodeCtrl::deform(const Skeleton& skeleton, const Vec<Vec3>& bo
 //======================================================================================================================
 //======================================================================================================================
 void SkelAnimModelNodeCtrl::update(float)
 void SkelAnimModelNodeCtrl::update(float)
 {
 {
-	/*frame += step;
+	frame += step;
 	if(frame > skelAnim->framesNum) // if the crnt is finished then play the next or loop the crnt
 	if(frame > skelAnim->framesNum) // if the crnt is finished then play the next or loop the crnt
 	{
 	{
 		frame = 0.0;
 		frame = 0.0;
 	}
 	}
 
 
-	interpolate(*skelAnim, frame, modelNode.getBoneTranslations(), modelNode.getBoneRotations());
-	updateBoneTransforms(modelNode.getModel().getSkeleton(), modelNode.getBoneTranslations(), modelNode.getBoneRotations());
-	if(app->getMainRenderer().getDbg().isEnabled() && app->getMainRenderer().getDbg().isShowSkeletonsEnabled())
+	interpolate(*skelAnim, frame, skinNode.getBoneTranslations(), skinNode.getBoneRotations());
+	updateBoneTransforms(skinNode.getSkin().getSkeleton(), skinNode.getBoneTranslations(), skinNode.getBoneRotations());
+	if(MainRendererSingleton::getInstance().getDbg().isEnabled() &&
+	   MainRendererSingleton::getInstance().getDbg().isShowSkeletonsEnabled())
 	{
 	{
-		deform(modelNode.getModel().getSkeleton(), modelNode.getBoneTranslations(), modelNode.getBoneRotations(),
-		       modelNode.getHeads(), modelNode.getTails());
-	}*/
+		deform(skinNode.getSkin().getSkeleton(), skinNode.getBoneTranslations(), skinNode.getBoneRotations(),
+		       skinNode.getHeads(), skinNode.getTails());
+	}
 }
 }

+ 12 - 5
src/Scene/Controllers/SkelAnimModelNodeCtrl.h

@@ -10,23 +10,30 @@
 
 
 class Skeleton;
 class Skeleton;
 class SkelAnim;
 class SkelAnim;
-class ModelNode;
+class SkinNode;
 
 
 
 
 /// SkelAnim controls a ModelNode
 /// SkelAnim controls a ModelNode
 class SkelAnimModelNodeCtrl: public Controller
 class SkelAnimModelNodeCtrl: public Controller
 {
 {
-	PROPERTY_RW(float, step, getStep, setStep)
-
 	public:
 	public:
-		SkelAnimModelNodeCtrl(ModelNode& skelNode_);
+		SkelAnimModelNodeCtrl(SkinNode& skelNode_);
+
+		/// @name Accessors
+		/// @{
+		float getStep() const {return step;}
+		float& getStep() {return step;}
+		void setStep(float s) {step = s;}
+		/// @}
+
 		void update(float time);
 		void update(float time);
 		void set(const SkelAnim* skelAnim_) {skelAnim = skelAnim_;}
 		void set(const SkelAnim* skelAnim_) {skelAnim = skelAnim_;}
 
 
 	private:
 	private:
+		float step;
 		float frame;
 		float frame;
 		const SkelAnim* skelAnim; ///< The active skeleton animation
 		const SkelAnim* skelAnim; ///< The active skeleton animation
-		ModelNode& modelNode; ///< Know your father
+		SkinNode& skinNode; ///< Know your father
 
 
 		/// @name The 3 steps of skeletal animation in 3 methods
 		/// @name The 3 steps of skeletal animation in 3 methods
 		/// @{
 		/// @{

+ 7 - 0
src/Scene/SkinNode.cpp

@@ -1,5 +1,7 @@
+#include <boost/foreach.hpp>
 #include "SkinNode.h"
 #include "SkinNode.h"
 #include "Skin.h"
 #include "Skin.h"
+#include "SkinPatchNode.h"
 
 
 
 
 //======================================================================================================================
 //======================================================================================================================
@@ -8,4 +10,9 @@
 void SkinNode::init(const char* filename)
 void SkinNode::init(const char* filename)
 {
 {
 	skin.loadRsrc(filename);
 	skin.loadRsrc(filename);
+
+	BOOST_FOREACH(const ModelPatch& patch, skin->getModelPatches())
+	{
+		patches.push_back(new SkinPatchNode(patch, this));
+	}
 }
 }

+ 26 - 0
src/Scene/SkinNode.h

@@ -4,22 +4,48 @@
 #include "SceneNode.h"
 #include "SceneNode.h"
 #include "SkinPatchNode.h"
 #include "SkinPatchNode.h"
 #include "Vec.h"
 #include "Vec.h"
+#include "Math.h"
 
 
 
 
 class Skin;
 class Skin;
+class SkelAnimModelNodeCtrl;
 
 
 
 
 /// A skin scene node
 /// A skin scene node
 class SkinNode: public SceneNode
 class SkinNode: public SceneNode
 {
 {
 	public:
 	public:
+		SkelAnimModelNodeCtrl* skelAnimModelNodeCtrl; ///< @todo fix this crap
+
 		SkinNode(): SceneNode(SNT_SKIN, true, NULL) {}
 		SkinNode(): SceneNode(SNT_SKIN, true, NULL) {}
 
 
+		/// @name Accessors
+		/// @{
+		const Vec<Vec3>& getHeads() const {return heads;}
+		Vec<Vec3>& getHeads() {return heads;}
+
+		const Vec<Vec3>& getTails() const {return tails;}
+		Vec<Vec3>& getTails() {return tails;}
+
+		const Vec<Mat3>& getBoneRotations() const {return boneRotations;}
+		Vec<Mat3>& getBoneRotations() {return boneRotations;}
+
+		const Vec<Vec3>& getBoneTranslations() const {return boneTranslations;}
+		Vec<Vec3>& getBoneTranslations() {return boneTranslations;}
+
+		const Skin& getSkin() const {return *skin;}
+		/// @}
+
 		void init(const char* filename);
 		void init(const char* filename);
 
 
 	private:
 	private:
 		RsrcPtr<Skin> skin; ///< The resource
 		RsrcPtr<Skin> skin; ///< The resource
 		Vec<SkinPatchNode*> patches;
 		Vec<SkinPatchNode*> patches;
+
+		Vec<Vec3> heads;
+		Vec<Vec3> tails;
+		Vec<Mat3> boneRotations;
+		Vec<Vec3> boneTranslations;
 };
 };
 
 
 
 

+ 32 - 0
src/Scene/SkinPatchNode.cpp

@@ -1,5 +1,9 @@
 #include "SkinPatchNode.h"
 #include "SkinPatchNode.h"
 #include "SkinNode.h"
 #include "SkinNode.h"
+#include "SkinsDeformer.h"
+
+
+#define BUFFER_OFFSET(i) ((char *)NULL + (i))
 
 
 
 
 //======================================================================================================================
 //======================================================================================================================
@@ -17,31 +21,59 @@ SkinPatchNode::SkinPatchNode(const ModelPatch& modelPatch, SkinNode* parent):
 
 
 	const Mesh& mesh = rsrc.getMesh();
 	const Mesh& mesh = rsrc.getMesh();
 
 
+	//
+	// Create the VAOs
+	//
+
+	tfVao.create();
 
 
+	// Positions
 	if(mesh.getVbo(Mesh::VBO_VERT_POSITIONS).isCreated())
 	if(mesh.getVbo(Mesh::VBO_VERT_POSITIONS).isCreated())
 	{
 	{
 		tfVbos[TFV_POSITIONS].create(GL_ARRAY_BUFFER, mesh.getVbo(Mesh::VBO_VERT_POSITIONS).getSizeInBytes(),
 		tfVbos[TFV_POSITIONS].create(GL_ARRAY_BUFFER, mesh.getVbo(Mesh::VBO_VERT_POSITIONS).getSizeInBytes(),
 	                               NULL, GL_STATIC_DRAW);
 	                               NULL, GL_STATIC_DRAW);
 		vboArr[Mesh::VBO_VERT_POSITIONS] = &tfVbos[TFV_POSITIONS];
 		vboArr[Mesh::VBO_VERT_POSITIONS] = &tfVbos[TFV_POSITIONS];
+
+		tfVao.attachArrayBufferVbo(tfVbos[TFV_POSITIONS], SkinsDeformer::TFSPA_POSITION, 3, GL_FLOAT, false, 0, NULL);
 	}
 	}
 
 
+	// Normals
 	if(mesh.getVbo(Mesh::VBO_VERT_NORMALS).isCreated())
 	if(mesh.getVbo(Mesh::VBO_VERT_NORMALS).isCreated())
 	{
 	{
 		tfVbos[TFV_NORMALS].create(GL_ARRAY_BUFFER, mesh.getVbo(Mesh::VBO_VERT_NORMALS).getSizeInBytes(),
 		tfVbos[TFV_NORMALS].create(GL_ARRAY_BUFFER, mesh.getVbo(Mesh::VBO_VERT_NORMALS).getSizeInBytes(),
 	                               NULL, GL_STATIC_DRAW);
 	                               NULL, GL_STATIC_DRAW);
 
 
 		vboArr[Mesh::VBO_VERT_NORMALS] = &tfVbos[TFV_NORMALS];
 		vboArr[Mesh::VBO_VERT_NORMALS] = &tfVbos[TFV_NORMALS];
+
+		tfVao.attachArrayBufferVbo(tfVbos[TFV_NORMALS], SkinsDeformer::TFSPA_NORMAL, 3, GL_FLOAT, false, 0, NULL);
 	}
 	}
 
 
+	// Tangents
 	if(mesh.getVbo(Mesh::VBO_VERT_TANGENTS).isCreated())
 	if(mesh.getVbo(Mesh::VBO_VERT_TANGENTS).isCreated())
 	{
 	{
 		tfVbos[TFV_TANGENTS].create(GL_ARRAY_BUFFER, mesh.getVbo(Mesh::VBO_VERT_TANGENTS).getSizeInBytes(),
 		tfVbos[TFV_TANGENTS].create(GL_ARRAY_BUFFER, mesh.getVbo(Mesh::VBO_VERT_TANGENTS).getSizeInBytes(),
 	                               NULL, GL_STATIC_DRAW);
 	                               NULL, GL_STATIC_DRAW);
 
 
 		vboArr[Mesh::VBO_VERT_TANGENTS] = &tfVbos[TFV_TANGENTS];
 		vboArr[Mesh::VBO_VERT_TANGENTS] = &tfVbos[TFV_TANGENTS];
+
+		tfVao.attachArrayBufferVbo(tfVbos[TFV_TANGENTS], SkinsDeformer::TFSPA_TANGENT, 4, GL_FLOAT, false, 0, NULL);
 	}
 	}
 
 
+	// Attach some extra stuff to the tfVao
+	RASSERT_THROW_EXCEPTION(!mesh.getVbo(Mesh::VBO_VERT_WEIGHTS).isCreated());
+
+	tfVao.attachArrayBufferVbo(mesh.getVbo(Mesh::VBO_VERT_WEIGHTS), SkinsDeformer::TFSPA_VERT_WEIGHT_BONES_NUM, 1,
+	                           GL_FLOAT, GL_FALSE, sizeof(MeshData::VertexWeight), BUFFER_OFFSET(0));
+
+
+	tfVao.attachArrayBufferVbo(mesh.getVbo(Mesh::VBO_VERT_WEIGHTS), SkinsDeformer::TFSPA_VERT_WEIGHT_BONE_IDS, 4,
+	                           GL_FLOAT, GL_FALSE, sizeof(MeshData::VertexWeight), BUFFER_OFFSET(4));
+
+	tfVao.attachArrayBufferVbo(mesh.getVbo(Mesh::VBO_VERT_WEIGHTS),SkinsDeformer::TFSPA_VERT_WEIGHT_WEIGHTS, 4,
+	                           GL_FLOAT, GL_FALSE, sizeof(MeshData::VertexWeight), BUFFER_OFFSET(20));
+
 
 
+	// Rendering VAOs
 	createVao(rsrc.getCpMtl(), vboArr, cpVao);
 	createVao(rsrc.getCpMtl(), vboArr, cpVao);
 	createVao(rsrc.getDpMtl(), vboArr, dpVao);
 	createVao(rsrc.getDpMtl(), vboArr, dpVao);
 }
 }

+ 5 - 2
src/Scene/SkinPatchNode.h

@@ -4,6 +4,7 @@
 #include <boost/array.hpp>
 #include <boost/array.hpp>
 #include "PatchNode.h"
 #include "PatchNode.h"
 #include "Vbo.h"
 #include "Vbo.h"
+#include "Vao.h"
 
 
 
 
 class SkinNode;
 class SkinNode;
@@ -17,13 +18,15 @@ class SkinPatchNode: public PatchNode
 		{
 		{
 			TFV_POSITIONS,
 			TFV_POSITIONS,
 			TFV_NORMALS,
 			TFV_NORMALS,
-			TFV_TANGENTS
+			TFV_TANGENTS,
+			TFV_NUM
 		};
 		};
 
 
 		SkinPatchNode(const ModelPatch& modelPatch, SkinNode* parent);
 		SkinPatchNode(const ModelPatch& modelPatch, SkinNode* parent);
 
 
 	public:
 	public:
-		boost::array<Vbo, 3> tfVbos; ///< VBOs that contain the deformed vertex attributes
+		boost::array<Vbo, TFV_NUM> tfVbos; ///< VBOs that contain the deformed vertex attributes
+		Vao tfVao; ///< For TF passes
 };
 };
 
 
 
 

+ 1 - 1
src/Util/Exception.h

@@ -33,7 +33,7 @@ class Exception: public std::exception
 // Macros                                                                                                              =
 // Macros                                                                                                              =
 //======================================================================================================================
 //======================================================================================================================
 
 
-#define EXCEPTION(x) Exception(std::string() + x, __FILE__, __LINE__, __func__)
+#define EXCEPTION(x) Exception(std::string() + x, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 
 #if DEBUG_ENABLED == 1
 #if DEBUG_ENABLED == 1
 	#define RASSERT_THROW_EXCEPTION(x) \
 	#define RASSERT_THROW_EXCEPTION(x) \

+ 2 - 1
src/Util/HighRezTimer.cpp

@@ -57,5 +57,6 @@ uint HighRezTimer::getElapsedTime() const
 uint HighRezTimer::getCrntTime()
 uint HighRezTimer::getCrntTime()
 {
 {
 	using namespace boost::posix_time;
 	using namespace boost::posix_time;
-	return ptime(microsec_clock::local_time()).time_of_day().total_milliseconds();
+	uint ms = ptime(microsec_clock::local_time()).time_of_day().total_milliseconds();
+	return ms;
 }
 }

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff