本文整理汇总了C++中IDerivedObject::ClearAFlag方法的典型用法代码示例。如果您正苦于以下问题:C++ IDerivedObject::ClearAFlag方法的具体用法?C++ IDerivedObject::ClearAFlag怎么用?C++ IDerivedObject::ClearAFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDerivedObject
的用法示例。
在下文中一共展示了IDerivedObject::ClearAFlag方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ImportHCTCapsule
INode* HavokImport::ImportHCTCapsule(bhkCapsuleShapeRef shape, INode *parent, INode *ragdollParent, Matrix3& tm)
{
USES_CONVERSION;
bhkShapeRef retval;
if (SimpleObject *obj = (SimpleObject *)ni.gi->CreateInstance(GEOMOBJECT_CLASS_ID, HK_TAPEREDCAPSULE_CLASS_ID)) {
if (IParamBlock2* pblock2 = obj->GetParamBlockByID(PB_TAPEREDCAPSULE_OBJ_PBLOCK))
{
float radius = shape->GetRadius();
int mtl = GetHavokIndexFromMaterials(ni.IsSkyrim() ? -1 : shape->GetMaterial(), ni.IsSkyrim() ? shape->GetSkyrimMaterial() : -1);
float radius1 = shape->GetRadius1() * ni.bhkScaleFactor;
float radius2 = shape->GetRadius2();
Vector3 pt1 = shape->GetFirstPoint();
Vector3 pt2 = shape->GetSecondPoint();
float len = (pt2 - pt1).Magnitude() * ni.bhkScaleFactor;
Point3 center = (TOPOINT3(pt2 + pt1) / 2.0f) * ni.bhkScaleFactor;
Point3 norm = Normalize(TOPOINT3(pt2 - pt1));
Matrix3 mat;
MatrixFromNormal(norm, mat);
pblock2->SetValue(PA_TAPEREDCAPSULE_OBJ_RADIUS, 0, radius1, 0);
pblock2->SetValue(PA_TAPEREDCAPSULE_OBJ_HEIGHT, 0, len, 0);
if (INode *n = ni.CreateImportRagdollNode(A2T(shape->GetType().GetTypeName().c_str()), obj, ragdollParent)) {
PosRotScale prs = prsDefault;
n->SetObjOffsetPos(parent->GetObjOffsetPos() + center);
n->SetObjOffsetRot(parent->GetObjOffsetRot()*mat);
Point3 pos = tm.GetTrans();
Quat rot(tm);
PosRotScaleNode(n, pos, rot, 1.0, prsDefault);
Object *pObj = n->GetObjectRef();
IDerivedObject *dobj = nullptr;
if (pObj->SuperClassID() == GEN_DERIVOB_CLASS_ID)
dobj = static_cast<IDerivedObject*>(pObj);
else {
dobj = CreateDerivedObject(pObj);
}
//Havok shape
Modifier* shapeMod = (Modifier*)CreateInstance(OSM_CLASS_ID, HK_SHAPE_MODIFIER_CLASS_ID);
if (IParamBlock2* shapeParameters = shapeMod->GetParamBlockByID(PB_SHAPE_MOD_PBLOCK)) {
shapeParameters->SetValue(PA_SHAPE_MOD_SHAPE_TYPE, 0, 2, 0);
}
dobj->SetAFlag(A_LOCK_TARGET);
dobj->AddModifier(shapeMod);
dobj->ClearAFlag(A_LOCK_TARGET);
n->SetObjectRef(dobj);
return n;
}
}
}
return ragdollParent;
#if 0
if (SimpleObject *ob = (SimpleObject *)ni.gi->CreateInstance(GEOMOBJECT_CLASS_ID, SCUBA_CLASS_ID)) {
float radius = shape->GetRadius();
float radius1 = shape->GetRadius1();
float radius2 = shape->GetRadius2();
Point3 pt1 = TOPOINT3(shape->GetFirstPoint());
Point3 pt2 = TOPOINT3(shape->GetSecondPoint());
float height = Length(pt1 - pt2);
int heighttype = 1;
RefTargetHandle t = ob->GetReference(0);
if (IParamBlock2* pblock2 = ob->GetParamBlockByID(0))
{
pblock2->SetValue(CAPSULE_RADIUS, 0, radius);
pblock2->SetValue(CAPSULE_HEIGHT, 0, height);
pblock2->SetValue(CAPSULE_CENTERS, 0, heighttype);
}
if (INode *n = ni.CreateImportNode(shape->GetType().GetTypeName().c_str(), ob, parent)) {
// Need to "Affect Pivot Only" and "Center to Object" first
//n->CenterPivot(0, FALSE);
// Need to reposition the Capsule so that caps are rotated correctly for pts given
int mtlIdx = GetHavokIndexFromMaterial(shape->GetMaterial());
int lyrIdx = GetHavokIndexFromLayer(OL_UNIDENTIFIED);
CreatebhkCollisionModifier(n, bv_type_capsule, mtlIdx, lyrIdx, 0);
ImportBase(body, shape, parent, n, tm);
AddShape(rbody, n);
return true;
}
}
return true;
#endif
}
示例2: ImportHCTSphere
INode* HavokImport::ImportHCTSphere(bhkSphereShapeRef shape, INode * parent, INode* ragdollParent, Matrix3 & tm)
{
USES_CONVERSION;
bhkShapeRef retval;
if (SimpleObject *obj = (SimpleObject *)ni.gi->CreateInstance(GEOMOBJECT_CLASS_ID, HK_TAPEREDCAPSULE_CLASS_ID)) {
if (IParamBlock2* pblock2 = obj->GetParamBlockByID(PB_TAPEREDCAPSULE_OBJ_PBLOCK))
{
float radius = shape->GetRadius();
int mtl = GetHavokIndexFromMaterials(ni.IsSkyrim() ? -1 : shape->GetMaterial(), ni.IsSkyrim() ? shape->GetSkyrimMaterial() : -1);
//float radius1 = shape->GetRadius1() * ni.bhkScaleFactor;
//float radius2 = shape->GetRadius2();
//Vector3 pt1 = shape->GetFirstPoint();
//Vector3 pt2 = shape->GetSecondPoint();
float len = radius * ni.bhkScaleFactor;
//Point3 center = (TOPOINT3(pt2 + pt1) / 2.0f) * ni.bhkScaleFactor;
//Point3 norm = Normalize(TOPOINT3(len));
//Matrix3 mat;
//MatrixFromNormal(norm, mat);
//Matrix3 newTM = tm * mat * TransMatrix(center);
pblock2->SetValue(PA_TAPEREDCAPSULE_OBJ_RADIUS, 0, len, 0);
// pblock2->SetValue(PA_TAPEREDCAPSULE_OBJ_HEIGHT, 0, 1.0, 0);
if (INode *n = ni.CreateImportNode(A2T(shape->GetType().GetTypeName().c_str()), obj, ragdollParent)) {
// ImportBase(body, shape, parent, n, newTM);
const int MaxChar = 512;
char buffer[MaxChar];
//TSTR name(A2THelper(buffer, parent->GetName().c_str(), _countof(buffer)));
n->SetName(FormatText(TEXT("Ragdoll_%s"), parent->GetName()));
PosRotScale prs = prsDefault;
//n->SetObjOffsetScale(ScaleValue(Point3(1, 1, 1)));
Point3 pos = tm.GetTrans();
Quat rot(tm);
PosRotScaleNode(n, pos, rot, 1.0, prsDefault);
Object *pObj = n->GetObjectRef();
IDerivedObject *dobj = nullptr;
if (pObj->SuperClassID() == GEN_DERIVOB_CLASS_ID)
dobj = static_cast<IDerivedObject*>(pObj);
else {
dobj = CreateDerivedObject(pObj);
}
Modifier* shapeMod = (Modifier*)CreateInstance(OSM_CLASS_ID, HK_SHAPE_MODIFIER_CLASS_ID);
if (IParamBlock2* shapeParameters = shapeMod->GetParamBlockByID(PB_SHAPE_MOD_PBLOCK)) {
shapeParameters->SetValue(PA_SHAPE_MOD_SHAPE_TYPE, 0, 1, 0);
}
dobj->SetAFlag(A_LOCK_TARGET);
dobj->AddModifier(shapeMod);
dobj->ClearAFlag(A_LOCK_TARGET);
n->SetObjectRef(dobj);
//AddShape(rbody, n);
return n;
}
}
}
return ragdollParent;
}
示例3: createRagdollRigidBody
//.........这里部分代码省略.........
constraintMod = (Modifier*)CreateInstance(OSM_CLASS_ID, HK_CONSTRAINT_RAGDOLL_CLASS_ID);
if (IParamBlock2* constraintParameters = constraintMod->GetParamBlockByID(PB_CONSTRAINT_MOD_COMMON_SPACES_PARAMS)) {
constraintParameters->SetValue(PA_CONSTRAINT_MOD_PARENT_NODE, 0, ragdollParent, 0);
constraintParameters->SetValue(PA_CONSTRAINT_MOD_PARENT_ROTATION_LOCK, 0, 0, 0);
//TOVECTOR3(rag.twistA);
//MatrixFromNormal(TOPOINT3(rag.twistA), parentRotation);
Point3 origin(0,0,0);
Matrix3 parentRotation(TOPOINT3(rag.planeA),TOPOINT3(rag.motorA),TOPOINT3(rag.twistA),origin);
//TOVECTOR3(rag.twistB);
//MatrixFromNormal(TOPOINT3(rag.twistB), childRotation);
Matrix3 childRotation(TOPOINT3(rag.planeB), TOPOINT3(rag.motorB), TOPOINT3(rag.twistB), origin);
constraintParameters->SetValue(PA_CONSTRAINT_MOD_CHILD_SPACE_TRANSLATION, 0, TOPOINT3(rag.pivotB), 0);
constraintParameters->SetValue(PA_CONSTRAINT_MOD_CHILD_SPACE_ROTATION, 0, childRotation, 0);
constraintParameters->SetValue(PA_CONSTRAINT_MOD_PARENT_SPACE_TRANSLATION, 0, TOPOINT3(rag.pivotA), 0);
constraintParameters->SetValue(PA_CONSTRAINT_MOD_PARENT_SPACE_ROTATION, 0, parentRotation, 0);
}
if (IParamBlock2* constraintParameters = constraintMod->GetParamBlockByID(PB_RAGDOLL_MOD_PBLOCK)) {
constraintParameters->SetValue(PA_RAGDOLL_MOD_CONE_ANGLE, 0, TODEG(rag.coneMaxAngle), 0);
constraintParameters->SetValue(PA_RAGDOLL_MOD_PLANE_MIN, 0, TODEG(rag.planeMinAngle), 0);
constraintParameters->SetValue(PA_RAGDOLL_MOD_PLANE_MAX, 0, TODEG(rag.planeMaxAngle), 0);
constraintParameters->SetValue(PA_RAGDOLL_MOD_TWIST_MIN, 0, TODEG(rag.twistMinAngle), 0);
constraintParameters->SetValue(PA_RAGDOLL_MOD_TWIST_MAX, 0, TODEG(rag.twistMaxAngle), 0);
constraintParameters->SetValue(PA_RAGDOLL_MOD_MAX_FRICTION_TORQUE, 0, rag.maxFriction, 0);
}
}
else if (constraint->IsDerivedType(bhkMalleableConstraint::TYPE)) {
bhkMalleableConstraintRef malleableConstraint = bhkMalleableConstraintRef(*it);
if (malleableConstraint->GetConstraintType() == (unsigned int)2) {
LimitedHingeDescriptor lh = malleableConstraint->GetLimitedHinge();
constraintMod = (Modifier*)CreateInstance(OSM_CLASS_ID, HK_CONSTRAINT_HINGE_CLASS_ID);
if (IParamBlock2* constraintParameters = constraintMod->GetParamBlockByID(PB_CONSTRAINT_MOD_COMMON_SPACES_PARAMS)) {
constraintParameters->SetValue(PA_CONSTRAINT_MOD_PARENT_NODE, 0, ragdollParent, 0);
constraintParameters->SetValue(PA_CONSTRAINT_MOD_PARENT_ROTATION_LOCK, 0, 0, 0);
Point3 origin(0, 0, 0);
Matrix3 parentRotation(TOPOINT3(lh.perp2AxleInA1), TOPOINT3(lh.perp2AxleInA2), TOPOINT3(lh.axleA), origin);
Matrix3 childRotation(TOPOINT3(lh.perp2AxleInB1), TOPOINT3(lh.perp2AxleInB2), TOPOINT3(lh.axleB), origin);
//Matrix3 parentRotation(true);
//MatrixFromNormal(TOPOINT3(lh.axleA), parentRotation);
//Matrix3 childRotation(true);
//MatrixFromNormal(TOPOINT3(lh.axleB), childRotation);
constraintParameters->SetValue(PA_CONSTRAINT_MOD_CHILD_SPACE_ROTATION, 0, childRotation, 0);
constraintParameters->SetValue(PA_CONSTRAINT_MOD_PARENT_SPACE_ROTATION, 0, parentRotation, 0);
}
if (IParamBlock2* constraintParameters = constraintMod->GetParamBlockByID(PB_HINGE_MOD_PBLOCK)) {
constraintParameters->SetValue(PA_HINGE_MOD_IS_LIMITED, 0, 1, 0);
constraintParameters->SetValue(PA_HINGE_MOD_LIMIT_MIN, 0, TODEG(lh.minAngle), 0);
constraintParameters->SetValue(PA_HINGE_MOD_LIMIT_MAX, 0, TODEG(lh.maxAngle), 0);
constraintParameters->SetValue(PA_HINGE_MOD_MAX_FRICTION_TORQUE, 0, lh.maxFriction, 0);
// constraintParameters->SetValue(PA_HINGE_MOD_MOTOR_TYPE, 0, lh.motor., 0);
}
}
else if (malleableConstraint->GetConstraintType() == (unsigned int)7) {
RagdollDescriptor rag = malleableConstraint->GetRagdoll();
constraintMod = (Modifier*)CreateInstance(OSM_CLASS_ID, HK_CONSTRAINT_RAGDOLL_CLASS_ID);
if (IParamBlock2* constraintParameters = constraintMod->GetParamBlockByID(PB_CONSTRAINT_MOD_COMMON_SPACES_PARAMS)) {
constraintParameters->SetValue(PA_CONSTRAINT_MOD_PARENT_NODE, 0, ragdollParent, 0);
constraintParameters->SetValue(PA_CONSTRAINT_MOD_PARENT_ROTATION_LOCK, 0, 0, 0);
//TOVECTOR3(rag.twistA);
//MatrixFromNormal(TOPOINT3(rag.twistA), parentRotation);
Point3 origin(0, 0, 0);
Matrix3 parentRotation(TOPOINT3(rag.planeA), TOPOINT3(rag.motorA), TOPOINT3(rag.twistA), origin);
//TOVECTOR3(rag.twistB);
//MatrixFromNormal(TOPOINT3(rag.twistB), childRotation);
Matrix3 childRotation(TOPOINT3(rag.planeB), TOPOINT3(rag.motorB), TOPOINT3(rag.twistB), origin);
constraintParameters->SetValue(PA_CONSTRAINT_MOD_CHILD_SPACE_TRANSLATION, 0, TOPOINT3(rag.pivotB), 0);
constraintParameters->SetValue(PA_CONSTRAINT_MOD_CHILD_SPACE_ROTATION, 0, childRotation, 0);
constraintParameters->SetValue(PA_CONSTRAINT_MOD_PARENT_SPACE_TRANSLATION, 0, TOPOINT3(rag.pivotA), 0);
constraintParameters->SetValue(PA_CONSTRAINT_MOD_PARENT_SPACE_ROTATION, 0, parentRotation, 0);
}
if (IParamBlock2* constraintParameters = constraintMod->GetParamBlockByID(PB_RAGDOLL_MOD_PBLOCK)) {
constraintParameters->SetValue(PA_RAGDOLL_MOD_CONE_ANGLE, 0, TODEG(rag.coneMaxAngle), 0);
constraintParameters->SetValue(PA_RAGDOLL_MOD_PLANE_MIN, 0, TODEG(rag.planeMinAngle), 0);
constraintParameters->SetValue(PA_RAGDOLL_MOD_PLANE_MAX, 0, TODEG(rag.planeMaxAngle), 0);
constraintParameters->SetValue(PA_RAGDOLL_MOD_TWIST_MIN, 0, TODEG(rag.twistMinAngle), 0);
constraintParameters->SetValue(PA_RAGDOLL_MOD_TWIST_MAX, 0, TODEG(rag.twistMaxAngle), 0);
constraintParameters->SetValue(PA_RAGDOLL_MOD_MAX_FRICTION_TORQUE, 0, rag.maxFriction, 0);
}
}
}
++it;
}
}
dobj->SetAFlag(A_LOCK_TARGET);
dobj->AddModifier(rbMod);
if (constraintMod)
dobj->AddModifier(constraintMod);
dobj->ClearAFlag(A_LOCK_TARGET);
n->SetObjectRef(dobj);
}
示例4: ResetNodes
void ResetXForm::ResetNodes(const INodeTab& nodesToReset)
{
Interface *ip = GetCOREInterface();
for (int i = 0; i < nodesToReset.Count(); i++) {
INode *node = nodesToReset[i];
if (!node || node->IsGroupMember() || node->IsGroupHead())
continue;
if (SelectedAncestor(node))
continue;
Matrix3 ntm, ptm, rtm(1), piv(1), tm;
// Get Parent and Node TMs
ntm = node->GetNodeTM(ip->GetTime());
ptm = node->GetParentTM(ip->GetTime());
// Compute the relative TM
ntm = ntm * Inverse(ptm);
// The reset TM only inherits position
rtm.SetTrans(ntm.GetTrans());
// Set the node TM to the reset TM
tm = rtm*ptm;
node->SetNodeTM(ip->GetTime(), tm);
// Compute the pivot TM
piv.SetTrans(node->GetObjOffsetPos());
PreRotateMatrix(piv,node->GetObjOffsetRot());
ApplyScaling(piv,node->GetObjOffsetScale());
// Reset the offset to 0
node->SetObjOffsetPos(Point3(0,0,0));
node->SetObjOffsetRot(IdentQuat());
node->SetObjOffsetScale(ScaleValue(Point3(1,1,1)));
// Take the position out of the matrix since we don't reset position
ntm.NoTrans();
// Apply the offset to the TM
ntm = piv * ntm;
// Apply a derived object to the node's object
Object *obj = node->GetObjectRef();
IDerivedObject *dobj = CreateDerivedObject(obj);
// Create an XForm mod
SimpleMod *mod = (SimpleMod*)ip->CreateInstance(
OSM_CLASS_ID,
Class_ID(CLUSTOSM_CLASS_ID,0));
// Apply the transformation to the mod.
SetXFormPacket pckt(ntm);
mod->tmControl->SetValue(ip->GetTime(),&pckt);
// Add the modifier to the derived object.
dobj->SetAFlag(A_LOCK_TARGET); // RB 3/11/99: When the macro recorder is on the derived object will get deleted unless it is locked.
dobj->AddModifier(mod);
dobj->ClearAFlag(A_LOCK_TARGET);
// Replace the node's object
node->SetObjectRef(dobj);
}
// Why on earth were we clearing the undo stack?
// GetSystemSetting(SYSSET_CLEAR_UNDO);
ip->RedrawViews(ip->GetTime());
SetSaveRequiredFlag(TRUE);
}