本文整理汇总了C#中Body.AttachNode方法的典型用法代码示例。如果您正苦于以下问题:C# Body.AttachNode方法的具体用法?C# Body.AttachNode怎么用?C# Body.AttachNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Body
的用法示例。
在下文中一共展示了Body.AttachNode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WayPoint
public WayPoint()
{
_Orientation = Quaternion.IDENTITY;
_DisplayNameOffset = new Vector3(0, 0.2f, 0);
Entity = Engine.Singleton.SceneManager.CreateEntity("Spawn.mesh");
Node = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
Node.AttachObject(Entity);
ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
Node,
Quaternion.IDENTITY,
0.1f,
Engine.Singleton.GetUniqueBodyId());
Vector3 inertia, offset;
collision.CalculateInertialMatrix(out inertia, out offset);
Inertia = inertia;
Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
Body.AttachNode(Node);
Body.SetMassMatrix(0, inertia * 0);
Body.ForceCallback += BodyForceCallback;
Body.UserData = this;
Body.MaterialGroupID = Engine.Singleton.MaterialManager.WaypointMaterialID;
//Body.MaterialGroupID = Engine.Singleton.MaterialManager.CharacterMaterialID;
collision.Dispose();
}
示例2: SetCollisionMesh
public void SetCollisionMesh(String meshFile)
{
m_CollisionNode =
Core.Singleton.m_SceneManager.RootSceneNode.CreateChildSceneNode();
m_CollisionEntity = Core.Singleton.m_SceneManager.CreateEntity(meshFile);
m_CollisionNode.AttachObject(m_CollisionEntity);
m_CollisionNode.SetVisible(false);
MogreNewt.CollisionPrimitives.TreeCollisionSceneParser collision =
new MogreNewt.CollisionPrimitives.TreeCollisionSceneParser(
Core.Singleton.m_NewtonWorld);
collision.ParseScene(m_CollisionNode, true, 1);
m_Body = new Body(Core.Singleton.m_NewtonWorld, collision);
collision.Dispose();
m_Body.AttachNode(m_CollisionNode);
}
示例3: PhysicsNode
public PhysicsNode(SimNode simNode, State State)
: base(simNode.SceneNode)
{
SceneNode = simNode.SceneNode;
SceneNode child = SceneNode;
while (child.NumChildren() > 0) child = child.GetChild(0) as SceneNode;
var hull = new MogreNewt.CollisionPrimitives.ConvexHull(State.PhysicsWorld.World, child, child.Orientation, 0.002f, SceneNode.Name.GetHashCode());
Body = new Body(State.PhysicsWorld.World, hull);
Body.AttachNode(SceneNode);
Body.IsGravityEnabled = true;
Body.SetPositionOrientation(SceneNode._getDerivedPosition(), SceneNode.Orientation); // REALPosition Orient
Body.ForceCallback += State.PhysicsWorld.ForceCallback;
// Body.AngularDamping = new Vector3(1,1,1);
// Body.LinearDamping = 1;
Body.UserData = new PhysicsControlData();
hull.Dispose();
}
示例4: Character
public Character(CharacterProfile profile)
{
m_Profile = profile.Clone();
m_Orientation = Quaternion.IDENTITY;
m_Entity = Core.Singleton.m_SceneManager.CreateEntity(m_Profile.m_MeshName);
m_Node = Core.Singleton.m_SceneManager.RootSceneNode.CreateChildSceneNode();
m_Node.AttachObject(m_Entity);
Vector3 scaledSize = m_Entity.BoundingBox.HalfSize * m_Profile.m_BodyScaleFactor;
ConvexCollision collision = new MogreNewt.CollisionPrimitives.Capsule(
Core.Singleton.m_NewtonWorld,
System.Math.Min(scaledSize.x, scaledSize.z),
scaledSize.y * 2,
Vector3.UNIT_X.GetRotationTo(Vector3.UNIT_Y),
Core.Singleton.GetUniqueBodyId());
Vector3 inertia, offset;
collision.CalculateInertialMatrix(out inertia, out offset);
inertia *= m_Profile.m_BodyMass;
m_Body = new Body(Core.Singleton.m_NewtonWorld, collision, true);
m_Body.AttachNode(m_Node);
m_Body.SetMassMatrix(m_Profile.m_BodyMass, inertia);
m_Body.AutoSleep = false;
m_Body.Transformed += BodyTransformCallback;
m_Body.ForceCallback += BodyForceCallback;
Joint upVector = new MogreNewt.BasicJoints.UpVector(
Core.Singleton.m_NewtonWorld, m_Body, Vector3.UNIT_Y);
collision.Dispose();
}
示例5: Init
public void Init(State State)
{
this.State = State;
State.PhysicsWorld = this;
World = new MogreNewt.World();
World.SetPlatformArchitecture(MogreNewt.World.PlatformArchitecture.PA_BEST_HARDWARE);
World.SetWorldSize(new Vector3(-500, -500, -500), new Vector3(500, 500, 500));
World.SetSolverModel(MogreNewt.World.SolverModelMode.SM_2_PASS);
World.DebuggerInstance.Init(State.SceneManager);
// using the new "SceneParser" TreeCollision primitive. this will automatically parse an entire tree of
// SceneNodes (parsing all children), and add collision for all meshes in the tree.
var statCol = new MogreNewt.CollisionPrimitives.TreeCollisionSceneParser(World);
statCol.ParseScene(State.SceneManager.RootSceneNode, true, 0); // was floornode
var sceneBody = new Body(World, statCol);
statCol.Dispose();
sceneBody.AttachNode(State.SceneManager.RootSceneNode); // was floornode
sceneBody.SetPositionOrientation(new Vector3(0.0f, 0.0f, 0.0f), Quaternion.IDENTITY);
var ent = State.SceneManager.CreateEntity("cylinder_body", "mocksub.mesh");
var simNode = new SimNode(State.SceneManager.RootSceneNode, ent);
// rigid body.
var phyNode = new PhysicsNode(simNode, State);
phyNode.Body.SetPositionOrientation(new Vector3(0, 10, 0), Quaternion.IDENTITY);
phyNode.Body.SetMassMatrix(125, Vector3.ZERO);
var physicsNode = new PhysicsNode(State.SubNode, State);
physicsNode.Body.SetMassMatrix(125, Vector3.ZERO);
// TODO: FIX THIS State.SubNode = physicsNode;
// initial position
State.Root.FrameStarted += NewtonUpdate;
}
示例6: Enemy
public Enemy(CharacterProfile profile, bool czyPojemnik, float zasiegWzr, float zasiegOgl)
{
Profile = profile.Clone();
_Orientation = Quaternion.IDENTITY;
Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
Node = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
Node.AttachObject(Entity);
Vector3 scaledSize = Entity.BoundingBox.HalfSize * Profile.BodyScaleFactor;
ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
Node,
Quaternion.IDENTITY,
0.1f,
Engine.Singleton.GetUniqueBodyId());
Vector3 inertia, offset;
collision.CalculateInertialMatrix(out inertia, out offset);
inertia *= Profile.BodyMass;
Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
Body.AttachNode(Node);
Body.SetMassMatrix(Profile.BodyMass, inertia);
Body.AutoSleep = false;
Body.Transformed += BodyTransformCallback;
Body.ForceCallback += BodyForceCallback;
Body.UserData = this;
Body.MaterialGroupID = Engine.Singleton.MaterialManager.EnemyMaterialID;
Joint upVector = new MogreNewt.BasicJoints.UpVector(
Engine.Singleton.NewtonWorld, Body, Vector3.UNIT_Y);
collision.Dispose();
isContainer = czyPojemnik;
isSeen = false;
isReachable = false;
_ZasiegWzroku = zasiegWzr;
_ZasiegOgolny = zasiegOgl;
_Statistics = Profile.Statistics.statistics_Clone();
State = StateTypes.IDLE;
//DROPPRIZE KUFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
if (Profile.DropPrizeID == "")
Profile.DropPrizeID = "pPusty";
DropPrize = PrizeManager.P[Profile.DropPrizeID].prize_Clone();
List<DescribedProfile> lista_tym = new List<DescribedProfile>();
List<DescribedProfile> lista_tym2 = new List<DescribedProfile>(DropPrize.ItemsList);
if (DropPrize.ItemsList.Count > 2)
{
for (int i = 0; i < 2; i++)
{
int Los = Engine.Singleton.Random.Next(lista_tym2.Count);
lista_tym.Add(lista_tym2[Los]);
lista_tym2.RemoveAt(Los);
DropPrize.ItemsList = new List<DescribedProfile>(lista_tym);
}
}
else
DropPrize.ItemsList = new List<DescribedProfile>(DropPrize.ItemsList);
DropPrize.AmountGold = Engine.Singleton.Random.Next(DropPrize.AmountGold / 2, DropPrize.AmountGold + 1);
DropExp = DropPrize.AmountExp;
//PO DROPPRIZIE KUFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
walkAnim = Entity.GetAnimationState("WALK");
idleAnim = Entity.GetAnimationState("IDLE");
attackAnim = Entity.GetAnimationState("ATTACK");
deadAnim = Entity.GetAnimationState("DEAD");
//Animation("IdleLegs").Enabled = true;
//Animation("IdleLegs").Loop = true;
FriendlyType = Profile.FriendlyType;
ProfName = Profile.ProfileName;
}
示例7: RecalculateCollision
public void RecalculateCollision()
{
Vector3 pos = Position;
Quaternion orient = Orientation;
Node.DetachAllObjects();
Engine.Singleton.SceneManager.DestroySceneNode(Node);
Engine.Singleton.SceneManager.DestroyEntity(Entity);
Body.Dispose();
Body = null;
Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
Node = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
Node.AttachObject(Entity);
ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
Node,
Quaternion.IDENTITY,
0.1f,
Engine.Singleton.GetUniqueBodyId());
Vector3 inertia, offset;
collision.CalculateInertialMatrix(out inertia, out offset);
inertia *= Profile.BodyMass;
Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
Body.AttachNode(Node);
Body.SetMassMatrix(Profile.BodyMass, inertia);
Body.AutoSleep = false;
Body.Transformed += BodyTransformCallback;
Body.ForceCallback += BodyForceCallback;
Orientation = orient;
Position = pos;
Body.UserData = this;
Body.MaterialGroupID = Engine.Singleton.MaterialManager.EnemyMaterialID;
Joint upVector = new MogreNewt.BasicJoints.UpVector(
Engine.Singleton.NewtonWorld, Body, Vector3.UNIT_Y);
collision.Dispose();
}
示例8: EnemyDecTree
//public List<GameObject> Contacts;
//public Described PickingTarget;
//public List<DescribedProfile> Inventory;
//ItemSword _Sword;
//Entity SwordEntity;
//public CharacterAnimBlender AnimBlender;
//public bool TalkPerm;
//public bool InventoryPerm;
//public bool PickItemOrder;
//public bool MoveOrder;
//public bool MoveOrderBack;
//public bool GetSwordOrder;
//public bool HideSwordOrder;
//bool _RunOrder;
/*public bool RunOrder
{
get
{
return _RunOrder;
}
set
{
if (_RunOrder == true && value == false)
{
_RunOrder = false;
Profile.WalkSpeed -= 2.0f;
}
if (_RunOrder == false && value == true)
{
_RunOrder = true;
Profile.WalkSpeed += 2.0f;
}
}
}
public float TurnDelta;
public bool FollowPathOrder;
public List<Vector3> WalkPath;
public static DecTree.Enemies.e_Node Tree = new EnemyDecTree();
//////////////////////////////////////////////
// Moje zmienne:
//////////////////////////////////////////////
Container Container;
public bool isContainer;
bool isSeen;
bool isReachable;
float ZasiegWzroku;
float ZasiegOgolny;
Prize DropPrize;
public Statistics Statistics;*/
public Enemy(CharacterProfile profile)
{
Profile = profile.Clone();
_Orientation = Quaternion.IDENTITY;
Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
Node = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
Node.AttachObject(Entity);
// Vector3 scaledSize = Entity.BoundingBox.HalfSize * Profile.BodyScaleFactor;
ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
Node,
Quaternion.IDENTITY,
0.1f,
Engine.Singleton.GetUniqueBodyId());
Vector3 inertia, offset;
collision.CalculateInertialMatrix(out inertia, out offset);
Inertia = inertia;
Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
Body.AttachNode(Node);
Body.SetMassMatrix(Profile.BodyMass, inertia * Profile.BodyMass);
//Body.AutoSleep = false;
//Body.Transformed += BodyTransformCallback;
Body.ForceCallback += BodyForceCallback;
Body.UserData = this;
Body.MaterialGroupID = Engine.Singleton.MaterialManager.CharacterMaterialID;
//Joint upVector = new MogreNewt.BasicJoints.UpVector(
// Engine.Singleton.NewtonWorld, Body, Vector3.UNIT_Y);
collision.Dispose();
}