本文整理汇总了C++中BL_ArmatureObject类的典型用法代码示例。如果您正苦于以下问题:C++ BL_ArmatureObject类的具体用法?C++ BL_ArmatureObject怎么用?C++ BL_ArmatureObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BL_ArmatureObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindConstraint
void KX_ArmatureSensor::FindConstraint()
{
m_constraint = NULL;
if (m_gameobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE) {
BL_ArmatureObject* armobj = (BL_ArmatureObject*)m_gameobj;
// get the persistent pose structure
bPose* pose = armobj->GetOrigPose();
bPoseChannel* pchan;
bConstraint* pcon;
// and locate the constraint
for (pchan = (bPoseChannel*)pose->chanbase.first; pchan; pchan=(bPoseChannel*)pchan->next) {
if (pchan->name == m_posechannel) {
// now locate the constraint
for (pcon = (bConstraint *)pchan->constraints.first; pcon; pcon = (bConstraint *)pcon->next) {
if (pcon->name == m_constraintname) {
if (pcon->flag & CONSTRAINT_DISABLE)
/* this constraint is not valid, can't use it */
break;
m_constraint = pcon;
break;
}
}
break;
}
}
}
}
示例2: FindConstraint
void BL_ArmatureActuator::FindConstraint()
{
m_constraint = NULL;
if (m_gameobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE) {
BL_ArmatureObject* armobj = (BL_ArmatureObject*)m_gameobj;
m_constraint = armobj->GetConstraint(m_posechannel, m_constraintname);
}
}
示例3:
PyObject *KX_ArmatureSensor::pyattr_get_constraint(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
{
KX_ArmatureSensor* sensor = static_cast<KX_ArmatureSensor*>(self);
if (sensor->m_gameobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE) {
BL_ArmatureObject* armobj = (BL_ArmatureObject*)sensor->m_gameobj;
BL_ArmatureConstraint* constraint = armobj->GetConstraint(sensor->m_posechannel, sensor->m_constraintname);
if (constraint)
return constraint->GetProxy();
}
Py_RETURN_NONE;
}
示例4: CListWrapper
PyObject *BL_ArmatureObject::pyattr_get_channels(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
BL_ArmatureObject *self = static_cast<BL_ArmatureObject *>(self_v);
self->LoadChannels(); // make sure we have the channels
return (new CListWrapper(self_v,
self->GetProxy(),
NULL,
bl_armature_object_get_channels_size_cb,
bl_armature_object_get_channels_item_cb,
bl_armature_object_get_channels_item_name_cb,
NULL))->NewProxy(true);
}
示例5: _PyUnicode_AsString
PyObject* BL_ActionActuator::PyGetChannel(PyObject* value) {
char *string= _PyUnicode_AsString(value);
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 */
}
// get_pose_channel accounts for NULL pose, run on both incase one exists but
// the channel doesnt
if( !(pchan=get_pose_channel(m_userpose, string)) &&
!(pchan=get_pose_channel(m_pose, string)) )
{
PyErr_SetString(PyExc_ValueError, "channel doesnt exist");
return NULL;
}
PyObject *ret = PyTuple_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]));
PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->quat[2]));
PyList_SET_ITEM(list, 3, PyFloat_FromDouble(pchan->quat[3]));
PyTuple_SET_ITEM(ret, 2, list);
return ret;
/*
return Py_BuildValue("([fff][fff][ffff])",
pchan->loc[0], pchan->loc[1], pchan->loc[2],
pchan->size[0], pchan->size[1], pchan->size[2],
pchan->quat[0], pchan->quat[1], pchan->quat[2], pchan->quat[3] );
*/
}
示例6: m_action
BL_Action::BL_Action(class KX_GameObject* gameobj)
:
m_action(NULL),
m_pose(NULL),
m_blendpose(NULL),
m_blendinpose(NULL),
m_ptrrna(NULL),
m_obj(gameobj),
m_startframe(0.f),
m_endframe(0.f),
m_endtime(0.f),
m_localtime(0.f),
m_blendin(0.f),
m_blendframe(0.f),
m_blendstart(0.f),
m_speed(0.f),
m_priority(0),
m_playmode(0),
m_ipo_flags(0),
m_done(true),
m_calc_localtime(true)
{
if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
{
BL_ArmatureObject *obj = (BL_ArmatureObject*)m_obj;
m_ptrrna = new PointerRNA();
RNA_id_pointer_create(&obj->GetArmatureObject()->id, m_ptrrna);
}
else
{
BL_DeformableGameObject *obj = (BL_DeformableGameObject*)m_obj;
BL_ShapeDeformer *shape_deformer = dynamic_cast<BL_ShapeDeformer*>(obj->GetDeformer());
if (shape_deformer)
{
m_ptrrna = new PointerRNA();
RNA_id_pointer_create(&shape_deformer->GetKey()->id, m_ptrrna);
}
}
}
示例7: IsNegativeEvent
bool BL_ArmatureActuator::Update(double curtime, bool frame)
{
// the only role of this actuator is to ensure that the armature pose will be evaluated
bool result = false;
bool bNegativeEvent = IsNegativeEvent();
RemoveAllEvents();
if (!bNegativeEvent) {
BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
switch (m_type) {
case ACT_ARM_RUN:
result = true;
obj->UpdateTimestep(curtime);
break;
case ACT_ARM_ENABLE:
if (m_constraint)
m_constraint->ClrConstraintFlag(CONSTRAINT_OFF);
break;
case ACT_ARM_DISABLE:
if (m_constraint)
m_constraint->SetConstraintFlag(CONSTRAINT_OFF);
break;
case ACT_ARM_SETTARGET:
if (m_constraint) {
m_constraint->SetTarget(m_gametarget);
m_constraint->SetSubtarget(m_gamesubtarget);
}
break;
case ACT_ARM_SETWEIGHT:
if (m_constraint)
m_constraint->SetWeight(m_weight);
break;
case ACT_ARM_SETINFLUENCE:
if (m_constraint)
m_constraint->SetInfluence(m_influence);
break;
}
}
return result;
}
示例8: SetLocalTime
void BL_Action::Update(float curtime)
{
// Don't bother if we're done with the animation
if (m_done)
return;
curtime -= KX_KetsjiEngine::GetSuspendedDelta();
// Grab the start time here so we don't end up with a negative m_localtime when
// suspending and resuming scenes.
if (m_starttime < 0)
m_starttime = curtime;
if (m_calc_localtime)
SetLocalTime(curtime);
else
{
ResetStartTime(curtime);
m_calc_localtime = true;
}
// Handle wrap around
if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe)) {
switch (m_playmode) {
case ACT_MODE_PLAY:
// Clamp
m_localtime = m_endframe;
m_done = true;
break;
case ACT_MODE_LOOP:
// Put the time back to the beginning
m_localtime = m_startframe;
m_starttime = curtime;
break;
case ACT_MODE_PING_PONG:
// Swap the start and end frames
float temp = m_startframe;
m_startframe = m_endframe;
m_endframe = temp;
m_starttime = curtime;
break;
}
}
if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
{
BL_ArmatureObject *obj = (BL_ArmatureObject*)m_obj;
obj->GetPose(&m_pose);
// Extract the pose from the action
{
Object *arm = obj->GetArmatureObject();
bPose *temp = arm->pose;
arm->pose = m_pose;
animsys_evaluate_action(m_ptrrna, m_action, NULL, m_localtime);
arm->pose = temp;
}
// Handle blending between armature actions
if (m_blendin && m_blendframe<m_blendin)
{
IncrementBlending(curtime);
// Calculate weight
float weight = 1.f - (m_blendframe/m_blendin);
// Blend the poses
game_blend_poses(m_pose, m_blendinpose, weight);
}
// Handle layer blending
if (m_layer_weight >= 0)
{
obj->GetMRDPose(&m_blendpose);
game_blend_poses(m_pose, m_blendpose, m_layer_weight);
}
obj->SetPose(m_pose);
obj->SetActiveAction(NULL, 0, curtime);
}
else
{
BL_DeformableGameObject *obj = (BL_DeformableGameObject*)m_obj;
BL_ShapeDeformer *shape_deformer = dynamic_cast<BL_ShapeDeformer*>(obj->GetDeformer());
// Handle shape actions if we have any
if (shape_deformer && shape_deformer->GetKey())
{
Key *key = shape_deformer->GetKey();
animsys_evaluate_action(m_ptrrna, m_action, NULL, m_localtime);
// Handle blending between shape actions
//.........这里部分代码省略.........
示例9: printf
bool BL_Action::Play(const char* name,
float start,
float end,
short priority,
float blendin,
short play_mode,
float layer_weight,
short ipo_flags,
float playback_speed)
{
// Only start playing a new action if we're done, or if
// the new action has a higher priority
if (!IsDone() && priority > m_priority)
return false;
m_priority = priority;
bAction* prev_action = m_action;
// First try to load the action
m_action = (bAction*)KX_GetActiveScene()->GetLogicManager()->GetActionByName(name);
if (!m_action)
{
printf("Failed to load action: %s\n", name);
m_done = true;
return false;
}
// If we have the same settings, don't play again
// This is to resolve potential issues with pulses on sensors such as the ones
// reported in bug #29412. The fix is here so it works for both logic bricks and Python.
// However, this may eventually lead to issues where a user wants to override an already
// playing action with the same action and settings. If this becomes an issue,
// then this fix may have to be re-evaluated.
if (!IsDone() && m_action == prev_action && m_startframe == start && m_endframe == end
&& m_priority == priority && m_speed == playback_speed)
return false;
if (prev_action != m_action)
{
// First get rid of any old controllers
ClearControllerList();
// Create an SG_Controller
SG_Controller *sg_contr = BL_CreateIPO(m_action, m_obj, KX_GetActiveScene()->GetSceneConverter());
m_sg_contr_list.push_back(sg_contr);
m_obj->GetSGNode()->AddSGController(sg_contr);
sg_contr->SetObject(m_obj->GetSGNode());
// Extra controllers
if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_LIGHT)
{
sg_contr = BL_CreateLampIPO(m_action, m_obj, KX_GetActiveScene()->GetSceneConverter());
m_sg_contr_list.push_back(sg_contr);
m_obj->GetSGNode()->AddSGController(sg_contr);
sg_contr->SetObject(m_obj->GetSGNode());
}
else if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_CAMERA)
{
sg_contr = BL_CreateCameraIPO(m_action, m_obj, KX_GetActiveScene()->GetSceneConverter());
m_sg_contr_list.push_back(sg_contr);
m_obj->GetSGNode()->AddSGController(sg_contr);
sg_contr->SetObject(m_obj->GetSGNode());
}
}
m_ipo_flags = ipo_flags;
InitIPO();
// Setup blendin shapes/poses
if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
{
BL_ArmatureObject *obj = (BL_ArmatureObject*)m_obj;
obj->GetMRDPose(&m_blendinpose);
}
else
{
BL_DeformableGameObject *obj = (BL_DeformableGameObject*)m_obj;
BL_ShapeDeformer *shape_deformer = dynamic_cast<BL_ShapeDeformer*>(obj->GetDeformer());
if (shape_deformer && shape_deformer->GetKey())
{
obj->GetShape(m_blendinshape);
// Now that we have the previous blend shape saved, we can clear out the key to avoid any
// further interference.
KeyBlock *kb;
for (kb=(KeyBlock*)shape_deformer->GetKey()->block.first; kb; kb=(KeyBlock*)kb->next)
kb->curval = 0.f;
}
}
// Now that we have an action, we have something we can play
m_starttime = -1.f; // We get the start time on our first update
m_startframe = m_localtime = start;
m_endframe = end;
m_blendin = blendin;
m_playmode = play_mode;
m_endtime = 0.f;
m_blendframe = 0.f;
m_blendstart = 0.f;
//.........这里部分代码省略.........
示例10: printf
bool BL_Action::Play(const char* name,
float start,
float end,
short priority,
float blendin,
short play_mode,
float layer_weight,
short ipo_flags,
float playback_speed)
{
// Only start playing a new action if we're done, or if
// the new action has a higher priority
if (priority != 0 && !IsDone() && priority >= m_priority)
return false;
m_priority = priority;
bAction* prev_action = m_action;
// First try to load the action
m_action = (bAction*)KX_GetActiveScene()->GetLogicManager()->GetActionByName(name);
if (!m_action)
{
printf("Failed to load action: %s\n", name);
m_done = true;
return false;
}
if (prev_action != m_action)
{
// First get rid of any old controllers
ClearControllerList();
// Create an SG_Controller
SG_Controller *sg_contr = BL_CreateIPO(m_action, m_obj, KX_GetActiveScene()->GetSceneConverter());
m_sg_contr_list.push_back(sg_contr);
m_obj->GetSGNode()->AddSGController(sg_contr);
sg_contr->SetObject(m_obj->GetSGNode());
// Extra controllers
if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_LIGHT)
{
sg_contr = BL_CreateLampIPO(m_action, m_obj, KX_GetActiveScene()->GetSceneConverter());
m_sg_contr_list.push_back(sg_contr);
m_obj->GetSGNode()->AddSGController(sg_contr);
sg_contr->SetObject(m_obj->GetSGNode());
}
else if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_CAMERA)
{
sg_contr = BL_CreateCameraIPO(m_action, m_obj, KX_GetActiveScene()->GetSceneConverter());
m_sg_contr_list.push_back(sg_contr);
m_obj->GetSGNode()->AddSGController(sg_contr);
sg_contr->SetObject(m_obj->GetSGNode());
}
}
m_ipo_flags = ipo_flags;
InitIPO();
// Setup blendin shapes/poses
if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
{
BL_ArmatureObject *obj = (BL_ArmatureObject*)m_obj;
obj->GetMRDPose(&m_blendinpose);
}
else
{
BL_DeformableGameObject *obj = (BL_DeformableGameObject*)m_obj;
BL_ShapeDeformer *shape_deformer = dynamic_cast<BL_ShapeDeformer*>(obj->GetDeformer());
if (shape_deformer && shape_deformer->GetKey())
{
obj->GetShape(m_blendinshape);
// Now that we have the previous blend shape saved, we can clear out the key to avoid any
// further interference.
KeyBlock *kb;
for (kb=(KeyBlock*)shape_deformer->GetKey()->block.first; kb; kb=(KeyBlock*)kb->next)
kb->curval = 0.f;
}
}
// Now that we have an action, we have something we can play
m_starttime = KX_GetActiveEngine()->GetFrameTime();
m_startframe = m_localtime = start;
m_endframe = end;
m_blendin = blendin;
m_playmode = play_mode;
m_endtime = 0.f;
m_blendframe = 0.f;
m_blendstart = 0.f;
m_speed = playback_speed;
m_layer_weight = layer_weight;
m_done = false;
return true;
}
示例11: PyErr_SetString
PyObject* BL_ActionActuator::PyGetChannel(PyObject* value)
{
PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.getChannel() no longer works, please use BL_ArmatureObject.channels instead");
return NULL;
#if 0 // XXX To be removed in a later version (first removed in 2.64)
const char *string= _PyUnicode_AsString(value);
if (GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE)
{
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)) &&
!(pchan=BKE_pose_channel_find_name(m_pose, string)) )
{
PyErr_SetString(PyExc_ValueError, "channel doesnt exist");
return NULL;
}
PyObject *ret = PyTuple_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]));
PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->quat[2]));
PyList_SET_ITEM(list, 3, PyFloat_FromDouble(pchan->quat[3]));
PyTuple_SET_ITEM(ret, 2, list);
return ret;
#if 0
return Py_BuildValue("([fff][fff][ffff])",
pchan->loc[0], pchan->loc[1], pchan->loc[2],
pchan->size[0], pchan->size[1], pchan->size[2],
pchan->quat[0], pchan->quat[1], pchan->quat[2], pchan->quat[3] );
#endif
#endif
}
示例12: UpdateChildCoordinates
bool
KX_BoneParentRelation::
UpdateChildCoordinates(
SG_Spatial * child,
const SG_Spatial * parent,
bool& parentUpdated
) {
MT_assert(child != NULL);
// This way of accessing child coordinates is a bit cumbersome
// be nice to have non constant reference access to these values.
const MT_Vector3 & child_scale = child->GetLocalScale();
const MT_Point3 & child_pos = child->GetLocalPosition();
const MT_Matrix3x3 & child_rotation = child->GetLocalOrientation();
// we don't know if the armature has been updated or not, assume yes
parentUpdated = true;
// the childs world locations which we will update.
MT_Vector3 child_w_scale;
MT_Point3 child_w_pos;
MT_Matrix3x3 child_w_rotation;
bool valid_parent_transform = false;
if (parent)
{
BL_ArmatureObject *armature = (BL_ArmatureObject*)(parent->GetSGClientObject());
if (armature)
{
MT_Matrix4x4 parent_matrix;
if (armature->GetBoneMatrix(m_bone, parent_matrix))
{
// Get the child's transform, and the bone matrix.
MT_Matrix4x4 child_transform (
MT_Transform(child_pos + MT_Vector3(0.0f, armature->GetBoneLength(m_bone), 0.0f),
child_rotation.scaled(
child_scale[0],
child_scale[1],
child_scale[2])));
// The child's world transform is parent * child
parent_matrix = parent->GetWorldTransform() * parent_matrix;
child_transform = parent_matrix * child_transform;
// Recompute the child transform components from the transform.
child_w_scale.setValue(
MT_Vector3(child_transform[0][0], child_transform[0][1], child_transform[0][2]).length(),
MT_Vector3(child_transform[1][0], child_transform[1][1], child_transform[1][2]).length(),
MT_Vector3(child_transform[2][0], child_transform[2][1], child_transform[2][2]).length());
child_w_rotation.setValue(child_transform[0][0], child_transform[0][1], child_transform[0][2],
child_transform[1][0], child_transform[1][1], child_transform[1][2],
child_transform[2][0], child_transform[2][1], child_transform[2][2]);
child_w_rotation.scale(1.0f/child_w_scale[0], 1.0f/child_w_scale[1], 1.0f/child_w_scale[2]);
child_w_pos = MT_Point3(child_transform[0][3], child_transform[1][3], child_transform[2][3]);
valid_parent_transform = true;
}
}
}
if (valid_parent_transform)
{
child->SetWorldScale(child_w_scale);
child->SetWorldPosition(child_w_pos);
child->SetWorldOrientation(child_w_rotation);
}
else {
child->SetWorldFromLocalTransform();
}
child->ClearModified();
// this node must always be updated, so reschedule it for next time
child->ActivateRecheduleUpdateCallback();
return valid_parent_transform;
}
示例13: SetLocalTime
void BL_Action::Update(float curtime, bool applyToObject)
{
/* Don't bother if we're done with the animation and if the animation was already applied to the object.
* of if the animation made a double update for the same time and that it was applied to the object.
*/
if ((m_done && m_appliedToObject) || (m_prevUpdate == curtime && m_appliedToObject)) {
return;
}
m_prevUpdate = curtime;
curtime -= (float)KX_KetsjiEngine::GetSuspendedDelta();
if (m_calc_localtime)
SetLocalTime(curtime);
else
{
ResetStartTime(curtime);
m_calc_localtime = true;
}
// Handle wrap around
if (m_localframe < std::min(m_startframe, m_endframe) || m_localframe > std::max(m_startframe, m_endframe)) {
switch (m_playmode) {
case ACT_MODE_PLAY:
// Clamp
m_localframe = m_endframe;
m_done = true;
break;
case ACT_MODE_LOOP:
// Put the time back to the beginning
m_localframe = m_startframe;
m_starttime = curtime;
break;
case ACT_MODE_PING_PONG:
// Swap the start and end frames
float temp = m_startframe;
m_startframe = m_endframe;
m_endframe = temp;
m_starttime = curtime;
break;
}
}
m_appliedToObject = applyToObject;
// In case of culled armatures (doesn't requesting to transform the object) we only manages time.
if (!applyToObject) {
return;
}
if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
{
BL_ArmatureObject *obj = (BL_ArmatureObject*)m_obj;
if (m_layer_weight >= 0)
obj->GetPose(&m_blendpose);
// Extract the pose from the action
obj->SetPoseByAction(m_tmpaction, m_localframe);
// Handle blending between armature actions
if (m_blendin && m_blendframe<m_blendin)
{
IncrementBlending(curtime);
// Calculate weight
float weight = 1.f - (m_blendframe/m_blendin);
// Blend the poses
obj->BlendInPose(m_blendinpose, weight, ACT_BLEND_BLEND);
}
// Handle layer blending
if (m_layer_weight >= 0)
obj->BlendInPose(m_blendpose, m_layer_weight, m_blendmode);
obj->UpdateTimestep(curtime);
}
else
{
BL_DeformableGameObject *obj = (BL_DeformableGameObject*)m_obj;
BL_ShapeDeformer *shape_deformer = dynamic_cast<BL_ShapeDeformer*>(obj->GetDeformer());
// Handle shape actions if we have any
if (shape_deformer && shape_deformer->GetKey())
{
Key *key = shape_deformer->GetKey();
PointerRNA ptrrna;
RNA_id_pointer_create(&key->id, &ptrrna);
animsys_evaluate_action(&ptrrna, m_tmpaction, NULL, m_localframe);
// Handle blending between shape actions
if (m_blendin && m_blendframe < m_blendin)
{
IncrementBlending(curtime);
//.........这里部分代码省略.........
示例14: CM_Error
//.........这里部分代码省略.........
sg_contr->SetObject(m_obj->GetSGNode());
// World
sg_contr = BL_CreateWorldIPO(m_action, kxscene->GetBlenderScene()->world, kxscene->GetSceneConverter());
if (sg_contr) {
m_sg_contr_list.push_back(sg_contr);
m_obj->GetSGNode()->AddSGController(sg_contr);
sg_contr->SetObject(m_obj->GetSGNode());
}
// Try obcolor
sg_contr = BL_CreateObColorIPO(m_action, m_obj, kxscene->GetSceneConverter());
if (sg_contr) {
m_sg_contr_list.push_back(sg_contr);
m_obj->GetSGNode()->AddSGController(sg_contr);
sg_contr->SetObject(m_obj->GetSGNode());
}
// Now try materials
for (int matidx = 1; matidx <= m_obj->GetBlenderObject()->totcol; ++matidx) {
Material *mat = give_current_material(m_obj->GetBlenderObject(), matidx);
if (!mat) {
continue;
}
KX_BlenderSceneConverter *converter = kxscene->GetSceneConverter();
RAS_IPolyMaterial *polymat = converter->FindCachedPolyMaterial(kxscene, mat);
if (!polymat) {
continue;
}
sg_contr = BL_CreateMaterialIpo(m_action, mat, polymat, m_obj, converter);
if (sg_contr) {
m_sg_contr_list.push_back(sg_contr);
m_obj->GetSGNode()->AddSGController(sg_contr);
sg_contr->SetObject(m_obj->GetSGNode());
}
}
// Extra controllers
if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_LIGHT)
{
sg_contr = BL_CreateLampIPO(m_action, m_obj, kxscene->GetSceneConverter());
m_sg_contr_list.push_back(sg_contr);
m_obj->GetSGNode()->AddSGController(sg_contr);
sg_contr->SetObject(m_obj->GetSGNode());
}
else if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_CAMERA)
{
sg_contr = BL_CreateCameraIPO(m_action, m_obj, kxscene->GetSceneConverter());
m_sg_contr_list.push_back(sg_contr);
m_obj->GetSGNode()->AddSGController(sg_contr);
sg_contr->SetObject(m_obj->GetSGNode());
}
m_ipo_flags = ipo_flags;
InitIPO();
// Setup blendin shapes/poses
if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
{
BL_ArmatureObject *obj = (BL_ArmatureObject*)m_obj;
obj->GetPose(&m_blendinpose);
}
else
{
BL_DeformableGameObject *obj = (BL_DeformableGameObject*)m_obj;
BL_ShapeDeformer *shape_deformer = dynamic_cast<BL_ShapeDeformer*>(obj->GetDeformer());
if (shape_deformer && shape_deformer->GetKey())
{
obj->GetShape(m_blendinshape);
// Now that we have the previous blend shape saved, we can clear out the key to avoid any
// further interference.
KeyBlock *kb;
for (kb=(KeyBlock *)shape_deformer->GetKey()->block.first; kb; kb=(KeyBlock *)kb->next)
kb->curval = 0.f;
}
}
// Now that we have an action, we have something we can play
m_starttime = KX_GetActiveEngine()->GetFrameTime() - kxscene->getSuspendedDelta();
m_startframe = m_localframe = start;
m_endframe = end;
m_blendin = blendin;
m_playmode = play_mode;
m_blendmode = blend_mode;
m_blendframe = 0.f;
m_blendstart = 0.f;
m_speed = playback_speed;
m_layer_weight = layer_weight;
m_done = false;
m_appliedToObject = false;
m_prevUpdate = -1.0f;
return true;
}
示例15: BL_ArmatureObject
CValue* BL_ArmatureObject::GetReplica()
{
BL_ArmatureObject* replica = new BL_ArmatureObject(*this);
replica->ProcessReplica();
return replica;
}