VRUT::IOScriptingModule Class Reference

IO Scripting class. More...

#include <ioscripting.h>

Inheritance diagram for VRUT::IOScriptingModule:

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

List of all members.

Public Member Functions

 IOScriptingModule (const MODULE_ID &_id, const wxString &_name, EventHandler *msgSink)
 Class constructor.
virtual ~IOScriptingModule ()
 Class destructor.
virtual wxString GetDesc () const
 Always overload method giving description for your module.
virtual wxString GetSupportedExts () const
 Supported extensions.
virtual bool ImportScene (const wxString &fname, SCENE_ID _sceneID, const wxString &rootUid)
 Scene importing.
virtual bool ExportScene (const wxString &fname, const Scene *scene)
 Scene exporting.


Detailed Description

IO Scripting class.

Definition at line 28 of file ioscripting.h.


Constructor & Destructor Documentation

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

Class constructor.

Definition at line 32 of file ioscripting.h.

00033                      : IOModule(_id, _name, 0, msgSink) {}

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

Class destructor.

Definition at line 36 of file ioscripting.h.

00036 {}


Member Function Documentation

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

Always overload method giving description for your module.

Implements VRUT::Module.

Definition at line 39 of file ioscripting.h.

00040               {
00041                      return wxT("Test IO for scripting");
00042               }

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

Supported extensions.

Implements VRUT::IOModule.

Definition at line 44 of file ioscripting.h.

00045               {
00046                      return wxT("IOS");
00047               }

bool IOScriptingModule::ImportScene ( const wxString &  fname,
SCENE_ID  _sceneID,
const wxString &  rootUid 
) [virtual]

Scene importing.

Create a new geometry node

Insert it to scene using event

Geometry 1

Geometry 2

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 17 of file ioscripting.cpp.

00019 {
00021        SceneNode * node1 = new GeometryNode(wxT("ios_n1"), wxT("ios_n1"));
00022        SceneNode * node2 = new GeometryNode(wxT("ios_n2"), wxT("ios_n2"));
00024        wxCommandEvent evtn1 = Event::GET_EVT_SCENE_NODE_INSERT(_sceneID, node1, rootUid);
00025        PostToKernel(evtn1);
00026        wxCommandEvent evtn2 = Event::GET_EVT_SCENE_NODE_INSERT(_sceneID, node2, rootUid);
00027        PostToKernel(evtn2);
00028        
00029        float shift = 0.3f;
00031        GeometryTriangles * geom1 = new GeometryTriangles(wxT("ios_g1"));
00032        geom1->vertices.push_back(VECTOR3(-0.2f+shift,-0.2f,0.5));
00033        geom1->vertices.push_back(VECTOR3(-0.2f+shift,0.2f,0.5));
00034        geom1->vertices.push_back(VECTOR3(0.2f +shift,0.2f,0.5));
00035        geom1->vertices.push_back(VECTOR3(0.2f +shift,-0.2f,0.5));
00036        geom1->indices.push_back(0);
00037        geom1->indices.push_back(1);
00038        geom1->indices.push_back(2);
00039        geom1->indices.push_back(3);
00040        geom1->normals.push_back(VECTOR3(0, -1, 0));
00041        geom1->normals.push_back(VECTOR3(0, -1, 0));
00042        geom1->normals.push_back(VECTOR3(0, -1, 0));
00043        geom1->normals.push_back(VECTOR3(0, -1, 0));
00044 
00046        GeometryTriangles * geom2 = new GeometryTriangles(wxT("ios_g2"));
00047        geom2->vertices.push_back(VECTOR3(-0.2f -shift, -0.2f, 0.5));
00048        geom2->vertices.push_back(VECTOR3(-0.2f -shift,  0.2f, 0.5));
00049        geom2->vertices.push_back(VECTOR3(0.2f  -shift,  0.2f, 0.5));
00050        geom2->vertices.push_back(VECTOR3(0.2f  -shift, -0.2f, 0.5));
00051        geom2->indices.push_back(0);
00052        geom2->indices.push_back(1);
00053        geom2->indices.push_back(2);
00054        geom2->indices.push_back(3);
00055        geom2->normals.push_back(VECTOR3(0, -1, 0));
00056        geom2->normals.push_back(VECTOR3(0, -1, 0));
00057        geom2->normals.push_back(VECTOR3(0, -1, 0));
00058        geom2->normals.push_back(VECTOR3(0, -1, 0));
00059 
00060 
00063        std::pair<GeometryTriangles::Indice, GeometryTriangles::PRIMITIVE_TYPE> triDesc1(0, GeometryTriangles::QUADS);
00064        std::pair<GeometryTriangles::Indice, GeometryTriangles::PRIMITIVE_TYPE> triDesc2(0, GeometryTriangles::QUADS);
00066        geom1->triDescList.push_back(triDesc1);
00067        geom2->triDescList.push_back(triDesc2);
00069        wxCommandEvent evt2 = Event::GET_EVT_SCENE_GEOMETRY_ADD(_sceneID, geom1);
00070        PostToKernel(evt2);
00071        wxCommandEvent evt3 = Event::GET_EVT_SCENE_GEOMETRY_ADD(_sceneID, geom2);
00072        PostToKernel(evt3);
00074        wxCommandEvent evt4 = Event::GET_EVT_SCENE_NODE_GEOMETRY_SET(_sceneID, wxT("ios_n1"), geom1->GetName());
00075        PostToKernel(evt4);
00076        wxCommandEvent evt5 = Event::GET_EVT_SCENE_NODE_GEOMETRY_SET(_sceneID, wxT("ios_n2"), geom2->GetName());
00077        PostToKernel(evt5);
00078 
00080        wxCommandEvent evt6 = Event::GET_EVT_IO_SCENE_IMPORT_DONE(_sceneID);
00081        PostToKernel(evt6);
00082 
00083        return true;
00084 }

bool IOScriptingModule::ExportScene ( const wxString &  fname,
const Scene scene 
) [virtual]

Scene exporting.

Implements VRUT::IOModule.

Definition at line 87 of file ioscripting.cpp.

00088 {
00089        if (scene)
00090               LOG(wxString::Format(wxT("<IOScriptingModule>Saving scene '%s' to file '%s' isn't supported"), scene->GetName().c_str(), fname.c_str()));
00091 
00092        return true;
00093 }


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

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