PDA

View Full Version : m15 with alternate textures



kryton9
20-03-2007, 10:52
Petr, in the model viewer I am developing. I want to give the user the option to load up different textures to try on their model.
I am not sure how to do this with the current
TBGL_m15LoadModel ModelFile, TextureSubdirectory, ModelID, TargetedDisplayList, NormalVectorMethod

Right now the only option I see is to just delete the loaded m15 and just reload it with the new texture the user selected?

I also wanted to try different uv wrapping on the model by the user in case they wanted to experiment and give finer control while trying out different textures. Am I missing something, or is this where I would need to use the glu headers? Thanks then I can focus on what I need too for now.

Petr Schreiber
20-03-2007, 11:17
Hi kryton,

regarding different texture set... both things can be done using "model shaders".
Only thing you might find complicated is to save modified m15 file,
but it is quite easy stuff I think, when in trouble just tell me :)

Here is example for UV change, you can easily modify it to direct UV set:


sub MoveUVCoords( model as long, UShift as single, VShift as single )

local i as long
local vertices as long
local U, V as single

vertices = tbgl_m15GetModelVertexcount( model )

for i = 1 to vertices
u = tbgl_m15GetVertexParam( model, i, %TBGL_m15TexX)
v = tbgl_m15GetVertexParam( model, i, %TBGL_m15TexY)

tbgl_m15SetVertexParam( model, i, %TBGL_m15TexX, u+Ushift)
tbgl_m15SetVertexParam( model, i, %TBGL_m15TexY, v+Vshift)
next
end sub


By assigning %TBGL_m15TexN you can assign texture index to vertices similar way.
You can see some current commands are quite clumsy. I am prepairing their facelift for new TBGL version.
Reson for doing them this way was to save some bytes on size of TBGL module, but I think it is not worth it.

Bye,
Petr

kryton9
20-03-2007, 11:24
Thanks Petr, will mess around with this today when I get up. Thanks for giving me stuff to dream about and get fired up about to work on when I get up!!