VRUT::_io Class Reference

Add comment here for your module class. More...

#include <_io.h>

Inheritance diagram for VRUT::_io:

VRUT::IOModule VRUT::SceneModule VRUT::Module

List of all members.

Public Member Functions

 _io (const MODULE_ID &_id, const wxString &_name, EventHandler *msgSink)
 Class constructor - do not alter.
virtual ~_io ()
 Class destructor - deinitialize your data.
virtual wxString GetDesc () const
 Always overload method giving description for your module.
virtual wxString GetSupportedExts () const
 IOModule needs to have overloaded method that gives supported extensions.
virtual bool ImportScene (const wxString &fname, SCENE_ID _sceneID, const wxString &rootName)
virtual bool ExportScene (const wxString &fname, const Scene *scene)
 Export scene to file.

Protected Member Functions

virtual void processEvent (wxCommandEvent &evt)
 Overload this to process events you need.
virtual void run ()
 Overload only if you need to do some action every iteration of module's loop.

Protected Attributes

int var
 Add any variables.
Parameter::ParameterIdentificator varParamID
 Add var param identificator to register this as parameter.


Detailed Description

Add comment here for your module class.

Definition at line 31 of file _io.h.


Constructor & Destructor Documentation

VRUT::_io::_io ( const MODULE_ID _id,
const wxString &  _name,
EventHandler msgSink 
) [inline]

Class constructor - do not alter.

Initialize your variables Do not change other than param name when initializing param identificators

Register your params - choose GUI type or just register w/o GUI

Definition at line 67 of file _io.h.

00068                      : IOModule(_id, _name, 0, msgSink),
00071                      varParamID(_name, wxT("var"), _id)
00072               {
00074                      REGISTER_PARAM_GUI_SLIDER(varParamID, wxT("100"), 0, 200);
00075               }

virtual VRUT::_io::~_io (  )  [inline, virtual]

Class destructor - deinitialize your data.

Definition at line 77 of file _io.h.

00078               {
00079               }


Member Function Documentation

virtual void VRUT::_io::processEvent ( wxCommandEvent &  evt  )  [inline, protected, virtual]

Overload this to process events you need.

Always call base method

Remember to process registered param update events

Reimplemented from VRUT::IOModule.

Definition at line 40 of file _io.h.

00041               {
00043                      IOModule::processEvent(evt);
00044 
00045                      switch (evt.GetEventType())
00046                      {
00048                      case Event::EVT_PARAM_SET:
00049                             UPDATE_PARAM_FROM_EVENT_INT(varParamID, var, evt);
00050                             break;
00051                      }
00052               }

virtual void VRUT::_io::run (  )  [inline, protected, virtual]

Overload only if you need to do some action every iteration of module's loop.

These actions below usually take place as reaction to events and not in run() method Use <className> in all your log messages

If using long time operations be sure to check for exit during them

If we are to exit return to main loop as soon as possible

Reimplemented from VRUT::Module.

Definition at line 54 of file _io.h.

00055               {
00058                      LOG(wxT("<_io>I am still alive"));
00060                      if (TestExit())
00062                             return;
00063               }

virtual wxString VRUT::_io::GetDesc (  )  const [inline, virtual]

Always overload method giving description for your module.

Implements VRUT::Module.

Definition at line 82 of file _io.h.

00083               {
00084                      return wxT("This is my module");
00085               }

virtual wxString VRUT::_io::GetSupportedExts (  )  const [inline, virtual]

IOModule needs to have overloaded method that gives supported extensions.

Usually only one extension is supported, use spaces if more

Implements VRUT::IOModule.

Definition at line 87 of file _io.h.

00088               {
00090                      return wxT("NONE1 NONE2 NONE3 FHS");
00091               }

virtual bool VRUT::_io::ImportScene ( const wxString &  fname,
SCENE_ID  _sceneID,
const wxString &  rootName 
) [inline, virtual]

These 2 methods below are called from kernel or invoked by event processing in IOModule All you need to do is overload them

You can use this helper method to get input stream with scene data it automatically decompresses data if an archive is used

Use TextParser instead of wx classes as they are really slow

Deallocate inputStream as GetInputStream gives ownership

Now the fun stuff Create a new geometry node

Insert it to scene using event

Let's create a simple geometry

This describes geometry organization First is indice where the primitive type starts, second is primitive type to use

More primitive types can be used inside one geometry but usually one is enough

Now add this geometry to scene

We can finally assign geometry to our node

Don't forget to inform about our successful import

Implements VRUT::IOModule.

Definition at line 94 of file _io.h.

00095               {
00098                      wxInputStream * inputStream = IOModule::GetInputStream(fname);
00099                      if (inputStream)
00100                      {
00102                             TextParser textParser(inputStream, 10000, 1000);
00103                             LOG(wxT("<_io>") + textParser.GetWxLine());
00105                             SAFE_DELETE(inputStream);
00106                      }
00107 
00110                      SceneNode * node = new GeometryNode(wxT("_io_test"));
00112                      wxCommandEvent evt = Event::GET_EVT_SCENE_NODE_INSERT(_sceneID, node, rootName);
00113                      PostToKernel(evt);
00115                      GeometryTriangles * geom = new GeometryTriangles(wxT("_io_test_geometry"));
00116                      geom->vertices.push_back(VECTOR3(-1,0,0));
00117                      geom->vertices.push_back(VECTOR3(0,1,0));
00118                      geom->vertices.push_back(VECTOR3(0,0,-1));
00119                      geom->indices.push_back(0);
00120                      geom->indices.push_back(1);
00121                      geom->indices.push_back(2);
00122                      geom->normals.push_back(VECTOR3(0, -1, 0));
00123                      geom->normals.push_back(VECTOR3(0, -1, 0));
00124                      geom->normals.push_back(VECTOR3(0, -1, 0));
00127                      std::pair<GeometryTriangles::Indice, GeometryTriangles::PRIMITIVE_TYPE> triDesc(0, GeometryTriangles::TRI_LIST);
00129                      geom->triDescList.push_back(triDesc);
00131                      wxCommandEvent evt2 = Event::GET_EVT_SCENE_GEOMETRY_ADD(_sceneID, geom);
00132                      PostToKernel(evt2);
00134                      wxCommandEvent evt3 = Event::GET_EVT_SCENE_NODE_GEOMETRY_SET(_sceneID, wxT("_io_test"), geom->GetName());
00135                      PostToKernel(evt3);
00136 
00138                      wxCommandEvent ev4 = Event::GET_EVT_IO_SCENE_IMPORT_DONE(_sceneID);
00139                      PostToKernel(ev4);
00140 
00141                      return true;
00142               }

virtual bool VRUT::_io::ExportScene ( const wxString &  fname,
const Scene scene 
) [inline, virtual]

Export scene to file.

Implements VRUT::IOModule.

Definition at line 143 of file _io.h.

00144               {
00145                      if (scene)
00146                             LOG(wxString::Format(wxT("<_io>Saving scene '%s' to file '%s'"), scene->GetName().c_str(), fname.c_str()));
00148 
00149                      return true;
00150               }


Member Data Documentation

int VRUT::_io::var [protected]

Add any variables.

Definition at line 35 of file _io.h.

Add var param identificator to register this as parameter.

Definition at line 37 of file _io.h.


The documentation for this class was generated from the following file:

Generated on Tue Mar 10 14:41:45 2009 for VRUT by  doxygen 1.5.5