Skip to content
Queatz edited this page Mar 22, 2012 · 1 revision

Export Options

  • Use low-precision floats
  • Include uv textures
  • Include vertex colors
  • Include modifiers
  • Include constraints
  • Include names
  • Include world
  • There are more

Types

Bold = Object
Italic = Property
[type, type] or [type] is how it's packed and unpacks.

For subclassed types, size() has to return the super class's size() added in, as well as the bytes.

If a List is empty, always set it to None rather than an empty list, so it doesn't have to be created.

Always pack multiple bools into 1 byte, even if not stated.

Most types here are not mutable, but some are. Subclass Type whenever possible.

Helper Types

  • List
    • members [many id, list of Type]
  • String
    • string [str]
  • File
    • path [id, String]

Standard Definitions List

The SDL follows closely the structure of Blender, with a few exceptions:

  • Only what is currently in use is saved. So if you export a Halo material you lose all settings of that material that were for Solid.

  • As many types as possible are independent and can be linked to multiple objects. Such as:

    • Modifiers
    • Constraints
    • CustomCurves
    • ColorRamps
  • Animation is entirely separate. It is done through Animation objects that link anything with an Action. The result is -4 bytes for everything that doesn't use animation, and +4 bytes for everything that does.

  • Materials are always linked directly instead of by index.

  • Many things are more modular, such as material shaders and lamp falloffs.

  • Other small things

    • CurveMaps don't store min/max, just the hard value.

Naming Convention

Subclasses append their superclass's name to their's.

  • ForceField
    • RangedForceField
      • AirRangedForceField

Attribute objects append their name after the name of the object they are an attribute of.

  • ForceField

    • attribute [id, ForceFieldAttribute]
  • ForceFieldAttribute

    • attributes

The Standard Definitions List


  • Animation

    • action [id, Action]
    • user [id]
  • Keyframe

    • point [Vec2]
    • interpolation [byte, str]
      • 0, "constant"
      • 1, "linear"
      • 1, "bezier"
    • leftHandle [Vec2]
    • rightHandle [Vec2]
  • FCurve

    • datapath [short]
    • keyframes [id, List]
    • extrapolation [byte, str]
      • 0, "constant"
      • 1, "linear"
    • modifiers [id, List]
  • FCurveModifier

    • blendIn [float]
    • blendOut [float]
    • frameStart [float]
    • frameEnd [float]
    • influence [float]
    • ranged [byte, bool]
    • GeneratorFCurveModifier
      • additive [float]
      • FactorizedPolynomialGeneratorFCurveModifier
        • coefficients [floats, list of float]
      • ExpandedPolynomialGeneratorFCurveModifier
        • Same as Factorized
    • BuiltInFunctionFCurveModifier
      • type [byte, str]
        • 0, "sine"
        • 1, "cosine"
        • 2, "tangent"
        • 3, "square root"
        • 4, "natural logarithm"
        • 5, "normalized sine"
      • amplitude [float]
      • phaseMultiplier [float]
      • phaseOffset [float]
      • valueOffset [float]
    • EnvelopeFCurveModifier
      • referenceValue [float]
      • phaseOffset [float]
      • valueOffset [float]
      • points [floats, list of BuiltInFunctionFCurveModifierControlPoint] Make this type just have 3 float attributes: frame, min, max. This type doesn't go in the defs list. Define it within the EnvelopeFCurveModifier class.
    • CyclesFCurveModifier
      • beforeMode [byte, str]
        • 0, "none"
        • 1, "repeat motion"
        • 2, "repeat with offset"
        • 3, "repeat mirrored"
      • afterMode [byte, str]
        • Same as beforeMode
      • beforeCycles [short]
      • afterCycles [short]
    • NoiseFCurveModifier
      • blendMode [byte, str]
        • 0, "replace"
        • 1, "add"
        • 2, "subtract"
        • 3, "multiply"
      • scale [float]
      • phase [float]
      • strength [float]
      • depth [unsigned short] it's '=H'
    • PythonFCurveModifier
      • It's not implemented in Blender
    • LimitsFCurveModifier
      • limitMinimumX [byte, bool] Pack all [byte, bool] into the same byte
      • limitMinimumY [byte, bool]
      • limitMaximumX [byte, bool]
      • limitMaximumY [byte, bool]
      • minimumX [float]
      • minimumY [float]
      • maximumX [float]
      • maximumY [float]
    • SteppedFCurveModifier
      • stepSize [float]
      • stepOffset [float]
      • stepOffset [float]
      • Note: check for the Use Start/End Frame options and setstart/end frame to zero if unchecked.
  • Action

    • name [id, String]
    • fcurves [id, List]
  • Object

    • name [id, String]
    • data [id]
    • parent [id, Object]
    • location [id, Vec3]
    • rotation [id, Vec3]
    • scale [id, Vec3]
    • modifiers [id, List]
    • constraints [id, List]
  • Armature

  • PoseBone

  • Camera

    • type [byte, str]
      • 0, "perspective"
      • 1, "orthographic"
    • lens [float]
    • near [float]
    • far [float]
    • focus [id, Object]
  • Geometry

    • offset [float]
    • extrude [float]
    • bevelDepth [float]
    • bevelResolution [int]
    • bevelObject [id, Object]
    • taperObject [id, Object]
    • caps [byte, bool]
  • Shape

    • resolution [int]
    • fill [byte, str]
      • 0, "none"
      • 1, "back"
      • 2, "front"
      • 3, "both"
  • Curve

    • splines [id, List]
    • materials [id, List]
    • shape [id, Shape]
    • geometry [id, Geometry]
  • SplinePoint

    • coordinates [Vec3]

    • radius [float]

    • tilt [float]

    • weight [float]

    • BezierSplinePoint

      • leftHandle [Vec3]
      • rightHandle [Vec3]
      • leftHandleType [byte, str]
        • 0, "free"
        • 1, "vector"
        • 2, "aligned"
        • 3, "auto"
      • rightHandleType [byte, str]
        • Same as left handle.
  • Spline

    • points [id, List] This is a List of either BezierSplinePoints or SplinePoints.
    • material [id, Material]
  • Font

    • name [id, String]
    • file [id, File]
  • Paragraph

    • align [byte, str]
      • 0, "left"
      • 1, "center"
      • 2, "right"
      • 3, "justify"
      • 4, "flush"
    • characterSpacing [float]
    • wordSpacing [float]
    • lineSpacing [float]
    • offset [Vec2]
  • TextBox

    • width [float]
    • height [float]
    • x [float]
    • y [float]
  • Text

    • string [id, String]
    • shape [id, Shape]
    • geometry [id, Geometry]
    • paragraph [id, Paragraph]
    • font [id, Font]
    • size [float]
    • sheer [float]
    • boxes [id, List of TextBox]
  • Bone

    • name [id, String]
    • parent [id, Armature or Bone]
    • head [Vec3]
    • tail [Vec3]
    • inheritRotation [byte, bool] Note, these two can be stored in the same byte.
    • inheritScale [byte, bool]
  • ForceFieldKink

    • axis [bool, str]
      • 0, 'x'
      • 1, 'y'
      • 2, 'z'
    • frequency [float]
    • amplitude [float]
    • shape [float]
    • CurlForceFieldKink
    • RadialForceFieldKink
    • WaveForceFieldKink
    • BraidForceFieldKink
    • RotationForceFieldKink
    • RollForceFieldKink
  • ForceField

    • parent [id, Object]
    • RangedForceField
      • noise [float]
      • seed [int]
      • falloff [byte, str]
        • 0, "sphere"
        • 1, "tube"
        • 2, "cone"
      • direction [byte, str]
        • 0, "negative"
        • 1, "both"
        • 2, "positive"
      • power [float]
      • minimun [float]
      • maximun [float]
      • effectLocation [byte, bool] Note, these three can be saved in the same byte.
      • effectRotation [byte, bool]
      • collides [byte, bool]
      • AirRangedForceField
        • shape [byte, str]
          • 0, "point"
          • 1, "plane"
        • strength [float]
        • flow [float]
        • ForceAirRangedForceField
        • WindAirRangedForceField
        • VortexAirRangedForceField
        • MagneticAirRangedForceField
        • ChargeAirRangedForceField
        • LennardJonesAirRangedForceField
        • BoidAirRangedForceField
        • TurbulenceAirRangedForceField
          • size [float]
          • global [byte, bool]
      • HarmonicRangedForceField
        • strength [float]
        • damping [float]
        • restLength [float]
        • multipleSprings [byte, bool]
      • TextureRangedForceField
        • strength [float]
        • texture [id, Texture]
        • nabla [float]
        • useObjectCoordinates [byte, bool] Pack 'em together
        • useRootCoordinates [byte, bool]
        • 2d [byte, bool]
    • CurveGuideForceField
      • minimum [float]
      • maximum [float]
      • free [float]
      • falloffPower [float]
      • clumpingAmount [float]
      • clumpingShape [float]
      • additive [byte, bool]
      • weights [byte, bool]
      • kink [id, *ForceFieldKink]
  • Constraint
    Either find them here http://www.blender.org/documentation/blender_python_api_2_62_release/bpy.types.html or in Blender.

    All these have various settings that need to be implemented. Do these once you get the hang of things.

    • name [id, String]

    • CameraSolverConstraint

    • ObjectSolverConstraint

    • FollowTrackConstraint

    • CopyLocationConstraint

    • CopyRotationConstraint

    • CopyScaleConstraint

    • CopyTransformsConstraint

    • LimitDistanceConstraint

    • LimitLocationConstraint

    • LimitRotationConstraint

    • LimitScaleConstraint

    • MaintainVolumeConstraint

    • TransformationConstraint

    • ClampToConstraint

    • DampedTrackConstraint

    • InverseKinematicsConstraint

    • LockedTrackConstraint

    • SplineIKConstraint

    • StretchToConstraint

    • TrackToConstraint

    • ActionConstraint

    • ChildOfConstraint

    • FloorConstraint

    • FollowPathConstraint

    • PivotConstraint

    • RigidBodyJointConstraint

    • ShrinkwrapConstraint

  • Group

    • name [id, String]
    • objects [id, List]
  • RayShadow

    • color [id, Vec3]
    • samples [short]
    • soft [float]
  • BufferShadow

    • color [id, Vec3]
    • samples [short]
    • soft [float]
    • bias [float]
    • buffers [short]
    • size [short]
    • start [float]
    • end [float]
  • CurveMap

    • points [bytes, list]
      Repeat until end of bytes is reached.
      This should be Vec2's packed together, and Vec2's in a list when unpacked.
      Make sure to make CurveMaps of MutableType.
      Also, make sure the values are mapped correctly with the range
  • LampFalloff

    • distance [float]
    • *ConstantLampFalloff
    • InverseLinearLampFalloff
    • InverseSquareLampFalloff
    • CustomLampFalloff
      • curve [id, Curve]
    • LinearQuadraticWeightedLampFalloff
      • linear [float]
      • quadratic [float]
  • Lamp

    • color [Vec3]
    • negative [byte, bool] These three bools go in one and the same byte.
    • specular [byte, bool]
    • diffuse [byte, bool]
    • shadow [id, None or RayShadow or BufferShadow]
    • AreaLamp
      • distance [float]
      • gamma [float]
    • SpotLamp
      • falloff [id, *LampFalloff]
      • spotSize [float]
      • spotBlend [float]
      • haloIntensity [float] If the Halo option is unchecked, set this to 0, regardless.
      • shape [byte, str]
        • 0, "round"
        • 1, "square"
    • PointLamp
      • falloff [id, *LampFalloff]
    • DirectionalLamp
    • HemisphereLamp
  • ColorRamp

    • interpolation [byte, str]
      • 0, "constant"
      • 1, "linear"
      • 2, "b-spline"
      • 3, "cardinal"
      • 4, "ease"
    • elements [floats, list of ColorRampElement]
      • ColorRampElement should have 1 float member 'position' and 1 Vec4 'color'.
  • Shader

    • color [id, Vec3 or ColorRamp]

    • intensity [float]

    • LambertDiffuseShader

    • OrenNayerDiffuseShader

      • roughness [float]
    • ToonDiffuseShader

      • size [float]
      • smooth [float]
    • MinnaertDiffuseShader

      • darkness [float]
    • FresnelDiffuseShader

      • fresnel [float]
      • factor [float]
    • CookTorrSpecularShader

      • hardness [float]
    • PhongSpecularShader

      • hardness [float]
    • BlinnSpecularShader

      • hardness [float]
      • ior [float]
    • ToonSpecularShader

      • size [float]
      • smooth [float]
    • WardisoSpecularShader

      • slope [float]
  • SolidMaterialTransparency

    • alpha [float]
    • fresnel [float]
    • fresnelFactor [float]
    • specular [float]
  • SolidMaterial

    • diffuse [id, *Shader]
    • specular [id, *Shader]
    • emission [float]
    • ambient [float]
    • translucency [float]
    • shadeless [byte, bool]
    • tangentShading [byte, bool]
    • transparency [id, None or SolidMaterialTransparency]
    • textures [id, List of TextureSlot]
  • TextureSlot

    • texture [id, Texture]
    • mapping [id, TextureMapping]
    • influence [id, TextureInfluence]
  • TextureMappingCoordinates

    • GlobalTextureMappingCoordinates
    • ObjectTextureMappingCoordinates
      • object [id, Object]
      • fromOriginal [byte, bool]
    • GeneratedTextureMappingCoordinates
    • UVTextureMappingCoordinates
      • map [short]
    • ParticleTextureMappingCoordinates
    • StickyTextureMappingCoordinates
    • WindowTextureMappingCoordinates
    • NormalTextureMappingCoordinates
    • ReflectionTextureMappingCoordinates
    • TangentTextureMappingCoordinates
    • StressTextureMappingCoordinates
  • TextureMapping

    • coordinates [id, *TextureMappingCoordinates]
    • offset [Vec3]
    • size [Vec3]
    • mapping [byte, str]
      • unpacks to "XYZ" "YXZ" etc. store three 2-byte ints.
    • projection [byte, str]
      • 0, 1, 2, 3 = flat, cube, tube, sphere
  • TextureInfluence

    • See the Influence panel. Everything on there should be done in the same way as others here were done. Check for all the booleans and set their respective to 0 if they're not checked (don't save these booleans.) The Negative and Stencil booleans should be saved.
  • Texture

    Figure all these out. Shouldn't be hard, they each have their own box in Blender with the same name (Noise has none.)

    • color [id, None or ColorRamp]
    • BlendTexture
    • CloudsTexture
    • DistortedNoiseTexture
    • EnvironmentMapTexture
    • ImageTexture
    • FilmTexture
    • MarbleTexture
    • MusgraveTexture
    • NoiseTexture
    • PointDensityTexture
    • StucciTexture
    • VoronoiTexture
    • VoxelTexture
    • WoodTexture
    • OceanTexture
  • Modifier
    Either find them here http://www.blender.org/documentation/blender_python_api_2_62_release/bpy.types.html or in Blender.
    See the Constraints for more comments.

    • name [id, String]

    • ArrayModifier

    • BevelModifier

    • BooleanModifier

    • BuildModifier

    • DecimateModifier

    • EdgeSplitModifier

    • MaskModifier

    • MirrorModifier

    • MultiresolutionModifier

    • RemeshModifier

    • ScrewModifier

    • SolidifyModifier

    • SubdivisionSurfaceModifier

    • ArmatureModifier

    • CastModifier

    • CurveModifier

    • DisplaceModifier

    • HookModifier

    • LatticeModifier

    • MeshDeformModifier

    • ShrinkwrapModifier

    • SimpleDeformModifier

    • SmoothModifier

    • WarpModifier

    • WaveModifier

    • ClothModifier

    • CollisionModifier

    • DynamicPaintModifier

    • ExplodeModifier

    • FluidSimulationModifier

    • OceanModifier

    • ParticleInstanceModifier

    • ParticleSystemModifier

    • SmokeModifier

    • SoftBodyModifier

  • ParticleSystem

    This should take a while.

    Split 'em up into different objects. Basically one object per panel in Blender. Leave Cache and Display off. Link force fields directly to ForceField object. The "Advanced" checkbox should map to an AdvancedHairSettings object, which just contains id links to ParticleSystemVelocity, Rotation, and Physics.

    • HairParticleSystem
    • EmitterParticleSystem
  • Mesh

    The hardest one. :)

    First the common place stuff:

    • name [id, String]

    • materials [id, List]

      Next is space-saving intensity and a little header.

      Unpacked, Meshes look like this, with the exception that if any of these are empty they are non-existent:

    • vertices [list of Vec3]

    • faces (incl. edges) [list of [list of int]]

    • uvs [list of [list of Vec2]]

    • vertexGroups [list of [list of VertexWeight(float, int)]]

    • vertexColors [list of [list of Vec3]]

    Packed, they should look something like:

      [low_precision?] # If low precision, the following will all be halfs instead of floats
      [facesize] # If all faces contain less than 15 vertices, use 4-bit ints, <255 vertices use ubytes, else ushorts, else uint
      [number_of_vertices]
      
      [3 halfs] [3 halfs] [3 halfs] [3 halfs] ... # The vertices
      
      # After reading number_of_vertices * 3 * halfsize, we arrive at the face list
      [ubyte] [ubyte] [ubyte] [ubyte] [ubyte] # blocks of facesize to determine the number of vertices in each face
      # We read until a senteniel of 0 is reached
      # Next we read vertice indexes according to the face sizes we found above
      [ushort] [ushort] [ushort] [ushort] [ushort] # if number_of_vertices < 255 use ubyte, else ushort, else uint
      
      # If the next ushort is 0 then we don't have uv maps, so skip this section.  Otherwise:
      [ushort number_of_uv_maps]
      [half half] [half half] [half half] # For each vertex, in accordance with low_precision.
      
      # If the next ushort is 0 then we don't have vertex groups, so skip this section.  Otherwise:
      [ushort number_of_vertex_groups]
      [ushort] [half] [ushort] [half] [ushort] [half] # In accordance with low_precision and number_of_vertices.
      # Until a 0 ushort is reached.  Repeat until number_of_vertext_groups is reached.
      
      # If the next ushort is 0 then we don't have vertex colors, so skip this section.  Otherwise:
      [ushort number_of_vertex_colors]
      [half half half] # For each vertex and in accordance with low_precision.
      # Until a 0 ushort is reached.  Repeat until number_of_vertex_colors is reached.
    
  • Scene

    • name [id, String]
    • objects [id, List]
    • camera [id, Camera]
  • Sound

    • name [id, String]
    • file [id, File]
  • Speaker

    • volume [float]
    • pitch [float]
    • distancing [SpeakerDistance]
    • cone [SpeakerCone]
  • SpeakerDistance

    • See Speaker Distance Panel
  • SpeakerCone

    • See Speaker Cone Panel
  • TextBlock

    • name [id, String]
    • text [id, String or File]
  • WorldMist

    • falloff [byte, str]
      • See World Mist Panel
    • See World Mist Panel
  • World

    • mist [id, None or WorldMist]
    • ambientColor [id, Vec3]
    • horizonColor [id, Vec3]
    • zenithColor [id, Vec3]
Clone this wiki locally