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

Fixed OBJ textures #239

Merged
merged 5 commits into from
Feb 11, 2021
Merged

Fixed OBJ textures #239

merged 5 commits into from
Feb 11, 2021

Conversation

jennuine
Copy link
Contributor

@jennuine jennuine commented Feb 9, 2021

Bug Fix

Resolves issue #139 for OBJ files only

Summary

The Ogre 2 plugin uses a texture's filename to uniquely identify each texture, so any textures named texture.png are treated the same, even if they're in different directories. The new change checks to see if the mesh has an OBJ file (model.obj), if it does it sets baseName to be the full path (instead of texture.png).

For example, load this world on ign-gazebo:

world.sdf

<?xml version="1.0" ?>
<sdf version="1.6">
  <world name="shapes">
    <plugin
      filename="ignition-gazebo-physics-system"
      name="ignition::gazebo::systems::Physics">
    </plugin>
    <plugin
      filename="ignition-gazebo-scene-broadcaster-system"
      name="ignition::gazebo::systems::SceneBroadcaster">
    </plugin>

    <gui fullscreen="0">

      <!-- 3D scene -->
      <plugin filename="GzScene3D" name="3D View">
        <ignition-gui>
          <title>3D View</title>
          <property type="bool" key="showTitleBar">false</property>
          <property type="string" key="state">docked</property>
        </ignition-gui>

        <engine>ogre2</engine>
        <scene>scene</scene>
        <ambient_light>1.0 1.0 1.0</ambient_light>
        <background_color>0.8 0.8 0.8</background_color>
        <camera_pose>-6 0 6 0 0.5 0</camera_pose>
      </plugin>
    </gui>

    <light type="directional" name="sun">
      <cast_shadows>true</cast_shadows>
      <pose>0 0 10 0 0 0</pose>
      <diffuse>0.8 0.8 0.8 1</diffuse>
      <specular>0.2 0.2 0.2 1</specular>
      <attenuation>
        <range>1000</range>
        <constant>0.9</constant>
        <linear>0.01</linear>
        <quadratic>0.001</quadratic>
      </attenuation>
      <direction>-0.5 0.1 -0.9</direction>
    </light>

    <model name="ground_plane">
      <static>true</static>
      <link name="link">
        <collision name="collision">
          <geometry>
            <plane>
              <normal>0 0 1</normal>
            </plane>
          </geometry>
        </collision>
        <visual name="visual">
          <geometry>
            <plane>
              <normal>0 0 1</normal>
              <size>100 100</size>
            </plane>
          </geometry>
          <material>
            <ambient>0.8 0.8 0.8 1</ambient>
            <diffuse>0.8 0.8 0.8 1</diffuse>
            <specular>0.8 0.8 0.8 1</specular>
          </material>
        </visual>
      </link>
    </model>

<include>
<uri>
https://fuel.ignitionrobotics.org/1.0/GoogleResearch/models/adizero_F50_TRX_FG_LEA
</uri>
</include>
<include>
<pose>0 0.5 0 0 0 0</pose>
<uri>
https://fuel.ignitionrobotics.org/1.0/GoogleResearch/models/adistar_boost_m
</uri>
</include>
  </world>
</sdf>

2021-02-09T12:48:21 639635366

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See
    contributing)
  • All tests passed (See
    test coverage)
  • While waiting for a review on your PR, please help review
    another open pull request
    to support the maintainers

Note to maintainers: Remember to use Squash-Merge

Signed-off-by: Jenn Nguyen <[email protected]>
Signed-off-by: Jenn Nguyen <[email protected]>
@jennuine jennuine requested a review from chapulina February 9, 2021 20:50
@jennuine jennuine requested a review from iche033 as a code owner February 9, 2021 20:50
@github-actions github-actions bot added the 🏰 citadel Ignition Citadel label Feb 9, 2021
@codecov
Copy link

codecov bot commented Feb 9, 2021

Codecov Report

Merging #239 (bc6d0da) into ign-rendering3 (36bc282) will increase coverage by 0.00%.
The diff coverage is 40.00%.

Impacted file tree graph

@@               Coverage Diff               @@
##           ign-rendering3     #239   +/-   ##
===============================================
  Coverage           50.63%   50.63%           
===============================================
  Files                 129      129           
  Lines               11864    11869    +5     
===============================================
+ Hits                 6007     6010    +3     
- Misses               5857     5859    +2     
Impacted Files Coverage Δ
ogre2/src/Ogre2Material.cc 95.47% <40.00%> (-1.29%) ⬇️
...e/ignition/rendering/base/BaseGaussianNoisePass.hh 100.00% <0.00%> (+3.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 36bc282...b74577d. Read the comment docs.

@chapulina chapulina added the bug Something isn't working label Feb 10, 2021
Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workaround makes the assumption that the model will always have a model.obj file in a meshes directory, which may not always be true. I can't think if a simple alternative though, because at this point in the code we don't know whether the mesh is OBJ or not.

We eventually want to make the baseName = _texture change for all meshes, but we can't do it until SubT is updated to use the same texture file for all duplicates. Considering that this workaround is temporary and meant to at least fix the models from GoogleResearch, which match the current assumptions, I think it's ok to get it in like this.

Do you mind adding aFIXME note about this on the code and a link back to the original issue? Feel free to merge after that's in. Thanks!

@jennuine
Copy link
Contributor Author

@chapulina how does b74577d look? I wasn't sure how specific the comment needed to be

Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the workaround. The FIXME message looks good to me 👍

@chapulina chapulina merged commit 64016f6 into ign-rendering3 Feb 11, 2021
@chapulina chapulina deleted the jennuine/obj_textures branch February 11, 2021 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 🏰 citadel Ignition Citadel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants