[Bf-python] bug or evolution of Object module?

PERIN Jean-Baptiste jb_perin at yahoo.fr
Mon Nov 28 13:45:45 CET 2005


I forgot to explain the modification I made .. 

line 234, in makeJoint (...)
=============================

  # Offset Empty
  ob.setLocation(offset[0]*scale, offset[1]*scale,
offset[2]*scale)


is replaced by:
---------------
  #compute position in worldspace system  
  offsetX, offsetY, offsetZ = offset[0], offset[1],
offset[2]
  if parent[-1] != None:
      obParent = Object.Get(prefix + parent[-1])
      offsetX, offsetY, offsetZ =
offsetX+obParent.getLocation()[0],
offsetY+obParent.getLocation()[1],
offsetZ+obParent.getLocation()[2]

  # Offset Empty
  ob.setLocation(offsetX*scale, offsetY*scale,
offsetZ*scale)


line 287 (with respect to previous modification),  in
makeEnd(...)
=================================================================
  # Offset Empty
  ob.setLocation(offset[0]*scale, offset[1]*scale,
offset[2]*scale) 

becomes:
--------
  #compute position in worldspace system
  offsetX, offsetY, offsetZ =
offset[0]+obParent.getLocation()[0],
offset[1]+obParent.getLocation()[1],
offset[2]+obParent.getLocation()[2]
  
  # Offset Empty
  ob.setLocation(offsetX*scale, offsetY*scale,
offsetZ*scale) 



Best regards,
Jean-Baptiste PERIN


--- PERIN Jean-Baptiste <jb_perin at yahoo.fr> a écrit :

> 
> This morning, as I was trying to use bvh_import
> script, I noticed that there were a big issue with
> this marvellous script in Blender 2.40 CVS 05/11/27
> 
> I investigated and I realized that the problem was
> coming from the Object module ..
> 
> By the past, the coordinates passed to the
> Object.setLocation() function was expressed
> relatively
> to the parent object.
> 
> It seems that it no longer is the case ..
> 
> To correct the bvh_import script.. I had to express
> empties'position with absolute coordinates  (in
> worldspace) instead of relative coordinates
> 
> I find it is weird ..
> 
> Is that a new design for Object module ?.. or is
> that
> just a temporary bug due to intense recoding ?
> 
> I hope it is just a temporary bug .. 
> otherwise .. there are going to be a lot of script
> to
> update .. and please consider the attached script as
> a
> canditate fix
> 
> Best regards, 
> Jean-Baptiste PERIN
> 
> PS: by the way .. when is the new Armature module
> documentation due to be released ?.. I think I'll
> have
> to correct the BVH2ARM.py script as well ..and to do
> so .. I need to know how does the new Armature
> module
> behaves ..
> 
> 
> 	
> 
> 	
> 		
>
___________________________________________________________________________
> 
> Appel audio GRATUIT partout dans le monde avec le
> nouveau Yahoo! Messenger 
> Téléchargez cette version sur
http://fr.messenger.yahoo.com> #!BPY
> 
> """
> Name: 'Motion Capture (.bvh)...'
> Blender: 239
> Group: 'Import'
> Tip: 'Import a (.bvh) motion capture file'
> """
> 
> __author__ = "Campbell Barton"
> __url__ = ("blender", "elysiun",
>
"http://jmsoler.free.fr/util/blenderfile/py/bvh_import.py")
> __version__ = "1.0.4 05/11/28"
> 
> __bpydoc__ = """\
> This script imports BVH motion capture data to
> Blender.
> 
> Supported: Poser 3.01<br>
> 
> Missing:<br>
> 
> Known issues:<br>
> 
> Notes:<br>
>    Jean-Michel Soler improved importer to support
> Poser 3.01 files;<br>
>    Jean-Baptiste Perin wrote a script to create an
> armature out of the
> Empties created by this importer, it's in the
> Scripts window -> Scripts -> Animation menu.
> """
> 
> # $Id: bvh_import.py,v 1.7 2005/06/27 15:57:09
> sirdude Exp $
> #
> 
> #===============================================#
> # BVH Import script 1.04 patched by JB Perin    #
> # corrected for 2.40 (empties location must now #
> # be expressed in worldspace coordinates)       #
> # How weird ..                                  #
> # 28/11/2005,                                   #  
> #===============================================#
> 
> #===============================================#
> # BVH Import script 1.03 patched by Campbell    #
> # Small optimizations and scale input           #
> # 01/01/2005,                                   #  
> #===============================================#
> 
> #===============================================#
> # BVH Import script 1.02 patched by Jm Soler    #
> # to the Poser 3.01 bvh file                    # 
> # 28/12/2004,                                   #  
> #===============================================#
> 
> #===============================================#
> # BVH Import script 1.0 by Campbell Barton      #
> # 25/03/2004, euler rotation code taken from    #
> # Reevan Mckay's BVH import script v1.1         #
> # if you have any questions about this script   #
> # email me ideasman at linuxmail.org               #
> #===============================================#
> 
> #===============================================#
> # TODO:                                         #
> # * Create bones when importing                 #
> # * Make an IPO jitter removal script           #
> # * Work out a better naming system             #
> #===============================================#
> 
> #
>
--------------------------------------------------------------------------
> 
> # BVH Import v0.9 by Campbell Barton (AKA Ideasman) 
> #
>
--------------------------------------------------------------------------
> 
> # ***** BEGIN GPL LICENSE BLOCK ***** 
> # 
> # This program is free software; you can
> redistribute it and/or 
> # modify it under the terms of the GNU General
> Public License 
> # as published by the Free Software Foundation;
> either version 2 
> # of the License, or (at your option) any later
> version. 
> # 
> # This program is distributed in the hope that it
> will be useful, 
> # but WITHOUT ANY WARRANTY; without even the implied
> warranty of 
> # MERCHANTABILITY or FITNESS FOR A PARTICULAR
> PURPOSE.  See the 
> # GNU General Public License for more details. 
> # 
> # You should have received a copy of the GNU General
> Public License 
> # along with this program; if not, write to the Free
> Software Foundation, 
> # Inc., 59 Temple Place - Suite 330, Boston, MA 
> 02111-1307, USA. 
> # 
> # ***** END GPL LICENCE BLOCK ***** 
> #
>
--------------------------------------------------------------------------
> 
> 
> 
> import string
> import math
> import Blender
> from Blender import Window, Object, Scene, Ipo, Draw
> from Blender.Scene import Render
> 
> 
> # # PSYCO IS CRASHING ON MY SYSTEM
> # # Attempt to load psyco, speed things up
> # try:
> #   print 'using psyco to speed up BVH importing'
> #   import psyco
> #   psyco.full()
> #  
> # except:
> #   print 'psyco is not present on this system'
> 
> # Default scale
> scale = 0.01
> 
> # Update as we load?
> debug = 0
> 
> # Get the current scene.
> scn = Scene.GetCurrent()
> context = scn.getRenderingContext()
> 
> # Here we store the Ipo curves in the order they
> load.
> channelCurves = []
> 
> # Object list
> # We need this so we can loop through the objects
> and edit there IPO's 
> # Chenging there rotation to EULER rotation
> objectList = []
> 
> def getScale():
> 	return Draw.PupFloatInput('BVH Scale: ', 0.01,
> 0.001, 10.0, 0.1, 3)
> 
> def MAT(m):
> 	if len(m) == 3:
> 		return Blender.Mathutils.Matrix(m[0], m[1], m[2])
> 	elif len(m) == 4:
> 		return Blender.Mathutils.Matrix(m[0], m[1], m[2],
> m[3])
> 
> 
> 
> #===============================================#
> # eulerRotation: converts X, Y, Z rotation      #
> # to eular Rotation. This entire function       #
> # is copied from Reevan Mckay's BVH script      #
> #===============================================#
> # Vars used in eular rotation funtcion
> DEG_TO_RAD = math.pi/180.0
> RAD_TO_DEG = 180.0/math.pi
> PI=3.14159
> 
> def eulerRotate(x,y,z): 
>   #=================================
>   def RVMatMult3 (mat1,mat2):
>   #=================================
>     mat3=[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0]]
>     for i in range(3):
>       for k in range(3):
>         for j in range(3):
>          
> mat3[i][k]=mat3[i][k]+mat1[i][j]*mat2[j][k]
>     return mat3
>   
>   
>   #=================================
>   def	RVAxisAngleToMat3 (rot4):
>   #	Takes a direction vector and
>   #	a rotation (in rads) and
>   #	returns the rotation matrix.
>   #	Graphics Gems I p. 466:
>   #=================================
>     mat3=[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0]]
>     if math.fabs(rot4[3])>0.01:
>       s=math.sin(rot4[3])
>       c=math.cos(rot4[3])
>       t=1.0-math.cos(rot4[3])
>     else:
>       s=rot4[3]
>       c=1.0
>       t=0.0
> 
> 
=== message truncated ===>
_______________________________________________
> Bf-python mailing list
> Bf-python at projects.blender.org
>
http://projects.blender.org/mailman/listinfo/bf-python
> 



	

	
		
___________________________________________________________________________ 
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger 
Téléchargez cette version sur http://fr.messenger.yahoo.com



More information about the Bf-python mailing list