diff --git a/SConstruct b/SConstruct index 61d4a14..0caf74c 100644 --- a/SConstruct +++ b/SConstruct @@ -31,6 +31,8 @@ opts.AddOptions( ) env = Environment(tools = ["zip", "config_checks"], toolpath = ["scons"], options = opts) +env.Decider("MD5-timestamp") +SetOption('implicit_cache', 1) env["Build"] = env["Build"].lower() if env["PLATFORM"] == "win32": env.Tool("mingw") diff --git a/aclocal.m4 b/aclocal.m4 index 791d0ea..3fcd24b 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -84,16 +84,14 @@ fi]) # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], -[if test -n "$PKG_CONFIG"; then - if test -n "$$1"; then - pkg_cv_[]$1="$$1" - else - PKG_CHECK_EXISTS([$3], - [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], - [pkg_failed=yes]) - fi -else - pkg_failed=untried +[if test -n "$$1"; then + pkg_cv_[]$1="$$1" + elif test -n "$PKG_CONFIG"; then + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], + [pkg_failed=yes]) + else + pkg_failed=untried fi[]dnl ])# _PKG_CONFIG @@ -137,9 +135,9 @@ See the pkg-config man page for more details.]) if test $pkg_failed = yes; then _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then - $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1` else - $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD diff --git a/configure b/configure index bb06c47..73ecbc0 100755 --- a/configure +++ b/configure @@ -7811,11 +7811,10 @@ pkg_failed=no { echo "$as_me:$LINENO: checking for PANGO" >&5 echo $ECHO_N "checking for PANGO... $ECHO_C" >&6; } -if test -n "$PKG_CONFIG"; then - if test -n "$PANGO_CFLAGS"; then - pkg_cv_PANGO_CFLAGS="$PANGO_CFLAGS" - else - if test -n "$PKG_CONFIG" && \ +if test -n "$PANGO_CFLAGS"; then + pkg_cv_PANGO_CFLAGS="$PANGO_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"pangoft2\"") >&5 ($PKG_CONFIG --exists --print-errors "pangoft2") 2>&5 ac_status=$? @@ -7825,15 +7824,13 @@ if test -n "$PKG_CONFIG"; then else pkg_failed=yes fi - fi -else - pkg_failed=untried + else + pkg_failed=untried fi -if test -n "$PKG_CONFIG"; then - if test -n "$PANGO_LIBS"; then - pkg_cv_PANGO_LIBS="$PANGO_LIBS" - else - if test -n "$PKG_CONFIG" && \ +if test -n "$PANGO_LIBS"; then + pkg_cv_PANGO_LIBS="$PANGO_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"pangoft2\"") >&5 ($PKG_CONFIG --exists --print-errors "pangoft2") 2>&5 ac_status=$? @@ -7843,9 +7840,8 @@ if test -n "$PKG_CONFIG"; then else pkg_failed=yes fi - fi -else - pkg_failed=untried + else + pkg_failed=untried fi @@ -7858,9 +7854,9 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - PANGO_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "pangoft2"` + PANGO_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "pangoft2" 2>&1` else - PANGO_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "pangoft2"` + PANGO_PKG_ERRORS=`$PKG_CONFIG --print-errors "pangoft2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$PANGO_PKG_ERRORS" >&5 diff --git a/data/test.cfg b/data/test.cfg index 424ee80..9da4c65 100644 --- a/data/test.cfg +++ b/data/test.cfg @@ -54,7 +54,7 @@ sun_light="color_transition(hour*60+minute,0,rgb(0,0,0), equipment="short_sword,shield_slot,armor_slot" improvement_points="40" level="1" - model="chr-heroine2.3d" + model="chr-heroine.3d" portrait="portraits/callieh.png" [attributes] agility="8" diff --git a/src/Makefile.am b/src/Makefile.am index 73b0cdc..fd39fb0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,6 +21,7 @@ endif SUBDIRS=. editor libsilvertree_a_SOURCES=\ +animation.hpp \ base_terrain_fwd.hpp \ base_terrain.hpp \ battle_character_fwd.hpp \ @@ -154,6 +155,7 @@ world.hpp \ tinyxml/tinyxml.h \ zoom_map_generator.hpp \ \ +animation.cpp \ base_terrain.cpp \ battle_character.cpp \ battle_character_npc.cpp \ diff --git a/src/Makefile.in b/src/Makefile.in index d00118a..63d51b7 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -65,7 +65,7 @@ AR = ar ARFLAGS = cru libsilvertree_a_AR = $(AR) $(ARFLAGS) libsilvertree_a_LIBADD = -am__libsilvertree_a_SOURCES_DIST = base_terrain_fwd.hpp \ +am__libsilvertree_a_SOURCES_DIST = animation.hpp base_terrain_fwd.hpp \ base_terrain.hpp battle_character_fwd.hpp battle_character.hpp \ battle_character_npc.hpp battle_character_pc.hpp battle.hpp \ battle_map_generator.hpp battle_menu_fwd.hpp battle_menu.hpp \ @@ -104,8 +104,8 @@ am__libsilvertree_a_SOURCES_DIST = base_terrain_fwd.hpp \ util.hpp variant.hpp widget.hpp wml_command_fwd.hpp \ wml_command.hpp wml_node_fwd.hpp wml_node.hpp wml_parser.hpp \ wml_utils.hpp wml_writer.hpp world_fwd.hpp world.hpp \ - tinyxml/tinyxml.h zoom_map_generator.hpp base_terrain.cpp \ - battle_character.cpp battle_character_npc.cpp \ + tinyxml/tinyxml.h zoom_map_generator.hpp animation.cpp \ + base_terrain.cpp battle_character.cpp battle_character_npc.cpp \ battle_character_pc.cpp battle.cpp battle_map_generator.cpp \ battle_menu.cpp battle_missile.cpp battle_modification.cpp \ battle_move.cpp button.cpp camera_controller.cpp camera.cpp \ @@ -136,7 +136,7 @@ am__libsilvertree_a_SOURCES_DIST = base_terrain_fwd.hpp \ tinyxml/tinyxmlerror.cpp tinyxml/tinyxmlparser.cpp \ zoom_map_generator.cpp pango_text.hpp pango_text.cpp @HAVE_PANGO_TRUE@am__objects_1 = pango_text.$(OBJEXT) -am_libsilvertree_a_OBJECTS = titlescreen.$(OBJEXT) \ +am_libsilvertree_a_OBJECTS = titlescreen.$(OBJEXT) animation.$(OBJEXT) \ base_terrain.$(OBJEXT) battle_character.$(OBJEXT) \ battle_character_npc.$(OBJEXT) battle_character_pc.$(OBJEXT) \ battle.$(OBJEXT) battle_map_generator.$(OBJEXT) \ @@ -355,8 +355,8 @@ silvertreerpg_LDADD = libsilvertree.a AM_CPPFLAGS = -DDATADIR=\"$(pkgdatadir)\" AM_CXXFLAGS = -Wall -Werror -Wno-sign-compare -Wno-switch -Wno-switch-enum SUBDIRS = . editor -libsilvertree_a_SOURCES = base_terrain_fwd.hpp base_terrain.hpp \ - battle_character_fwd.hpp battle_character.hpp \ +libsilvertree_a_SOURCES = animation.hpp base_terrain_fwd.hpp \ + base_terrain.hpp battle_character_fwd.hpp battle_character.hpp \ battle_character_npc.hpp battle_character_pc.hpp battle.hpp \ battle_map_generator.hpp battle_menu_fwd.hpp battle_menu.hpp \ battle_missile.hpp battle_modification.hpp battle_move_fwd.hpp \ @@ -394,8 +394,8 @@ libsilvertree_a_SOURCES = base_terrain_fwd.hpp base_terrain.hpp \ util.hpp variant.hpp widget.hpp wml_command_fwd.hpp \ wml_command.hpp wml_node_fwd.hpp wml_node.hpp wml_parser.hpp \ wml_utils.hpp wml_writer.hpp world_fwd.hpp world.hpp \ - tinyxml/tinyxml.h zoom_map_generator.hpp base_terrain.cpp \ - battle_character.cpp battle_character_npc.cpp \ + tinyxml/tinyxml.h zoom_map_generator.hpp animation.cpp \ + base_terrain.cpp battle_character.cpp battle_character_npc.cpp \ battle_character_pc.cpp battle.cpp battle_map_generator.cpp \ battle_menu.cpp battle_missile.cpp battle_modification.cpp \ battle_move.cpp button.cpp camera_controller.cpp camera.cpp \ @@ -498,6 +498,7 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/animation.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base_terrain.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/battle.Po@am__quote@ diff --git a/src/animation.cpp b/src/animation.cpp new file mode 100644 index 0000000..fed4d1b --- /dev/null +++ b/src/animation.cpp @@ -0,0 +1,24 @@ +/*************************************************************************** + * Copyright (C) 2008 by Sergey Popov * + * * + * This file is part of Silver Tree. * + * * + * Silver Tree is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * Silver Tree is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see * + ***************************************************************************/ + +#include "animation.hpp" + +namespace graphics { +boost::scoped_ptr time_source::time_source_; +} diff --git a/src/animation.hpp b/src/animation.hpp new file mode 100644 index 0000000..daf38e1 --- /dev/null +++ b/src/animation.hpp @@ -0,0 +1,101 @@ +/*************************************************************************** + * Copyright (C) 2008 by Sergey Popov * + * * + * This file is part of Silver Tree. * + * * + * Silver Tree is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * Silver Tree is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see * + ***************************************************************************/ + +#ifndef ANIMATION_HPP_INCLUDED +#define ANIMATION_HPP_INCLUDED + +#include +#include + +#include + +namespace graphics { + +class time_source : boost::noncopyable +{ + Uint32 ticks_; + + time_source() : ticks_(SDL_GetTicks()) {} + + static boost::scoped_ptr time_source_; + + public: + void advance_time() { ticks_ = SDL_GetTicks(); } + Uint32 time() const { return ticks_; } + + static time_source& instance() + { + if(!time_source_) + time_source_.reset(new time_source); + return *time_source_; + } +}; + +template class animation +{ + Uint32 start_; + float duration_; + + float time_offset() const { return static_cast(time_source::instance().time() - start_)/1000.0; } + public: + animation() : start_(time_source::instance().time()), duration_(0) {} + virtual ~animation() {} + virtual ValueType operator()(float time) const = 0; + + ValueType play() const { return (*this)(time_offset()); } + void set_duration(float duration) { duration_ = duration; } + bool finished() const { return time_offset() > duration_; } +}; + +template class function_animation : public animation +{ + Function function_; + public: + function_animation() : function_() {} + function_animation(Function function) : function_(function) {} + ValueType operator()(float time) const { return function_(time); } +}; + +template class linear_function +{ + ValueType a_, b_; + + public: + linear_function(ValueType a, ValueType b) : a_(a), b_(b) {} + ValueType operator()(float x) const { return a_ * x + b_; } +}; + +template function_animation make_animation(Function function) +{ + return function_animation(function); +} + +template class quadratic_function +{ + ValueType a_, b_, c_; + + public: + quadratic_function() : a_(), b_(), c_() {} + quadratic_function(ValueType a, ValueType b, ValueType c) : a_(a), b_(b), c_(c) {} + ValueType operator()(float x) const { return a_ * (x * x) + b_ * x + c_; } +}; + +} + +#endif diff --git a/src/particle.cpp b/src/particle.cpp index 32c98ff..dfafc64 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -6,18 +6,17 @@ namespace graphics { void particle::draw() { - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color_); - glVertex3f(pos_[0]-size_, pos_[1], pos_[2]); - glVertex3f(pos_[0]+size_, pos_[1], pos_[2]); - glVertex3f(pos_[0], pos_[1]+size_, pos_[2]); - for(int n = 0; n != 3; ++n) { - pos_[n] += velocity_[n]; - velocity_[n] += acceleration_[n]; - } - - for(int n = 0; n != 4; ++n) { - color_[n] += color_diff_[n]; - } + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color_.array()); + Eigen::Vector3f pos = position_anim_.play(); + pos.x() -= size_; + glVertex3fv(pos.array()); + pos.x() += 2 * size_; + glVertex3fv(pos.array()); + pos.x() -= size_; + pos.y() += size_; + glVertex3fv(pos.array()); + + color_ += color_diff_; ttl_--; } diff --git a/src/particle.hpp b/src/particle.hpp index 3a143f2..98fc11d 100644 --- a/src/particle.hpp +++ b/src/particle.hpp @@ -3,20 +3,22 @@ #include +#include "eigen/vector.h" + +#include "animation.hpp" + namespace graphics { class particle { public: friend class particle_emitter; void draw(); - bool dead() const { return ttl_ <= 0; } + bool dead() const { return position_anim_.finished(); } private: GLfloat size_; - GLfloat pos_[3]; - GLfloat velocity_[3]; - GLfloat acceleration_[3]; - GLfloat color_[4]; - GLfloat color_diff_[4]; + function_animation > position_anim_; + Eigen::Vector4f color_; + Eigen::Vector4f color_diff_; int ttl_; }; diff --git a/src/particle_emitter.cpp b/src/particle_emitter.cpp index 448db46..adb9650 100644 --- a/src/particle_emitter.cpp +++ b/src/particle_emitter.cpp @@ -92,23 +92,28 @@ void particle_emitter::initialize_particle(particle& p) const const GLfloat g = (rand()%1000)/1000.0; const GLfloat h = 1.0 - g; const GLfloat speed = speed_->execute().as_int()/1000.0; + Eigen::Vector3f particle_pos; + Eigen::Vector3f particle_velocity; + Eigen::Vector3f particle_acceleration; for(int n = 0; n != 3; ++n) { - p.pos_[n] = pos1_[n]*g + pos2_[n]*h; + particle_pos[n] = pos1_[n]*g + pos2_[n]*h; if(pos_diffs_[n]) { - p.pos_[n] += pos_diffs_[n]->execute().as_int()/1000.0; + particle_pos[n] += pos_diffs_[n]->execute().as_int()/1000.0; } - p.velocity_[n] = (dir1_[n]*g + dir2_[n]*h)*speed; + particle_velocity[n] = (dir1_[n]*g + dir2_[n]*h)*speed; if(velocity_diffs_[n]) { - p.velocity_[n] += velocity_diffs_[n]->execute().as_int()/1000.0; + particle_velocity[n] += velocity_diffs_[n]->execute().as_int()/45.; } if(acceleration_[n]) { - p.acceleration_[n] = acceleration_[n]->execute().as_int()/10000.0; + particle_acceleration[n] = acceleration_[n]->execute().as_int()/40.; } else { - p.acceleration_[n] = 0.0; + particle_acceleration[n] = 0.0; } } + p.position_anim_ = function_animation >(quadratic_function(particle_acceleration, particle_velocity, particle_pos)); + p.position_anim_.set_duration((float)p.ttl_/30.); for(int n = 0; n != 4; ++n) { if(color_[n]) { diff --git a/src/world.cpp b/src/world.cpp index 5115a13..04d8f09 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -34,6 +34,7 @@ #include "wml_parser.hpp" #include "wml_utils.hpp" #include "world.hpp" +#include "animation.cpp" #include #include @@ -431,6 +432,8 @@ bool world::draw() const } #endif + graphics::time_source::instance().advance_time(); + return drew; }