Crystal Space
Welcome, Guest. Please login or register.
October 26, 2014, 02:25:57 am

Login with username, password and session length
Search:     Advanced search
9011 Posts in 2044 Topics by 8828 Members
Latest Member: Saikjanna
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Game Content Creation
| | |-+  [SOLVED] Multiple Materials on a SprCal3D mesh
« previous next »
Pages: [1] Print
Author Topic: [SOLVED] Multiple Materials on a SprCal3D mesh  (Read 3438 times)
zaz
Newbie
*
Posts: 16


View Profile
« on: July 30, 2005, 01:27:35 am »

Edit: While I didn't solve this the way I desired, I was able to modify the blender2cal3d_2.py code to export submeshes as separate meshes.  See my post in this forum that includes my patch file.

According to the "Creating Art for CS" page, SprCal3D should support "several materials" per mesh.

I know that you want to have as few textures/materials per mesh in the game due to performance reasons, but at the moment I'm trying to reuse several old blender models for some prototyping and those models have several UV mapped textures.

I can export a model fine from blender and view it with the cal3d_miniviewer tools and get the expected results.  Now I'm trying to get these models into CS and can't figure out how to assign more than one texture to a SprCal3D mesh.

In my model.cmf file, each separate blender material, i.e. each separately UV mapped texture, is its own cal3d submesh.  Each of these submeshes has its own UV mapping and cal3d material associated with it.  When I load this into CS, I can't determine how to associate more than one texture per mesh on my SprCal3D mesh.

I have something similar to the following in my world file:

Code:
      <material file="cal3d/textures/body.png"  name="body"  />
      <mesh material="body" name="model" file="cal3d/model.cmf"/>

This will get my model in, however the body.png texture is mapped to the head as well as the body.  I need to also define a "head" and other materials and then associate them with the proper materials as cal3d and blender see/saw them.

I've looked through some of the sprcal3d code for support for mutiple materials per mesh and didn't notice it.  Also, most examples of SprCal3D models I've found for CS are actually composed of several cal3d meshes (.cmf files).  So, at this point I've concluded that while a SprCal3D model can use more than one material, those materials can only be assigned to separate cal3d meshes.

Am I missing something ?  Is the statement that SprCal3D supports "several materials" per mesh wrong or misleading in the "Creating Art for CS" page ?  Or is there some syntax to the world file I'm not familar with, say a way of defining a material with multiple textures in it ?
« Last Edit: August 01, 2005, 05:47:35 pm by zaz » Logged
Hilake
Newbie
*
Posts: 27


View Profile Email
« Reply #1 on: July 30, 2005, 06:49:06 am »

I also want to know the answer. But I use the whole picture of my module at last.

There still have some problem for me. Is there some part of your module didn't move? For example, a part of it's leg or a skirt that pertain to the skeleton.
Logged
zaz
Newbie
*
Posts: 16


View Profile
« Reply #2 on: July 30, 2005, 10:56:27 pm »

My models work fine in cal3d_miniviewer, everything moves as it should.  The little testing I've done in CS so far looks ok too, but I haven't tested in CS extensively yet.  At the moment, I'm just fighting the material problem as far as I can see yet.

Have you used the miniviewers from cal3d to test your models ?  Are you getting the same results in CS as in the miniviewers ?

The particular set of models I'm working with right now were originally built for rendering animations in blender, so they have way too many bones at nearly 200.  Also, they are largely animated with IKs and have lots of extra bones to support various constraints.  It took quite a bit of futzing around in blender, writing scripts to clean unneeded IPO channels from baked actions, small modifications to the cal3d exporter script to ignore some of the bones only used for constraints or IKs, etc.  But these models are available to me right now and learning the ins and outs of complex models like this will allow me to create or manage the creation of real models later.

I didn't seem to have as much luck with the standard cal3d exporter script released with blender.  The script I'm using now is part of the current cal3d CVS (maybe part of 0.10) and is called blender2cal3d_2.py.  Note the _2 in the filename.  It seems to work better and has a little bit of a GUI.  If you're using this version, make sure you restart it each time you export though as there's a bug in it that makes your skeletons invalid if you Export more than once per run.  I posted the fix to the cal3d forums at sf, but its unlikely to have made it into CVS by now.

I did initially have problems with my first model's legs not moving under some circumstances, however these went away when I finally had clean skeletons exported, i.e. I'd removed all the extraneous IK and other constraint related bones and corresponding IPO/Action channels.

Since I'm also playing with the torque game engine, I've been fighting these animation problems quite a bit.  Some of the things I've learned are:
  • Apply your scales and rotations to everything you're exporting, i.e. CTRL-AKEY on each object/mesh/armature.
  • Recalc your bone rotations in blender on your armature bones, i.e. in edit mode on an armature, select all your bones (AKEY) and the press CTRL-NKEY.  Beware this is very likely to cause you to reanimate any bones whose rotations were changed.
  • Game engine animation systems, or at least their blender exporters, don't like child bones that begin other than at their parent's end.  For example, it doesn't work very well to parent a bone for a bicep directly to the spine bone(s) leaving a big gap between where the bicep bone starts and the top of the spine bone its parented to.  Add a shoulder bone going from the spine to the bicep bone, even if you never animate it.
  • If you put a key frame in for one bone, its best to put them in for all bones that are animated with an action.  Example:  You pose a model in a sitting position and only animate the head to look around.  Technically since most of the animated bones are being left in their originally posed position, you wouldn't need key frames for them beyond the first, however whenever you put a key frame in for the head and neck to animate the looking around, you should also put a key frame in for the other bones involved in posiing your model in the original state position.
  • If you're trying to animate with IKs you'll need to make sure you bake your actions in blender and then only export the baked actions as the IK actions aren't supported by most, if any, game engines now.
  • If you do go the IK-with-baking route in blender, you have to clean the baked actions up as well as control what bones are exported.  Bascially, don't export bones that don't move anything on the mesh or provide missing structure to the skeleton, i.e. the above mentioned shoulder bones.  Also, don't export the baked actions without cleaning them up manually or with a script.  You should remove extraneous and/or unwanted animation channels in these actions and reduce the number of key frames (baking puts a key frame in for each frame).
  • Be aware of naming conventions of the exporters.  Some of the exporters, like blender2cal3d_2.py, ignore bones, meshes and actions that start with an "_" (underscore).  Also, it assigns special meaning to actions that start with a @ sign.
  • Start with something simple, like the guy in http://community.crystalspace3d.org/tiki-read_article.php?articleId=16 and then play around with it until you understand what your changes cause to happen in cal3d and CS.
  • Once you figure out the solution to a problem, document it so you are able to refer to it later or pass it on to others on your team.
  • Hmm, a hundred other little things I'm forgetting at the moment because I haven't been following the last step yet, smiley.

What you're trying to do isn't a simple or trivial task, at least in the beginning, its going to take some time to come to terms with it.
Logged
Hilake
Newbie
*
Posts: 27


View Profile Email
« Reply #3 on: August 01, 2005, 02:36:24 am »

It work will in the miniviewer, but it have may problems in cs. Such as one leg didn't move, and the model's skirt alse didn't move.

Thanks for your answer.


Have you used the miniviewers from cal3d to test your models ?  Are you getting the same results in CS as in the miniviewers ?
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 7.537 seconds with 16 queries.