Author Topic: object pivot  (Read 6079 times)

Offline Tishu

  • byte
  • *
  • Posts: 32
    • View Profile
Re: object pivot
« Reply #30 on: January 29, 2012, 01:52:26 pm »

Thanks for your last message, it helped me resolve the issue by looking at the python script used by Blender to export 3DS. Here is what I did, I hope this can help someone...

Firstly, all the keyframe export section was commented out in my version with the following comment
Code: [Select]

I uncommented all the relevant sections, and then checked the flags used. I noticed that the script is using different conventions, and here are the relevant ones:

Code: [Select]
#------ Main Chunks
OBJECTINFO   =      long("0x3D3D",16);      #This gives the version of the mesh and is found right before the material and object information
VERSION      =      long("0x0002",16);      #This gives the version of the .3ds file
KFDATA       =      long("0xB000",16);      #This is the header for all of the key frame info

#>------ sub defines of KFDATA
KFDATA_KFHDR            = long("0xB00A",16);
KFDATA_KFSEG            = long("0xB008",16);
KFDATA_KFCURTIME        = long("0xB009",16);
KFDATA_OBJECT_NODE_TAG  = long("0xB002",16);

#>------ sub defines of OBJECT_NODE_TAG
OBJECT_NODE_ID          = long("0xB030",16);
OBJECT_NODE_HDR         = long("0xB010",16);
OBJECT_PIVOT            = long("0xB013",16);
OBJECT_INSTANCE_NAME    = long("0xB011",16);
POS_TRACK_TAG = long("0xB020",16);
ROT_TRACK_TAG = long("0xB021",16);
SCL_TRACK_TAG = long("0xB022",16);

I checked what values are set for these, and the one that is interesting here POS_TRACK_TAG (0XB020) was forced to zero, as the author of this script uses it as a position and not a rotation center:

Code: [Select]
# meshes have their transformations applied before
# exporting, so write identity transforms here:
    # position vector:
    #track_chunk.add_variable("position", _3ds_point_3d((0.0,0.0,0.0)))

I changed the last line to

Code: [Select]
track_chunk.add_variable("position", _3ds_point_3d(obj.getLocation()))

And all is good now!

Code: [Select]
01-29 12:46:32.024: I/jPCT-AE(23839): Name in hierarchy found: balancier
01-29 12:46:32.034: I/jPCT-AE(23839): Setting rotation pivot of object balancier_jPCT0 to (0.3,-0.3,0.0025380924)

The conventions used in the original python script and in the JPCT loader are questionable as there does not seem to be an "official" 3DS specification, but this works great for Blender/JPCT-AE usage.


Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: object pivot
« Reply #31 on: December 11, 2013, 01:55:26 pm »

How did you make it work? I un-commented the code and it still crashed on Blender v2.69. A lot of errors after that.