Collada import when nodes share geometry but not material #32240

Closed
opened 2012-08-02 15:43:56 +02:00 by Michael Zeilfelder · 8 comments

%%%When a Collada file contains several nodes which link to the same mesh but each node has it's own material then on import the materials are not created as objects for each node but as shared data for the mesh. Which leads to all nodes having the same material(s) now instead of each node having it's own.

I have attached 2 examples. The first one is a Collada file with 2 cubes which I exported in Irrlicht (a patched version) which pretty much just contains the minimum to reproduce the problem (+ a screenshot to show how it should look like).

The second example is a .blend file which looks pretty similar. To reproduce it with that export it as Collada and then import that Collada file again.
%%%

%%%When a Collada file contains several nodes which link to the same mesh but each node has it's own material then on import the materials are not created as objects for each node but as shared data for the mesh. Which leads to all nodes having the same material(s) now instead of each node having it's own. I have attached 2 examples. The first one is a Collada file with 2 cubes which I exported in Irrlicht (a patched version) which pretty much just contains the minimum to reproduce the problem (+ a screenshot to show how it should look like). The second example is a .blend file which looks pretty similar. To reproduce it with that export it as Collada and then import that Collada file again. %%%

Changed status to: 'Open'

Changed status to: 'Open'

%%%A forgot to write ... the system this was tested on was Blender 2.63.0 (r45996) on Windows 7.%%%

%%%A forgot to write ... the system this was tested on was Blender 2.63.0 (r45996) on Windows 7.%%%
Member

%%%In the standard Collada data there is no way to distinguish between materials assigned to Geometry and materials assigned to Object. Therefore Blender inserts the materials based on the user preferences (yes, you can specify if you want materials to be automatically assigned to Object or to Data).

I tested this and i found that while it works in principle there is still a bug which breaks the material settings. For the "2 cubes testfile" the first material is correctly assigned to the object while the secnd material is assigned to the mesh and the secnd object gets 2 material slots. I am working on that.


I am also thinking about doing some test to determine where the materials have to be bound:

if user preferences are: assign materials to data

  if the current geometry is reused by 2 or more objects and all objects contain the same set of materials in the same order
      then assign the materials to Data
  else
      assign the materials to Object

else

  else assign the materials to the objects

end

Does that make sense ?%%%

%%%In the standard Collada data there is no way to distinguish between materials assigned to Geometry and materials assigned to Object. Therefore Blender inserts the materials based on the user preferences (yes, you can specify if you want materials to be automatically assigned to Object or to Data). I tested this and i found that while it works in principle there is still a bug which breaks the material settings. For the "2 cubes testfile" the first material is correctly assigned to the object while the secnd material is assigned to the mesh and the secnd object gets 2 material slots. I am working on that. **** I am also thinking about doing some test to determine where the materials have to be bound: if user preferences are: assign materials to data ``` if the current geometry is reused by 2 or more objects and all objects contain the same set of materials in the same order then assign the materials to Data else assign the materials to Object ``` else ``` else assign the materials to the objects ``` end Does that make sense ?%%%
Member

%%%@Sergey: i just added the files:

shared_mesh_multiple_mat.blend
shared_mesh_multiple_mat_reimported.blend

To reproduce the problem:

  • in user preferences -> editing: set "Link Materials to Object"
  • open the shared_mesh_multiple_mat.blend
  • verify that the objects have 2 materials both materials assigned to Object
  • export as collada (selection only, keep rest to defaults)
  • clean the scene
  • import the collada
  • you end up with the situation in shared_mesh_multiple_mat_reimported.blend

i use trunk version 49795%%%

%%%@Sergey: i just added the files: shared_mesh_multiple_mat.blend shared_mesh_multiple_mat_reimported.blend To reproduce the problem: - in user preferences -> editing: set "Link Materials to Object" - open the shared_mesh_multiple_mat.blend - verify that the objects have 2 materials both materials assigned to Object - export as collada (selection only, keep rest to defaults) - clean the scene - import the collada - you end up with the situation in shared_mesh_multiple_mat_reimported.blend i use trunk version 49795%%%
Member

%%%I believe that set_mesh() does some wrong assumption...%%%

%%%I believe that set_mesh() does some wrong assumption...%%%
Member

%%%The attached patch fully solves the import issue without any know restrictions.

@any senior developer: Please can you check if the solution is correctly implemented.
Any hint for improvement or an easier (fully working) solution is very appreciated :)%%%

%%%The attached patch fully solves the import issue without any know restrictions. @any senior developer: Please can you check if the solution is correctly implemented. Any hint for improvement or an easier (fully working) solution is very appreciated :)%%%
Member

%%%Committed in revision 49847%%%

%%%Committed in revision 49847%%%
Member

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#32240
No description provided.