Help with Blender and Python scripts

Started by mrwho, February 27, 2007, 03:06:03 PM

Previous topic - Next topic

mrwho

How do you use them? I downloaded the script for exporting meshes into obj files, and placed it in the same folder as the rest of the scripts. Actually, I can't use any of them. How do I load/use a script???

mrwho

Okay, I figured out how to get it working, but of course there's another problem. I get it to export, and the first weird thing is that the mtl file is only 1 KB. When I put it in TG2, it renders as a solid black object, no materials at all. What do I do? I tried 5 or 6 different models, and they all end up the same. I'm using the obj exporting script found on the Blender.org website

Will

I'm not sure if blender supports materials.

Regards,

Will
The world is round... so you have to use spherical projection.

mrwho

I think they do, they had a couple different methods of exporting the obj (standard, default, obj groups, and material layers) I tried all of them, and none seemed to work. I'll try to find one that goes to .max or 3ds

red_planet

What's the source of your obj file ?

Or are you creating in Blender ?

If you aren't familiar with how to apply materials to Blender meshes, I suggest going through a few tutorials..several are linked from the blender.org website as well as the blender forum. (http://blenderartists.org/forum/index.php)

You shouldn't need to dl an exporter, the python script for exporting obj files is bundled with Blender and is available from the scripts menu. ( the button with a snake (python?????) opens a scripts window.

If Blender isn't working for you.. you could try Wingz 3d...my personal experience so far has been that the obj exporter in wingz is more compliant with the obj importer in TGTP. I had success with multiple materials created in Blender but only when exported to obj from Blender.. then imported into and then (re)exported from Wingz...a bit clunky..but it beats paying loads of money for if you don't have it...

hope this helps....

Rgds

Chris

§ardine

Also remember that the mtl file does not contain the images that are applied to you model.
All it does is specify color, alpha, shininess and gives a link to the images used. -It's not unusual for the file size to be that small.

It's usually best to keep the images in the same folder as everything else as well.  8)

mrwho

thanks for the help. The original file has been made in Blender (I downloaded them in the .blend format anyways), and they're all textured just fine, some really look nice. How would I get the materials to come out right? I've attached one of the files I'm trying to get into a correct obj format, maybe someone else will have better luck. I've been converting other formats into obj just fine, but Blender is giving me issues.

§ardine

#7
ok here is what I've found so far, the texture image is packed in the blend file you will need to unpack it to use it with your .obj.

To do this: open the file in blender. The texturing button should be open by default, so navigate to the image panel and click the small button with a box on it -this is next to the "reload" button. A pop-up choice box will ask if you want to disable packing, select this and then "create //textures/chbulbu.jpg". This will create a sub folder where the blend file is with the texture image inside it. I would move this down to the same directory as the blend file and re-link it there before exporting to .obj

I'll see what else I can do from my end here

-§ardine

Edit: also if you select "Copy Images" while exporting the obj I believe this will do the same thing :D - just saw that option ;D I also just realized it has quite a few more texture than one :P so you will need to unpack them all if you are getting an error message like I do with the "Copy Images" option.

§ardine

actually... now that I'm getting to this model it has 17 references in the mtl file and 16 is the max we can use right now with the multi-shader. you will need to do some optimizing to get this to work.

Also, each texture has it's own bump map image. These won't be referenced in the mtl file ,and wont work in TG as is, but you might be able to use them as displacement if you want to try later.  ;D This, of course, will need to be done after importing into TG2TP. You will find a number of threads that might point you in the right direction for this idea.

mrwho

thanks for your help! Now, which python script are you using to export? The one I use doesn't have an option for 'copy images' Mine's called obj_io_modif232b.py

§ardine

hmm not sure of the actual script file name. I'm using the Wavefront(.obj) (third from the bottom in file>export) that blender version 2.42a ships with.

looks like there is a problem with the script however as I'm getting an error everytime I try to use the "copy Images" option  :-\

I may have a go at this some more tomorrow if I get the time. it's getting late here and my mind has shut down

anyway hope this helps a bit
lata

mrwho

well, the 3rd option for exporting says 'Videoscape' and that exports in a boj format. the problem is, no textures show up. I have to manually save them in a folder, then somehow tell the mtl file where to look for the corresponding textures, and I have no idea how to do that

§ardine

I would use the Wavefront (.obj) like hillrunner and I mentioned. It's been working fine for me.

As far as your textures are concerned you shouldn't need to edit the mtl file if everything is set up correctly in blender before you export to .obj

Were you able to get the first texture unpacked like I mentioned above? You will then need to click the "load image" button and navigate to the newly unpacked image file. You will want to do this for each of the materials that contain images. And then export to .obj. Just remember that there are 17 materials in this model, and Terragen only can handle 16 atm. 1 or 2 of them have repeated textures so I would think that you could do some tweaking to get the number down under 16.

I'm still learning blender myself so there may be an easier way of doing this. (If someone else knows of a better way... now's the time to speak up  :P)

g2g for now,
~Sardine

mrwho

#13
i'm about ready to chuck my laptop across the room. I make the textures fine, they show up in a folder and stuff. I go to export the model, blah blah blah, and the obj file is 157 kb. I open it in TG 2, and NOTHING is there. I increase the scale to 10, 100, and 1000, but still nothing shows up >:( >:( >:(

and yes, i know that objects initially show up at 0,0,0

§ardine

#14
well I hope your laptop is still in one piece...  :-\

I've managed to learn something here you must not export the .obj with any spaces in the name else Terragen will not be able to find the mtl file. - ??? would this be considered a bug even though it's a bit expected ??? Oshyan?- I'm assuming that it is looking for a mtl by the name of "Dreadnaught" instead of "Dreadnaught g.mlt" if that is what you exported as.

I've gotten the model into tgo format with only 16 materials although you will find that it is a bit too colorful. :D the diffuse color is set to some "pretty" extremes and I'm sure you will want to rework them. Also on the quick render I did it looked like the texture images are repeating too often (I didn't bother to look at the uv mapping on the blend file as I'm a bit rushed on time) but maybe they are correct - I did just do the default Quick Render.

[attachurl=#1]

hope I helped save your laptop from disaster...

~§ardine