- typedef LazyStatic<TypeCasts> StaticTypeCasts;
-
- void* m_test;
-
- Bounded& get(NullType<Bounded>)
- {
- return m_picomodel;
- }
- Cullable& get(NullType<Cullable>)
- {
- return m_picomodel;
- }
-
- void lightsChanged()
- {
- m_lightList->lightsChanged();
- }
- typedef MemberCaller<PicoModelInstance, &PicoModelInstance::lightsChanged> LightsChangedCaller;
-
- void constructRemaps()
- {
- ASSERT_MESSAGE(m_skins.size() == m_picomodel.size(), "ERROR");
- ModelSkin* skin = NodeTypeCast<ModelSkin>::cast(path().parent());
- if(skin != 0 && skin->realised())
- {
- SurfaceRemaps::iterator j = m_skins.begin();
- for(PicoModel::const_iterator i = m_picomodel.begin(); i != m_picomodel.end(); ++i, ++j)
- {
- const char* remap = skin->getRemap((*i)->getShader());
- if(!string_empty(remap))
- {
- (*j).first = remap;
- (*j).second = GlobalShaderCache().capture(remap);
- }
- else
- {
- (*j).second = 0;
- }
- }
- SceneChangeNotify();
- }
- }
- void destroyRemaps()
- {
- ASSERT_MESSAGE(m_skins.size() == m_picomodel.size(), "ERROR");
- for(SurfaceRemaps::iterator i = m_skins.begin(); i != m_skins.end(); ++i)
- {
- if((*i).second != 0)
- {
- GlobalShaderCache().release((*i).first.c_str());
- (*i).second = 0;
- }
- }
- }
- void skinChanged()
- {
- destroyRemaps();
- constructRemaps();
- }
-
- PicoModelInstance(const scene::Path& path, scene::Instance* parent, PicoModel& picomodel) :
- Instance(path, parent, this, StaticTypeCasts::instance().get()),
- m_picomodel(picomodel),
- m_surfaceLightLists(m_picomodel.size()),
- m_skins(m_picomodel.size())
- {
- m_lightList = &GlobalShaderCache().attach(*this);
- m_picomodel.m_lightsChanged = LightsChangedCaller(*this);
-
- Instance::setTransformChangedCallback(LightsChangedCaller(*this));
-
- constructRemaps();
- }
- ~PicoModelInstance()
- {
- destroyRemaps();
-
- Instance::setTransformChangedCallback(Callback());
-
- m_picomodel.m_lightsChanged = Callback();
- GlobalShaderCache().detach(*this);
- }
-
- void render(Renderer& renderer, const VolumeTest& volume, const Matrix4& localToWorld) const
- {
- SurfaceLightLists::const_iterator j = m_surfaceLightLists.begin();
- SurfaceRemaps::const_iterator k = m_skins.begin();
- for(PicoModel::const_iterator i = m_picomodel.begin(); i != m_picomodel.end(); ++i, ++j, ++k)
- {
- if((*i)->intersectVolume(volume, localToWorld) != c_volumeOutside)
- {
- renderer.setLights(*j);
- (*i)->render(renderer, localToWorld, (*k).second != 0 ? (*k).second : (*i)->getState());
- }
- }
- }
-
- void renderSolid(Renderer& renderer, const VolumeTest& volume) const
- {
- m_lightList->evaluateLights();
-
- render(renderer, volume, Instance::localToWorld());
- }
- void renderWireframe(Renderer& renderer, const VolumeTest& volume) const
- {
- renderSolid(renderer, volume);
- }
-
- void testSelect(Selector& selector, SelectionTest& test)
- {
- m_picomodel.testSelect(selector, test, Instance::localToWorld());
- }
-
- bool testLight(const RendererLight& light) const
- {
- return light.testAABB(worldAABB());
- }
- void insertLight(const RendererLight& light)
- {
- const Matrix4& localToWorld = Instance::localToWorld();
- SurfaceLightLists::iterator j = m_surfaceLightLists.begin();
- for(PicoModel::const_iterator i = m_picomodel.begin(); i != m_picomodel.end(); ++i)
- {
- Surface_addLight(*(*i), *j++, localToWorld, light);
- }
- }
- void clearLights()
- {
- for(SurfaceLightLists::iterator i = m_surfaceLightLists.begin(); i != m_surfaceLightLists.end(); ++i)
- {
- (*i).clear();
- }
- }
+CopiedString first;
+Shader* second;
+Remap() : second( 0 ){
+}
+};
+typedef Array<Remap> SurfaceRemaps;
+SurfaceRemaps m_skins;
+
+PicoModelInstance( const PicoModelInstance& );
+PicoModelInstance operator=( const PicoModelInstance& );
+public:
+typedef LazyStatic<TypeCasts> StaticTypeCasts;
+
+void* m_test;
+
+Bounded& get( NullType<Bounded>){
+ return m_picomodel;
+}
+Cullable& get( NullType<Cullable>){
+ return m_picomodel;
+}
+
+void lightsChanged(){
+ m_lightList->lightsChanged();
+}
+typedef MemberCaller<PicoModelInstance, &PicoModelInstance::lightsChanged> LightsChangedCaller;
+
+void constructRemaps(){
+ ASSERT_MESSAGE( m_skins.size() == m_picomodel.size(), "ERROR" );
+ ModelSkin* skin = NodeTypeCast<ModelSkin>::cast( path().parent() );
+ if ( skin != 0 && skin->realised() ) {
+ SurfaceRemaps::iterator j = m_skins.begin();
+ for ( PicoModel::const_iterator i = m_picomodel.begin(); i != m_picomodel.end(); ++i, ++j )
+ {
+ const char* remap = skin->getRemap( ( *i )->getShader() );
+ if ( !string_empty( remap ) ) {
+ ( *j ).first = remap;
+ ( *j ).second = GlobalShaderCache().capture( remap );
+ }
+ else
+ {
+ ( *j ).second = 0;
+ }
+ }
+ SceneChangeNotify();
+ }
+}
+void destroyRemaps(){
+ ASSERT_MESSAGE( m_skins.size() == m_picomodel.size(), "ERROR" );
+ for ( SurfaceRemaps::iterator i = m_skins.begin(); i != m_skins.end(); ++i )
+ {
+ if ( ( *i ).second != 0 ) {
+ GlobalShaderCache().release( ( *i ).first.c_str() );
+ ( *i ).second = 0;
+ }
+ }
+}
+void skinChanged(){
+ destroyRemaps();
+ constructRemaps();
+}
+
+PicoModelInstance( const scene::Path& path, scene::Instance* parent, PicoModel& picomodel ) :
+ Instance( path, parent, this, StaticTypeCasts::instance().get() ),
+ m_picomodel( picomodel ),
+ m_surfaceLightLists( m_picomodel.size() ),
+ m_skins( m_picomodel.size() ){
+ m_lightList = &GlobalShaderCache().attach( *this );
+ m_picomodel.m_lightsChanged = LightsChangedCaller( *this );
+
+ Instance::setTransformChangedCallback( LightsChangedCaller( *this ) );
+
+ constructRemaps();
+}
+~PicoModelInstance(){
+ destroyRemaps();
+
+ Instance::setTransformChangedCallback( Callback() );
+
+ m_picomodel.m_lightsChanged = Callback();
+ GlobalShaderCache().detach( *this );
+}
+
+void render( Renderer& renderer, const VolumeTest& volume, const Matrix4& localToWorld ) const {
+ SurfaceLightLists::const_iterator j = m_surfaceLightLists.begin();
+ SurfaceRemaps::const_iterator k = m_skins.begin();
+ for ( PicoModel::const_iterator i = m_picomodel.begin(); i != m_picomodel.end(); ++i, ++j, ++k )
+ {
+ if ( ( *i )->intersectVolume( volume, localToWorld ) != c_volumeOutside ) {
+ renderer.setLights( *j );
+ ( *i )->render( renderer, localToWorld, ( *k ).second != 0 ? ( *k ).second : ( *i )->getState() );
+ }
+ }
+}
+
+void renderSolid( Renderer& renderer, const VolumeTest& volume ) const {
+ m_lightList->evaluateLights();
+
+ render( renderer, volume, Instance::localToWorld() );
+}
+void renderWireframe( Renderer& renderer, const VolumeTest& volume ) const {
+ renderSolid( renderer, volume );
+}
+
+void testSelect( Selector& selector, SelectionTest& test ){
+ m_picomodel.testSelect( selector, test, Instance::localToWorld() );
+}
+
+bool testLight( const RendererLight& light ) const {
+ return light.testAABB( worldAABB() );
+}
+void insertLight( const RendererLight& light ){
+ const Matrix4& localToWorld = Instance::localToWorld();
+ SurfaceLightLists::iterator j = m_surfaceLightLists.begin();
+ for ( PicoModel::const_iterator i = m_picomodel.begin(); i != m_picomodel.end(); ++i )
+ {
+ Surface_addLight( *( *i ), *j++, localToWorld, light );
+ }
+}
+void clearLights(){
+ for ( SurfaceLightLists::iterator i = m_surfaceLightLists.begin(); i != m_surfaceLightLists.end(); ++i )
+ {
+ ( *i ).clear();
+ }
+}