本文整理汇总了C++中KX_GameObject::NodeSetLocalOrientation方法的典型用法代码示例。如果您正苦于以下问题:C++ KX_GameObject::NodeSetLocalOrientation方法的具体用法?C++ KX_GameObject::NodeSetLocalOrientation怎么用?C++ KX_GameObject::NodeSetLocalOrientation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KX_GameObject
的用法示例。
在下文中一共展示了KX_GameObject::NodeSetLocalOrientation方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
bool KX_TrackToActuator::Update(double curtime, bool frame)
{
bool result = false;
bool bNegativeEvent = IsNegativeEvent();
RemoveAllEvents();
if (bNegativeEvent)
{
// do nothing on negative events
}
else if (m_object)
{
KX_GameObject* curobj = (KX_GameObject*) GetParent();
MT_Vector3 dir = curobj->NodeGetWorldPosition() - ((KX_GameObject*)m_object)->NodeGetWorldPosition();
MT_Matrix3x3 mat;
MT_Matrix3x3 oldmat;
mat = vectomat(dir, m_trackflag, m_upflag, m_allow3D);
oldmat = curobj->NodeGetWorldOrientation();
/* erwin should rewrite this! */
mat = matrix3x3_interpol(oldmat, mat, m_time);
/* check if the model is parented and calculate the child transform */
if (m_parentobj) {
MT_Point3 localpos;
localpos = curobj->GetSGNode()->GetLocalPosition();
// Get the inverse of the parent matrix
MT_Matrix3x3 parentmatinv;
parentmatinv = m_parentobj->NodeGetWorldOrientation().inverse();
// transform the local coordinate system into the parents system
mat = parentmatinv * mat;
// append the initial parent local rotation matrix
mat = m_parentlocalmat * mat;
// set the models tranformation properties
curobj->NodeSetLocalOrientation(mat);
curobj->NodeSetLocalPosition(localpos);
//curobj->UpdateTransform();
}
else {
curobj->NodeSetLocalOrientation(mat);
}
result = true;
}
return result;
}
示例2:
void KX_BlenderSceneConverter::resetNoneDynamicObjectToIpo()
{
if (addInitFromFrame) {
KX_SceneList* scenes = m_ketsjiEngine->CurrentScenes();
int numScenes = scenes->size();
if (numScenes>=0) {
KX_Scene* scene = scenes->at(0);
CListValue* parentList = scene->GetRootParentList();
for (int ix=0;ix<parentList->GetCount();ix++) {
KX_GameObject* gameobj = (KX_GameObject*)parentList->GetValue(ix);
if (!gameobj->IsDynamic()) {
Object* blenderobject = gameobj->GetBlenderObject();
if (!blenderobject)
continue;
if (blenderobject->type==OB_ARMATURE)
continue;
float eu[3];
mat4_to_eul(eu,blenderobject->obmat);
MT_Point3 pos = MT_Point3(
blenderobject->obmat[3][0],
blenderobject->obmat[3][1],
blenderobject->obmat[3][2]
);
MT_Vector3 eulxyz = MT_Vector3(
eu[0],
eu[1],
eu[2]
);
MT_Vector3 scale = MT_Vector3(
blenderobject->size[0],
blenderobject->size[1],
blenderobject->size[2]
);
gameobj->NodeSetLocalPosition(pos);
gameobj->NodeSetLocalOrientation(MT_Matrix3x3(eulxyz));
gameobj->NodeSetLocalScale(scale);
gameobj->NodeUpdateGS(0);
}
}
}
}
}
示例3: HandleActorFace
void KX_SteeringActuator::HandleActorFace(MT_Vector3& velocity)
{
if (m_facingMode==0 && (!m_navmesh || !m_normalUp))
return;
KX_GameObject* curobj = (KX_GameObject*) GetParent();
MT_Vector3 dir = m_facingMode==0 ? curobj->NodeGetLocalOrientation().getColumn(1) : velocity;
if (dir.fuzzyZero())
return;
dir.normalize();
MT_Vector3 up(0,0,1);
MT_Vector3 left;
MT_Matrix3x3 mat;
if (m_navmesh && m_normalUp)
{
dtStatNavMesh* navmesh = m_navmesh->GetNavMesh();
MT_Vector3 normal;
MT_Vector3 trpos = m_navmesh->TransformToLocalCoords(curobj->NodeGetWorldPosition());
if (getNavmeshNormal(navmesh, trpos, normal))
{
left = (dir.cross(up)).safe_normalized();
dir = (-left.cross(normal)).safe_normalized();
up = normal;
}
}
switch (m_facingMode)
{
case 1: // TRACK X
{
left = dir.safe_normalized();
dir = -(left.cross(up)).safe_normalized();
break;
};
case 2: // TRACK Y
{
left = (dir.cross(up)).safe_normalized();
break;
}
case 3: // track Z
{
left = up.safe_normalized();
up = dir.safe_normalized();
dir = left;
left = (dir.cross(up)).safe_normalized();
break;
}
case 4: // TRACK -X
{
left = -dir.safe_normalized();
dir = -(left.cross(up)).safe_normalized();
break;
};
case 5: // TRACK -Y
{
left = (-dir.cross(up)).safe_normalized();
dir = -dir;
break;
}
case 6: // track -Z
{
left = up.safe_normalized();
up = -dir.safe_normalized();
dir = left;
left = (dir.cross(up)).safe_normalized();
break;
}
}
mat.setValue (
left[0], dir[0],up[0],
left[1], dir[1],up[1],
left[2], dir[2],up[2]
);
KX_GameObject* parentObject = curobj->GetParent();
if (parentObject)
{
MT_Vector3 localpos;
localpos = curobj->GetSGNode()->GetLocalPosition();
MT_Matrix3x3 parentmatinv;
parentmatinv = parentObject->NodeGetWorldOrientation ().inverse ();
mat = parentmatinv * mat;
mat = m_parentlocalmat * mat;
curobj->NodeSetLocalOrientation(mat);
curobj->NodeSetLocalPosition(localpos);
}
else
{
curobj->NodeSetLocalOrientation(mat);
}
}
示例4: Update
//.........这里部分代码省略.........
/* Y */
fp1[0] = actormat[0][1];
fp1[1] = actormat[1][1];
fp1[2] = actormat[2][1];
fp2[0] = frommat[0][1];
fp2[1] = frommat[1][1];
fp2[2] = frommat[2][1];
break;
case OB_NEGX:
/* -X */
fp1[0] = -actormat[0][0];
fp1[1] = -actormat[1][0];
fp1[2] = -actormat[2][0];
fp2[0] = frommat[0][0];
fp2[1] = frommat[1][0];
fp2[2] = frommat[2][0];
break;
case OB_NEGY:
/* -Y */
fp1[0] = -actormat[0][1];
fp1[1] = -actormat[1][1];
fp1[2] = -actormat[2][1];
fp2[0] = frommat[0][1];
fp2[1] = frommat[1][1];
fp2[2] = frommat[2][1];
break;
default:
assert(0);
break;
}
inp = fp1[0]*fp2[0] + fp1[1]*fp2[1] + fp1[2]*fp2[2];
fac = (-1.0f + inp) * m_damping;
from[0] += fac * fp1[0];
from[1] += fac * fp1[1];
from[2] += fac * fp1[2];
/* only for it lies: cross test and perpendicular bites up */
if (inp < 0.0f) {
/* Don't do anything if the cross product is too small.
* The camera up-axis becomes unstable and starts to oscillate.
* The 0.01f threshold is arbitrary but seems to work well in practice. */
float cross = fp1[0] * fp2[1] - fp1[1] * fp2[0];
if (cross > 0.01f) {
from[0] -= fac * fp1[1];
from[1] += fac * fp1[0];
}
else if (cross < -0.01f) {
from[0] += fac * fp1[1];
from[1] -= fac * fp1[0];
}
}
/* CONSTRAINT 5: minimum / maximum distance */
rc[0] = (lookat[0]-from[0]);
rc[1] = (lookat[1]-from[1]);
rc[2] = (lookat[2]-from[2]);
distsq = rc[0]*rc[0] + rc[1]*rc[1] + rc[2]*rc[2];
if (distsq > maxdistsq) {
distsq = 0.15f * (distsq - maxdistsq) / distsq;
from[0] += distsq*rc[0];
from[1] += distsq*rc[1];
from[2] += distsq*rc[2];
}
else if (distsq < mindistsq) {
distsq = 0.15f * (mindistsq - distsq) / mindistsq;
from[0] -= distsq*rc[0];
from[1] -= distsq*rc[1];
from[2] -= distsq*rc[2];
}
/* CONSTRAINT 7: track to floor below actor */
rc[0] = (lookat[0]-from[0]);
rc[1] = (lookat[1]-from[1]);
rc[2] = (lookat[2]-from[2]);
Kx_VecUpMat3(rc, mat, 3); /* y up Track -z */
/* now set the camera position and rotation */
obj->NodeSetLocalPosition(from);
actormat[0][0] = mat[0][0]; actormat[0][1] = mat[1][0]; actormat[0][2] = mat[2][0];
actormat[1][0] = mat[0][1]; actormat[1][1] = mat[1][1]; actormat[1][2] = mat[2][1];
actormat[2][0] = mat[0][2]; actormat[2][1] = mat[1][2]; actormat[2][2] = mat[2][2];
obj->NodeSetLocalOrientation(actormat);
return true;
}
示例5: Update
//.........这里部分代码省略.........
case 2: // track Z
{
left = up.safe_normalized();
up = dir.safe_normalized();
dir = left;
left = (dir.cross(up)).safe_normalized();
mat.setValue (
left[0], dir[0],up[0],
left[1], dir[1],up[1],
left[2], dir[2],up[2]
);
break;
}
case 3: // TRACK -X
{
// (1.0 , 0.0 , 0.0 ) x direction is forward, z (0.0 , 0.0 , 1.0 ) up
left = -dir.safe_normalized();
dir = -(left.cross(up)).safe_normalized();
mat.setValue (
left[0], dir[0],up[0],
left[1], dir[1],up[1],
left[2], dir[2],up[2]
);
break;
};
case 4: // TRACK -Y
{
// (0.0 , -1.0 , 0.0 ) -y direction is forward, z (0.0 , 0.0 , 1.0 ) up
left = (-dir.cross(up)).safe_normalized();
mat.setValue (
left[0], -dir[0],up[0],
left[1], -dir[1],up[1],
left[2], -dir[2],up[2]
);
break;
}
case 5: // track -Z
{
left = up.safe_normalized();
up = -dir.safe_normalized();
dir = left;
left = (dir.cross(up)).safe_normalized();
mat.setValue (
left[0], dir[0],up[0],
left[1], dir[1],up[1],
left[2], dir[2],up[2]
);
break;
}
default:
{
// (1.0 , 0.0 , 0.0 ) -x direction is forward, z (0.0 , 0.0 , 1.0 ) up
left = -dir.safe_normalized();
dir = -(left.cross(up)).safe_normalized();
mat.setValue (
left[0], dir[0],up[0],
left[1], dir[1],up[1],
left[2], dir[2],up[2]
);
}
}
MT_Matrix3x3 oldmat;
oldmat= curobj->NodeGetWorldOrientation();
/* erwin should rewrite this! */
mat= matrix3x3_interpol(oldmat, mat, m_time);
if(m_parentobj){ // check if the model is parented and calculate the child transform
MT_Point3 localpos;
localpos = curobj->GetSGNode()->GetLocalPosition();
// Get the inverse of the parent matrix
MT_Matrix3x3 parentmatinv;
parentmatinv = m_parentobj->NodeGetWorldOrientation ().inverse ();
// transform the local coordinate system into the parents system
mat = parentmatinv * mat;
// append the initial parent local rotation matrix
mat = m_parentlocalmat * mat;
// set the models tranformation properties
curobj->NodeSetLocalOrientation(mat);
curobj->NodeSetLocalPosition(localpos);
//curobj->UpdateTransform();
}
else
{
curobj->NodeSetLocalOrientation(mat);
}
result = true;
}
return result;
}
示例6: Update
//.........这里部分代码省略.........
/* rotation. We do not check whether we really have a camera as parent. */
/* It may be better to turn this into a general tracking actuator later */
/* on, since lots of plausible relations can be filled in here. */
/* ... set up some parameters ... */
/* missing here: the 'floorloc' of the actor's shadow */
mindistsq= m_minHeight*m_minHeight;
maxdistsq= m_maxHeight*m_maxHeight;
/* C1: not checked... is a future option */
/* C2: blender test_visibility function. Can this be a ray-test? */
/* C3: fixed height */
from[2] = (15.0*from[2] + lookat[2] + m_height)/16.0;
/* C4: camera behind actor */
if (m_x) {
fp1[0] = actormat[0][0];
fp1[1] = actormat[1][0];
fp1[2] = actormat[2][0];
fp2[0] = frommat[0][0];
fp2[1] = frommat[1][0];
fp2[2] = frommat[2][0];
}
else {
fp1[0] = actormat[0][1];
fp1[1] = actormat[1][1];
fp1[2] = actormat[2][1];
fp2[0] = frommat[0][1];
fp2[1] = frommat[1][1];
fp2[2] = frommat[2][1];
}
inp= fp1[0]*fp2[0] + fp1[1]*fp2[1] + fp1[2]*fp2[2];
fac= (-1.0 + inp) * m_damping;
from[0]+= fac*fp1[0];
from[1]+= fac*fp1[1];
from[2]+= fac*fp1[2];
/* alleen alstie ervoor ligt: cross testen en loodrechte bijtellen */
if(inp<0.0) {
if(fp1[0]*fp2[1] - fp1[1]*fp2[0] > 0.0) {
from[0]-= fac*fp1[1];
from[1]+= fac*fp1[0];
}
else {
from[0]+= fac*fp1[1];
from[1]-= fac*fp1[0];
}
}
/* CONSTRAINT 5: minimum / maximum afstand */
rc[0]= (lookat[0]-from[0]);
rc[1]= (lookat[1]-from[1]);
rc[2]= (lookat[2]-from[2]);
distsq= rc[0]*rc[0] + rc[1]*rc[1] + rc[2]*rc[2];
if(distsq > maxdistsq) {
distsq = 0.15*(distsq-maxdistsq)/distsq;
from[0] += distsq*rc[0];
from[1] += distsq*rc[1];
from[2] += distsq*rc[2];
}
else if(distsq < mindistsq) {
distsq = 0.15*(mindistsq-distsq)/mindistsq;
from[0] -= distsq*rc[0];
from[1] -= distsq*rc[1];
from[2] -= distsq*rc[2];
}
/* CONSTRAINT 7: track to schaduw */
rc[0]= (lookat[0]-from[0]);
rc[1]= (lookat[1]-from[1]);
rc[2]= (lookat[2]-from[2]);
Kx_VecUpMat3(rc, mat, 3); /* y up Track -z */
/* now set the camera position and rotation */
obj->NodeSetLocalPosition(from);
actormat[0][0]= mat[0][0]; actormat[0][1]= mat[1][0]; actormat[0][2]= mat[2][0];
actormat[1][0]= mat[0][1]; actormat[1][1]= mat[1][1]; actormat[1][2]= mat[2][1];
actormat[2][0]= mat[0][2]; actormat[2][1]= mat[1][2]; actormat[2][2]= mat[2][2];
obj->NodeSetLocalOrientation(actormat);
return true;
}