RE: [Algorithms] Model exporting - shader binding
Brought to you by:
vexxed72
|
From: Matthew M. <ma...@me...> - 2000-10-13 17:19:37
|
I think its a good idea to enforce unique names for all individually-addressable model entities. My approach has a few different elements: - an identifier class - has a string inside it - a symbol table - when you get a string, ask the symbol table if it's already in there - if it is, the symbol table gives you the identifier back. Then all objects referrring to the same name get the same actual object to use as an identifier, and comparisons are simply pointer equalities. - a dictionary - this maps identifier objects to the actual objects they identify - a link class - used to reference from one object to another - initalized with an identifier, but caches the result of a lookup so there's no real searching happening at frame-time - can be subclassed for demand-driven loading This is fast when tuned and extremely handy. Your game code winds up never dinking with strings directly, but you still have the convenience of asking for objects by name and getting them quickly. I've left out some details, most of which are handled by the STL (Standard Template Library.) >-----Original Message----- >From: gda...@li... >[mailto:gda...@li...]On Behalf Of >Barstow, Jason >Sent: Tuesday, October 10, 2000 2:06 AM >To: gda...@li... >Subject: [Algorithms] Model exporting - shader binding > > >I have a system working (D3D) where each model (mesh) can consist >of one or more vertex format buffers (VBs). > >Each VB is bound to a default shader at load time based on its format. >Currently this is almost always the basic single-textured-lit shader. > >Furthermore, I can bind sub-objects within the model to shaders also; >so if I have a car I can bind the chasis to one shader and the wheels >to another. > >I can overide the default shader and allocate specific shaders >to specific model parts at run-time. However, I'd much rather be >able to get the shader from the original model source. > >My idea atm, is to specifiy the shader id/name in the max object name. >So the car model hierarchy might be something like this : > >Object:"Car [SINGLETEXTURESHADER]" > Object:"Wheel1 [BUMPMAPSHADER]" > Object:"Wheel2 [BUMPMAPSHADER]" > Object:"Wheel3 [BUMPMAPSHADER]" > Object:"Wheel4 [BUMPMAPSHADER]" > >On export the shaderid would be validated and written to file. >But this is rather ugly - it requires correct spelling for one thing. > >Is there a better system for this ? >How do other people bind shaders to their models and subparts thereof ? > >(Currently I'm working with MAX ASE format files.) > >Regards, >Jason Barstow > >_______________________________________________ >GDAlgorithms-list mailing list >GDA...@li... >http://lists.sourceforge.net/mailman/listinfo/gdalgorithms-list > |