Source

pygamekit / gameobject.pxd


from prerequisites cimport *
from variable cimport *
from scene cimport *
from collision cimport *
from animation cimport *
cimport gkmath

#cdef class GameObject(pywrap):
    #pass

cdef extern from "OgreSceneNode.h":
    cdef cppclass Ogre_SceneNode "Ogre::SceneNode":
        const_std_string& getName()
        void setVisible(bool,bool)
        
        Ogre_MovableObject *getAttachedObject (int)

cdef extern from "OgreMovableObject.h":

    cdef cppclass Ogre_MovableObject "Ogre::MovableObject":
        const_std_string& getMovableType()
        
    Ogre_Entity *cast_entity "static_cast<Ogre::Entity *>" (void *)
    
cdef extern from "OgreEntity.h":
    enum:
        VES_TANGENT "Ogre::VES_TANGENT"
    cdef cppclass Ogre_Entity "Ogre::Entity":
        void buildTangentVectors "getMesh()->buildTangentVectors"(
            int, unsigned short sourceTexCoordSet, unsigned short index, bool splitMirrored, bool splitRotated, bool storeParityInW)

cdef extern from "gkScene.h":
    cppclass gkScene
    
cdef extern from "gkGameObject.h":
    
    cdef enum gkGameObjectTypes:
        GK_OB_NULL = 0
        GK_CAMERA
        GK_LIGHT
        GK_ENTITY
        GK_OBJECT
        GK_SKELETON
        GK_PARTICLES

    cdef cppclass gkGameObject:
        
        Ogre_SceneNode*          getNode()
        int getType()
        gkGameObjectProperties&   getProperties()
        
        gkScene*        getOwner()
        
        gkEntity*       getEntity()
        gkSkeleton*     getSkeleton()
        
        gkVariable* createVariable(const_std_string& name, bool debug)
        gkVariable* getVariable(const_std_string& name)
        bool        hasVariable(const_std_string& name)
        void        removeVariable(const_std_string& name)
        void        clearVariables()
    
        gkGameObject* clone(const_std_string& name)

        #bool                     hasParent()
        gkGameObject*             getParent()
        gkGameObjectArray&        getChildren()

        void setParent(gkGameObject* par)
        void setParentInPlace(gkGameObject* par)
        void clearParent()
        void clearParentInPlace()
        void addChild(gkGameObject* ob)
        void removeChild(gkGameObject* ob)
        bool hasChild(gkGameObject* ob)
    
        gkmath.TransformState&  getTransformState()
        gkmath.Matrix4&         getTransform()
        gkmath.Vector3&         getPosition()
        gkmath.Quaternion&      getOrientation()
        gkmath.Vector3&         getScale()
        gkmath.Euler            getRotation()

        gkmath.TransformState&  getWorldTransformState()
        gkmath.Matrix4&         getWorldTransform()
        gkmath.Vector3&         getWorldPosition()
        gkmath.Vector3&         getWorldScale()
        gkmath.Quaternion&      getWorldOrientation()
        gkmath.Euler            getWorldRotation()


        void applyTransformState(gkmath.TransformState& newstate, Real& weight)
        void setTransform(gkmath.Matrix4& v)
        void setTransform(gkmath.TransformState& v)
        void setPosition(gkmath.Vector3& v)
        void setScale(gkmath.Vector3& v)

        void setOrientation(gkmath.Quaternion& q)
        void setOrientation(gkmath.Euler& v)

        void rotate(gkmath.Euler& drot, int tspace)
        void rotate(gkmath.Quaternion& q, int tspace)
        void translate(gkmath.Vector3& dloc, int tspace)
        void scale(gkmath.Vector3& dscale)

        void yaw(gkmath.Radian& v, int tspace)
        void pitch(gkmath.Radian& v, int tspace)
        void roll(gkmath.Radian& v, int tspace)

        # Rigid body

        void        applyTorque(gkmath.Vector3& t, int tspace)
        void        applyForce(gkmath.Vector3& f, int tspace)
        void        setLinearVelocity(gkmath.Vector3& linv, int tspace)
        void        setAngularVelocity(gkmath.Vector3& angv, int tspace)
        gkmath.Vector3   getLinearVelocity()
        gkmath.Vector3   getAngularVelocity()
        
        # physics

        #void           attachRigidBody(gkRigidBody* body)
        #gkRigidBody*   getAttachedBody()
        #void           attachCharacter(gkCharacter* character)
        #gkCharacter*   getAttachedCharacter()
        gkPhysicsController*     getPhysicsController()
        #btCollisionObject*       getCollisionObject()

        # Animation
        
        gkAnimationPlayer*     addAnimation(const_std_string name)
        gkAnimationPlayer*     getAnimationPlayer(const_std_string name)
        
        void playAnimation(gkAnimationPlayer* act, Real blend, int mode, int priority)
        void stopAnimation(gkAnimationPlayer* act)
        
        gkAnimations& getAnimations()
    
    cppclass gkSkeleton
    
    cdef cppclass gkEntity(gkGameObject):
        void setSkeleton(gkSkeleton* skel)
        void createInstance()
        
    enum gkGameObjectMode:
        GK_GHOST
        GK_ACTOR
        GK_INVISIBLE
        GK_OCCLUDER
        GK_HAS_LOGIC
        GK_IMMOVABLE
        GK_STATIC_GEOM
        
    cdef cppclass gkGameObjectProperties:
        int m_mode
        bool isActor()
        bool isInvisible()
        bool isOccluder()
        bool isGhost()
    
cdef extern from "gkBone.h":
    cdef cppclass gkBone:
        void applyChannelTransform(gkmath.TransformState& channel, Real weight)
        void applyPoseTransform(gkmath.TransformState& pose)
        gkmath.TransformState&        getPose()
    
cdef extern from "gkSkeleton.h":
    cdef cppclass gkSkeleton:
        gkBone*              getBone(const_std_string& name)

cdef extern from "gkCamera.h":
    cdef cppclass gkCamera:
        pass

cdef extern from "gkGameObject.h":
    
    cdef cppclass gkGameObjectHashMapIterator "gkGameObjectHashMap::Iterator":
        bool hasMoreElements()
        gkGameObjectHashMapIterator getNext()
        std_string    first
        gkGameObject* second

    cdef cppclass gkGameObjectHashMap:
        gkGameObjectHashMapIterator iterator()
        unsigned int size()
        
    cdef cppclass gkGameObjectArrayIterator "gkGameObjectArray::Iterator":
        bool hasMoreElements()
        gkGameObject* getNext()
        unsigned int size()

    cdef cppclass gkGameObjectArray:
        gkGameObjectArrayIterator iterator()
        unsigned int size()
        #todo: find, get element N
        
    cdef cppclass gkAnimationsIterator "utHashTable<gkHashedString, gkAnimationPlayer*>::Iterator":
        bool hasMoreElements()
        #gkAnimationsIterator getNext() #wrong type?
        gkHashedString     peekNextKey()
        gkAnimationPlayer* peekNextValue()
        void next()

    cdef cppclass gkAnimations "utHashTable<gkHashedString, gkAnimationPlayer*>":
        gkAnimationsIterator iterator()
        unsigned int size()