Daniele Bartolini 12 лет назад
Родитель
Сommit
a666434f21
3 измененных файлов с 0 добавлено и 86 удалено
  1. 0 29
      engine/lua/LuaSprite.cpp
  2. 0 41
      engine/renderers/Sprite.cpp
  3. 0 16
      engine/renderers/Sprite.h

+ 0 - 29
engine/lua/LuaSprite.cpp

@@ -110,32 +110,6 @@ static int sprite_set_local_pose(lua_State* L)
 	return 0;
 }
 
-//-----------------------------------------------------------------------------
-static int sprite_play_animation(lua_State* L)
-{
-	LuaStack stack(L);
-
-	Sprite* sprite = stack.get_sprite(1);
-	uint32_t start = stack.get_int(2);
-	uint32_t end = stack.get_int(3);
-	float time = stack.get_float(4);
-	bool loop = stack.get_bool(5);
-
-	sprite->play_animation(start, end, time, loop);
-	return 0;
-}
-
-//-----------------------------------------------------------------------------
-static int sprite_stop_animation(lua_State* L)
-{
-	LuaStack stack(L);
-
-	Sprite* sprite = stack.get_sprite(1);
-
-	sprite->stop_animation();
-	return 0;
-}
-
 //-----------------------------------------------------------------------------
 void load_sprite(LuaEnvironment& env)
 {
@@ -145,9 +119,6 @@ void load_sprite(LuaEnvironment& env)
 	env.load_module_function("Sprite", "set_local_position", 	sprite_set_local_position);
 	env.load_module_function("Sprite", "set_local_rotation", 	sprite_set_local_rotation);
 	env.load_module_function("Sprite", "set_local_pose", 		sprite_set_local_pose);
-
-	env.load_module_function("Sprite", "play_animation", 		sprite_play_animation);
-	env.load_module_function("Sprite", "stop_animation", 		sprite_stop_animation);	
 }
 
 } // namespace crown

+ 0 - 41
engine/renderers/Sprite.cpp

@@ -44,12 +44,6 @@ Sprite::Sprite(RenderWorld& render_world, SceneGraph& sg, int32_t node, const Sp
 	, m_scene_graph(sg)
 	, m_node(node)
 	, m_resource(sr)
-	, m_start_frame(0)
-	, m_cur_frame(0)
-	, m_tot_time(1.0)
-	, m_anim_time(0.0)
-	, m_loop(false)
-	, m_is_playing(false)
 {
 	m_vb = sr->vertex_buffer();
 	m_ib = sr->index_buffer();
@@ -114,29 +108,6 @@ void Sprite::set_local_pose(Unit* unit, const Matrix4x4& pose)
 	unit->set_local_pose(m_node, pose);
 }
 
-//-----------------------------------------------------------------------------
-void Sprite::play_animation(uint32_t start, uint32_t end, float time, bool loop)
-{
-	m_start_frame = start;
-	m_end_frame = end;
-	m_tot_time = time;
-	m_anim_time = 0.0;
-	m_loop = loop;
-}
-
-//-----------------------------------------------------------------------------
-void Sprite::stop_animation()
-{
-	m_cur_frame = 0;
-}
-
-//-----------------------------------------------------------------------------
-void Sprite::set_frame(uint32_t i)
-{
-	CE_ASSERT(i < m_resource->num_frames(), "Frame out of bounds"); 
-	m_cur_frame = i;
-}
-
 //-----------------------------------------------------------------------------
 void Sprite::set_material(MaterialId mat)
 {
@@ -146,11 +117,6 @@ void Sprite::set_material(MaterialId mat)
 //-----------------------------------------------------------------------------
 void Sprite::render(Renderer& r, UniformId uniform, float dt)
 {
-	// Compute current frame
-	uint32_t cur_frame = ((m_end_frame - m_start_frame) / m_tot_time) * m_anim_time;
-	m_cur_frame = cur_frame > m_end_frame ? m_end_frame : cur_frame;
-	m_anim_time += dt;
-
 	Material* material = m_render_world.lookup_material(m_material);
 	material->bind(r, uniform);
 
@@ -161,16 +127,9 @@ void Sprite::render(Renderer& r, UniformId uniform, float dt)
 		| STATE_BLEND_EQUATION_ADD 
 		| STATE_BLEND_FUNC(STATE_BLEND_FUNC_SRC_ALPHA, STATE_BLEND_FUNC_ONE_MINUS_SRC_ALPHA));
 	r.set_vertex_buffer(m_vb);
-	const uint32_t start_index = m_cur_frame * 6;
 	r.set_index_buffer(m_ib, 0, 6);
 	r.set_pose(world_pose());
 	r.commit(0);
-
-	if (m_cur_frame == m_end_frame && m_loop)
-	{
-		m_anim_time = 0.0;
-		m_cur_frame = m_start_frame;
-	}
 }
 
 } // namespace crown

+ 0 - 16
engine/renderers/Sprite.h

@@ -59,14 +59,6 @@ struct Sprite
 	void					set_local_rotation(Unit* unit, const Quaternion& rot);
 	void					set_local_pose(Unit* unit, const Matrix4x4& pose);
 
-	/// Plays the animation from frame @a start to frame @a.
-	/// @a time is for how long the animation has to be played.
-	void					play_animation(uint32_t start, uint32_t end, float time, bool loop);
-
-	/// Stops the current animation.
-	void					stop_animation();
-
-	void					set_frame(uint32_t i);
 	void					set_material(MaterialId mat);
 	void					render(Renderer& r, UniformId uniform, float dt);
 
@@ -77,14 +69,6 @@ public:
 	int32_t					m_node;
 	const SpriteResource*	m_resource;
 
-	uint32_t				m_start_frame;
-	uint32_t				m_cur_frame;
-	uint32_t				m_end_frame;
-	float 					m_tot_time;
-	float					m_anim_time;
-	bool					m_loop;
-	bool					m_is_playing;
-
 	MaterialId				m_material;
 	VertexBufferId			m_vb;
 	IndexBufferId			m_ib;