Source

pygamekit / gameobject.pxd

Full commit

from prerequisites cimport *
from variable cimport *
from scene 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)
    
        gkTransformState&  getTransformState()
        gkMatrix4&         getTransform()
        gkVector3&         getPosition()
        gkmath.Quaternion& getOrientation()
        gkVector3&         getScale()
        gkEuler          getRotation()

        gkTransformState&  getWorldTransformState()
        gkMatrix4&         getWorldTransform()
        gkVector3&         getWorldPosition()
        gkVector3&         getWorldScale()
        gkmath.Quaternion& getWorldOrientation()
        gkEuler            getWorldRotation()


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

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

        void rotate(gkEuler& drot, int tspace)
        void rotate(gkmath.Quaternion& 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(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 "Animation/gkAnimation.h":
    cdef cppclass gkAnimation:
        pass
    cdef cppclass gkAnimationPlayer:
        Real         getTimePosition()
        Real         getWeight()
        int          getMode()
        Real         getSpeedFactor()
        Real         getLength()

        void         setMode(int v)
        void         setAnimation(gkAnimation* v)
        void         setSpeedFactor(Real v)

        void         enable(bool v)
        bool         isEnabled()
        bool         isDone()

        void setBlendFrames(Real v)
        void setTimePosition(Real v)
        void setWeight(Real w)

        void evaluate(Real tick)
        void reset()
        
        gkGameObject* getObject()
    
cdef extern from "gkBone.h":
    cdef cppclass gkBone:
        void applyChannelTransform(gkTransformState& channel, Real weight)
        void applyPoseTransform(gkTransformState& pose)
        gkTransformState&        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()
        
cdef extern from "btBulletDynamicsCommon.h":
    
    cdef cppclass btManifoldPoint
    cdef cppclass btDynamicsWorld
    cdef cppclass btCollisionObject
    cdef cppclass btCollisionShape
    
cdef extern from "Physics/gkPhysicsController.h":
    
    
    cdef struct gkContactInfo:
        gkPhysicsController* collider
        btManifoldPoint      point

        #typedef utArray[gkContactInfo] Array
        #typedef utArrayIterator[Array] Iterator

    cdef cppclass gkPhysicsController:
        
        gkPhysicsController(gkGameObject* object, btDynamicsWorld* owner)
        #virtual void setTransformState(const gkTransformState& state)
        #virtual void updateTransform()

        bool isStaticObject()

        void suspend(bool v)
        bool isSuspended()

        #gkPhysicsProperties& getProperties()

        void enableContactProcessing(bool v)

        #gkContactInfo::Array&    getContacts()
        #gkContactInfo::Iterator  getContactIterator()
        
        bool collidesWith(gkGameObject* ob, gkContactInfo* cpy) #cpy = 0
        bool collidesWith(const_std_string& name, gkContactInfo* cpy, bool emptyFilter)#emptyFilter = true

        # Sensor tests,
        # If prop is empty and material is empty, return any old collision.
        # If onlyActor is true, filter collision on actor settings (gkGameObjectProperties).
        # If testAllMaterials is true, test all assigned opposed to only testing the first assigned.
        bool sensorCollides(const_std_string& prop, const_std_string& material, bool onlyActor, bool testAllMaterials)
        bool sensorCollides(const_std_string& prop, const_std_string& material, bool onlyActor, bool testAllMaterials, gkGameObjectArray*)
        bool sensorTest(gkGameObject* ob, const_std_string& prop, const_std_string& material, 
                        bool onlyActor, bool testAllMaterials)

        gkPhysicsController* castController(btCollisionObject* colObj)
        gkPhysicsController* castController(void* colObj)
        gkGameObject* castObject(btCollisionObject* colObj)


        btCollisionObject* getCollisionObject()

        btCollisionShape* getShape()

        btDynamicsWorld* getOwner()

        gkGameObject* getObject()


        #gkBoundingBox getAabb()

        #void setShape(btCollisionShape* shape)

        #virtual void create()
        #virtual void destroy()

        #void _handleManifold(btPersistentManifold* manifold)
        #void _resetContactInfo()
        #bool _markDbvt(bool v)
        
        #btCollisionShape* _createShape()