Advertisement

Milkshape model loading

Started by May 16, 2001 12:31 PM
7 comments, last by bakery2k1 23 years, 7 months ago
I am using the Milkshape model tutorial from the nehe site, and it''s working fine. However when I ask it to load my own models, they come out OK but all white, ie no textures at all. Anyone know why this is?
I''ve never looked at NeHe''s work, but perhaps it has something to do with the word MILKshape?

G''luck,
-Alamar
Advertisement
1st, check that your texture loading code is working.
2nd, make sure that you are saving your MS models to the directory from which your game will load them.
3rd, make sure you are actually assigning textures in MS.
4th, make sure you haven''t broken the code by changing it yourself
5th, come back and post again
6th, have a beer

-DeVore
>1st, check that your texture loading code is working.

It loads the example texture OK, and it will load my texture onto the standard model.

>2nd, make sure that you are saving your MS models to the directory from which your game will load them.

Yep, am doing.

>3rd, make sure you are actually assigning textures in MS.

The model appears fine in MS.

>4th, make sure you haven't broken the code by changing it yourself

I havent even recompiled

>5th, come back and post again

Here you are!

Some more info:
When I load the example model into MS, the texture does not appear in the preview window. If I reload the texture so that the model appears textured in Milkshape, then the model comes out white in the program.
Does anyone know what's happening?

Edited by - bakery2k1 on May 16, 2001 2:48:08 PM
OK, got it. It was saving the wrong location for the texture. I dont know how to correct this so I moved the texture!
Now it works. Thanks.
if you convert the example model to milkshape ascii and look at the location it is saving it says for example
"data\Wood.bmp" which milkshape won''t load but lesson 32 will

but when you then assign the texture yourself in milkshape it changes to
"..\..\lesson32\data\Wood.bmp"
which the lesson 32 is not loading, but milkshape does

I''m gonna continue to fool around with it
it's all about a good time!AOLIM name: -LOKAPUJA-
Advertisement
I had this same problem. The problem is with the way Milkshape stores it''s directory names, the first texture assigned to a material get''s the whole path ("C:\My Programs\GenGL\Data\something.bmp"), then the next texture, so long as it was assigned in milkshape from the same path only get''s it''s path as ".\somethingelse.bmp".. this was an annoying little feature but can easily be taken care of.. not only that but it should be.. this way you can define a standard data path, say, "C:\My App\Data\Textures", strip out all the unwanted path data in the file name and simply add the file name to the default string. PLUS, allowing us to do this we can allow other people to add content to our game without over-writing our data (sorta like the -cgame cstrike command line option for Half Life).

here''s a quick little snippit of code I used to fix this "problem":

if (strlen(Material->m_texture) > 0)
{
StrippedFilename = strrchr(Material->m_texture, ''\\'');
ContainerModel->Materials.TextureFilename = new char[strlen(StrippedFilename)+1];
strcpy(ContainerModel->Materials.TextureFilename, StrippedFilename);<br><br> TextureCount += 1;<br> ContainerModel->Materials.Texture = TextureCount; <br> }<br><br>Note that since I''m loading in a bunch of different models, I load all the textures at once and simply flag them here to be loaded later using my "default" data path.<br><br>Hope this helps!<br>-Jon </i>
"Ah hell.. it doesn''t work.. AGAIN!"
When I originally wrote the article, Milkshape stored absolute paths. I converted the example to a relative path. The code would work either way and the program to convert the texture names was available from my site.

Now MS3D stores all as relative, starting with .\filename.bmp or .\data\filename.bmp
My latest release of PortaLib handles this, but I never quite got around to updating the tut. I''ll make that a priority for this weekend.

In the meantime - put everything in the same directory, works great


~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
~~~Cheers!Brett PorterPortaLib3D : A portable 3D game/demo libary for OpenGLCommunity Service Announcement: Read How to ask questions the smart way before posting!
thanks alot,
i see what i need to do, now

good thing for message boards, that was buggin me for a while
it's all about a good time!AOLIM name: -LOKAPUJA-

This topic is closed to new replies.

Advertisement