Source

pygamekit / gameobject.pxd


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

#cdef class GameObject(pywrap):
    #pass

cdef extern from "gkScene.h":
    cppclass gkScene
    
cdef extern from "gkGameObject.h":

    cppclass gkEntity
    cppclass gkSkeleton
    
    cdef enum gkGameObjectTypes:
        GK_OB_NULL = 0
        GK_CAMERA
        GK_LIGHT
        GK_ENTITY
        GK_OBJECT
        GK_SKELETON
        GK_PARTICLES
        
    cppclass gkInstancedObject:
        void createInstance(bool queue=*)
        void destroyInstance(bool queue=*)
        void reinstance(bool queue=*)

    cdef cppclass gkGameObject(gkInstancedObject):
    
        gkString&   getName()
        gkString&   getGroupName()
        
        int getType()
        gkGameObjectProperties&   getProperties()
        
        #void            setOwner(gkScene*)  # use scene methos instead
        gkScene*        getOwner()
        
        gkEntity*       getEntity()
        gkSkeleton*     getSkeleton()
        
        gkVariable* createVariable(gkString& name, bool debug)
        gkVariable* getVariable(gkString& name)
        bool        hasVariable(gkString& name)
        void        removeVariable(gkString& name)
        void        clearVariables()
    
        gkGameObject* clone(gkString& name)

        #bool                     hasParent()
        gkGameObject*             getParent()
        gkGameObjectArray&        getChildren()
        
        void setVisible(bool)
        void setVisibleRecursive(bool)
        bool getVisible()

        void setParent(gkGameObject* par)
        void setParentInPlace(gkGameObject* par)
        void clearParent()
        void clearParentInPlace()
        void addChild(gkGameObject* ob)
        void removeChild(gkGameObject* ob)
        bool hasChild(gkGameObject* ob)
    
        gkTransformState&  getTransformState()
        gkMatrix4&         getTransform()
        gkVector3&         getPosition()
        gkQuaternion&      getOrientation()
        gkVector3&         getScale()
        gkEuler            getRotation()

        gkTransformState&  getWorldTransformState()
        gkMatrix4&         getWorldTransform()
        gkVector3&         getWorldPosition()
        gkVector3&         getWorldScale()
        gkQuaternion&      getWorldOrientation()
        gkEuler            getWorldRotation()


        void applyTransformState(gkTransformState& newstate, gkScalar& weight)
        void setTransform(gkMatrix4& v)
        void setTransform(gkTransformState& v)
        void setPosition(gkVector3& v)
        void setScale(gkVector3& v)

        void setOrientation(gkQuaternion& q)
        void setOrientation(gkEuler& v)

        void rotate(gkEuler& drot, int tspace)
        void rotate(gkQuaternion& q, int tspace)
        void translate(gkVector3& dloc, int tspace)
        void scale(gkVector3& dscale)

        void yaw(gkRadian& v, int tspace)
        void pitch(gkRadian& v, int tspace)
        void roll(gkRadian& v, int tspace)

        # Rigid body

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

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

        # Animation
        
        gkAnimationPlayer*     addAnimation(gkString name)
        gkAnimationPlayer*     getAnimationPlayer(gkString name)
        
        void playAnimation(gkAnimationPlayer* act, gkScalar blend, int mode, int priority)
        void stopAnimation(gkAnimationPlayer* act)
        
        gkAnimations& getAnimations()
    
    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(gkTransformState& channel, gkScalar weight)
        void applyPoseTransform(gkTransformState& pose)
        gkTransformState&        getPose()
    
cdef extern from "gkSkeleton.h":
    cdef cppclass gkSkeleton:
        gkBone*              getBone(gkString& name)

cdef extern from "gkGameObject.h":
    
    cdef cppclass gkGameObjectHashMapIterator "gkGameObjectHashMap::Iterator":
        bool hasMoreElements()
        gkGameObjectHashMapIterator getNext()
        gkString    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()
        
cdef extern from "gkLight.h":
    cppclass gkLight(gkGameObject)
        
cdef extern from "Particles/gkParticleObject.h":
    cppclass gkParticleObject(gkGameObject)
        
cdef extern from "gkGameObjectManager.h":
    cppclass gkGameObjectManager "gkGameObjectManager::getSingleton":
        gkGameObjectManager()
        gkGameObject* createObject(gkString&)
        gkLight* createLight(gkString&)
        gkCamera* createCamera(gkString&)
        gkEntity* createEntity(gkString&)
        gkSkeleton* createSkeleton(gkString&)
        gkParticleObject* createParticleObject(gkString&)

        gkGameObject* getObject(gkString&)
        gkLight* getLight(gkString&)
        gkCamera* getCamera(gkString&)
        gkEntity* getEntity(gkString&)
        gkSkeleton* getSkeleton(gkString&)
        gkParticleObject* getParticleObject(gkString&)
        
        void destroy(gkGameObject*)

cdef extern from "gkResourceName.h":
    cppclass gkResourceName:
        gkResourceName()
        gkResourceName(char* inName, char* inGroup=*)
        gkResourceName(gkString& inName, gkString& inGroup=*)
        #gkResourceName(gkHashedString& inName, gkHashedString& inGroup=*)