Revision: 2616
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2616&view=rev
Author:   ulteq
Date:     2012-05-21 22:42:04 +0000 (Mon, 21 May 2012)
Log Message:
-----------
new twodreplay project WIP

Modified Paths:
--------------
    trunk/source/CMakeLists.txt
    trunk/source/main/CMakeLists.txt
    trunk/source/main/gameplay/TwoDReplay.h

Added Paths:
-----------
    trunk/source/twodreplay/
    trunk/source/twodreplay/CMakeLists.txt
    trunk/source/twodreplay/icon.rc
    trunk/source/twodreplay/main.cpp
    trunk/source/twodreplay/resource.h
    trunk/source/twodreplay/ror.ico

Removed Paths:
-------------
    trunk/source/main/main_tdr2svg/

Modified: trunk/source/CMakeLists.txt
===================================================================
--- trunk/source/CMakeLists.txt 2012-05-21 02:42:40 UTC (rev 2615)
+++ trunk/source/CMakeLists.txt 2012-05-21 22:42:04 UTC (rev 2616)
@@ -14,6 +14,12 @@
   add_subdirectory(configurator)
 ENDIF()
 
+set(ROR_BUILD_TWODREPLAY "TRUE" CACHE BOOL "build the twodreplay")
+
+IF(ROR_BUILD_TWODREPLAY)
+  add_subdirectory(twodreplay)
+ENDIF()
+
 IF(ROR_BUILD_UPDATER)
   add_subdirectory(updater)
 ENDIF()

Modified: trunk/source/main/CMakeLists.txt
===================================================================
--- trunk/source/main/CMakeLists.txt    2012-05-21 02:42:40 UTC (rev 2615)
+++ trunk/source/main/CMakeLists.txt    2012-05-21 22:42:04 UTC (rev 2616)
@@ -165,5 +165,3 @@
 IF(ROR_BUILD_SIM)
        add_subdirectory(main_sim)
 endif()
-
-#add_subdirectory(main_tdr2svg)

Modified: trunk/source/main/gameplay/TwoDReplay.h
===================================================================
--- trunk/source/main/gameplay/TwoDReplay.h     2012-05-21 02:42:40 UTC (rev 
2615)
+++ trunk/source/main/gameplay/TwoDReplay.h     2012-05-21 22:42:04 UTC (rev 
2616)
@@ -17,16 +17,11 @@
 You should have received a copy of the GNU General Public License
 along with Rigs of Rods.  If not, see <http://www.gnu.org/licenses/>.
 */
-#ifndef TWODREPLAY_H__
-#define TWODREPLAY_H__
+#ifndef __TwoDReplay_H_
+#define __TwoDReplay_H_
 
 #include "RoRPrerequisites.h"
-#include "OgrePrerequisites.h"
-#include "BeamData.h"
-#include "Beam.h"
 
-#include <vector>
-
 /** FILE FORMAT
  *
  *  HEADER - r2d_file_header_t
@@ -110,12 +105,14 @@
 class TwoDReplay
 {
 protected:
+
        FILE *file;
        float time;
 
        void start();
 
 public:
+
        TwoDReplay();
        ~TwoDReplay();
 
@@ -123,6 +120,4 @@
        void recordFrame();
 };
 
-#endif //TWODREPLAY_H__
-
-
+#endif // __TwoDReplay_H_

Added: trunk/source/twodreplay/CMakeLists.txt
===================================================================
--- trunk/source/twodreplay/CMakeLists.txt                              (rev 0)
+++ trunk/source/twodreplay/CMakeLists.txt      2012-05-21 22:42:04 UTC (rev 
2616)
@@ -0,0 +1,100 @@
+project(RoR_TDR2JS)
+
+#setup libraries
+macro(setup_lib name)
+   if(ROR_USE_${name})
+      include_directories(${${name}_INCLUDE_DIRS})
+      link_directories   (${${name}_LIBRARY_DIRS})
+      add_definitions("-DUSE_${name}")
+      set(optional_libs ${optional_libs} ${${name}_LIBRARIES})
+      #message(STATUS "${name} Enabled:      \tYES")
+      #message(STATUS "${name}_INCLUDE_DIRS: \t${${name}_INCLUDE_DIRS}")
+      #if(${${name}_LIBRARY_DIRS})
+      #   message(STATUS "${name}_LIBRARY_DIRS: \t${${name}_LIBRARY_DIRS}")
+      #endif(${${name}_LIBRARY_DIRS})
+      #message(STATUS "${name}_LIBRARIES:    \t${${name}_LIBRARIES}")
+   else()
+          #message(STATUS "${name} Enabled:      \tNO")
+   endif(ROR_USE_${name})
+endmacro(setup_lib)
+
+if(WIN32)
+       # use precompiled stuff
+       set(wxWidgets_INCLUDE_DIRS 
"${ROR_DEPENDENCIES_DIR}/includes/${ARCH_DIR}/WxWidgets" CACHE PATH "The 
wxWidgets include path to use")
+       set(wxWidgets_LIBRARY_DIRS 
"${ROR_DEPENDENCIES_DIR}/libs/${ARCH_DIR}/WxWidgets/Release" CACHE PATH "The 
wxWidgets lib path to use")
+       set(wxWidgets_LIBRARIES    
"wxbase29u.lib;wxmsw29u_core.lib;wxmsw29u_html.lib;wxbase29u_net.lib;wxmsw29u_adv.lib;wxpng.lib;wxtiff.lib;wxjpeg.lib;wxzlib.lib;wxregexu.lib;wxexpat.lib;winmm.lib;comctl32.lib;rpcrt4.lib;wsock32.lib;"
 CACHE STRING "The wxWidgets lib to link against")
+       add_definitions("-D_UNICODE -D_CRT_SECURE_NO_WARNINGS -DUNICODE")
+       include_directories(${wxWidgets_INCLUDE_DIRS})
+       link_directories (${wxWidgets_LIBRARY_DIRS})
+else(WIN32)
+       # find wxwidgets
+       SET(wxWidgets_USE_UNICODE ON)
+       FIND_PACKAGE(wxWidgets REQUIRED COMPONENTS base core html net adv)
+       include( ${wxWidgets_USE_FILE} )
+       #include_directories(${wxWidgets_INCLUDE_DIRS})
+       #add_definitions("-D${wxWidgets_DEFINITIONS}" ${wxWidgets_CXX_FLAGS})
+       #link_directories (${wxWidgets_LIB_DIR})
+endif(WIN32)
+
+IF(WIN32)
+   include_directories(${Boost_INCLUDE_DIRS})
+   link_directories   (${Boost_LIBRARY_DIRS})
+   include_directories(${PThread_INCLUDE_DIRS})
+   link_directories   (${PThread_LIBRARY_DIRS})
+
+   set(OS_LIBS "${PThread_LIBRARIES};dinput8.lib;dxguid.lib")
+   set(OS_SOURCE "icon.rc")
+
+   # disable some annoying VS warnings:
+   # warning C4244: 'initializing' : conversion from 'const float' to 'int', 
possible loss of data
+   # warning C4305: 'initializing' : truncation from 'double' to 'const float'
+   add_definitions("/wd4305 /wd4244")
+
+
+   #now: delay loading for opencl
+   if(ROR_USE_OPENCL)
+      set(CMAKE_EXE_LINKER_FLAGS_DEBUG          
"${CMAKE_EXE_LINKER_FLAGS_DEBUG}          /DELAYLOAD:OpenCL.dll")
+      set(CMAKE_EXE_LINKER_FLAGS_RELEASE        
"${CMAKE_EXE_LINKER_FLAGS_RELEASE}        /DELAYLOAD:OpenCL.dll")
+      set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL     
"${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}     /DELAYLOAD:OpenCL.dll")
+      set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO 
"${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /DELAYLOAD:OpenCL.dll")
+      set(OS_LIBS ${OS_LIBS} Delayimp.lib)
+   endif(ROR_USE_OPENCL)
+   
+   setup_lib(CRASHRPT)
+ELSEIF(UNIX)
+   find_package(PkgConfig)
+   PKG_CHECK_MODULES  (GTK gtk+-2.0 REQUIRED)
+   INCLUDE_DIRECTORIES(${GTK_INCLUDE_DIRS})
+
+   PKG_CHECK_MODULES  (Ogre OGRE REQUIRED)
+   PKG_CHECK_MODULES  (Ois OIS REQUIRED)
+
+   set(OS_LIBS "")
+
+ENDIF(WIN32)
+
+setup_lib(OPENCL)
+setup_lib(OPENAL)
+
+include_directories(${Ogre_INCLUDE_DIRS})
+link_directories   (${Ogre_LIBRARY_DIRS})
+include_directories(${Ois_INCLUDE_DIRS})
+link_directories   (${Ois_LIBRARY_DIRS})
+include_directories(${RoR_SOURCE_DIR}/source/protocol)
+
+add_definitions("-DNOOGRE -D_UNICODE")
+include_directories(../main/)
+include_directories(../main/gameplay/)
+include_directories(../main/physics)
+
+FILE(GLOB sources "*.cpp")
+FILE(GLOB headers "*.h")
+
+IF(WIN32)
+       add_executable(twodreplay WIN32 ${sources} ${headers} ${OS_SOURCE} 
../main/utils/Settings.cpp ../main/utils/errorutils.cpp ../main/utils/utils.cpp)
+       TARGET_LINK_LIBRARIES(twodreplay Version.lib)
+ELSE(WIN32)
+       add_executable(twodreplay ${sources} ${headers} ${OS_SOURCE} 
../main/utils/Settings.cpp ../main/utils/errorutils.cpp ../main/utils/utils.cpp)
+ENDIF(WIN32)
+
+TARGET_LINK_LIBRARIES(twodreplay ${Ogre_LIBRARIES} ${Ois_LIBRARIES} ${OS_LIBS} 
${optional_libs} ${wxWidgets_LIBRARIES})

Added: trunk/source/twodreplay/icon.rc
===================================================================
--- trunk/source/twodreplay/icon.rc                             (rev 0)
+++ trunk/source/twodreplay/icon.rc     2012-05-21 22:42:04 UTC (rev 2616)
@@ -0,0 +1,103 @@
+// IMPROVED BY HAND, DO NOT OPEN IN VISUAL STUDIO!
+
+// Microsoft Visual C++ generated resource script.
+//
+#include <Windows.h>
+#include "RoRVersion.h"
+#include "resource.h"
+/////////////////////////////////////////////////////////////////////////////
+// English (United States) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ICON1               ICON                    "ror.ico"
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE 
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE 
+BEGIN
+    "\0"
+END
+
+3 TEXTINCLUDE 
+BEGIN
+    "\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION ROR_VERSION_STRING_WIN
+ PRODUCTVERSION ROR_VERSION_STRING_WIN
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904b0"
+        BEGIN
+            VALUE "CompanyName", "rigsofrods.com"
+            VALUE "FileDescription", "Rigs of Rods Simulator"
+            VALUE "FileVersion", ROR_VERSION_STRING
+            VALUE "InternalName", "RoR"
+            VALUE "LegalCopyright", "Copyright (C) 2005-2011 rigsofrods.com"
+            VALUE "OriginalFilename", "RoR.exe"
+            VALUE "ProductName", "Rigs of Rods"
+            VALUE "ProductVersion", ROR_VERSION_STRING
+            VALUE "Comments", SVN_ID
+                       
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200
+    END
+END
+
+#endif    // English (United States) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+

Added: trunk/source/twodreplay/main.cpp
===================================================================
--- trunk/source/twodreplay/main.cpp                            (rev 0)
+++ trunk/source/twodreplay/main.cpp    2012-05-21 22:42:04 UTC (rev 2616)
@@ -0,0 +1,153 @@
+/*
+This source file is part of Rigs of Rods
+Copyright 2005-2012 Pierre-Michel Ricordel
+Copyright 2007-2012 Thomas Fischer
+
+For more information, see http://www.rigsofrods.com/
+
+Rigs of Rods is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 3, as
+published by the Free Software Foundation.
+
+Rigs of Rods 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 Rigs of Rods.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "TwoDReplay.h"
+
+#include "BeamData.h"
+
+using namespace Ogre;
+
+const char colors[10][8] = {
+               "#FF4848",
+               "#5757FF",
+               "#1FCB4A",
+               "#BABA21",
+               "#FF800D",
+               "#892EE4",
+               "#1F88A7",
+               "#990099",
+               "#B9264F",
+               "#06DCFB"
+};
+
+int main(int argc, char**argv)
+{
+       if(argc != 2)
+       {
+               printf("usage: %s <file.tdr>\n", argv[0]);
+               return 1;
+       }
+       FILE *file = fopen(argv[1], "r");
+       if(!file)
+       {
+               printf("error opening file: %s\n", argv[1]);
+               return 1;
+       }
+
+       char fnout[1024]="";
+       strncpy(fnout, argv[1], 1024);
+       strcat(fnout, ".js");
+       FILE *fileo = fopen(fnout, "w");
+       if(!fileo)
+       {
+               printf("error opening ouput file: %s\n", fnout);
+               return 1;
+       }
+       fprintf(fileo, "var data = [\n");
+
+       // first: read and compare header
+
+       r2d_file_header_t header;
+       fread(&header, 1, sizeof(header), file);
+
+       if(strncmp(header.fileformat, R2DFILEFORMAT, 8))
+       {
+               printf("unsupported file format: %s\n", header.fileformat);
+               printf("supported fileformat: %s\n", R2DFILEFORMAT);
+               return 1;
+       }
+       printf("loaded file with %d rigs:\n", header.num_rigs);
+
+       int wheel_count[MAX_TRUCKS];
+
+       for(int t=0; t<header.num_rigs; t++)
+       {
+               r2d_file_wheel_setup_t ws;
+               r2d_file_rig_t rig;
+               fread(&rig, 1, sizeof(rig), file);
+               printf(" %d %s / %s / %s / wheels:%d\n", rig.num, rig.name, 
rig.filename, rig.hash, rig.num_wheels);
+               wheel_count[t] = rig.num_wheels;
+               for(int w=0; w < rig.num_wheels; w++)
+               {
+                       fread(&ws, 1, sizeof(ws), file);
+                       printf("  wheel %d : width: %g, radius:%g, type:%d\n", 
w, ws.width, ws.radius, ws.type);
+               }
+       }
+
+       long header_pos = ftell(file);
+       // done parsing header, now to the data
+
+       // read all data
+       int entries = 0;
+       r2d_file_entry_t entry;
+       while(!feof(file))
+       {
+               fread(&entry, 1, sizeof(entry), file);
+               entries++;
+               printf("got entry: rig:%d, time:%gs, frame:%ld, type:%d\n", 
entry.rignum, (float)entry.time_ms/1000.0f, entry.physframe, entry.type);
+               fprintf(fileo, "\t{ ");
+               fprintf(fileo, "type: %d, ", entry.type);
+               fprintf(fileo, "rignum: %d, ", entry.rignum);
+               fprintf(fileo, "time_ms: %ld, ", entry.time_ms);
+               fprintf(fileo, "physframe: %ld, ", entry.physframe);
+               fprintf(fileo, "\n");
+               
+
+               r2d_memory_structure_rig_t st;
+               st.entry = entry;
+
+               if(entry.type == R2DTYPE_FRAME)
+               {
+                       r2d_file_frame_t frame;
+                       fread(&frame, 1, sizeof(frame), file);
+                       fprintf(fileo, "\t\tframe: {");
+                       fprintf(fileo, "brake: %g, ", frame.brake);
+                       fprintf(fileo, "steering: %g, ", frame.steering);
+                       fprintf(fileo, "accel: %g, ", frame.accel);
+                       fprintf(fileo, "clutch: %g, ", frame.clutch);
+                       fprintf(fileo, "gear: %d, ", frame.gear);
+                       fprintf(fileo, "gearMode: %d, ", frame.gearMode);
+                       fprintf(fileo, "pbrake: %d, \n", frame.pbrake);
+                       fprintf(fileo, "\t\t\twheels: { \n");
+
+                       r2d_file_wheel_frame_t wf;
+                       for(int w=0; w < wheel_count[entry.rignum]; w++)
+                       {
+                               fread(&wf, 1, sizeof(wf), file);
+                               fprintf(fileo, "\t\t\t\t%d: { ", w);
+                               fprintf(fileo, "x: %g, ", wf.wheel_pos[0]);
+                               fprintf(fileo, "y: %g, ", wf.wheel_pos[1]);
+                               fprintf(fileo, "z: %g, ", wf.wheel_pos[2]);
+                               fprintf(fileo, "dir: %g, ", wf.wheel_direction);
+                               fprintf(fileo, "slip: %g, ", wf.wheel_slip);
+                               fprintf(fileo, "speed: %g", wf.wheel_speed);
+                               fprintf(fileo, " },\n");
+                       }
+                       fprintf(fileo, "\t\t\t},\n");
+                       fprintf(fileo, "\t\t},\n");
+               }
+               fprintf(fileo, "\t}, \n");
+       }
+       fclose(file);
+       fprintf(fileo, "];\n");
+       fprintf(fileo, "var data_size = %d\n", entries);
+       fclose(fileo);
+       printf("done, saved as file %s\n", fnout);
+       return 0;
+}

Added: trunk/source/twodreplay/resource.h
===================================================================
--- trunk/source/twodreplay/resource.h                          (rev 0)
+++ trunk/source/twodreplay/resource.h  2012-05-21 22:42:04 UTC (rev 2616)
@@ -0,0 +1,16 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by icon.rc
+//
+#define IDI_ICON1                       101
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        102
+#define _APS_NEXT_COMMAND_VALUE         40001
+#define _APS_NEXT_CONTROL_VALUE         1000
+#define _APS_NEXT_SYMED_VALUE           101
+#endif
+#endif

Added: trunk/source/twodreplay/ror.ico
===================================================================
(Binary files differ)


Property changes on: trunk/source/twodreplay/ror.ico
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel

Reply via email to