Jump to content

Help with importing models / animations


Vaelek
 Share

Recommended Posts

I thought I was getting the hang of things and successfully modeled and imported a UV mapped model, but now I've hit a road block and could use some guidance.

 

I've created a simple animated windmill in Blender, and am having some issues getting it into LW correctly.

 

First, if I export it as is (using fbx or LW exporter), any materials I apply to it do little more than change its hue, and are a plain solid color, not reacting to the flashlight. I did no texturing in Blender and was just going to deal with that for now within LW directly.

 

Second, nothing I have tried has populated anything in the animations tab of the model details within LW.

 

Third, I did the Ctl-A thing on the base of the model. If I do it for location to the winmill wheel, it appears in the right location relative to the model in LW, but in Blender, the origin changes so the animation is no longer centered on the center of the wheel and completely breaks. If I have the wheel origin set to the center of the object, it animates fine in Blender, but appears below the base in LW.

 

I've done much trial and error and googling and have really made no progress at all here so I'm hoping someone can give me a hand and tell me what I'm doing wrong.

 

I've attached both the .blend file and the .mdl. Please help.

 

Thanks!

Windmill.zip

Link to comment
Share on other sites

I just tested it as well. The problem is that the Blender file you gave does not use bones. Bones are essential for animation in Leadwerks, and for most 3D animation programs for that matter.

 

If you really want the windmill to work without the need of rigging and such, the nice part is that the wheel is a child of the main meshes, so you could rotate it in code. I'm not sure if you need this model to work or if you are just testing various things right now.

Link to comment
Share on other sites

@CreativeOcclusion: Thanks for taking a look

 

@Nick.Ace:

At this point I am just testing to try and learn how to work with animations and getting models from Blender into LW before putting any real time into anything. I thought bones were more for skeletal type animations. To use them in something like this, would it basically be 2 bones, one in the base and one in the wheel, and just rotating the one in the wheel? I've never worked with them before.

 

Do you happen to have any idea what is going on as far as the wheel separating from the base when placed in LW? In another non-animated model I'm testing I'm having similar issues. Looks fine in Blender but things just don't line up correctly when brought into LW. My thought is it has to do with origins but I haven't found anything that explains it in a way that makes much sense to me.

 

Thanks!

  • Upvote 1
Link to comment
Share on other sites

For your first question, yeah two bones would be sufficient in this case. Bones can be used for either, but the .fbx file format only supports bones animation, as do most file formats probably.

 

For the second question, I think each part is being locally relocated (so the wheel is being recentered around it's axis and the same with the base). I might be wrong though. The animation thing you had done might also have been messing the placement up a bit, but since you say it may have been this way for other non-animated meshes, then it might be the case that each mesh is being separately reassigned.

 

In terms of how to fix this, I'm not too sure how in Blender. You can reposition the children meshes in code, but that's sort of tedious. Are you parenting the children meshes within Blender? This might cause issues as well. Also, when in doubt, I always use the .fbx exporter in Blender over the .mdl one, because it used to fail when it first came out with certain MakeHuman models (I'm not sure if it got fixed or not, I never really checked).

  • Upvote 1
Link to comment
Share on other sites

Hi,

 

Conceptually it is pretty simple to set up a rigid model animated with bones in blender, but in practice many operations are required, and there are quite a few blender-specific things to know.. I don't really have space here to do a full tutorial, but i'll try to cover the salient points.

 

First you must combine your separate meshes into a single one, and then create a vertex group for each separate part, with the appropriate vertices from your composite mesh assigned. Then create a skeleton, with bone-names following the vertex groups. once the skeleton is bound to the composite mesh, the bones in the skeleton will move the correspondingly-named vertex group.

 

So i created 2 vertex groups, 'sails' and 'tower' and 2 bones (also called 'sails' and 'tower') I selected the vertices in the sail assembly, and assigned them to the 'sails' vertex group, inverted the selection and assigned the rest to the 'tower' vertex group.

 

Then i selected the model, and the armature, and ctrl-p to parent/assign armature to mesh. At this point, entering pose mode and rotating the 'sail' bone will rotate the sail assembly in the mesh.

 

I created 2 keyframes, one at frame 1 with a z-axis rotation of 0 and one at frame 31 with a rotation of 360 degrees, set my scene start and end frame to 1 and 31,

 

The default quaternion interpolation for bones doesnt work well for simple, single-axis rotations, so setting the bones' rotation mode to euler xyz first is often necessary.

 

Also, keyframe interpolation needs to be set to linear, as well as channel extrapolation for this type of 'continuous' rotation to be seamless.

 

There are also some issues with actions and making sure they stay in your .blend file across save/reload (its important to click the 'F' button for actions you wsh to keep in the action editor).

 

As I said earlier, its difficult for me to cover everything, so you will probably need to look for tutorials/documentation on the internet before a lot of this becomes easy, but I have set up your windmill with a skeleton, and attached it to this message. Hope it helps.

 

http://marchingcubes.com/Windmill_w_skel.blend

  • Upvote 1
Link to comment
Share on other sites

@MarchingCubes

I will have to re-read that a few times to let it all sink in and try to follow what you're saying but that should be very helpful thank you!

I arrived at my own version of this before seeing your post. I didn't do all of the things you said, but at least in Blender, the end result seemed to work. I imported it into LW and everything was where it was supposed to be, I had 2 animation tracks, the 2nd being only a couple frames and just appeared to be garbage. I applied a material to the sail that used the animation shaders, clicked play, and it spun correctly!

 

Now.. As soon as I save, the sail disappears?!?!? The only way to make it reappear is to apply a material without the animation shaders. I did a quick and dirty UV map of your version and when I put the material on it in LW nothing disappears and it plays fine in the model editor, however when I drop it in to my scene with the SimpleAnimation script, nothing moves either.

 

What am I doing wrong now? My Blend and mdl export are attached.

 

I'm so close I can taste it!

Windmill4.zip

Link to comment
Share on other sites

Hi,

 

I don't have too much to do right now, so I have done some work on this for you.

 

I have a blender project, leadwerks .mdl, .tex, .mat and an animation script in a zip which should get you a working windmill.

 

I have only done the most basic and crappy UV mapping, with a test grid, so you will have to redo this with your real texture, however as you can see in:

 

http://marchingcubes.com/windmill.mp4

 

this windmill with animation works just fine in leadwerks.

 

Take a look at the blender project in:

 

http://marchingcubes.com/windmill_marchingcubes.zip

 

it should pretty much export cleanly with correct animation, using the leadwerks blender exporter - to something that can be dropped into leadwerks, and attaching the supplied windmill_animation.lua script should make it go nicely, with controllable speed (you may wish to break this out into a Script.variable you can set graphically from the ui)

 

I did have to trim 2 frames off the complete 360deg animation to get it to 'wrap' smoothly in leadwerks without noticeable 'jitter' at each revolution, but this is done for you in the blender project, so hopefully you can just re-UV and texture and your windmill will be good to go.

 

Hope that helps

Link to comment
Share on other sites

@beo6 Thanks for the input. That's sort of the idea I was getting.

 

I thought this would be the most basic of animating to be a good starting point to learning how it works both in Blender and LW. Even if this is not the ideal method of accomplishing it in this particular case, I'm still baffled by the fact that everything seems fine coming in to LW up until the point I apply a material with the animation shaders and then save/exit the model editor, at which point the sail disappears.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...