1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. The Results have come out of the old ARENA oven. Check out who won the 30th Texturing Contest!
    Dismiss Notice
  3. Hey guys, we've posted the Results for the 30th Modeling Contest. Check them out!
    Dismiss Notice
  4. The 15th Mini-Mapping Contest came to an end. The Secrets of Warcraft 3 are soon to be revealed! Come and vote in the public poll for your favorite maps.
    Dismiss Notice
  5. The 12th incarnation of the Music Contest is LIVE! The theme is Synthwave. Knight Rider needs a song to listen to on his journey. You should definitely have some fun with this theme!
    Dismiss Notice
  6. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

MDL Exporter for Blender3D!

Discussion in 'Modeling & Animation' started by Fingolfin, Aug 26, 2018.

  1. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,168
    Resources:
    152
    Models:
    142
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    152
    Warcraft MDL Exporter for Blender

    It's been a long time coming, but now there's finally a way to export Blender models for Warcraft III!
    This plugin is currently under development, but already supports practically all properties of the MDL format. I will try to keep this thread updated with new info and instructions on how to use it.

    DOWNLOAD

    Tutorial: [3D Art] - Exporting models from Blender using the MDL exporter plugin
    Procedural tree modeling tutorial: [3D Art] - Creating procedural trees using Blender

    Current issues:
    • Although animations are supported, there can be some limitations and issues. For instance, you can't parent armature objects to other objects. Euler rotations should be supported but i haven't tested yet.
    • Bezier and Hermite interpolation are exported in a somewhat approximative fashion, and although it usually looks good, you might get some issues. Rotations will automatically use linear interpolation as of right now.
    • Animating the dimensions of a particle emitter is currently not supported and will throw errors.
    • Armatures apparently need to have a scale of 1 for translation animations to work correctly. This will be fixed.

    Usage Guide

    Modeling

    Meshes with the same materials will be combined into geosets.
    To control the smoothness of your normals, set the object to "Render Smooth" in the right toobar, and then go to the "Object Data" properties tab and check the box which says "Auto Smooth". Here, you can choose the maximum sharpness angle which will be smoothed. Note that any mesh with a particle system attached to it will be treated as an emitter, and thus will not be exported as a geoset.

    Attachment Points

    To create an attachment point, add an empty object and give it a name ending with "Ref" - for example, "Overhead Ref" will create the attachment point "Overhead". Attachment points can be parented to bones by selecting first the object, then shift-selecting the bone, and pressing CTRL+P>Set parent to object.

    Event Objects

    In their most basic form, event objects are empty objects with a name matching the pattern "[EventType][UniqueId][EventId]". One example is "SND1DHLB" which represents the sound event "Death Human Large Building". This can be a bit hard to remember, so fortunately there is a helper operator for this. Press SPACE to open the search bar and type in "Add MDL Event Object". This will create an empty where you can configure the event type and ID from dropdown lists in the object properties tab. To determine when the event is executed, there is a property called "eventtrack" in the "Custom Properties" submenu which you can animate. If you create your event from an empty object, you will have to add this property yourself. What value you assign to it in the animation doesn't matter - only the frame numbers are used.

    Event_Objects.jpg

    Collision Shapes

    Collision shapes are used typically to specify the clickable surface of a unit. There are two types of collision primitives - Box and Sphere. To create one, press SPACE to open the search bar and type "Add MDL Collision Shape". You will be prompted to choose between the two types. After confirming, the shape will be created at the position of your 3D cursor. Note that like particle emitters, collision shapes use the scale of the empty object as radius, so don't use "Apply Scale" on them or the scale will not be properly exported. It is now safe to apply the scale of collision shapes.

    Lights

    Create a lamp and go to the "data" properties panel to find a panel named "MDL Light Settings". Here, you can configure the light type as well as attenuation properties, color, and intensity. All values except the light type can be animated.

    Billboarding

    Lights, bones, and attachment points can all be billboarded. A panel titled "MDL Billboard Options" will appear in the "object" properties tab when a relevant object is selected. You can constrain billboarding to a certain axis by checking the "Billboard Lock X/Y/Z" checkboxes respectively.

    Materials

    Meshes will need materials in order to be exported. When creating a new mesh, go to the Materials tab and make sure that the mesh has a material assigned to it. At the bottom of the tab, there is a panel with the label "MDL Material Settings". Press the "+" button next to the "Layers" window to create a new material layer. Each layer can have a Texture Type assigned to it, the different texture types are:
    • Texture (requires a path specified)
    • Team Color
    • Team Glow
    • Cliff
    • Lordaeron Tree
    • Ashenvale Tree
    • Barrens Tree
    • Mushroom Tree
    • Northrend Tree
    • Replaceable ID
    As you might guess, the different "Tree" options are for replaceable tree textures, "Replaceable ID" is for manually entering an ID. For regular textures, paths can be easily found in MPQ editors such as the MPQ browser in Magos Model Editor (just right-click a texture in the hierarchy and press "copy path to clipboard"). Layers also have a filter mode, which dictates how it will be blended together with the below layers. The "Blend", "Transparent" and "Additive Alpha" filter modes also expose an extra "Alpha" property (animatable), which you can use to add an extra transparency factor to the layer or to create fade-out effects. Layers are rendered top to bottom, so team colors would typically be at the top of the list with the texture below. Layer names are for organising your layers mostly and aren't exported.

    [​IMG]

    Rigging

    For the most basic models and animations, rigging is not necessary. The exporter will automatically create bones for objects which don't have any, and transfer any animations to them. To make bones manually, create an empty object (CTRL+A > Empty) and give it a name which starts with "Bone_". You can also use Blender's armature objects to create bone hierarchies, this is necessary if you want to have deforming bones. Select your meshes first, then your armature, and press CTRL+P and select "Armature Deform with Automatic Weights". This allows multiple bones to affect the deformation of a single mesh.

    Bones which have no geosets attached to them will be automatically converted into helpers.

    Animation

    Animating in Blender is done by first changing a value, then adding a keyframe to save it. Most properties can be keyframed by mousing over it and pressing I. Location, Rotation and Scale can be keyframed by simply pressing I anywhere in the 3D viewport and selecting them from the drop down menu.

    Creating Sequences

    When animating your model, the animation will be done as a single, long segment of different movements in the animation timeline. Sequences define the start and end bounds of each named animation clip. To create one, mouse over the timeline and press M to create a timeline marker, and then CTRL+M to name it. You can name them anything, but Warcraft generally only accepts certain names such as "Stand", "Death", "Birth", etc. Drag your timeline marker to the start of your sequence, and then create another one with the exact same name and place it at the end. Note that you MUST have a start and end marker for your animation to export. You can place as many sequences as you like, but they cannot overlap.

    Timeline.jpg

    Whenever two timeline markers with the same name are created, a sequence will be created in the sequence manager, which you can find under the scene tab in the properties menu. Here, you can edit things like looping and rarity - changing the name in the sequence editor will also change the corresponding timeline markers. If the name contains the word "Walk", the editor will expose a Movement Speed parameter which controls the relationship between the units movement speed and the walk animation playback rate. If you create a Death, Decay, or Attack animation, their non-looping values will default to "False" for convenience.

    Sequence Editor.jpg

    Global Sequences

    A global sequence is an animation which repeats itself over and over, regardless of which sequence is playing. An example of this is the movement of the flames of the Fire Lord hero. To mark an animation as global, go into the graph editor, select your animation curve(s), and go to "Key>Add F-Curve Modifier>Cycles" (or press SHIFT+CTRL+M). For animations with multiple channels, such as rotation/color/scale/position, only the first channel needs the modifier. Note that most properties support global sequences, including most particle settings, event track keys, light intensity, visibility, etc. (i will make a full list at some point). Also note that global sequences always start from the first frame - all frames from 0 up until your last animated frame will be part of the sequence.

    Animating Visibility

    You can control when or not an object will be visible by animating its render visibility. The easiest way of doing this is to select the object, change render visibility by clicking at the camera icon next to it in the outliner, and then pressing the I key with your mouse still over the icon to create a keyframe. Another option is to add a "custom property" to the object, name it "visibility", and then animate that - whichever is more convenient.

    [​IMG]

    Animating Vertex Color

    Warcraft materials can be given an aninmated tint which is applied as a vertex color in the game (same as the tint color properties in the object editor). Tint is applied per-object using the "Color" field in the object properties tab. Animate it, and a GeosetAnim will be automatically created for this geoset. It also works to just set the object color to anything else than white.

    Texture Animations

    To create a texture animation for a layer, enable nodes for the material and add a "Mapping" node to the node tree, give it the same name as the layer you want to animate, and animate its properties. The name of a node can be changed in the viewport menu of the node wiewport (N to toggle).

    Interpolation Modes

    You can change the interpolation mode of your keyframes by pressing A in the graph editor so that all keyframes are selected, and then go to Key>Interpolation Mode. All three modes are supported, though Bezier rotations will be converted to Hermite in a somewhat experimental way.

    Particle Emitters

    The exporter supports all three emitter types: ParticleEmitter, ParticleEmitter2, and RibbonEmitter. These are referred to as "Model Emitters", "Particle Emitters" and "Ribbon Emitters" respectively. To create a particle emitter, create a plane (SHIFT+A>Mesh>Plane), go to the "Particles" tab in the properties window, and press "New". Scroll down to the bottom and you will find the emitter settings. Most properties have informative tooltips if you mouse over them - there are also some excellent tutorials on how to do particle emitters in the tutorials section.

    One important thing to node though: Exported emitters will use the plane's X and Y scale to define its bounds. For this reason, make sure to never apply its scale (For those who don't know what this means - you can apply an objects scale by pressing CTRL+A>Scale to set its scale to (1, 1, 1) and instead apply the scale to the vertex positions). Remember that you can animate the X/Y scale to animate the bounds of the emitter; Unlike other objects, it is safe to individually keyframe the X and Y scale of an emitter, and you can also have different global sequences for each axis. "Emission Rate", "Speed", "Gravity", Variation", and "Latitude" can all be animated (hover over the field and press I to keyframe the value).


    Particle Editor.jpg
     
    Last edited: Mar 12, 2019
  2. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Very nice. Truly a long time coming.

    It has been way too long since I used Blender though, can't really test it.

    Helpers are the same as generic objects, aka the parent class of all nodes. In other words, they are the same as bones as far as animations go etc.

    Note that both helpers and multiple bones per vertex are absolutely required.

    If you are having issues with texture animation rotations, the keys are quaternions that rotate around the Z axis. An easier way to look at it is that they are simple 2D rotations.
    Their form is [0, 0, Z, W].
    The center of rotation is [0.5, 0.5], so translations are needed.

    I would assume Blender can give you the bounding boxes of things. Therefore, is there any particular reason to use the local scale, rather than the bounding box? the latter will avoid the issues with node scale vs actual size.

    Continuing with the same line of thought, I would assume Blender also gives you a way to get a quaternion representation of a node's rotation also when it's defined with euler angles, so is there a reason to limit this?
    Euler angles are very yiffy, I agree, but Blender and other modeling tools do support them, so use it to your advantage.

    And again, with the same theme - I would assume Blender supports both bezier and hermite interpolations, so same question there.

    Of course I may be wrong about these assumptions, I haven't written any Blender code in longer than I haven't used it for modelling :p

    Please support MDX as well!
     
    Last edited: Aug 26, 2018
  3. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,168
    Resources:
    152
    Models:
    142
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    152
    Thanks! Multiple bones per vertex is something i'm working on right now, it will likely be done today. It hasn't been a big deal in terms of visuals for the models i've tested though. I've gotten the impression that 3 bones is the max per vertex, so i'm using that limit. Fixed!

    As for helpers, from what i understand they are just empty nodes in the hierarchy which can serve as parents, but nothing else. The thing is, the exporter currently optimizes away these kinds of useless nodes and instead use the nearest animated parent (or the root bone), so i'm not sure in what situation i'd want to generate a helper. When are they created in the Art Tools exporter? When do you use them in any other Wc3 model authoring tool?

    Thanks, this is very useful info. Texture rotations in blender are always in Euler (AFAIK) and rotate in 3D space (since Blender suports 3D textues and noise generators). I could propably create a quaternion from an axis-angle representation here.

    This was my first solution, but the thing is that you can't animate the bounding box of an object and there's no way of getting a curve for this (since it's a generated value). Another option would be to use custom properties, but this would not provide any visual feedback. I think not applying scale is a very small thing to ask. Optionally, i could temporarily assign an identity matrix as world matrix for the object (so as to give it neutral orientation), save its bounds to a scale vector, and then reassign its world matrix. This would allow me to multiply in that scale vector to each keyframe.

    This is true, but remember that there are multiple quaternion representations for each Euler rotation, and which one is correct depends on which value you are interpolating from. I think there are helper functions for calculating this, but it still means that i have to consider the next and previous frames to calculate a correct rotation, and it screws up my algorithms. Another problem, which is essentially what's behind the requirement of having the same amount of keyframes per channel, is that i don't know how to generate proper control points for bezier curves. Blender only supports Bezier interpolation - Hermite and Bezier are just different representations of the same curve, only that Hermite uses tangents while Bezier uses control points. The issue is that in Blender, a control point has two coordinates - its Y coordinate for each frame (for Bezier, this is the InTan/OutTan value of the incoming and outgoing handles respectively), but also X coordinates, which exist on the "Frame" axis, which makes for a total of 2 handle coordinates per axis... but there is no X coordinate for MDL handles, only the tangent value. It makes sense to me that the InTan and OutTan vectors would represent the 3D positions of the control points. For this reason i'm using only the Y coordinates of the keyframes, and this seems to create accurate results. however, for rotations, i've noticed that the Hermite tangents are often the exact same values as the ones in the keyframe itself, at least in a continuous rotation. For other rotations, it is some other similar value which i can't seem to wrap my head around. Like, what would be the coordinate of a control point for a 4-Dimensional sphere? The expected value for Hermite would be (Handle coordinates) - (Keyframe coordinates), for a straight tangent the value would be (0, 0, 0). But it's not.

    I'll get to that, i chose MDL to start with since this is pretty much the first piece of Python code i've ever written, so i wanted to pick the easier option. I will have to refactor the code though so that it spits out a structured data object for the model which it sends into a file writer function of choice.
     
    Last edited: Aug 26, 2018
  4. Stefan.K

    Stefan.K

    Joined:
    Dec 29, 2014
    Messages:
    1,389
    Resources:
    82
    Models:
    82
    Resources:
    82
  5. Hayate

    Hayate

    Joined:
    Oct 20, 2010
    Messages:
    2,604
    Resources:
    65
    Models:
    50
    Icons:
    14
    Spells:
    1
    Resources:
    65
    Does that mean that I will suddenly be active in Hive again?
    Too be continued


    Exciting on this
     
  6. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Helpers are used by most WC3 models in existence.
    You can't simply remove them and expect models to work.
    You can try to find actual useless ones as an optimization, but that's for later.

    Animated scaling is a good reason, I didn't think about it.

    Tangents/control points don't have a frame, just a value.
    The fact that you see them in 2D on the graph is, well, just to allow you to see them in a meaningful way.
    That is, their direction in respect to their keyframes makes visual sense, especially when you see how it changes the curve itself.
    Without visually seeing them in the graph editor, all you'd have are text boxes and the curve shape, far less convenient.

    If Blender only supports bezier, then I imagine you should too. I doubt there's much use in supporting hermite when the user can't see it in Blender properly.

    Supporting MDX is actually easier than MDL, as is always the case with binary and text files, if you ask me. Sure, you can't easily see the data with your eyes, but at the same time all you have to do is follow the specs and read the next N bytes as it says, rather than parsing tokens, skipping white spaces and comments, etc. etc. :p
     
  7. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,168
    Resources:
    152
    Models:
    142
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    152
    Well, i know that Helpers are common, but can you please explain to me then in which particular situations a bone/parent object should be converted into a helper? Should i instead of optimizing away useless bones convert them into helpers? Should bones become helpers if they have children, but no animation or geoset data?

    As for tangents/control points - if the tangent X axis is just for visuals, then why does the length of the tangent change the properties of the curve? If they were of a normalized length, then i would understand, but as of now in Blender, pulling the control point on the horizontal axis will alter the properties of the curve.

    Yes, binary formats are not really any harder, it's just that it's very hard to interpret the error feedback when something goes wrong, especially if you don't know all the details of the format. With MDL files, you can just compare the values you get with those of a model exported with Art Tools.
     
  8. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    You normally don't need to convert any nodes, it's something the user decides.
    Helpers can't have vertices attached to them, so if one has vertices attached to it, it must be a bone (if we are talking about automatic fix conversions), however the fact a bone has no vertices attached to it does not mean it must always be a helper. If it also doesn't reference a geoset animation, I guess it can be converted as a form of optimization, but it's not required.
    I have no idea what happens if it references a geoset that has a geoset animation referencing it. Does it affect the visibility of the bone? No idea. I could never figure out the rules of when different parts of models (nodes, geosets, layers) are visible and being processed by the game or not.
    Note that when bones are invisible, any node down the chain isn't updated as a runtime optimization, in which case converting to a helper will have side effects. But what are the exact rules? who knows.
    For an example of this, think about units that have internal morphs, like the Mountain King. The Avatar part is all under a bone that is visible only in the alternate animations, meaning all of the relevant nodes, geosets, emitters, etc. cost more or less nothing when Avatar isn't active.

    When you move around tangents in curve graphs, you are changing their value. Again, the fact that you see them in a graphical way is to make the process intuitive. It makes a lot of sense that when you move a tangent in some direction and length, the curve around it will move in the same fashion.
    If you look at the values directly, unless you're a computer, or have experience with writing manual splines, they won't really make a lot of intuitive sense, as you noted.

    You are free to look at my specs/code for MDX :p
     
    Last edited: Aug 26, 2018
  9. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,168
    Resources:
    152
    Models:
    142
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    152
    I don't really think you quite understand the issue with the curve handles here. Again, bezier keyframes in Blender have two coordinates: Frame, and Value. Consider the following curve:

    Curve_1.jpg

    As you can see, this particular keyframe has the value 1.75 and its left handle is also at the value 1.75. Y and Z are at 0 and 3 respectively. In other words, the sensible representation would be this:

    Code (Text):
    Translation 2 {
        0: {0, 0, 0}
            InTan {0, 0, 0}
            OutTan{0, 0, 0}
        4166: {1.75, 0, 3}
            InTan {1.75, 0, 3}
            OutTan {1.75, 0, 3}
    }
    But then, consider the following curve:

    Curve_2.jpg

    The values are the same, but the handle is moved back. Notice how the shape of the curve is radically changed? The curves are clearly not identical, regardless of what you say. As for Hermite interpolation, these use the derivative of the outgoing tangent instead of the "height" of the control point. This should yield the tangents (0, 0, 0) for most keyframes, yet the most common form when exporting from Art Tools is the same as you'd get if they were exported using Bezièr interpolation. This is something which puzzles me.

    Regarding helpers: Helpers can't store ANY information other than parent, visibility, and billboard properties. Yes, you could technically use a helper to control the visibility of a group, but that's really all i can think of, and having a root bone will serve the same purpose. I guess i can still implement them for that particular case, though. I can't really let the user decide, since marking something as a helper despite having a mesh skinned to it will not work.
     
    Last edited: Aug 26, 2018
  10. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    The graphical representation you see of tangents/control points is NOT time based. When you moved the point left, you didn't change its frame, you change its value, which in turn affects the curve. The curve itself IS time based, which is why when you stretched the control point, the curve changed such that you get different values in the same frames.
    You can look at a keyframe as one structure containing a frame, a value, and (optionally) tangents/control points. The latter are not keyframes by themselves.
    Indeed, this is why the MDL keyframes look how they look - the tangents are a part of the keyframe.

    Helpers don't control visibility, they have translation/rotation/scaling animations.
    Technically all helpers can be bones, however bones have more processing to them, thus using helpers is a simple and natural optimization.
    Yes, you cannot have helpers with any vertices attached to them, that doesn't mean you need to automatically change bones/helpers in every other case! Indeed, you shouldn't, since it can have side effects, unless you add the code that checks if there are side effects.
    Perhaps @Retera can chime in, since this is stuff he did for MatrixEater.
     
    Last edited: Aug 26, 2018
  11. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,168
    Resources:
    152
    Models:
    142
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    152
    You're really starting to bug he here, GhostWolf. No, the values of the handles do NOT change when you move them, i don't know why you claim to know that they do. The handles are specified as 2D coordinates within the graph. Here is some proof:

    Curve_3.jpg
    Curve_4.jpg

    And yes, i know perfectly well that the control points aren't actually related to frame timing, but the length of the tangent DOES affect the appearance of the curve (but not the stored value). I also know that in Blender, the X value of the control point is stored in terms of the frame number as it appears in the graph. The question is how to combine these 6 values into a handle coordinate in 3D space.
    Here is a link to the Blender Python API documentation: Keyframe(bpy_struct) — Blender 2.71.6 1abcbe7 - API documentation

    Regarding helpers, according to the MDL/X specification they do support animated visibility. You are right though that they also have TRS animations, i didn't realize that... then it makes a lot more sense. Any objects in the hierarchy which are animated but have no geosets attached to them should be helpers.
     
    Last edited: Aug 27, 2018
  12. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Your images confused me, so I googled a bit and what you are using here are fcurves, rather than bezier curves. According to an answer on stackoverflow the former is indeed based on time.
    With that in mind, I have no idea how the control points are converted, my bad.
    One thing I saw is at A Primer on Bézier Curves if you search for "Rational B-Splines". I won't say I know much about this subject, but it sounds fairly similar, with the ratio being the difference in time between the control point and the point itself. I may be totally off though.

    For bones with no vertices attached to them, you still need to consider visibility. Refer to my reply above, I don't know exactly when bones are visible or not, and this may have side effects if you change without checking and it just happens to be a model with weird stuff.

    I don't think helpers actually support visibility animations.
    I know it's written in MDL specs, however no such animations are known for MDX, nor did I ever see any model with anything.
    Perhaps test it for MDL and see if it works. Who knows, maybe there's a KGOV animation or something :p
     
    Last edited: Aug 27, 2018
  13. Abovegame

    Abovegame

    Joined:
    Jan 2, 2016
    Messages:
    464
    Resources:
    1
    Maps:
    1
    Resources:
    1
    If this works then this is awesome !! :))))
     
  14. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,168
    Resources:
    152
    Models:
    142
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    152
    @GhostWolf, can you confirm that there are models in the Warcraft MPQ which do save translation, rotation, and scale animations for helpers? Because if so, i can add helper support with little effort. I know that practically all MDL entries with an object ID has such fields specified as animatable, but for most (such as attachments and event objects), adding animation data to them won't actually have any effect.
     
  15. Hayate

    Hayate

    Joined:
    Oct 20, 2010
    Messages:
    2,604
    Resources:
    65
    Models:
    50
    Icons:
    14
    Spells:
    1
    Resources:
    65
    by any chance there will be a possibilities to import mdl model coming in future?
     
  16. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,168
    Resources:
    152
    Models:
    142
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    152
    I most likely won't support MDL import, but there are already some importers available for Blender. This one looks the most promising, but there is also this one which supports MDX.

    I will at some point support MDX exporting though.
     
  17. Hayate

    Hayate

    Joined:
    Oct 20, 2010
    Messages:
    2,604
    Resources:
    65
    Models:
    50
    Icons:
    14
    Spells:
    1
    Resources:
    65
    Hey wanna ask, this export does not support IK is it? Somehow my animation export is very wonky


    Edit: Seems like it might be because I animated in Euler instead of quaternion, by any chance if there is a way to change the animation modes without reanimating the whole thing? Dammit!

    =.=
     
    Last edited: Nov 9, 2018
  18. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,168
    Resources:
    152
    Models:
    142
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    152
    There are plugins for converting Euler curves to Quaternion, though some might require a small amount of python knowledge. I am working on Euler support though, since i realize that's what people use mostly. IK not supported unless you bake it down to keyframes (and preferably do a keyframe optimization).

    I have to warn you that animation support is extremely experimental and there is no guarantee that it will work out in your case. First of all, rotations don't properly support bezier interpolation, and that will look weird. To fix this, open the graph editor, select all keyframes, and go to key>interpolation mode>linear. Second, rotations in armatures don't work well with axis correction - if you want to use armature animations, make sure that the armature is pointing towards the -Y direction (Might also be +Y. You may have to apply rotation, though i'm not sure) and then in the export settings, set axis correction to X=X and Z=Z.

    Overall, i'd recommend you to experiment a bit and see what works and what doesn't. Personally, i tend to do my animating by creating empties and giving them names starting with "Bone_", and parenting them to each other. This method has worked best for me and i have successfully finished a few models this way (though unfortunately this workflow does not support skinned meshes). I haven't done much animation with armatures yet, though it should kinda work (i have some test files), just let me know if you encounter any specific issues (and if so, send me the .blend file so that i can investigate).

    Another thing i noticed is that mesh bounds will for some reason become weird. Perhaps because i don't write bounds in the geoset (just the global bounds). For now, you will have to open the model in magos and recalculate bounds there - a fix is coming for this.

    Just a tip - in user settings, you can set default rotation mode as well as default interpolation mode. Could save you some pain in the future.
     
  19. Hayate

    Hayate

    Joined:
    Oct 20, 2010
    Messages:
    2,604
    Resources:
    65
    Models:
    50
    Icons:
    14
    Spells:
    1
    Resources:
    65

    managed to change Euler to Quaternion after did some digging, I was using IK, no wonder the animation goes chaotic,
    Do you have any tutorials or any info i can use on baking the keyframe thingy? or at least what keyword i should use to search on that?

    thank you :)

    experimental or not i appreciate your effort on making this addon. It brings back my motivation in warcraft modding :)


    Edit: Manage to figure out how to bake that animation, but now got another problem when export, when i open the model in magos, i get an error "expected "{", got "S" in group "Bone" in "C:\SumthinSumthin\Model.mdl"

    I can open the model in MDLVIS but there is no sequence and i get some MDLVIS error

    Edit: Managed to "Bake" the animation
    But Yeah It kinda screw up when I export
    I included my .blend file, you see if it will be possible to export into .mdx
     

    Attached Files:

    Last edited: Nov 10, 2018
  20. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,168
    Resources:
    152
    Models:
    142
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    152
    From inspecting the blender files i can see a couple of issues:

    First of all, you are still using Bezier interpolation for the rotations - i really should disable this until it is fixed, but for now, you should just change interpolation mode of all keyframes to Linear.

    Second, one requirement of the exporter is that each "channel" (X, Y, Z) of an animated property (say, rotation or position) needs to have the same amount of keyframes. So basically, if you want to keyframe the rotation at a frame, then both the X, Y, Z, and W curves need to have a key at that frame. With the baking you did (or presumably the optimization, if you did any), there are areas where frames are missing from some channels (you can see this in the Graph editor). It can be fixed by simply putting the cursor at those areas and inserting rotation or location keyframes there for those bones, though this can be tedious work. I am working on an automatic fix for this, but it might take a few weeks.

    Other than that, everything seems to export fine. Perhaps you can try to save a copy of the file without animations, export it, and try an animation transfer tool to transfer some Paladin animations? The bone hierarchies should still export, i think. If not, it should be enough to add a single keyframe to each bone to make them not be optimized away. The model looks great, by the way!

    EDIT: PS, one thing i noticed recently is that animating render visibility (to animate geoset visibility) is inversed. In other words, keying render visibility to "On" will result in the object being hidden in the export, and vice versa. Also something i'm working on.