OBJ importer in 3.3 does not keep the vertex order #100421

Closed
opened 2022-08-15 20:42:55 +02:00 by Amy Moo · 12 comments

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3060/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 516.40

Blender Version
Broken: version: 3.4.0 Alpha, branch: master, commit date: 2022-08-14 18:40, hash: 659b63751d
Worked: (newest version of Blender that worked as expected)

Short description of error
In order for morph to work in DAZ Studio, the morphed mesh has to have the same number of vertices and faces, and the same order of the vertices. This is the reason I asked for it many years ago, see https:*developer.blender.org/T27145 and https:*developer.blender.org/T36159. Therefore, it is not an issue for the Wavefront (.obj) (legacy) importer or exporter.

Exact steps for others to reproduce the error

  • Start with cube, subdivide it 10x in edit mode
  • Export cube as .obj and import it.
  • Move imported cube next to original
  • Create basis shape key and another shape key.
  • Enter edit mode, select all vertices, run checker deselect operator and scale selected vertices a bit, exit edit mode.
  • Select original cube
  • Create basis shape key
  • Add duplicate cube to selection

Use transfer shape key operator to copy shape key from duplicate to original.

Untitled.png
Left cube is imported duplicate with desired keyshape, right cube is after step 9.

**System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 3060/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 516.40 **Blender Version** Broken: version: 3.4.0 Alpha, branch: master, commit date: 2022-08-14 18:40, hash: `659b63751d` Worked: (newest version of Blender that worked as expected) **Short description of error** In order for morph to work in DAZ Studio, the morphed mesh has to have the same number of vertices and faces, and the same order of the vertices. This is the reason I asked for it many years ago, see https:*developer.blender.org/T27145 and https:*developer.blender.org/T36159. Therefore, it is not an issue for the Wavefront (.obj) (legacy) importer or exporter. **Exact steps for others to reproduce the error** - Start with cube, subdivide it 10x in edit mode - Export cube as .obj and import it. - Move imported cube next to original - Create basis shape key and another shape key. - Enter edit mode, select all vertices, run checker deselect operator and scale selected vertices a bit, exit edit mode. - Select original cube - Create basis shape key - Add duplicate cube to selection # Use transfer shape key operator to copy shape key from duplicate to original. ![Untitled.png](https://archive.blender.org/developer/F13390898/Untitled.png) Left cube is imported duplicate with desired keyshape, right cube is after step 9.
Author

Added subscriber: @amy_aimei

Added subscriber: @amy_aimei
Author

Additional information:
I have tested the build on Aug 6 (800c7dbf41). It works. Therefore, it must be the changes after that date cause the issue.

Additional information: I have tested the build on Aug 6 (800c7dbf41a2). It works. Therefore, it must be the changes after that date cause the issue.

Added subscriber: @aras_p

Added subscriber: @aras_p

@amy_aimei Can you attach the sample files? i.e. the obj file you get from step 2 (what's exported from daz), and the obj file you get from step 6 (what's exported out of blender after modifications)

@amy_aimei Can you attach the sample files? i.e. the obj file you get from step 2 (what's exported from daz), and the obj file you get from step 6 (what's exported out of blender after modifications)
Author

I've made a simple way to check and the issue seems to be located in the importer code. I wrote a Python script in Blender to list the vertices in order with the corresponding coordinate. Then, use the Wavefront (.obj) (legacy) importer with the "Keep Vert Order" option enabled to import the file. Use the script to list the vertices in order with the corresponding coordinate. It is the baseline, i.e., the correct vertices order. Then, export it with Wavefront (.obj). Then, import it back using Wavefront (.obj) (legacy). Use the script to list the vertices. I noticed that it is fine. This means the exporter is fine. But when I used the Wavefront (.obj) to import the obj, then export it by using Wavefront (.obj) (legacy). Then, import it back using Wavefront (.obj) (legacy). Use the script to list the vertices. I noticed the coordinates don't match. This means the vertices order is not being preserved when it is imported. The issue at the importer code.

I guess, the issue is caused by the change https://developer.blender.org/rBd76583cb4a16315c196f07f4acb9340f341bee47

I've made a simple way to check and the issue seems to be located in the importer code. I wrote a Python script in Blender to list the vertices in order with the corresponding coordinate. Then, use the Wavefront (.obj) (legacy) importer with the "Keep Vert Order" option enabled to import the file. Use the script to list the vertices in order with the corresponding coordinate. It is the baseline, i.e., the correct vertices order. Then, export it with Wavefront (.obj). Then, import it back using Wavefront (.obj) (legacy). Use the script to list the vertices. I noticed that it is fine. This means the exporter is fine. But when I used the Wavefront (.obj) to import the obj, then export it by using Wavefront (.obj) (legacy). Then, import it back using Wavefront (.obj) (legacy). Use the script to list the vertices. I noticed the coordinates don't match. This means the vertices order is not being preserved when it is imported. The issue at the importer code. I guess, the issue is caused by the change https://developer.blender.org/rBd76583cb4a16315c196f07f4acb9340f341bee47
Author

The script I used to list the vertices in order with the corresponding coordinate:
(Select the object to check before running the script.)

import bpy

currMode = bpy.context.active_object.mode
bpy.ops.object.mode_set(mode='OBJECT')
targetMesh = bpy.context.active_object.data
targetVerts = targetMesh.vertices
for targetVert in targetVerts:
  print(targetVert.index, targetVert.co)
bpy.ops.object.mode_set(mode=currMode)
The script I used to list the vertices in order with the corresponding coordinate: (Select the object to check before running the script.) ``` import bpy currMode = bpy.context.active_object.mode bpy.ops.object.mode_set(mode='OBJECT') targetMesh = bpy.context.active_object.data targetVerts = targetMesh.vertices for targetVert in targetVerts: print(targetVert.index, targetVert.co) bpy.ops.object.mode_set(mode=currMode) ```
Author

The obj I used to test{F13389325}

The obj I used to test{[F13389325](https://archive.blender.org/developer/F13389325/temp.obj)}

Added subscriber: @iss

Added subscriber: @iss

Can confirm this, and since Blender can do this with shape keys, I will update description to eliminate need for 3rd party software

Can confirm this, and since Blender can do this with shape keys, I will update description to eliminate need for 3rd party software

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Aras Pranckevicius self-assigned this 2022-08-16 06:56:51 +02:00
Aras Pranckevicius changed title from OBJ importer/exporter does not keep the vertice order to OBJ importer in 3.3 does not keep the vertex order 2022-08-16 06:57:29 +02:00

This issue was referenced by efdcef7855

This issue was referenced by efdcef7855e378bc3183ceab16e17f3dfd8e3c76

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Bastien Montagne added this to the Pipeline, Assets & IO project 2023-02-09 15:40:02 +01:00
Bastien Montagne removed this from the Pipeline, Assets & IO project 2023-02-10 12:49:18 +01:00
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
Interest: X11
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
4 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#100421
No description provided.