Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

problems with rbody file

Help
doc
2005-09-20
2013-04-17
  • doc
    doc
    2005-09-20

    I am trying to three meshes into my program. Only two of the meshes will load, the rifle and webbing for a soldier, but not the body mesh. I think there is something wrong in my rbody file to do with the material set. Can anyone tell me where i can find information on the meaning of the thread and material values in material set connection? I can not find any tutorials or documentation on what the values are meant to represent.

     
    • Peter S
      Peter S
      2005-09-20

      Hi, you can (hopefully) find the answer to your question in the thread "Problems in rbody file" (https://sourceforge.net/forum/forum.php?thread_id=1354477&forum_id=442703) in this forum. See second post.

      regards
      Peter Sunna

       
    • doc
      doc
      2005-09-21

      I have already read the "problems in rbody file' posting and although i am having similar problems it does not answer my previous question. That is where can i find documentation on the thread id and the connection part of material set. Does the thread id represent the mesh the material applies to? etc.

      when you use tga files to create one material to use for the entire mesh, is the tga file created through 3dsmax 7 render to texture. I can render a tga file similar to those in the example, however they are broken into many small fragments as apposed to the tga of biguy tga file which looks like one entire skin stretched out on a board.

      thanks

       
      • Peter S
        Peter S
        2005-09-21

        When you bind a material to your character in 3ds, the name of the material (in 3ds) must consist of a unique number surrounded by square brackets (for example "facematerial[0]", "armmaterial[1]", "legmaterial[2]", and so on). So, every material in your character must have a unique number. This number is the thread id of the mesh that uses this material. Each mesh get its thread id when it is exported from 3ds by scanning the material name that is tied to it for a number between square brackets. No material is given the mesh at this time! I know this is confusing, but that's the way it goes. The material id, on the other hand, is set when the .rbody-file is loaded. The material defined first in the rbody-file get material id 0, second defined material get material id 1, and so on. When you construct a material set you must bind every thread id to a material id. All meshes in you character only know that they use a material with thread id x. They don't know anything more. In the material set you define what material thread_id x is pointing to. That is, you say that "my face mesh (and all its submeshes whit the same material) should use sad_face_material in material set sad_material_set". This is the connection, which is given the thread_id and the material_id to match. Following this all meshes that use different materials (read: have different thread_id:s) must "be connected" in a material set. If you just have one look of you character, then you only need one material set. If you only use one material, then you only need on connection in your material set.

        I hope this post combined with my earlier post on the subject does the trick.

        regards
        Peter Sunna

         
        • doc
          doc
          2005-09-21

          I understand now that each mesh has a threadID associated with it by naming the texture in 3dsmax 'name[int]'

          The way I have read this, it seems each mesh can therefore have only one texture assigned to it.  Is this correct?  As it stands, I have three meshes, each having 3 materials assigned to them for a total of 9 materials.  I have posted the rbody code in another thread. 

          If I knew how to create one large tga file to texture map one whole mesh my problems would be solved, as I have got a single animated mesh with one texture to work fine. At the moment I do not know how to do this, so the best I can do is try and get multiple textures to work.

          To simplify things, I can create one mesh with multiple materials.  In that case, would the connections be (0,0) (1,1) (2,2) etc. or (0,0), (1,0) (2,0) etc (meaning that the mesh has only one thread ID which would be zero)??

          Thanks for your help

           
          • doc
            doc
            2005-09-22

            I think I may have discovered the problem to my woes !  (anybody else feel free to read)

            I found the cal3d file format documentation and opened up the mesh files that were exported (in a hex editor)  The 3rd integer in the file indicates how many submeshes the mesh file contains.  This means each mesh CAN have multiple materials, so for a single mesh file with 2 textures your rbody would look something like (ignoring syntax):
            Mesh meshfile
            Material mat0
            Material mat1
            MaterialSet
              * Connection (thread 0 to Material 0)
              * Connection (thread 1 to Material 1)

            The problem I was having was that two of my meshes were imported into my 3d studio max scene and the third was created in there to begin with.  The two meshes that I could load and display correctly by setting "default 1" were the two I imported and upon looking at their exported mesh files, the number of sub-meshes correctly corresponded to the number of materials assigned to each mesh in 3d studio max.  When I looked at the mesh file that was giving me the problem, I immedietly discovered that it had 7 submeshes (it should have had only 3).  Somehow in 3dsmax, the imported models were being added on as submeshes to the third one. This caused all the problems with the threads - I am assuming this was the problem. I am now working with a single mesh with multiple textures (they still look like they are being attached wierdly, but thats another story!!)

            I hope this helps other people!!  If im wrong with anything, please let me know.  Cheers,

            Doc.

             
    • doc
      doc
      2005-09-21

      thanks paul,

      At least i know how everything links in know. I have changed the rbody file and think it is correct now. Can you please check it and see if you can find any problems with it.

      # ReplicantBody v0.1

          path "./models/redone/fourmesh"
          skeleton "soldier.csf"
          default_act "ACT_STAND"
          scale 0.025
          foot_offset 3.0 // Before scaling

          // Bones used when calculating character speed
          ContactBones {
              bone_name "Bip01 L Foot"
              bone_name "Bip01 R Foot"

          }

          // Bones from which you can get the direction
          DirectionBones {

              head_bone "Bip01 Head"

          }

          Animation {
              name "stand"
              filename "walking.caf"
              act_name "ACT_STAND"
              act_weight 1.0
              speed 0.0
              is_looped 1
          }
          Animation {
              name "walk"
              filename "walking.caf"
              act_name "ACT_WALK"
              act_weight 1.0
              speed 2.0
              is_looped 1
          }
          Animation {
              name "run"
              filename "walking.caf"
              act_name "ACT_RUN"
              act_weight 1.0
              speed 100
              is_looped 1
          }
          Mesh {
              name "body"
              filename "body.cmf"
              is_default 0   
              }

          Mesh {
              name "rifle"
              filename "rifle.cmf"
              is_default 1   
              }
          Mesh {
              name "webbing"
              filename "webbing.cmf"
              is_default 1   
              }

          Material {
              filename "cam[0].crf"
          }
          Material {
              filename "boots[1].crf"
          }
          Material {
              filename "skin[2].crf"
          }
          Material {
              filename "webbingcam[3].crf"
          }
          Material {
              filename "webbingfabric[4].crf"
          }
          Material {
              filename "sterygreen[5].crf"
          }
          Material {
              filename "steyrM[6].crf"
          }
          Material {
              filename "mag[7].crf"
          }

          MaterialSet {
              name "original"
              is_default 1
              Connection {
                  thread_id 0
                  material_id 0
              }
              Connection {
                  thread_id 1
                  material_id 1
              }
              Connection {
                  thread_id 2
                  material_id 2
              }
              Connection {
                  thread_id 3
                  material_id 3
              }
              Connection {
                  thread_id 4
                  material_id 4
              }
              Connection {
                  thread_id 5
                  material_id 5
              }
              Connection {
                  thread_id 6
                  material_id 6
              }
              Connection {
                  thread_id 7
                  material_id 7
              }

          }

      Unfortunately it still doesn't work. it will load the rifle and webbing mesh's but not the body. The program would crash without throwing exceptions if i change the body mesh to 1.

      sorry to keep bothering you.

      Doc

       
    • Peter S
      Peter S
      2005-09-22

      RBody can crash if there is any mesh that hasen't got a material assigned to it. If you look in osgbody.cpp you see a line with the following code:

      CalCoreMaterial *core_material = getBody()->getCalCoreModel()->getCoreMaterial(core_submesh->getCoreMaterialId());

      As you can see no exception handling is done if core_submesh->getCoreMaterialId() returns a negative value (ie, there isn't any material tied to the mesh). Can this bug be the problem?

      regards
      Peter