{
ReportList reports;
BlendFileData *bfd;
-
+
BKE_reports_init(&reports, RPT_STORE);
bfd= BLO_read_from_file(filename, &reports, BLO_READ_SKIP_USERDEF);
{
BL_KetsjiNextFrameState *state = (BL_KetsjiNextFrameState *) state0;
return BL_KetsjiNextFrame(
- state->ketsjiengine,
- state->C,
- state->win,
- state->scene,
+ state->ketsjiengine,
+ state->C,
+ state->win,
+ state->scene,
state->ar,
- state->keyboarddevice,
- state->mousedevice,
+ state->keyboarddevice,
+ state->mousedevice,
state->draw_letterbox);
}
#endif
// Acquire Python's GIL (global interpreter lock)
// so we can safely run Python code and API calls
PyGILState_STATE gilstate = PyGILState_Ensure();
-
+
PyObject *pyGlobalDict = PyDict_New(); /* python utility storage, spans blend file loading */
#endif
bool restrictAnimFPS = (startscene->gm.flag & GAME_RESTRICT_ANIM_UPDATES) != 0;
short drawtype = v3d->drawtype;
-
+
/* we do not support material mode in game engine, force change to texture mode */
if (drawtype == OB_MATERIAL) drawtype = OB_TEXTURE;
if (animation_record) usefixed= false; /* override since you don't want to run full-speed for sim recording */
// create the canvas and rasterizer
RAS_ICanvas* canvas = new KX_BlenderCanvas(wm, win, area_rect, ar);
-
+
// default mouse state set on render panel
if (mouse_state)
canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
RAS_IRasterizer::MipmapOption mipmapval = rasterizer->GetMipmapping();
-
+
// create the inputdevices
KX_BlenderKeyboardDevice* keyboarddevice = new KX_BlenderKeyboardDevice();
KX_BlenderMouseDevice* mousedevice = new KX_BlenderMouseDevice();
-
+
// create a networkdevice
NG_NetworkDeviceInterface* networkdevice = new
NG_LoopBackNetworkDeviceInterface();
//
// create a ketsji/blendersystem (only needed for timing and stuff)
KX_BlenderSystem* kxsystem = new KX_BlenderSystem();
-
+
// create the ketsjiengine
KX_KetsjiEngine* ketsjiengine = new KX_KetsjiEngine(kxsystem);
-
+
// set the devices
ketsjiengine->SetKeyboardDevice(keyboarddevice);
ketsjiengine->SetMouseDevice(mousedevice);
{
exitrequested = KX_EXIT_REQUEST_NO_REQUEST;
if (bfd) BLO_blendfiledata_free(bfd);
-
+
char basedpath[FILE_MAX];
// base the actuator filename with respect
// to the original file working directory
// that happened to be loaded first
BLI_path_abs(basedpath, pathname);
bfd = load_game_data(basedpath);
-
+
// if it wasn't loaded, try it forced relative
if (!bfd)
{
// just add "//" in front of it
char temppath[FILE_MAX] = "//";
BLI_strncpy(temppath + 2, basedpath, FILE_MAX - 2);
-
+
BLI_path_abs(temppath, pathname);
bfd = load_game_data(temppath);
}
-
+
// if we got a loaded blendfile, proceed
if (bfd)
{
{
int startFrame = scene->r.cfra;
ketsjiengine->SetAnimRecordMode(animation_record, startFrame);
-
+
// Quad buffered needs a special window.
if (scene->gm.stereoflag == STEREO_ENABLED) {
if (scene->gm.stereomode != RAS_IRasterizer::RAS_STEREO_QUADBUFFERED)
rasterizer->SetBackColor(scene->gm.framing.col);
}
-
+
if (exitrequested != KX_EXIT_REQUEST_QUIT_GAME)
{
if (rv3d->persp != RV3D_CAMOB)
ketsjiengine->SetCameraOverrideClipping(v3d->near, v3d->far);
ketsjiengine->SetCameraOverrideLens(v3d->lens);
}
-
+
// create a scene converter, create and convert the startingscene
KX_ISceneConverter* sceneconverter = new KX_BlenderSceneConverter(blenderdata, ketsjiengine);
ketsjiengine->SetSceneConverter(sceneconverter);
sceneconverter->SetGLSLMaterials(true);
if (scene->gm.flag & GAME_NO_MATERIAL_CACHING)
sceneconverter->SetCacheMaterials(false);
-
+
KX_Scene* startscene = new KX_Scene(keyboarddevice,
mousedevice,
networkdevice,
rasterizer,
canvas);
ketsjiengine->AddScene(startscene);
-
+
// init the rasterizer
rasterizer->Init();
-
+
// start the engine
ketsjiengine->StartEngine(true);
-
+
// Set the animation playback rate for ipo's and actions
// the framerate below should patch with FPS macro defined in blendef.h
// Could be in StartEngine set the framerate, we need the scene to do this
ketsjiengine->SetAnimFrameRate(FPS);
-
+
#ifdef WITH_PYTHON
char *python_main = NULL;
pynextframestate.state = NULL;
ketsjinextframestate.keyboarddevice = keyboarddevice;
ketsjinextframestate.mousedevice = mousedevice;
ketsjinextframestate.draw_letterbox = draw_letterbox;
-
+
pynextframestate.state = &ketsjinextframestate;
pynextframestate.func = &BL_KetsjiPyNextFrame;
printf("Yielding control to Python script '%s'...\n", python_main);
// inside the GameLogic dictionary when the python interpreter is finalized.
// which allows the scene to safely delete them :)
// see: (space.c)->start_game
-
+
//PyDict_Clear(PyModule_GetDict(gameLogic));
-
+
// Keep original items, means python plugins will autocomplete members
PyObject *gameLogic_keys_new = PyDict_Keys(PyModule_GetDict(gameLogic));
const Py_ssize_t numitems= PyList_GET_SIZE(gameLogic_keys_new);
// set mipmap setting back to its original value
rasterizer->SetMipmapping(mipmapval);
}
-
+
// clean up some stuff
if (ketsjiengine)
{
// stop all remaining playing sounds
AUD_Device_stopAll(BKE_sound_get_device());
-
+
} while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME);
-
+
if (bfd) BLO_blendfiledata_free(bfd);
BLI_strncpy(G.main->name, oldsce, sizeof(G.main->name));
int winX = m_frame_rect.GetLeft();
int winY = m_frame_rect.GetBottom();
int winH = m_frame_rect.GetHeight();
-
+
WM_cursor_warp(m_win, winX + x, winY + (winH-y));
}
struct wmWindowManager;
/**
- * 2D Blender device context abstraction.
+ * 2D Blender device context abstraction.
* The connection from 3d rendercontext to 2d Blender surface embedding.
*/
public:
/* Construct a new canvas.
- *
+ *
* \param area The Blender ARegion to run the game within.
*/
KX_BlenderCanvas(struct wmWindowManager *wm, struct wmWindow* win, RAS_Rect &rect, struct ARegion* ar);
~KX_BlenderCanvas();
- void
+ void
Init(
);
-
- void
+
+ void
SwapBuffers(
);
void GetDisplayDimensions(int &width, int &height);
- void
+ void
ResizeWindow(
int width,
int height
BeginFrame(
);
- void
+ void
EndFrame(
);
- void
+ void
ClearColor(
float r,
float g,
float a
);
- void
+ void
ClearBuffer(
int type
);
- int
+ int
GetWidth(
) const;
- int
+ int
GetHeight(
) const;
const int*
GetViewPort();
- void
+ void
SetMouseState(
RAS_MouseState mousestate
);
- void
+ void
SetMousePosition(
int x,
int y
);
- void
+ void
MakeScreenShot(
const char* filename
);
-
- bool
+
+ bool
BeginDraw(
);
- void
+ void
EndDraw(
);
#ifdef _MSC_VER
/* annoying warnings about truncated STL debug info */
# pragma warning (disable:4786)
-#endif
+#endif
#include "KX_BlenderKeyboardDevice.h"
#include "KX_KetsjiEngine.h"
bool KX_BlenderKeyboardDevice::IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)
{
const SCA_InputEvent & inevent = m_eventStatusTables[m_currentTable][inputcode];
- bool pressed = (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
+ bool pressed = (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
inevent.m_status == SCA_InputEvent::KX_ACTIVE);
return pressed;
}
void KX_BlenderKeyboardDevice::NextFrame()
{
SCA_IInputDevice::NextFrame();
-
+
// now convert justpressed keyevents into regular (active) keyevents
int previousTable = 1-m_currentTable;
for (int keyevent= KX_BEGINKEY; keyevent<= KX_ENDKEY;keyevent++)
bool KX_BlenderKeyboardDevice::ConvertBlenderEvent(unsigned short incode, short val, unsigned int unicode)
{
bool result = false;
-
+
// convert event
KX_EnumInputs kxevent = this->ToNative(incode);
break;
}
case SCA_InputEvent::KX_ACTIVE:
-
+
{
m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_ACTIVE;
break;
m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTACTIVATED;
}
}
-
+
} else if (val == KM_RELEASE)
{
// blender eventval == 0
#ifdef _MSC_VER
/* annoying warnings about truncated STL debug info */
# pragma warning (disable:4786)
-#endif
+#endif
#include "KX_BlenderMouseDevice.h"
bool KX_BlenderMouseDevice::IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)
{
const SCA_InputEvent & inevent = m_eventStatusTables[m_currentTable][inputcode];
- bool pressed = (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
+ bool pressed = (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
inevent.m_status == SCA_InputEvent::KX_ACTIVE);
return pressed;
}
void KX_BlenderMouseDevice::NextFrame()
{
SCA_IInputDevice::NextFrame();
-
+
// now convert justpressed keyevents into regular (active) keyevents
int previousTable = 1-m_currentTable;
for (int mouseevent= KX_BEGINMOUSE; mouseevent< KX_ENDMOUSEBUTTONS;mouseevent++)
if (oldevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED ||
oldevent.m_status == SCA_InputEvent::KX_ACTIVE )
{
-
+
m_eventStatusTables[m_currentTable][mousemove].m_status = SCA_InputEvent::KX_JUSTRELEASED;
} else
{
if (oldevent.m_status == SCA_InputEvent::KX_JUSTRELEASED)
{
-
+
m_eventStatusTables[m_currentTable][mousemove].m_status = SCA_InputEvent::KX_NO_INPUTSTATUS;
}
}
bool KX_BlenderMouseDevice::ConvertBlenderEvent(unsigned short incode, short val, unsigned int unicode)
{
bool result = false;
-
+
// convert event
KX_EnumInputs kxevent = this->ToNative(incode);
int previousTable = 1-m_currentTable;
switch (m_eventStatusTables[previousTable][kxevent].m_status)
{
-
+
case SCA_InputEvent::KX_ACTIVE:
case SCA_InputEvent::KX_JUSTACTIVATED:
{
m_eventStatusTables[m_currentTable][kxevent].m_status = SCA_InputEvent::KX_JUSTACTIVATED;
}
}
-
+
} else if (val == KM_RELEASE)
{
// blender eventval == 0
switch (m_eventStatusTables[previousTable][kxevent].m_status)
{
-
+
case SCA_InputEvent::KX_ACTIVE:
case SCA_InputEvent::KX_JUSTACTIVATED:
{
float layer_weight,
short ipo_flags,
short end_reset,
- float stride)
+ float stride)
: SCA_IActuator(gameobj, KX_ACT_ACTION),
-
+
m_lastpos(0, 0, 0),
m_blendframe(0),
m_flag(0),
m_localtime=m_startframe;
m_lastUpdate=-1;
-
+
}
void BL_ActionActuator::SetBlendTime(float newtime)
dt = -dt;
m_localtime = m_startframe + dt;
-
+
// Handle wrap around
if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe))
{
// We handle ping pong ourselves to increase compabitility
// with files made prior to animation changes from GSoC 2011.
playtype = BL_Action::ACT_MODE_PLAY;
-
+
if (m_flag & ACT_FLAG_REVERSE)
{
start = m_endframe;
if (m_flag & ACT_FLAG_CONTINUE)
bUseContinue = true;
-
-
+
+
// Handle events
if (frame)
{
return false;
}
}
-
+
// If a different action is playing, we've been overruled and are no longer active
if (obj->GetCurrentAction(m_layer) != m_action && !obj->IsActionDone(m_layer))
m_flag &= ~ACT_FLAG_ACTIVE;
m_flag |= ACT_FLAG_PLAY_END;
break;
-
+
case ACT_ACTION_FLIPPER:
// Convert into a play action and play back to the beginning
float temp = end;
PyErr_SetString(PyExc_NotImplementedError, "actuator.getChannel(): Only armatures support channels");
return NULL;
}
-
+
if (!string) {
PyErr_SetString(PyExc_TypeError, "expected a single string");
return NULL;
}
-
+
bPoseChannel *pchan;
-
+
if (m_userpose==NULL && m_pose==NULL) {
BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
obj->GetPose(&m_pose); /* Get the underlying pose from the armature */
}
-
+
// BKE_pose_channel_find_name accounts for NULL pose, run on both in case one exists but
// the channel doesnt
if ( !(pchan=BKE_pose_channel_find_name(m_userpose, string)) &&
}
PyObject *ret = PyTuple_New(3);
-
- PyObject *list = PyList_New(3);
+
+ PyObject *list = PyList_New(3);
PyList_SET_ITEM(list, 0, PyFloat_FromDouble(pchan->loc[0]));
PyList_SET_ITEM(list, 1, PyFloat_FromDouble(pchan->loc[1]));
PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->loc[2]));
PyTuple_SET_ITEM(ret, 0, list);
-
+
list = PyList_New(3);
PyList_SET_ITEM(list, 0, PyFloat_FromDouble(pchan->size[0]));
PyList_SET_ITEM(list, 1, PyFloat_FromDouble(pchan->size[1]));
PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->size[2]));
PyTuple_SET_ITEM(ret, 1, list);
-
+
list = PyList_New(4);
PyList_SET_ITEM(list, 0, PyFloat_FromDouble(pchan->quat[0]));
PyList_SET_ITEM(list, 1, PyFloat_FromDouble(pchan->quat[1]));
PyErr_SetString(PyExc_NotImplementedError, "actuator.setChannel(): Only armatures support channels");
return NULL;
}
-
+
if (PyTuple_Size(args)==2) {
if (!PyArg_ParseTuple(args,"sO:setChannel", &string, &pymat)) // matrix
return NULL;
PyErr_SetString(PyExc_ValueError, "Expected a string and a 4x4 matrix (2 args) or a string and loc/size/quat sequences (4 args)");
return NULL;
}
-
+
if (pymat) {
float matrix[4][4];
MT_Matrix4x4 mat;
-
+
if (!PyMatTo(pymat, mat))
return NULL;
-
+
mat.getValue((float*)matrix);
-
+
BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
-
+
if (!m_userpose) {
if (!m_pose)
obj->GetPose(&m_pose); /* Get the underlying pose from the armature */
}
// pchan= BKE_pose_channel_verify(m_userpose, string); // adds the channel if its not there.
pchan= BKE_pose_channel_find_name(m_userpose, string); // adds the channel if its not there.
-
+
if (pchan) {
copy_v3_v3(pchan->loc, matrix[3]);
mat4_to_size(pchan->size, matrix);
MT_Vector3 loc;
MT_Vector3 size;
MT_Quaternion quat;
-
+
if (!PyVecTo(pyloc, loc) || !PyVecTo(pysize, size) || !PyQuatTo(pyquat, quat))
return NULL;
-
+
// same as above
if (!m_userpose) {
if (!m_pose)
}
// pchan= BKE_pose_channel_verify(m_userpose, string);
pchan= BKE_pose_channel_find_name(m_userpose, string); // adds the channel if its not there.
-
+
// for some reason loc.setValue(pchan->loc) fails
if (pchan) {
pchan->loc[0] = loc[0]; pchan->loc[1] = loc[1]; pchan->loc[2] = loc[2];
pchan->quat[0] = quat[3]; pchan->quat[1] = quat[0]; pchan->quat[2] = quat[1]; pchan->quat[3] = quat[2]; /* notice xyzw -> wxyz is intentional */
}
}
-
+
if (pchan==NULL) {
PyErr_SetString(PyExc_ValueError, "Channel could not be found, use the 'channelNames' attribute to get a list of valid channels");
return NULL;
}
-
+
Py_RETURN_NONE;
#endif
}
int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
{
BL_ActionActuator* self = static_cast<BL_ActionActuator*>(self_v);
-
+
if (!PyUnicode_Check(value))
{
PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, expected the string name of the action");
bAction *action= NULL;
STR_String val = _PyUnicode_AsString(value);
-
+
if (val != "")
{
action= (bAction*)self->GetLogicManager()->GetActionByName(val);
return PY_SET_ATTR_FAIL;
}
}
-
+
self->SetAction(action);
return PY_SET_ATTR_SUCCESS;
BL_ActionActuator* self = static_cast<BL_ActionActuator*>(self_v);
PyObject *ret= PyList_New(0);
PyObject *item;
-
+
if (self->GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE)
{
PyErr_SetString(PyExc_NotImplementedError, "actuator.channelNames: Only armatures support channels");
}
bPose *pose= ((BL_ArmatureObject*)self->GetParent())->GetOrigPose();
-
+
if (pose) {
bPoseChannel *pchan;
for (pchan= (bPoseChannel *)pose->chanbase.first; pchan; pchan= (bPoseChannel *)pchan->next) {
Py_DECREF(item);
}
}
-
+
return ret;
#endif
}
int BL_ActionActuator::pyattr_set_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
{
BL_ActionActuator* self = static_cast<BL_ActionActuator*>(self_v);
-
+
if (PyObject_IsTrue(value))
self->m_flag |= ACT_FLAG_CONTINUE;
else
self->m_flag &= ~ACT_FLAG_CONTINUE;
-
+
return PY_SET_ATTR_SUCCESS;
}
int BL_ActionActuator::pyattr_set_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
{
BL_ActionActuator* self = static_cast<BL_ActionActuator*>(self_v);
-
+
((KX_GameObject*)self->m_gameobj)->SetActionFrame(self->m_layer, PyFloat_AsDouble(value));
-
+
return PY_SET_ATTR_SUCCESS;
}
#include "DNA_actuator_types.h"
#include "MT_Point3.h"
-class BL_ActionActuator : public SCA_IActuator
+class BL_ActionActuator : public SCA_IActuator
{
public:
Py_Header
virtual bool Update(double curtime, bool frame);
virtual CValue* GetReplica();
virtual void ProcessReplica();
-
+
void SetBlendTime(float newtime);
void SetLocalTime(float curtime);
void ResetStartTime(float curtime);
-
+
bAction* GetAction() { return m_action; }
void SetAction(bAction* act) { m_action= act; }
}
}
#endif /* WITH_PYTHON */
-
+
protected:
MT_Point3 m_lastpos;
float m_blendframe;
float m_starttime;
/** The current time of the action */
float m_localtime;
-
+
float m_lastUpdate;
float m_blendin;
float m_blendstart;
/**
* This class is the conversion of the Pose channel constraint.
* It makes a link between the pose constraint and the KX scene.
- * The main purpose is to give access to the constraint target
- * to link it to a game object.
+ * The main purpose is to give access to the constraint target
+ * to link it to a game object.
* It also allows to activate/deactivate constraints during the game.
* Later it will also be possible to create constraint on the fly
*/
BL_ArmatureActuator* actuator = static_cast<BL_ArmatureActuator*>(self);
KX_GameObject* &target = (!strcmp(attrdef->m_name, "target")) ? actuator->m_gametarget : actuator->m_gamesubtarget;
KX_GameObject *gameobj;
-
+
if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &gameobj, true, "actuator.object = value: BL_ArmatureActuator"))
return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
-
+
if (target != NULL)
target->UnregisterActuator(actuator);
target = gameobj;
-
+
if (target)
target->RegisterActuator(actuator);
-
+
return PY_SET_ATTR_SUCCESS;
}
/**
* This class is the conversion of the Pose channel constraint.
* It makes a link between the pose constraint and the KX scene.
- * The main purpose is to give access to the constraint target
- * to link it to a game object.
+ * The main purpose is to give access to the constraint target
+ * to link it to a game object.
* It also allows to activate/deactivate constraints during the game.
* Later it will also be possible to create constraint on the fly
*/
virtual void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map);
virtual bool Update(double curtime, bool frame);
virtual void ReParent(SCA_IObject* parent);
-
+
#ifdef WITH_PYTHON
/* These are used to get and set m_target */
#endif // WITH_PYTHON
BL_ArmatureChannel::BL_ArmatureChannel(
- BL_ArmatureObject *armature,
+ BL_ArmatureObject *armature,
bPoseChannel *posechannel)
: PyObjectPlus(), m_posechannel(posechannel), m_armature(armature)
{
// Keep these attributes in order of BCA_ defines!!! used by py_attr_getattr and py_attr_setattr
KX_PYATTRIBUTE_RO_FUNCTION("bone",BL_ArmatureChannel,py_attr_getattr),
KX_PYATTRIBUTE_RO_FUNCTION("parent",BL_ArmatureChannel,py_attr_getattr),
-
+
{ NULL } //Sentinel
};
PyErr_SetString(PyExc_AttributeError, "channel is NULL");
return PY_SET_ATTR_FAIL;
}
-
+
switch (attr_order) {
default:
break;
};
// not used since this class is never instantiated
-PyObject *BL_ArmatureBone::GetProxy()
-{
- return NULL;
+PyObject *BL_ArmatureBone::GetProxy()
+{
+ return NULL;
}
-PyObject *BL_ArmatureBone::NewProxy(bool py_owns)
-{
- return NULL;
+PyObject *BL_ArmatureBone::NewProxy(bool py_owns)
+{
+ return NULL;
}
PyObject *BL_ArmatureBone::py_bone_repr(PyObject *self)
BL_ArmatureObject* m_armature;
public:
- BL_ArmatureChannel(class BL_ArmatureObject *armature,
+ BL_ArmatureChannel(class BL_ArmatureObject *armature,
struct bPoseChannel *posechannel);
virtual ~BL_ArmatureChannel();
#endif // WITH_PYTHON
BL_ArmatureConstraint::BL_ArmatureConstraint(
- BL_ArmatureObject *armature,
+ BL_ArmatureObject *armature,
bPoseChannel *posechannel,
- bConstraint *constraint,
+ bConstraint *constraint,
KX_GameObject* target,
KX_GameObject* subtarget)
: PyObjectPlus(), m_constraint(constraint), m_posechannel(posechannel), m_armature(armature)
KX_PYATTRIBUTE_RO_FUNCTION("ik_flag",BL_ArmatureConstraint,py_attr_getattr),
KX_PYATTRIBUTE_RW_FUNCTION("ik_dist",BL_ArmatureConstraint,py_attr_getattr,py_attr_setattr),
KX_PYATTRIBUTE_RW_FUNCTION("ik_mode",BL_ArmatureConstraint,py_attr_getattr,py_attr_setattr),
-
+
{ NULL } //Sentinel
};
PyErr_SetString(PyExc_AttributeError, "constraint is NULL");
return PY_SET_ATTR_FAIL;
}
-
+
switch (attr_order) {
case BCA_ENFORCE:
dval = PyFloat_AsDouble(value);
struct bPose;
/**
- * SG_DList : element of controlled constraint list
+ * SG_DList : element of controlled constraint list
* head = BL_ArmatureObject::m_controlledConstraints
* SG_QList : not used
*/
struct bPose* m_subpose;
public:
- BL_ArmatureConstraint(class BL_ArmatureObject *armature,
- struct bPoseChannel *posechannel,
- struct bConstraint *constraint,
+ BL_ArmatureConstraint(class BL_ArmatureObject *armature,
+ struct bPoseChannel *posechannel,
+ struct bConstraint *constraint,
KX_GameObject* target,
KX_GameObject* subtarget);
virtual ~BL_ArmatureConstraint();
#include "MT_Matrix4x4.h"
-/**
+/**
* Move here pose function for game engine so that we can mix with GE objects
* Principle is as follow:
* Use Blender structures so that BKE_pose_where_is can be used unchanged
* Copy the constraint so that they can be enabled/disabled/added/removed at runtime
* Don't copy the constraints for the pose used by the Action actuator, it does not need them.
- * Scan the constraint structures so that the KX equivalent of target objects are identified and
+ * Scan the constraint structures so that the KX equivalent of target objects are identified and
* stored in separate list.
* When it is about to evaluate the pose, set the KX object position in the obmat of the corresponding
* Blender objects and restore after the evaluation.
bPose *out;
bPoseChannel *pchan, *outpchan;
GHash *ghash;
-
+
/* the game engine copies the current armature pose and then swaps
* the object pose pointer. this makes it possible to change poses
* without affecting the original blender data. */
*dst=NULL;
return;
}
-
+
out= (bPose*)MEM_dupallocN(src);
out->chanhash = NULL;
out->agroups.first= out->agroups.last= NULL;
} else {
dstweight = 1.0f;
}
-
+
schan= (bPoseChannel *)src->chanbase.first;
for (dchan = (bPoseChannel *)dst->chanbase.first; dchan; dchan=(bPoseChannel *)dchan->next, schan= (bPoseChannel *)schan->next) {
// always blend on all channels since we don't know which one has been set
/* quat interpolation done separate */
if (schan->rotmode == ROT_MODE_QUAT) {
float dquat[4], squat[4];
-
+
copy_qt_qt(dquat, dchan->quat);
copy_qt_qt(squat, schan->quat);
// Normalize quaternions so that interpolation/multiplication result is correct.
mul_fac_qt_fl(squat, srcweight);
mul_qt_qtqt(dchan->quat, dquat, squat);
}
-
+
normalize_qt(dchan->quat);
}
/* blending for loc and scale are pretty self-explanatory... */
dchan->loc[i] = (dchan->loc[i]*dstweight) + (schan->loc[i]*srcweight);
dchan->size[i] = 1.0f + ((dchan->size[i]-1.0f)*dstweight) + ((schan->size[i]-1.0f)*srcweight);
-
+
/* euler-rotation interpolation done here instead... */
// FIXME: are these results decent?
if (schan->rotmode)
dcon->enforce= dcon->enforce*(1.0f-srcweight) + scon->enforce*srcweight;
}
}
-
+
/* this pose is now in src time */
dst->ctime= src->ctime;
}
BL_ArmatureObject::BL_ArmatureObject(
- void* sgReplicationInfo,
- SG_Callbacks callbacks,
+ void* sgReplicationInfo,
+ SG_Callbacks callbacks,
Object *armature,
Scene *scene,
int vert_deform_type)
if (m_poseChannels.Empty()) {
bPoseChannel* pchan;
BL_ArmatureChannel* proxy;
-
+
m_channelNumber = 0;
for (pchan = (bPoseChannel *)m_pose->chanbase.first; pchan; pchan=(bPoseChannel *)pchan->next) {
proxy = new BL_ArmatureChannel(this, pchan);
{
LoadChannels();
SG_DList::iterator<BL_ArmatureChannel> cit(m_poseChannels);
- for (cit.begin(); !cit.end(); ++cit)
+ for (cit.begin(); !cit.end(); ++cit)
{
BL_ArmatureChannel* channel = *cit;
if (channel->m_posechannel == pchan)
{
LoadChannels();
SG_DList::iterator<BL_ArmatureChannel> cit(m_poseChannels);
- for (cit.begin(); !cit.end(); ++cit)
+ for (cit.begin(); !cit.end(); ++cit)
{
BL_ArmatureChannel* channel = *cit;
if (!strcmp(channel->m_posechannel->name, str))
{
/* If the caller supplies a null pose, create a new one. */
/* Otherwise, copy the armature's pose channels into the caller-supplied pose */
-
+
if (!*pose) {
/* probably not to good of an idea to
- * duplicate everything, but it clears up
- * a crash and memory leakage when
+ * duplicate everything, but it clears up
+ * a crash and memory leakage when
* &BL_ActionActuator::m_pose is freed
*/
game_copy_pose(pose, m_pose, 0);
NULL))->NewProxy(true);
}
-KX_PYMETHODDEF_DOC_NOARGS(BL_ArmatureObject, update,
+KX_PYMETHODDEF_DOC_NOARGS(BL_ArmatureObject, update,
"update()\n"
"Make sure that the armature will be updated on next graphic frame.\n"
"This is automatically done if a KX_ArmatureActuator with mode run is active\n"
struct Object;
class KX_BlenderSceneConverter;
-class BL_ArmatureObject : public KX_GameObject
+class BL_ArmatureObject : public KX_GameObject
{
Py_Header
public:
void RestorePose();
bool UpdateTimestep(double curtime);
-
+
struct bArmature *GetArmature() { return (bArmature*)m_objArma->data; }
const struct bArmature * GetArmature() const { return (bArmature*)m_objArma->data; }
const struct Scene * GetScene() const { return m_scene; }
-
+
Object* GetArmatureObject() {return m_objArma;}
Object* GetOrigArmatureObject() {return m_origObjArma;}
/// Retrieve the pose matrix for the specified bone.
/// Returns true on success.
bool GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix);
-
+
/// Returns the bone length. The end of the bone is in the local y direction.
float GetBoneLength(Bone* bone) const;
Object *m_origObjArma;
struct bPose *m_pose;
struct bPose *m_armpose;
- struct Scene *m_scene; // need for BKE_pose_where_is
+ struct Scene *m_scene; // need for BKE_pose_where_is
double m_lastframe;
double m_timestep; // delta since last pose evaluation.
int m_vert_deform_type;
static std::map<int, SCA_IInputDevice::KX_EnumInputs> create_translate_table()
{
std::map<int, SCA_IInputDevice::KX_EnumInputs> m;
-
+
/* The reverse table. In order to not confuse ourselves, we */
/* immediately convert all events that come in to KX codes. */
m[LEFTMOUSE ] = SCA_IInputDevice::KX_LEFTMOUSE;
m[WHEELDOWNMOUSE ] = SCA_IInputDevice::KX_WHEELDOWNMOUSE;
m[MOUSEX ] = SCA_IInputDevice::KX_MOUSEX;
m[MOUSEY ] = SCA_IInputDevice::KX_MOUSEY;
-
- // TIMERS
-
- m[TIMER0 ] = SCA_IInputDevice::KX_TIMER0;
- m[TIMER1 ] = SCA_IInputDevice::KX_TIMER1;
- m[TIMER2 ] = SCA_IInputDevice::KX_TIMER2;
-
- // SYSTEM
-
+
+ // TIMERS
+
+ m[TIMER0 ] = SCA_IInputDevice::KX_TIMER0;
+ m[TIMER1 ] = SCA_IInputDevice::KX_TIMER1;
+ m[TIMER2 ] = SCA_IInputDevice::KX_TIMER2;
+
+ // SYSTEM
+
#if 0
/* **** XXX **** */
- m[KEYBD ] = SCA_IInputDevice::KX_KEYBD;
- m[RAWKEYBD ] = SCA_IInputDevice::KX_RAWKEYBD;
- m[REDRAW ] = SCA_IInputDevice::KX_REDRAW;
- m[INPUTCHANGE ] = SCA_IInputDevice::KX_INPUTCHANGE;
- m[QFULL ] = SCA_IInputDevice::KX_QFULL;
- m[WINFREEZE ] = SCA_IInputDevice::KX_WINFREEZE;
- m[WINTHAW ] = SCA_IInputDevice::KX_WINTHAW;
- m[WINCLOSE ] = SCA_IInputDevice::KX_WINCLOSE;
- m[WINQUIT ] = SCA_IInputDevice::KX_WINQUIT;
- m[Q_FIRSTTIME ] = SCA_IInputDevice::KX_Q_FIRSTTIME;
+ m[KEYBD ] = SCA_IInputDevice::KX_KEYBD;
+ m[RAWKEYBD ] = SCA_IInputDevice::KX_RAWKEYBD;
+ m[REDRAW ] = SCA_IInputDevice::KX_REDRAW;
+ m[INPUTCHANGE ] = SCA_IInputDevice::KX_INPUTCHANGE;
+ m[QFULL ] = SCA_IInputDevice::KX_QFULL;
+ m[WINFREEZE ] = SCA_IInputDevice::KX_WINFREEZE;
+ m[WINTHAW ] = SCA_IInputDevice::KX_WINTHAW;
+ m[WINCLOSE ] = SCA_IInputDevice::KX_WINCLOSE;
+ m[WINQUIT ] = SCA_IInputDevice::KX_WINQUIT;
+ m[Q_FIRSTTIME ] = SCA_IInputDevice::KX_Q_FIRSTTIME;
/* **** XXX **** */
#endif
-
- // standard keyboard
-
- m[AKEY ] = SCA_IInputDevice::KX_AKEY;
- m[BKEY ] = SCA_IInputDevice::KX_BKEY;
- m[CKEY ] = SCA_IInputDevice::KX_CKEY;
- m[DKEY ] = SCA_IInputDevice::KX_DKEY;
- m[EKEY ] = SCA_IInputDevice::KX_EKEY;
- m[FKEY ] = SCA_IInputDevice::KX_FKEY;
- m[GKEY ] = SCA_IInputDevice::KX_GKEY;
- m[HKEY ] = SCA_IInputDevice::KX_HKEY;
- m[IKEY ] = SCA_IInputDevice::KX_IKEY;
- m[JKEY ] = SCA_IInputDevice::KX_JKEY;
- m[KKEY ] = SCA_IInputDevice::KX_KKEY;
- m[LKEY ] = SCA_IInputDevice::KX_LKEY;
- m[MKEY ] = SCA_IInputDevice::KX_MKEY;
- m[NKEY ] = SCA_IInputDevice::KX_NKEY;
- m[OKEY ] = SCA_IInputDevice::KX_OKEY;
- m[PKEY ] = SCA_IInputDevice::KX_PKEY;
- m[QKEY ] = SCA_IInputDevice::KX_QKEY;
- m[RKEY ] = SCA_IInputDevice::KX_RKEY;
- m[SKEY ] = SCA_IInputDevice::KX_SKEY;
- m[TKEY ] = SCA_IInputDevice::KX_TKEY;
- m[UKEY ] = SCA_IInputDevice::KX_UKEY;
- m[VKEY ] = SCA_IInputDevice::KX_VKEY;
- m[WKEY ] = SCA_IInputDevice::KX_WKEY;
- m[XKEY ] = SCA_IInputDevice::KX_XKEY;
- m[YKEY ] = SCA_IInputDevice::KX_YKEY;
- m[ZKEY ] = SCA_IInputDevice::KX_ZKEY;
-
- m[ZEROKEY ] = SCA_IInputDevice::KX_ZEROKEY;
- m[ONEKEY ] = SCA_IInputDevice::KX_ONEKEY;
- m[TWOKEY ] = SCA_IInputDevice::KX_TWOKEY;
- m[THREEKEY ] = SCA_IInputDevice::KX_THREEKEY;
- m[FOURKEY ] = SCA_IInputDevice::KX_FOURKEY;
- m[FIVEKEY ] = SCA_IInputDevice::KX_FIVEKEY;
- m[SIXKEY ] = SCA_IInputDevice::KX_SIXKEY;
- m[SEVENKEY ] = SCA_IInputDevice::KX_SEVENKEY;
- m[EIGHTKEY ] = SCA_IInputDevice::KX_EIGHTKEY;
- m[NINEKEY ] = SCA_IInputDevice::KX_NINEKEY;
-
- m[CAPSLOCKKEY ] = SCA_IInputDevice::KX_CAPSLOCKKEY;
-
- m[LEFTCTRLKEY ] = SCA_IInputDevice::KX_LEFTCTRLKEY;
- m[LEFTALTKEY ] = SCA_IInputDevice::KX_LEFTALTKEY;
- m[RIGHTALTKEY ] = SCA_IInputDevice::KX_RIGHTALTKEY;
- m[RIGHTCTRLKEY ] = SCA_IInputDevice::KX_RIGHTCTRLKEY;
- m[RIGHTSHIFTKEY ] = SCA_IInputDevice::KX_RIGHTSHIFTKEY;
- m[LEFTSHIFTKEY ] = SCA_IInputDevice::KX_LEFTSHIFTKEY;
-
- m[ESCKEY ] = SCA_IInputDevice::KX_ESCKEY;
- m[TABKEY ] = SCA_IInputDevice::KX_TABKEY;
- m[RETKEY ] = SCA_IInputDevice::KX_RETKEY;
- m[SPACEKEY ] = SCA_IInputDevice::KX_SPACEKEY;
- m[LINEFEEDKEY ] = SCA_IInputDevice::KX_LINEFEEDKEY;
- m[BACKSPACEKEY ] = SCA_IInputDevice::KX_BACKSPACEKEY;
- m[DELKEY ] = SCA_IInputDevice::KX_DELKEY;
- m[SEMICOLONKEY ] = SCA_IInputDevice::KX_SEMICOLONKEY;
- m[PERIODKEY ] = SCA_IInputDevice::KX_PERIODKEY;
- m[COMMAKEY ] = SCA_IInputDevice::KX_COMMAKEY;
- m[QUOTEKEY ] = SCA_IInputDevice::KX_QUOTEKEY;
- m[ACCENTGRAVEKEY ] = SCA_IInputDevice::KX_ACCENTGRAVEKEY;
- m[MINUSKEY ] = SCA_IInputDevice::KX_MINUSKEY;
+
+ // standard keyboard
+
+ m[AKEY ] = SCA_IInputDevice::KX_AKEY;
+ m[BKEY ] = SCA_IInputDevice::KX_BKEY;
+ m[CKEY ] = SCA_IInputDevice::KX_CKEY;
+ m[DKEY ] = SCA_IInputDevice::KX_DKEY;
+ m[EKEY ] = SCA_IInputDevice::KX_EKEY;
+ m[FKEY ] = SCA_IInputDevice::KX_FKEY;
+ m[GKEY ] = SCA_IInputDevice::KX_GKEY;
+ m[HKEY ] = SCA_IInputDevice::KX_HKEY;
+ m[IKEY ] = SCA_IInputDevice::KX_IKEY;
+ m[JKEY ] = SCA_IInputDevice::KX_JKEY;
+ m[KKEY ] = SCA_IInputDevice::KX_KKEY;
+ m[LKEY ] = SCA_IInputDevice::KX_LKEY;
+ m[MKEY ] = SCA_IInputDevice::KX_MKEY;
+ m[NKEY ] = SCA_IInputDevice::KX_NKEY;
+ m[OKEY ] = SCA_IInputDevice::KX_OKEY;
+ m[PKEY ] = SCA_IInputDevice::KX_PKEY;
+ m[QKEY ] = SCA_IInputDevice::KX_QKEY;
+ m[RKEY ] = SCA_IInputDevice::KX_RKEY;
+ m[SKEY ] = SCA_IInputDevice::KX_SKEY;
+ m[TKEY ] = SCA_IInputDevice::KX_TKEY;
+ m[UKEY ] = SCA_IInputDevice::KX_UKEY;
+ m[VKEY ] = SCA_IInputDevice::KX_VKEY;
+ m[WKEY ] = SCA_IInputDevice::KX_WKEY;
+ m[XKEY ] = SCA_IInputDevice::KX_XKEY;
+ m[YKEY ] = SCA_IInputDevice::KX_YKEY;
+ m[ZKEY ] = SCA_IInputDevice::KX_ZKEY;
+
+ m[ZEROKEY ] = SCA_IInputDevice::KX_ZEROKEY;
+ m[ONEKEY ] = SCA_IInputDevice::KX_ONEKEY;
+ m[TWOKEY ] = SCA_IInputDevice::KX_TWOKEY;
+ m[THREEKEY ] = SCA_IInputDevice::KX_THREEKEY;
+ m[FOURKEY ] = SCA_IInputDevice::KX_FOURKEY;
+ m[FIVEKEY ] = SCA_IInputDevice::KX_FIVEKEY;
+ m[SIXKEY ] = SCA_IInputDevice::KX_SIXKEY;
+ m[SEVENKEY ] = SCA_IInputDevice::KX_SEVENKEY;
+ m[EIGHTKEY ] = SCA_IInputDevice::KX_EIGHTKEY;
+ m[NINEKEY ] = SCA_IInputDevice::KX_NINEKEY;
+
+ m[CAPSLOCKKEY ] = SCA_IInputDevice::KX_CAPSLOCKKEY;
+
+ m[LEFTCTRLKEY ] = SCA_IInputDevice::KX_LEFTCTRLKEY;
+ m[LEFTALTKEY ] = SCA_IInputDevice::KX_LEFTALTKEY;
+ m[RIGHTALTKEY ] = SCA_IInputDevice::KX_RIGHTALTKEY;
+ m[RIGHTCTRLKEY ] = SCA_IInputDevice::KX_RIGHTCTRLKEY;
+ m[RIGHTSHIFTKEY ] = SCA_IInputDevice::KX_RIGHTSHIFTKEY;
+ m[LEFTSHIFTKEY ] = SCA_IInputDevice::KX_LEFTSHIFTKEY;
+
+ m[ESCKEY ] = SCA_IInputDevice::KX_ESCKEY;
+ m[TABKEY ] = SCA_IInputDevice::KX_TABKEY;
+ m[RETKEY ] = SCA_IInputDevice::KX_RETKEY;
+ m[SPACEKEY ] = SCA_IInputDevice::KX_SPACEKEY;
+ m[LINEFEEDKEY ] = SCA_IInputDevice::KX_LINEFEEDKEY;
+ m[BACKSPACEKEY ] = SCA_IInputDevice::KX_BACKSPACEKEY;
+ m[DELKEY ] = SCA_IInputDevice::KX_DELKEY;
+ m[SEMICOLONKEY ] = SCA_IInputDevice::KX_SEMICOLONKEY;
+ m[PERIODKEY ] = SCA_IInputDevice::KX_PERIODKEY;
+ m[COMMAKEY ] = SCA_IInputDevice::KX_COMMAKEY;
+ m[QUOTEKEY ] = SCA_IInputDevice::KX_QUOTEKEY;
+ m[ACCENTGRAVEKEY ] = SCA_IInputDevice::KX_ACCENTGRAVEKEY;
+ m[MINUSKEY ] = SCA_IInputDevice::KX_MINUSKEY;
m[PLUSKEY ] = SCA_IInputDevice::KX_PLUSKEY;
m[SLASHKEY ] = SCA_IInputDevice::KX_SLASHKEY;
- m[BACKSLASHKEY ] = SCA_IInputDevice::KX_BACKSLASHKEY;
- m[EQUALKEY ] = SCA_IInputDevice::KX_EQUALKEY;
- m[LEFTBRACKETKEY ] = SCA_IInputDevice::KX_LEFTBRACKETKEY;
- m[RIGHTBRACKETKEY ] = SCA_IInputDevice::KX_RIGHTBRACKETKEY;
-
- m[LEFTARROWKEY ] = SCA_IInputDevice::KX_LEFTARROWKEY;
- m[DOWNARROWKEY ] = SCA_IInputDevice::KX_DOWNARROWKEY;
- m[RIGHTARROWKEY ] = SCA_IInputDevice::KX_RIGHTARROWKEY;
- m[UPARROWKEY ] = SCA_IInputDevice::KX_UPARROWKEY;
-
- m[PAD2 ] = SCA_IInputDevice::KX_PAD2;
- m[PAD4 ] = SCA_IInputDevice::KX_PAD4;
- m[PAD6 ] = SCA_IInputDevice::KX_PAD6;
- m[PAD8 ] = SCA_IInputDevice::KX_PAD8;
-
- m[PAD1 ] = SCA_IInputDevice::KX_PAD1;
- m[PAD3 ] = SCA_IInputDevice::KX_PAD3;
- m[PAD5 ] = SCA_IInputDevice::KX_PAD5;
- m[PAD7 ] = SCA_IInputDevice::KX_PAD7;
- m[PAD9 ] = SCA_IInputDevice::KX_PAD9;
-
- m[PADPERIOD ] = SCA_IInputDevice::KX_PADPERIOD;
- m[PADSLASHKEY ] = SCA_IInputDevice::KX_PADSLASHKEY;
- m[PADASTERKEY ] = SCA_IInputDevice::KX_PADASTERKEY;
-
- m[PAD0 ] = SCA_IInputDevice::KX_PAD0;
- m[PADMINUS ] = SCA_IInputDevice::KX_PADMINUS;
- m[PADENTER ] = SCA_IInputDevice::KX_PADENTER;
- m[PADPLUSKEY ] = SCA_IInputDevice::KX_PADPLUSKEY;
-
-
- m[F1KEY ] = SCA_IInputDevice::KX_F1KEY;
- m[F2KEY ] = SCA_IInputDevice::KX_F2KEY;
- m[F3KEY ] = SCA_IInputDevice::KX_F3KEY;
- m[F4KEY ] = SCA_IInputDevice::KX_F4KEY;
- m[F5KEY ] = SCA_IInputDevice::KX_F5KEY;
- m[F6KEY ] = SCA_IInputDevice::KX_F6KEY;
- m[F7KEY ] = SCA_IInputDevice::KX_F7KEY;
- m[F8KEY ] = SCA_IInputDevice::KX_F8KEY;
- m[F9KEY ] = SCA_IInputDevice::KX_F9KEY;
- m[F10KEY ] = SCA_IInputDevice::KX_F10KEY;
- m[F11KEY ] = SCA_IInputDevice::KX_F11KEY;
+ m[BACKSLASHKEY ] = SCA_IInputDevice::KX_BACKSLASHKEY;
+ m[EQUALKEY ] = SCA_IInputDevice::KX_EQUALKEY;
+ m[LEFTBRACKETKEY ] = SCA_IInputDevice::KX_LEFTBRACKETKEY;
+ m[RIGHTBRACKETKEY ] = SCA_IInputDevice::KX_RIGHTBRACKETKEY;
+
+ m[LEFTARROWKEY ] = SCA_IInputDevice::KX_LEFTARROWKEY;
+ m[DOWNARROWKEY ] = SCA_IInputDevice::KX_DOWNARROWKEY;
+ m[RIGHTARROWKEY ] = SCA_IInputDevice::KX_RIGHTARROWKEY;
+ m[UPARROWKEY ] = SCA_IInputDevice::KX_UPARROWKEY;
+
+ m[PAD2 ] = SCA_IInputDevice::KX_PAD2;
+ m[PAD4 ] = SCA_IInputDevice::KX_PAD4;
+ m[PAD6 ] = SCA_IInputDevice::KX_PAD6;
+ m[PAD8 ] = SCA_IInputDevice::KX_PAD8;
+
+ m[PAD1 ] = SCA_IInputDevice::KX_PAD1;
+ m[PAD3 ] = SCA_IInputDevice::KX_PAD3;
+ m[PAD5 ] = SCA_IInputDevice::KX_PAD5;
+ m[PAD7 ] = SCA_IInputDevice::KX_PAD7;
+ m[PAD9 ] = SCA_IInputDevice::KX_PAD9;
+
+ m[PADPERIOD ] = SCA_IInputDevice::KX_PADPERIOD;
+ m[PADSLASHKEY ] = SCA_IInputDevice::KX_PADSLASHKEY;
+ m[PADASTERKEY ] = SCA_IInputDevice::KX_PADASTERKEY;
+
+ m[PAD0 ] = SCA_IInputDevice::KX_PAD0;
+ m[PADMINUS ] = SCA_IInputDevice::KX_PADMINUS;
+ m[PADENTER ] = SCA_IInputDevice::KX_PADENTER;
+ m[PADPLUSKEY ] = SCA_IInputDevice::KX_PADPLUSKEY;
+
+
+ m[F1KEY ] = SCA_IInputDevice::KX_F1KEY;
+ m[F2KEY ] = SCA_IInputDevice::KX_F2KEY;
+ m[F3KEY ] = SCA_IInputDevice::KX_F3KEY;
+ m[F4KEY ] = SCA_IInputDevice::KX_F4KEY;
+ m[F5KEY ] = SCA_IInputDevice::KX_F5KEY;
+ m[F6KEY ] = SCA_IInputDevice::KX_F6KEY;
+ m[F7KEY ] = SCA_IInputDevice::KX_F7KEY;
+ m[F8KEY ] = SCA_IInputDevice::KX_F8KEY;
+ m[F9KEY ] = SCA_IInputDevice::KX_F9KEY;
+ m[F10KEY ] = SCA_IInputDevice::KX_F10KEY;
+ m[F11KEY ] = SCA_IInputDevice::KX_F11KEY;
m[F12KEY ] = SCA_IInputDevice::KX_F12KEY;
m[F13KEY ] = SCA_IInputDevice::KX_F13KEY;
m[F14KEY ] = SCA_IInputDevice::KX_F14KEY;
m[OSKEY ] = SCA_IInputDevice::KX_OSKEY;
- m[PAUSEKEY ] = SCA_IInputDevice::KX_PAUSEKEY;
- m[INSERTKEY ] = SCA_IInputDevice::KX_INSERTKEY;
- m[HOMEKEY ] = SCA_IInputDevice::KX_HOMEKEY;
- m[PAGEUPKEY ] = SCA_IInputDevice::KX_PAGEUPKEY;
- m[PAGEDOWNKEY ] = SCA_IInputDevice::KX_PAGEDOWNKEY;
+ m[PAUSEKEY ] = SCA_IInputDevice::KX_PAUSEKEY;
+ m[INSERTKEY ] = SCA_IInputDevice::KX_INSERTKEY;
+ m[HOMEKEY ] = SCA_IInputDevice::KX_HOMEKEY;
+ m[PAGEUPKEY ] = SCA_IInputDevice::KX_PAGEUPKEY;
+ m[PAGEDOWNKEY ] = SCA_IInputDevice::KX_PAGEDOWNKEY;
m[ENDKEY ] = SCA_IInputDevice::KX_ENDKEY;
return m;
unsigned int integer;
unsigned char cp[4];
} out_color, in_color;
-
+
in_color.integer = icol;
out_color.cp[0] = in_color.cp[3]; // red
out_color.cp[1] = in_color.cp[2]; // green
out_color.cp[2] = in_color.cp[1]; // blue
out_color.cp[3] = in_color.cp[0]; // alpha
-
+
return out_color.integer;
}
out_color.cp[1] = in_color.cp[2]; // green
out_color.cp[2] = in_color.cp[1]; // blue
out_color.cp[3] = in_color.cp[0]; // alpha
-
+
return out_color.integer;
}
int unit = 0;
if (tface)
{
-
+
uvs[0][0].setValue(tface->uv[0]);
uvs[1][0].setValue(tface->uv[1]);
uvs[2][0].setValue(tface->uv[2]);
- if (mface->v4)
+ if (mface->v4)
uvs[3][0].setValue(tface->uv[3]);
}
else
{
uvs[0][0] = uvs[1][0] = uvs[2][0] = uvs[3][0] = MT_Point2(0.f, 0.f);
}
-
+
vector<STR_String> found_layers;
for (int vind = 0; vind<MAXTEX; vind++)
//If no UVSet is specified, try grabbing one from the UV/Image editor
if (map.uvCoName.IsEmpty() && tface)
- {
+ {
uvs[0][unit].setValue(tface->uv[0]);
uvs[1][unit].setValue(tface->uv[1]);
uvs[2][unit].setValue(tface->uv[2]);
- if (mface->v4)
+ if (mface->v4)
uvs[3][unit].setValue(tface->uv[3]);
++unit;
uvs[1][unit].setValue(layer.face->uv[1]);
uvs[2][unit].setValue(layer.face->uv[2]);
- if (mface->v4)
+ if (mface->v4)
uvs[3][unit].setValue(layer.face->uv[3]);
else
uvs[3][unit].setValue(0.0f, 0.0f);
const bool validmat = (mat != NULL);
const bool validface = (tface != NULL);
const bool use_vcol = GetMaterialUseVColor(mat, glslmat);
-
+
material->IdMode = DEFAULT_BLENDER;
material->glslmat = (validmat) ? glslmat: false;
material->materialindex = mface->mat_nr;
if (mat->septex & (1 << i)) {
// If this texture slot isn't in use, set it to disabled to prevent multi-uv problems
material->mapping[i].mapping = DISABLE;
- }
+ }
else {
material->mapping[i].mapping |= (mttmp->texco & TEXCO_REFL) ? USEREFL : 0;
material->mapping[i].projplane[2] = mttmp->projz;
}
/// --------------------------------
-
+
switch (mttmp->blendtype) {
case MTEX_BLEND:
material->blend_mode[i] = BLEND_MIX;
if (ma && (ma->mode & MA_FACETEXTURE) == 0)
converter->CachePolyMaterial(scene, ma, polymat);
}
-
+
// see if a bucket was reused or a new one was created
// this way only one KX_BlenderMaterial object has to exist per bucket
- bool bucketCreated;
+ bool bucketCreated;
RAS_MaterialBucket* bucket = scene->FindBucket(polymat, bucketCreated);
// this is needed to free up memory afterwards.
/* mark face as flat, so vertices are split */
bool flat = (mface->flag & ME_SMOOTH) == 0;
-
+
int nverts = (mface->v4)? 4: 3;
RAS_Polygon *poly = meshobj->AddPolygon(bucket, nverts);
meshobj->AddVertex(poly,3,pt[3],uvs[3],tan[3],rgb[3],no[3],flat,mface->v4);
}
- if (tface)
+ if (tface)
tface++;
if (mcol)
mcol+=4;
if (layers)
delete []layers;
-
+
dm->release(dm);
converter->RegisterGameMesh(meshobj, mesh);
return meshobj;
}
-
-
+
+
static PHY_MaterialProps *CreateMaterialFromBlenderObject(struct Object* blenderobject)
{
PHY_MaterialProps *materialProps = new PHY_MaterialProps;
-
+
MT_assert(materialProps && "Create physics material properties failed");
-
+
Material* blendermat = give_current_material(blenderobject, 1);
-
+
if (blendermat)
{
MT_assert(0.0f <= blendermat->reflect && blendermat->reflect <= 1.0f);
-
+
materialProps->m_restitution = blendermat->reflect;
materialProps->m_friction = blendermat->friction;
materialProps->m_fh_spring = blendermat->fh;
materialProps->m_fh_normal = false;
}
-
+
return materialProps;
}
static PHY_ShapeProps *CreateShapePropsFromBlenderObject(struct Object* blenderobject)
{
PHY_ShapeProps *shapeProps = new PHY_ShapeProps;
-
+
MT_assert(shapeProps);
-
+
shapeProps->m_mass = blenderobject->mass;
-
+
// This needs to be fixed in blender. For now, we use:
-
+
// in Blender, inertia stands for the size value which is equivalent to
// the sphere radius
shapeProps->m_inertia = blenderobject->formfactor;
-
+
MT_assert(0.0f <= blenderobject->damping && blenderobject->damping <= 1.0f);
MT_assert(0.0f <= blenderobject->rdamping && blenderobject->rdamping <= 1.0f);
-
+
shapeProps->m_lin_drag = 1.0f - blenderobject->damping;
shapeProps->m_ang_drag = 1.0f - blenderobject->rdamping;
-
- shapeProps->m_friction_scaling[0] = blenderobject->anisotropicFriction[0];
+
+ shapeProps->m_friction_scaling[0] = blenderobject->anisotropicFriction[0];
shapeProps->m_friction_scaling[1] = blenderobject->anisotropicFriction[1];
shapeProps->m_friction_scaling[2] = blenderobject->anisotropicFriction[2];
shapeProps->m_do_anisotropic = ((blenderobject->gameflag & OB_ANISOTROPIC_FRICTION) != 0);
-
- shapeProps->m_do_fh = (blenderobject->gameflag & OB_DO_FH) != 0;
+
+ shapeProps->m_do_fh = (blenderobject->gameflag & OB_DO_FH) != 0;
shapeProps->m_do_rot_fh = (blenderobject->gameflag & OB_ROT_FH) != 0;
-
+
// velocity clamping XXX
shapeProps->m_clamp_vel_min = blenderobject->min_vel;
shapeProps->m_clamp_vel_max = blenderobject->max_vel;
return shapeProps;
}
-
-
-
-
+
+
+
+
//////////////////////////////////////////////////////////
-
+
static float my_boundbox_mesh(Mesh *me, float *loc, float *size)
float mloc[3], msize[3];
float radius_sq=0.0f, vert_radius_sq, *co;
int a;
-
+
if (me->bb==0) {
me->bb = BKE_boundbox_alloc_unit();
}
bb= me->bb;
-
+
INIT_MINMAX(min, max);
if (!loc) loc= mloc;
if (!size) size= msize;
-
+
mvert= me->mvert;
for (a = 0; a<me->totvert; a++, mvert++) {
co = mvert->co;
-
+
/* bounds */
minmax_v3v3_v3(min, max, co);
-
+
/* radius */
vert_radius_sq = len_squared_v3(co);
if (vert_radius_sq > radius_sq)
radius_sq = vert_radius_sq;
}
-
+
if (me->totvert) {
loc[0] = (min[0] + max[0]) / 2.0f;
loc[1] = (min[1] + max[1]) / 2.0f;
loc[2] = (min[2] + max[2]) / 2.0f;
-
+
size[0] = (max[0] - min[0]) / 2.0f;
size[1] = (max[1] - min[1]) / 2.0f;
size[2] = (max[2] - min[2]) / 2.0f;
loc[0] = loc[1] = loc[2] = 0.0f;
size[0] = size[1] = size[2] = 0.0f;
}
-
+
bb->vec[0][0] = bb->vec[1][0] = bb->vec[2][0] = bb->vec[3][0] = loc[0]-size[0];
bb->vec[4][0] = bb->vec[5][0] = bb->vec[6][0] = bb->vec[7][0] = loc[0]+size[0];
-
+
bb->vec[0][1] = bb->vec[1][1] = bb->vec[4][1] = bb->vec[5][1] = loc[1]-size[1];
bb->vec[2][1] = bb->vec[3][1] = bb->vec[6][1] = bb->vec[7][1] = loc[1]+size[1];
PHY_ShapeProps* shapeprops =
CreateShapePropsFromBlenderObject(blenderobject);
-
- PHY_MaterialProps* smmaterial =
+
+ PHY_MaterialProps* smmaterial =
CreateMaterialFromBlenderObject(blenderobject);
DerivedMesh* dm = NULL;
{
RAS_ILightObject *lightobj = rasterizer->CreateLight();
KX_LightObject *gamelight;
-
+
lightobj->m_att1 = la->att1;
lightobj->m_att2 = (la->mode & LA_QUAD) ? la->att2 : 0.0f;
lightobj->m_coeff_const = la->coeff_const;
lightobj->m_layer = layerflag;
lightobj->m_spotblend = la->spotblend;
lightobj->m_spotsize = la->spotsize;
-
+
lightobj->m_nodiffuse = (la->mode & LA_NO_DIFF) != 0;
lightobj->m_nospecular = (la->mode & LA_NO_SPEC) != 0;
-
+
bool glslmat = converter->GetGLSLMaterials();
// in GLSL NEGATIVE LAMP is handled inside the lamp update function
lightobj->m_color[2] = -lightobj->m_color[2];
}
}
-
+
if (la->type==LA_SUN) {
lightobj->m_type = RAS_ILightObject::LIGHT_SUN;
} else if (la->type==LA_SPOT) {
gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rasterizer,
lightobj, glslmat);
-
+
return gamelight;
}
Camera* ca = static_cast<Camera*>(ob->data);
RAS_CameraData camdata(ca->lens, ca->ortho_scale, ca->sensor_x, ca->sensor_y, ca->sensor_fit, ca->shiftx, ca->shifty, ca->clipsta, ca->clipend, ca->type == CAM_PERSP, ca->YF_dofdist);
KX_Camera *gamecamera;
-
+
gamecamera= new KX_Camera(kxscene, KX_Scene::m_callbacks, camdata);
gamecamera->SetName(ca->id.name + 2);
-
+
return gamecamera;
}
static KX_GameObject *gameobject_from_blenderobject(
- Object *ob,
- KX_Scene *kxscene,
+ Object *ob,
+ KX_Scene *kxscene,
RAS_IRasterizer *rendertools,
KX_BlenderSceneConverter *converter,
- bool libloading)
+ bool libloading)
{
KX_GameObject *gameobj = NULL;
Scene *blenderscene = kxscene->GetBlenderScene();
-
+
switch (ob->type) {
case OB_LAMP:
{
KX_LightObject* gamelight = gamelight_from_blamp(ob, static_cast<Lamp*>(ob->data), ob->lay, kxscene, rendertools, converter);
gameobj = gamelight;
-
+
if (blenderscene->lay & ob->lay)
{
gamelight->AddRef();
break;
}
-
+
case OB_CAMERA:
{
KX_Camera* gamecamera = gamecamera_from_bcamera(ob, kxscene, converter);
gameobj = gamecamera;
-
+
//don't add a reference: the camera list in kxscene->m_cameras is not released at the end
//gamecamera->AddRef();
kxscene->AddCamera(gamecamera);
-
+
break;
}
-
+
case OB_MESH:
{
Mesh* mesh = static_cast<Mesh*>(ob->data);
float center[3], extents[3];
float radius = my_boundbox_mesh((Mesh*) ob->data, center, extents);
RAS_MeshObject* meshobj = BL_ConvertMesh(mesh,ob,kxscene,converter, libloading);
-
+
// needed for python scripting
kxscene->GetLogicManager()->RegisterMeshName(meshobj->GetName(),meshobj);
}
gameobj = new BL_DeformableGameObject(ob,kxscene,KX_Scene::m_callbacks);
-
+
// set transformation
gameobj->AddMesh(meshobj);
kxscene->SetLodHysteresisValue(blenderscene->gm.scehysteresis);
}
}
-
+
// for all objects: check whether they want to
// respond to updates
- bool ignoreActivityCulling =
+ bool ignoreActivityCulling =
((ob->gameflag2 & OB_NEVER_DO_ACTIVITY_CULLING)!=0);
gameobj->SetIgnoreActivityCulling(ignoreActivityCulling);
gameobj->SetOccluder((ob->gameflag & OB_OCCLUDER) != 0, false);
// that requires it
Material *mat= NULL;
bool bUseObjectColor=false;
-
+
for (int i=0;i<mesh->totcol;i++) {
mat=mesh->mat[i];
if (!mat) break;
}
if (bUseObjectColor)
gameobj->SetObjectColor(ob->col);
-
+
// two options exists for deform: shape keys and armature
// only support relative shape key
bool bHasShapeKey = mesh->key != NULL && mesh->key->type==KEY_RELATIVE;
kxscene->GetBlenderScene(), ob, meshobj);
((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont);
} else if (bHasShapeKey) {
- // not that we can have shape keys without dvert!
- BL_ShapeDeformer *dcont = new BL_ShapeDeformer((BL_DeformableGameObject*)gameobj,
+ // not that we can have shape keys without dvert!
+ BL_ShapeDeformer *dcont = new BL_ShapeDeformer((BL_DeformableGameObject*)gameobj,
ob, meshobj);
((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont);
} else if (bHasArmature) {
((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont);
#endif
}
-
+
MT_Point3 min = MT_Point3(center) - MT_Vector3(extents);
MT_Point3 max = MT_Point3(center) + MT_Vector3(extents);
SG_BBox bbox = SG_BBox(min, max);
gameobj->GetSGNode()->SetBBox(bbox);
gameobj->GetSGNode()->SetRadius(radius);
-
+
break;
}
-
+
case OB_ARMATURE:
{
bArmature *arm = (bArmature*)ob->data;
/* Get the current pose from the armature object and apply it as the rest pose */
break;
}
-
+
case OB_EMPTY:
{
gameobj = new KX_EmptyObject(kxscene,KX_Scene::m_callbacks);
#endif
}
- if (gameobj)
+ if (gameobj)
{
gameobj->SetLayer(ob->lay);
gameobj->SetBlenderObject(ob);
{
bArmature *arm= (bArmature*)ob->data;
bPoseChannel *pchan;
-
+
/* find active */
for (pchan= (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if (pchan->bone && (pchan->bone == arm->act_bone) && (pchan->bone->layer & arm->layer))
return pchan;
}
-
+
return NULL;
}
return NULL;
// XXX - shouldnt we care about the pose data and not the mode???
- if (ob->mode & OB_MODE_POSE) {
+ if (ob->mode & OB_MODE_POSE) {
bPoseChannel *pchan;
pchan = get_active_posechannel2(ob);
if (pchan)
return &pchan->constraints;
}
- else
+ else
return &ob->constraints;
return NULL;
if (gameobje->GetName()==busc)
return gameobje;
}
-
+
return 0;
}
} else {
frame_type = RAS_FrameSettings::e_frame_scale;
}
-
+
aspect_width = (int)(blenderscene->r.xsch * blenderscene->r.xasp);
aspect_height = (int)(blenderscene->r.ysch * blenderscene->r.yasp);
}
-
+
RAS_FrameSettings frame_settings(
frame_type,
blenderscene->gm.framing.col[0],
kxscene->SetFramingType(frame_settings);
kxscene->SetGravity(MT_Vector3(0,0, -blenderscene->gm.gravity));
-
+
/* set activity culling parameters */
kxscene->SetActivityCulling( (blenderscene->gm.mode & WO_ACTIVITY_CULLING) != 0);
kxscene->SetActivityCullingRadius(blenderscene->gm.activityBoxRadius);
kxscene->SetDbvtCulling((blenderscene->gm.mode & WO_DBVT_CULLING) != 0);
-
+
// no occlusion culling by default
kxscene->SetDbvtOcclusionRes(0);
int activeLayerBitInfo = blenderscene->lay;
-
+
// list of all object converted, active and inactive
CListValue* sumolist = new CListValue();
-
+
vector<parentChildLink> vec_parent_child;
-
+
CListValue* objectlist = kxscene->GetObjectList();
CListValue* inactivelist = kxscene->GetInactiveList();
CListValue* parentlist = kxscene->GetRootParentList();
-
+
SCA_LogicManager* logicmgr = kxscene->GetLogicManager();
SCA_TimeEventManager* timemgr = kxscene->GetTimeEventManager();
-
+
CListValue* logicbrick_conversionlist = new CListValue();
-
+
//SG_TreeFactory tf;
-
+
// Convert actions to actionmap
bAction *curAct;
for (curAct = (bAction*)maggie->action.first; curAct; curAct=(bAction*)curAct->id.next)
allblobj.insert(blenderobject);
KX_GameObject* gameobj = gameobject_from_blenderobject(
- base->object,
- kxscene,
- rendertools,
+ base->object,
+ kxscene,
+ rendertools,
converter,
libloading);
allblobj.insert(blenderobject);
groupobj.insert(blenderobject);
KX_GameObject* gameobj = gameobject_from_blenderobject(
- blenderobject,
- kxscene,
- rendertools,
+ blenderobject,
+ kxscene,
+ rendertools,
converter,
libloading);
// non-camera objects not supported as camera currently
if (blenderscene->camera && blenderscene->camera->type == OB_CAMERA) {
KX_Camera *gamecamera= (KX_Camera*) converter->FindGameObject(blenderscene->camera);
-
+
if (gamecamera)
kxscene->SetActiveCamera(gamecamera);
}
Object* blenderobj = *oit;
if (blenderobj->type==OB_MESH) {
Mesh *me = (Mesh*)blenderobj->data;
-
+
if (me->dvert) {
BL_DeformableGameObject *obj = (BL_DeformableGameObject*)converter->FindGameObject(blenderobj);
}
}
}
-
+
// create hierarchy information
int i;
vector<parentChildLink>::iterator pcit;
-
+
for (pcit = vec_parent_child.begin();!(pcit==vec_parent_child.end());++pcit)
{
-
+
struct Object* blenderchild = pcit->m_blenderchild;
struct Object* blenderparent = blenderchild->parent;
KX_GameObject* parentobj = converter->FindGameObject(blenderparent);
if (!parentobj || objectlist->SearchValue(childobj) != objectlist->SearchValue(parentobj))
{
- // special case: the parent and child object are not in the same layer.
+ // special case: the parent and child object are not in the same layer.
// This weird situation is used in Apricot for test purposes.
// Resolve it by not converting the child
childobj->GetSGNode()->DisconnectFromParent();
obj->Release();
}
childrenlist->Release();
-
+
// now destroy recursively
converter->UnregisterGameObject(childobj); // removing objects during conversion make sure this runs too
kxscene->RemoveObject(childobj);
-
+
continue;
}
KX_BoneParentRelation *bone_parent_relation = KX_BoneParentRelation::New(parent_bone);
pcit->m_gamechildnode->SetParentRelation(bone_parent_relation);
}
-
+
break;
}
case PARSKEL: // skinned - ignore
// unhandled
break;
}
-
+
parentobj-> GetSGNode()->AddChild(pcit->m_gamechildnode);
}
vec_parent_child.clear();
-
+
// find 'root' parents (object that has not parents in SceneGraph)
for (i=0;i<sumolist->GetCount();++i)
{
for (i=0; i<sumolist->GetCount();i++)
{
KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i);
- if (gameobj->GetMeshCount() > 0)
+ if (gameobj->GetMeshCount() > 0)
{
MT_Point3 box[2];
gameobj->GetSGNode()->BBox().getmm(box, MT_Transform::Identity());
continue;
bRigidBodyJointConstraint *dat = (bRigidBodyJointConstraint *)curcon->data;
-
+
/* Skip if no target or a child object is selected or constraints are deactivated */
if (!dat->tar || dat->child || (curcon->flag & CONSTRAINT_OFF))
continue;
if (libloading)
continue;
- /* Skipped already converted constraints.
+ /* Skipped already converted constraints.
* This will happen when a group instance is made from a linked group instance
* and both are on the active layer. */
if (bl_isConstraintInList(gameobj, convertedlist))
set<KX_GameObject*>::iterator gobit;
for (gobit = convertedlist.begin(); gobit != convertedlist.end(); gobit++)
(*gobit)->Release();
-
+
convertedlist.clear();
sumolist->Release();
}
logicbrick_conversionlist->Release();
-
+
// Calculate the scene btree -
// too slow - commented out.
//kxscene->SetNodeTree(tf.MakeTree());
class KX_KetsjiEngine* ketsjiEngine,
e_PhysicsEngine physics_engine,
class RAS_IRasterizer* rendertools,
- class RAS_ICanvas* canvas,
- class KX_BlenderSceneConverter* sceneconverter,
+ class RAS_ICanvas* canvas,
+ class KX_BlenderSceneConverter* sceneconverter,
bool alwaysUseExpandFraming,
bool libloading=false
);
m_activeAct = act;
m_activePriority = priority;
m_lastframe = curtime;
-
+
return true;
}
else {
// this check is normally superfluous: a shape deformer can only be created if the mesh
// has relative keys
Key* key = shape_deformer->GetKey();
- if (key && key->type==KEY_RELATIVE)
+ if (key && key->type==KEY_RELATIVE)
{
KeyBlock *kb;
for (kb = (KeyBlock *)key->block.first; kb; kb = (KeyBlock *)kb->next)
class BL_ShapeActionActuator;
struct Key;
-class BL_DeformableGameObject : public KX_GameObject
+class BL_DeformableGameObject : public KX_GameObject
{
public:
CValue* GetReplica();
bool SetActiveAction(class BL_ShapeActionActuator *act, short priority, double curtime);
bool GetShape(vector<float> &shape);
-
+
virtual void SetDeformer(class RAS_Deformer* deformer);
virtual class RAS_Deformer* GetDeformer()
{
}
public:
-
+
protected:
-
+
RAS_Deformer *m_pDeformer;
class BL_ShapeActionActuator *m_activeAct;
if (m_transnors)
delete [] m_transnors;
}
-
+
void BL_MeshDeformer::ProcessReplica()
{
m_transverts = NULL;
const float *co2 = m_transverts[v2.getOrigIndex()];
const float *co3 = m_transverts[v3.getOrigIndex()];
const float *co4 = NULL;
-
+
/* compute face normal */
float fnor[3], n1[3], n2[3];
delete [] m_transverts;
if (m_transnors)
delete [] m_transnors;
-
+
m_transverts=new float[m_bmesh->totvert][3];
m_transnors=new float[m_bmesh->totvert][3];
m_tvtot = m_bmesh->totvert;
protected:
class RAS_MeshObject* m_pMeshObject;
struct Mesh* m_bmesh;
-
+
// this is so m_transverts doesn't need to be converted
// before deformation
float (*m_transverts)[3];
float (*m_transnors)[3];
- struct Object* m_objMesh;
+ struct Object* m_objMesh;
// --
int m_tvtot;
BL_DeformableGameObject* m_gameobj;
/* we need to compute the deformed mesh taking into account the current
* shape and skin deformers, we cannot just call mesh_create_derived_physics()
* because that would use the m_transvers already deformed previously by BL_ModifierDeformer::Update(),
- * so restart from scratch by forcing a full update the shape/skin deformers
+ * so restart from scratch by forcing a full update the shape/skin deformers
* (will do nothing if there is no such deformer) */
BL_ShapeDeformer::ForceUpdate();
BL_ShapeDeformer::Update();
struct DerivedMesh;
struct Object;
-class BL_ModifierDeformer : public BL_ShapeDeformer
+class BL_ModifierDeformer : public BL_ShapeDeformer
{
public:
static bool HasCompatibleDeformer(Object *ob);
short playtype,
short blendin,
short priority,
- float stride)
+ float stride)
: SCA_IActuator(gameobj, KX_ACT_SHAPEACTION),
-
+
m_lastpos(0, 0, 0),
m_blendframe(0),
m_flag(0),
m_blendframe = newtime;
}
-CValue* BL_ShapeActionActuator::GetReplica()
+CValue* BL_ShapeActionActuator::GetReplica()
{
BL_ShapeActionActuator* replica = new BL_ShapeActionActuator(*this);//m_float,GetName());
replica->ProcessReplica();
{
m_localtime = m_startframe;
return true;
- }
+ }
else if (m_localtime > m_endframe)
{
m_localtime = m_endframe;
void BL_ShapeActionActuator::SetStartTime(float curtime)
{
float direction = m_startframe < m_endframe ? 1.0 : -1.0;
-
+
if (!(m_flag & ACT_FLAG_REVERSE))
m_starttime = curtime - direction*(m_localtime - m_startframe)/KX_KetsjiEngine::GetAnimFrameRate();
else
void BL_ShapeActionActuator::SetLocalTime(float curtime)
{
float delta_time = (curtime - m_starttime)*KX_KetsjiEngine::GetAnimFrameRate();
-
+
if (m_endframe < m_startframe)
delta_time = -delta_time;
vector<float>::const_iterator it;
float dstweight;
KeyBlock *kb;
-
+
dstweight = 1.0F - srcweight;
- for (it=m_blendshape.begin(), kb = (KeyBlock *)key->block.first;
+ for (it=m_blendshape.begin(), kb = (KeyBlock *)key->block.first;
kb && it != m_blendshape.end();
kb = (KeyBlock *)kb->next, it++)
{
float newweight;
curtime -= KX_KetsjiEngine::GetSuspendedDelta();
-
+
// result = true if animation has to be continued, false if animation stops
// maybe there are events for us in the queue !
if (frame)
bNegativeEvent = m_negevent;
bPositiveEvent = m_posevent;
RemoveAllEvents();
-
+
if (bPositiveEvent)
m_flag |= ACT_FLAG_ACTIVE;
-
+
if (bNegativeEvent)
{
if (!(m_flag & ACT_FLAG_ACTIVE))
m_flag &= ~ACT_FLAG_ACTIVE;
}
}
-
+
/* This action can only be attached to a deform object */
BL_DeformableGameObject *obj = (BL_DeformableGameObject*)GetParent();
float length = m_endframe - m_startframe;
-
+
priority = m_priority;
-
+
/* Determine pre-incrementation behavior and set appropriate flags */
switch (m_playtype) {
case ACT_ACTION_MOTION:
default:
break;
}
-
+
/* Perform increment */
if (keepgoing) {
if (m_playtype == ACT_ACTION_MOTION) {
MT_Point3 newpos;
MT_Point3 deltapos;
-
+
newpos = obj->NodeGetWorldPosition();
-
+
/* Find displacement */
deltapos = newpos-m_lastpos;
m_localtime += (length/m_stridelength) * deltapos.length();
SetLocalTime(curtime);
}
}
-
+
/* Check if a wrapping response is needed */
if (length) {
if (m_localtime < m_startframe || m_localtime > m_endframe)
}
else
m_localtime = m_startframe;
-
+
/* Perform post-increment tasks */
switch (m_playtype) {
case ACT_ACTION_FROM_PROP:
CValue* propval = GetParent()->GetProperty(m_propname);
if (propval)
m_localtime = propval->GetNumber();
-
+
if (bNegativeEvent) {
keepgoing=false;
}
if (wrap) {
if (!(m_flag & ACT_FLAG_REVERSE))
m_localtime = m_endframe;
- else
+ else
m_localtime = m_startframe;
m_flag &= ~ACT_FLAG_LOCKINPUT;
keepgoing = false;
break;
}
-
+
/* Set the property if its defined */
if (m_framepropname[0] != '\0') {
CValue* propowner = GetParent();
}
newval->Release();
}
-
+
if (bNegativeEvent)
m_blendframe=0.0f;
-
+
/* Apply the pose if necessary*/
if (apply) {
}
else {
ListBase tchanbase= {NULL, NULL};
-
+
if (m_blendin && m_blendframe==0.0f) {
// this is the start of the blending, remember the startup shape
obj->GetShape(m_blendshape);
if (0) { // XXX !execute_ipochannels(&tchanbase)) {
// no update, this is possible if action does not match the keys, stop the action
keepgoing = false;
- }
+ }
else {
// the key have changed, apply blending if needed
if (m_blendin && (m_blendframe<m_blendin)) {
m_blendframe = 0.0f;
}
}
-
+
if (!keepgoing) {
m_blendframe = 0.0f;
}
bAction *action= NULL;
STR_String val = _PyUnicode_AsString(value);
-
+
if (val != "")
{
action= (bAction*)self->GetLogicManager()->GetActionByName(val);
return PY_SET_ATTR_FAIL;
}
}
-
+
self->SetAction(action);
return PY_SET_ATTR_SUCCESS;
#include <vector>
struct Key;
-class BL_ShapeActionActuator : public SCA_IActuator
+class BL_ShapeActionActuator : public SCA_IActuator
{
public:
Py_Header
virtual bool Update(double curtime, bool frame);
virtual CValue* GetReplica();
virtual void ProcessReplica();
-
+
void SetBlendTime (float newtime);
void BlendShape(struct Key* key, float weight);
-
+
bAction* GetAction() { return m_action; }
void SetAction(bAction* act) { m_action= act; }
float m_starttime;
/** The current time of the action */
float m_localtime;
-
+
float m_lastUpdate;
float m_blendin;
float m_blendstart;
if (m_lastShapeUpdate != m_gameobj->GetLastFrame()) {
/* the key coefficient have been set already, we just need to blend the keys */
Object* blendobj = m_gameobj->GetBlendObject();
-
+
/* we will blend the key directly in m_transverts array: it is used by armature as the start position */
/* m_key can be NULL in case of Modifier deformer */
if (m_key) {
m_bDynamic = true;
}
- // Don't release the weight array as in Blender, it will most likely be reusable on next frame
+ // Don't release the weight array as in Blender, it will most likely be reusable on next frame
// The weight array are ultimately deleted when the skin mesh is destroyed
-
+
/* Update the current frame */
m_lastShapeUpdate=m_gameobj->GetLastFrame();
// non dynamic deformer = Modifer without armature and shape keys, no need to create storage
if (!bSkinUpdate && bShapeUpdate && m_bDynamic) {
- // this means that there is no armature, we still need to
+ // this means that there is no armature, we still need to
// update the normal (was not done after shape key calculation)
#ifdef __NLA_DEFNORMALS
#include "BL_DeformableGameObject.h"
#include <vector>
-class BL_ShapeDeformer : public BL_SkinDeformer
+class BL_ShapeDeformer : public BL_SkinDeformer
{
public:
BL_ShapeDeformer(BL_DeformableGameObject *gameobj,
#include "BKE_lattice.h"
#include "BKE_deform.h"
}
-
+
#include "BLI_blenlib.h"
#include "BLI_math.h"
copy_m4_m4(m_objMesh->obmat, m_obmat);
armature_deform_verts( par_arma, m_objMesh, NULL, m_transverts, NULL, m_bmesh->totvert, m_deformflags, NULL, NULL );
-
- // restore matrix
+
+ // restore matrix
copy_m4_m4(m_objMesh->obmat, obmat);
#ifdef __NLA_DEFNORMALS
}
}
}
-
+
// Update Vertex Normal
norm = norm_chan_mat.topLeftCorner<3, 3>()*norm;
#include "RAS_Deformer.h"
-class BL_SkinDeformer : public BL_MeshDeformer
+class BL_SkinDeformer : public BL_MeshDeformer
{
public:
// void SetArmatureController (BL_ArmatureController *cont);
bool Update (void);
bool UpdateInternal (bool shape_applied);
bool Apply (class RAS_IPolyMaterial *polymat);
- bool UpdateBuckets(void)
+ bool UpdateBuckets(void)
{
// update the deformer and all the mesh slots; Apply() does it well, so just call it.
return Apply(NULL);
}
bool PoseUpdated(void)
- {
+ {
if (m_armobj && m_lastArmaUpdate!=m_armobj->GetLastFrame()) {
return true;
}
{
if (action==NULL)
return;
-
+
for (FCurve *fcu = (FCurve *)action->curves.first; fcu; fcu = fcu->next) {
if (fcu->rna_path) {
- BL_ScalarInterpolator *new_ipo = new BL_ScalarInterpolator(fcu);
+ BL_ScalarInterpolator *new_ipo = new BL_ScalarInterpolator(fcu);
//assert(new_ipo);
push_back(new_ipo);
}
{}
virtual ~BL_ScalarInterpolator() {}
-
+
virtual float GetValue(float currentTime) const;
struct FCurve *GetFCurve() { return m_fcu; }
*worldit = m_worldinfos.back();
m_worldinfos.pop_back();
size--;
- }
+ }
else {
i++;
worldit++;
*polymit = m_polymaterials.back();
m_polymaterials.pop_back();
size--;
- }
+ }
else {
i++;
polymit++;
*matit = m_materials.back();
m_materials.pop_back();
size--;
- }
+ }
else {
i++;
matit++;
*meshit = m_meshobjects.back();
m_meshobjects.pop_back();
size--;
- }
+ }
else {
i++;
meshit++;
m_alwaysUseExpandFraming= to_what;
}
-void KX_BlenderSceneConverter::RegisterGameObject(KX_GameObject *gameobject, Object *for_blenderobject)
+void KX_BlenderSceneConverter::RegisterGameObject(KX_GameObject *gameobject, Object *for_blenderobject)
{
/* only maintained while converting, freed during game runtime */
m_map_blender_to_gameobject.insert(CHashedPtr(for_blenderobject), gameobject);
/* only need to run this during conversion since
* m_map_blender_to_gameobject is freed after conversion */
-void KX_BlenderSceneConverter::UnregisterGameObject(KX_GameObject *gameobject)
+void KX_BlenderSceneConverter::UnregisterGameObject(KX_GameObject *gameobject)
{
Object *bobp = gameobject->GetBlenderObject();
if (bobp) {
}
}
-KX_GameObject *KX_BlenderSceneConverter::FindGameObject(Object *for_blenderobject)
+KX_GameObject *KX_BlenderSceneConverter::FindGameObject(Object *for_blenderobject)
{
KX_GameObject **obp = m_map_blender_to_gameobject[CHashedPtr(for_blenderobject)];
if (meshp) {
return *meshp;
- }
+ }
else {
return NULL;
}
localDel_ipoCurve( tmpicu );
}
}
- }
+ }
else {
ipo = NULL; // XXX add_ipo(blenderObject->id.name+2, ID_OB);
blenderObject->ipo = ipo;
const MT_Point3& position = gameObj->NodeGetWorldPosition();
//const MT_Vector3& scale = gameObj->NodeGetWorldScaling();
const MT_Matrix3x3& orn = gameObj->NodeGetWorldOrientation();
-
+
float eulerAngles[3];
float eulerAnglesOld[3] = {0.0f, 0.0f, 0.0f};
float tmat[3][3];
-
+
// XXX animato
Ipo* ipo = blenderObject->ipo;
icu_rz = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z, 1);
if (icu_rz) icu_rz->ipo = IPO_LIN;
}
-
+
if (icu_rx) eulerAnglesOld[0] = eval_icu( icu_rx, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
if (icu_ry) eulerAnglesOld[1] = eval_icu( icu_ry, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
if (icu_rz) eulerAnglesOld[2] = eval_icu( icu_rz, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
-
+
// orn.getValue((float *)tmat); // uses the wrong ordering, cant use this
for (int r = 0; r < 3; r++)
for (int c = 0; c < 3; c++)
tmat[r][c] = orn[c][r];
-
+
// mat3_to_eul( eulerAngles,tmat); // better to use Mat3ToCompatibleEul
mat3_to_compatible_eul( eulerAngles, eulerAnglesOld,tmat);
-
+
//eval_icu
for (int x = 0; x < 3; x++)
eulerAngles[x] *= (float) ((180 / 3.14159265f) / 10.0);
-
+
//fill the curves with data
if (icu_lx) insert_vert_icu(icu_lx, frameNumber, position.x(), 1);
if (icu_ly) insert_vert_icu(icu_ly, frameNumber, position.y(), 1);
if (icu_rx) insert_vert_icu(icu_rx, frameNumber, eulerAngles[0], 1);
if (icu_ry) insert_vert_icu(icu_ry, frameNumber, eulerAngles[1], 1);
if (icu_rz) insert_vert_icu(icu_rz, frameNumber, eulerAngles[2], 1);
-
+
// Handles are corrected at the end, testhandles_ipocurve isn't needed yet
#endif
}
for (vector<Main *>::iterator it = m_DynamicMaggie.begin(); !(it == m_DynamicMaggie.end()); it++)
if (BLI_path_cmp((*it)->name, path) == 0)
return *it;
-
+
return NULL;
}
int totnames_dummy;
names = BLO_blendhandle_get_datablock_names(bpy_openlib, idcode, &totnames_dummy);
-
+
int i = 0;
LinkNode *n = names;
while (n) {
BLO_blendhandle_close(bpy_openlib);
return NULL;
}
-
+
if (GetMainDynamicPath(path)) {
snprintf(err_local, sizeof(err_local), "blend file already open \"%s\"\n", path);
*err_str = err_local;
BKE_reports_clear(&reports);
/* done linking */
-
+
/* needed for lookups*/
GetMainDynamic().push_back(main_newlib);
BLI_strncpy(main_newlib->name, path, sizeof(main_newlib->name));
-
-
+
+
status = new KX_LibLoadStatus(this, m_ketsjiEngine, scene_merge, path);
if (idcode == ID_ME) {
/* Convert all new meshes into BGE meshes */
ID *mesh;
-
+
for (mesh = (ID *)main_newlib->mesh.first; mesh; mesh = (ID *)mesh->next ) {
if (options & LIB_LOAD_VERBOSE)
printf("MeshName: %s\n", mesh->name + 2);
for (scene = (ID *)main_newlib->scene.first; scene; scene = (ID *)scene->next ) {
if (options & LIB_LOAD_VERBOSE)
printf("SceneName: %s\n", scene->name + 2);
-
+
if (options & LIB_LOAD_ASYNC) {
scenes->push_back((Scene *)scene);
- }
+ }
else {
/* merge into the base scene */
KX_Scene* other = m_ketsjiEngine->CreateScene((Scene *)scene, true);
scene_merge->MergeScene(other);
-
+
// RemoveScene(other); // Don't run this, it frees the entire scene converter data, just delete the scene
delete other;
}
/* in case the mesh might be refered to later */
{
CTR_Map<STR_HashedString, void *> &mapStringToMeshes = scene->GetLogicManager()->GetMeshMap();
-
+
for (int i = 0; i < mapStringToMeshes.size(); i++) {
RAS_MeshObject *meshobj = (RAS_MeshObject *) *mapStringToMeshes.at(i);
if (meshobj && IS_TAGGED(meshobj->GetMesh())) {
}
}
}
-
+
//scene->FreeTagged(); /* removed tagged objects and meshes*/
CListValue *obj_lists[] = {scene->GetObjectList(), scene->GetInactiveList(), NULL};
*worldit = m_worldinfos.back();
m_worldinfos.pop_back();
size--;
- }
+ }
else {
i++;
worldit++;
*matit = m_materials.back();
m_materials.pop_back();
size--;
- }
+ }
else {
i++;
matit++;
*meshit = m_meshobjects.back();
m_meshobjects.pop_back();
size--;
- }
+ }
else {
i++;
meshit++;
// Saved KX_LibLoadStatus objects
map<char *, class KX_LibLoadStatus*> m_status_map;
- // Should also have a list of collision shapes.
+ // Should also have a list of collision shapes.
// For the time being this is held in KX_Scene::m_shapes
CTR_Map<CHashedPtr,KX_GameObject*> m_map_blender_to_gameobject; /* cleared after conversion */
CTR_Map<CHashedPtr,RAS_MeshObject*> m_map_mesh_to_gamemesh; /* cleared after conversion */
CTR_Map<CHashedPtr,SCA_IActuator*> m_map_blender_to_gameactuator; /* cleared after conversion */
CTR_Map<CHashedPtr,SCA_IController*>m_map_blender_to_gamecontroller; /* cleared after conversion */
-
+
CTR_Map<CHashedPtr,BL_InterpolatorList*> m_map_blender_to_gameAdtList;
-
+
Main* m_maggie;
vector<struct Main*> m_DynamicMaggie;
bool TryAndLoadNewFile();
void SetAlwaysUseExpandFraming(bool to_what);
-
+
void RegisterGameObject(KX_GameObject *gameobject, struct Object *for_blenderobject);
void UnregisterGameObject(KX_GameObject *gameobject);
KX_GameObject *FindGameObject(struct Object *for_blenderobject);
void RegisterBlenderMaterial(BL_Material *mat);
void CacheBlenderMaterial(KX_Scene *scene, Material *mat, BL_Material *blmat);
BL_Material *FindCachedBlenderMaterial(KX_Scene *scene, Material *mat);
-
+
void RegisterInterpolatorList(BL_InterpolatorList *actList, struct bAction *for_act);
BL_InterpolatorList *FindInterpolatorList(struct bAction *for_act);
///this is for reseting the position,rotation and scale of the gameobjet that is not dynamic
virtual void resetNoneDynamicObjectToIpo();
-
+
///this generates ipo curves for position, rotation, allowing to use game physics in animation
virtual void WritePhysicsObjectToAnimationIpo(int frameNumber);
virtual void TestHandlesPhysicsObjectToAnimationIpo();
// struct Main* GetMain() { return m_maggie; }
struct Main* GetMainDynamicPath(const char *path);
vector<struct Main*> &GetMainDynamic();
-
+
class KX_LibLoadStatus *LinkBlendFileMemory(void *data, int length, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options);
class KX_LibLoadStatus *LinkBlendFilePath(const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options);
class KX_LibLoadStatus *LinkBlendFile(struct BlendHandle *bpy_openlib, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options);
virtual void MergeAsyncLoads();
virtual void FinalizeAsyncLoads();
void AddScenesToMergeQueue(class KX_LibLoadStatus *status);
-
+
void PrintStats() {
printf("BGE STATS!\n");
#endif
// /printf("\t m_ketsjiEngine->m_scenes: %d\n", m_ketsjiEngine->CurrentScenes()->size());
}
-
+
/* LibLoad Options */
- enum
+ enum
{
LIB_LOAD_LOAD_ACTIONS = 1,
LIB_LOAD_VERBOSE = 2,
#ifdef WITH_PYTHON
PyObject *GetPyNamespace();
#endif
-
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BlenderSceneConverter")
#endif
#include "BL_BlenderDataConversion.h"
-/**
+/**
* KX_flt_trunc needed to round 'almost' zero values to zero, else velocities etc. are incorrectly set
*/
KX_BlenderSceneConverter* converter
)
{
-
+
int uniqueint = 0;
int actcount = 0;
int executePriority = 0;
{
STR_String uniquename = bact->name;
STR_String& objectname = gameobj->GetName();
-
+
SCA_IActuator* baseact = NULL;
switch (bact->type)
{
/* Blender uses a bit vector internally for the local-flags. In */
/* KX, we have four bools. The compiler should be smart enough */
/* to do the right thing. We need to explicitly convert here! */
-
+
KX_LocalFlags bitLocalFlag;
-
+
bitLocalFlag.Force = bool((obact->flag & ACT_FORCE_LOCAL)!=0);
bitLocalFlag.Torque = bool((obact->flag & ACT_TORQUE_LOCAL) !=0);//rlocal;
bitLocalFlag.DLoc = bool((obact->flag & ACT_DLOC_LOCAL)!=0);
{
obref = converter->FindGameObject(obact->reference);
}
-
+
KX_ObjectActuator* tmpbaseact = new KX_ObjectActuator(
gameobj,
obref,
if (actact->flag & ACT_IPOLOCAL) ipo_flags |= BL_Action::ACT_IPOFLAG_LOCAL;
if (actact->flag & ACT_IPOADD) ipo_flags |= BL_Action::ACT_IPOFLAG_ADD;
if (actact->flag & ACT_IPOCHILD) ipo_flags |= BL_Action::ACT_IPOFLAG_CHILD;
-
+
BL_ActionActuator* tmpbaseact = new BL_ActionActuator(
gameobj,
propname,
bActionActuator* actact = (bActionActuator*) bact->data;
STR_String propname = actact->name;
STR_String propframe = actact->frameProp;
-
+
BL_ShapeActionActuator* tmpbaseact = new BL_ShapeActionActuator(
gameobj,
propname,
bCameraActuator *camact = (bCameraActuator *) bact->data;
if (camact->ob) {
KX_GameObject *tmpgob = converter->FindGameObject(camact->ob);
-
- /* visifac, fac and axis are not copied from the struct... */
+
+ /* visifac, fac and axis are not copied from the struct... */
/* that's some internal state... */
KX_CameraActuator *tmpcamact = new KX_CameraActuator(
gameobj,
case ACT_MESSAGE:
{
bMessageActuator *msgAct = (bMessageActuator *) bact->data;
-
+
/* Get the name of the properties that objects must own that
* we're sending to, if present
*/
STR_String toPropName = msgAct->toPropName;
-
+
/* Get the Message Subject to send.
*/
STR_String subject = msgAct->subject;
-
+
/* Get the bodyType
*/
int bodyType = msgAct->bodyType;
* we'll be sending, might be empty
*/
const STR_String body = msgAct->body;
-
+
KX_NetworkMessageActuator *tmpmsgact = new KX_NetworkMessageActuator(
gameobj, // actuator controlling object
scene->GetNetworkScene(), // needed for replication
/* get type, and possibly a start and end frame */
KX_SoundActuator::KX_SOUNDACT_TYPE
soundActuatorType = KX_SoundActuator::KX_SOUNDACT_NODEF;
-
+
switch (soundact->type) {
case ACT_SND_PLAY_STOP_SOUND:
soundActuatorType = KX_SoundActuator::KX_SOUNDACT_PLAYSTOP;
case ACT_SND_LOOP_BIDIRECTIONAL_STOP_SOUND:
soundActuatorType = KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP;
break;
-
+
default:
/* This is an error!!! */
soundActuatorType = KX_SoundActuator::KX_SOUNDACT_NODEF;
}
-
- if (soundActuatorType != KX_SoundActuator::KX_SOUNDACT_NODEF)
+
+ if (soundActuatorType != KX_SoundActuator::KX_SOUNDACT_NODEF)
{
bSound* sound = soundact->sound;
bool is3d = soundact->flag & ACT_SND_3D_SOUND ? true : false;
{
bPropertyActuator* propact = (bPropertyActuator*) bact->data;
SCA_IObject* destinationObj = NULL;
-
+
/*
* here the destinationobject is searched. problem with multiple scenes: other scenes
* have not been converted yet, so the destobj will not be found, so the prop will
*/
if (propact->ob)
destinationObj = converter->FindGameObject(propact->ob);
-
+
SCA_PropertyActuator* tmppropact = new SCA_PropertyActuator(
gameobj,
destinationObj,
}
case ACT_EDIT_OBJECT:
{
- bEditObjectActuator *editobact
+ bEditObjectActuator *editobact
= (bEditObjectActuator *) bact->data;
/* There are four different kinds of 'edit object' thingies */
/* The alternative to this lengthy conversion is packing */
/* several actuators in one, which is not very nice design.. */
switch (editobact->type) {
- case ACT_EDOB_ADD_OBJECT:
+ case ACT_EDOB_ADD_OBJECT:
{
-
- // does the 'original' for replication exists, and
+
+ // does the 'original' for replication exists, and
// is it in a non-active layer ?
SCA_IObject* originalval = NULL;
if (editobact->ob)
originalval = converter->FindGameObject(editobact->ob);
}
}
-
+
KX_SCA_AddObjectActuator* tmpaddact = new KX_SCA_AddObjectActuator(
gameobj,
originalval,
break;
case ACT_EDOB_END_OBJECT:
{
- KX_SCA_EndObjectActuator* tmpendact
+ KX_SCA_EndObjectActuator* tmpendact
= new KX_SCA_EndObjectActuator(gameobj,scene);
baseact = tmpendact;
}
SCA_IObject* originalval = NULL;
if (editobact->ob)
originalval = converter->FindGameObject(editobact->ob);
-
+
KX_TrackToActuator* tmptrackact = new KX_TrackToActuator(
gameobj,
originalval,
float min = 0.0, max = 0.0;
char *prop = NULL;
KX_ConstraintActuator::KX_CONSTRAINTTYPE locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_NODEF;
- bConstraintActuator *conact
+ bConstraintActuator *conact
= (bConstraintActuator*) bact->data;
- /* convert settings... degrees in the ui become radians */
- /* internally */
+ /* convert settings... degrees in the ui become radians */
+ /* internally */
if (conact->type == ACT_CONST_TYPE_ORI) {
min = conact->minloc[0];
max = conact->maxloc[0];
} else {
switch (conact->flag) {
case ACT_CONST_LOCX:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCX;
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCX;
min = conact->minloc[0];
max = conact->maxloc[0];
break;
case ACT_CONST_LOCY:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCY;
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCY;
min = conact->minloc[1];
max = conact->maxloc[1];
break;
max = conact->maxrot[2] * (float)MT_RADS_PER_DEG;
break;
default:
- ; /* error */
+ ; /* error */
}
}
KX_ConstraintActuator *tmpconact = new KX_ConstraintActuator(
{
bSceneActuator *sceneact = (bSceneActuator *) bact->data;
STR_String nextSceneName("");
-
+
KX_SceneActuator* tmpsceneact;
int mode = KX_SceneActuator::KX_SCENE_NODEF;
KX_Camera *cam = NULL;
mode = KX_SceneActuator::KX_SCENE_SET_SCENE;
break;
};
-
+
if (sceneact->scene) {
nextSceneName = sceneact->scene->id.name + 2;
}
-
+
break;
}
case ACT_SCENE_CAMERA:
break;
case ACT_SCENE_RESTART:
{
-
+
mode = KX_SceneActuator::KX_SCENE_RESTART;
break;
}
}
case ACT_RANDOM:
{
- bRandomActuator *randAct
+ bRandomActuator *randAct
= (bRandomActuator *) bact->data;
-
+
unsigned long seedArg = randAct->seed;
if (seedArg == 0)
{
seedArg = (int)(ketsjiEngine->GetRealTime()*100000.0);
seedArg ^= (intptr_t)randAct;
}
- SCA_RandomActuator::KX_RANDOMACT_MODE modeArg
+ SCA_RandomActuator::KX_RANDOMACT_MODE modeArg
= SCA_RandomActuator::KX_RANDOMACT_NODEF;
SCA_RandomActuator *tmprandomact;
float paraArg1 = 0.0;
float paraArg2 = 0.0;
-
+
switch (randAct->distribution) {
case ACT_RANDOM_BOOL_CONST:
modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_CONST;
bool recursive = ((vis_act->flag & ACT_VISIBILITY_RECURSIVE) != 0);
tmp_vis_act = new KX_VisibilityActuator(gameobj, !v, o, recursive);
-
+
baseact = tmp_vis_act;
}
break;
bStateActuator *sta_act = (bStateActuator *) bact->data;
KX_StateActuator * tmp_sta_act = NULL;
- tmp_sta_act =
+ tmp_sta_act =
new KX_StateActuator(gameobj, sta_act->type, sta_act->mask);
-
+
baseact = tmp_sta_act;
}
break;
tmpgob = NULL;
break;
}
-
+
KX_ParentActuator *tmpparact
= new KX_ParentActuator(gameobj,
mode,
baseact = tmpparact;
break;
}
-
+
case ACT_ARMATURE:
{
bArmatureActuator* armAct = (bArmatureActuator*) bact->data;
bool normalup = (stAct->flag & ACT_STEERING_NORMALUP) !=0;
bool lockzvel = (stAct->flag & ACT_STEERING_LOCKZVEL) !=0;
KX_SteeringActuator *tmpstact
- = new KX_SteeringActuator(gameobj, mode, targetob, navmeshob,stAct->dist,
- stAct->velocity, stAct->acceleration, stAct->turnspeed,
+ = new KX_SteeringActuator(gameobj, mode, targetob, navmeshob,stAct->dist,
+ stAct->velocity, stAct->acceleration, stAct->turnspeed,
selfTerminated, stAct->updateTime,
scene->GetObstacleSimulation(), facingMode, normalup, enableVisualization, lockzvel);
baseact = tmpstact;
default:
; /* generate some error */
}
-
+
if (baseact && !(bact->flag & ACT_DEACTIVATE))
{
baseact->SetExecutePriority(executePriority++);
baseact->SetLogicManager(logicmgr);
//gameobj->SetProperty(uniquename,baseact);
gameobj->AddActuator(baseact);
-
+
converter->RegisterGameActuator(baseact, bact);
// done with baseact, release it
baseact->Release();
}
else if (baseact)
baseact->Release();
-
+
bact = bact->next;
}
}
// When libloading, this is delayed to KX_Scene::MergeScene_LogicBrick to avoid GIL issues
if (!libloading)
pyctrl->SetNamespace(converter->GetPyNamespace());
-
+
if (pycont->mode==SCA_PythonController::SCA_PYEXEC_SCRIPT) {
if (pycont->text)
{
pyctrl->SetScriptName(pycont->text->id.name+2);
MEM_freeN(buf);
}
-
+
}
}
else {
/* let the controller print any warnings here when importing */
- pyctrl->SetScriptText(STR_String(pycont->module));
+ pyctrl->SetScriptText(STR_String(pycont->module));
pyctrl->SetScriptName(pycont->module); /* will be something like module.func so using it as the name is OK */
if (pycont->flag & CONT_PY_DEBUG) {
}
default:
{
-
+
}
}
gamecontroller->SetName(bcontr->name);
gamecontroller->SetLogicManager(logicmgr);
gameobj->AddController(gamecontroller);
-
+
converter->RegisterGameController(gamecontroller, bcontr);
#ifdef WITH_PYTHON
/* We cant do this because importing runs the script which could end up accessing
* internal BGE functions, this is unstable while we're converting the scene.
* This is a pity because its useful to see errors at startup but cant help it */
-
+
// pyctrl->Import();
}
}
}
else if (gamecontroller)
gamecontroller->Release();
-
+
bcontr = bcontr->next;
}
class KX_GameObject* gameobj,
class SCA_LogicManager* logicmgr,
int activeLayerBitInfo,
- bool isInActiveLayer,
+ bool isInActiveLayer,
class KX_BlenderSceneConverter* converter,
bool libloading
);
void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventManager* timemgr,SCA_IScene* scene, bool isInActiveLayer)
{
-
+
bProperty* prop = (bProperty*)object->prop.first;
CValue* propval;
bool show_debug_info;
float floatprop = *((float*)&prop->data);
CValue* timeval = new CFloatValue(floatprop);
- // set a subproperty called 'timer' so that
- // we can register the replica of this property
+ // set a subproperty called 'timer' so that
+ // we can register the replica of this property
// at the time a game object is replicated (AddObjectActuator triggers this)
CValue *bval = new CBoolValue(true);
timeval->SetProperty("timer",bval);
{
timemgr->AddTimeProperty(timeval);
}
-
+
propval = timeval;
gameobj->SetProperty(prop->name,timeval);
// todo make an assert etc.
}
}
-
+
if (propval)
{
if (show_debug_info && isInActiveLayer)
// done with propval, release it
propval->Release();
}
-
+
#ifdef WITH_PYTHON
/* Warn if we double up on attributes, this isn't quite right since it wont find inherited attributes however there arnt many */
for (PyAttributeDef *attrdef = KX_GameObject::Attributes; attrdef->m_name; attrdef++) {
bool invert = false;
bool level = false;
bool tap = false;
-
+
while (sens)
{
sens = sens->next;
class KX_KetsjiEngine* kxengine,
int activeLayerBitInfo,
bool isInActiveLayer,
- class RAS_ICanvas* canvas,
+ class RAS_ICanvas* canvas,
class KX_BlenderSceneConverter* converter);
#endif /* __KX_CONVERTSENSORS_H__ */
#ifdef WITH_PYTHON
-PyMethodDef KX_LibLoadStatus::Methods[] =
+PyMethodDef KX_LibLoadStatus::Methods[] =
{
{NULL} //Sentinel
};
PyObject* KX_LibLoadStatus::pyattr_get_onfinish(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_LibLoadStatus* self = static_cast<KX_LibLoadStatus*>(self_v);
-
+
if (self->m_finish_cb) {
Py_INCREF(self->m_finish_cb);
return self->m_finish_cb;
PyObject* KX_LibLoadStatus::pyattr_get_onprogress(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
KX_LibLoadStatus* self = static_cast<KX_LibLoadStatus*>(self_v);
-
+
if (self->m_progress_cb) {
Py_INCREF(self->m_progress_cb);
return self->m_progress_cb;
slot = *mmat->m_slots[(void*)m_gameobj];
// for each array
- for (slot->begin(it); !slot->end(it); slot->next(it))
+ for (slot->begin(it); !slot->end(it); slot->next(it))
{
btSoftBody::tNodeArray& nodes(softBody->m_nodes);
}
virtual bool UpdateBuckets(void)
{
- // this is to update the mesh slots outside the rasterizer,
+ // this is to update the mesh slots outside the rasterizer,
// no need to do it for this deformer, it's done in any case in Apply()
return false;
}
* Is used by parser when an expression tree is build containing booleans.
*/
-class CBoolValue : public CPropValue
+class CBoolValue : public CPropValue
{
//PLUGIN_DECLARE_SERIAL(CBoolValue,CValue)
virtual int GetValueType();
bool GetBool();
virtual void SetValue(CValue* newval);
-
+
virtual CValue* Calc(VALUE_OPERATOR op, CValue *val);
virtual CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
-
+
void Configure(CValue* menuvalue);
virtual CValue* GetReplica();
#ifdef WITH_PYTHON
#include "EXP_Expression.h"
#include "EXP_Value.h" // Added by ClassView
-class CConstExpr : public CExpression
+class CConstExpr : public CExpression
{
//PLUGIN_DECLARE_SERIAL_EXPRESSION (CConstExpr,CExpression)
public:
virtual bool MergeExpression(CExpression* otherexpr);
-
+
void BroadcastOperators(VALUE_OPERATOR op);
virtual unsigned char GetExpressionID();
CConstExpr(CValue* constval);
CConstExpr();
virtual ~CConstExpr();
-
+
private:
CValue* m_value;
class CListValue;
-class CEmptyValue : public CPropValue
+class CEmptyValue : public CPropValue
{
//PLUGIN_DECLARE_SERIAL (CEmptyValue,CValue)
public:
#include "EXP_Value.h"
-class CErrorValue : public CPropValue
+class CErrorValue : public CPropValue
{
public:
CBrokenLinkInfo(CExpression** pmemexpr,CExpression* expr)
:m_pmemExpr(pmemexpr),
m_pExpr(expr)
- {
+ {
assertd(pmemexpr);
m_bRestored=false;
};
virtual ~CBrokenLinkInfo();
void RestoreLink();
void BreakLink();
-
-
+
+
// members vars
private:
CExpression** m_pmemExpr;
CExpression* m_pExpr;
bool m_bRestored;
-
-
+
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:CBrokenLinkInfo")
#endif
-class CExpression
+class CExpression
{
public:
enum {
virtual bool MergeExpression(CExpression* otherexpr) = 0;
CExpression();
-
+
virtual CValue* Calculate() = 0; //pure virtual
virtual unsigned char GetExpressionID() = 0;
//virtual bool IsInside(float x,float y,float z,bool bBorderInclude=true) = 0; //pure virtual
//gRefCountExpr++;
&nb