Author Topic: obj world  (Read 4988 times)

Offline draga

  • byte
  • *
  • Posts: 20
    • View Profile
obj world
« on: December 01, 2009, 01:31:25 pm »
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...




Offline trisco

  • byte
  • *
  • Posts: 23
    • View Profile
Re: obj world
« Reply #1 on: December 01, 2009, 01:53:27 pm »
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.
« Last Edit: December 03, 2009, 09:09:18 pm by EgonOlsen »

Offline draga

  • byte
  • *
  • Posts: 20
    • View Profile
Re: obj world
« Reply #2 on: December 09, 2009, 08:44:13 pm »
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??

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: obj world
« Reply #3 on: December 09, 2009, 10:11:12 pm »
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.

Offline draga

  • byte
  • *
  • Posts: 20
    • View Profile
Re: obj world
« Reply #4 on: December 10, 2009, 10:08:21 am »
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?

Offline draga

  • byte
  • *
  • Posts: 20
    • View Profile
Re: obj world
« Reply #5 on: December 10, 2009, 01:43:49 pm »
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() ?
 

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: obj world
« Reply #6 on: December 10, 2009, 08:21:02 pm »
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.

Offline draga

  • byte
  • *
  • Posts: 20
    • View Profile
Re: obj world
« Reply #7 on: December 10, 2009, 08:29:49 pm »
ok, thanks for your answer :)

Offline draga

  • byte
  • *
  • Posts: 20
    • View Profile
Re: obj world
« Reply #8 on: December 14, 2009, 03:21:11 pm »
I have still a few questions:
About which methode(s) I get Information of a object's assigned texture (texture name for example)??

Offline Wojtek

  • int
  • **
  • Posts: 62
    • View Profile
Re: obj world
« Reply #9 on: December 14, 2009, 07:02:13 pm »
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

Offline draga

  • byte
  • *
  • Posts: 20
    • View Profile
Re: obj world
« Reply #10 on: December 15, 2009, 10:45:55 am »
ok, thanks. I'll try it. ;)