Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COLLADA Cube Mesh not Colored #91

Open
jaelrod opened this issue Sep 1, 2020 · 4 comments
Open

COLLADA Cube Mesh not Colored #91

jaelrod opened this issue Sep 1, 2020 · 4 comments
Labels
bug Something isn't working graphics Graphics component help wanted Extra attention is needed

Comments

@jaelrod
Copy link

jaelrod commented Sep 1, 2020

Loading a COLLADA mesh containing a cube with colored surface results in a white cube instead.
mesh.dae.txt

COLLADA loaded in Blender:
image

Same COLLADA loaded in Ignition Gazebo v3.2.0:
image

@chapulina chapulina added bug Something isn't working graphics Graphics component labels Sep 1, 2020
@chapulina chapulina added the help wanted Extra attention is needed label Sep 15, 2020
@ahcorde
Copy link
Contributor

ahcorde commented Jan 13, 2021

Hi @jaelrod,

I have loaded your mesh into Blender and imported again to Collada and I'm able to see the color:

Selección_088

A quick look to your dae file looks like your triangles have no material. You include the material in the triangles:
Replace this line:

        <triangles count="12">

with:

        <triangles material="material-cube" count="12">

Please close the issue if the problem is resolved.

@jaelrod
Copy link
Author

jaelrod commented Jan 13, 2021

Why would <triangles/> be the appropriate place to define the material? If I have a geometries library, I would fundamentally prefer that to be decoupled from the material applied on top of the geometry, which I believe is the inspiration behind the COLLADA specification itself separating the definition of geometry vs. materials. If I want to have a blue cube like this and a cube that is similarly red in hue, I should be able to accomplish that with simply applying a different, red material from library_materials onto the same geometry from library_geometries.

In light of that, I think my application of the material makes more sense where it is in the .dae.txt that I uploaded, in the instantiation of the mesh under the visual_scene, rather than to the triangles themselves:

  <library_visual_scenes>
    <visual_scene id="Scene" name="Scene">
      <node>
        <matrix sid="transform">0.35 0 0 0 0 0.4 0 0 0 0 1 0 0 0 0 1</matrix>
        <instance_geometry url="#mesh-cube">
          <bind_material>
            <technique_common>
              **<instance_material symbol="material" target="#material-cube"/>
            </technique_common>
          </bind_material>
        </instance_geometry>
      </node>
    </visual_scene>
  </library_visual_scenes>

This might seem a bit pedantic, but it does, in fact, make a huge difference for me, as I am composing these assets' information in a rather unconventional way. Since posting this comment, working around this issue has resulted in an order of magnitude increase in size of my COLLADA assets due to repeating equivalent geometries within library_geometries.

As mentioned in the original comment, the exact attached mesh file loads into blender with the material correctly applied to the geometry. Per the COLLADA specification, the material reference within the visual_scene ought to be valid.

@jaelrod
Copy link
Author

jaelrod commented Jan 13, 2021

Khronos Group COLLADA Specification 1.5.0:
https://www.khronos.org/files/collada_spec_1_5.pdf

From Specification – Core Elements Reference 5-61 (page 101):

The <instance_geometry> element instantiates an object described by a element. A
geometry object is instantiated within the local coordinate system of its parent or and
that determines its position, orientation, and scale. COLLADA supports convex mesh, mesh, and spline
primitives.
...
[ <bind_material> ] binds material symbols to material instances. This allows a
single geometry to be instantiated into a scene multiple times
each with a different appearance. See main entry.

From COLLADA – Digital Asset Schema Release 1.5.0 (page 268):

This abstract symbol needs to be bound to a particular material instance. The application does the
instantiation when processing the <instance_geometry> elements within the <bind_material>
elements. The application scans the geometry for material attributes and binds actual material objects to
them as indicated by the <instance_material> (geometry) symbol attributes. See “Example” below.

@ahcorde
Copy link
Contributor

ahcorde commented Jan 15, 2021

Thank you for the explanation @jaelrod

I have created a PR that should fix the issue #151

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working graphics Graphics component help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants