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());
129 for(Array<ArbitraryMeshVertex>::const_iterator i = m_vertices.begin(); i != m_vertices.end(); ++i)
131 Vector3 normal = vector3_added(vertex3f_to_vector3((*i).vertex), vector3_scaled(normal3f_to_vector3((*i).normal), 8));
132 glVertex3fv(vertex3f_to_array((*i).vertex));
133 glVertex3fv(vector3_to_array(normal));
139 VolumeIntersectionValue intersectVolume(const VolumeTest& test, const Matrix4& localToWorld) const
141 return test.TestAABB(m_aabb_local, localToWorld);
144 const AABB& localAABB() const
149 void render(Renderer& renderer, const Matrix4& localToWorld, Shader* state) const
151 renderer.SetState(state, Renderer::eFullMaterials);
152 renderer.addRenderable(*this, localToWorld);
155 void render(Renderer& renderer, const Matrix4& localToWorld) const
157 render(renderer, localToWorld, m_state);
160 void testSelect(Selector& selector, SelectionTest& test, const Matrix4& localToWorld)
162 test.BeginMesh(localToWorld);
164 SelectionIntersection best;
165 testSelect(test, best);
168 selector.addIntersection(best);
172 const char* getShader() const
174 return m_shader.c_str();
176 Shader* getState() const
185 m_state = GlobalShaderCache().capture(m_shader.c_str());
189 GlobalShaderCache().release(m_shader.c_str());
194 m_aabb_local = AABB();
195 for(std::size_t i = 0; i < m_vertices.size(); ++i )
196 aabb_extend_by_point_safe(m_aabb_local, reinterpret_cast<const Vector3&>(m_vertices[i].vertex));
199 for(Array<RenderIndex>::iterator i = m_indices.begin(); i != m_indices.end(); i += 3)
201 ArbitraryMeshVertex& a = m_vertices[*(i + 0)];
202 ArbitraryMeshVertex& b = m_vertices[*(i + 1)];
203 ArbitraryMeshVertex& c = m_vertices[*(i + 2)];
205 ArbitraryMeshTriangle_sumTangents(a, b, c);
208 for(Array<ArbitraryMeshVertex>::iterator i = m_vertices.begin(); i != m_vertices.end(); ++i)
210 vector3_normalise(reinterpret_cast<Vector3&>((*i).tangent));
211 vector3_normalise(reinterpret_cast<Vector3&>((*i).bitangent));
215 void testSelect(SelectionTest& test, SelectionIntersection& best)
218 VertexPointer(VertexPointer::pointer(&m_vertices.data()->vertex), sizeof(ArbitraryMeshVertex)),
219 IndexPointer(m_indices.data(), IndexPointer::index_type(m_indices.size())),
224 void CopyPicoSurface(picoSurface_t* surface)
226 picoShader_t* shader = PicoGetSurfaceShader( surface );
230 m_shader = PicoGetShaderName( shader );
232 m_vertices.resize( PicoGetSurfaceNumVertexes( surface ) );
233 m_indices.resize( PicoGetSurfaceNumIndexes( surface ) );
235 for(std::size_t i = 0; i < m_vertices.size(); ++i )
237 picoVec_t* xyz = PicoGetSurfaceXYZ( surface, int(i) );
238 m_vertices[i].vertex = vertex3f_from_array(xyz);
240 picoVec_t* normal = PicoGetSurfaceNormal( surface, int(i) );
241 m_vertices[i].normal = normal3f_from_array(normal);
243 picoVec_t* st = PicoGetSurfaceST( surface, 0, int(i) );
244 m_vertices[i].texcoord = TexCoord2f(st[0], st[1]);
247 picoVec_t* color = PicoGetSurfaceColor( surface, 0, int(i) );
248 m_vertices[i].colour = Colour4b(color[0], color[1], color[2], color[3]);
252 picoIndex_t* indexes = PicoGetSurfaceIndexes( surface, 0 );
253 for(std::size_t j = 0; j < m_indices.size(); ++j )
254 m_indices[ j ] = indexes[ j ];
259 void constructQuad(std::size_t index, const Vector3& a, const Vector3& b, const Vector3& c, const Vector3& d, const Vector3& normal)
261 m_vertices[index * 4 + 0] = ArbitraryMeshVertex(
262 vertex3f_for_vector3(a),
263 normal3f_for_vector3(normal),
264 texcoord2f_from_array(aabb_texcoord_topleft)
266 m_vertices[index * 4 + 1] = ArbitraryMeshVertex(
267 vertex3f_for_vector3(b),
268 normal3f_for_vector3(normal),
269 texcoord2f_from_array(aabb_texcoord_topright)
271 m_vertices[index * 4 + 2] = ArbitraryMeshVertex(
272 vertex3f_for_vector3(c),
273 normal3f_for_vector3(normal),
274 texcoord2f_from_array(aabb_texcoord_botright)
276 m_vertices[index * 4 + 3] = ArbitraryMeshVertex(
277 vertex3f_for_vector3(d),
278 normal3f_for_vector3(normal),
279 texcoord2f_from_array(aabb_texcoord_botleft)
285 AABB aabb(Vector3(0, 0, 0), Vector3(8, 8, 8));
288 aabb_corners(aabb, points);
290 m_vertices.resize(24);
292 constructQuad(0, points[2], points[1], points[5], points[6], aabb_normals[0]);
293 constructQuad(1, points[1], points[0], points[4], points[5], aabb_normals[1]);
294 constructQuad(2, points[0], points[1], points[2], points[3], aabb_normals[2]);
295 constructQuad(3, points[0], points[3], points[7], points[4], aabb_normals[3]);
296 constructQuad(4, points[3], points[2], points[6], points[7], aabb_normals[4]);
297 constructQuad(5, points[7], points[6], points[5], points[4], aabb_normals[5]);
299 m_indices.resize(36);
301 RenderIndex indices[36] = {
305 12, 13, 14, 12, 14, 15,
306 16, 17, 18, 16, 18, 19,
307 20, 21, 22, 10, 22, 23,
311 Array<RenderIndex>::iterator j = m_indices.begin();
312 for(RenderIndex* i = indices; i != indices+(sizeof(indices)/sizeof(RenderIndex)); ++i)
324 typedef std::pair<CopiedString, int> PicoModelKey;
331 typedef std::vector<PicoSurface*> surfaces_t;
332 surfaces_t m_surfaces;
336 Callback m_lightsChanged;
342 PicoModel(picoModel_t* model)
344 CopyPicoModel(model);
348 for(surfaces_t::iterator i = m_surfaces.begin(); i != m_surfaces.end(); ++i)
352 typedef surfaces_t::const_iterator const_iterator;
354 const_iterator begin() const
356 return m_surfaces.begin();
358 const_iterator end() const
360 return m_surfaces.end();
362 std::size_t size() const
364 return m_surfaces.size();
367 VolumeIntersectionValue intersectVolume(const VolumeTest& test, const Matrix4& localToWorld) const
369 return test.TestAABB(m_aabb_local, localToWorld);
372 virtual const AABB& localAABB() const
377 void render(Renderer& renderer, const VolumeTest& volume, const Matrix4& localToWorld, std::vector<Shader*> states) const
379 for(surfaces_t::const_iterator i = m_surfaces.begin(); i != m_surfaces.end(); ++i)
381 if((*i)->intersectVolume(volume, localToWorld) != c_volumeOutside)
383 (*i)->render(renderer, localToWorld, states[i - m_surfaces.begin()]);
388 void testSelect(Selector& selector, SelectionTest& test, const Matrix4& localToWorld)
390 for(surfaces_t::iterator i = m_surfaces.begin(); i != m_surfaces.end(); ++i)
392 if((*i)->intersectVolume(test.getVolume(), localToWorld) != c_volumeOutside)
394 (*i)->testSelect(selector, test, localToWorld);
400 void CopyPicoModel(picoModel_t* model)
402 m_aabb_local = AABB();
404 /* each surface on the model will become a new map drawsurface */
405 int numSurfaces = PicoGetModelNumSurfaces( model );
406 //% SYs_FPrintf( SYS_VRB, "Model %s has %d surfaces\n", name, numSurfaces );
407 for(int s = 0; s < numSurfaces; ++s)
410 picoSurface_t* surface = PicoGetModelSurface( model, s );
414 /* only handle triangle surfaces initially (fixme: support patches) */
415 if( PicoGetSurfaceType( surface ) != PICO_TRIANGLES )
418 /* fix the surface's normals */
419 PicoFixSurfaceNormals( surface );
421 PicoSurface* picosurface = new PicoSurface(surface);
422 aabb_extend_by_aabb_safe(m_aabb_local, picosurface->localAABB());
423 m_surfaces.push_back(picosurface);
428 PicoSurface* picosurface = new PicoSurface();
429 m_aabb_local = picosurface->localAABB();
430 m_surfaces.push_back(picosurface);
434 inline void Surface_addLight(PicoSurface& surface, VectorLightList& lights, const Matrix4& localToWorld, const RendererLight& light)
436 if(light.testAABB(aabb_for_oriented_aabb(surface.localAABB(), localToWorld)))
438 lights.addLight(light);
442 class PicoModelInstance :
443 public scene::Instance,
445 public SelectionTestable,
446 public LightCullable,
451 InstanceTypeCastTable m_casts;
455 InstanceContainedCast<PicoModelInstance, Bounded>::install(m_casts);
456 InstanceContainedCast<PicoModelInstance, Cullable>::install(m_casts);
457 InstanceStaticCast<PicoModelInstance, Renderable>::install(m_casts);
458 InstanceStaticCast<PicoModelInstance, SelectionTestable>::install(m_casts);
459 InstanceStaticCast<PicoModelInstance, SkinnedModel>::install(m_casts);
461 InstanceTypeCastTable& get()
467 PicoModel& m_picomodel;
469 const LightList* m_lightList;
470 typedef Array<VectorLightList> SurfaceLightLists;
471 SurfaceLightLists m_surfaceLightLists;
482 typedef Array<Remap> SurfaceRemaps;
483 SurfaceRemaps m_skins;
485 PicoModelInstance(const PicoModelInstance&);
486 PicoModelInstance operator=(const PicoModelInstance&);
488 typedef LazyStatic<TypeCasts> StaticTypeCasts;
492 Bounded& get(NullType<Bounded>)
496 Cullable& get(NullType<Cullable>)
503 m_lightList->lightsChanged();
505 typedef MemberCaller<PicoModelInstance, &PicoModelInstance::lightsChanged> LightsChangedCaller;
507 void constructRemaps()
509 ASSERT_MESSAGE(m_skins.size() == m_picomodel.size(), "ERROR");
510 ModelSkin* skin = NodeTypeCast<ModelSkin>::cast(path().parent());
511 if(skin != 0 && skin->realised())
513 SurfaceRemaps::iterator j = m_skins.begin();
514 for(PicoModel::const_iterator i = m_picomodel.begin(); i != m_picomodel.end(); ++i, ++j)
516 const char* remap = skin->getRemap((*i)->getShader());
517 if(!string_empty(remap))
520 (*j).second = GlobalShaderCache().capture(remap);
532 ASSERT_MESSAGE(m_skins.size() == m_picomodel.size(), "ERROR");
533 for(SurfaceRemaps::iterator i = m_skins.begin(); i != m_skins.end(); ++i)
537 GlobalShaderCache().release((*i).first.c_str());
548 PicoModelInstance(const scene::Path& path, scene::Instance* parent, PicoModel& picomodel) :
549 Instance(path, parent, this, StaticTypeCasts::instance().get()),
550 m_picomodel(picomodel),
551 m_surfaceLightLists(m_picomodel.size()),
552 m_skins(m_picomodel.size())
554 m_lightList = &GlobalShaderCache().attach(*this);
555 m_picomodel.m_lightsChanged = LightsChangedCaller(*this);
557 Instance::setTransformChangedCallback(LightsChangedCaller(*this));
565 Instance::setTransformChangedCallback(Callback());
567 m_picomodel.m_lightsChanged = Callback();
568 GlobalShaderCache().detach(*this);
571 void render(Renderer& renderer, const VolumeTest& volume, const Matrix4& localToWorld) const
573 SurfaceLightLists::const_iterator j = m_surfaceLightLists.begin();
574 SurfaceRemaps::const_iterator k = m_skins.begin();
575 for(PicoModel::const_iterator i = m_picomodel.begin(); i != m_picomodel.end(); ++i, ++j, ++k)
577 if((*i)->intersectVolume(volume, localToWorld) != c_volumeOutside)
579 renderer.setLights(*j);
580 (*i)->render(renderer, localToWorld, (*k).second != 0 ? (*k).second : (*i)->getState());
585 void renderSolid(Renderer& renderer, const VolumeTest& volume) const
587 m_lightList->evaluateLights();
589 render(renderer, volume, Instance::localToWorld());
591 void renderWireframe(Renderer& renderer, const VolumeTest& volume) const
593 renderSolid(renderer, volume);
596 void testSelect(Selector& selector, SelectionTest& test)
598 m_picomodel.testSelect(selector, test, Instance::localToWorld());
601 bool testLight(const RendererLight& light) const
603 return light.testAABB(worldAABB());
605 void insertLight(const RendererLight& light)
607 const Matrix4& localToWorld = Instance::localToWorld();
608 SurfaceLightLists::iterator j = m_surfaceLightLists.begin();
609 for(PicoModel::const_iterator i = m_picomodel.begin(); i != m_picomodel.end(); ++i)
611 Surface_addLight(*(*i), *j++, localToWorld, light);
616 for(SurfaceLightLists::iterator i = m_surfaceLightLists.begin(); i != m_surfaceLightLists.end(); ++i)
623 class PicoModelNode : public scene::Node::Symbiot, public scene::Instantiable
627 NodeTypeCastTable m_casts;
631 NodeStaticCast<PicoModelNode, scene::Instantiable>::install(m_casts);
633 NodeTypeCastTable& get()
641 InstanceSet m_instances;
642 PicoModel m_picomodel;
645 typedef LazyStatic<TypeCasts> StaticTypeCasts;
647 PicoModelNode() : m_node(this, this, StaticTypeCasts::instance().get())
650 PicoModelNode(picoModel_t* model) : m_node(this, this, StaticTypeCasts::instance().get()), m_picomodel(model)
663 scene::Instance* create(const scene::Path& path, scene::Instance* parent)
665 return new PicoModelInstance(path, parent, m_picomodel);
667 void forEachInstance(const scene::Instantiable::Visitor& visitor)
669 m_instances.forEachInstance(visitor);
671 void insert(scene::Instantiable::Observer* observer, const scene::Path& path, scene::Instance* instance)
673 m_instances.insert(observer, path, instance);
675 scene::Instance* erase(scene::Instantiable::Observer* observer, const scene::Path& path)
677 return m_instances.erase(observer, path);
684 template<typename Key, typename Type>
688 static Type* construct(const Key& key)
690 return new Type(key);
692 static void destroy(Type* value)
698 template<typename Key, typename Type, typename creation_policy = create_new<Key, Type> >
699 class cache_element : public creation_policy
702 inline cache_element() : m_count(0), m_value(0) {}
703 inline ~cache_element()
705 ASSERT_MESSAGE(m_count == 0 , "destroyed a reference before it was released\n");
709 inline Type* capture(const Key& key)
715 inline void release()
717 ASSERT_MESSAGE(!empty(), "failed to release reference - not found in cache\n");
725 inline void refresh(const Key& key)
727 m_value->refresh(key);
730 inline void construct(const Key& key)
732 m_value = creation_policy::construct(key);
734 inline void destroy()
736 creation_policy::destroy(m_value);
743 class create_picomodel
745 typedef PicoModelKey key_type;
746 typedef PicoModel value_type;
748 static value_type* construct(const key_type& key)
750 picoModel_t* picomodel = PicoLoadModel(const_cast<char*>(key.first.c_str()), key.second);
751 value_type* value = new value_type(picomodel);
752 PicoFreeModel(picomodel);
755 static void destroy(value_type* value)
765 typedef PicoModel value_type;
768 typedef PicoModelKey key_type;
769 typedef cache_element<key_type, value_type, create_picomodel> elem_type;
770 typedef std::map<key_type, elem_type> cache_type;
772 value_type* capture(const key_type& key)
774 return m_cache[key].capture(key);
776 void release(const key_type& key)
778 m_cache[key].release();
785 ModelCache g_model_cache;
789 typedef struct remap_s {
790 char m_remapbuff[64+1024];
800 RemapWrapper(const char* name)
804 m_model = g_model_cache.capture(ModelCache::key_type(m_name, m_frame));
808 virtual ~RemapWrapper()
810 g_model_cache.release(ModelCache::key_type(m_name, m_frame));
812 for(shaders_t::iterator i = m_shaders.begin(); i != m_shaders.end(); ++i)
814 GlobalShaderCache().release((*i).c_str());
817 for(remaps_t::iterator j = m_remaps.begin(); j != m_remaps.end(); ++j)
823 VolumeIntersectionValue intersectVolume(const VolumeTest& test, const Matrix4& localToWorld) const
825 return m_model->intersectVolume(test, localToWorld);
828 virtual const AABB& localAABB() const
830 return m_model->localAABB();
833 void render(Renderer& renderer, const VolumeTest& volume, const Matrix4& localToWorld) const
835 m_model->render(renderer, volume, localToWorld, m_states);
838 void testSelect(Selector& selector, SelectionTest& test, const Matrix4& localToWorld)
840 m_model->testSelect(selector, test, localToWorld);
844 void add_remap(const char *remap)
851 while( *ch && *ch != ';' )
856 globalErrorStream() << "WARNING: Shader _remap key found in a model entity without a ; character\n";
858 pRemap = new remap_t;
860 strncpy( pRemap->m_remapbuff, remap, sizeof(pRemap->m_remapbuff) );
862 pRemap->m_remapbuff[ch - remap] = '\0';
864 pRemap->original = pRemap->m_remapbuff;
865 pRemap->remap = pRemap->m_remapbuff + ( ch - remap ) + 1;
867 m_remaps.push_back( pRemap );
871 void parse_namestr(const char *name)
874 bool hasName, hasFrame;
876 hasName = hasFrame = false;
880 for( s = ptr = name; ; ++ptr )
882 if( !hasName && (*ptr == ':' || *ptr == '\0'))
886 m_name = CopiedString(s, ptr);
889 else if(*ptr == '?' || *ptr == '\0')
893 m_frame = atoi(CopiedString(s, ptr).c_str());
896 else if(*ptr == '&' || *ptr == '\0')
899 add_remap(CopiedString(s, ptr).c_str());
908 void construct_shaders()
910 const char* global_shader = shader_for_remap("*");
912 m_shaders.reserve(m_model->size());
913 m_states.reserve(m_model->size());
914 for(PicoModel::iterator i = m_model->begin(); i != m_model->end(); ++i)
916 const char* shader = shader_for_remap((*i)->getShader());
920 : (global_shader[0] != '\0')
922 : (*i)->getShader());
923 m_states.push_back(GlobalShaderCache().capture(m_shaders.back().c_str()));
927 inline const char* shader_for_remap(const char* remap)
929 for(remaps_t::iterator i = m_remaps.begin(); i != m_remaps.end(); ++i)
931 if(shader_equal(remap, (*i)->original))
943 typedef std::vector<remap_t*> remaps_t;
945 typedef std::vector<CopiedString> shaders_t;
947 typedef std::vector<Shader*> states_t;
951 class RemapWrapperInstance : public scene::Instance, public Renderable, public SelectionTestable
953 RemapWrapper& m_remapwrapper;
955 RemapWrapperInstance(const scene::Path& path, scene::Instance* parent, RemapWrapper& remapwrapper) : Instance(path, parent), m_remapwrapper(remapwrapper)
957 scene::Instance::m_cullable = &m_remapwrapper;
958 scene::Instance::m_render = this;
959 scene::Instance::m_select = this;
962 void renderSolid(Renderer& renderer, const VolumeTest& volume) const
964 m_remapwrapper.render(renderer, volume, Instance::localToWorld());
966 void renderWireframe(Renderer& renderer, const VolumeTest& volume) const
968 renderSolid(renderer, volume);
971 void testSelect(Selector& selector, SelectionTest& test)
973 m_remapwrapper.testSelect(selector, test, Instance::localToWorld());
977 class RemapWrapperNode : public scene::Node::Symbiot, public scene::Instantiable
980 typedef RemapWrapperInstance instance_type;
981 InstanceSet m_instances;
982 RemapWrapper m_remapwrapper;
984 RemapWrapperNode(const char* name) : m_node(this), m_remapwrapper(name)
986 m_node.m_instance = this;
998 scene::Instance* create(const scene::Path& path, scene::Instance* parent)
1000 return new instance_type(path, parent, m_remapwrapper);
1002 void forEachInstance(const scene::Instantiable::Visitor& visitor)
1004 m_instances.forEachInstance(visitor);
1006 void insert(scene::Instantiable::Observer* observer, const scene::Path& path, scene::Instance* instance)
1008 m_instances.insert(observer, path, instance);
1010 scene::Instance* erase(scene::Instantiable::Observer* observer, const scene::Path& path)
1012 return m_instances.erase(observer, path);
1016 scene::Node& LoadRemapModel(const char* name)
1018 return (new RemapWrapperNode(name))->node();
1024 size_t picoInputStreamReam(void* inputStream, unsigned char* buffer, size_t length)
1026 return reinterpret_cast<InputStream*>(inputStream)->read(buffer, length);
1029 scene::Node& loadPicoModel(const picoModule_t* module, ArchiveFile& file)
1031 picoModel_t* model = PicoModuleLoadModelStream(module, &file.getInputStream(), picoInputStreamReam, file.size(), 0);
1032 PicoModelNode* modelNode = new PicoModelNode(model);
1033 PicoFreeModel(model);
1034 return modelNode->node();