Author Topic: How to set texture to object material  (Read 723 times)

Offline jaychang0917

  • int
  • **
  • Posts: 50
    • View Profile
How to set texture to object material
« on: April 05, 2017, 09:42:51 am »
Suppose my model is a composite of objects, and each object contains few materials, I need to map different texture for each material.

I tried to print the name, i can't get the material name but object name. How can I get the material name of each object?
Code: [Select]
for (Animated3D o : skinnedGroup) {
    System.out.println("name:" + o.getName());
    o.build();
    o.discardMeshData();
}
// output
name:headMesh_triangles
name:headMesh_triangles
name:headMesh_triangles
name:headMesh_triangles
name:headMesh_triangles
name:headMesh_triangles
name:headMesh_triangles
name:headMesh_triangles
name:headMesh_triangles
name:headMesh_triangles
name:Cover_LMesh_triangles
name:Cover_LMesh_triangles
name:Cover_RMesh_triangles
...



Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1971
    • View Profile
    • http://www.aptalkarga.com
Re: How to set texture to object material
« Reply #1 on: April 05, 2017, 11:13:12 pm »
you cannot I believe. materials and texture information is not passed to Bones during export-import process. texture coordinates are passed though.

in this case, you can for example bake the materials into a texture and assign that texture to your Animated3D's

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1971
    • View Profile
    • http://www.aptalkarga.com
Re: How to set texture to object material
« Reply #2 on: April 06, 2017, 02:59:45 pm »
video not appearing part may also related to a thread synchronization issue. in particular if you dont consume a video frame new update never arrives (as far as I remember)

Offline jaychang0917

  • int
  • **
  • Posts: 50
    • View Profile
Re: How to set texture to object material
« Reply #3 on: April 07, 2017, 03:55:27 pm »
you cannot I believe. materials and texture information is not passed to Bones during export-import process. texture coordinates are passed though.

in this case, you can for example bake the materials into a texture and assign that texture to your Animated3D's

i tried to set the texture by Animated3D index instead of name, seems work.
Code: [Select]
animatedGroup.get(0).setTexture("head");
animatedGroup.get(1).setTexture("headTop");
animatedGroup.get(2).setTexture("head");
...

Offline jaychang0917

  • int
  • **
  • Posts: 50
    • View Profile
Re: How to set texture to object material
« Reply #4 on: April 07, 2017, 03:56:27 pm »
video not appearing part may also related to a thread synchronization issue. in particular if you dont consume a video frame new update never arrives (as far as I remember)

?? you are answering my qestion? :)

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1971
    • View Profile
    • http://www.aptalkarga.com
Re: How to set texture to object material
« Reply #5 on: April 07, 2017, 04:07:03 pm »
Quote
i tried to set the texture by Animated3D index instead of name, seems work.
Code: [Select]
animatedGroup.get(0).setTexture("head");
animatedGroup.get(1).setTexture("headTop");
animatedGroup.get(2).setTexture("head");
...
nice :)

Quote
Quote
video not appearing part may also related to a thread synchronization issue. in particular if you dont consume a video frame new update never arrives (as far as I remember)

?? you are answering my qestion? :)
nope, sorry, wrong thread, have no idea how this happened :D

Offline jaychang0917

  • int
  • **
  • Posts: 50
    • View Profile
Re: How to set texture to object material
« Reply #6 on: April 11, 2017, 07:09:19 am »
raft, I found that the imported model is not rendered correctly. If the geometry contains multiple elements, it seems only render the first element. Do you have any idea?

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1971
    • View Profile
    • http://www.aptalkarga.com
Re: How to set texture to object material
« Reply #7 on: April 11, 2017, 10:10:29 am »
which pipeline are you using, Collada or Ogre3D?

are you sure it's exported correctly?

Offline jaychang0917

  • int
  • **
  • Posts: 50
    • View Profile
Re: How to set texture to object material
« Reply #8 on: April 11, 2017, 10:20:26 am »
which pipeline are you using, Collada or Ogre3D?

are you sure it's exported correctly?

I am using Collada.

I found that the model is rendered correctly using the ProceduralAnimationBonesSample, is it the jpct-ae problem?

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1971
    • View Profile
    • http://www.aptalkarga.com
Re: How to set texture to object material
« Reply #9 on: April 11, 2017, 11:05:11 am »
interesting, might be jpct-ae

Offline jaychang0917

  • int
  • **
  • Posts: 50
    • View Profile
Re: How to set texture to object material
« Reply #10 on: April 11, 2017, 11:24:23 am »
interesting, might be jpct-ae

Almost all code are the same for desktop and android version except the FrameBuffer object creation.

For android (jpct-ae)
Code: [Select]
frameBuffer = new FrameBuffer(width, height);

For desktop (jpct)
Code: [Select]
frameBuffer = new FrameBuffer(width, height, FrameBuffer.SAMPLINGMODE_NORMAL);

So what approach can i take to solve this problem?
« Last Edit: April 11, 2017, 11:30:50 am by jaychang0917 »

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1971
    • View Profile
    • http://www.aptalkarga.com
Re: How to set texture to object material
« Reply #11 on: April 11, 2017, 11:28:48 am »
may be ask in jpct-AE forum? :)

Offline jaychang0917

  • int
  • **
  • Posts: 50
    • View Profile
Re: How to set texture to object material
« Reply #12 on: April 11, 2017, 12:41:09 pm »
may be ask in jpct-AE forum? :)

I post a new thread in jpct-AE forum, see if you have any idea :)
http://www.jpct.net/forum2/index.php/topic,4878.msg33311.html#msg33311

Offline AGP

  • quad
  • ******
  • Posts: 1524
    • View Profile
Re: How to set texture to object material
« Reply #13 on: May 09, 2017, 02:18:58 pm »
It doesn't seem appropriate now that I've read the rest of the thread, but it's useful to point out the following max script that I use to create texture atlases (it fails 30% of the time but it's still very useful when it works): http://www.scriptspot.com/3ds-max/scripts/texture-atlas-generator