本文整理汇总了C++中NiNodeRef::GetLocalTranslation方法的典型用法代码示例。如果您正苦于以下问题:C++ NiNodeRef::GetLocalTranslation方法的具体用法?C++ NiNodeRef::GetLocalTranslation怎么用?C++ NiNodeRef::GetLocalTranslation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NiNodeRef
的用法示例。
在下文中一共展示了NiNodeRef::GetLocalTranslation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalcLength
static float CalcLength(NiNodeRef node, vector<NiAVObjectRef>& children)
{
bool hasChildren = !children.empty();
float len = 0.0f;
if (hasChildren) {
for (vector<NiAVObjectRef>::iterator itr=children.begin(), end = children.end(); itr != end; ++itr) {
len += GetObjectLength(*itr);
}
len /= float(children.size());
}
else
{
len = node->GetLocalTranslation().Magnitude();
}
return len;
}
示例2: convertNiNode
NiNodeRef NifConvertUtility::convertNiNode(NiNodeRef pSrcNode, NiTriShapeRef pTmplNode, NiNodeRef pRootNode, NiAlphaPropertyRef pTmplAlphaProp)
{
NiNodeRef pDstNode (pSrcNode);
//pDstNode->SetName(pDstNode->GetName().replace(
string node_name_in = pDstNode->GetName();
string node_name_out = "";
for (int i = 0; i < node_name_in.length(); i++)
{
if (node_name_in[i] != '.' && node_name_in[i] != '_' && node_name_in[i] != ' ')
{
node_name_out = node_name_out + node_name_in[i];
}
}
pDstNode->SetName(node_name_out);
node_name_in = node_name_out;
if (node_name_in.compare("AttachLight") == 0)
{
Vector3 tr = pDstNode->GetLocalTranslation();
tr.z += 10.0f;
pDstNode->SetLocalTranslation(tr);
}
if (node_name_in.compare("ShadowBox") == 0)
{
cout << "Removing ShadowBox" << endl;
pDstNode->ClearChildren();
}
if (toLower(node_name_in).find("fireemit") != -1)
{
NiExtraDataRef ed = root_bsafade->GetExtraData().front();
NiIntegerExtraDataRef iref = DynamicCast<NiIntegerExtraData>(ed);
iref->SetData(147);
cout << "Adding TorchFlame Addon" << endl;
BSValueNodeRef candle_flame = new BSValueNode();
candle_flame->SetName("AddOnNode");
candle_flame->value = 46;
pDstNode->AddChild(DynamicCast<NiAVObject>(candle_flame));
}
else if (node_name_in.find("CandleFlame") != -1)
{
NiExtraDataRef ed = root_bsafade->GetExtraData().front();
NiIntegerExtraDataRef iref = DynamicCast<NiIntegerExtraData>(ed);
iref->SetData(147);
cout << "Adding CandleFlame Addon" << endl;
BSValueNodeRef candle_flame = new BSValueNode();
candle_flame->SetName("AddOnNode");
candle_flame->value = 49;
pDstNode->AddChild(DynamicCast<NiAVObject>(candle_flame));
}
vector<NiAVObjectRef> srcShapeList(pDstNode->GetChildren());
//if (!pDstNode->GetType().IsSameType(NiNode::TYPE) && !pDstNode->GetType().IsSameType(BSFadeNode::TYPE) && !pDstNode->GetType().IsSameType(NiTriShape::TYPE) && !pDstNode->GetType().IsSameType(NiTriStrips::TYPE))
{
}
// find NiAlphaProperty and use as template in sub-nodes
if (DynamicCast<NiAlphaProperty>(pDstNode->GetPropertyByType(NiAlphaProperty::TYPE)) != NULL)
{
pTmplAlphaProp = DynamicCast<NiAlphaProperty>(pDstNode->GetPropertyByType(NiAlphaProperty::TYPE));
}
// unlink protperties -> not used in new format
pDstNode->ClearProperties();
// shift extra data to new version
pDstNode->ShiftExtraData(VER_20_2_0_7);
// unlink children
pDstNode->ClearChildren();
pDstNode->ClearEffects();
pDstNode->ClearControllers();
if (!pDstNode->GetType().IsSameType(BSFadeNode::TYPE))
{
pDstNode->ClearExtraData();
}
// iterate over source nodes and convert using template
for (auto ppIter=srcShapeList.begin(), pEnd=srcShapeList.end(); ppIter != pEnd; ppIter++)
{
//DynamicCast<NiTriShape>(*ppIter) == NULL && DynamicCast<NiTriStrips>(*ppIter) == NULL ** DynamicCast<NiTriStrips>(*ppIter) != NULL
//.........这里部分代码省略.........
示例3: ImportBones
void NifImporter::ImportBones(NiNodeRef node, bool recurse)
{
try
{
if (uncontrolledDummies)
BuildControllerRefList(node, ctrlCount);
string name = node->GetName();
vector<NiAVObjectRef> children = node->GetChildren();
vector<NiNodeRef> childNodes = DynamicCast<NiNode>(children);
NiAVObject::CollisionType cType = node->GetCollisionMode();
if (children.empty() && name == "Bounding Box")
return;
// Do all node manipulations here
NiNodeRef parent = node->GetParent();
string parentname = (parent ? parent->GetName() : "");
Matrix44 m4 = node->GetWorldTransform();
// Check for Prn strings and change parent if necessary
if (supportPrnStrings) {
list<NiStringExtraDataRef> strings = DynamicCast<NiStringExtraData>(node->GetExtraData());
for (list<NiStringExtraDataRef>::iterator itr = strings.begin(); itr != strings.end(); ++itr){
if (strmatch((*itr)->GetName(), "Prn")) {
parentname = (*itr)->GetData();
if (INode *pn = gi->GetINodeByName(parentname.c_str())){
// Apparently Heads tend to need to be rotated 90 degrees on import for
if (!rotate90Degrees.empty() && wildmatch(rotate90Degrees, parentname)) {
m4 *= TOMATRIX4(RotateYMatrix(TORAD(90)));
}
m4 *= TOMATRIX4(pn->GetObjTMAfterWSM(0, NULL));
}
}
}
}
float len = node->GetLocalTranslation().Magnitude();
// Remove NonAccum nodes and merge into primary bone
if (mergeNonAccum && wildmatch("* NonAccum", name) && parent)
{
string realname = name.substr(0, name.length() - 9);
if (strmatch(realname, parent->GetName()))
{
Matrix44 tm = parent->GetLocalTransform() * node->GetLocalTransform();
name = realname;
len += tm.GetTranslation().Magnitude();
parent = parent->GetParent();
}
}
PosRotScale prs = prsDefault;
Vector3 pos; Matrix33 rot; float scale;
m4.Decompose(pos, rot, scale);
Matrix3 im = TOMATRIX3(m4);
Point3 p = im.GetTrans();
Quat q(im);
//q.Normalize();
Vector3 ppos;
Point3 zAxis(0,0,0);
bool hasChildren = !children.empty();
if (hasChildren) {
float len = 0.0f;
for (vector<NiAVObjectRef>::iterator itr=children.begin(), end = children.end(); itr != end; ++itr) {
len += GetObjectLength(*itr);
}
len /= float(children.size());
ppos = pos + Vector3(len, 0.0f, 0.0f); // just really need magnitude as rotation will take care of positioning
}
else if (parent)
{
ppos = pos + Vector3(len/3.0f, 0.0f, 0.0f);
}
Point3 pp(ppos.x, ppos.y, ppos.z);
Point3 qp = TORAD(TOEULER(im));
INode *bone = NULL;
if (!doNotReuseExistingBones) // Games like BC3 reuse the same bone names
{
bone = FindNode(node);
if (bone == NULL)
bone = gi->GetINodeByName(name.c_str());
}
if (bone)
{
// Is there a better way of "Affect Pivot Only" behaviors?
INode *pinode = bone->GetParentNode();
if (pinode)
bone->Detach(0,1);
PosRotScaleNode(bone, p, q, scale, prs);
if (pinode)
pinode->AttachChild(bone, 1);
}
else
{
//.........这里部分代码省略.........