Raydium 3D Game Engine

Official forum for everything about Raydium, ManiaDrive, MeMak, ...
It is currently Tue Mar 19, 2024 7:02 am

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: We need bone ID exporter
PostPosted: Thu Nov 01, 2007 8:04 am 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
I have put this request outside of the animation thread to get more readers.
I have made some advances in the animation system, but i need a modification of the tri file exporter for blender.
The tri file should now indicate in each vertex the name of the associated bone, if the mesh has an armature.
Can someone do this job?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 01, 2007 9:52 am 
Offline

Joined: Sun Oct 09, 2005 10:46 pm
Posts: 759
Hello,

I can have a look.

You need to be more specific about bones. How can i add them.

After it depend on the blender structure. If it's flat versus vertex and face it will be quite easy. Else i don't know.

Have a nice day
Ouille


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 01, 2007 11:11 am 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Thanks :)
Well, if i'm not wrong tri files are one vertex per line.
So you could add the linked bone to that vertex at the end of the line with something like @@Bone"nameofthebone".
That format is just an idea.

Need more explanations?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 01, 2007 12:36 pm 
Offline

Joined: Sun Oct 09, 2005 10:46 pm
Posts: 759
Hello,

I've reinstall python to test.
Can you send me a sample file, or a very simple howto to make tests ?

I just hope bones informations can be accessed on a retex basis.

Just post a simple blend file.

Have a nice day
Ouille


Top
 Profile  
 
 Post subject: once upon the time ...
PostPosted: Thu Nov 01, 2007 3:52 pm 
Offline

Joined: Sun Oct 09, 2005 10:46 pm
Posts: 759
Hello,

Here is a new export script
Code:
#!BPY

"""
Name: 'Raydium Export (.tri format)'
Blender: 2.43"
Group: 'Export'
Tooltip: 'Export to .tri format'
"""

#import rpdb2;
#rpdb2.start_embedded_debugger("test",True)

import Blender

from Blender import NMesh

class source:
   def __init__(self,filename):
      self.file=open(filename,"w")

   def writeFaces(self):
      Blender.Window.EditMode(0)
      scene=Blender.Scene.GetCurrent()
      self.file.write("1\n") #tri version
      
      objects = Blender.Object.GetSelected()

      if len(objects) == 0:
          print "-- Exporting all objects"
          objects = scene.getChildren()
      else:
          print "-- Exporting only selected objects"

      for object in objects:
          objtype=object.getType()
          if objtype == "Mesh":
         print "ok, it's a mesh"
         mesh=object.getData(mesh=1) # let's get a Mesh, not a NMesh (faster, thin)
         mgroup = mesh.getVertGroupNames()
         for mi in mgroup:
            print "Group:",mi
            for i in mesh.getVertsFromGroup(mi):
               print "Gvert:",i
         for face in mesh.faces:
            if len(face)!=3:
                print "ERROR: NOT A TRIANGLE ONLY MESH ! (select all vertices and use CTRL+T)"
                      for i in range(3): #triangles only ! (CTRL+T)
                          #indx=face.vlist.index(face[i])
                indx=face.v[i].index
                #print "Vertex:",indx
                ngrp="" # default no group name
                for mi in mgroup:
                   #print "group:",mesh.getVertsFromGroup(mi,0,[indx])
                   if (len(mesh.getVertsFromGroup(mi,0,[indx]))>0):
                      #print "group:",indx,mi
                      ngrp = "@@ " + mi
                #print "Vert / Group:",indx,"/",ngrp
                if(mesh.faceUV and face.image):
               u=face.uv[i][0]
               v=face.uv[i][1]
               layers=mesh.getUVLayerNames()
               texture=Blender.sys.basename(face.image.filename)
               but=texture
               cpt=0 # layers counter
               if(len(layers)>1):
                   org=mesh.activeUVLayer
                   texture=texture+';'
                   # loop on layers and append uv and name to a string
                   for layer in layers:
                  mesh.activeUVLayer=layer
                  uu=face.uv[i][0]
                  vv=face.uv[i][1]
                  t=Blender.sys.basename(face.image.filename)
                  if(t!=but):
                      if(cpt>0):
                     texture=texture+'|'
                      cpt=cpt+1
                      texture=texture+str(uu)+'|'+str(vv)+'|'+t
                   mesh.activeUVLayer=org
               self.file.write("%f %f %f %f %f %f %f %f %s %s\n" % (mesh.verts[indx].co[0],mesh.verts[indx].co[1],mesh.verts[indx].co[2],mesh.verts[indx].no[0],mesh.verts[indx].no[1],mesh.verts[indx].no[2],u,v,texture,ngrp))
                else:
                  if(mesh.vertexColors and len(face.col)>0):
                     self.file.write("%f %f %f %f %f %f 0 0 rgb(%3.3f,%3.3f,%3.3f) %s\n" % (mesh.verts[indx].co[0],mesh.verts[indx].co[1],mesh.verts[indx].co[2],mesh.verts[indx].no[0],mesh.verts[indx].no[1],mesh.verts[indx].no[2],face.col[i].r/255.0,face.col[i].g/255.0,face.col[i].b/255.0,ngrp))
                  else:
                     self.file.write("%f %f %f %f %f %f 0 0 rgb(0.6,0.6,0.6) %s\n" % (mesh.verts[indx].co[0],mesh.verts[indx].co[1],mesh.verts[indx].co[2],mesh.verts[indx].no[0],mesh.verts[indx].no[1],mesh.verts[indx].no[2],ngrp))
               

   def close(self):
         self.file.flush()
         self.file.close()

def fs_callback(filename):
   if filename.find('.tri', -4) <= 0: filename += '.tri'
   obj=source(filename)
   obj.writeFaces()
   obj.close
   print "Exported to %s. Textures must be .tga, uncompressed, origin NOT at lower-left.\n" % (filename)

#fs_callback("tt.tri")
#import rpdb2;rpdb2.start_embedded_debugger("aa")
Blender.Window.FileSelector(fs_callback, "Export Raydium Tri")
#fs_callback("tmp.tri")


you'll have a tri like this

Code:
1
-0.292892 2.700000 -0.707106 0.707083 0.000000 -0.707083 0 0 rgb(0.6,0.6,0.6) @@ B3
-0.444437 2.700000 -0.831475 0.555559 0.000000 -0.831446 0 0 rgb(0.6,0.6,0.6) @@ B3
-0.292892 3.300000 -0.707106 0.707083 0.000000 -0.707083 0 0 rgb(0.6,0.6,0.6) @@ B3
-0.444437 2.700000 -0.831475 0.555559 0.000000 -0.831446 0 0 rgb(0.6,0.6,0.6) @@ B3
-0.444437 3.300000 -0.831475 0.555559 0.000000 -0.831446 0 0 rgb(0.6,0.6,0.6) @@ B3
-0.292892 3.300000 -0.707106 0.707083 0.000000 -0.707083 0 0 rgb(0.6,0.6,0.6) @@ B3
...
-1.000007 2.300000 -1.000000 0.000000 0.000000 -1.000000 0 0 rgb(0.6,0.6,0.6)
-1.195097 2.300000 -0.980784 -0.195074 0.000000 -0.980773 0 0 rgb(0.6,0.6,0.6)
-1.195097 2.700000 -0.980784 -0.195074 0.000000 -0.980773 0 0 rgb(0.6,0.6,0.6) @@ B3
-1.000007 2.300000 -1.000000 0.000000 0.000000 -1.000000 0 0 rgb(0.6,0.6,0.6)
-1.195097 2.700000 -0.980784 -0.195074 0.000000 -0.980773 0 0 rgb(0.6,0.6,0.6) @@ B3
-1.000007 2.700000 -1.000000 0.000000 0.000000 -1.000000 0 0 rgb(0.6,0.6,0.6) @@ B3
-1.195097 2.300000 -0.980784 -0.195074 0.000000 -0.980773 0 0 rgb(0.6,0.6,0.6)
-1.382689 2.300000 -0.923878 -0.382672 0.000000 -0.923856 0 0 rgb(0.6,0.6,0.6)
...
-0.168529 1.899999 -0.555569 0.831446 0.000000 -0.555559 0 0 rgb(0.6,0.6,0.6) @@ B2
-0.292892 2.299999 -0.707106 0.707083 0.000000 -0.707083 0 0 rgb(0.6,0.6,0.6)
-0.168529 2.299999 -0.555569 0.831446 0.000000 -0.555559 0 0 rgb(0.6,0.6,0.6)
-0.292892 1.399999 -0.707106 0.707083 0.000000 -0.707083 0 0 rgb(0.6,0.6,0.6) @@ B2
-0.444437 1.400000 -0.831475 0.555559 0.000000 -0.831446 0 0 rgb(0.6,0.6,0.6) @@ B2
-0.292892 1.899999 -0.707106 0.707083 0.000000 -0.707083 0 0 rgb(0.6,0.6,0.6) @@ B2
...
-0.000000 1.399999 0.000002 1.000000 0.000000 0.000000 0 0 rgb(0.6,0.6,0.6) @@ B2
-0.019214 0.899999 -0.195089 0.980773 0.000000 -0.195074 0 0 rgb(0.6,0.6,0.6) @@ B1
-0.076120 0.899999 -0.382682 0.923856 0.000000 -0.382672 0 0 rgb(0.6,0.6,0.6) @@ B1
-0.076120 1.399999 -0.382682 0.923856 0.000000 -0.382672 0 0 rgb(0.6,0.6,0.6) @@ B2
-0.019214 0.899999 -0.195089 0.980773 0.000000 -0.195074 0 0 rgb(0.6,0.6,0.6) @@ B1
-0.076120 1.399999 -0.382682 0.923856 0.000000 -0.382672 0 0 rgb(0.6,0.6,0.6) @@ B2
-0.019214 1.399999 -0.195089 0.980773 0.000000 -0.195074 0 0 rgb(0.6,0.6,0.6) @@ B2


Hope this can help.

Group name are not directly linked to vertices, so i need to look up each vertice, this is very slow and slow down all export process.

We probably need to change some things, but it's for tests purpose.

Have a nice day
Ouille


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 01, 2007 5:05 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Great! i'll test it ASAP. Sadly i think i won't be able to do that until tomorrow.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 03, 2007 8:08 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Hmm, i got problems:
Code:
**** START ****
/home/vicente/huesos.bvh
Armature
<type 'Armature'>
**** END ****
Exporting armature Armature to file /home/vicente/huesos.bvh
Traceback (most recent call last):
  File "<string>", line 162, in exportBVH
  File "<string>", line 102, in printArmatureHierarchie
  File "<string>", line 60, in getBoneRestRot
ValueError: object "Master" not found

Here you can get the testing file i used:
http://vicentecarro.dyndns.org/raydium/huesos.blend


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 03, 2007 8:21 pm 
Offline

Joined: Sun Oct 09, 2005 10:46 pm
Posts: 759
Hello,

Here i don't have problem.
But i perhaps mis-understand.

I've just modified tri export to add armature associated with vertex.
I haven't touch to bhv.

You're file don't seem to have armature associated to vertex

here is a sample of my out tri associated with your file.
Code:
1
-1.000000 1.959800 1.000000 -0.707083 0.000000 0.707083 0 0 rgb(0.6,0.6,0.6)
-1.000000 4.000000 1.000000 -0.666646 0.666646 0.333323 0 0 rgb(0.6,0.6,0.6)
-1.000000 1.959801 -1.000000 -0.707083 0.000000 -0.707083 0 0 rgb(0.6,0.6,0.6)
-1.000000 4.000000 1.000000 -0.666646 0.666646 0.333323 0 0 rgb(0.6,0.6,0.6)
-1.000000 4.000001 -1.000000 -0.577349 0.577349 -0.577349 0 0 rgb(0.6,0.6,0.6)
-1.000000 1.959801 -1.000000 -0.707083 0.000000 -0.707083 0 0 rgb(0.6,0.6,0.6)
-1.000000 -0.039999 1.000000 -0.707083 0.000000 0.707083 0 0 rgb(0.6,0.6,0.6)
-1.000000 1.959800 1.000000 -0.707083 0.000000 0.707083 0 0 rgb(0.6,0.6,0.6)
-1.000000 -0.039999 -1.000000 -0.707083 0.000000 -0.707083 0 0 rgb(0.6,0.6,0.6)
-1.000000 1.959800 1.000000 -0.707083 0.000000 0.707083 0 0 rgb(0.6,0.6,0.6)
-1.000000 1.959801 -1.000000 -0.707083 0.000000 -0.707083 0 0 rgb(0.6,0.6,0.6)
-1.000000 -0.039999 -1.000000 -0.707083 0.000000 -0.707083 0 0 rgb(0.6,0.6,0.6)
1.000000 1.959798 1.000000 0.707083 0.000000 0.707083 0 0 rgb(0.6,0.6,0.6)

Other lines are like thoses.

I use blender 2.45.
I have python 2.5 installed but i don't think it's the problem.

Can you give me a really simple .blend file ?

Have a nice night ;o)
Ouille


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 03, 2007 8:59 pm 
Offline

Joined: Sun Oct 09, 2005 10:46 pm
Posts: 759
Hello,

Looking forward i have problem with your file.

You use armature as modifier.

I work on this type of association:
http://mmaigrot.free.fr/didac-blender/ikas/ik-p1.php

Armature are associated with vertex on a per vertex basis (using groups of vertex).
I extract armature name from this group name.

In your case, the whole vertex are associated with the same armature.
I can probably just give the armature name, but not the bone.

in your file you'll have
Quote:
@@ Armature

at each end of ligne.


Is there what you want ?

Bye
Ouille.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 03, 2007 9:22 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
First, sorry, the problem i told you was refering to bvh exporter, not your modification.
However, as you say, there is a problem with the way to get the bone info.

What i need is the bone(s) name(s) applied in each vertex. In a future, we'll add also the weight(force) of each bone.

For example is the next vertex is under the influence of 2 different bones i should get something like
Code:
-0.292892 1.899999 -0.707106 0.707083 0.000000 -0.707083 0 0 rgb(0.6,0.6,0.6) @@ B1,B2


The bones MUST be of the same armature...
update: And now i'm seeing what you say. I also need to know the name of the armature...

So the format can be as:

Code:
-0.292892 1.899999 -0.707106 0.707083 0.000000 -0.707083 0 0 rgb(0.6,0.6,0.6) @@ B1,B2
...at the final of the file...
ARMATURE:nameofarmature

For example


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 03, 2007 9:28 pm 
Offline

Joined: Sun Oct 09, 2005 10:46 pm
Posts: 759
Ouch ...

Your vertex are associated to bones via groups ?

If yes, i have small modifs todo.

Second problem, i'm not sure to know where i can find armatture name ...

Last, in your sample, there are no vertex associated with bones ? I'm right ?

Have a nice day
Ouille


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 03, 2007 10:27 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Nope, i'm not using vertexgroups, i'm using bones with envelopes.
If i'm not wrong, the "vertexgroups" way don't allow different forces(weights) of various bones at time in one vertex. So i have to use the "bones with envelopes" way.
About armature name...no idea, however you can left it for the last.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group