2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2002-10-12 11:37:38 +00:00
|
|
|
* KX_CameraActuator.cpp
|
|
|
|
*
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-02-25 13:35:59 +00:00
|
|
|
/** \file gameengine/Ketsji/KX_CameraActuator.cpp
|
|
|
|
* \ingroup ketsji
|
|
|
|
*/
|
|
|
|
|
2012-07-24 09:08:27 +00:00
|
|
|
#include "BLI_math_vector.h"
|
2011-02-25 13:35:59 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "KX_CameraActuator.h"
|
|
|
|
#include <math.h>
|
2009-03-17 21:44:58 +00:00
|
|
|
#include <float.h>
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "KX_GameObject.h"
|
|
|
|
|
2008-09-06 14:13:31 +00:00
|
|
|
#include "PyObjectPlus.h"
|
2008-09-06 02:46:11 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* Native functions */
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
KX_CameraActuator::KX_CameraActuator(
|
|
|
|
SCA_IObject* gameobj,
|
2008-07-19 07:45:19 +00:00
|
|
|
SCA_IObject *obj,
|
2009-02-07 20:35:16 +00:00
|
|
|
float hght,
|
|
|
|
float minhght,
|
|
|
|
float maxhght,
|
2012-01-11 07:27:39 +00:00
|
|
|
short axis,
|
2011-06-13 17:08:33 +00:00
|
|
|
float damping
|
2002-10-12 11:37:38 +00:00
|
|
|
):
|
2009-09-24 21:22:24 +00:00
|
|
|
SCA_IActuator(gameobj, KX_ACT_CAMERA),
|
2002-10-12 11:37:38 +00:00
|
|
|
m_ob (obj),
|
|
|
|
m_height (hght),
|
|
|
|
m_minHeight (minhght),
|
|
|
|
m_maxHeight (maxhght),
|
2012-01-11 07:27:39 +00:00
|
|
|
m_axis(axis),
|
2011-06-13 17:08:33 +00:00
|
|
|
m_damping (damping)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2008-07-19 07:45:19 +00:00
|
|
|
if (m_ob)
|
|
|
|
m_ob->RegisterActuator(this);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
KX_CameraActuator::~KX_CameraActuator()
|
|
|
|
{
|
2008-07-19 07:45:19 +00:00
|
|
|
if (m_ob)
|
|
|
|
m_ob->UnregisterActuator(this);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CValue*
|
|
|
|
KX_CameraActuator::
|
|
|
|
GetReplica(
|
|
|
|
) {
|
|
|
|
KX_CameraActuator* replica = new KX_CameraActuator(*this);
|
|
|
|
replica->ProcessReplica();
|
|
|
|
return replica;
|
|
|
|
};
|
|
|
|
|
2008-07-19 07:45:19 +00:00
|
|
|
void KX_CameraActuator::ProcessReplica()
|
|
|
|
{
|
|
|
|
if (m_ob)
|
|
|
|
m_ob->RegisterActuator(this);
|
|
|
|
SCA_IActuator::ProcessReplica();
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-07-19 07:45:19 +00:00
|
|
|
bool KX_CameraActuator::UnlinkObject(SCA_IObject* clientobj)
|
|
|
|
{
|
|
|
|
if (clientobj == m_ob)
|
|
|
|
{
|
|
|
|
// this object is being deleted, we cannot continue to track it.
|
|
|
|
m_ob = NULL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
2011-05-06 20:18:42 +00:00
|
|
|
void KX_CameraActuator::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map)
|
2008-07-19 07:45:19 +00:00
|
|
|
{
|
|
|
|
void **h_obj = (*obj_map)[m_ob];
|
|
|
|
if (h_obj) {
|
|
|
|
if (m_ob)
|
|
|
|
m_ob->UnregisterActuator(this);
|
|
|
|
m_ob = (SCA_IObject*)(*h_obj);
|
|
|
|
m_ob->RegisterActuator(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-22 17:35:43 +00:00
|
|
|
/* copied from blender BLI_math ... don't know if there's an equivalent */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-12-11 14:29:01 +00:00
|
|
|
static void Kx_VecUpMat3(float vec[3], float mat[3][3], short axis)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
// Construct a camera matrix s.t. the specified axis
|
|
|
|
|
|
|
|
// maps to the given vector (*vec). Also defines the rotation
|
|
|
|
|
|
|
|
// about this axis by mapping one of the other axis to the y-axis.
|
|
|
|
|
|
|
|
|
|
|
|
float inp;
|
|
|
|
short cox = 0, coy = 0, coz = 0;
|
|
|
|
|
2012-03-04 04:35:12 +00:00
|
|
|
/* up range has no meaning, is not really up!
|
|
|
|
* see: VecUpMat3old
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
if (axis==0) {
|
2002-10-12 11:37:38 +00:00
|
|
|
cox= 0; coy= 1; coz= 2; /* Y up Z tr */
|
|
|
|
}
|
2012-03-24 07:52:14 +00:00
|
|
|
if (axis==1) {
|
2002-10-12 11:37:38 +00:00
|
|
|
cox= 1; coy= 2; coz= 0; /* Z up X tr */
|
|
|
|
}
|
2012-03-24 07:52:14 +00:00
|
|
|
if (axis==2) {
|
2002-10-12 11:37:38 +00:00
|
|
|
cox= 2; coy= 0; coz= 1; /* X up Y tr */
|
|
|
|
}
|
2012-03-24 07:52:14 +00:00
|
|
|
if (axis==3) {
|
2002-10-12 11:37:38 +00:00
|
|
|
cox= 0; coy= 1; coz= 2; /* Y op -Z tr */
|
2012-10-22 08:15:51 +00:00
|
|
|
vec[0] = -vec[0];
|
|
|
|
vec[1] = -vec[1];
|
|
|
|
vec[2] = -vec[2];
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2012-03-24 07:52:14 +00:00
|
|
|
if (axis==4) {
|
2002-10-12 11:37:38 +00:00
|
|
|
cox= 1; coy= 0; coz= 2; /* */
|
|
|
|
}
|
2012-03-24 07:52:14 +00:00
|
|
|
if (axis==5) {
|
2002-10-12 11:37:38 +00:00
|
|
|
cox= 2; coy= 1; coz= 0; /* Y up X tr */
|
|
|
|
}
|
|
|
|
|
2012-10-22 08:15:51 +00:00
|
|
|
mat[coz][0] = vec[0];
|
|
|
|
mat[coz][1] = vec[1];
|
|
|
|
mat[coz][2] = vec[2];
|
2012-07-22 17:35:43 +00:00
|
|
|
if (normalize_v3((float *)mat[coz]) == 0.f) {
|
2008-05-07 22:32:45 +00:00
|
|
|
/* this is a very abnormal situation: the camera has reach the object center exactly
|
2012-03-09 18:28:30 +00:00
|
|
|
* We will choose a completely arbitrary direction */
|
2008-05-07 22:32:45 +00:00
|
|
|
mat[coz][0] = 1.0f;
|
|
|
|
mat[coz][1] = 0.0f;
|
|
|
|
mat[coz][2] = 0.0f;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-07-18 23:03:27 +00:00
|
|
|
inp = mat[coz][2];
|
|
|
|
mat[coy][0] = - inp * mat[coz][0];
|
|
|
|
mat[coy][1] = - inp * mat[coz][1];
|
|
|
|
mat[coy][2] = 1.0f - inp * mat[coz][2];
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-07-22 17:35:43 +00:00
|
|
|
if (normalize_v3((float *)mat[coy]) == 0.f) {
|
2008-05-07 22:32:45 +00:00
|
|
|
/* the camera is vertical, chose the y axis arbitrary */
|
|
|
|
mat[coy][0] = 0.f;
|
|
|
|
mat[coy][1] = 1.f;
|
|
|
|
mat[coy][2] = 0.f;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-07-22 17:35:43 +00:00
|
|
|
cross_v3_v3v3(mat[cox], mat[coy], mat[coz]);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
bool KX_CameraActuator::Update(double curtime, bool frame)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2012-03-03 11:45:08 +00:00
|
|
|
/* wondering... is it really necessary/desirable to suppress negative */
|
2008-07-19 07:45:19 +00:00
|
|
|
/* events here? */
|
|
|
|
bool bNegativeEvent = IsNegativeEvent();
|
|
|
|
RemoveAllEvents();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-07-19 07:45:19 +00:00
|
|
|
if (bNegativeEvent || !m_ob)
|
|
|
|
return false;
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
KX_GameObject *obj = (KX_GameObject*) GetParent();
|
|
|
|
MT_Point3 from = obj->NodeGetWorldPosition();
|
|
|
|
MT_Matrix3x3 frommat = obj->NodeGetWorldOrientation();
|
|
|
|
/* These casts are _very_ dangerous!!! */
|
|
|
|
MT_Point3 lookat = ((KX_GameObject*)m_ob)->NodeGetWorldPosition();
|
|
|
|
MT_Matrix3x3 actormat = ((KX_GameObject*)m_ob)->NodeGetWorldOrientation();
|
|
|
|
|
2013-03-23 03:04:02 +00:00
|
|
|
float fp1[3]={0}, fp2[3]={0}, rc[3];
|
2002-10-12 11:37:38 +00:00
|
|
|
float inp, fac; //, factor = 0.0; /* some factor... */
|
|
|
|
float mindistsq, maxdistsq, distsq;
|
|
|
|
float mat[3][3];
|
|
|
|
|
|
|
|
/* The rules: */
|
|
|
|
/* CONSTRAINT 1: not implemented */
|
|
|
|
/* CONSTRAINT 2: can camera see actor? */
|
|
|
|
/* CONSTRAINT 3: fixed height relative to floor below actor. */
|
|
|
|
/* CONSTRAINT 4: camera rotates behind actor */
|
|
|
|
/* CONSTRAINT 5: minimum / maximum distance */
|
|
|
|
/* CONSTRAINT 6: again: fixed height relative to floor below actor */
|
|
|
|
/* CONSTRAINT 7: track to floor below actor */
|
|
|
|
/* CONSTRAINT 8: look a little bit left or right, depending on how the
|
2012-03-09 18:28:30 +00:00
|
|
|
*
|
|
|
|
* character is looking (horizontal x)
|
|
|
|
*/
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/* ...and then set the camera position. Since we assume the parent of */
|
|
|
|
/* this actuator is always a camera, just set the parent position and */
|
|
|
|
/* rotation. We do not check whether we really have a camera as parent. */
|
|
|
|
/* It may be better to turn this into a general tracking actuator later */
|
|
|
|
/* on, since lots of plausible relations can be filled in here. */
|
|
|
|
|
|
|
|
/* ... set up some parameters ... */
|
|
|
|
/* missing here: the 'floorloc' of the actor's shadow */
|
|
|
|
|
2011-09-25 12:31:21 +00:00
|
|
|
mindistsq= m_minHeight*m_minHeight;
|
2002-10-12 11:37:38 +00:00
|
|
|
maxdistsq= m_maxHeight*m_maxHeight;
|
|
|
|
|
|
|
|
/* C1: not checked... is a future option */
|
|
|
|
|
|
|
|
/* C2: blender test_visibility function. Can this be a ray-test? */
|
|
|
|
|
|
|
|
/* C3: fixed height */
|
2012-07-18 23:03:27 +00:00
|
|
|
from[2] = (15.0f * from[2] + lookat[2] + m_height) / 16.0f;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* C4: camera behind actor */
|
2012-01-11 07:27:39 +00:00
|
|
|
switch (m_axis) {
|
|
|
|
case OB_POSX:
|
|
|
|
/* X */
|
|
|
|
fp1[0] = actormat[0][0];
|
|
|
|
fp1[1] = actormat[1][0];
|
|
|
|
fp1[2] = actormat[2][0];
|
|
|
|
|
|
|
|
fp2[0] = frommat[0][0];
|
|
|
|
fp2[1] = frommat[1][0];
|
|
|
|
fp2[2] = frommat[2][0];
|
|
|
|
break;
|
|
|
|
case OB_POSY:
|
|
|
|
/* Y */
|
|
|
|
fp1[0] = actormat[0][1];
|
|
|
|
fp1[1] = actormat[1][1];
|
|
|
|
fp1[2] = actormat[2][1];
|
|
|
|
|
|
|
|
fp2[0] = frommat[0][1];
|
|
|
|
fp2[1] = frommat[1][1];
|
|
|
|
fp2[2] = frommat[2][1];
|
|
|
|
break;
|
|
|
|
case OB_NEGX:
|
|
|
|
/* -X */
|
|
|
|
fp1[0] = -actormat[0][0];
|
|
|
|
fp1[1] = -actormat[1][0];
|
|
|
|
fp1[2] = -actormat[2][0];
|
|
|
|
|
|
|
|
fp2[0] = frommat[0][0];
|
|
|
|
fp2[1] = frommat[1][0];
|
|
|
|
fp2[2] = frommat[2][0];
|
|
|
|
break;
|
|
|
|
case OB_NEGY:
|
|
|
|
/* -Y */
|
|
|
|
fp1[0] = -actormat[0][1];
|
|
|
|
fp1[1] = -actormat[1][1];
|
|
|
|
fp1[2] = -actormat[2][1];
|
|
|
|
|
|
|
|
fp2[0] = frommat[0][1];
|
|
|
|
fp2[1] = frommat[1][1];
|
|
|
|
fp2[2] = frommat[2][1];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
break;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2012-10-27 10:42:28 +00:00
|
|
|
|
2012-07-18 23:03:27 +00:00
|
|
|
inp = fp1[0]*fp2[0] + fp1[1]*fp2[1] + fp1[2]*fp2[2];
|
|
|
|
fac = (-1.0f + inp) * m_damping;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-10-27 10:42:28 +00:00
|
|
|
from[0] += fac * fp1[0];
|
|
|
|
from[1] += fac * fp1[1];
|
|
|
|
from[2] += fac * fp1[2];
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/* alleen alstie ervoor ligt: cross testen en loodrechte bijtellen */
|
2012-07-18 23:03:27 +00:00
|
|
|
if (inp < 0.0f) {
|
|
|
|
if (fp1[0] * fp2[1] - fp1[1] * fp2[0] > 0.0f) {
|
|
|
|
from[0] -= fac * fp1[1];
|
|
|
|
from[1] += fac * fp1[0];
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-07-18 23:03:27 +00:00
|
|
|
from[0] += fac * fp1[1];
|
|
|
|
from[1] -= fac * fp1[0];
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* CONSTRAINT 5: minimum / maximum afstand */
|
|
|
|
|
2012-10-22 08:15:51 +00:00
|
|
|
rc[0] = (lookat[0]-from[0]);
|
|
|
|
rc[1] = (lookat[1]-from[1]);
|
|
|
|
rc[2] = (lookat[2]-from[2]);
|
2012-07-18 23:03:27 +00:00
|
|
|
distsq = rc[0]*rc[0] + rc[1]*rc[1] + rc[2]*rc[2];
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-03-24 07:52:14 +00:00
|
|
|
if (distsq > maxdistsq) {
|
2012-07-18 23:03:27 +00:00
|
|
|
distsq = 0.15f * (distsq - maxdistsq) / distsq;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
from[0] += distsq*rc[0];
|
|
|
|
from[1] += distsq*rc[1];
|
|
|
|
from[2] += distsq*rc[2];
|
|
|
|
}
|
2012-03-24 07:52:14 +00:00
|
|
|
else if (distsq < mindistsq) {
|
2012-07-18 23:03:27 +00:00
|
|
|
distsq = 0.15f * (mindistsq - distsq) / mindistsq;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
from[0] -= distsq*rc[0];
|
|
|
|
from[1] -= distsq*rc[1];
|
|
|
|
from[2] -= distsq*rc[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* CONSTRAINT 7: track to schaduw */
|
2012-10-22 08:15:51 +00:00
|
|
|
rc[0] = (lookat[0]-from[0]);
|
|
|
|
rc[1] = (lookat[1]-from[1]);
|
|
|
|
rc[2] = (lookat[2]-from[2]);
|
2005-03-09 19:45:59 +00:00
|
|
|
Kx_VecUpMat3(rc, mat, 3); /* y up Track -z */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* now set the camera position and rotation */
|
|
|
|
|
|
|
|
obj->NodeSetLocalPosition(from);
|
|
|
|
|
2012-10-22 08:15:51 +00:00
|
|
|
actormat[0][0] = mat[0][0]; actormat[0][1] = mat[1][0]; actormat[0][2] = mat[2][0];
|
|
|
|
actormat[1][0] = mat[0][1]; actormat[1][1] = mat[1][1]; actormat[1][2] = mat[2][1];
|
|
|
|
actormat[2][0] = mat[0][2]; actormat[2][1] = mat[1][2]; actormat[2][2] = mat[2][2];
|
2002-10-12 11:37:38 +00:00
|
|
|
obj->NodeSetLocalOrientation(actormat);
|
|
|
|
|
2008-07-19 07:45:19 +00:00
|
|
|
return true;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2011-10-27 14:41:26 +00:00
|
|
|
CValue *KX_CameraActuator::findObject(const char *obName)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
/* hook to object system */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2009-09-29 21:42:40 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* Python functions */
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* Integration hooks ------------------------------------------------------- */
|
|
|
|
PyTypeObject KX_CameraActuator::Type = {
|
2009-06-08 20:08:19 +00:00
|
|
|
PyVarObject_HEAD_INIT(NULL, 0)
|
2002-10-12 11:37:38 +00:00
|
|
|
"KX_CameraActuator",
|
2009-04-20 15:06:46 +00:00
|
|
|
sizeof(PyObjectPlus_Proxy),
|
2002-10-12 11:37:38 +00:00
|
|
|
0,
|
2009-04-20 15:06:46 +00:00
|
|
|
py_base_dealloc,
|
2002-10-12 11:37:38 +00:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
2009-04-20 15:06:46 +00:00
|
|
|
py_base_repr,
|
2009-06-29 12:06:46 +00:00
|
|
|
0,0,0,0,0,0,0,0,0,
|
2009-06-28 11:22:26 +00:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
|
|
|
|
0,0,0,0,0,0,0,
|
|
|
|
Methods,
|
|
|
|
0,
|
|
|
|
0,
|
2009-06-29 12:06:46 +00:00
|
|
|
&SCA_IActuator::Type,
|
|
|
|
0,0,0,0,0,0,
|
|
|
|
py_base_new
|
2002-10-12 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
PyMethodDef KX_CameraActuator::Methods[] = {
|
2010-04-17 15:47:00 +00:00
|
|
|
{NULL, NULL} //Sentinel
|
2002-10-12 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
2009-02-07 20:35:16 +00:00
|
|
|
PyAttributeDef KX_CameraActuator::Attributes[] = {
|
2009-03-17 21:44:58 +00:00
|
|
|
KX_PYATTRIBUTE_FLOAT_RW("min",-FLT_MAX,FLT_MAX,KX_CameraActuator,m_minHeight),
|
|
|
|
KX_PYATTRIBUTE_FLOAT_RW("max",-FLT_MAX,FLT_MAX,KX_CameraActuator,m_maxHeight),
|
|
|
|
KX_PYATTRIBUTE_FLOAT_RW("height",-FLT_MAX,FLT_MAX,KX_CameraActuator,m_height),
|
2012-11-22 05:33:05 +00:00
|
|
|
KX_PYATTRIBUTE_SHORT_RW("axis", 0, 5, true, KX_CameraActuator, m_axis),
|
|
|
|
KX_PYATTRIBUTE_RW_FUNCTION("object", KX_CameraActuator, pyattr_get_object, pyattr_set_object),
|
2011-06-13 17:08:33 +00:00
|
|
|
KX_PYATTRIBUTE_FLOAT_RW("damping",0.f,10.f,KX_CameraActuator,m_damping),
|
2009-02-07 20:35:16 +00:00
|
|
|
{NULL}
|
|
|
|
};
|
|
|
|
|
2012-09-16 04:58:18 +00:00
|
|
|
PyObject *KX_CameraActuator::pyattr_get_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
2009-04-20 15:06:46 +00:00
|
|
|
{
|
2012-10-22 08:15:51 +00:00
|
|
|
KX_CameraActuator* self = static_cast<KX_CameraActuator*>(self_v);
|
2009-04-20 15:06:46 +00:00
|
|
|
if (self->m_ob==NULL)
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
else
|
|
|
|
return self->m_ob->GetProxy();
|
|
|
|
}
|
|
|
|
|
|
|
|
int KX_CameraActuator::pyattr_set_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
|
|
|
{
|
2012-10-22 08:15:51 +00:00
|
|
|
KX_CameraActuator* self = static_cast<KX_CameraActuator*>(self_v);
|
2009-04-20 15:06:46 +00:00
|
|
|
KX_GameObject *gameobj;
|
|
|
|
|
|
|
|
if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: KX_CameraActuator"))
|
2009-06-08 20:08:19 +00:00
|
|
|
return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
|
2009-04-20 15:06:46 +00:00
|
|
|
|
|
|
|
if (self->m_ob)
|
2012-09-16 04:58:18 +00:00
|
|
|
self->m_ob->UnregisterActuator(self);
|
2009-04-20 15:06:46 +00:00
|
|
|
|
|
|
|
if ((self->m_ob = (SCA_IObject*)gameobj))
|
|
|
|
self->m_ob->RegisterActuator(self);
|
|
|
|
|
2009-06-08 20:08:19 +00:00
|
|
|
return PY_SET_ATTR_SUCCESS;
|
2009-04-20 15:06:46 +00:00
|
|
|
}
|
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#endif // WITH_PYTHON
|
2009-09-29 21:42:40 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* eof */
|