2 Copyright (C) 2001-2006, William Joseph.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "picomodel.h"
27 #include "idatastream.h"
29 #include "modelskin.h"
32 #include "renderable.h"
33 #include "selectable.h"
35 #include "math/frustum.h"
36 #include "string/string.h"
37 #include "generic/static.h"
38 #include "shaderlib.h"
40 #include "instancelib.h"
41 #include "transformlib.h"
42 #include "traverselib.h"
45 class VectorLightList : public LightList
47 typedef std::vector<const RendererLight*> Lights;
50 void addLight(const RendererLight& light)
52 m_lights.push_back(&light);
58 void evaluateLights() const
61 void lightsChanged() const
64 void forEachLight(const RendererLightCallback& callback) const
66 for(Lights::const_iterator i = m_lights.begin(); i != m_lights.end(); ++i)
74 public OpenGLRenderable
77 CopiedString m_shader;
80 Array<ArbitraryMeshVertex> m_vertices;
81 Array<RenderIndex> m_indices;
90 PicoSurface(picoSurface_t* surface)
92 CopyPicoSurface(surface);
100 void render(RenderStateFlags state) const
102 if((state & RENDER_BUMP) != 0)
104 if(GlobalShaderCache().useShaderLanguage())
106 glNormalPointer(GL_FLOAT, sizeof(ArbitraryMeshVertex), &m_vertices.data()->normal);
107 glVertexAttribPointerARB(c_attr_TexCoord0, 2, GL_FLOAT, 0, sizeof(ArbitraryMeshVertex), &m_vertices.data()->texcoord);
108 glVertexAttribPointerARB(c_attr_Tangent, 3, GL_FLOAT, 0, sizeof(ArbitraryMeshVertex), &m_vertices.data()->tangent);
109 glVertexAttribPointerARB(c_attr_Binormal, 3, GL_FLOAT, 0, sizeof(ArbitraryMeshVertex), &m_vertices.data()->bitangent);
113 glVertexAttribPointerARB(11, 3, GL_FLOAT, 0, sizeof(ArbitraryMeshVertex), &m_vertices.data()->normal);
114 glVertexAttribPointerARB(8, 2, GL_FLOAT, 0, sizeof(ArbitraryMeshVertex), &m_vertices.data()->texcoord);
115 glVertexAttribPointerARB(9, 3, GL_FLOAT, 0, sizeof(ArbitraryMeshVertex), &m_vertices.data()->tangent);
116 glVertexAttribPointerARB(10, 3, GL_FLOAT, 0, sizeof(ArbitraryMeshVertex), &m_vertices.data()->bitangent);
121 glNormalPointer(GL_FLOAT, sizeof(ArbitraryMeshVertex), &m_vertices.data()->normal);
122 glTexCoordPointer(2, GL_FLOAT, sizeof(ArbitraryMeshVertex), &m_vertices.data()->texcoord);
124 glVertexPointer(3, GL_FLOAT, sizeof(ArbitraryMeshVertex), &m_vertices.data()->vertex);
125 glDrawElements(GL_TRIANGLES, GLsizei(m_indices.size()), RenderIndexTypeID, m_indices.data());
128 GLfloat modelview[16];
129 glGetFloatv(GL_MODELVIEW_MATRIX, modelview); // I know this is slow as hell, but hey - we're in _DEBUG
130 Matrix4 modelview_inv(
131 modelview[0], modelview[1], modelview[2], modelview[3],
132 modelview[4], modelview[5], modelview[6], modelview[7],
133 modelview[8], modelview[9], modelview[10], modelview[11],
134 modelview[12], modelview[13], modelview[14], modelview[15]);
135 matrix4_full_invert(modelview_inv);
136 Matrix4 modelview_inv_transposed = matrix4_transposed(modelview_inv);
140 for(Array<ArbitraryMeshVertex>::const_iterator i = m_vertices.begin(); i != m_vertices.end(); ++i)
142 Vector3 normal = normal3f_to_vector3((*i).normal);
143 normal = matrix4_transformed_direction(modelview_inv, vector3_normalised(matrix4_transformed_direction(modelview_inv_transposed, normal))); // do some magic
144 Vector3 normalTransformed = vector3_added(vertex3f_to_vector3((*i).vertex), vector3_scaled(normal, 8));
145 glVertex3fv(vertex3f_to_array((*i).vertex));
146 glVertex3fv(vector3_to_array(normalTransformed));
152 VolumeIntersectionValue intersectVolume(const VolumeTest& test, const Matrix4& localToWorld) const
154 return test.TestAABB(m_aabb_local, localToWorld);
157 const AABB& localAABB() const
162 void render(Renderer& renderer, const Matrix4& localToWorld, Shader* state) const
164 renderer.SetState(state, Renderer::eFullMaterials);
165 renderer.addRenderable(*this, localToWorld);
168 void render(Renderer& renderer, const Matrix4& localToWorld) const
170 render(renderer, localToWorld, m_state);
173 void testSelect(Selector& selector, SelectionTest& test, const Matrix4& localToWorld)
175 test.BeginMesh(localToWorld);
177 SelectionIntersection best;
178 testSelect(test, best);
181 selector.addIntersection(best);
185 const char* getShader() const
187 return m_shader.c_str();
189 Shader* getState() const
198 m_state = GlobalShaderCache().capture(m_shader.c_str());
202 GlobalShaderCache().release(m_shader.c_str());
207 m_aabb_local = AABB();
208 for(std::size_t i = 0; i < m_vertices.size(); ++i )
209 aabb_extend_by_point_safe(m_aabb_local, reinterpret_cast<const Vector3&>(m_vertices[i].vertex));
212 for(Array<RenderIndex>::iterator i = m_indices.begin(); i != m_indices.end(); i += 3)
214 ArbitraryMeshVertex& a = m_vertices[*(i + 0)];
215 ArbitraryMeshVertex& b = m_vertices[*(i + 1)];
216 ArbitraryMeshVertex& c = m_vertices[*(i + 2)];
218 ArbitraryMeshTriangle_sumTangents(a, b, c);
221 for(Array<ArbitraryMeshVertex>::iterator i = m_vertices.begin(); i != m_vertices.end(); ++i)
223 vector3_normalise(reinterpret_cast<Vector3&>((*i).tangent));
224 vector3_normalise(reinterpret_cast<Vector3&>((*i).bitangent));
228 void testSelect(SelectionTest& test, SelectionIntersection& best)
231 VertexPointer(VertexPointer::pointer(&m_vertices.data()->vertex), sizeof(ArbitraryMeshVertex)),
232 IndexPointer(m_indices.data(), IndexPointer::index_type(m_indices.size())),
237 void CopyPicoSurface(picoSurface_t* surface)
239 picoShader_t* shader = PicoGetSurfaceShader( surface );
243 m_shader = PicoGetShaderName( shader );
245 m_vertices.resize( PicoGetSurfaceNumVertexes( surface ) );
246 m_indices.resize( PicoGetSurfaceNumIndexes( surface ) );
248 for(std::size_t i = 0; i < m_vertices.size(); ++i )
250 picoVec_t* xyz = PicoGetSurfaceXYZ( surface, int(i) );
251 m_vertices[i].vertex = vertex3f_from_array(xyz);
253 picoVec_t* normal = PicoGetSurfaceNormal( surface, int(i) );
254 m_vertices[i].normal = normal3f_from_array(normal);
256 picoVec_t* st = PicoGetSurfaceST( surface, 0, int(i) );
257 m_vertices[i].texcoord = TexCoord2f(st[0], st[1]);
260 picoVec_t* color = PicoGetSurfaceColor( surface, 0, int(i) );
261 m_vertices[i].colour = Colour4b(color[0], color[1], color[2], color[3]);
265 picoIndex_t* indexes = PicoGetSurfaceIndexes( surface, 0 );
266 for(std::size_t j = 0; j < m_indices.size(); ++j )
267 m_indices[ j ] = indexes[ j ];
272 void constructQuad(std::size_t index, const Vector3& a, const Vector3& b, const Vector3& c, const Vector3& d, const Vector3& normal)
274 m_vertices[index * 4 + 0] = ArbitraryMeshVertex(
275 vertex3f_for_vector3(a),
276 normal3f_for_vector3(normal),
277 texcoord2f_from_array(aabb_texcoord_topleft)
279 m_vertices[index * 4 + 1] = ArbitraryMeshVertex(
280 vertex3f_for_vector3(b),
281 normal3f_for_vector3(normal),
282 texcoord2f_from_array(aabb_texcoord_topright)
284 m_vertices[index * 4 + 2] = ArbitraryMeshVertex(
285 vertex3f_for_vector3(c),
286 normal3f_for_vector3(normal),
287 texcoord2f_from_array(aabb_texcoord_botright)
289 m_vertices[index * 4 + 3] = ArbitraryMeshVertex(
290 vertex3f_for_vector3(d),
291 normal3f_for_vector3(normal),
292 texcoord2f_from_array(aabb_texcoord_botleft)
298 AABB aabb(Vector3(0, 0, 0), Vector3(8, 8, 8));
301 aabb_corners(aabb, points);
303 m_vertices.resize(24);
305 constructQuad(0, points[2], points[1], points[5], points[6], aabb_normals[0]);
306 constructQuad(1, points[1], points[0], points[4], points[5], aabb_normals[1]);
307 constructQuad(2, points[0], points[1], points[2], points[3], aabb_normals[2]);
308 constructQuad(3, points[0], points[3], points[7], points[4], aabb_normals[3]);
309 constructQuad(4, points[3], points[2], points[6], points[7], aabb_normals[4]);
310 constructQuad(5, points[7], points[6], points[5], points[4], aabb_normals[5]);
312 m_indices.resize(36);
314 RenderIndex indices[36] = {
318 12, 13, 14, 12, 14, 15,
319 16, 17, 18, 16, 18, 19,
320 20, 21, 22, 10, 22, 23,
324 Array<RenderIndex>::iterator j = m_indices.begin();
325 for(RenderIndex* i = indices; i != indices+(sizeof(indices)/sizeof(RenderIndex)); ++i)
337 typedef std::pair<CopiedString, int> PicoModelKey;
344 typedef std::vector<PicoSurface*> surfaces_t;
345 surfaces_t m_surfaces;
349 Callback m_lightsChanged;
355 PicoModel(picoModel_t* model)
357 CopyPicoModel(model);
361 for(surfaces_t::iterator i = m_surfaces.begin(); i != m_surfaces.end(); ++i)
365 typedef surfaces_t::const_iterator const_iterator;
367 const_iterator begin() const
369 return m_surfaces.begin();
371 const_iterator end() const
373 return m_surfaces.end();
375 std::size_t size() const
377 return m_surfaces.size();
380 VolumeIntersectionValue intersectVolume(const VolumeTest& test, const Matrix4& localToWorld) const
382 return test.TestAABB(m_aabb_local, localToWorld);
385 virtual const AABB& localAABB() const
390 void render(Renderer& renderer, const VolumeTest& volume, const Matrix4& localToWorld, std::vector<Shader*> states) const
392 for(surfaces_t::const_iterator i = m_surfaces.begin(); i != m_surfaces.end(); ++i)
394 if((*i)->intersectVolume(volume, localToWorld) != c_volumeOutside)
396 (*i)->render(renderer, localToWorld, states[i - m_surfaces.begin()]);
401 void testSelect(Selector& selector, SelectionTest& test, const Matrix4& localToWorld)
403 for(surfaces_t::iterator i = m_surfaces.begin(); i != m_surfaces.end(); ++i)
405 if((*i)->intersectVolume(test.getVolume(), localToWorld) != c_volumeOutside)
407 (*i)->testSelect(selector, test, localToWorld);
413 void CopyPicoModel(picoModel_t* model)
415 m_aabb_local = AABB();
417 /* each surface on the model will become a new map drawsurface */
418 int numSurfaces = PicoGetModelNumSurfaces( model );
419 //% SYs_FPrintf( SYS_VRB, "Model %s has %d surfaces\n", name, numSurfaces );
420 for(int s = 0; s < numSurfaces; ++s)
423 picoSurface_t* surface = PicoGetModelSurface( model, s );
427 /* only handle triangle surfaces initially (fixme: support patches) */
428 if( PicoGetSurfaceType( surface ) != PICO_TRIANGLES )
431 /* fix the surface's normals */
432 PicoFixSurfaceNormals( surface );
434 PicoSurface* picosurface = new PicoSurface(surface);
435 aabb_extend_by_aabb_safe(m_aabb_local, picosurface->localAABB());
436 m_surfaces.push_back(picosurface);
441 PicoSurface* picosurface = new PicoSurface();
442 m_aabb_local = picosurface->localAABB();
443 m_surfaces.push_back(picosurface);
447 inline void Surface_addLight(PicoSurface& surface, VectorLightList& lights, const Matrix4& localToWorld, const RendererLight& light)
449 if(light.testAABB(aabb_for_oriented_aabb(surface.localAABB(), localToWorld)))
451 lights.addLight(light);
455 class PicoModelInstance :
456 public scene::Instance,
458 public SelectionTestable,
459 public LightCullable,
464 InstanceTypeCastTable m_casts;
468 InstanceContainedCast<PicoModelInstance, Bounded>::install(m_casts);
469 InstanceContainedCast<PicoModelInstance, Cullable>::install(m_casts);
470 InstanceStaticCast<PicoModelInstance, Renderable>::install(m_casts);
471 InstanceStaticCast<PicoModelInstance, SelectionTestable>::install(m_casts);
472 InstanceStaticCast<PicoModelInstance, SkinnedModel>::install(m_casts);
474 InstanceTypeCastTable& get()
480 PicoModel& m_picomodel;
482 const LightList* m_lightList;
483 typedef Array<VectorLightList> SurfaceLightLists;
484 SurfaceLightLists m_surfaceLightLists;
495 typedef Array<Remap> SurfaceRemaps;
496 SurfaceRemaps m_skins;
498 PicoModelInstance(const PicoModelInstance&);
499 PicoModelInstance operator=(const PicoModelInstance&);
501 typedef LazyStatic<TypeCasts> StaticTypeCasts;
505 Bounded& get(NullType<Bounded>)
509 Cullable& get(NullType<Cullable>)
516 m_lightList->lightsChanged();
518 typedef MemberCaller<PicoModelInstance, &PicoModelInstance::lightsChanged> LightsChangedCaller;
520 void constructRemaps()
522 ASSERT_MESSAGE(m_skins.size() == m_picomodel.size(), "ERROR");
523 ModelSkin* skin = NodeTypeCast<ModelSkin>::cast(path().parent());
524 if(skin != 0 && skin->realised())
526 SurfaceRemaps::iterator j = m_skins.begin();
527 for(PicoModel::const_iterator i = m_picomodel.begin(); i != m_picomodel.end(); ++i, ++j)
529 const char* remap = skin->getRemap((*i)->getShader());
530 if(!string_empty(remap))
533 (*j).second = GlobalShaderCache().capture(remap);
545 ASSERT_MESSAGE(m_skins.size() == m_picomodel.size(), "ERROR");
546 for(SurfaceRemaps::iterator i = m_skins.begin(); i != m_skins.end(); ++i)
550 GlobalShaderCache().release((*i).first.c_str());
561 PicoModelInstance(const scene::Path& path, scene::Instance* parent, PicoModel& picomodel) :
562 Instance(path, parent, this, StaticTypeCasts::instance().get()),
563 m_picomodel(picomodel),
564 m_surfaceLightLists(m_picomodel.size()),
565 m_skins(m_picomodel.size())
567 m_lightList = &GlobalShaderCache().attach(*this);
568 m_picomodel.m_lightsChanged = LightsChangedCaller(*this);
570 Instance::setTransformChangedCallback(LightsChangedCaller(*this));
578 Instance::setTransformChangedCallback(Callback());
580 m_picomodel.m_lightsChanged = Callback();
581 GlobalShaderCache().detach(*this);
584 void render(Renderer& renderer, const VolumeTest& volume, const Matrix4& localToWorld) const
586 SurfaceLightLists::const_iterator j = m_surfaceLightLists.begin();
587 SurfaceRemaps::const_iterator k = m_skins.begin();
588 for(PicoModel::const_iterator i = m_picomodel.begin(); i != m_picomodel.end(); ++i, ++j, ++k)
590 if((*i)->intersectVolume(volume, localToWorld) != c_volumeOutside)
592 renderer.setLights(*j);
593 (*i)->render(renderer, localToWorld, (*k).second != 0 ? (*k).second : (*i)->getState());
598 void renderSolid(Renderer& renderer, const VolumeTest& volume) const
600 m_lightList->evaluateLights();
602 render(renderer, volume, Instance::localToWorld());
604 void renderWireframe(Renderer& renderer, const VolumeTest& volume) const
606 renderSolid(renderer, volume);
609 void testSelect(Selector& selector, SelectionTest& test)
611 m_picomodel.testSelect(selector, test, Instance::localToWorld());
614 bool testLight(const RendererLight& light) const
616 return light.testAABB(worldAABB());
618 void insertLight(const RendererLight& light)
620 const Matrix4& localToWorld = Instance::localToWorld();
621 SurfaceLightLists::iterator j = m_surfaceLightLists.begin();
622 for(PicoModel::const_iterator i = m_picomodel.begin(); i != m_picomodel.end(); ++i)
624 Surface_addLight(*(*i), *j++, localToWorld, light);
629 for(SurfaceLightLists::iterator i = m_surfaceLightLists.begin(); i != m_surfaceLightLists.end(); ++i)
636 class PicoModelNode : public scene::Node::Symbiot, public scene::Instantiable
640 NodeTypeCastTable m_casts;
644 NodeStaticCast<PicoModelNode, scene::Instantiable>::install(m_casts);
646 NodeTypeCastTable& get()
654 InstanceSet m_instances;
655 PicoModel m_picomodel;
658 typedef LazyStatic<TypeCasts> StaticTypeCasts;
660 PicoModelNode() : m_node(this, this, StaticTypeCasts::instance().get())
663 PicoModelNode(picoModel_t* model) : m_node(this, this, StaticTypeCasts::instance().get()), m_picomodel(model)
676 scene::Instance* create(const scene::Path& path, scene::Instance* parent)
678 return new PicoModelInstance(path, parent, m_picomodel);
680 void forEachInstance(const scene::Instantiable::Visitor& visitor)
682 m_instances.forEachInstance(visitor);
684 void insert(scene::Instantiable::Observer* observer, const scene::Path& path, scene::Instance* instance)
686 m_instances.insert(observer, path, instance);
688 scene::Instance* erase(scene::Instantiable::Observer* observer, const scene::Path& path)
690 return m_instances.erase(observer, path);
697 template<typename Key, typename Type>
701 static Type* construct(const Key& key)
703 return new Type(key);
705 static void destroy(Type* value)
711 template<typename Key, typename Type, typename creation_policy = create_new<Key, Type> >
712 class cache_element : public creation_policy
715 inline cache_element() : m_count(0), m_value(0) {}
716 inline ~cache_element()
718 ASSERT_MESSAGE(m_count == 0 , "destroyed a reference before it was released\n");
722 inline Type* capture(const Key& key)
728 inline void release()
730 ASSERT_MESSAGE(!empty(), "failed to release reference - not found in cache\n");
738 inline void refresh(const Key& key)
740 m_value->refresh(key);
743 inline void construct(const Key& key)
745 m_value = creation_policy::construct(key);
747 inline void destroy()
749 creation_policy::destroy(m_value);
756 class create_picomodel
758 typedef PicoModelKey key_type;
759 typedef PicoModel value_type;
761 static value_type* construct(const key_type& key)
763 picoModel_t* picomodel = PicoLoadModel(const_cast<char*>(key.first.c_str()), key.second);
764 value_type* value = new value_type(picomodel);
765 PicoFreeModel(picomodel);
768 static void destroy(value_type* value)
778 typedef PicoModel value_type;
781 typedef PicoModelKey key_type;
782 typedef cache_element<key_type, value_type, create_picomodel> elem_type;
783 typedef std::map<key_type, elem_type> cache_type;
785 value_type* capture(const key_type& key)
787 return m_cache[key].capture(key);
789 void release(const key_type& key)
791 m_cache[key].release();
798 ModelCache g_model_cache;
802 typedef struct remap_s {
803 char m_remapbuff[64+1024];
813 RemapWrapper(const char* name)
817 m_model = g_model_cache.capture(ModelCache::key_type(m_name, m_frame));
821 virtual ~RemapWrapper()
823 g_model_cache.release(ModelCache::key_type(m_name, m_frame));
825 for(shaders_t::iterator i = m_shaders.begin(); i != m_shaders.end(); ++i)
827 GlobalShaderCache().release((*i).c_str());
830 for(remaps_t::iterator j = m_remaps.begin(); j != m_remaps.end(); ++j)
836 VolumeIntersectionValue intersectVolume(const VolumeTest& test, const Matrix4& localToWorld) const
838 return m_model->intersectVolume(test, localToWorld);
841 virtual const AABB& localAABB() const
843 return m_model->localAABB();
846 void render(Renderer& renderer, const VolumeTest& volume, const Matrix4& localToWorld) const
848 m_model->render(renderer, volume, localToWorld, m_states);
851 void testSelect(Selector& selector, SelectionTest& test, const Matrix4& localToWorld)
853 m_model->testSelect(selector, test, localToWorld);
857 void add_remap(const char *remap)
864 while( *ch && *ch != ';' )
869 globalErrorStream() << "WARNING: Shader _remap key found in a model entity without a ; character\n";
871 pRemap = new remap_t;
873 strncpy( pRemap->m_remapbuff, remap, sizeof(pRemap->m_remapbuff) );
875 pRemap->m_remapbuff[ch - remap] = '\0';
877 pRemap->original = pRemap->m_remapbuff;
878 pRemap->remap = pRemap->m_remapbuff + ( ch - remap ) + 1;
880 m_remaps.push_back( pRemap );
884 void parse_namestr(const char *name)
887 bool hasName, hasFrame;
889 hasName = hasFrame = false;
893 for( s = ptr = name; ; ++ptr )
895 if( !hasName && (*ptr == ':' || *ptr == '\0'))
899 m_name = CopiedString(s, ptr);
902 else if(*ptr == '?' || *ptr == '\0')
906 m_frame = atoi(CopiedString(s, ptr).c_str());
909 else if(*ptr == '&' || *ptr == '\0')
912 add_remap(CopiedString(s, ptr).c_str());
921 void construct_shaders()
923 const char* global_shader = shader_for_remap("*");
925 m_shaders.reserve(m_model->size());
926 m_states.reserve(m_model->size());
927 for(PicoModel::iterator i = m_model->begin(); i != m_model->end(); ++i)
929 const char* shader = shader_for_remap((*i)->getShader());
933 : (global_shader[0] != '\0')
935 : (*i)->getShader());
936 m_states.push_back(GlobalShaderCache().capture(m_shaders.back().c_str()));
940 inline const char* shader_for_remap(const char* remap)
942 for(remaps_t::iterator i = m_remaps.begin(); i != m_remaps.end(); ++i)
944 if(shader_equal(remap, (*i)->original))
956 typedef std::vector<remap_t*> remaps_t;
958 typedef std::vector<CopiedString> shaders_t;
960 typedef std::vector<Shader*> states_t;
964 class RemapWrapperInstance : public scene::Instance, public Renderable, public SelectionTestable
966 RemapWrapper& m_remapwrapper;
968 RemapWrapperInstance(const scene::Path& path, scene::Instance* parent, RemapWrapper& remapwrapper) : Instance(path, parent), m_remapwrapper(remapwrapper)
970 scene::Instance::m_cullable = &m_remapwrapper;
971 scene::Instance::m_render = this;
972 scene::Instance::m_select = this;
975 void renderSolid(Renderer& renderer, const VolumeTest& volume) const
977 m_remapwrapper.render(renderer, volume, Instance::localToWorld());
979 void renderWireframe(Renderer& renderer, const VolumeTest& volume) const
981 renderSolid(renderer, volume);
984 void testSelect(Selector& selector, SelectionTest& test)
986 m_remapwrapper.testSelect(selector, test, Instance::localToWorld());
990 class RemapWrapperNode : public scene::Node::Symbiot, public scene::Instantiable
993 typedef RemapWrapperInstance instance_type;
994 InstanceSet m_instances;
995 RemapWrapper m_remapwrapper;
997 RemapWrapperNode(const char* name) : m_node(this), m_remapwrapper(name)
999 m_node.m_instance = this;
1011 scene::Instance* create(const scene::Path& path, scene::Instance* parent)
1013 return new instance_type(path, parent, m_remapwrapper);
1015 void forEachInstance(const scene::Instantiable::Visitor& visitor)
1017 m_instances.forEachInstance(visitor);
1019 void insert(scene::Instantiable::Observer* observer, const scene::Path& path, scene::Instance* instance)
1021 m_instances.insert(observer, path, instance);
1023 scene::Instance* erase(scene::Instantiable::Observer* observer, const scene::Path& path)
1025 return m_instances.erase(observer, path);
1029 scene::Node& LoadRemapModel(const char* name)
1031 return (new RemapWrapperNode(name))->node();
1037 size_t picoInputStreamReam(void* inputStream, unsigned char* buffer, size_t length)
1039 return reinterpret_cast<InputStream*>(inputStream)->read(buffer, length);
1042 scene::Node& loadPicoModel(const picoModule_t* module, ArchiveFile& file)
1044 picoModel_t* model = PicoModuleLoadModelStream(module, &file.getInputStream(), picoInputStreamReam, file.size(), 0, file.getName());
1045 PicoModelNode* modelNode = new PicoModelNode(model);
1046 PicoFreeModel(model);
1047 return modelNode->node();