Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1154


Ignore:
Timestamp:
Apr 24, 2008, 11:04:01 AM (16 years ago)
Author:
rgrieder
Message:
  • updated input branch to trunk state. Only Input system files should differ now.
  • this revision doesn't even compile, its just an 'svn save'
Location:
code/branches/input
Files:
3 deleted
13 edited
2 copied

Legend:

Unmodified
Added
Removed
  • code/branches/input/CMakeLists.txt

    r1085 r1154  
    3232
    3333#set binary output directories
    34 SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
    35 SET(LIBRARY_OUTPUT_PATH    ${PROJECT_BINARY_DIR}/bin/lib)
     34SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
     35SET(LIBRARY_OUTPUT_PATH    ${PROJECT_SOURCE_DIR}/bin/lib)
    3636
    3737# global compiler/linker flags. force -O2!
     
    4343SET(CMAKE_MODULE_LINKER_FLAGS " --no-undefined")
    4444
    45 #Create verbose makefile output when compiling
    46 SET(CMAKE_VERBOSE_MAKEFILE TRUE)
     45#use 'cmake -D make_verb:1 path' to get verbose make output when compiling
     46IF (MAKE_VERB)
     47 SET(CMAKE_VERBOSE_MAKEFILE TRUE)
     48ENDIF (MAKE_VERB)
    4749
    4850
     
    7981  ${ENet_INCLUDE_DIR}
    8082  ${Boost_INCLUDE_DIRS}
    81   ${OPENAL_INCLUDE_DIR} ${ALUT_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR} ${OGG_INCLUDE_DIR}
     83  ${OPENAL_INCLUDE_DIR}
     84  ${ALUT_INCLUDE_DIR}
     85  ${VORBIS_INCLUDE_DIR}
     86  ${OGG_INCLUDE_DIR}
    8287  ${Lua_INCLUDE_DIR}
    8388)
    84 
    85 
    86 ################ Source files ###################
    87 
    88 #At first, build lua
    89 MESSAGE(STATUS "\n******************* Building tolua... ******************\n\n")
    90 EXECUTE_PROCESS(COMMAND ./tolua-build)
    91 MESSAGE(STATUS "\n\n******************* Building tolua done ****************\n")
    92 
    93 #generate lua bind source files
    94 EXECUTE_PROCESS(COMMAND bin/./tolua-exec-script)
    9589
    9690#add main source dir
  • code/branches/input/bin/levels/sample.oxw

    r1089 r1154  
    3838
    3939
    40 <!--?lua
     40<?lua
    4141for i = 1, 226, 1
    4242do ?>
    43   <Model position="<?lua print(math.random(-19597, 18732))?>, <?lua print(math.random(-19597, 18732)) ?>, <?lua print(math.random(-19597, 18732)) ?>" scale="<?lua print(math.random( 20, 119)) ?>" mesh="ast<?lua print(i%6 + 1) ?>.mesh" rotationAxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationRate="<?lua print(math.random(16, 44)) ?>" />
     43  <Model position="<?lua print(math.random(-19597, 18732))?>, <?lua print(math.random(-19597, 18732)) ?>, <?lua print(math.random(-19597, 18732)) ?>" scale="<?lua print(math.random( 20, 119)) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" rotationAxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationRate="<?lua print(math.random(16, 44)) ?>" />
    4444<?lua
    4545end
    46 ?-->
     46?>
  • code/branches/input/cmake/FindLua.cmake

    r1076 r1154  
    1 # Find Lua includes and library
     1#  Find Lua header and library files
    22#
    3 # This module defines
    4 #  Lua_INCLUDE_DIR
    5 #  Lua_LIBRARIES, the libraries to link against to use Lua.
    6 #  Lua_LIB_DIR, the location of the libraries
    7 #  Lua_FOUND, If false, do not try to use Lua
     3#  When called, this script tries to define:
     4#  Lua_INCLUDE_DIR    Header files directory
     5#  Lua_LIBRARIES      library files (or file when using lua 5.1)
     6#  Lua_FOUND          defined (true) if lua was found
     7#  Lua_VERSION        either 5.1 or 5.0 or undefined
    88#
    9 # Copyright © 2007, Matt Williams
    10 #
    11 # Redistribution and use is allowed according to the terms of the BSD license.
     9#  authors: Benjamin Knecht, Reto Grieder
    1210
    13 MESSAGE(STATUS "lua libs in cache: ${Lua_LIBRARIES}")
    1411IF (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
    15     SET(Lua_FIND_QUIETLY TRUE) # Already in cache, be silent
     12
     13  # Already in cache, be silent
     14  SET(Lua_FOUND TRUE)
     15  SET(Lua_FIND_QUIETLY TRUE)
     16  MESSAGE(STATUS "Lua was found.")
     17
     18ELSE (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
     19
     20  FIND_PATH(Lua_INCLUDE_DIR_51 lua.h
     21    /usr/include/lua5.1
     22    /usr/local/include/lua5.1
     23    ../libs/lua-5.1.3/src)
     24
     25  FIND_PATH(Lua_INCLUDE_DIR_50 lua.h
     26    /usr/include/lua50
     27    /usr/local/include/lua50
     28    /usr/pack/lua-5.0.3-sd/include)
     29
     30  FIND_LIBRARY(Lua_LIBRARY_51 NAMES lua5.1 lua PATHS
     31    /usr/lib
     32    /usr/local/lib
     33    ../libs/lua-5.1.3/lib)
     34
     35  FIND_LIBRARY(Lua_LIBRARY_1_50 NAMES lua50 lua PATHS
     36        /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib #tardis
     37    /usr/lib
     38    /usr/local/lib)
     39
     40  FIND_LIBRARY(Lua_LIBRARY_2_50 NAMES lualib50 lualib PATHS
     41        /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib #tardis
     42    /usr/lib
     43    /usr/local/lib)
     44
     45
     46  IF (Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
     47
     48    # Found newer lua 5.1 libs
     49    SET(Lua_FOUND TRUE)
     50    SET(Lua_VERSION 5.1 CACHE STRING "")
     51    SET(Lua_INCLUDE_DIR ${Lua_INCLUDE_DIR_51} CACHE PATH "")
     52    SET(Lua_LIBRARIES ${Lua_LIBRARY_51} CACHE FILEPATH "")
     53
     54  ELSEIF(Lua_INCLUDE_DIR_50 AND Lua_LIBRARY_1_50 AND Lua_LIBRARY_2_50)
     55
     56    # Found older lua 5.0 libs
     57    SET(Lua_FOUND TRUE)
     58    SET(Lua_VERSION 5.0 CACHE STRING "")
     59    SET(Lua_INCLUDE_DIR ${Lua_INCLUDE_DIR_50} CACHE PATH "")
     60    SET(Lua_LIBRARIES ${Lua_LIBRARY_1_50} ${Lua_LIBRARY_2_50} CACHE FILEPATH "")
     61
     62  ENDIF (Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
     63       
     64
     65  IF (Lua_FOUND)
     66    MESSAGE(STATUS "Found Lua: ${Lua_LIBRARIES}")
     67  ELSE (Lua_FOUND)
     68    IF (Lua_FIND_REQUIRED)
     69      MESSAGE(FATAL_ERROR "Could not find Lua")
     70    ENDIF (Lua_FIND_REQUIRED)
     71  ENDIF (Lua_FOUND)
     72
    1673ENDIF (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
    1774
    18 FIND_PATH(Lua_INCLUDE_DIR lua.h
    19         /usr/include/lua5.1
    20         /usr/local/include/lua5.1
    21         ../libs/lua-5.1.3/src)
    22 
    23 FIND_LIBRARY(Lua_LIBRARIES lua5.1
    24         /usr/lib
    25         /usr/local/lib
    26         ../libs/lua-5.1.3/lib)
    27 
    28 IF (NOT Lua_INCLUDE_DIR)
    29  FIND_PATH(Lua_INCLUDE_DIR lua.h
    30         /usr/include/lua50
    31         /usr/local/include/lua50
    32         /usr/pack/lua-5.0.3-sd/include)
    33 ENDIF (NOT Lua_INCLUDE_DIR)
    34 
    35 IF (NOT Lua_LIBRARIES)
    36  FIND_LIBRARY(Lua_LIBRARIES lua50
    37         /usr/lib
    38         /usr/local/lib)
    39 
    40  FIND_LIBRARY(Lua_LIBRARY lualib50
    41         /usr/lib
    42         /usr/local/lib)
    43 
    44 #SET(Lua_LIBRARIES ${Lua_LIBRARIES} ${Lua_LIBRARY})
    45 ENDIF (NOT Lua_LIBRARIES)
    46 
    47 #especially for tardis
    48 IF (NOT Lua_LIBRARIES)
    49  FIND_LIBRARY(Lua_LIBRARIES lua
    50         /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib)
    51 
    52  FIND_LIBRARY(Lua_LIBRARY lualib
    53         /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib)
    54 
    55 #SET(Lua_LIBRARIES ${Lua_LIBRARIES} ${Lua_LIBRARY})
    56 ENDIF (NOT Lua_LIBRARIES)
    57 
    58 IF (Lua_INCLUDE_DIR AND Lua_LIBRARIES)
    59     SET(Lua_FOUND TRUE)
    60 ENDIF (Lua_INCLUDE_DIR AND Lua_LIBRARIES)
    61 
    62 IF (Lua_FOUND)
    63     MESSAGE(STATUS "Found Lua: ${Lua_LIBRARIES}")
    64     MESSAGE(STATUS "Found Lua: ${Lua_LIBRARY}")
    65 ELSE (Lua_FOUND)
    66     IF (Lua_FIND_REQUIRED)
    67         MESSAGE(FATAL_ERROR "Could not find Lua")
    68     ENDIF (Lua_FIND_REQUIRED)
    69 ENDIF (Lua_FOUND)
  • code/branches/input/src/core/CMakeLists.txt

    r1084 r1154  
    1 #get the created files
    2 AUX_SOURCE_DIRECTORY(tolua TOLUA_BIND_FILES)
    3 
    4 SET( CORE_SRC_FILES
     1SET(CORE_SRC_FILES
    52  OrxonoxClass.cc
    63  BaseObject.cc
     
    2926  Tickable.cc
    3027  Script.cc
    31   ${TOLUA_BIND_FILES}
     28  tolua/tolua_bind.cc
     29#tolua/tolua_bind.h
    3230)
    3331
    34 ADD_LIBRARY( core SHARED ${CORE_SRC_FILES})
     32#SET_SOURCE_FILES_PROPERTIES(tolua/tolua_bind.h
     33#  PROPERTIES
     34#  OBJECT_DEPENDS tolua/tolua_bind.h
     35#  OBJECT_DEPENDS tolua/tolua_bind.cc
     36#  GENERATED true
     37#  HEADER_FILE_ONLY true
     38#)
    3539
    36 TARGET_LINK_LIBRARIES( core
     40GET_TARGET_PROPERTY(TOLUA_EXE tolua LOCATION)
     41ADD_CUSTOM_COMMAND(
     42  OUTPUT tolua/tolua_bind.cc tolua/tolua_bind.h
     43  COMMAND ${TOLUA_EXE} -n core -o ../../src/core/tolua/tolua_bind.cc -H ../../src/core/tolua/tolua_bind.h ../../src/core/tolua/tolua.pkg
     44  DEPENDS tolua
     45  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib
     46)
     47
     48ADD_LIBRARY(core SHARED ${CORE_SRC_FILES})
     49
     50TARGET_LINK_LIBRARIES(core
     51  ${Lua_LIBRARIES}
     52  ${OIS_LIBRARIES}
     53  ${OGRE_LIBRARIES}
    3754  util
    38   ${Lua_LIBRARIES}
    39   ${Lua_LIBRARY}
    40   ${OIS_LIBRARIES}
    4155)
  • code/branches/input/src/core/ConfigFileManager.h

    r1064 r1154  
    6363    {
    6464        public:
     65            virtual ~ConfigFileEntry() {};
    6566            virtual void setValue(const std::string& value) = 0;
    6667            virtual std::string getValue() const = 0;
  • code/branches/input/src/core/InputManager.cc

    r1118 r1154  
    125125    // create the handlers
    126126    this->handlerGUI_ = new InputHandlerGUI();
     127    this->handlerGUI_->initialise();
    127128    this->handlerGame_ = new InputHandlerGame();
    128     //this->handlerBuffer_ = new InputBuffer();
    129     this->handlerGame_->loadBindings();
    130 
    131     /*COUT(ORX_DEBUG) << "*** InputManager: Loading key bindings..." << std::endl;
    132     // load the key bindings
    133     InputEvent empty = {0, false, 0, 0, 0};
    134     for (int i = 0; i < this->numberOfKeys_; i++)
    135       this->bindingsKeyPressed_[i] = empty;
    136 
    137     //assign 'abort' to the escape key
    138     this->bindingsKeyPressed_[(int)OIS::KC_ESCAPE].id = 1;
     129    this->handlerGame_->initialise();
     130
    139131    COUT(ORX_DEBUG) << "*** InputManager: Loading done." << std::endl;*/
    140132
     
    159151    this->inputSystem_   = 0;
    160152
    161     if (this->handlerBuffer_)
    162       delete this->handlerBuffer_;
    163153    if (this->handlerGame_)
    164154      delete this->handlerGame_;
     
    166156      delete this->handlerGUI_;
    167157
    168     this->handlerBuffer_ = 0;
    169158    this->handlerGame_   = 0;
    170159    this->handlerGUI_    = 0;
     
    192181        this->keyboard_->setEventCallback(this->handlerGame_);
    193182        break;
    194       case IM_KEYBOARD:
    195         this->mouse_->setEventCallback(this->handlerGame_);
    196         this->keyboard_->setEventCallback(this->handlerBuffer_);
    197         break;
    198183      case IM_UNINIT:
    199184        this->mouse_->setEventCallback(0);
     
    211196
    212197    // Give the listeners the chance to do additional calculations
     198    this->currentHandler_->tick(dt);
    213199  }
    214200
  • code/branches/input/src/core/InputManager.h

    r1084 r1154  
    5151    IM_INGAME:   Normal game mode. Key bindings and mouse are active.
    5252  */
    53   enum InputMode
    54   {
    55     IM_GUI      = 0,
    56     IM_KEYBOARD = 1,
    57     IM_INGAME   = 2,
    58     IM_UNINIT   = 3,
    59   };
    6053
    6154  /**
     
    8376    static InputManager& getSingleton();
    8477    static InputManager* getSingletonPtr() { return &getSingleton(); }
    85     static void setInputMode(int mode);
     78
     79    static void setInputHandler(std::string& name);
    8680
    8781  private:
     
    9589    OIS::Mouse        *mouse_;          //!< OIS keyboard
    9690
    97     InputMode          currentMode_;    //!< Input mode currently used
    98     InputMode          setMode_;        //!< Input mode that has been set lately
    99     InputHandlerGUI   *handlerGUI_;     //!< Handles the input if in GUI mode
    100     // FIXME: insert the InputBuffer once merged with core2
    101     InputBuffer       *handlerBuffer_;  //!< Handles the input if in Buffer mode
    102     InputHandlerGame  *handlerGame_;    //!< Handles the input if in Game mode
     91    BaseInputHandler* currentHandler_;
     92    BaseInputHandler* switchToHandler_;
     93    //! Maps the names of the input handlers to their instance
     94    std::map<std::string, BaseInputHandler*> handlers_;
    10395
    104     //! Pointer to the instance of the singleton
    105     //static InputManager *singletonRef_s;
    10696  };
    10797}
  • code/branches/input/src/core/Loader.cc

    r1085 r1154  
    115115        Script::init(Script::getLuaState());
    116116        Script::run();*/
    117         //Script* lua = Script::getInstance();
    118         //lua->loadFile(level->getFile(), true);
    119         //lua->run();
     117        Script* lua = Script::getInstance();
     118        lua->loadFile(level->getFile(), true);
     119        lua->run();
    120120
    121121        try
     
    124124            COUT(3) << "Mask: " << Loader::currentMask_s << std::endl;
    125125
    126             ticpp::Document xmlfile(level->getFile());
    127             xmlfile.LoadFile();
     126            //ticpp::Document xmlfile(level->getFile());
     127            //xmlfile.LoadFile();
    128128            //ticpp::Element myelement(*Script::getFileString());
    129             //ticpp::Document xmlfile;
    130             xmlfile.ToDocument();
    131             //xmlfile.Parse(lua->getLuaOutput(), true);
     129            ticpp::Document xmlfile;
     130            //xmlfile.ToDocument();
     131            xmlfile.Parse(lua->getLuaOutput(), true);
    132132
    133133            ticpp::Element rootElement;
  • code/branches/input/src/core/Script.cc

    r1076 r1154  
    6060    luaopen_debug(luaState_);
    6161#endif
    62     tolua_orxonox_open(luaState_);
     62    tolua_core_open(luaState_);
    6363    output_ = "";
    6464  }
     
    102102  }
    103103
     104#if LUA_VERSION_NUM != 501
     105  const char * Script::lua_Chunkreader(lua_State *L, void *data, size_t *size)
     106  {
     107    LoadS* ls = ((LoadS*)data);
     108    if (ls->size == 0) return NULL;
     109    *size = ls->size;
     110    ls->size = 0;
     111    return ls->s;
     112  }
     113#endif
    104114  void Script::run()
    105115  {
     
    110120    error = luaL_loadstring(luaState_, init.c_str());
    111121#else
    112     error = lua_load(luaState_, &orxonox::Script::lua_Chunkreader, (void*)init.c_str(), "init");
     122    LoadS ls;
     123    ls.s = init.c_str();
     124    ls.size = init.size();
     125    error = lua_load(luaState_, &orxonox::Script::lua_Chunkreader, &ls, init.c_str());
    113126#endif
    114127    if (error == 0)
  • code/branches/input/src/core/Script.h

    r1056 r1154  
    5050  class _CoreExport Script // tolua_export
    5151  { // tolua_export
     52    struct LoadS {
     53      const char *s;
     54      size_t size;
     55    };
     56
    5257    public:
    5358      inline static Script* getInstance() { if (!Script::singletonRef) Script::singletonRef = new Script(); return Script::singletonRef; } // tolua_export
     
    6166
    6267#if LUA_VERSION_NUM != 501
    63     inline static const char * lua_Chunkreader(lua_State *L, void *data, size_t *size) { return NULL;};
     68    static const char * lua_Chunkreader(lua_State *L, void *data, size_t *size);
    6469#endif
    6570
  • code/branches/input/src/orxonox/CMakeLists.txt

    r1070 r1154  
    3030#  objects/weapon/BulletManager.cc
    3131#  objects/weapon/WeaponStation.cc
     32  tolua/tolua_bind.cc
     33#  tolua/tolua_bind.h
    3234)
    3335
     36#SET_SOURCE_FILES_PROPERTIES(tolua/tolua_bind.h
     37#  PROPERTIES
     38#  OBJECT_DEPENDS tolua/tolua_bind.h
     39#  OBJECT_DEPENDS tolua/tolua_bind.cc
     40#  GENERATED true
     41#  HEADER_FILE_ONLY true
     42#)
     43
     44GET_TARGET_PROPERTY(TOLUA_EXE tolua LOCATION)
     45ADD_CUSTOM_COMMAND(
     46  OUTPUT tolua/tolua_bind.cc tolua/tolua_bind.h
     47  COMMAND ${TOLUA_EXE} -n orxonox -o ../../src/orxonox/tolua/tolua_bind.cc -H ../../src/orxonox/tolua/tolua_bind.h ../../src/orxonox/tolua/tolua.pkg
     48  DEPENDS tolua
     49  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib
     50)
     51       
    3452ADD_EXECUTABLE( orxonox ${ORXONOX_SRC_FILES} )
    3553
  • code/branches/input/src/util/CMakeLists.txt

    r1118 r1154  
    1 AUX_SOURCE_DIRECTORY(tinyxml TINYXML_SRC_FILES)
    2 
    3 SET (UTIL_SRC_FILES
     1SET(UTIL_SRC_FILES
    42  ArgReader.cc
     3  Clipboard.cc
     4  ExprParser.cc
    55  Math.cc
    6   String.cc
    7   Clipboard.cc
    8   SubString.cc
    9   ExprParser.cc
    106  MultiTypePrimitive.cc
    117  MultiTypeString.cc
    128  MultiTypeMath.cc
     9  String.cc
     10  SubString.cc
     11
     12  tinyxml/ticpp.cc
     13  tinyxml/tinystr.cc
     14  tinyxml/tinyxml.cc
     15  tinyxml/tinyxmlerror.cc
     16  tinyxml/tinyxmlparser.cc
     17
    1318  tolua/tolua_event.c
    1419  tolua/tolua_is.c
     
    1621  tolua/tolua_push.c
    1722  tolua/tolua_to.c
    18   ${TINYXML_SRC_FILES}
    1923)
    2024
    21 ADD_LIBRARY( util SHARED ${UTIL_SRC_FILES} )
     25ADD_LIBRARY(util SHARED ${UTIL_SRC_FILES})
    2226
    2327IF(TESTING_ENABLED)
     
    2529ENDIF(TESTING_ENABLED)
    2630
    27 TARGET_LINK_LIBRARIES( util
     31TARGET_LINK_LIBRARIES(util
    2832  ${OGRE_LIBRARIES}
    2933  ${Lua_LIBRARIES}
    30   ${Lua_LIBRARY}
    3134)
    3235
     36ADD_SUBDIRECTORY(tolua)
     37
  • code/branches/input/visual_studio/vc8/orxonox.vcproj

    r1035 r1154  
    384384                                </File>
    385385                        </Filter>
     386                        <Filter
     387                                Name="tolua"
     388                                >
     389                                <File
     390                                        RelativePath="..\..\src\orxonox\tolua\tolua_bind.cc"
     391                                        >
     392                                        <FileConfiguration
     393                                                Name="Debug|Win32"
     394                                                >
     395                                                <Tool
     396                                                        Name="VCCLCompilerTool"
     397                                                        UsePrecompiledHeader="0"
     398                                                />
     399                                        </FileConfiguration>
     400                                </File>
     401                        </Filter>
    386402                </Filter>
    387403                <Filter
     
    511527                                <File
    512528                                        RelativePath="..\..\src\orxonox\tools\Timer.h"
     529                                        >
     530                                </File>
     531                        </Filter>
     532                        <Filter
     533                                Name="tolua"
     534                                >
     535                                <File
     536                                        RelativePath="..\..\src\orxonox\tolua\tolua_bind.h"
    513537                                        >
    514538                                </File>
Note: See TracChangeset for help on using the changeset viewer.