Page 1 of 1

[BLENDER] Some Blender questions for blender-users...

Posted: Wed Nov 01, 2006 12:02 pm
by Lideln
Hi all !

I just edited my post because my worst issue is not the world map size anymore : at the moment I am using scales everywhere to get a quite big world, so the problem is a bit solved, but now I have some textures AND blender issues :lol:

1) In BLENDER I made a terrain (thanks to an heightmap feature in blender) and exported it to .3ds format.

Code: Select all

	mesh = hotp->scene->getMesh("data/levels/terrain_plat_1.3ds");
	node = hotp->scene->addOctTreeSceneNode(mesh);
	node->setScale(vector3df(80.0f, 80.0f, 80.0f));//(2.0f,0.8f,2.0f));
	node->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
	node->setMaterialFlag(video::EMF_LIGHTING, false);
I CAN NOT find how to correctly apply a texture on my outdoor level in Irrlicht :oops:
I tried this :

Code: Select all

node->setMaterialTexture(0, hotp->driver->getTexture("data/levels/map1.jpg"));
But it does not work, my mesh becomes completely dark green :shock:

2) In blender (v2.42) I created another tree (my previous tree had 2434 vertices and 2432 faces), less memory consuming : only 26 vertices and 26 faces :lol: (it should be a tree like in old CS : a trunk represented by a small cylinder and the foliage represented by 2 orthogonal faces on which I put a "noobish" texture.

In blender then I texture my trunk cylinder and my foliage faces, and I set my foliage faces to "double sided", in order to see them from front or back. I also set "UseAlpha" in the texture, and "Alpha" in "Map To" of the material. I then export to .obj (the only format that seems to work).

In irrlicht, I load my trees with :

Code: Select all

	// Place 100 nodes of this object
	mesh = hotp->scene->getMesh("data/objects/arbre1.obj");
	for (int i = 0; i < 100; ++i)
	{
		// Add another copy
		ptiga = hotp->scene->addOctTreeSceneNode(mesh->getMesh(0));
		// No global light, so...
		ptiga->setMaterialFlag(video::EMF_LIGHTING, false);
		// Align the copies in a row
		ptiga->setPosition(vector3df(0 + 4 * i, 10, -10));
	}
The trees are laid on the floor, and not standing (due to a strange rotation that comes out of nowhere :lol: ) , the trunk is (seems to be) correctly displayed, but for the foliage there are two issues :

a) they do not seem to be double sided since I can only see one part of each face (say, the front one), and the other part (say, the back one) is transparent.

b) the texture does not seem to appear : I have a black rectangle, thats all, no texture :(

The trunk texture is in .jpg, and the foliage texture is in .tga.

Does anyone here know blender and can give me advices about how to set textures in blender, what format and how to export, and how to set textures properly in irrlicht pleaaaaaaase ?

If someone uses Blender with Irrlicht quite often, I would love to be taught some good tips :)

Thanks a lot,

Lideln (who needs a bit help to get started :) )

Posted: Wed Nov 01, 2006 9:47 pm
by xtheagonyscenex
when i export .objs from blender in front veiw numpad1 i have my objects directly faceing me and i have no materials set in blender(seems to cause problems in irrlicht 1.1) so i only make uv coords and export it and they load in irrlicht correctly without rotation also i need to know what the console says about the texture and where it is loacated(should be near the .exe, also is the tree trunk and "foilage" in the same mesh? cuz you could make them seperate and export them one at a time you can finally do in 2.42 and it will look exactly like the blend file when you load them in the engine as long as you dont move them as for textures i would suggest using a zip archive when you done making whatever your making for now i use in the same folder as my exe. 3 textures,models,shaders then when you type you just type load texture "Textures/Mytexture.tga

Posted: Wed Nov 01, 2006 10:13 pm
by Lideln
Hi agonyScene !

Thank you for your answer.
Mmmmh I do not export in a specific view... I just export, thats all, I don't know if this is affected by one view (I made my Blender look like 3ds, I mean with the 4 views).

You make UVmapping for all your objects ?

My tree is in fact composed of mmmmh.... Say 12 objects maybe :
(because I made a new tree that does not use the 2 faces, like in CounterStrike)
- 1 trunk
- 10 "big leaf"
- 1 "top of the tree" (a cone to not see the trunk from the top)

I applied textures to the materials in Blender for every object, and then exported to wavefront .obj

In Irrlicht, I do not apply textures with code.

The Irrlicht output is :

Code: Select all

Loaded texture: data/objects/branche.tga
Loaded texture: data/objects/tronc.jpg
Loaded mesh: data/objects/arbre2.obj
So everything seems to be fine...

But the texture for the leafs does not use transparency, and with my old tree (the texture used transparency) it was NOT transparent.

Posted: Thu Nov 02, 2006 8:51 pm
by xtheagonyscenex
you should make the leafs one object if they use the same texture and yeah i uv map all my objects

Posted: Thu Nov 02, 2006 10:20 pm
by Lideln
Mmmmh UVmapping is hard sometimes (especially for total noobs like me)

Thanks to some tests, my level now displays quite well (but I still have to rotate 90° on X and Z axis in order to have it perfectly displayed...)

I still have the transparency issue :(
I will try with UVmap to see if it can "kill" the transparency issue
(sorry for my poor english lol)

Thanks again,

Posted: Thu Nov 02, 2006 10:47 pm
by hybrid
The transparency issues with .obj files are not easy to solve. We have to map the .obj concept as close as possible with Irrlicht's concept. Irrlicht has at least three possibilities to create transparency: Transparent where texture is black, transparent based on texture alpha channel, and transparent based on vertex color alpha value. This has to be mapped to Kx and Tx values in .mtl files.

Posted: Fri Nov 03, 2006 8:06 am
by Lideln
Mmmmh Ok thank you for your answer Hybrid.
Since I'm noob, I'm not suer of what you mean (I mean concretely).
Do I have to use UVmap, or, do I have to set the transparent parts of my texture to black, and then use a specific option in Irrlicht ?

Thanks again,

PS : here is my .mtl file for the tree that has transparency (2 orthogonal plane squares, each with that transparent texture applied)

Code: Select all

# Blender MTL File: arbre1.blend
# Material Count: 2
newmtl mat_feuillage
Ns 96.0
Ka 0.0 0.0 0.0
Kd 0.64 0.64 0.64
Ks 0.5 0.5 0.5
Ni 1.0
d 1.0
illum 2
map_Kd feuillage.tga


newmtl mat_tronc
Ns 96.0
Ka 0.0 0.0 0.0
Kd 0.64 0.64 0.64
Ks 0.5 0.5 0.5
Ni 1.0
d 1.0
illum 2
map_Kd tronc.jpg
Is there something special that you can see ? I can see that I do not have Tx values :shock:

Posted: Fri Nov 03, 2006 6:03 pm
by xtheagonyscenex
just make a png and try the 3 texture modes and 1 will work im using alpha tga with a .obj file and i use EMT_TRANSPARENT_ALPHA_REF, and it works fine

Posted: Fri Nov 03, 2006 9:40 pm
by hybrid
But the idea is to have the material to be set up by the material file, not manually after that.
The 'Ni' value is unsupported in the Irrlicht loader, do you know what it is good for? The 'd' value is for transparency, but you don't set transparency here (should be < 1.0 then).

Posted: Fri Nov 03, 2006 9:52 pm
by Lideln
Thanks Agony and Hybrid for your answers ! :)

Agony, I will try what you told me, but as Hybrid said, the goal is to load the obj without setting textures on it manually after, so I have to check the mtl file out.

Hybrid, I don't know what the Ni value is for.
I maybe found an explanation on this site :
http://www.fileformat.info/format/material/
Ni optical_density

Specifies the optical density for the surface. This is also known as index of refraction.

"optical_density" is the value for the optical density. The values can range from 0.001 to 10. A value of 1.0 means that light does not bend as it passes through an object. Increasing the optical_density increases the amount of bending. Glass has an index of refraction of about 1.5. Values of less than 1.0 produce bizarre results and are not recommended.
I hope it will help you supporting the Ni value in Irrlicht, if it is of any use ?

This is weird that transparency is not set, because I pushed the "Alpha" buttons in Blender (thought it is true that in the Blender rendering, I don't have transparency neither)

Its hard to find tutorials about textures with transparency (for exemple a "leaf" texture painted on a square face... there will be transparent areas, unless you model the leaf itself I guess...)

Here is what I can say about that.
I will of course keep on testing the different possibilities and keep you informed if I find something interesting and useful for people.

Good night !

Posted: Fri Nov 03, 2006 10:24 pm
by hybrid
Ok, so Ni is not supported by Irrlicht, and also won't be in the next future. Maybe just try to manually change the d value, might work already :wink: then it's simply a question of the modeller.

Posted: Sat Nov 04, 2006 10:13 am
by Lideln
Ok for Ni :)

Yes Ill try to do it, thats true, but I dont want neither the whole texture to become transparent :)

I figured out something yesterday, when trying to display a large level by having multiple "objects" (planes) in the same .obj. I applied stupid textures on it : colored squares with a number written on them (1, 2, etc.), written in BLACK.

I had 9 planes (9 objects then, and then 9 textures). For the first one I used an UVmap, and for the others just an image texture, without UVmap.

I exported in .obj. In irrlicht, the first (with the UVmap) was displayed correctly, but for the others... I could NOT see the number on them ! :shock:

It gave me the idea to try that with my tree, but I did not get the same result (I can upload my project if needed, or just a screenshot) : the 2 planes representing the leafs were the same that at the beginning : one not visible at all (because... I dunno because why... I thing I have turned on double-sided), and the other entirely black (the texture is correctly loaded according to the output)

Posted: Tue Nov 07, 2006 6:13 pm
by xtheagonyscenex
you have to export one at a time or the all use the same uv coards

Posted: Tue Nov 07, 2006 7:43 pm
by Lideln
Hi Agony,

In fact, I exported all of them in one single .obj file, and with 9 different UVmap, and it works fine.
I have just 1 or 2 issues : strange rotation of the mesh, one of the faces is... reversed (like if displayed in a mirror), and the position of the origin is not always good.

But in a general way, it works quite nice I have to admit.
Painting the entire map texture on 9 (or more) different bitmap files will be more difficult I guess :)

Have a nice evening,