Added Python module for Lights.
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>
Sun, 30 May 2004 11:09:46 +0000 (11:09 +0000)
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>
Sun, 30 May 2004 11:09:46 +0000 (11:09 +0000)
Added attributes to the vertex class.

36 files changed:
source/gameengine/Ketsji/KX_Light.cpp
source/gameengine/Ketsji/KX_Light.h
source/gameengine/Ketsji/KX_PyMath.cpp
source/gameengine/Ketsji/KX_PyMath.h
source/gameengine/Ketsji/KX_VertexProxy.cpp
source/gameengine/Ketsji/KX_VertexProxy.h
source/gameengine/PyDoc/BL_ActionActuator.py [new file with mode: 0644]
source/gameengine/PyDoc/GameKeys.py
source/gameengine/PyDoc/GameLogic.py
source/gameengine/PyDoc/KX_CDActuator.py
source/gameengine/PyDoc/KX_Camera.py
source/gameengine/PyDoc/KX_CameraActuator.py [new file with mode: 0644]
source/gameengine/PyDoc/KX_GameActuator.py
source/gameengine/PyDoc/KX_GameObject.py
source/gameengine/PyDoc/KX_Light.py [new file with mode: 0644]
source/gameengine/PyDoc/KX_MeshProxy.py
source/gameengine/PyDoc/KX_MouseFocusSensor.py
source/gameengine/PyDoc/KX_NearSensor.py
source/gameengine/PyDoc/KX_NetworkMessageSensor.py
source/gameengine/PyDoc/KX_RadarSensor.py
source/gameengine/PyDoc/KX_RaySensor.py
source/gameengine/PyDoc/KX_TouchSensor.py
source/gameengine/PyDoc/KX_VertexProxy.py
source/gameengine/PyDoc/Rasterizer.py
source/gameengine/PyDoc/SCA_ANDController.py [new file with mode: 0644]
source/gameengine/PyDoc/SCA_AlwaysSensor.py
source/gameengine/PyDoc/SCA_ILogicBrick.py
source/gameengine/PyDoc/SCA_ISensor.py
source/gameengine/PyDoc/SCA_KeyboardSensor.py
source/gameengine/PyDoc/SCA_MouseSensor.py
source/gameengine/PyDoc/SCA_ORController.py [new file with mode: 0644]
source/gameengine/PyDoc/SCA_PropertySensor.py
source/gameengine/PyDoc/SCA_PythonController.py
source/gameengine/PyDoc/SCA_RandomSensor.py
source/gameengine/Rasterizer/RAS_TexVert.cpp
source/gameengine/Rasterizer/RAS_TexVert.h

index 658f45a49b0e4decd1d1265db02d0dc53474217e..9be4256f58f357833a8c596e1c84b10abd08f942 100644 (file)
 #include "KX_Light.h"
 #include "RAS_IRenderTools.h"
 
+#include "KX_PyMath.h"
+
  
 KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,
                                                           class RAS_IRenderTools* rendertools,
-                                                          const RAS_LightObject&       lightobj
+                                                          const RAS_LightObject&       lightobj,
+                                                          PyTypeObject* T
                                                           )
  :
-       KX_GameObject(sgReplicationInfo,callbacks),
+       KX_GameObject(sgReplicationInfo,callbacks,T),
                m_rendertools(rendertools)
 {
        m_lightobj = lightobj;
@@ -77,3 +80,171 @@ CValue*             KX_LightObject::GetReplica()
        m_rendertools->AddLight(&replica->m_lightobj);
        return replica;
 }
+
+PyObject* KX_LightObject::_getattr(const STR_String& attr)
+{
+       if (attr == "layer")
+               return PyInt_FromLong(m_lightobj.m_layer);
+       
+       if (attr == "energy")
+               return PyFloat_FromDouble(m_lightobj.m_energy);
+       
+       if (attr == "distance")
+               return PyFloat_FromDouble(m_lightobj.m_distance);
+       
+       if (attr == "colour" || attr == "color")
+               return Py_BuildValue("[fff]", m_lightobj.m_red, m_lightobj.m_green, m_lightobj.m_blue);
+               
+       if (attr == "lin_attenuation")
+               return PyFloat_FromDouble(m_lightobj.m_att1);
+       
+       if (attr == "spotsize")
+               return PyFloat_FromDouble(m_lightobj.m_spotsize);
+       
+       if (attr == "spotblend")
+               return PyFloat_FromDouble(m_lightobj.m_spotblend);
+               
+       if (attr == "SPOT")
+               return PyInt_FromLong(RAS_LightObject::LIGHT_SPOT);
+               
+       if (attr == "SUN")
+               return PyInt_FromLong(RAS_LightObject::LIGHT_SUN);
+       
+       if (attr == "NORMAL")
+               return PyInt_FromLong(RAS_LightObject::LIGHT_NORMAL);
+       
+       if (attr == "type")
+               return PyInt_FromLong(m_lightobj.m_type);
+               
+       _getattr_up(KX_GameObject);
+}
+
+int       KX_LightObject::_setattr(const STR_String& attr, PyObject *pyvalue)
+{
+       if (attr == "SPOT" || attr == "SUN" || attr == "NORMAL")
+       {
+               PyErr_Format(PyExc_RuntimeError, "Attribute %s is read only.", attr.ReadPtr());
+               return 1;
+       }
+       
+       if (PyInt_Check(pyvalue))
+       {
+               int value = PyInt_AsLong(pyvalue);
+               if (attr == "layer")
+               {
+                       m_lightobj.m_layer = value;
+                       return 0;
+               }
+               
+               if (attr == "type")
+               {
+                       if (value >= RAS_LightObject::LIGHT_SPOT && value <= RAS_LightObject::LIGHT_NORMAL)
+                               m_lightobj.m_type = (RAS_LightObject::LightType) value;
+                       return 0;
+               }
+       }
+       
+       if (PyFloat_Check(pyvalue))
+       {
+               float value = PyFloat_AsDouble(pyvalue);
+               if (attr == "energy")
+               {
+                       m_lightobj.m_energy = value;
+                       return 0;
+               }
+       
+               if (attr == "distance")
+               {
+                       m_lightobj.m_distance = value;
+                       return 0;
+               }
+               
+               if (attr == "lin_attenuation")
+               {
+                       m_lightobj.m_att1 = value;
+                       return 0;
+               }
+               
+               if (attr == "spotsize")
+               {
+                       m_lightobj.m_spotsize = value;
+                       return 0;
+               }
+               
+               if (attr == "spotblend")
+               {
+                       m_lightobj.m_spotblend = value;
+                       return 0;
+               }
+       }
+
+       if (PySequence_Check(pyvalue))
+       {
+               if (attr == "colour" || attr == "color")
+               {
+                       MT_Vector3 colour(MT_Vector3FromPyList(pyvalue));
+                       m_lightobj.m_red = colour[0];
+                       m_lightobj.m_green = colour[1];
+                       m_lightobj.m_blue = colour[2];
+                       return 0;
+               }
+       }
+       
+       return KX_GameObject::_setattr(attr, pyvalue);
+}
+
+PyMethodDef KX_LightObject::Methods[] = {
+       {NULL,NULL} //Sentinel
+};
+
+char KX_LightObject::doc[] = "Module KX_LightObject\n\n"
+"Constants:\n"
+"\tSPOT\n"
+"\tSUN\n"
+"\tNORMAL\n"
+"Attributes:\n"
+"\ttype -> SPOT, SUN or NORMAL\n"
+"\t\tThe type of light.\n"
+"\tlayer -> integer bit field.\n"
+"\t\tThe layers this light applies to.\n"
+"\tenergy -> float.\n"
+"\t\tThe brightness of the light.\n"
+"\tdistance -> float.\n"
+"\t\tThe effect radius of the light.\n"
+"\tcolour -> list [r, g, b].\n"
+"\tcolor  -> list [r, g, b].\n"
+"\t\tThe colour of the light.\n"
+"\tlin_attenuation -> float.\n"
+"\t\tThe attenuation factor for the light.\n"
+"\tspotsize -> float.\n"
+"\t\tThe size of the spot.\n"
+"\tspotblend -> float.\n"
+"\t\tThe blend? of the spot.\n";
+
+PyTypeObject KX_LightObject::Type = {
+       PyObject_HEAD_INIT(&PyType_Type)
+               0,
+               "KX_LightObject",
+               sizeof(KX_LightObject),
+               0,
+               PyDestructor,
+               0,
+               __getattr,
+               __setattr,
+               0, //&MyPyCompare,
+               __repr,
+               0, //&cvalue_as_number,
+               0,
+               0,
+               0,
+               0, 0, 0, 0, 0, 0,
+               doc
+};
+
+PyParentObject KX_LightObject::Parents[] = {
+       &KX_LightObject::Type,
+       &KX_GameObject::Type,
+               &SCA_IObject::Type,
+               &CValue::Type,
+               NULL
+};
index 311780af755337f59c0db3f7b80dff6d6b7b49ec..11fe7155c8268d721e88781b7bf67534178ab208 100644 (file)
 
 class KX_LightObject : public KX_GameObject
 {
+       Py_Header;
+protected:
        RAS_LightObject         m_lightobj;
        class RAS_IRenderTools* m_rendertools;  //needed for registering and replication of lightobj
+       static char             doc[];
 
 public:
-       KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,class RAS_IRenderTools* rendertools,const struct RAS_LightObject& lightobj);
+       KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,class RAS_IRenderTools* rendertools,const struct RAS_LightObject& lightobj, PyTypeObject *T = &Type);
        virtual ~KX_LightObject();
        virtual CValue*         GetReplica();
        RAS_LightObject*        GetLightData() { return &m_lightobj;}
+       
+       virtual PyObject* _getattr(const STR_String& attr); /* lens, near, far, projection_matrix */
+       virtual int       _setattr(const STR_String& attr, PyObject *pyvalue);
 };
 
 #endif //__KX_LIGHT
index 11bc5d750ff023862bb494ab360eb71a94e9c7c5..ba687744dfcf951327e5f7475775eb1d45e43295 100644 (file)
@@ -42,6 +42,7 @@
 #include "MT_Vector3.h"
 #include "MT_Vector4.h"
 #include "MT_Matrix4x4.h"
+#include "MT_Point2.h"
 
 #include "ListValue.h"
 
@@ -135,6 +136,50 @@ MT_Point3 MT_Point3FromPyList(PyObject* pylist)
        return point;
 }
 
+MT_Point2 MT_Point2FromPyList(PyObject* pylist)
+{
+       MT_Point2 point(0., 0.);
+       bool error=false;
+       if (pylist->ob_type == &CListValue::Type)
+       {
+               CListValue* listval = (CListValue*) pylist;
+               unsigned int numitems = listval->GetCount();
+               if (numitems <= 2)
+               {
+                       for (unsigned int index=0;index<numitems;index++)
+                       {
+                               point[index] = listval->GetValue(index)->GetNumber();
+                       }
+               }       else
+               {
+                       error = true;
+               }
+               
+       } else
+       {
+               // assert the list is long enough...
+               unsigned int numitems = PySequence_Size(pylist);
+               if (numitems <= 2)
+               {
+                       for (unsigned int index=0;index<numitems;index++)
+                       {
+                               PyObject *item = PySequence_GetItem(pylist,index); /* new ref */
+                               point[index] = PyFloat_AsDouble(item);
+                               Py_DECREF(item);
+                       }
+               }
+               else
+               {
+                       error = true;
+               }
+
+       }
+       if (error)
+               PyErr_SetString(PyExc_TypeError, "Expected list of twos items for point argument.");
+
+       return point;
+}
+
 MT_Vector4 MT_Vector4FromPyList(PyObject* pylist)
 {
        MT_Vector4 vec(0., 0., 0., 1.);
@@ -360,6 +405,12 @@ PyObject* PyObjectFromMT_Matrix3x3(const MT_Matrix3x3 &mat)
                mat[2][0], mat[2][1], mat[2][2]);
 }
 
+PyObject* PyObjectFromMT_Vector4(const MT_Vector4 &vec)
+{
+       return Py_BuildValue("[ffff]", 
+               vec[0], vec[1], vec[2], vec[3]);
+}
+
 PyObject* PyObjectFromMT_Vector3(const MT_Vector3 &vec)
 {
        return Py_BuildValue("[fff]", 
@@ -371,3 +422,8 @@ PyObject* PyObjectFromMT_Point3(const MT_Point3 &pos)
        return Py_BuildValue("[fff]",
                pos[0], pos[1], pos[2]);
 }
+
+PyObject* PyObjectFromMT_Point2(const MT_Point2 &pos)
+{
+       return Py_BuildValue("[ff]", pos[0], pos[1]);
+}
index 7fdf207e435ff083ef91c34154d682bacf8184e6..72793a6cbae7ee72364c44ae742da87837415621 100644 (file)
 #ifndef __KX_PYMATH_H__
 #define __KX_PYMATH_H__
 
-#include "MT_Vector3.h"
+#include "MT_Point2.h"
 #include "MT_Point3.h"
+#include "MT_Vector3.h"
 #include "MT_Vector4.h"
-#include "MT_Matrix4x4.h"
 #include "MT_Matrix3x3.h"
+#include "MT_Matrix4x4.h"
 
 #include "KX_Python.h"
 
@@ -57,6 +58,11 @@ MT_Point3 MT_Point3FromPyList(PyObject* pylist);
  */
 MT_Vector4 MT_Vector4FromPyList(PyObject* pylist);
 
+/**
+ * Converts a python list to an MT_Vector2
+ */
+MT_Point2 MT_Point2FromPyList(PyObject* pylist);
+
 /**
  * Converts a python list to an MT_Quaternion
  */
@@ -92,11 +98,21 @@ PyObject* PyObjectFromMT_Matrix3x3(const MT_Matrix3x3 &mat);
  */
 PyObject* PyObjectFromMT_Vector3(const MT_Vector3 &vec);
 
+/**
+ * Converts an MT_Vector4 to a python object
+ */
+PyObject* PyObjectFromMT_Vector4(const MT_Vector4 &vec);
+
 /**
  * Converts an MT_Vector3 to a python object.
  */
 PyObject* PyObjectFromMT_Point3(const MT_Point3 &pos);
 
+/**
+ * Converts an MT_Point2 to a python object.
+ */
+PyObject* PyObjectFromMT_Point2(const MT_Point2 &vec);
 /**
  * True if the given PyObject can be converted to an MT_Matrix
  * @param rank = 3 (for MT_Matrix3x3) or 4 (for MT_Matrix4x4)
index a8c6d0f921c8fb7a6575df863ba78d5041b2265e..d4f82c31ea2852decaec3ca596fb1d81970fb475 100644 (file)
@@ -36,6 +36,8 @@
 #include <config.h>
 #endif
 
+#include "KX_PyMath.h"
+
 PyTypeObject KX_VertexProxy::Type = {
        PyObject_HEAD_INIT(&PyType_Type)
        0,
@@ -77,10 +79,157 @@ PyMethodDef KX_VertexProxy::Methods[] = {
 PyObject*
 KX_VertexProxy::_getattr(const STR_String& attr)
 {
+  if (attr == "XYZ")
+       return PyObjectFromMT_Vector3(m_vertex->getLocalXYZ());
+
+  if (attr == "UV")
+       return PyObjectFromMT_Point2(MT_Point2(m_vertex->getUV1()));
+
+  if (attr == "colour" || attr == "color")
+  {
+       unsigned int icol = m_vertex->getRGBA();
+       unsigned char *colp = (unsigned char *) &icol;
+       MT_Vector4 colour(colp[0], colp[1], colp[2], colp[3]);
+       colour /= 255.0;
+       return PyObjectFromMT_Vector4(colour);
+  }
+  
+  if (attr == "normal")
+  {
+       MT_Vector3 normal(m_vertex->getNormal()[0], m_vertex->getNormal()[1], m_vertex->getNormal()[2]);
+       return PyObjectFromMT_Vector3(normal/32767.);
+  }
+
+  // pos
+  if (attr == "x")
+       return PyFloat_FromDouble(m_vertex->getLocalXYZ()[0]);
+  if (attr == "y")
+       return PyFloat_FromDouble(m_vertex->getLocalXYZ()[1]);
+  if (attr == "z")
+       return PyFloat_FromDouble(m_vertex->getLocalXYZ()[2]);
+
+  // Col
+  if (attr == "r")
+       return PyFloat_FromDouble(((unsigned char*)m_vertex->getRGBA())[0]/255.0);
+  if (attr == "g")
+       return PyFloat_FromDouble(((unsigned char*)m_vertex->getRGBA())[1]/255.0);
+  if (attr == "b")
+       return PyFloat_FromDouble(((unsigned char*)m_vertex->getRGBA())[2]/255.0);
+  if (attr == "a")
+       return PyFloat_FromDouble(((unsigned char*)m_vertex->getRGBA())[3]/255.0);
+
+  // UV
+  if (attr == "u")
+       return PyFloat_FromDouble(m_vertex->getUV1()[0]);
+  if (attr == "v")
+       return PyFloat_FromDouble(m_vertex->getUV1()[1]);
+
   _getattr_up(SCA_IObject);
 }
 
+int    KX_VertexProxy::_setattr(const STR_String& attr, PyObject *pyvalue)
+{
+  if (PySequence_Check(pyvalue))
+  {
+       if (attr == "XYZ")
+       {
+               m_vertex->SetXYZ(MT_Point3FromPyList(pyvalue));
+               return 0;
+       }
+       
+       if (attr == "UV")
+       {
+               m_vertex->SetUV(MT_Point2FromPyList(pyvalue));
+               return 0;
+       }
+       
+       if (attr == "colour" || attr == "color")
+       {
+               m_vertex->SetRGBA(MT_Vector4FromPyList(pyvalue));
+               return 0;
+       }
+       
+       if (attr == "normal")
+       {
+               m_vertex->SetNormal(MT_Vector3FromPyList(pyvalue));
+               return 0;
+       }
+  }
+  
+  if (PyFloat_Check(pyvalue))
+  {
+       float val = PyFloat_AsDouble(pyvalue);
+       // pos
+       MT_Point3 pos(m_vertex->getLocalXYZ());
+       if (attr == "x")
+       {
+               pos.x() = val;
+               m_vertex->SetXYZ(pos);
+               return 0;
+       }
+       
+       if (attr == "y")
+       {
+               pos.y() = val;
+               m_vertex->SetXYZ(pos);
+               return 0;
+       }
+       
+       if (attr == "z")
+       {
+               pos.z() = val;
+               m_vertex->SetXYZ(pos);
+               return 0;
+       }
+       
+       // uv
+       MT_Point2 uv = m_vertex->getUV1();
+       if (attr == "u")
+       {
+               uv[0] = val;
+               m_vertex->SetUV(uv);
+               return 0;
+       }
 
+       if (attr == "v")
+       {
+               uv[1] = val;
+               m_vertex->SetUV(uv);
+               return 0;
+       }
+       
+       // col
+       unsigned int icol = m_vertex->getRGBA();
+       unsigned char *cp = (unsigned char*) &icol;
+       val *= 255.0;
+       if (attr == "r")
+       {
+               cp[0] = (unsigned char) val;
+               m_vertex->SetRGBA(icol);
+               return 0;
+       }
+       if (attr == "g")
+       {
+               cp[1] = (unsigned char) val;
+               m_vertex->SetRGBA(icol);
+               return 0;
+       }
+       if (attr == "b")
+       {
+               cp[2] = (unsigned char) val;
+               m_vertex->SetRGBA(icol);
+               return 0;
+       }
+       if (attr == "a")
+       {
+               cp[3] = (unsigned char) val;
+               m_vertex->SetRGBA(icol);
+               return 0;
+       }
+  }
+  
+  return SCA_IObject::_setattr(attr, pyvalue);
+}
 
 KX_VertexProxy::KX_VertexProxy(RAS_TexVert* vertex)
 :m_vertex(vertex)
index f447014b8b81101d4f46f76c1b514c09dd4f46c8..29fee7d6ae76c7bcf534eaf24cc9b50f959b9034 100644 (file)
@@ -37,6 +37,7 @@
 class KX_VertexProxy   : public SCA_IObject
 {
        Py_Header;
+protected:
 
        class RAS_TexVert*      m_vertex;
 public:
@@ -56,6 +57,7 @@ public:
 
 // stuff for python integration
        virtual PyObject* _getattr(const STR_String& attr);
+       virtual int    KX_VertexProxy::_setattr(const STR_String& attr, PyObject *pyvalue);
 
        KX_PYMETHOD(KX_VertexProxy,GetXYZ);
        KX_PYMETHOD(KX_VertexProxy,SetXYZ);
diff --git a/source/gameengine/PyDoc/BL_ActionActuator.py b/source/gameengine/PyDoc/BL_ActionActuator.py
new file mode 100644 (file)
index 0000000..a1b0777
--- /dev/null
@@ -0,0 +1,137 @@
+# $Id$
+# Documentation for BL_ActionActuator
+from SCA_ILogicBrick import *
+
+class BL_ActionActuator(SCA_ILogicBrick):
+       """
+       Action Actuators apply an action to an actor.
+       """
+       def setAction(action, reset = True):
+               """
+               Sets the current action.
+               
+               @param action: The name of the action to set as the current action.
+               @type action: string
+               @param reset: Optional parameter indicating whether to reset the
+                             blend timer or not.  A value of 1 indicates that the
+                             timer should be reset.  A value of 0 will leave it
+                             unchanged.  If reset is not specified, the timer will
+                             be reset.
+               """
+
+       def setStart(start):
+               """
+               Specifies the starting frame of the animation.
+               
+               @param start: the starting frame of the animation
+               @type start: float
+               """
+
+       def setEnd(end):
+               """
+               Specifies the ending frame of the animation.
+               
+               @param end: the ending frame of the animation
+               @type end: float
+               """
+       def setBlendin(blendin):
+               """
+               Specifies the number of frames of animation to generate
+               when making transitions between actions.
+               
+               @param blendin: the number of frames in transition.
+               @type blendin: float
+               """
+
+       def setPriority(priority):
+               """
+               Sets the priority of this actuator.
+               
+               @param priority: Specifies the new priority.  Actuators will lower
+                                priority numbers will override actuators with higher
+                                numbers.
+               @type priority: integer
+               """
+       def setFrame(frame):
+               """
+               Sets the current frame for the animation.
+               
+               @param frame: Specifies the new current frame for the animation
+               @type frame: float
+               """
+
+       def setProperty(prop):
+               """
+               Sets the property to be used in FromProp playback mode.
+               
+               @param prop: the name of the property to use.
+               @type prop: string.
+               """
+
+       def setBlendtime(blendtime):
+               """
+               Sets the internal frame timer.
+                
+               Allows the script to directly modify the internal timer
+               used when generating transitions between actions.  
+               
+               @param blendtime: The new time. This parameter must be in the range from 0.0 to 1.0.
+               @type blendtime: float
+               """
+
+       def getAction():
+               """
+               getAction() returns the name of the action associated with this actuator.
+               
+               @rtype: string
+               """
+       
+       def getStart():
+               """
+               Returns the starting frame of the action.
+               
+               @rtype: float
+               """
+       def getEnd():
+               """
+               Returns the last frame of the action.
+               
+               @rtype: float
+               """
+       def getBlendin():
+               """
+               Returns the number of interpolation animation frames to be generated when this actuator is triggered.
+               
+               @rtype: float
+               """
+       def getPriority():
+               """
+               Returns the priority for this actuator.  Actuators with lower Priority numbers will
+               override actuators with higher numbers.
+               
+               @rtype: integer
+               """
+       def getFrame():
+               """
+               Returns the current frame number.
+               
+               @rtype: float
+               """
+       def getProperty():
+               """
+               Returns the name of the property to be used in FromProp mode.
+               
+               @rtype: string
+               """
+       def setChannel(channel, matrix, mode = False):
+               """
+               @param channel: A string specifying the name of the bone channel.
+               @type channel: string
+               @param matrix: A 4x4 matrix specifying the overriding transformation
+                              as an offset from the bone's rest position.
+               @type matrix: list [[float]]
+               @param mode: True for armature/world space, False for bone space
+               @type mode: boolean
+               """
+
+
index 2c938d27fa3a0f2fe813ef199b62c9486423ed70..58fc53b0961c75d37a3ff43bda34689196135d90 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 """
 Documentation for the GameKeys module.
 
index 3672a16be44cd2c4e893adccbc0a57ba6a781c4b..05dfd0cd4811a09affe8d008e995df5b8e177e3f 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 """
 Documentation for the GameLogic Module.
 
index fa210f8534cad8aa3e16af9875e268397b0ffe6c..12e74f166b52bba999495ef920824329375f21ad 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for CD Actuator
 from SCA_ILogicBrick import *
 
index fc44824b854cabfb1286daae937c9f30e61589c0..729380ddfb00fa4478129cd2437ccdec499940bd 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for Camera game objects.
 from KX_GameObject import *
 
@@ -128,7 +129,7 @@ class KX_Camera(KX_GameObject):
                Sets the camera's projection matrix.
                
                You should use normalised device coordinates for the clipping planes:
-               left = -1.0, right = 1.0, top = 1.0, bottom = -1.0, near = 0.0, far = 1.0
+               left = -1.0, right = 1.0, top = 1.0, bottom = -1.0, near = cam.near, far = cam.far
                
                @type matrix: 4x4 matrix.
                @param matrix: The new projection matrix for this camera.
@@ -137,41 +138,31 @@ class KX_Camera(KX_GameObject):
                @verbatim{
                import GameLogic
                
-               # Scale a matrix
-               def Scale(matrix, scalar):
-                       for row in matrix:
-                               for col in row:
-                                       col = col * scalar
-               
                # Generate an identiy matrix.
                def Identity():
                        return [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]
                
                # Generate a perspective projection matrix
-               def Perspective():
-                       m = Identity()
-                       m[0][0] = m[0][2] = 2.0
-                       m[1][1] = m[1][2] = 2.0
-                       m[2][2] = m[2][3] = -1.0
-                       m[3][2] = -1.0
-                       m[3][3] = 0.0
-                       return m
+               def Perspective(cam):
+                       return [[cam.near, 0.0     ,  0.0                                  ,  0.0                                      ],
+                               [0.0     , cam.near,  0.0                                  ,  0.0                                      ],
+                               [0.0     , 0.0     , -(cam.far+cam.near)/(cam.far-cam.near), -2.0*cam.far*cam.near/(cam.far - cam.near)],
+                               [0.0     , 0.0     , -1.0                                  ,  0.0                                      ]]
                
                # Generate an orthographic projection matrix
-               # You will need to Scale this matrix.
-               def Orthographic():
-                       m = Identity()
-                       m[0][0] = 2.0
-                       m[0][3] = 0.0
-                       m[1][1] = 2.0
-                       m[1][3] = 0.0
-                       m[2][2] = 1.0
-                       m[2][3] = 1.0
-                       m[3][3] = 1.0
-                       return m
+               # You will need to scale the camera
+               def Orthographic(cam):
+                       return [[1.0/cam.scaling[0], 0.0               ,  0.0                   ,  0.0                                  ],
+                               [0.0               , 1.0/cam.scaling[1],  0.0                   ,  0.0                                  ],
+                               [0.0               , 0.0               , -2.0/(cam.far-cam.near), -(cam.far+cam.near)/(cam.far-cam.near)],
+                               [0.0               , 0.0               ,  0.0                   ,  1.0                                  ]]
                
                # Generate an isometric projection matrix
                def Isometric():
+                       return [[0.866, 0.0  , 0.866, 0.0],
+                               [0.25 , 0.866,-0.25 , 0.0],
+                               [0.0  , 0.0  ,-1.0  , 0.0],
+                               [0.0  , 0.0  , 0.0  , 1.0]]
                        m = Identity()
                        m[0][0] = m[0][2] = m[1][1] = 0.8660254037844386
                        m[1][0] = 0.25
diff --git a/source/gameengine/PyDoc/KX_CameraActuator.py b/source/gameengine/PyDoc/KX_CameraActuator.py
new file mode 100644 (file)
index 0000000..1030f0c
--- /dev/null
@@ -0,0 +1,11 @@
+# $Id$
+# Documentation for KX_CameraActuator
+from SCA_ILogicBrick import *
+
+class KX_CameraActuator(SCA_ILogicBrick):
+       """
+       Applies changes to a camera.
+       
+       This actuator has no python methods.
+       """
+
index 6c2a989286b7cf7745f2b633b5b4880914413f09..740177dcfca4018e5b8f80276ff3efd917ff0324 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for KX_GameActuator
 
 class KX_GameActuator:
index b4a88e831294637519c2c3f35b93c29e1e99011c..cdde9d039687e7dca365b5432b64bdb2c33cd01a 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for game objects
 
 class KX_GameObject:
diff --git a/source/gameengine/PyDoc/KX_Light.py b/source/gameengine/PyDoc/KX_Light.py
new file mode 100644 (file)
index 0000000..95f6622
--- /dev/null
@@ -0,0 +1,37 @@
+# $Id$
+# Documentation for Light game objects.
+from KX_GameObject import *
+
+class KX_Light(KX_GameObject):
+       """
+       A Light object.
+       
+       Constants:
+       @cvar SPOT:   A spot light source. See attribute 'type'
+       @cvar SUN:    A point light source with no attenuation. See attribute 'type'
+       @cvar NORMAL: A point light source. See attribute 'type'
+       
+       Attributes:
+       @cvar type:            The type of light - must be SPOT, SUN or NORMAL
+       @cvar layer:           The layer mask that this light affects object on. (bitfield)
+       @cvar energy:          The brightness of this light. (float)
+       @cvar distance:        The maximum distance this light can illuminate. (float) (SPOT and NORMAL lights only)
+       @cvar colour:          The colour of this light. ([r, g, b]) Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0]
+       @cvar color:           Synonym for colour.
+       @cvar lin_attenuation: The linear component of this lights attenuation. (SPOT and NORMAL lights only)
+       @cvar spotsize:        The cone angle of the spot light, in degrees. (float) (SPOT lights only)
+                              0.0 <= spotsize <= 180.0. Spotsize = 360.0 is also accepted. 
+       @cvar spotblend:       Specifies the intensity distribution of the spot light. (float) (SPOT lights only)
+                              Higher values result in a more focused light source.
+                              0.0 <= spotblend <= 1.0.
+       
+       Example:
+       # Turn on a red alert light.
+       import GameLogic
+       
+       co = GameLogic.getCurrentController()
+       light = co.getOwner()
+       
+       light.energy = 1.0
+       light.colour = [1.0, 0.0, 0.0]
+       """
index a5cb8e7ace2578034e30efccd76813067e9f14ce..30858ace97f0d5752f834d80a4f8347ca43d77a5 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for KX_MeshProxy
 
 class KX_MeshProxy:
index 9e0d523725b0d357e96a93fb13635f2f6cc4fa65..28d584037f837b03aae268e3db68688339980865 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for KX_MouseFocusSensor
 from SCA_MouseSensor import *
 
index 95d83ae008e5bd9c6beff94c7edd20fff0706e2d..fef2e4b2acc50f99fd85d828786f7c397d757eb6 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for KX_NearSensor
 from KX_TouchSensor import *
 
index 94ccccc3e09390244f999430cc46c6aecc27b05f..85f87ecbaa7016b9bc76d81a5848c94953c64f6b 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for KX_NetworkMessageSensor
 from SCA_ISensor import *
 
index 5800cd3e13528e610610e3b0666a3be2c30e1edd..64be858371a733a1f2aef02c3260efda7d6e7ee1 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for KX_RadarSensor
 from KX_NearSensor import *
 
index ede288d9578ecaa81b76c6c462b42f0c51510949..e487edcb655113610bb203ec60493d8c1b29b338 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for KX_RaySensor
 from SCA_ISensor import *
 
index 013da4b57c0541fcdbb8de688802cf6a76129a27..88278d57f769f916e5f2f4023262cce033ec0215 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for KX_TouchSensor
 from SCA_ISensor import *
 
index 41afdbab3d795424fe06e0e2bd8ca554ce044326..198298a5394067835a8386ff5dcb0b605619b38b 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for the vertex proxy class
 
 class KX_VertexProxy:
@@ -5,8 +6,27 @@ class KX_VertexProxy:
        A vertex holds position, UV, colour and normal information.
        
        Note:
-       The physics simulation is NOT currently updated - physics will not respond correctly
+       The physics simulation is NOT currently updated - physics will not respond
        to changes in the vertex position.
+       
+       Attributes:
+       @cvar XYZ: The position of the vertex. (list [x, y, z])
+       @cvar UV: The texture coordinates of the vertex. (list [u, v])
+       @cvar normal: The normal of the vertex (list [nx, ny, nz])
+       @cvar colour: The colour of the vertex. (list [r, g, b, a]) Black = [0.0, 0.0, 0.0, 1.0], White = [1.0, 1.0, 1.0, 1.0]
+       @cvar color: Synonym for colour.
+       
+       @cvar x: The x coordinate of the vertex. (float)
+       @cvar y: The y coordinate of the vertex. (float)
+       @cvar z: The z coordinate of the vertex. (float)
+       
+       @cvar u: The u texture coordinate of the vertex. (float)
+       @cvar v: The v texture coordinate of the vertex. (float)
+       
+       @cvar r: The red component of the vertex colour.   (float) 0.0 <= r <= 1.0
+       @cvar g: The green component of the vertex colour. (float) 0.0 <= g <= 1.0
+       @cvar b: The blue component of the vertex colour.  (float) 0.0 <= b <= 1.0
+       @cvar a: The alpha component of the vertex colour. (float) 0.0 <= a <= 1.0
        """
        
        def getXYZ():
index 1dd64a996a281ba744f38e49c1776027c0d38a38..2c4e368a819ecaaa6a30bc7bb17914ca86032681 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 """
 Documentation for the Rasterizer module.
 
diff --git a/source/gameengine/PyDoc/SCA_ANDController.py b/source/gameengine/PyDoc/SCA_ANDController.py
new file mode 100644 (file)
index 0000000..eec66f5
--- /dev/null
@@ -0,0 +1,11 @@
+# $Id$
+# Documentation for SCA_ANDController
+form SCA_ILogicBrick import *
+
+class SCA_ANDController(SCA_ILogicBrick):
+       """
+       An AND controller activates only when all linked sensors are activated.
+       
+       There are no special python methods for this controller.
+       """
+
index 8ab761ce02b8026250fbec7861a82735042a718e..54ab07a8a9995ab91365b01c3766e6f99becdc62 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for SCA_AlwaysSensor
 from SCA_ISensor import *
 
index 860094b9758addc7dac8cdf0c9ec4f2332738cdf..6bb6d7fd43d39b4abfdd7c0cd9260d40bd362aa2 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for the logic brick base class SCA_ILogicBrick
 from KX_GameObject import *
 
index a5583b0f63f69eded30f93ecc05990adc13ac539..c964788f44777e670806c927967a7db432d8c32a 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for SCA_ISensor
 from SCA_ILogicBrick import *
 
index 21e2390e39ea4bc446a7b79b91e943e2589226a4..e90fb9cc2f1026e9e5bf11872e77acf956191740 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for SCA_KeyboardSensor
 from SCA_ISensor import *
 
index 24867f192b28dd7094d7413473b6b176259f58e3..06b261f67facdf264f112b9c665bb510b8a18cdd 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for SCA_MouseSensor
 from SCA_ISensor import *
 
diff --git a/source/gameengine/PyDoc/SCA_ORController.py b/source/gameengine/PyDoc/SCA_ORController.py
new file mode 100644 (file)
index 0000000..ccea583
--- /dev/null
@@ -0,0 +1,11 @@
+# $Id$
+# Documentation for SCA_ORController
+from SCA_ILogicBrick import *
+
+class SCA_ORController(SCA_ILogicBrick):
+       """
+       An OR controller activates when any connected sensor activates.
+       
+       There are no special python methods for this controller.
+       """
+
index ad5b1e87a7d23a2cf317fb56f7cfd13f28668e46..f0a14477b24ba9d31a0f5b4d05eb258a687f3189 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for SCA_PropertySensor
 from SCA_ISensor import *
 
index a07edd03a8c7712218ace03be0845f6f88508a9b..f09261782882654927ef50aeab2fde7cb12291c5 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for SCA_PythonController
 from SCA_ILogicBrick import *
 
index bab92f2afc86b35ebc5ca26cf8da878072a54a3d..940b8f879ffd257b1e425d4bf817586e4a1c8409 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 # Documentation for SCA_RandomSensor
 from SCA_ISensor import *
 
index add1a652d12caaa0ca3814314e0d8c8a0b8721a1..febe5dac5ee9d41aac041c4da61e1aaf8944be76 100644 (file)
@@ -60,6 +60,15 @@ const MT_Point3& RAS_TexVert::xyz()
        return g_pt3;
 }
 
+void RAS_TexVert::SetRGBA(const MT_Vector4& rgba)
+{
+       unsigned char *colp = (unsigned char*) &m_rgba;
+       colp[0] = rgba[0]*255.0;
+       colp[1] = rgba[1]*255.0;
+       colp[2] = rgba[2]*255.0;
+       colp[3] = rgba[3]*255.0;
+}
+
 #ifndef RAS_TexVert_INLINE
 
 void RAS_TexVert::SetXYZ(const MT_Point3& xyz)
index d5fa18744af3766b5916cec9a2b594da9c43f20d..0480c97421dbf98cf81f0f35edadcd84f5b73d8e 100644 (file)
@@ -124,6 +124,7 @@ public:
        void                            SetFlag(const short flag);
        
 #endif
+       void                            SetRGBA(const MT_Vector4& rgba);
        const MT_Point3&        xyz();
 
        // compare two vertices, and return TRUE if both are almost identical (they can be shared)