00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "ioscripting.h"
00013
00014 using namespace VRUT;
00015
00017 bool IOScriptingModule::ImportScene(const wxString & fname,
00018 SCENE_ID _sceneID, const wxString & rootUid)
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 }
00085
00087 bool IOScriptingModule::ExportScene(const wxString & fname, const Scene * scene)
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 }