Game Development Community

Fix: MS - Simple Alpha Channel Support for Milkshape Exporter

by Ken Finney · in Torque Game Engine · 04/18/2002 (7:18 am) · 11 replies

The Milkshape Exporter supports Additive Translucency only - it kicks in when you have the emissive material slider set to less than 75% (default for it is to be all the way to to the right; if you move it left about 1/4 of full range and keep going, you get 75% or less...). That's the total extent of translucency/transparency in the ms2dtsExporter.dll

Now, in MS, the second material button (the botom one)loads a material in as the Alpha Texture, but the exporter doesn't do anything with it.

The following fix enables non-additive/non-subtractive translucency when the exporter simply detects the presence of an Alpha Texture. Remember to keep the emissive slider pushed all the way to the RIGHT, or you will end up with additive translucency, which in most cases, most of us DON'T want.

in the file DTSMilkshapeShape.cc in the ms2dtsExporter project at around line 185, add the code below shown in bold:
// Check transparency value
            if (msMaterial_GetTransparency (msMat) <= 0.75f)
               mat.flags |= Material::Translucent | Material::Additive ;
[b]
            msMaterial_GetAlphaTexture (msMat, alphaName, MS_MAX_PATH); //--- KCF ---             
            if (strlen(alphaName)>0)                    //--- KCF ---    
               mat.flags |= Material::Translucent;     //--- KCF ---       
 [/b]
            materials.push_back(mat) ;

now rebuild, move the dll to your MS directory, run MS, and make sure you have a texture loaded with that second button as the alpha texture.

NOTE: Milkshape will NOT let you import .PNG files, so you need *two* copies of your texture, one as PNG and one as JPG, both with IDENTICAL names, but different extensions. You use the JPG version in MS, and use the PNG version in Torque. The exporter exports the name without the extension, and when torque sees the name, it looks for a PNG first by default...



#1
04/18/2002 (7:25 am)
Won't ket you import PNGs?

Lets me do it, is this new to the latest version of MS?

BTW, very cool :) I'll give this a shot later tonight :)
#2
04/18/2002 (7:43 am)
Ed, I use MS 1.5.9, MS gives me an error when I try to specify a PNG file for a material ...
#3
04/18/2002 (7:48 am)
BTW - this little fix completely liberates me from begging people I know that have 3D Max to make little things for me, like very low poly bushes. Gawd, I hated that :-)
#4
04/18/2002 (7:49 am)
Milkshape3D v1.5.10 is out. Lets me import PNG files and specify them as a Material. I added a sphere, opened up the f.png file from one of the fps/shapes/interiors directories, and boom! It's there :-).
#5
04/18/2002 (7:53 am)
WHAT !!!??? WHY WASN'T I NOTIFIED OF THIS ??? WHERE'S THAT BLASTED ASSISTANT....*fires randomly selected person in the office*
#6
04/18/2002 (8:00 am)
hmmm. I just d/l'd 1.5.10 and tried loading a 64x64 .PNG with alpha channel, and got this:

razor.idlegames.com/acetw/tw/mserror.jpg
which is par for course.

Not only that, but now I'm short-staffed at the office, too :-(


;-)
#7
04/18/2002 (8:16 am)
I get that error whenever I use a PNG with transparency with MS3D. That's why I got fed up and added TGA support to Torque. I'll gladly clean things up and post as a resource if anyone wishes.
#8
04/18/2002 (11:18 am)
MS 1.5.10 can import a .PNG.... it can not import one with an Alpha Channel.
#9
04/18/2002 (11:46 am)
Hmmm, I am on 1.5.9 as well. Guess none of mine have alpha channels :)

NEat hack with the JPG's, didn't realize the material was referenced with just the file name not the extension.
#10
04/18/2002 (12:46 pm)
LOL.. just discovered that MS3D doesn't show compressed Targas.. I can't win.

Actually, it's not that big a deal; PS6 only puts out uncompressed Targas anyway.
#11
04/18/2002 (1:26 pm)
Torque will use whatever image it can find that matches the name portion.

If you use player.png in MS torque can use any of the following:

player.jpg
player.gif
player.bmp
player.bm8 (not sure about this one still being in)
player.png