Md2 strip Material

Software: Prefab3D

Tempy111, Sr. Member
Posted: 26 August 2016 10:31 AM   Total Posts: 133

Okay, got a Md2 I made, it’s fine. I used it with Away3d 3.6 but anyway

I won’t load in Away3D 4. the problem seams to be a dependency for a material. I load the Md2 into Prefab and yep, it seams to be looking for a material. Now, I want to STRIP that material, so it’s the same, say the example files md2. the Model when in Away3d will have one of two materials depending. I try to export it in Prefab as a md2 without saving dependency but, it doesn’t strip the need from one in the code and I can’t figure out where (if anywhere) there is something that’ll let me remove the material.

Any clues?

   

Avatar
Fabrice Closier, Administrator
Posted: 26 August 2016 10:53 AM   Total Posts: 1265   [ # 1 ]

md2 format has by default a material dependency. Originally, the images linked in md2’s were not of a flash supported format. In older away3d 3.x parser, I recall I’ve added a trick that was using the prefix yet using extension jpg, so if the jpg was having the same name as the md2 file and placed in same directory, the jpg was loaded and applied, bypassing the need of this default dependency and the potential error caused by the unsupported format often exported with these files. Running myself a totally different package of parsers, I don’t recall if it’s still there in the public 4.x parsers. Place a jpg with same name and you’ll know right away.

Note that you have an alternative in Prefab that might be more flexible than using md2 format: export your animation as an as3 class.

   

Tempy111, Sr. Member
Posted: 26 August 2016 12:27 PM   Total Posts: 133   [ # 2 ]

I put a jpg in the folder with it with the same name BUT still moans.. odd

I was using Md2 cause i’m more familiar with the format and editing & animating it but I guess I could just export it as as3 class or something else.

the Prefab process log just says “ERROR while loading dependency: [Error #2032]
dependency: [.jpg]”

Anyway.. I’ll look into the As3 class option.. each model needs to be in it’s own folder for that doesn’t it?

   

Avatar
Fabrice Closier, Administrator
Posted: 26 August 2016 01:23 PM   Total Posts: 1265   [ # 3 ]

Obviously the dependency has been somehow encoded, but misses the prefix.
As I will not investigate/fix this (too old version), use the as3 exports or hack the md2 parser instead.

for the exports, simply compile/look at the example project class if you want to see how you could implement.

   

Tempy111, Sr. Member
Posted: 26 August 2016 01:27 PM   Total Posts: 133   [ # 4 ]

fair enough ^_^

i’m looking at the as3 class right now, trying to look at it all… should be fairly simple.

thanks ^_^

   

Tempy111, Sr. Member
Posted: 27 August 2016 12:52 PM   Total Posts: 133   [ # 5 ]

slightly wrong/unrelated place but kinda to finish this off.. can’t figure out how to change Material (so there is a Default material, but other textures can be used for reusing the model)..

all works with the designed texture.  Setup a new material via bitmapData/bitmaptexture/texturematerial way. for the As3 class model which is attached to the scene, i do:
Model.meshes[0].material = newmaterial

and the material just doesn’t change. mesh 0 is the only one in there.. as3class models seam to handle a bit different and i can’t find a guide on handling them.. sorry to be a pain ^_^

   

Avatar
Fabrice Closier, Administrator
Posted: 27 August 2016 03:07 PM   Total Posts: 1265   [ # 6 ]

As usual, without seeing any code, its hard to tell…

   

Tempy111, Sr. Member
Posted: 27 August 2016 03:13 PM   Total Posts: 133   [ # 7 ]

Ah, sorry ^_^;

var map:BitmapData;
 var 
bt:BitmapTexture;
 var 
material:TextureMaterial;
 
map Bitmap(new BunnyTex2()).bitmapData;
   
 
bt = new BitmapTexture(map);
 
material = new TextureMaterial(bt);
 
Pet = new Bunny();
 
_view.scene.addChild(Pet);
 
Pet.meshes[0].material material

i think that’s pretty much what’s relevant.

Ah, figured out a way.. Edited the AS class (in this case ‘Bunny.as’) to add a second material, which i don’t know if i needed to or not BUT i then changed the meshs line into
Pet.Meshes[0].subMeshes[0].material = Pet.materials[Number];
and it’s all fine now ^_^

   

Avatar
Fabrice Closier, Administrator
Posted: 27 August 2016 07:25 PM   Total Posts: 1265   [ # 8 ]

I haven’t run the code, but it seems ok.
What I think is happening is that the code works, but material is overwritten once the class material is ready and sets it.
So if you need to change the material, either wait or change the class so it does not generate a material.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X