Home - Forums - Documentation - Gallery - Bugs
(Example)
Current revision (17:00, 31 March 2008) (edit) (undo)
 
(13 intermediate revisions not shown.)
Line 1: Line 1:
== Introduction ==
== Introduction ==
-
There are a number of interfaces in cs and cel which can serve as callbacks to discover things happening in engine. To be able use this functionality, one must inherit from special base classes for python.
+
There are a number of interfaces in cs and cel which can serve as callbacks to discover things happening in engine. To be able to use this functionality, one must inherit from special python base classes.
-
There are two modules in csexternal repository that provide such classes, one for cs and one for cel: '''cscallback''' and '''celcallback'''.
+
There are two modules in [https://b2cs.delcorp.org/svn/csexternal/trunk csexternal repository] that provide such classes, one for cs and one for cel: '''cscallback''' and '''celcallback'''.
-
In general for a given interface, there is a base class, with the naming convention of prefixing with '''py''' instead of '''i''' as is normal for interfaces.
+
In general for a given interface, there is a base class, with the naming convention of prefixing with '''py''' instead of '''i''' as is normal for interfaces.
 +
 
 +
In the cscallback module there are also a couple classes (see tables below) that can be inherited from, these don't need any name change.
== Example ==
== Example ==
-
For example, in '''iMovableListener''' this would be '''pyMovableListener'''. And to use it just declare your class inheriting from this, and implement the needed functions in interface from python:
+
For example, in '''iMovableListener''' this would be '''pyMovableListener'''. To use it just declare your class inheriting from this, and implement the needed interface functions in your class.
<pre>
<pre>
Line 19: Line 21:
pyMovableListener.__init__(self,ObjectRegistry)
pyMovableListener.__init__(self,ObjectRegistry)
# callback functions
# callback functions
-
def MovableChanged(movable):
+
def MovableChanged(self,movable):
print "movable changed"
print "movable changed"
-
def MovableDestroyed(movable):
+
def MovableDestroyed(self,movable):
print "movable destroyed"
print "movable destroyed"
-
movlistener = MyMovableListener
+
movlistener = MyMovableListener()
Movable.AddListener(movlistener)
Movable.AddListener(movlistener)
</pre>
</pre>
Line 33: Line 35:
=== cscallback ===
=== cscallback ===
-
<pre>
+
 
-
iMissingLoaderData
+
==== interfaces ====
-
iTerrainCellHeightDataCallback
+
 
-
iTerrainCellLoadCallback
+
{| border="1" cellpadding="5" cellspacing="0"
-
iParticleEmitter
+
|iMissingLoaderData||[http://www.crystalspace3d.org/docs/online/api/structiMissingLoaderData.html api]
-
iParticleEffector
+
|-
-
iSkeletonBoneUpdateCallback
+
|iTerrainCellHeightDataCallback||[http://www.crystalspace3d.org/docs/online/api/structiTerrainCellHeightDataCallback.html api]
-
iSkeletonAnimationCallback
+
|-
-
iSkeletonUpdateCallback
+
|iTerrainCellLoadCallback||[http://www.crystalspace3d.org/docs/online/api/structiTerrainCellLoadCallback.html api]
-
iMeshObjectDrawCallback
+
|-
-
iObjectModelListener
+
|iParticleEmitter||[http://www.crystalspace3d.org/docs/online/api/structiParticleEmitter.html api]
-
iObjectNameChangeListener
+
|-
-
iProcTexCallback
+
|iParticleEffector||[http://www.crystalspace3d.org/docs/online/api/structiParticleEffector.html api]
-
iODEFrameUpdateCallback
+
|-
-
iReporterListener
+
|iSkeletonBoneUpdateCallback||[http://www.crystalspace3d.org/docs/online/api/structiSkeletonBoneUpdateCallback.html api]
-
iStandardReporterListener
+
|-
-
iDynamicsStepCallback
+
|iSkeletonAnimationCallback||[http://www.crystalspace3d.org/docs/online/api/structiSkeletonAnimationCallback.html api]
-
iDynamicsMoveCallback
+
|-
-
iDynamicsCollisionCallback
+
|iSkeletonUpdateCallback||[http://www.crystalspace3d.org/docs/online/api/structiSkeletonUpdateCallback.html api]
-
iDynamicsColliderCollisionCallback
+
|-
-
iOffscreenCanvasCallback
+
|iMeshObjectDrawCallback||[http://www.crystalspace3d.org/docs/online/api/structiMeshObjectDrawCallback.html api]
-
iVisibilityCullerListener
+
|-
-
iLightCallback
+
|iObjectModelListener||[http://www.crystalspace3d.org/docs/online/api/structiObjectModelListener.html api]
-
iPortalCallback
+
|-
-
iCameraSectorListener
+
|iObjectNameChangeListener||[http://www.crystalspace3d.org/docs/online/api/structiObjectNameChangeListener.html api]
-
iEngineFrameCallback
+
|-
-
iEngineSectorCallback
+
|iProcTexCallback||[http://www.crystalspace3d.org/docs/online/api/structiProcTexCallback.html api]
-
iSectorCallback
+
|-
-
iSectorMeshCallback
+
|iODEFrameUpdateCallback||[http://www.crystalspace3d.org/docs/online/api/structiODEFrameUpdateCallback.html api]
-
iLightVisibleCallback
+
|-
-
iMeshDrawCallback
+
|iReporterListener||[http://www.crystalspace3d.org/docs/online/api/structiReporterListener.html api]
-
iTextureCallback
+
|-
-
iMovableListener
+
|iStandardReporterListener||[http://www.crystalspace3d.org/docs/online/api/structiStandardReporterListener.html api]
-
iSndSysStreamCallback
+
|-
-
iSndSysRendererCallback
+
|iDynamicsStepCallback||[http://www.crystalspace3d.org/docs/online/api/structiDynamicsStepCallback.html api]
-
iSndSysListener
+
|-
-
iSndSysListenerDoppler
+
|iDynamicsMoveCallback||[http://www.crystalspace3d.org/docs/online/api/structiDynamicsMoveCallback.html api]
-
</pre>
+
|-
 +
|iDynamicsCollisionCallback||[http://www.crystalspace3d.org/docs/online/api/structiDynamicsCollisionCallback.html api]
 +
|-
 +
|iDynamicsColliderCollisionCallback||[http://www.crystalspace3d.org/docs/online/api/structiDynamicsColliderCollisionCallback.html api]
 +
|-
 +
|iOffscreenCanvasCallback||[http://www.crystalspace3d.org/docs/online/api/structiOffscreenCanvasCallback.html api]
 +
|-
 +
|iVisibilityCullerListener||[http://www.crystalspace3d.org/docs/online/api/structiVisibilityCullerListener.html api]
 +
|-
 +
|iLightCallback||[http://www.crystalspace3d.org/docs/online/api/structiLightCallback.html api]
 +
|-
 +
|iPortalCallback||[http://www.crystalspace3d.org/docs/online/api/structiPortalCallback.html api]
 +
|-
 +
|iCameraSectorListener||[http://www.crystalspace3d.org/docs/online/api/structiCameraSectorListener.html api]
 +
|-
 +
|iEngineFrameCallback||[http://www.crystalspace3d.org/docs/online/api/structiEngineFrameCallback.html api]
 +
|-
 +
|iEngineSectorCallback||[http://www.crystalspace3d.org/docs/online/api/structiEngineSectorCallback.html api]
 +
|-
 +
|iSectorCallback||[http://www.crystalspace3d.org/docs/online/api/structiSectorCallback.html api]
 +
|-
 +
|iSectorMeshCallback||[http://www.crystalspace3d.org/docs/online/api/structiSectorMeshCallback.html api]
 +
|-
 +
|iLightVisibleCallback||[http://www.crystalspace3d.org/docs/online/api/structiLightVisibleCallback.html api]
 +
|-
 +
|iMeshDrawCallback||[http://www.crystalspace3d.org/docs/online/api/structiMeshDrawCallback.html api]
 +
|-
 +
|iTextureCallback||[http://www.crystalspace3d.org/docs/online/api/structiTextureCallback.html api]
 +
|-
 +
|iMovableListener||[http://www.crystalspace3d.org/docs/online/api/structiMovableListener.html api]
 +
|-
 +
|iSndSysStreamCallback||[http://www.crystalspace3d.org/docs/online/api/structiSndSysStreamCallback.html api]
 +
|-
 +
|iSndSysRendererCallback||[http://www.crystalspace3d.org/docs/online/api/structiSndSysRendererCallback.html api]
 +
|-
 +
|iSndSysListener||[http://www.crystalspace3d.org/docs/online/api/structiSndSysListener.html api]
 +
|-
 +
|iSndSysListenerDoppler||[http://www.crystalspace3d.org/docs/online/api/structiSndSysListenerDoppler.html api]
 +
|-
 +
|}
 +
 
 +
==== classes ====
 +
 
 +
classes that can be directly inherited.
 +
 
 +
{| border="1" cellpadding="5" cellspacing="0"
 +
|csBaseEventHandler||[http://www.crystalspace3d.org/docs/online/api/classcsBaseEventHandler.html api]
 +
|-
 +
|csApplicationFramework||[http://www.crystalspace3d.org/docs/online/api/classcsApplicationFramework.html api]
 +
|-
 +
|}
 +
 
=== celcallback ===
=== celcallback ===
-
<pre>
+
 
-
iQuestTriggerCallback
+
==== interfaces ====
-
iQuestSequenceCallback
+
 
-
iCelNewEntityCallback
+
{| border="1" cellpadding="5" cellspacing="0"
-
iCelEntityRemoveCallback
+
|iQuestTriggerCallback||[http://www.crystalspace3d.org/cel/docs/online/api/structiQuestTriggerCallback.html api]
-
iCelTimerListener
+
|-
-
iPcInventoryListener
+
|iQuestSequenceCallback||[http://www.crystalspace3d.org/cel/docs/online/api/structiQuestSequenceCallback.html api]
-
iPcTriggerListener
+
|-
-
iPcSoundListener
+
|iCelNewEntityCallback||[http://www.crystalspace3d.org/cel/docs/online/api/structiCelNewEntityCallback.html api]
-
iPcPropertyListener
+
|-
-
iPcMeshSelectListener
+
|iCelEntityRemoveCallback||[http://www.crystalspace3d.org/cel/docs/online/api/structiCelEntityRemoveCallback.html api]
-
iPcGravityCallback
+
|-
-
</pre>
+
|iCelTimerListener||[http://www.crystalspace3d.org/cel/docs/online/api/structiCelTimerListener.html api]
 +
|-
 +
|iPcInventoryListener||[http://www.crystalspace3d.org/cel/docs/online/api/structiPcInventoryListener.html api]
 +
|-
 +
|iCelInventorySpace||[http://www.crystalspace3d.org/cel/docs/online/api/structiCelInventorySpace.html api]
 +
|-
 +
|iCelInventorySpaceSlot||[http://www.crystalspace3d.org/cel/docs/online/api/structiCelInventorySpaceSlot.html api]
 +
|-
 +
|iPcTriggerListener||[http://www.crystalspace3d.org/cel/docs/online/api/structiPcTriggerListener.html api]
 +
|-
 +
|iPcSoundListener||[http://www.crystalspace3d.org/cel/docs/online/api/structiPcSoundListener.html api]
 +
|-
 +
|iPcPropertyListener||[http://www.crystalspace3d.org/cel/docs/online/api/structiPcPropertyListener.html api]
 +
|-
 +
|iPcMeshSelectListener||[http://www.crystalspace3d.org/cel/docs/online/api/structiPcMeshSelectListener.html api]
 +
|-
 +
|iPcGravityCallback||[http://www.crystalspace3d.org/cel/docs/online/api/structiPcGravityCallback.html api]
 +
|-
 +
|}
Back to [[PyCrystal]]
Back to [[PyCrystal]]

Current revision

Contents

Introduction

There are a number of interfaces in cs and cel which can serve as callbacks to discover things happening in engine. To be able to use this functionality, one must inherit from special python base classes.

There are two modules in csexternal repository that provide such classes, one for cs and one for cel: cscallback and celcallback.

In general for a given interface, there is a base class, with the naming convention of prefixing with py instead of i as is normal for interfaces.

In the cscallback module there are also a couple classes (see tables below) that can be inherited from, these don't need any name change.

Example

For example, in iMovableListener this would be pyMovableListener. To use it just declare your class inheriting from this, and implement the needed interface functions in your class.

from cscallback import pyMovableListener

class MyMovableListener(pyMovableListener):
    # constructor
    def __init__(self):
        pyMovableListener.__init__(self,ObjectRegistry)
    # callback functions
    def MovableChanged(self,movable):
        print "movable changed"
    def MovableDestroyed(self,movable):
        print "movable destroyed"

movlistener = MyMovableListener()
Movable.AddListener(movlistener)

Note how the constructor for all callback classes requires that you pass the object registry (in the previous example, it is assumed ObjectRegistry is the object registry, and Movable a valid movable).

Supported interfaces

cscallback

interfaces

iMissingLoaderDataapi
iTerrainCellHeightDataCallbackapi
iTerrainCellLoadCallbackapi
iParticleEmitterapi
iParticleEffectorapi
iSkeletonBoneUpdateCallbackapi
iSkeletonAnimationCallbackapi
iSkeletonUpdateCallbackapi
iMeshObjectDrawCallbackapi
iObjectModelListenerapi
iObjectNameChangeListenerapi
iProcTexCallbackapi
iODEFrameUpdateCallbackapi
iReporterListenerapi
iStandardReporterListenerapi
iDynamicsStepCallbackapi
iDynamicsMoveCallbackapi
iDynamicsCollisionCallbackapi
iDynamicsColliderCollisionCallbackapi
iOffscreenCanvasCallbackapi
iVisibilityCullerListenerapi
iLightCallbackapi
iPortalCallbackapi
iCameraSectorListenerapi
iEngineFrameCallbackapi
iEngineSectorCallbackapi
iSectorCallbackapi
iSectorMeshCallbackapi
iLightVisibleCallbackapi
iMeshDrawCallbackapi
iTextureCallbackapi
iMovableListenerapi
iSndSysStreamCallbackapi
iSndSysRendererCallbackapi
iSndSysListenerapi
iSndSysListenerDopplerapi

classes

classes that can be directly inherited.

csBaseEventHandlerapi
csApplicationFrameworkapi

celcallback

interfaces

iQuestTriggerCallbackapi
iQuestSequenceCallbackapi
iCelNewEntityCallbackapi
iCelEntityRemoveCallbackapi
iCelTimerListenerapi
iPcInventoryListenerapi
iCelInventorySpaceapi
iCelInventorySpaceSlotapi
iPcTriggerListenerapi
iPcSoundListenerapi
iPcPropertyListenerapi
iPcMeshSelectListenerapi
iPcGravityCallbackapi

Back to PyCrystal

| Article | Discussion | View source | History |