OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Add search location for textures in FBX plugin


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Submission
View previous topic :: View next topic  
Author Message
bbjorn
Appreciator


Joined: 12 Oct 2010
Posts: 221
Location: Linköping, Sweden

PostPosted: Mon Feb 04, 2019 2:22 pm    Post subject:
Add search location for textures in FBX plugin
Reply with quote

Hi,

This change is sent as pull request #710

The FBX plugin may fail texture lookup even if the texture is located in the same folder as the model file. Currently the plugin checks the following locations:

1. The absolute filename appended to the current directory (Works well when the absolute filename is a pure filename, but fails when the absolute filename is a complete path)

2. The absolute filename only. (Works well assuming the texture can be found at exactly this complete path).

3. The relative filename appended to the current directory (requires that the texture is placed at exactly in the same relative location to the model as the file was saved in).

Some examples of success and failure:
In all examples below I assume we load the FBX file from the path: "D:\application\models\cow.fbx"

Case 1: The author of the FBX model have saved the model in such way that the stored absolute filename is "cowskin.tga". The plugin will then try to find the model in path: D:\application\models\cowskin.tga".
- Potential failure case: The author of the FBX model have saved the model with a full absolute path such as "c:\model\cow\texture\cowskin.tga" and our plugin will then try to lookup path "D:\application\models\c:\model\cow\texture\cowskin.tga" which will fail.


Case 2: The author of the FBX file have included a full path in the absolute path "c:\model\cow\texture\cowskin.tga" and this is the path the second option will try.


Case 3: The author of the FBX file have saved the file to the path "c:\model\cow\cow.fbx" while the texture was stored in "c:\model\cow\texture\cowskin.tga". This usually results in the FBX exporter assigning the relative path: "texture\cowskin.tga". The plugin will then try to lookup the texture in the folder "D:\application\models\texture\cowskin.tga"
- Potential failure case: The author of the FBX file have stored the texture in a far away folder, for example "c:\textures\animals\cow\cowskin.tga". This will result in the relative path: "..\..\..\textures\cow\cowskin.tga". The plugin will then try to lookup the texture in the folder: "D:\application\models\..\..\..\textures\cow\cowskin.tga" which will be an invalid location (i.e. one more parent folder than what is available).


This pull request adds a fourth option as a last resort:

4. The pure filename part of the absolute filename (i.e. without any paths) appended to the current directory. This will look in the same folder as the model is stored in.


Regards,
Björn
Back to top
View user's profile Send private message Visit poster's website
bbjorn
Appreciator


Joined: 12 Oct 2010
Posts: 221
Location: Linköping, Sweden

PostPosted: Mon Feb 04, 2019 2:45 pm    Post subject:
Reply with quote

Sorry, the last failure case was wrong

Let me try again: Failure case for the 3rd case:

The author of the FBX file have stored the model in a far away folder compared to the texure, for example the model in"c:\model\animal\cow\cow.fbx" while the texture is in "c:\texture\cow\cowskin.tga". The resulting relative path will then be "..\..\..\texture\cow\cowskin.tga".

If the resulting FBX model is stored in the path "D:\application\models\cow.fbx", then the plugin will try to lookup in "D:\application\models\..\..\..\texture\cow\cowskin.tga", i.e. it tried to move to a parent directory three times which is impossible.

Regards,
Björn
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Submission All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts OSG GLTF loader plugin Chris Hanson General 0 Thu Dec 06, 2018 9:55 pm View latest post
No new posts playing videos with audio channels wi... Trajce Nikolov NICK General 7 Wed Nov 21, 2018 9:17 pm View latest post
No new posts Could not find plugin to load objects sdef General [3rdparty] 1 Sat Oct 27, 2018 6:10 am View latest post
No new posts Osgdem created terrains not displayin... D.J. Caldwell General 3 Wed Oct 24, 2018 7:32 pm View latest post
No new posts osg3.6.3 plugin issues jaisingla Plugins [osgPlugins] 2 Thu Oct 18, 2018 6:35 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP