Main Menu

obj world

Started by draga, December 01, 2009, 01:31:25 PM

Previous topic - Next topic

draga

Hello,

I've done a world in obj-format (+mtl file).
In the obj file there are many objects (trees,grasses).

If I now Load by the Loader Class, I get an Array of Object3D.
But how should I now load the textures ( with setTexture()  ) from an Object3D?
I don't know what texture should be assigned to the Object3D...




trisco

#1
http://www.jpct.net/wiki/index.php/Loading_models

this should help you, just make sure the names of the texture in the texturemanager correspond to the one in your obj file.

draga

thanks for your answer.

It seems that JPCT loads the textures automatically...It came always a message that the textures are already defined, after I run my "mtl texture loader"...
By the way...I only have white meshes, textures don't work at me...

Can you say what could be going wrong??

EgonOlsen

No, it doesn't load them. But if you are not loading them BEFORE you are loading the model, it creates white textures with the names from the file. Try to switch the order.

draga

thanks it works ;)

Now I have still a problem:
The Billboards grasses/Trees are jpg files, and the transparent parts are black.
What should I do?

draga

ok, I fixed it by calling setTransparency(2)...
Now a house seems to move magically infront of trees, but in real it isnt so...
Have I to write a editor to make for example the house not calling setTransparency() ?

EgonOlsen

The loaders for 3ds and obj actually load transparency information from the file. If you objects are transparent in the editor, they should be in jPCT. If that's not an option, you need a way to identify if an object should be transparent or not. I'm usually using texture information for this, i.e. all objects that are using a texture "blahblah" are transparent...or use the objects' names instead.

draga

ok, thanks for your answer :)

draga

I have still a few questions:
About which methode(s) I get Information of a object's assigned texture (texture name for example)??

Wojtek

Hi,

The Object3D class has "PolygonManager getPolygonManager()" method, which you can use to get the texture id assigned to given polygon of your object (see "int getPolygonTexture(int polyID)" method of PolygonManager).

Next, you can use TextureManager.getInstance(). getTextureByID(textureId) to get the texture object that is associated to id returned by PolygonManager.

Hope that helps.

BTW. It is not possible to get the list of textures if polygon has more textures assigned.

Wojtek

draga

ok, thanks. I'll try it. ;)