Kaynağa Gözat

- Events
- Scripting the events
- Scripting the HighRezTimer

Panagiotis Christopoulos Charitos 14 yıl önce
ebeveyn
işleme
240cd4b52f

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 1
build/debug/Makefile


+ 2 - 2
src/Events/Event.cpp

@@ -8,7 +8,7 @@ namespace Event {
 //======================================================================================================================
 // Constructor                                                                                                         =
 //======================================================================================================================
-Event::Event(EventType type_, uint startTime_, int duration_):
+Event::Event(EventType type_, uint startTime_, uint duration_):
 	type(type_),
 	startTime(startTime_),
 	duration(duration_)
@@ -35,7 +35,7 @@ void Event::update(uint prevUpdateTime, uint crntTime)
 	ASSERT(!isDead(crntTime));
 
 	// Dont update if its not the right time yet
-	if(startTime >= crntTime)
+	if(startTime <= crntTime)
 	{
 		updateSp(prevUpdateTime, crntTime);
 	}

+ 3 - 3
src/Events/Event.h

@@ -22,7 +22,7 @@ class Event
 {
 	public:
 		/// Constructor
-		Event(EventType type, uint startTime, int duration);
+		Event(EventType type, uint startTime, uint duration);
 
 		/// Copy constructor
 		Event(const Event& b) {*this = b;}
@@ -30,7 +30,7 @@ class Event
 		/// @name Accessors
 		/// @{
 		GETTER_R(uint, startTime, getStartTime)
-		GETTER_R(int, duration, getDuration)
+		GETTER_R(uint, duration, getDuration)
 		GETTER_R(EventType, type, getEventType)
 		bool isDead(uint crntTime) const {return crntTime >= startTime + duration;}
 		/// @}
@@ -56,7 +56,7 @@ class Event
 	private:
 		EventType type; ///< Self explanatory
 		uint startTime; ///< The time the event will start. Eg 23:00
-		int duration; ///< The duration of the event
+		uint duration; ///< The duration of the event
 };
 
 

+ 1 - 1
src/Events/EventMainRendererPpsHdr.cpp

@@ -9,7 +9,7 @@ namespace Event {
 //======================================================================================================================
 // Constructor                                                                                                         =
 //======================================================================================================================
-MainRendererPpsHdr::MainRendererPpsHdr(uint startTime, int duration,
+MainRendererPpsHdr::MainRendererPpsHdr(uint startTime, uint duration,
                                        float exposure_, uint blurringIterationsNum_, float blurringDist_):
 	Event(MAIN_RENDERER_PPS_HDR, startTime, duration)
 {

+ 1 - 1
src/Events/EventMainRendererPpsHdr.h

@@ -12,7 +12,7 @@ class MainRendererPpsHdr: public Event
 {
 	public:
 		/// Constructor
-		MainRendererPpsHdr(uint startTime, int duration,
+		MainRendererPpsHdr(uint startTime, uint duration,
 		                   float exposure, uint blurringIterationsNum, float blurringDist);
 
 		/// Copy constructor

+ 4 - 2
src/Events/EventSceneColor.cpp

@@ -1,6 +1,7 @@
 #include "EventSceneColor.h"
 #include "Scene.h"
 #include "Globals.h"
+#include "Logger.h"
 
 
 namespace Event {
@@ -9,7 +10,7 @@ namespace Event {
 //======================================================================================================================
 // Constructor                                                                                                         =
 //======================================================================================================================
-SceneColor::SceneColor(uint startTime, int duration, const Vec3& finalColor_):
+SceneColor::SceneColor(uint startTime, uint duration, const Vec3& finalColor_):
 	Event(SCENE_COLOR, startTime, duration),
 	finalColor(finalColor_)
 {
@@ -33,6 +34,7 @@ SceneColor::SceneColor(const SceneColor& b):
 SceneColor& SceneColor::operator=(const SceneColor& b)
 {
 	Event::operator=(b);
+	originalColor = b.originalColor;
 	finalColor = b.finalColor;
 	return *this;
 }
@@ -44,7 +46,7 @@ SceneColor& SceneColor::operator=(const SceneColor& b)
 void SceneColor::updateSp(uint /*prevUpdateTime*/, uint crntTime)
 {
 	float d = crntTime - getStartTime(); // delta
-	float dp = d / getDuration(); // delta as persentage
+	float dp = d / float(getDuration()); // delta as persentage
 
 	SceneSingleton::getInstance().setAmbientCol(interpolate(originalColor, finalColor, dp));
 }

+ 1 - 1
src/Events/EventSceneColor.h

@@ -13,7 +13,7 @@ class SceneColor: public Event
 {
 	public:
 		/// Constructor
-		SceneColor(uint startTime, int duration, const Vec3& finalColor);
+		SceneColor(uint startTime, uint duration, const Vec3& finalColor);
 
 		/// Copy constructor
 		SceneColor(const SceneColor& b);

+ 5 - 4
src/Main.cpp

@@ -44,6 +44,7 @@
 #include "UiFont.h"
 #include "EventManager.h"
 #include "EventSceneColor.h"
+#include "EventMainRendererPpsHdr.h"
 
 
 // map (hard coded)
@@ -314,10 +315,10 @@ void mainLoopExtra()
 	}
 
 
-	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_F))
+	if(InputSingleton::getInstance().getKey(SDL_SCANCODE_F) == 1)
 	{
-		Event::ManagerSingleton::getInstance().createEvent(Event::SceneColor(HighRezTimer::getCrntTime() + 4000, 5000,
-		                                                                     Vec3(1.0, 0.0, 0.0)));
+		Event::ManagerSingleton::getInstance().createEvent(Event::MainRendererPpsHdr(HighRezTimer::getCrntTime() + 5000,
+			5000, MainRendererSingleton::getInstance().getPps().getHdr().getExposure() + 20.0, 3, 1.4));
 	}
 
 
@@ -381,7 +382,7 @@ void mainLoop()
 
 		MainRendererSingleton::getInstance().render(*AppSingleton::getInstance().getActiveCam());
 
-		painter->setPosition(Vec2(0.0, 0.5));
+		painter->setPosition(Vec2(0.0, 0.1));
 		painter->setColor(Vec4(1.0));
 
 		//painter->drawText("A");

+ 2 - 0
src/Scripting/BoostPythonInterfaces.cpp

@@ -4,6 +4,8 @@
 
 BOOST_PYTHON_MODULE(Anki)
 {
+	CALL_WRAP(HighRezTimer);
+
 	CALL_WRAP(Vec2);
 	CALL_WRAP(Vec3);
 	CALL_WRAP(Vec4);

+ 1 - 1
src/Scripting/Events/EventMainRendererPpsHdr.bpi.cpp

@@ -5,7 +5,7 @@
 WRAP(EventMainRendererPpsHdr)
 {
 	class_<Event::MainRendererPpsHdr>("EventMainRendererPpsHdr", no_init)
-		.def(init<uint, int, float, uint, float>())
+		.def(init<uint, uint, float, uint, float>())
 		.def(init<const Event::MainRendererPpsHdr&>())
 	;
 }

+ 1 - 1
src/Scripting/Events/EventSceneColor.bpi.cpp

@@ -5,7 +5,7 @@
 WRAP(EventSceneColor)
 {
 	class_<Event::SceneColor>("EventSceneColor", no_init)
-		.def(init<uint, int, const Vec3&>())
+		.def(init<uint, uint, const Vec3&>())
 		.def(init<const Event::SceneColor&>())
 	;
 }

+ 11 - 0
src/Scripting/Util/HighRezTimer.bpi.cpp

@@ -0,0 +1,11 @@
+#include "ScriptingCommon.h"
+#include "HighRezTimer.h"
+
+
+WRAP(HighRezTimer)
+{
+	class_<HighRezTimer>("HighRezTimer")
+		.def("getCrntTime", &HighRezTimer::getCrntTime)
+		.staticmethod("getCrntTime")
+	;
+}

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor