Page MenuHome

IO_scene_3ds: Ported 3ds import & export to Blender 2.82
Needs ReviewPublic

Authored by Sebastian Sille (nrgsille) on Apr 16 2020, 5:36 PM.

Details

Summary

Ported 3ds import and export to Blender 2.82

T66329 T50620

Export 3ds:

  • added percent subchunk
  • added specularity and reflection
  • tesselation to loop triangles
  • uv list from triangle loops
  • material index from polygons
  • fixed matrix translation
  • fixed transformation matrix
  • fixed matrix multiplication
  • fixed syntax errors
  • moved import modules to the start of the script
  • added alpha data and material property
  • fixed texture mapping
  • added texture blur
  • added texture percentage
  • added secondary texture
  • uv texture support via principled BSDF
  • alternative uv image from paint slots
  • Masterscale Element added
  • deactivated evaluated depsgraph
  • fixed 3ds_string output from byte to string
  • added smooth groups
  • added reflection map
  • added roughness map
  • added emission map
  • added bump percent
  • added alpha flag
  • added tint flags
  • added tint colors
  • added light object
  • added camera object
  • fixed export timer

Import 3ds:

  • import math
  • advanced material shader support
  • added roughness
  • added specular
  • added metallic
  • added reflection map
  • added roughness map
  • added emission map
  • added bump percent
  • fixed ambient color
  • fixed specular color
  • added alpha flag
  • added tint flags
  • added tint colors
  • added texture percentage
  • texture angle to rotation mapping
  • added light color
  • added light intensity
  • added spotlight parameters
  • added color track tag
  • added camera
  • added cam target triangulation
  • added optional keyframe reading
  • cleanup

Here is a screenshot of the node structure.
It is a 3ds file with textures for diffuse, specular, opacity, shininess, reflection, emission and bumpmap.
As an extra it also supports now secondary texures, wich are not connected to principled bsdf - the exporter will take them from mixshaders and the importer creates a mixshader for main textures.
The import matches with the exported file and can be exported with the same result ;)
The other pic is my testmodel - lights are also supported now including color and position

here are the chunks from a simple cube with all textures linked to bsdf the last one is the keyframer, wich also works, but therefore the matrix translation of a child has to be related to the parent.

Diff Detail

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

preventing division thru zero

other method for triangulating - no zero division exception

Sebastian Sille (nrgsille) edited the summary of this revision. (Show Details)

now even better camera triangulation in importer

changed default percentage for textures

connected secondary texture to UV map

fixed camera lens values

Import/Export

now tested in Blender 2.83 without problems

added triangulated camera target to 3ds exporter

now all camera positions and focus is fixed

added ambient color (equal with blender world color)

added more light features
added spotlight with target and roll angle

Sebastian Sille (nrgsille) edited the summary of this revision. (Show Details)

added importing spotlight features and other light parameters

forgot to fix lens values again

@Campbell Barton (campbellbarton):

this is finished now - got nothing more to add here ^^

inverted rotation values for triangulation (at least on axis is inverted)

Sebastian Sille (nrgsille) edited the summary of this revision. (Show Details)

one thing left:
Added option to read keyframe data in the _init file and the 3ds importer

pivot data has no keyframes, so it can be readed

fixed light energy value - must be multiplied with 1000

found out, that the beam angles have to be recalculated

beam angle fix: beam angles have to be in degrees not radiant

fixed hotspot beam angle

Finally got precise spot and camera triangulation. Had to get the hypotenuse from pytagoras for the z axis^^

also fixed target triangulation in the 3ds importer (not easy to keep negative signs, but solved)^^

prevent from getting zero degree beam angle for hotspot in the 3ds exporter

changed beam angles to rounded values

fixed a Non-Type Error in importer

preeventing None-Type Errors, if Empty objects are proceeded

more safety triangulation for 90 degree angles

coverting beamangle from degrees to radians

Changed trigonometry calculation.
Cosinus seems to work better than Pythagoras

@Campbell Barton (campbellbarton)

I have tested this code now with version 2.83 - would you have a look? I think it can be released now

fixed another non-type error if emptys are proceeded

preventing zero division in trigonometry calculation

changed to best trigonometry method I found

fixed spotlight triangulation

@Sebastian Sille (nrgsille), would you be interested to have commit access to the add-ons repository to maintain this add-on?

@Sebastian Sille (nrgsille), would you be interested to have commit access to the add-ons repository to maintain this add-on?

Yes, would make sense. The keyframer section of the exporter still has to be done. maybe I got time to fix that later. Have you tested the code?

found a little error in the chunk definitions

fixed non-type error in world color if no world is used

fixed some wrong intends

Fixeed keyframe chunk definitions

changed object list to square brackets, otherwise no objects get exported

fixed another None Type error in importer - do not know where that None type is coming from