public void UpdateObjectFlags(ObjectFlagUpdatePacket pack) { if (this._physActor != null) { if (this._physActor.Kinematic == pack.AgentData.UsePhysics) { this._physActor.Kinematic = !pack.AgentData.UsePhysics; //if Usephysics = true, then Kinematic should = false } this.physicsEnabled = pack.AgentData.UsePhysics; if (this._physActor.Kinematic == false) { LLVector3 pos = this.Pos; this.UpdatePosition(pos); pos.Z += 0.000001f; this.UpdatePosition(pos); this.physicstest = true; } else { PhysicsVector vec = this._physActor.Position; LLVector3 pos = new LLVector3(vec.X, vec.Y, vec.Z); this.Pos = pos; this.updateFlag = true; } } }
public void AddViewerAgent(SimClient agentClient) { try { OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); Avatar newAvatar = new Avatar(agentClient, this, m_regionName, m_clientThreads, m_regionHandle, true, 20); OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world"); OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake "); newAvatar.SendRegionHandshake(this); if (!agentClient.m_child) { PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z); lock (this.LockPhysicsEngine) { newAvatar.PhysActor = this.phyScene.AddAvatar(pVec); } } lock (Entities) { this.Entities.Add(agentClient.AgentID, newAvatar); } lock (Avatars) { this.Avatars.Add(agentClient.AgentID, newAvatar); } } catch (Exception e) { OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: AddViewerAgent() - Failed with exception " + e.ToString()); } }
public void AddNewPrim(ObjectAddPacket addPacket, SimClient AgentClient) { try { OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Creating new prim"); Primitive prim = new Primitive(m_clientThreads, m_regionHandle, this); prim.CreateFromPacket(addPacket, AgentClient.AgentID, this._primCount); PhysicsVector pVec = new PhysicsVector(prim.Pos.X, prim.Pos.Y, prim.Pos.Z); PhysicsVector pSize = new PhysicsVector(0.255f, 0.255f, 0.255f); if (OpenSim.world.Avatar.PhysicsEngineFlying) { lock (this.LockPhysicsEngine) { prim.PhysActor = this.phyScene.AddPrim(pVec, pSize); } } this.Entities.Add(prim.uuid, prim); this._primCount++; } catch (Exception e) { OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Failed with exception " + e.ToString()); } }
public override void addForces() { lock (this.forcesList) { if (this.forcesList.Count > 0) { for (int i = 0; i < this.forcesList.Count; i++) { NewForce force = this.forcesList[i]; PhysicsVector phyVector = new PhysicsVector(force.X, force.Y, force.Z); lock (m_world.LockPhysicsEngine) { this._physActor.Velocity = phyVector; } this.updateflag = true; this.velocity = new LLVector3(force.X, force.Y, force.Z); //shouldn't really be doing this // but as we are setting the velocity (rather than using real forces) at the moment it is okay. } for (int i = 0; i < this.forcesList.Count; i++) { this.forcesList.RemoveAt(0); } } } }
public PhysXPrim(NxActor prim) { _velocity = new PhysicsVector(); _position = new PhysicsVector(); _acceleration = new PhysicsVector(); _prim = prim; }
public BasicActor() { _velocity = new PhysicsVector(); _position = new PhysicsVector(); _acceleration = new PhysicsVector(); _size = new PhysicsVector(); }
internal void ProcessVectorVehicleParam(Vehicle pParam, PhysicsVector pValue) { switch (pParam) { case Vehicle.ANGULAR_FRICTION_TIMESCALE: m_angularFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); break; case Vehicle.ANGULAR_MOTOR_DIRECTION: m_angularMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); m_angularMotorDirectionLASTSET = new Vector3(pValue.X, pValue.Y, pValue.Z); break; case Vehicle.LINEAR_FRICTION_TIMESCALE: m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); break; case Vehicle.LINEAR_MOTOR_DIRECTION: m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); m_linearMotorDirectionLASTSET = new Vector3(pValue.X, pValue.Y, pValue.Z); break; case Vehicle.LINEAR_MOTOR_OFFSET: // m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); break; } Reset(); }
public PhysXCharacter(NxCharacter character) { _velocity = new PhysicsVector(); _position = new PhysicsVector(); _acceleration = new PhysicsVector(); _character = character; }
public void AddPos(PhysicsVector Position) { foreach (Vertex t in vertices) { t.AddPos(Position); } }
/// <summary> /// Adds the force supplied to the Target Velocity /// The PID controller takes this target velocity and tries to make it a reality /// </summary> /// <param name="force"></param> public override void AddForce(PhysicsVector force, bool pushforce) { if (PhysicsVector.isFinite(force)) { if (pushforce) { m_pidControllerActive = false; force *= 100f; doForce(force); //m_log.Debug("Push!"); //_target_velocity.X += force.X; // _target_velocity.Y += force.Y; //_target_velocity.Z += force.Z; } else { m_pidControllerActive = true; _target_velocity.X += force.X; _target_velocity.Y += force.Y; _target_velocity.Z += force.Z; } } else { m_log.Warn("[PHYSICS]: Got a NaN force applied to a Character"); } //m_lastUpdateSent = false; }
public override PhysicsActor AddAvatar(PhysicsVector position) { BasicActor act = new BasicActor(); act.Position = position; _actors.Add(act); return(act); }
/// <summary> /// After all of the forces add up with 'add force' we apply them with doForce /// </summary> /// <param name="force"></param> public void doForce(PhysicsVector force) { if (!collidelock) { d.BodyAddForce(Body, force.X, force.Y, force.Z); //d.BodySetRotation(Body, ref m_StandUpRotation); //standupStraight(); } }
public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) { BasicActor act = new BasicActor(); act.Position = position; act.Flying = isFlying; _actors.Add(act); return(act); }
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation, bool isPhysical) { POSPrim prim = new POSPrim(); prim.Position = position; prim.Orientation = rotation; prim.Size = size; _prims.Add(prim); return(prim); }
public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) { BulletDotNETCharacter chr = new BulletDotNETCharacter(avName, this, position, size, avPIDD, avPIDP, avCapRadius, avStandupTensor, avDensity, avHeightFudgeFactor, avMovementDivisorWalk, avMovementDivisorRun); m_characters.Add(chr); AddPhysicsActorTaint(chr); return(chr); }
public override PhysicsActor AddAvatar(PhysicsVector position) { PhysicsVector pos = new PhysicsVector(); pos.X = position.X; pos.Y = position.Y; pos.Z = position.Z + 20; OdeCharacter newAv = new OdeCharacter(this, pos); this._characters.Add(newAv); return(newAv); }
public virtual bool Equals(Vertex v, float tolerance) { PhysicsVector diff = this - v; float d = diff.length(); if (d < tolerance) { return(true); } return(false); }
public OdeCharacter(OdeScene parent_scene, PhysicsVector pos) { _velocity = new PhysicsVector(); _position = pos; _acceleration = new PhysicsVector(); d.MassSetCapsule(out capsule_mass, 5.0f, 3, 0.5f, 2f); capsule_geom = d.CreateCapsule(OdeScene.space, 0.5f, 2f); this.BoundingCapsule = d.BodyCreate(OdeScene.world); d.BodySetMass(BoundingCapsule, ref capsule_mass); d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z); d.GeomSetBody(capsule_geom, BoundingCapsule); }
public void Move(float timeStep) { PhysicsVector vec = new PhysicsVector(); vec.X = this._velocity.X * timeStep; vec.Y = this._velocity.Y * timeStep; if (flying) { vec.Z = (this._velocity.Z + 0.5f) * timeStep; } d.BodySetLinearVel(this.BoundingCapsule, vec.X, vec.Y, vec.Z); }
public void doImpulse(PhysicsVector force, bool now) { tempVector3.setValue(force.X, force.Y, force.Z); if (now) { Body.applyCentralImpulse(tempVector3); } else { m_taintedForce += force; m_parent_scene.AddPhysicsActorTaint(this); } }
public override PhysicsActor AddAvatar(PhysicsVector position) { Vec3 pos = new Vec3(); pos.X = position.X; pos.Y = position.Y; pos.Z = position.Z; PhysXCharacter act = new PhysXCharacter(scene.AddCharacter(pos)); act.Position = position; _characters.Add(act); return(act); }
public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) { Vec3 pos = new Vec3(); pos.X = position.X; pos.Y = position.Y; pos.Z = position.Z; PhysXCharacter act = new PhysXCharacter(scene.AddCharacter(pos)); act.Flying = isFlying; act.Position = position; _characters.Add(act); return(act); }
public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) { PhysicsVector pos = new PhysicsVector(); pos.X = position.X; pos.Y = position.Y; pos.Z = position.Z; PhysicsVector siz = new PhysicsVector(); siz.X = size.X; siz.Y = size.Y; siz.Z = size.Z; return(new OdePrim()); }
// private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); public BulletDotNETCharacter(string avName, BulletDotNETScene parent_scene, PhysicsVector pos, PhysicsVector size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor) { m_taintedForce = new PhysicsVector(); m_velocity = new PhysicsVector(); m_target_velocity = new PhysicsVector(); m_position = pos; m_zeroPosition = new PhysicsVector(pos.X, pos.Y, pos.Z); // this is a class, not a struct. Must make new, or m_zeroPosition will == position regardless m_acceleration = new PhysicsVector(); m_parent_scene = parent_scene; PID_D = pid_d; PID_P = pid_p; CAPSULE_RADIUS = capsule_radius; m_density = density; heightFudgeFactor = height_fudge_factor; walkDivisor = walk_divisor; runDivisor = rundivisor; for (int i = 0; i < 11; i++) { m_colliderarr[i] = false; } for (int i = 0; i < 11; i++) { m_colliderGroundarr[i] = false; } CAPSULE_LENGTH = (size.Z * 1.15f) - CAPSULE_RADIUS * 2.0f; m_tainted_CAPSULE_LENGTH = CAPSULE_LENGTH; m_isPhysical = false; // current status: no ODE information exists m_tainted_isPhysical = true; // new tainted status: need to create ODE information m_parent_scene.AddPhysicsActorTaint(this); // m_name = avName; tempVector1 = new btVector3(0, 0, 0); tempVector2 = new btVector3(0, 0, 0); tempVector3 = new btVector3(0, 0, 0); tempVector4 = new btVector3(0, 0, 0); tempVector5RayCast = new btVector3(0, 0, 0); tempVector6RayCast = new btVector3(0, 0, 0); tempVector7RayCast = new btVector3(0, 0, 0); tempQuat1 = new btQuaternion(0, 0, 0, 1); tempTrans1 = new btTransform(tempQuat1, tempVector1); // m_movementComparision = new PhysicsVector(0, 0, 0); m_CapsuleOrientationAxis = new btVector3(1, 0, 1); }
private PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) { Vec3 pos = new Vec3(); pos.X = position.X; pos.Y = position.Y; pos.Z = position.Z; Vec3 siz = new Vec3(); siz.X = size.X; siz.Y = size.Y; siz.Z = size.Z; PhysXPrim act = new PhysXPrim(scene.AddNewBox(pos, siz)); _prims.Add(act); return(act); }
public void CreateAndDropPhysicalCube() { PrimitiveBaseShape newcube = PrimitiveBaseShape.CreateBox(); PhysicsVector position = new PhysicsVector(128, 128, 128); PhysicsVector size = new PhysicsVector(0.5f, 0.5f, 0.5f); Quaternion rot = Quaternion.Identity; PhysicsActor prim = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true); OdePrim oprim = (OdePrim)prim; OdeScene pscene = (OdeScene)ps; Assert.That(oprim.m_taintadd); prim.LocalID = 5; for (int i = 0; i < 58; i++) { ps.Simulate(0.133f); Assert.That(oprim.prim_geom != (IntPtr)0); Assert.That(oprim.m_targetSpace != (IntPtr)0); //Assert.That(oprim.m_targetSpace == pscene.space); m_log.Info("TargetSpace: " + oprim.m_targetSpace + " - SceneMainSpace: " + pscene.space); Assert.That(!oprim.m_taintadd); m_log.Info("Prim Position (" + oprim.m_localID + "): " + prim.Position.ToString()); // Make sure we're above the ground //Assert.That(prim.Position.Z > 20f); //m_log.Info("PrimCollisionScore (" + oprim.m_localID + "): " + oprim.m_collisionscore); // Make sure we've got a Body Assert.That(oprim.Body != (IntPtr)0); //m_log.Info( } // Make sure we're not somewhere above the ground Assert.That(prim.Position.Z < 21.5f); ps.RemovePrim(prim); Assert.That(oprim.m_taintremove); ps.Simulate(0.133f); Assert.That(oprim.Body == (IntPtr)0); }
public void UpdateClient(SimClient RemoteClient) { LLVector3 lPos; if (this._physActor != null && this.physicsEnabled) { PhysicsVector pPos = this._physActor.Position; lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); } else { lPos = this.Pos; } byte[] pb = lPos.GetBytes(); Array.Copy(pb, 0, OurPacket.ObjectData[0].ObjectData, 0, pb.Length); // OurPacket should be update with the follwing in updateShape() rather than having to do it here OurPacket.ObjectData[0].OwnerID = this.primData.OwnerID; OurPacket.ObjectData[0].PCode = this.primData.PCode; OurPacket.ObjectData[0].PathBegin = this.primData.PathBegin; OurPacket.ObjectData[0].PathEnd = this.primData.PathEnd; OurPacket.ObjectData[0].PathScaleX = this.primData.PathScaleX; OurPacket.ObjectData[0].PathScaleY = this.primData.PathScaleY; OurPacket.ObjectData[0].PathShearX = this.primData.PathShearX; OurPacket.ObjectData[0].PathShearY = this.primData.PathShearY; OurPacket.ObjectData[0].PathSkew = this.primData.PathSkew; OurPacket.ObjectData[0].ProfileBegin = this.primData.ProfileBegin; OurPacket.ObjectData[0].ProfileEnd = this.primData.ProfileEnd; OurPacket.ObjectData[0].Scale = this.primData.Scale; OurPacket.ObjectData[0].PathCurve = this.primData.PathCurve; OurPacket.ObjectData[0].ProfileCurve = this.primData.ProfileCurve; OurPacket.ObjectData[0].ParentID = this.primData.ParentID; OurPacket.ObjectData[0].ProfileHollow = this.primData.ProfileHollow; //finish off copying rest of shape data OurPacket.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset; OurPacket.ObjectData[0].PathRevolutions = this.primData.PathRevolutions; OurPacket.ObjectData[0].PathTaperX = this.primData.PathTaperX; OurPacket.ObjectData[0].PathTaperY = this.primData.PathTaperY; OurPacket.ObjectData[0].PathTwist = this.primData.PathTwist; OurPacket.ObjectData[0].PathTwistBegin = this.primData.PathTwistBegin; RemoteClient.OutPacket(OurPacket); }
/// <summary> /// Adds the force supplied to the Target Velocity /// The PID controller takes this target velocity and tries to make it a reality /// </summary> /// <param name="force"></param> /// <param name="pushforce">Is this a push by a script?</param> public override void AddForce(PhysicsVector force, bool pushforce) { if (pushforce) { m_pidControllerActive = false; force *= 100f; doForce(force, false); //System.Console.WriteLine("Push!"); //_target_velocity.X += force.X; // _target_velocity.Y += force.Y; //_target_velocity.Z += force.Z; } else { m_pidControllerActive = true; m_target_velocity.X += force.X; m_target_velocity.Y += force.Y; m_target_velocity.Z += force.Z; } //m_lastUpdateSent = false; }
public PhysicsVector getNormal() { // Vertices // Vectors for edges PhysicsVector e1; PhysicsVector e2; e1 = new PhysicsVector(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z); e2 = new PhysicsVector(v1.X - v3.X, v1.Y - v3.Y, v1.Z - v3.Z); // Cross product for normal PhysicsVector n = PhysicsVector.cross(e1, e2); // Length float l = n.length(); // Normalized "normal" n = n / l; return(n); }
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod, bool isPhysical) { Mesh mesh = null; if (size.X < 0.01f) { size.X = 0.01f; } if (size.Y < 0.01f) { size.Y = 0.01f; } if (size.Z < 0.01f) { size.Z = 0.01f; } mesh = CreateMeshFromPrimMesher(primName, primShape, size, lod); if (mesh != null) { if ((!isPhysical) && size.X < minSizeForComplexMesh && size.Y < minSizeForComplexMesh && size.Z < minSizeForComplexMesh) { #if SPAM m_log.Debug("Meshmerizer: prim " + primName + " has a size of " + size.ToString() + " which is below threshold of " + minSizeForComplexMesh.ToString() + " - creating simple bounding box"); #endif mesh = CreateBoundingBoxMesh(mesh); mesh.DumpRaw(baseDir, primName, "Z extruded"); } // trim the vertex and triangle lists to free up memory mesh.vertices.TrimExcess(); mesh.triangles.TrimExcess(); } return(mesh); }