forked from bartvdbraak/blender
Added Python module for Lights.
Added attributes to the vertex class.
This commit is contained in:
parent
b97c77df2b
commit
d38329b5aa
@ -41,13 +41,16 @@
|
||||
#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
|
||||
};
|
||||
|
@ -37,14 +37,20 @@
|
||||
|
||||
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
|
||||
|
@ -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]);
|
||||
}
|
||||
|
@ -34,11 +34,12 @@
|
||||
#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)
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
137
source/gameengine/PyDoc/BL_ActionActuator.py
Normal file
137
source/gameengine/PyDoc/BL_ActionActuator.py
Normal file
@ -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
|
||||
"""
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
"""
|
||||
Documentation for the GameKeys module.
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
"""
|
||||
Documentation for the GameLogic Module.
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Documentation for CD Actuator
|
||||
from SCA_ILogicBrick import *
|
||||
|
||||
|
@ -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
|
||||
|
11
source/gameengine/PyDoc/KX_CameraActuator.py
Normal file
11
source/gameengine/PyDoc/KX_CameraActuator.py
Normal file
@ -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.
|
||||
"""
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Documentation for KX_GameActuator
|
||||
|
||||
class KX_GameActuator:
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Documentation for game objects
|
||||
|
||||
class KX_GameObject:
|
||||
|
37
source/gameengine/PyDoc/KX_Light.py
Normal file
37
source/gameengine/PyDoc/KX_Light.py
Normal file
@ -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]
|
||||
"""
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Documentation for KX_MeshProxy
|
||||
|
||||
class KX_MeshProxy:
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Documentation for KX_MouseFocusSensor
|
||||
from SCA_MouseSensor import *
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Documentation for KX_NearSensor
|
||||
from KX_TouchSensor import *
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Documentation for KX_NetworkMessageSensor
|
||||
from SCA_ISensor import *
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Documentation for KX_RadarSensor
|
||||
from KX_NearSensor import *
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Documentation for KX_RaySensor
|
||||
from SCA_ISensor import *
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Documentation for KX_TouchSensor
|
||||
from SCA_ISensor import *
|
||||
|
||||
|
@ -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():
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
"""
|
||||
Documentation for the Rasterizer module.
|
||||
|
||||
|
11
source/gameengine/PyDoc/SCA_ANDController.py
Normal file
11
source/gameengine/PyDoc/SCA_ANDController.py
Normal file
@ -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.
|
||||
"""
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Documentation for SCA_AlwaysSensor
|
||||
from SCA_ISensor import *
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Documentation for the logic brick base class SCA_ILogicBrick
|
||||
from KX_GameObject import *
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Documentation for SCA_ISensor
|
||||
from SCA_ILogicBrick import *
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Documentation for SCA_KeyboardSensor
|
||||
from SCA_ISensor import *
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Documentation for SCA_MouseSensor
|
||||
from SCA_ISensor import *
|
||||
|
||||
|
11
source/gameengine/PyDoc/SCA_ORController.py
Normal file
11
source/gameengine/PyDoc/SCA_ORController.py
Normal file
@ -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.
|
||||
"""
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Documentation for SCA_PropertySensor
|
||||
from SCA_ISensor import *
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Documentation for SCA_PythonController
|
||||
from SCA_ILogicBrick import *
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Documentation for SCA_RandomSensor
|
||||
from SCA_ISensor import *
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user