Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8947 in orxonox.OLD for branches/mountain_lake/src/lib


Ignore:
Timestamp:
Jun 30, 2006, 11:03:53 AM (18 years ago)
Author:
hdavid
Message:

branches/mountain_lake: cloud effect is scriptable

Location:
branches/mountain_lake/src/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/mountain_lake/src/lib/graphics/effects/cloud_effect.cc

    r8946 r8947  
    2727#include "shell_command.h"
    2828#include "t_animation.h"
     29#include "script_class.h"
    2930
    3031#include "parser/tinyxml/tinyxml.h"
     
    4849SHELL_COMMAND(skyColor, CloudEffect, shellSkyColor);
    4950SHELL_COMMAND(cloudColor, CloudEffect, shellCloudColor);
     51
     52
     53CREATE_SCRIPTABLE_CLASS(CloudEffect, CL_CLOUD_EFFECT,
     54                        addMethod("shellSkyColor", ExecutorLua4<CloudEffect,float,float,float,float>(&CloudEffect::shellSkyColor))
     55                      ->addMethod("shellCloudColor", ExecutorLua4<CloudEffect,float,float,float,float>(&CloudEffect::shellCloudColor))
     56                       );
     57
    5058
    5159CREATE_FACTORY(CloudEffect, CL_CLOUD_EFFECT);
  • branches/mountain_lake/src/lib/graphics/effects/cloud_effect.h

    r8911 r8947  
    5050    virtual void deactivate();
    5151
    52     inline void activateCloud() {
     52    void activateCloud() {
    5353        this->activate();
    5454    }
    55 
    56     inline void deactivateCloud() {
     55    void deactivateCloud() {
    5756        this->deactivate();
    5857    }
    5958
    60     inline void setCloudOption(const std::string& option) {
     59    void setCloudOption(const std::string& option) {
    6160        if (option == "activate")
    6261            this->cloudActivate = true;
    6362    }
    6463
    65     inline void setAnimationSpeed(float speed) {
     64    void setAnimationSpeed(float speed) {
    6665        this->animationSpeed = speed;
    6766    }
    6867
    69     inline void setCloudScale(float scale) {
     68    void setCloudScale(float scale) {
    7069        this->scale = scale;
    7170    }
    7271
    73     inline void setCloudColor(float colorX, float colorY, float colorZ) {
     72    void setCloudColor(float colorX, float colorY, float colorZ) {
    7473        this->cloudColor = Vector(colorX, colorY, colorZ);
    7574    }
    7675
    77     inline void setSkyColor(float colorX, float colorY, float colorZ) {
     76    void setSkyColor(float colorX, float colorY, float colorZ) {
    7877        this->skyColor = Vector(colorX, colorY, colorZ);
    7978    }
    8079
    81     inline void setPlanetRadius(float planetRadius) {
     80    void setPlanetRadius(float planetRadius) {
    8281        this->planetRadius = planetRadius;
    8382    }
    8483
    85     inline void setAtmosphericRadius(float atmosphericRadius) {
     84    void setAtmosphericRadius(float atmosphericRadius) {
    8685        this->atmosphericRadius = atmosphericRadius;
    8786    }
    8887
    89     inline void setDivisions(int divs) {
     88    void setDivisions(int divs) {
    9089        this->divs = divs;
    9190    }
  • branches/mountain_lake/src/lib/util/executor/executor_lua.h

    r8711 r8947  
    4444  public:
    4545    /**
    46      * @brief Constructor of a ExecutorXML
    47      * @param function a Function to call
     46   * @brief Constructor of a ExecutorXML
     47   * @param function a Function to call
    4848     */
    4949    ExecutorLua0(void(T::*function)())
    50         : Executor()
     50  : Executor()
    5151    {
    5252      this->functionPointer = function;
     
    9191  public:
    9292    /**
    93      * @brief Constructor of a ExecutorXML
    94      * @param function a Function to call
     93   * @brief Constructor of a ExecutorXML
     94   * @param function a Function to call
    9595     */
    9696    ExecutorLua1(void(T::*function)(type0))
    97         : Executor(ExecutorParamType<type0>())
    98     {
    99       this->functionPointer = function;
    100       this->functorType = Executor_Objective | Executor_NoLoadString;
    101     }
    102 
    103     /**
    104        * @brief executes the Command on BaseObject
    105        * @param object the BaseObject to execute this Executor on
    106        * @param loadString ignored in this case
     97  : Executor(ExecutorParamType<type0>())
     98    {
     99      this->functionPointer = function;
     100      this->functorType = Executor_Objective | Executor_NoLoadString;
     101    }
     102
     103    /**
     104     * @brief executes the Command on BaseObject
     105     * @param object the BaseObject to execute this Executor on
     106     * @param loadString ignored in this case
    107107     */
    108108    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     
    120120
    121121    /**
    122        * @returns a _new_ Copy of this Executor
     122     * @returns a _new_ Copy of this Executor
    123123     */
    124124    virtual Executor* clone () const
     
    140140  public:
    141141    /**
    142      * @brief Constructor of a ExecutorXML
    143      * @param function a Function to call
     142   * @brief Constructor of a ExecutorXML
     143   * @param function a Function to call
    144144     */
    145145    ExecutorLua2(void(T::*function)(type0, type1))
    146         : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>())
     146  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>())
    147147    {
    148148      this->functionPointer = function;
     
    166166
    167167      (dynamic_cast<T*>(object)->*(functionPointer))(
    168         fromLua<type0>(state, 1),
    169         fromLua<type1>(state, 2) );
     168          fromLua<type0>(state, 1),
     169      fromLua<type1>(state, 2) );
    170170    }
    171171
     
    217217      (dynamic_cast<T*>(object)->*(functionPointer))(
    218218          fromLua<type0>(state, 1),
    219           fromLua<type1>(state, 2),
    220           fromLua<type2>(state, 3) );
     219      fromLua<type1>(state, 2),
     220      fromLua<type2>(state, 3) );
    221221    }
    222222
     
    233233
    234234
     235///////////
     236//// 4 ////
     237///////////
     238//! Executes a Function with a lua_State* parameter.
     239template<class T, typename type0, typename type1, typename type2, typename type3> class ExecutorLua4 : public Executor
     240{
     241  public:
     242    /**
     243   * @brief Constructor of a ExecutorXML
     244   * @param function a Function to call
     245     */
     246    ExecutorLua4(void(T::*function)(type0, type1, type2, type3))
     247  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>())
     248    {
     249      this->functionPointer = function;
     250      this->functorType = Executor_Objective | Executor_NoLoadString;
     251    }
     252
     253    /**
     254     * @brief executes the Command on BaseObject
     255     * @param object the BaseObject to execute this Executor on
     256     * @param loadString ignored in this case
     257     */
     258    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     259    {
     260      PRINTF(1)("no usefull executor\n");
     261    }
     262
     263    virtual void operator()(BaseObject* object, int& count, void* values) const
     264    {
     265      lua_State* state = (lua_State*)values;
     266      count = 0;
     267
     268      (dynamic_cast<T*>(object)->*(functionPointer))(
     269          fromLua<type0>(state, 1),
     270      fromLua<type1>(state, 2),
     271      fromLua<type2>(state, 3),
     272      fromLua<type3>(state, 4) );
     273    }
     274
     275    /**
     276     * @returns a _new_ Copy of this Executor
     277     */
     278    virtual Executor* clone () const
     279    {
     280      return new ExecutorLua4<T, type0, type1, type2, type3>(this->functionPointer);
     281    }
     282  private:
     283    void          (T::*functionPointer)(type0, type1, type2, type3);
     284};
    235285
    236286
     
    250300  public:
    251301    /**
    252      * @brief Constructor of a ExecutorXML
    253      * @param function a Function to call
     302   * @brief Constructor of a ExecutorXML
     303   * @param function a Function to call
    254304     */
    255305    ExecutorLua0ret(ret (T::*function)())
    256         : Executor()
     306  : Executor()
    257307    {
    258308      this->functionPointer = function;
     
    279329
    280330    /**
    281                        * @returns a _new_ Copy of this Executor
     331     * @returns a _new_ Copy of this Executor
    282332     */
    283333    virtual Executor* clone () const
     
    299349  public:
    300350    /**
    301      * @brief Constructor of a ExecutorXML
    302      * @param function a Function to call
     351   * @brief Constructor of a ExecutorXML
     352   * @param function a Function to call
    303353     */
    304354    ExecutorLua1ret(ret (T::*function)(type0))
    305         : Executor(ExecutorParamType<type0>())
     355  : Executor(ExecutorParamType<type0>())
    306356    {
    307357      this->functionPointer = function;
     
    325375
    326376      toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
    327                    fromLua<type0>(state, 1)));
     377          fromLua<type0>(state, 1)));
    328378    }
    329379
     
    347397  public:
    348398    /**
    349      * @brief Constructor of a ExecutorXML
    350      * @param function a Function to call
     399   * @brief Constructor of a ExecutorXML
     400   * @param function a Function to call
    351401     */
    352402    ExecutorLua2ret(ret (T::*function)(type0, type1))
    353         : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>())
     403  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>())
    354404    {
    355405      this->functionPointer = function;
     
    373423
    374424      toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     425          fromLua<type0>(state, 1),
     426          fromLua<type1>(state, 2) ));
     427    }
     428
     429    /**
     430     * @returns a _new_ Copy of this Executor
     431     */
     432    virtual Executor* clone () const
     433    {
     434      return new ExecutorLua2ret<T, ret, type0, type1>(this->functionPointer);
     435    }
     436  private:
     437    ret           (T::*functionPointer)(type0, type1);
     438};
     439
     440
     441///////////
     442//// 3 ////
     443///////////
     444//! Executes a Function with a lua_State* parameter.
     445template<class T, typename ret, typename type0, typename type1, typename type2> class ExecutorLua3ret : public Executor
     446{
     447  public:
     448    /**
     449   * @brief Constructor of a ExecutorXML
     450   * @param function a Function to call
     451     */
     452    ExecutorLua3ret(ret (T::*function)(type0, type1, type2))
     453  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>())
     454    {
     455      this->functionPointer = function;
     456      this->functorType = Executor_Objective | Executor_NoLoadString;
     457    }
     458
     459    /**
     460     * @brief executes the Command on BaseObject
     461     * @param object the BaseObject to execute this Executor on
     462     * @param loadString ignored in this case
     463     */
     464    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     465    {
     466      PRINTF(1)("no usefull executor\n");
     467    }
     468
     469    virtual void operator()(BaseObject* object, int& count, void* values) const
     470    {
     471      lua_State* state = (lua_State*)values;
     472      count = 1;
     473
     474      toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     475          fromLua<type0>(state, 1),
     476          fromLua<type1>(state, 2),
     477          fromLua<type2>(state, 3) ));
     478    }
     479
     480    /**
     481     * @returns a _new_ Copy of this Executor
     482     */
     483    virtual Executor* clone () const
     484    {
     485      return new ExecutorLua3ret<T, ret, type0, type1, type2>(this->functionPointer);
     486    }
     487  private:
     488    ret          (T::*functionPointer)(type0, type1, type2);
     489};
     490
     491
     492///////////
     493//// 4 ////
     494///////////
     495//! Executes a Function with a lua_State* parameter.
     496template<class T, typename ret, typename type0, typename type1, typename type2, typename type3> class ExecutorLua4ret : public Executor
     497{
     498  public:
     499    /**
     500   * @brief Constructor of a ExecutorXML
     501   * @param function a Function to call
     502     */
     503    ExecutorLua4ret(ret (T::*function)(type0, type1, type2, type3))
     504  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>())
     505    {
     506      this->functionPointer = function;
     507      this->functorType = Executor_Objective | Executor_NoLoadString;
     508    }
     509
     510    /**
     511     * @brief executes the Command on BaseObject
     512     * @param object the BaseObject to execute this Executor on
     513     * @param loadString ignored in this case
     514     */
     515    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     516    {
     517      PRINTF(1)("no usefull executor\n");
     518    }
     519
     520    virtual void operator()(BaseObject* object, int& count, void* values) const
     521    {
     522      lua_State* state = (lua_State*)values;
     523      count = 1;
     524
     525      toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     526          fromLua<type0>(state, 1),
     527          fromLua<type1>(state, 2),
     528          fromLua<type2>(state, 3),
     529          fromLua<type3>(state, 4) ));
     530    }
     531
     532    /**
     533     * @returns a _new_ Copy of this Executor
     534     */
     535    virtual Executor* clone () const
     536    {
     537      return new ExecutorLua4ret<T, ret, type0, type1, type2, type3>(this->functionPointer);
     538    }
     539  private:
     540    ret          (T::*functionPointer)(type0, type1, type2, type3);
     541};
     542
     543///////////
     544//// 5 ////
     545///////////
     546//! Executes a Function with a lua_State* parameter.
     547template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4> class ExecutorLua5ret : public Executor
     548{
     549  public:
     550    /**
     551   * @brief Constructor of a ExecutorXML
     552   * @param function a Function to call
     553     */
     554    ExecutorLua5ret(ret (T::*function)(type0, type1, type2, type3, type4))
     555  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>())
     556    {
     557      this->functionPointer = function;
     558      this->functorType = Executor_Objective | Executor_NoLoadString;
     559    }
     560
     561    /**
     562     * @brief executes the Command on BaseObject
     563     * @param object the BaseObject to execute this Executor on
     564     * @param loadString ignored in this case
     565     */
     566    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     567    {
     568      PRINTF(1)("no usefull executor\n");
     569    }
     570
     571    virtual void operator()(BaseObject* object, int& count, void* values) const
     572    {
     573      lua_State* state = (lua_State*)values;
     574      count = 1;
     575
     576      toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     577          fromLua<type0>(state, 1),
     578          fromLua<type1>(state, 2),
     579          fromLua<type2>(state, 3),
     580          fromLua<type3>(state, 4),
     581          fromLua<type4>(state, 5) ));
     582    }
     583
     584    /**
     585     * @returns a _new_ Copy of this Executor
     586     */
     587    virtual Executor* clone () const
     588    {
     589      return new ExecutorLua5ret<T, ret, type0, type1, type2, type3, type4>(this->functionPointer);
     590    }
     591  private:
     592    ret          (T::*functionPointer)(type0, type1, type2, type3, type4);
     593};
     594
     595///////////
     596//// 6 ////
     597///////////
     598//! Executes a Function with a lua_State* parameter.
     599template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4, typename type5> class ExecutorLua6ret : public Executor
     600{
     601  public:
     602    /**
     603   * @brief Constructor of a ExecutorXML
     604   * @param function a Function to call
     605     */
     606    ExecutorLua6ret(ret (T::*function)(type0, type1, type2, type3, type4, type5))
     607  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(),
     608             ExecutorParamType<type2>(), ExecutorParamType<type3>(),
     609             ExecutorParamType<type4>(), ExecutorParamType<type5>())
     610             {
     611               this->functionPointer = function;
     612               this->functorType = Executor_Objective | Executor_NoLoadString;
     613             }
     614
     615    /**
     616              * @brief executes the Command on BaseObject
     617              * @param object the BaseObject to execute this Executor on
     618              * @param loadString ignored in this case
     619     */
     620             virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     621             {
     622               PRINTF(1)("no usefull executor\n");
     623             }
     624
     625             virtual void operator()(BaseObject* object, int& count, void* values) const
     626             {
     627               lua_State* state = (lua_State*)values;
     628               count = 1;
     629
     630               toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
    375631                   fromLua<type0>(state, 1),
    376                    fromLua<type1>(state, 2) ));
    377     }
    378 
    379     /**
    380      * @returns a _new_ Copy of this Executor
    381      */
    382     virtual Executor* clone () const
    383     {
    384       return new ExecutorLua2ret<T, ret, type0, type1>(this->functionPointer);
    385     }
    386   private:
    387     ret           (T::*functionPointer)(type0, type1);
    388 };
     632                   fromLua<type1>(state, 2),
     633                   fromLua<type2>(state, 3),
     634                   fromLua<type3>(state, 4),
     635                   fromLua<type4>(state, 5),
     636                   fromLua<type5>(state, 6) ));
     637             }
     638
     639    /**
     640              * @returns a _new_ Copy of this Executor
     641     */
     642             virtual Executor* clone () const
     643             {
     644               return new ExecutorLua6ret<T, ret, type0, type1, type2, type3, type4, type5>(this->functionPointer);
     645             }
     646  private:
     647    ret           (T::*functionPointer)(type0, type1, type2, type3, type4, type5);
     648};
     649
     650///////////
     651//// 7 ////
     652///////////
     653//! Executes a Function with a lua_State* parameter.
     654template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4, typename type5, typename type6> class ExecutorLua7ret : public Executor
     655{
     656  public:
     657    /**
     658   * @brief Constructor of a ExecutorXML
     659   * @param function a Function to call
     660     */
     661    ExecutorLua7ret(ret (T::*function)(type0, type1, type2, type3, type4, type5, type6))
     662  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(),
     663             ExecutorParamType<type2>(), ExecutorParamType<type3>(),
     664             ExecutorParamType<type4>(), ExecutorParamType<type5>(),
     665             ExecutorParamType<type6>())
     666             {
     667               this->functionPointer = function;
     668               this->functorType = Executor_Objective | Executor_NoLoadString;
     669             }
     670
     671    /**
     672              * @brief executes the Command on BaseObject
     673              * @param object the BaseObject to execute this Executor on
     674              * @param loadString ignored in this case
     675     */
     676             virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     677             {
     678               PRINTF(1)("no usefull executor\n");
     679             }
     680
     681             virtual void operator()(BaseObject* object, int& count, void* values) const
     682             {
     683               lua_State* state = (lua_State*)values;
     684               count = 1;
     685
     686               toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     687                   fromLua<type0>(state, 1),
     688                   fromLua<type1>(state, 2),
     689                   fromLua<type2>(state, 3),
     690                   fromLua<type3>(state, 4),
     691                   fromLua<type4>(state, 5),
     692                   fromLua<type5>(state, 6),
     693                   fromLua<type6>(state, 7) ));
     694             }
     695
     696    /**
     697              * @returns a _new_ Copy of this Executor
     698     */
     699             virtual Executor* clone () const
     700             {
     701               return new ExecutorLua7ret<T, ret, type0, type1, type2, type3, type4, type5, type6>(this->functionPointer);
     702             }
     703  private:
     704    ret           (T::*functionPointer)(type0, type1, type2, type3, type4, type5, type6);
     705};
     706
    389707
    390708#endif /* _EXECUTOR_LUA_H */
Note: See TracChangeset for help on using the changeset viewer.