Changeset 1351

Show
Ignore:
Timestamp:
09/03/08 03:57:06 (3 months ago)
Author:
ArcRiley
Message:

Tickets #916 and #927 :

  • renamed soy.actions.Rotate → soy.actions.Torque
  • more soy.atoms and soy.actions documentation
  • soy.atoms.Axis now inherits soy.atoms.Vector as a rotational vector
  • soy.actions.Torque now uses soy.atoms.Axis
  • TexBlocks? example now uses cursor keys to change rotation
Location:
trunk/pysoy
Files:
2 removed
10 modified
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/pysoy/examples/TexBlocks.py

    r1350 r1351  
    5151key = soy.controllers.Keyboard(win) 
    5252marble = bks['Marble'] 
    53 key['Q'] = soy.actions.Force(marble, soy.atoms.Vector((-100,    0,    0))) 
    54 key['R'] = soy.actions.Force(marble, soy.atoms.Vector((   0,  100,    0))) 
    55 key['S'] = soy.actions.Force(marble, soy.atoms.Vector(( 100,    0,    0))) 
    56 key['T'] = soy.actions.Force(marble, soy.atoms.Vector((   0, -100,    0))) 
    57 key['U'] = soy.actions.Force(marble, soy.atoms.Vector((   0,    0, -100))) 
    58 key['V'] = soy.actions.Force(marble, soy.atoms.Vector((   0,    0,  100))) 
     53key['Q'] = soy.actions.Torque(marble, soy.atoms.Axis((-100,    0,    0))) 
     54key['R'] = soy.actions.Torque(marble, soy.atoms.Axis((   0,  100,    0))) 
     55key['S'] = soy.actions.Torque(marble, soy.atoms.Axis(( 100,    0,    0))) 
     56key['T'] = soy.actions.Torque(marble, soy.atoms.Axis((   0, -100,    0))) 
     57key['U'] = soy.actions.Torque(marble, soy.atoms.Axis((   0,    0, -100))) 
     58key['V'] = soy.actions.Torque(marble, soy.atoms.Axis((   0,    0,  100))) 
    5959key['q'] = soy.actions.Quit() 
    6060key[ 1 ] = soy.actions.Quit() # 9 = esc key 
  • trunk/pysoy/include/soy.actions.pxd

    r1350 r1351  
    3636  cdef object                  _callback 
    3737 
    38 cdef class Rotate (Action) : 
    39   cdef soy.bodies.Body         _bod 
    40   cdef ode.dVector3            _rotvector 
     38cdef class Torque (Action) : 
     39  cdef soy.bodies.Body         _target 
     40  cdef soy.atoms.Axis          _vector 
  • trunk/pysoy/include/soy.atoms.pxd

    r1241 r1351  
    2525cimport ode 
    2626 
    27 cdef class Vertex : 
    28   cdef soy._datatypes.VertexList  _list 
    29   cdef int                        _index 
    30   cdef void*                      _mutex 
    31  
    32  
    3327cdef class Face : 
    3428  cdef soy._datatypes.FaceList    _list 
     
    3630  cdef void*                      _mutex 
    3731 
     32cdef class Vector : 
     33  cdef ode.dVector3               _position 
    3834 
    39 cdef class Vector : 
    40   cdef ode.dVector3 _position 
     35cdef class Axis (Vector) : 
     36  cdef float                      _noop 
     37 
     38cdef class Vertex : 
     39  cdef soy._datatypes.VertexList  _list 
     40  cdef int                        _index 
     41  cdef void*                      _mutex 
  • trunk/pysoy/include/soy.bodies.pxd

    r1317 r1351  
    7979  cdef void                     _copyFrom                ( self, ode.dReal* ) 
    8080  cdef void                     _addForce                ( self, ode.dVector3 ) 
    81   cdef void                     _addRotation             ( self, ode.dVector3 ) 
     81  cdef void                     _addTorque               ( self, ode.dVector3 ) 
    8282  # WindowLoop functions 
    8383  cdef void                     _calcFogCoords           ( self )         nogil 
  • trunk/pysoy/src/actions/Quit.pym

    r1225 r1351  
    1919 
    2020cdef class Quit (Action) : 
    21   '''PySoy Quit 
     21  '''soy.actions.Quit 
    2222 
    2323    When called PySoy will quit.  There are no arguments to this class. 
    24     See soy.actions.Action for more information. 
    2524  ''' 
    2625 
  • trunk/pysoy/src/actions/Torque.pym

    r1350 r1351  
    1 # PySoy's action.Force class 
     1# PySoy's action.Torque class 
    22# 
    33# Copyright (C) 2006,2007,2008 PySoy Group 
     
    1818# $Id$ 
    1919 
    20 cdef class Force (Action) : 
    21   '''soy.actions.Force 
     20cdef class Torque (Action) : 
     21  '''soy.actions.Torque 
    2222 
    23     Adds velocity to a target L{body<soy.bodies.Body>}. 
     23    Adds rotational velocity to a target L{body<soy.bodies.Body>}. 
    2424 
    2525    @type  target : soy.bodies.Body 
    26     @param target : Body which force will be applied to 
    27     @type  vector : soy.atoms.Vector 
    28     @param vector : Vector of force to be applied 
     26    @param target : Body which torque will be applied to 
     27    @type  vector : soy.atoms.Axis 
     28    @param vector : Rotational vector to be applied 
    2929  ''' 
    3030 
     
    3737    if not isinstance(target, soy.bodies.Body) : 
    3838      raise TypeError('first argument must be an instance of soy.bodies.Body') 
    39     if not isinstance(vector, soy.atoms.Vector) : 
    40       raise TypeError('second argument must be an instance of soy.atoms.Vector') 
     39    if not isinstance(vector, soy.atoms.Axis) : 
     40      raise TypeError('second argument must be an instance of soy.atoms.Axis') 
    4141    self._target = target 
    4242    self._vector = vector 
     
    5050  cdef void _perform(self, unsigned int _duration) : 
    5151    # 
    52     # Body._addForce calls ode.dBodyAddForce on itself with proper locking 
    53     (<soy.bodies.Body> self._target)._addForce(self._vector._position) 
     52    # Body._addTorque calls ode.dBodyAddTorque on itself with proper locking 
     53    (<soy.bodies.Body> self._target)._addTorque(self._vector._position) 
  • trunk/pysoy/src/actions/soy.actions.pyx

    r1305 r1351  
    2424include "Quit.pym" 
    2525include "Stdout.pym" 
    26 include "Locomotive.pym" 
    27 include "Rotate.pym" 
     26include "Torque.pym" 
  • trunk/pysoy/src/atoms/Axis.pym

    r1227 r1351  
    1818# $Id$ 
    1919 
    20 ''' 
    21   We need an atom class called Axis storing the three axis values ODE  
    22 takes for various functions (joints, rotating a body, etc) 
    23   Testing should be done to ensure the three values constrain to ODE's specs  
    24 and a cdef function should return a dReal[3] for internal use. Lastly, adding  
    25 a function to soy.bodies.Body such as .rotate which accepts an axis and angle,  
    26 applying these to dRFromAxisAndAngle, or axis or two axis arguments to 
    27  dRFrom2Axes, or None for both which sets the body's rotational identity.  
    28 ''' 
    2920 
    30 cdef class Axis : 
    31   ''' PySoy Axis 
     21cdef class Axis (Vector) : 
     22  '''soy.atoms.Axis 
    3223 
    33       An atom class which stores 3 ODE axis values. 
    34       Body, Bone, Joint. 
     24    An axis is a rotational L{vector<soy.atoms.Vector>}. 
    3525  ''' 
    36        
    37   ############################################################################ 
    38   # 
    39   # Python functions 
    40   # 
    41  
    42   def __cinit__(self, *args, **keywords) : 
    43     pass 
    44  
    45  
    46   def __dealloc__(self) : 
    47     pass 
    48  
    49  
    50   def __repr__(self) : 
    51     return '<%s>' % self.__class__.__name__ 
    52  
    53  
    54   ############################################################################ 
    55   # 
    56   # Properties 
    57   # 
    58  
    59   property orientation: 
    60     def __get__(self) : 
    61       pass 
    62  
    63     def __set__(self, vector) : 
    64       pass 
  • trunk/pysoy/src/atoms/Vector.pym

    r1227 r1351  
    5252     
    5353  def __repr__(self) : 
    54     return "<Vector at (%f, %f, %f) >" % (self._position[0], 
    55                                self._position[1], 
    56                                self._position[2]) 
     54    ''' 
     55    @rtype  : string 
     56    @return : class name and value 
     57    ''' 
     58    return '<%s (%f, %f, %f)>' % (self.__class__.__name__, 
     59                                  self._position[0], 
     60                                  self._position[1], 
     61                                  self._position[2]) 
    5762 
    5863 
  • trunk/pysoy/src/atoms/soy.atoms.pyx

    r1236 r1351  
    1919 
    2020include "__init__.pym" 
     21include "Axis.pym" 
    2122include "Face.pym" 
    2223include "Vertex.pym" 
  • trunk/pysoy/src/bodies/Body.pym

    r1305 r1351  
    448448 
    449449 
    450   cdef void _addRotation(self, ode.dVector3 _rotvector) : 
     450  cdef void _addTorque(self, ode.dVector3 _vector) : 
    451451    if self._scene is None : 
    452452      raise UnboundLocalError('Body is not in a scene') 
    453453    self._scene._stepLock() 
    454     ode.dBodyAddTorque(self._bodyID, _rotvector[0], _rotvector[1], _rotvector[2]) 
     454    ode.dBodyAddTorque(self._bodyID, _vector[0], _vector[1], _vector[2]) 
    455455    self._scene._stepUnLock() 
    456456