public static void RemoveMouseover() { if (mouselook_current_target != null) { if (mouselook_current_desc_area != Rectangle.Empty) { int h = mouselook_current_desc_area.Height; int w = mouselook_current_desc_area.Width; Screen.UpdateGLBuffer(Global.MAP_OFFSET_ROWS, Global.MAP_OFFSET_COLS + mouselook_current_desc_area.Left, Global.MAP_OFFSET_ROWS + h - 1, Global.MAP_OFFSET_COLS + mouselook_current_desc_area.Right - 1); mouselook_current_desc_area = Rectangle.Empty; } mouselook_current_target = null; Screen.CursorVisible = true; // This should be safe, so long as mouseovers only appear while waiting for the player's move. } if (mouse_path != null) { foreach (pos p in mouse_path) { int i = p.row; int j = p.col; colorchar cch = Screen.MapChar(i, j); //I tried doing this with a single call to UpdateVertexArray. It was slow. Screen.gl.UpdateOtherSingleVertex(Screen.textSurface, U.Get1DIndex(i + Global.MAP_OFFSET_ROWS, j + Global.MAP_OFFSET_COLS, Global.SCREEN_W), (int)cch.c, 0, cch.color.GetFloatValues(), cch.bgcolor.GetFloatValues()); //Game.gl.UpdateVertexArray(i+Global.MAP_OFFSET_ROWS,j+Global.MAP_OFFSET_COLS,GLGame.text_surface,0,(int)cch.c,cch.color.GetFloatValues(),cch.bgcolor.GetFloatValues()); } mouse_path = null; } }
private void PlayerCollideHook(On.Player.orig_Collide orig, Player self, PhysicalObject otherObject, int myChunk, int otherChunk) { orig.Invoke(self, otherObject, myChunk, otherChunk); if (self.playerState.slugcatCharacter == PlayerManager.GetCustomPlayer("Electric").SlugcatIndex) { for (int i = 0; i < EVars.Count; i++) { if (EVars[i].ply == self) { if (otherObject is Creature && EVars[i].chargedActive && EVars[i].stunDelay == 0f) { if (!(otherObject is BigEel) && !(otherObject is Centipede) && !(otherObject is Fly) && !(otherObject as Creature).dead) { if (otherObject is Player && (otherObject as Player).playerState.slugcatCharacter == PlayerManager.GetCustomPlayer("Electric").SlugcatIndex) { return; } if (!(otherObject is Player) && (otherObject as Creature).abstractCreature.abstractAI.RealAI.friendTracker != null && (otherObject as Creature).abstractCreature.abstractAI.RealAI.friendTracker.Utility() > 0f) { return; } (otherObject as Creature).Violence(self.firstChunk, new Vector2?(Custom.DirVec(self.firstChunk.pos, otherObject.bodyChunks[otherChunk].pos) * 5f), otherObject.bodyChunks[otherChunk], null, Creature.DamageType.Electric, 0.8f, (!(otherObject is Player)) ? (270f * Mathf.Lerp((otherObject as Creature).Template.baseStunResistance, 1f, 0.5f)) : 140f); self.room.AddObject(new CreatureSpasmer(otherObject as Creature, false, (otherObject as Creature).stun)); EVars[i].stunDelay = 300f; self.room.PlaySound(SoundID.Jelly_Fish_Tentacle_Stun, self.firstChunk.pos); self.room.AddObject(new Explosion.ExplosionLight(self.firstChunk.pos, 150f, 0.85f, 4, new Color(0.7f, 0.7f, 1f))); EVars[i].chargedTimer -= 20f; } } } } } }
public bool IsIntersecting(Vector2 position, PhysicalObject box2) //Ne marche qu'avec des rectangles AABB { return(position.X < box2.Position.X + box2.Texture.Width && position.X + this._texture.Width > box2.Position.X && position.Y < box2.Position.Y + box2.Texture.Height && position.Y + this._texture.Height > box2.Position.Y); }
public static PhysicalObject ReadPhysicalObject(ref PhysicalObject physicalObject, ref BinaryReader reader, Room room) { if (!reader.ReadBoolean()) { return(null); } int dist = reader.ReadInt32(); if (physicalObject != null && physicalObject.abstractPhysicalObject != null && (physicalObject.abstractPhysicalObject as patch_AbstractPhysicalObject).dist == dist) { return(physicalObject); } PhysicalObject target = null; for (int i = 0; i < room.physicalObjects.Length; i++) { for (int j = 0; j < room.physicalObjects[i].Count; j++) { if (room.physicalObjects[i][j] != null && room.physicalObjects[i][j].abstractPhysicalObject != null && ((room.physicalObjects[i][j].abstractPhysicalObject as AbstractPhysicalObject) as patch_AbstractPhysicalObject).dist == dist) { target = room.physicalObjects[i][j]; } } } return(target); }
// I don't even know what this is yet here I am parsing it public static MeshModificationObject Read(Reader reader, PhysicalObject po, Pointer offset) { MapLoader l = MapLoader.Loader; //Debug.LogWarning("Unknown object @ " + offset); MeshModificationObject mod = new MeshModificationObject(po, offset); mod.off_model = Pointer.Read(reader); /*Pointer.DoAt(ref reader, mod.off_model, () => { * mod.mesh = MeshObject.Read(reader, po, mod.off_model); * });*/ mod.num_properties = reader.ReadUInt32(); mod.off_properties = Pointer.Read(reader); Pointer.DoAt(ref reader, mod.off_properties, () => { mod.properties = new MeshModificationProperty[mod.num_properties]; for (int i = 0; i < mod.num_properties; i++) { mod.properties[i] = new MeshModificationProperty(); mod.properties[i].id = reader.ReadUInt16(); mod.properties[i].unk = reader.ReadUInt16(); float x = reader.ReadSingle(); float z = reader.ReadSingle(); float y = reader.ReadSingle(); mod.properties[i].pos = new Vector3(x, y, z); } }); return(mod); }
public void EatHeldObject() { if (heldObject == null) { return; } Food heldFood = heldObject.GetComponent <Food>(); if (heldFood == null) { return; } if (heldFood.thisFoodType == food_type.meat && state.eaterType == Eater_type.herbivore) { return; } if (heldFood.thisFoodType == food_type.plant && state.eaterType == Eater_type.carnivore) { return; } state.fed += (float)heldFood.thisFoodType * 0.1f; // TODO: scale with foodtype and transform scale or other quantity Destroy(heldObject.gameObject); heldObject = null; target = null; }
// Start is called before the first frame update void Start() { physicalObject = GetComponent <PhysicalObject>(); rigidbody = physicalObject.body.GetComponent <Rigidbody2D>(); players = GameObject.FindGameObjectsWithTag("Player"); }
public virtual void GrabObject(PhysicalObject obj) { bool flag = true; int num = 0; while (flag && num < pickedUpItemsThisRealization.Count) { if (obj.abstractPhysicalObject.ID == pickedUpItemsThisRealization[num]) { flag = false; } num++; } if (flag) { pickedUpItemsThisRealization.Add(obj.abstractPhysicalObject.ID); } if (obj.graphicsModule != null) { obj.graphicsModule.BringSpritesToFront(); } if (obj is IDrawable) { for (int i = 0; i < oracle.abstractPhysicalObject.world.game.cameras.Length; i++) { oracle.abstractPhysicalObject.world.game.cameras[i].MoveObjectToContainer(obj as IDrawable, null); } } holdingObject = obj; }
public CombatReport(Mobile attacker, PhysicalObject target, EnumCombatEvent combatEvent, float damage) { AttackerObjectInstanceId = attacker.ObjectInstanceId; TargetObjectInstanceId = target == null ? 0 : target.ObjectInstanceId; CombatEvent = combatEvent; Damage = damage; }
public void Insert([NotNull] PhysicalObject rectF) { if (Nodes[0] != null) { var index = GetIndex(rectF); if (index != -1) { Nodes[index]?.Insert(rectF); return; } } Objects.Add(rectF); if (Objects.Count > MaxObjects && Level < MaxLevels) { if (Nodes[0] == null) { Split(); } var i = 0; while (i < Objects.Count) { var index = GetIndex(Objects[i]); if (index != -1) { Nodes[index]?.Insert(Objects[i]); Objects.RemoveAt(i); } else { i++; } } } }
private void BounceBack(Transform pos, PhysicalObject body) { if (pos.position.z > zoneLimitBounceBack || pos.position.z < -zoneLimitBounceBack) { body.velocity.z = -body.velocity.z; } }
// Start is called before the first frame update void Start() { if (gameObject.GetComponent <PhysicalObject>()) { physicalObject = gameObject.GetComponent <PhysicalObject>(); } }
public AbstractLargePiston(World world, PhysicalObject realizedObject, WorldCoordinate pos, EntityID ID, int originRoom, int placedIndex, bool db, bool dt) : base(world, (AbstractPhysicalObject.AbstractObjectType)patch_AbstractPhysicalObject.AbstractObjectType.LargePiston, realizedObject, pos, ID) { this.originRoom = originRoom; placedObjectIndex = placedIndex; deathmode = db; deathtop = dt; }
public void InformNearby(PhysicalObject po, IMessage message) { // notify all nearby clients int squareX = (int)(po.Position.X - _lowX) / Square.SquareSize; int squareZ = (int)(po.Position.Z - _lowZ) / Square.SquareSize; int i; for (i = -1; i <= 1; i++) { int j; for (j = -1; j <= 1; j++) { // check that neighbor exists if (squareX + i < 0 || squareX + i >= _squaresInX || squareZ + j < 0 || squareZ + j >= _squaresInZ || _square[squareX + i, squareZ + j] == null) { continue; } // need to send a message to all nearby clients // so long as the square isn't empty _square[squareX + i, squareZ + j].NotifyClients(message); } } }
public static IPO Read(EndianBinaryReader reader, Pointer offset, SuperObject so) { MapLoader l = MapLoader.Loader; IPO ipo = new IPO(offset, so); ipo.off_data = Pointer.Read(reader); ipo.off_radiosity = Pointer.Read(reader); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); ipo.name = "IPO"; if (l.mode == MapLoader.Mode.Rayman3GC) { ipo.name = new string(reader.ReadChars(0x32)).TrimEnd('\0'); } Pointer.Goto(ref reader, ipo.off_data); ipo.data = PhysicalObject.Read(reader, ipo.off_data); if (ipo.data != null) { ipo.data.Gao.transform.parent = ipo.Gao.transform; } /*if (ipo.data != null && ipo.data.visualSet.Count > 0) { * if (ipo.data.visualSet[0].obj is R3Mesh) { * GameObject meshGAO = ((R3Mesh)ipo.data.visualSet[0].obj).gao; * meshGAO.transform.parent = ipo.Gao.transform; * } * }*/ return(ipo); }
private void Shoot() { List <Asteroid> lPossibleTargets = GameRoom.GetObjectsOfType <Asteroid>().ToList(); lPossibleTargets.RemoveAll(x => mTargetedObjects.Contains(x)); if (lPossibleTargets != null) { if (lPossibleTargets.Count > 0) { //PhysicalObject lTarget = lPossibleTargets.OrderBy(x => this.SquaredDistance(x)).First(); PhysicalObject lTarget = lPossibleTargets.OrderByDescending(x => x.Size).First(); double lDirectionToTarget = 180 / Math.PI * Math.Atan2(lTarget.Position.Y - Position.Y, lTarget.Position.X - Position.X); GuidedMissile lNewMissile = new GuidedMissile(32, 12, mProjectileImage, this.Position, mAimDirection, 12, 8); lNewMissile.Target = lTarget; lNewMissile.Owner = this.Owner; lNewMissile.DestroyedEvent += OnMisileDestroyed; lTarget.DestroyedEvent += OnTargetDestroyed; mTargetedObjects.Add(lTarget); RaiseRoomActionEvent(ERoomAction.AddObject, lNewMissile); } } }
public PhysicalObjectInstance Add(PhysicalObject po) { if (po is Terrain) { Terrain t = (Terrain)po; TerrainPieces.Add(t); //WorldTerrain.SetHeight( po.Position.X, po.Position.Z, po.Position.Y ); //WorldTerrain.SetTexture( po.Position.X, po.Position.Z, Resources.GetTexture( po.ResourceID ), po.Rotation.Y ); return(null); } else { if (RenderingScene.Models.Contains(po.ObjectInstanceID)) { Log.WarningMessage("Trying to add existing PhysicalObject " + po.ObjectInstanceID); return((PhysicalObjectInstance)physicalObjectInstances[po.ObjectInstanceID]); } PhysicalObjectInstance poi; try { poi = new PhysicalObjectInstance(po, Resources); } catch (Exception e) { Log.ErrorMessage(e); return(null); } physicalObjectInstances.Add(po.ObjectInstanceID, poi); RenderingScene.Models.Add(po.ObjectInstanceID, poi.model); poi.model.Position = po.Position; poi.model.Rotation = po.Rotation; return(poi); } }
// I don't even know what this is yet here I am parsing it public static PatchGeometricObject Read(Reader reader, PhysicalObject po, Pointer offset) { MapLoader l = MapLoader.Loader; //Debug.LogWarning("Unknown object @ " + offset); PatchGeometricObject patch = new PatchGeometricObject(po, offset); patch.off_geometricObject = Pointer.Read(reader); patch.num_properties = reader.ReadUInt32(); patch.off_properties = Pointer.Read(reader); Pointer.DoAt(ref reader, patch.off_properties, () => { patch.properties = new PatchGeometricObjectProperty[patch.num_properties]; for (int i = 0; i < patch.num_properties; i++) { patch.properties[i] = new PatchGeometricObjectProperty(); patch.properties[i].ind_vertex = reader.ReadUInt16(); patch.properties[i].unk = reader.ReadUInt16(); float x = reader.ReadSingle(); float z = reader.ReadSingle(); float y = reader.ReadSingle(); patch.properties[i].pos = new Vector3(x, y, z); //l.print(mod.off_geometricObject + ": " + mod.properties[i].ind_vertex + " - " + mod.properties[i].unk + " - " + mod.properties[i].pos); } }); /*Pointer.DoAt(ref reader, mod.off_geometricObject, () => { * mod.mesh = GeometricObject.Read(reader, mod.off_geometricObject); * mod.mesh.Gao.name += " - " + mod.offset; * });*/ return(patch); }
private void Awake() { body = GetComponent <PhysicalObject>(); horns = GetComponentInChildren <Plane>(); gm = FindObjectOfType <GameManager>(); Cursor.lockState = CursorLockMode.Locked; }
private void CollisionWithProjectile(PhysicalObject o) { if (o is BasicProjectile) { (o as BasicProjectile).Owner.Score.Points += (int)(Image.Width * 10 * mSettings.PointsMultiplier); mHealth -= mSettings.ProjectileDamage; } if (o is GuidedMissile) { (o as GuidedMissile).Owner.Score.Points += (int)(Image.Width * 10 * mSettings.PointsMultiplier); mHealth -= mSettings.MissileDamage; } if (mHealth <= 0) { if (mSettings.Size > mSettings.MinSizeForChildren) { Destroy(); DestroyEffect(); //CreateChildren(); } else { Destroy(); DestroyEffect(); } } }
public OnCollosionEventArgs( [NotNull] PhysicalObject thisObj, [NotNull] PhysicalObject thatObj) { ThisObject = thisObj; ThatObject = thatObj; }
private bool DrawHandle(PhysicalObject CurrObj, GraphicsDevice gdDevice, SpriteBatch dbDraw) { //Debug stuff to help with movement algorithm /* * if (cTarget != null) { * DrawTools.DrawLine(gdDevice, dbDraw, Color.Red, 2, CenterPoint, cTarget.CenterPoint); * } * * if (cAvoid != null) { * DrawTools.DrawLine(gdDevice, dbDraw, Color.Cyan, 2, CenterPoint, cAvoid.CenterPoint); * } */ Vector vHealthBar = new Vector(); Vector2 vHealthStart, vHealthEnd; vHealthBar.SetPolarCoordinates(50f * (cnHealth / 100f), 0); vHealthStart = CenterPoint + new Vector2(-25, 25); vHealthEnd = vHealthStart + new Vector2((float)vHealthBar.Rectangular.Real, (float)vHealthBar.Rectangular.Imaginary); DrawTools.DrawLine(gdDevice, dbDraw, Color.Red, 5, vHealthStart, vHealthEnd); return(true); }
internal int GetIndex([NotNull] PhysicalObject rectF) { var index = -1; var verticalMidpoint = Bounds.X + Bounds.Width / 2; var horizontalMidpoint = Bounds.Y + Bounds.Height / 2; if (rectF.X < verticalMidpoint && rectF.X + rectF.Width < verticalMidpoint) { if (rectF.Y < horizontalMidpoint && rectF.Height < horizontalMidpoint) { index = 1; } else if (rectF.Y > horizontalMidpoint) { index = 2; } } else if (rectF.X > verticalMidpoint) { if (rectF.Y < horizontalMidpoint && rectF.Height < horizontalMidpoint) { index = 0; } else if (rectF.Y > horizontalMidpoint) { index = 3; } } return(index); }
private bool IsVisible(PhysicalObject obj) { return(obj != this.owner && !obj.IsAwaitingDeletion && (obj is FixedObstacle || obj is Boat || obj is Projectile) && Vector2.DistanceSquared(obj.Position, this.owner.Position) <= this.radiusSquared); }
public override void ReportCollision(GameTime CurrTime, PhysicalObject oCollider) { ctHitFlashUntil = CurrTime.TotalGameTime.TotalMilliseconds + ctHitFlashDuration; //Figure out what hit this and apply damage? if (oCollider is Projectile_t) { switch (((Projectile_t)oCollider).ProjectileType) { case eProjectileType_t.Straight: cnHealth -= 15; break; case eProjectileType_t.Tracking: cnHealth -= 10; break; default: break; } if (cnHealth < 0) { cnHealth = 0; } } return; }
public PhysicalObjectInstance Add( PhysicalObject po ) { if ( po is Terrain ) { Terrain t = (Terrain)po; TerrainPieces.Add( t ); //WorldTerrain.SetHeight( po.Position.X, po.Position.Z, po.Position.Y ); //WorldTerrain.SetTexture( po.Position.X, po.Position.Z, Resources.GetTexture( po.ResourceID ), po.Rotation.Y ); return null; } else { if ( RenderingScene.Models.Contains( po.ObjectInstanceID ) ) { Log.WarningMessage( "Trying to add existing PhysicalObject " + po.ObjectInstanceID ); return (PhysicalObjectInstance)physicalObjectInstances[po.ObjectInstanceID]; } PhysicalObjectInstance poi; try { poi = new PhysicalObjectInstance( po, Resources ); } catch ( Exception e ) { Log.ErrorMessage( e ); return null; } physicalObjectInstances.Add( po.ObjectInstanceID, poi ); RenderingScene.Models.Add( po.ObjectInstanceID, poi.model ); poi.model.Position = po.Position; poi.model.Rotation = po.Rotation; return poi; } }
void OnTriggerEnter(Collider c) { if (detachableMag && !attachMagazine) { Magazine tempMagazine = c.GetComponentInParent <Magazine> (); if (tempMagazine && tempMagazine.ammoType == ammoType) { //игнор колайтеров магазина myCollidersToIgnore = GetComponentInParent <PrimitiveWeapon> ().gameObject.GetComponentsInChildren <Collider> (); for (int j = 0; j < myCollidersToIgnore.Length; j++) { for (int k = 0; k < tempMagazine.MagazineColliders.Length; k++) { Physics.IgnoreCollision(myCollidersToIgnore[j], tempMagazine.MagazineColliders[k]); } } PhysicalObject tempPhysicalObject = tempMagazine.GetComponent <PhysicalObject>(); if (tempPhysicalObject) { tempPhysicalObject.DettachHands(); tempPhysicalObject.MyRigidbody.isKinematic = true; } tempMagazine.transform.parent = magazineAttachPoint; tempMagazine.transform.localPosition = Vector3.zero; tempMagazine.transform.localRotation = Quaternion.identity; attachMagazine = tempMagazine; tempMagazine.primitiveWeapon = this; tempMagazine.canLoad = false; MagazineLoad.Invoke(); return; } } }
public ESector CreateESector(Sector sector) { ESector eSector = new ESector() { SkyMaterial = sector.skyMaterial, SectorBorder = sector.sectorBorder, LightReferences = sector.staticLights.Select(l => l.Offset.ToString()).ToList(), Neighbours = sector.neighbors.Select(n => n.sector.offset.ToString()).ToList() }; eSector.Geometry = new Dictionary <string, EGeometry>(); foreach (SuperObject spo in sector.SuperObject.children) { IPO ipo = spo.data as IPO; if (ipo != null) // If IPO { EGeometry eg = new EGeometry(); PhysicalObject po = ipo.data; if (po.visualSet.Length > 0) { eg.Visuals = po.visualSet[0].obj as GeometricObject; eg.Collision = po.collideMesh; } eSector.Geometry.Add(ipo.offset.ToString(), eg); } } return(eSector); }
public bool NetGrab(PhysicalObject obj, int graspUsed, int chunkGrabbed, Creature.Grasp.Shareability shareability, float dominance, bool pacifying) { if (this.grasps[graspUsed] != null && this.grasps[graspUsed].grabbed == obj) { this.NetRelease(graspUsed); this.grasps[graspUsed] = new Creature.Grasp(this, obj, graspUsed, chunkGrabbed, shareability, dominance, true); obj.Grabbed(this.grasps[graspUsed]); new AbstractPhysicalObject.CreatureGripStick(this.abstractCreature, obj.abstractPhysicalObject, graspUsed, pacifying || obj.TotalMass < base.TotalMass); return(true); } for (int i = obj.grabbedBy.Count - 1; i >= 0; i--) { if (obj.grabbedBy[i].ShareabilityConflict(shareability)) { obj.grabbedBy[i].Release(); } } if (this.grasps[graspUsed] != null) { this.NetRelease(graspUsed); } this.grasps[graspUsed] = new Creature.Grasp(this, obj, graspUsed, chunkGrabbed, shareability, dominance, pacifying); obj.Grabbed(this.grasps[graspUsed]); new AbstractPhysicalObject.CreatureGripStick(this.abstractCreature, obj.abstractPhysicalObject, graspUsed, pacifying || obj.TotalMass < base.TotalMass); return(true); }
public LightWormGraphics(PhysicalObject ow) : base(ow, false) { numberOfWavesOnBody = 1.8f; sinSpeed = 0.0166666675f; swallowArray = new float[worm.tentacle.tChunks.Length]; cullRange = 1000f; }
private void CollisionWithAsteroid(PhysicalObject o) { if (o is Asteroid) { if (Strength > (o as Asteroid).Strength) { mHealth -= (o as Asteroid).Size / ((o as Asteroid).Size + Size); } else { mHealth = 0; } if (mHealth <= 0) { if (mSettings.Size > mSettings.MinSizeForChildren) { Destroy(); DestroyEffect(); CreateChildren(); } else { Destroy(); DestroyEffect(); } } } }
private static PhysicalObject Player_PickupCandidate(On.Player.orig_PickupCandidate orig, Player self, float favorSpears) { PhysicalObject result = null; float num = float.MaxValue; for (int i = 0; i < self.room.physicalObjects.Length; i++) { for (int j = 0; j < self.room.physicalObjects[i].Count; j++) { if ((!(self.room.physicalObjects[i][j] is PlayerCarryableItem) || (self.room.physicalObjects[i][j] as PlayerCarryableItem).forbiddenToPlayer < 1) && Custom.DistLess(self.bodyChunks[0].pos, self.room.physicalObjects[i][j].bodyChunks[0].pos, self.room.physicalObjects[i][j].bodyChunks[0].rad + 40f) && (Custom.DistLess(self.bodyChunks[0].pos, self.room.physicalObjects[i][j].bodyChunks[0].pos, self.room.physicalObjects[i][j].bodyChunks[0].rad + 20f) || self.room.VisualContact(self.bodyChunks[0].pos, self.room.physicalObjects[i][j].bodyChunks[0].pos)) && self.CanIPickThisUp(self.room.physicalObjects[i][j])) { if (!(self.room.physicalObjects[i][j] is Spear) || (self.room.physicalObjects[i][j] as Spear).mode != Weapon.Mode.StuckInWall || CanAffordPull(self)) //"Don't pickup spear in wall unless affordable" { float num2 = Vector2.Distance(self.bodyChunks[0].pos, self.room.physicalObjects[i][j].bodyChunks[0].pos); if (self.room.physicalObjects[i][j] is Spear) { num2 -= favorSpears; } if (self.room.physicalObjects[i][j].bodyChunks[0].pos.x < self.bodyChunks[0].pos.x == self.flipDirection < 0) { num2 -= 10f; } if (num2 < num) { result = self.room.physicalObjects[i][j]; num = num2; } } } } } return(result); }
static void Main() { ClientRepository client = new IndividualClient(); DataObject obj = new PhysicalObject(); client.Buy(obj); client.Borrow(obj); }
//TODO: if we don't actuall put the inital values we want in here, should the v argument be removed? public TreeVector2Member(PhysicalObject obj, Vector2 v) : base(obj) { simulationValue = v; drawValue = v; previousValue = v; this.obj = obj; this.collection = obj.Collection; }
public void Add( PhysicalObject po ) { if ( po is Terrain ) { Terrain t = (Terrain)po; terrainPieces.Add( new TerrainPiece( t.ObjectInstanceID, t.Position.X, t.Position.Z, t.Position.Y, t.ModelID ) ); } else { PhysicalObjectInstance poi = new PhysicalObjectInstance( po ); physicalObjectInstances.Add( po.ObjectInstanceID, poi ); scene.Models.Add( po.ObjectInstanceID, poi.model ); poi.model.Position = po.Position; poi.model.Rotation = po.Rotation; } }
private Vector3 vel; //Local class velocity for projectile only behaviours #endregion Fields #region Constructors /// <summary> /// Create a new projectile. /// </summary> /// <param name="game"></param> /// <param name="myModel"></param> /// <param name="pos"></param> /// <param name="vel"></param> /// <param name="targetType"></param> public Projectile(LabGame game, MyModel myModel, Vector3 pos, Vector3 vel, PhysicalObject shooter) { this.game = game; this.myModel = myModel; this.pos = pos; this.vel = vel; this.shooter = shooter; this.locallight.lightPos = new Vector4(this.pos.X, this.pos.Y, this.pos.Z - 2, 1f); this.locallight.lightCol = new Vector4(0.15f, 0.15f, 0.15f, 1f); squareHitRadius = hitRadius * hitRadius; GetParamsFromModel(); initPos = pos; }
// Terrain model loading occurs in TerrainCollection, // everything else gets it model loaded upon creation. public PhysicalObjectInstance( PhysicalObject po, ResourceManager rm ) { physicalObject = po; if ( !(po is Terrain) ) { if ( po is Mobile ) { model = rm.GetActor( po.ObjectInstanceID, po.ResourceID, po.Height ); } else { model = rm.GetModel( po.ObjectInstanceID, po.ResourceID, po.Height ); } // TODO: just for testing, show junk //if ( !(po is Junk) ) { model.Label = po.TemplateObjectName; //} } }
public static IMessage CreateMessage(PhysicalObject po) { if (po is Equipable) return new AddEquipable((Equipable)po); if (po is Junk) return new AddJunk((Junk)po); if (po is Mobile) return new AddMobile((Mobile)po); if (po is Quaffable) return new AddQuaffable((Quaffable)po); if (po is Readable) return new AddReadable((Readable)po); if (po is Terrain) return new AddTerrain((Terrain)po); if (po is Wieldable) return new AddWieldable((Wieldable)po); throw new Exception("AddPhysicalObject of unknown type " + po.GetType()); }
public void Add(PhysicalObject po) { if (po.Position.X > _highX || po.Position.Z > _highZ || po.Position.X < _lowX || po.Position.Z < _lowZ) { _log.Error("Tried to add physical object " + po.ObjectInstanceId + " outside the world."); return; } if (po is Terrain) { // keep terrain separate int terrainX = DivTruncate((int)(po.Position.X - _lowX), Constants.TerrainPieceSize); int terrainZ = DivTruncate((int)(po.Position.Z - _lowZ), Constants.TerrainPieceSize); _terrain[terrainX, terrainZ] = (Terrain)po; } else { // keep everything at ground level double? altitude = AltitudeAt(po.Position.X, po.Position.Z); if (altitude.HasValue) po.Position.Y = altitude.Value + po.Height / 2F; else _log.Warn("Physical object " + po.ObjectInstanceId + " is not on terrain."); // add the object to the world PhysicalObjects.Add(po.ObjectInstanceId, po); if (po is MobileAvatar) Mobiles.Add((MobileAvatar)po); int squareX = (int)(po.Position.X - _lowX) / Square.SquareSize; int squareZ = (int)(po.Position.Z - _lowZ) / Square.SquareSize; if (_square[squareX, squareZ] == null) _square[squareX, squareZ] = new Square(); _square[squareX, squareZ].Add(po); } // notify all nearby clients that a new // physical object has entered the world InformNearby(po, ToClient.AddPhysicalObject.CreateMessage(po)); //Log.Info( "Added new " + po.GetType() + " " + po.ObjectInstanceID + " at (" + po.Position.X + "," + po.Position.Y + "," +po.Position.Z + ") - ("+squareX+","+squareZ+")" ); }
public void Remove(PhysicalObject po) { int squareX = (int)(po.Position.X - _lowX) / Square.SquareSize; int squareZ = (int)(po.Position.Z - _lowZ) / Square.SquareSize; InformNearby(po, new ToClient.DropPhysicalObject(po)); _square[squareX, squareZ].Remove(po); PhysicalObjects.Remove(po.ObjectInstanceId); if (po is MobileAvatar) Mobiles.Remove((MobileAvatar)po); _log.Info("Removed " + po.GetType() + " " + po.ObjectInstanceId + " from the world."); }
public void Relocate(PhysicalObject po, Vector3D newPosition, Quaternion newRotation) { // keep everything inside world bounds if (newPosition.X >= _highX) newPosition.X = (float)_highX - 1; if (newPosition.Z >= _highZ) newPosition.Z = (float)_highZ - 1; if (newPosition.X <= _lowX) newPosition.X = (float)_lowX + 1; if (newPosition.Z <= _lowZ) newPosition.Z = (float)_lowZ + 1; int fromSquareX = (int)(po.Position.X - _lowX) / Square.SquareSize; int fromSquareZ = (int)(po.Position.Z - _lowZ) / Square.SquareSize; int toSquareX = (int)(newPosition.X - _lowX) / Square.SquareSize; int toSquareZ = (int)(newPosition.Z - _lowZ) / Square.SquareSize; int i, j; // TODO: disallow the relocation if it is outside terrain //return; // keep everything on the ground // TODO: re-factor below ma and overload Height double? altitude = AltitudeAt(newPosition.X, newPosition.Z); if (altitude.HasValue) { if (po is MobileAvatar) altitude += ((MobileAvatar)po).CurrentHeight / 2; else altitude += po.Height / 2; newPosition.Y = altitude.Value; } var ma = po as MobileAvatar; // check that the object can fit there // TODO: revisit /** TODO: for ( i=-1; i<=1; i++ ) { for ( j=-1; j<=1; j++ ) { if ( toSquareX+i < 0 || toSquareX+i >= squaresInX || toSquareZ+j < 0 || toSquareZ+j >= squaresInZ || square[toSquareX+i,toSquareZ+j] == null ) continue; foreach ( PhysicalObject spo in square[toSquareX+i,toSquareZ+j].physicalObjects ) { // ignoring yourself if ( spo == po ) continue; // distance between two objects in 2d space float dx = newPosition.X - spo.Position.X; float dy = newPosition.Y - spo.Position.Y; float dz = newPosition.Z - spo.Position.Z; float distance_squared = dx*dx + dy*dy + dz*dz; if ( distance_squared <= spo.BoundingSphereRadiusSquared + po.BoundingSphereRadiusSquared ) { // only if not already collided! float dx1 = po.Position.X - spo.Position.X; float dy1 = po.Position.Y - spo.Position.Y; float dz1 = po.Position.Z - spo.Position.Z; float distance_squared2 = dx1*dx1 + dy1*dy1 + dz1*dz1; if ( distance_squared2 <= spo.BoundingSphereRadiusSquared + po.BoundingSphereRadiusSquared ) { continue; } if ( ma != null && ma.client != null ) { ma.client.Send( new ToClient.Position( ma ) ); return; } } } } } */ // send everything nearby //public void server_foo(float x1, float z1, float x, float z) { if (ma != null && ma.Client != null && po.Position != newPosition) { int tx1 = DivTruncate((int)po.Position.X, Constants.TerrainPieceSize); int tz1 = DivTruncate((int)po.Position.Z, Constants.TerrainPieceSize); for (int k = 0; k < Constants.TerrainZoomOrder; k++) { int tbx = DivTruncate((int)newPosition.X, Constants.TerrainPieceSize) - Constants.xRadius[k]; int tbz = DivTruncate((int)newPosition.Z, Constants.TerrainPieceSize) - Constants.zRadius[k]; // Normalize to a 'grid' point tbx = DivTruncate(tbx, Constants.scale[k]) * Constants.scale[k]; tbz = DivTruncate(tbz, Constants.scale[k]) * Constants.scale[k]; for (i = 0; i <= Constants.xRadius[k] * 2; i += Constants.scale[k]) { for (j = 0; j <= Constants.zRadius[k] * 2; j += Constants.scale[k]) { int tx = tbx + i; int tz = tbz + j; if ((Math.Abs(tx - tx1) > Constants.xRadius[k]) || (Math.Abs(tz - tz1) > Constants.zRadius[k])) { int terrainX = tx - (int)_lowX / Constants.TerrainPieceSize; int terrainZ = tz - (int)_lowZ / Constants.TerrainPieceSize; if (terrainX >= 0 && terrainX < _squaresInX * Square.SquareSize / Constants.TerrainPieceSize && terrainZ >= 0 && terrainZ < _squaresInZ * Square.SquareSize / Constants.TerrainPieceSize) { Terrain t = _terrain[terrainX, terrainZ]; if (t != null) { if (// there is no higher zoom order k == (Constants.TerrainZoomOrder - 1) // this is not a higher order point || (tx % Constants.scale[k + 1]) != 0 || (tz % Constants.scale[k + 1]) != 0) ma.Client.Send(ToClient.AddPhysicalObject.CreateMessage(t)); } } } } } } } //} po.Position = newPosition; po.Rotation = newRotation; for (i = -1; i <= 1; i++) { for (j = -1; j <= 1; j++) { if (Math.Abs(fromSquareX + i - toSquareX) > 1 || Math.Abs(fromSquareZ + j - toSquareZ) > 1) { // squares which need to have their clients // add or remove the object // as the jump has brought the object in or out of focus /**** let the client remove them // remove from if ( // check the square exists fromSquareX+i >= 0 && fromSquareX+i < squaresInX && fromSquareZ+j >= 0 && fromSquareZ+j < squaresInZ && square[fromSquareX+i, fromSquareZ+j] != null ) { square[fromSquareX+i, fromSquareZ+j].NotifyClients( new ToClient.DropPhysicalObject( po ) ); // if the object is a mobile, it needs to be made aware // of its new world view if ( ma != null && ma.client != null ) { foreach( PhysicalObject toDrop in square[fromSquareX+i, fromSquareZ+j].physicalObjects ) { // Don't drop terrain, client is responsible for that if ( toDrop is Terrain ) continue; ma.client.Send( new ToClient.DropPhysicalObject( toDrop ) ); //Log.Info( "Told client to drop " + toDrop.ObjectInstanceID + "." ); } } } ***/ // add to if (// check the square exists toSquareX - i >= 0 && toSquareX - i < _squaresInX && toSquareZ - j >= 0 && toSquareZ - j < _squaresInZ && _square[toSquareX - i, toSquareZ - j] != null) { _square[toSquareX - i, toSquareZ - j].NotifyClients(ToClient.AddPhysicalObject.CreateMessage(po)); // if the object is a player, it needs to be made aware // of its new world view if (ma != null && ma.Client != null) { foreach (PhysicalObject toAdd in _square[toSquareX - i, toSquareZ - j].PhysicalObjects) { ma.Client.Send(ToClient.AddPhysicalObject.CreateMessage(toAdd)); //Log.Info( "Told client to add " + toAdd.ObjectInstanceID + "." ); } } } } else { // clients that have the object already in scope need to be // told its new position if (// check the square exists toSquareX + i >= 0 && toSquareX + i < _squaresInX && toSquareZ + j >= 0 && toSquareZ + j < _squaresInZ && _square[toSquareX + i, toSquareZ + j] != null) { if (ma != null && ma.Client != null) _square[toSquareX + i, toSquareZ + j].NotifyClientsExcept( new ToClient.PositionUpdate(po), ma.Client); else _square[toSquareX + i, toSquareZ + j].NotifyClients( new ToClient.PositionUpdate(po)); } } } } // transition the object to its new square if it changed squares if (fromSquareX != toSquareX || fromSquareZ != toSquareZ) { _square[fromSquareX, fromSquareZ].Remove(po); if (_square[toSquareX, toSquareZ] == null) _square[toSquareX, toSquareZ] = new Square(); _square[toSquareX, toSquareZ].Add(po); } }
public void InformNearby(PhysicalObject po, IMessage message) { // notify all nearby clients int squareX = (int)(po.Position.X - _lowX) / Square.SquareSize; int squareZ = (int)(po.Position.Z - _lowZ) / Square.SquareSize; int i; for (i = -1; i <= 1; i++) { int j; for (j = -1; j <= 1; j++) { // check that neighbor exists if (squareX + i < 0 || squareX + i >= _squaresInX || squareZ + j < 0 || squareZ + j >= _squaresInZ || _square[squareX + i, squareZ + j] == null) continue; // need to send a message to all nearby clients // so long as the square isn't empty _square[squareX + i, squareZ + j].NotifyClients(message); } } }
public RealProg(Renderer _renderer) { renderer = _renderer; renderer.cameraPosition.Z = -15; Shader myder = renderer.createBasicShader(); //Uncomment for AABB collisions // physicsworld.testtype = CollisionTestType.AABB; myder.Draw(); Bitmap mmap = new Bitmap("pic.jpg"); Texture2D mtex = renderer.createTextureFromBitmap(mmap); mtex.Draw(); rtex = renderer.createTexture(512, 512); rtex.Draw(); Mesh[] meshes = Primitives.LoadMesh("playercube.obj", flip); collisiontester = new PhysicalObject(meshes[0].meshverts, 5, CollisionType.Dynamic, physicsworld); collisiontester.Position = new Vector3D(-5, 0, 0); mainmesh = meshes[0]; foreach (Mesh mesh in meshes) { VertexBuffer tbuff = renderer.CreateVertexBuffer(mesh.meshverts, mesh.meshtexas, mesh.meshnorms); rotatingbuffer = tbuff; if (mesh.bitmap != null) { Console.WriteLine("BITMAP RENDER"); Texture2D tt = renderer.createTextureFromBitmap(mesh.bitmap); tt.Draw(); } tbuff.Draw(); } mtex.Draw(); Mesh cube = Primitives.LoadMesh("playercube.obj", flip)[0]; theobject = new PhysicalObject(cube.meshverts, 9, CollisionType.Dynamic, physicsworld); collisiontester.ownedVBO = rotatingbuffer; theobject.ownedVBO = renderer.CreateVertexBuffer(cube.meshverts, cube.meshtexas, cube.meshnorms); theobject.ownedVBO.Draw(); physicsworld.physicalobjects.Add(theobject); physicsworld.physicalobjects.Add(collisiontester); Mesh anothercube = Primitives.LoadMesh("playercube.obj", flip)[0]; PhysicalObject mobject = new PhysicalObject(anothercube.meshverts.Clone() as Vector3D[], 1, CollisionType.Dynamic, physicsworld); mobject.ownedVBO = renderer.CreateVertexBuffer(anothercube.meshverts, anothercube.meshtexas, anothercube.meshnorms); physicsworld.physicalobjects.Add(mobject); mobject.ownedVBO.Draw(); mobject.Position = new Vector3D(30, 0, 0); //Set physics properties theobject.Weight = 1; collisiontester.Weight = 1; //collisiontester.Velocity = new Vector3D(.05f, 0, 0); theobject.Position = new Vector3D(15, 0, 0); theobject.IsCube = true; theobject.Weight = 9999999; mobject.IsCube = true; //End physics properties physicsworld.Start(); physicsworld.physicsUpdateFrame += new System.Threading.ThreadStart(physicsworld_physicsUpdateFrame); System.Threading.Thread mthread = new System.Threading.Thread(thetar); mthread.Start(); #if PHONE renderer.defaultTouchpad.onTouchMoved += new TouchEvent(defaultTouchpad_onTouchMoved); renderer.defaultTouchpad.onTouchFound += new TouchEvent(defaultTouchpad_onTouchFound); renderer.defaultTouchpad.onTouchLost += new TouchEvent(defaultTouchpad_onTouchLost); #endif #if !PHONE renderer.defaultKeyboard.onKeyDown += new keyboardeventargs(defaultKeyboard_onKeyDown); renderer.defaultKeyboard.onKeyUp += new keyboardeventargs(defaultKeyboard_onKeyUp); renderer.defaultMouse.onMouseMove += new mouseEvent(defaultMouse_onMouseMove); renderer.defaultMouse.onMouseDown += new mouseEvent(defaultMouse_onMouseDown); #endif }
static void defaultMouse_onMouseDown(MouseButton btn, int x, int y) { lock (physicsworld.physicalobjects) { Mesh tmesh = Primitives.LoadMesh("playercube.obj", flip)[0]; PhysicalObject mobject = new PhysicalObject(tmesh.meshverts, 1, CollisionType.Dynamic, physicsworld); mobject.IsCube = true; mobject.ownedVBO = renderer.CreateVertexBuffer(tmesh.meshverts, tmesh.meshtexas, tmesh.meshnorms); mobject.ownedVBO.Draw(); physicsworld.physicalobjects.Add(mobject); mobject.Position = renderer.cameraPosition; if (btn == MouseButton.Left) { mobject.Velocity = Vector3D.ComputeRotation(renderer.worldRotation); } else { mobject.Weight = 3f; } } }
bool MightIntersect(PhysicalObject pobject) { if (boundingBox.PointWithin(pobject.boundingBox.maxX) || boundingBox.PointWithin(pobject.boundingBox.maxY) || boundingBox.PointWithin(pobject.boundingBox.maxZ) || boundingBox.PointWithin(pobject.boundingBox.minX) || boundingBox.PointWithin(pobject.boundingBox.minY) || boundingBox.PointWithin(pobject.boundingBox.minZ) || boundingBox.PointWithin(pobject.boundingBox.minX.Center(pobject.boundingBox.maxX)) || boundingBox.PointWithin(pobject.boundingBox.minY.Center(pobject.boundingBox.maxY)) ||boundingBox.PointWithin(pobject.boundingBox.minZ.Center(pobject.boundingBox.maxZ))) { return true; } else { return false; } }
public bool Contains(PhysicalObject pobject) { if (MightIntersect(pobject)) { if (internworld.testtype == CollisionTestType.AABB || IsCube) { return true; } foreach (Vector3D vert in pobject.internverts) { if (Contains(vert)) { return true; } } } return false; }
public RealProg(Renderer renderer) { Shader myder = renderer.createBasicShader(); World physicsworld = new World(); //Uncomment for AABB collisions // physicsworld.testtype = CollisionTestType.AABB; myder.Draw(); Texture2D mtex = renderer.createTexture(512, 512); mtex.Draw(); Mesh[] meshes = Primitives.LoadMesh("test.obj"); collisiontester = new PhysicalObject(meshes[0].meshverts, 5, CollisionType.Dynamic, physicsworld); mainmesh = meshes[0]; foreach (Mesh mesh in meshes) { VertexBuffer tbuff = renderer.CreateVertexBuffer(mesh.meshverts, mesh.meshtexas, mesh.meshnorms); rotatingbuffer = tbuff; if (mesh.bitmap != null) { Console.WriteLine("BITMAP RENDER"); Texture2D tt = renderer.createTextureFromBitmap(mesh.bitmap); tt.Draw(); } tbuff.Draw(); } Mesh cube = Primitives.LoadMesh("playercube.obj")[0]; theobject = new PhysicalObject(cube.meshverts, 9, CollisionType.Dynamic, physicsworld); collisiontester.ownedVBO = rotatingbuffer; theobject.ownedVBO = renderer.CreateVertexBuffer(cube.meshverts, cube.meshtexas, cube.meshnorms); theobject.ownedVBO.Draw(); physicsworld.physicalobjects.Add(theobject); physicsworld.physicalobjects.Add(collisiontester); //theobject.Velocity = new Vector3D(-.01f, 0, 0); Mesh anothercube = Primitives.LoadMesh("playercube.obj")[0]; PhysicalObject mobject = new PhysicalObject(anothercube.meshverts.Clone() as Vector3D[], 1, CollisionType.Dynamic, physicsworld); mobject.ownedVBO = renderer.CreateVertexBuffer(anothercube.meshverts, anothercube.meshtexas, anothercube.meshnorms); physicsworld.physicalobjects.Add(mobject); mobject.ownedVBO.Draw(); mobject.Position = new Vector3D(30, 0, 0); //Set physics properties // collisiontester.Velocity = new Vector3D(.2f, 0, 0); theobject.Weight = 1; //Uncomment for an inelastic collision //collisiontester.mode = CollisionMode.Inelastic; collisiontester.Weight = 1; collisiontester.Velocity = new Vector3D(.05f, 0, 0); theobject.Position = new Vector3D(15, 0, 0); //collisiontester.Velocity = new Vector3D(-.2f, 0, 0); //End physics properties physicsworld.Start(); List<Vector3D> vectors = new List<Vector3D>(); List<Vector2D> texcoords = new List<Vector2D>(); List<Vector3D> normals = new List<Vector3D>(); for (int i = 0; i < 3; i++) { normals.Add(new Vector3D(1, 1, 1)); } vectors.Add(new Vector3D(0, 0, 0)); vectors.Add(new Vector3D(8, 0, 0)); vectors.Add(new Vector3D(8, 8, 0)); texcoords.Add(new Vector2D(0, 0)); texcoords.Add(new Vector2D(1, 0)); texcoords.Add(new Vector2D(1, 1)); VertexBuffer tribuffer = renderer.CreateVertexBuffer(vectors.ToArray(), texcoords.ToArray(), normals.ToArray()); tribuffer.DepthTesting = false; tribuffer.IsStatic = true; tribuffer.Draw(); renderer.cameraPosition.Z = -25; renderer.cameraPosition.X = -16; //Primitives.createRectangle(renderer, 0, 0, 0, 10, 10).Draw(); System.Threading.Thread mthread = new System.Threading.Thread(thetar); mthread.Start(); }
public PhysicalObjectInstance( PhysicalObject po ) { physicalObject = po; model = ResourceManager.LoadModel( po.ObjectInstanceID, po.ModelID ); }
protected LoweringContext(PhysicalObject parentObject) { ParentObject = parentObject; }
public static void Main(string[] args) { try { // throw new Exception(); renderer = new DirectXLib.DirectEngine(); flip = true; }catch(Exception) { renderer = new GLRenderer(); flip = false; } renderer.cameraPosition.Z = -5; Shader myder = renderer.createBasicShader(); //Uncomment for AABB collisions //physicsworld.testtype = CollisionTestType.AABB; myder.Draw(); Bitmap mmap = new Bitmap("pic.jpg"); Texture2D mtex = renderer.createTextureFromBitmap(mmap); Bitmap newmap = new Bitmap("pic.jpg"); Graphics tfix = Graphics.FromImage(newmap); tfix.DrawString("Hello world!", new Font(FontFamily.GenericMonospace, 16), Brushes.Red, new PointF(0, 0)); tfix.Dispose(); mtex.UploadBitmap(newmap); mtex.Draw(); rtex = renderer.createTexture(512, 512); rtex.Draw(); Mesh[] meshes = Primitives.LoadMesh("playercube.obj",flip); collisiontester = new PhysicalObject(meshes[0].meshverts, 5, CollisionType.Dynamic,physicsworld); collisiontester.Position = new Vector3D(-5, 0, 0); mainmesh = meshes[0]; foreach (Mesh mesh in meshes) { VertexBuffer tbuff = renderer.CreateVertexBuffer(mesh.meshverts, mesh.meshtexas, mesh.meshnorms); rotatingbuffer = tbuff; if (mesh.bitmap != null) { Console.WriteLine("BITMAP RENDER"); Texture2D tt = renderer.createTextureFromBitmap(mesh.bitmap); tt.Draw(); } tbuff.Draw(); } mtex.Draw(); Mesh cube = Primitives.LoadMesh("playercube.obj",flip)[0]; theobject = new PhysicalObject(cube.meshverts, 9, CollisionType.Dynamic,physicsworld); collisiontester.ownedVBO = rotatingbuffer; theobject.ownedVBO = renderer.CreateVertexBuffer(cube.meshverts, cube.meshtexas, cube.meshnorms); theobject.ownedVBO.Draw(); physicsworld.physicalobjects.Add(theobject); physicsworld.physicalobjects.Add(collisiontester); Mesh anothercube = Primitives.LoadMesh("playercube.obj",flip)[0]; PhysicalObject mobject = new PhysicalObject(anothercube.meshverts.Clone() as Vector3D[], 1, CollisionType.Dynamic,physicsworld); mobject.ownedVBO = renderer.CreateVertexBuffer(anothercube.meshverts, anothercube.meshtexas, anothercube.meshnorms); physicsworld.physicalobjects.Add(mobject); mobject.ownedVBO.Draw(); mobject.Position = new Vector3D(30, 0, 0); //Set physics properties theobject.Weight = 1; collisiontester.Weight = 1; //collisiontester.Velocity = new Vector3D(.05f, 0, 0); theobject.Position = new Vector3D(15, 0, 0); theobject.IsCube = true; theobject.Weight = 9999999; mobject.IsCube = true; //End physics properties physicsworld.Start(); physicsworld.physicsUpdateFrame += new System.Threading.ThreadStart(physicsworld_physicsUpdateFrame); System.Threading.Thread mthread = new System.Threading.Thread(thetar); mthread.Start(); foreach (Keyboard et in renderer.GetExtensionKeyboards()) { et.onKeyDown += new keyboardeventargs(defaultKeyboard_onKeyDown); et.onKeyUp += new keyboardeventargs(defaultKeyboard_onKeyUp); } renderer.defaultMouse.onMouseMove += new mouseEvent(defaultMouse_onMouseMove); renderer.defaultMouse.onMouseDown += new mouseEvent(defaultMouse_onMouseDown); //Draw a quad List<Vector3D> overts = new List<Vector3D>(); List<Vector3D> onorms = new List<Vector3D>(); List<Vector2D> ocords = new List<Vector2D>(); //Triangle 0 overts.Add(new Vector3D(-1,-1,0)); overts.Add(new Vector3D(-1,1,0)); overts.Add(new Vector3D(1,1,0)); ocords.Add(new Vector2D(0,0)); ocords.Add(new Vector2D(0,1)); ocords.Add(new Vector2D(1,1)); //Triangle 1 overts.Add(new Vector3D(1,1,0)); overts.Add(new Vector3D(1,-1,0)); overts.Add(new Vector3D(-1,-1,0)); ocords.Add(new Vector2D(1,1)); ocords.Add(new Vector2D(1,0)); ocords.Add(new Vector2D(0,0)); float zfactor = 900; for(int i = 0;i<overts.Count;i++) { //Translate by -1 overts[i] = new Vector3D((overts[i].X)*zfactor,(overts[i].Y)*zfactor,overts[i].Z); } for(int i = 0;i<overts.Count;i++) { onorms.Add(new Vector3D(1,1,1)); } mbuff = renderer.CreateVertexBuffer(overts.ToArray(),ocords.ToArray(),onorms.ToArray()); mbuff.IsStatic = true; mbuff.Position.Z = zfactor; //rtex.Draw(); mbuff.Draw(); mtex.Draw(); }
public static void DoKick(MobileAvatar caster, PhysicalObject target) { caster.Kick(target); }
public static void AddPhysicalObject(string objectID, string objectType, string linkedRegion) { if (!physicalObjects.ContainsKey(objectID)) { PhysicalObject e = new PhysicalObject(); e.objectID = objectID; e.objectType = objectType; e.linkedRegion = linkedRegion; physicalObjects[objectID] = e; } }
private bool loadKnownObjects(string fileName) { if (!File.Exists(fileName)) return false; string[] lines = File.ReadAllLines(fileName); string[] parts; char[] delimiters = { ' ', '\t' }; this.knownObjects.Clear(); foreach (string s in lines) { if (s.StartsWith("//")) continue; if (s.Length < 3) continue; parts = s.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); if (parts.Length < 1) continue; if (!this.knownObjects.ContainsKey(parts[0])) { PhysicalObject tempObject = new PhysicalObject(parts[0]); this.knownObjects.Add(parts[0], tempObject); } else TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Repeated HashCode in known objects: \"" + parts[0] + "\""); } if (this.knownObjects.Count < 2) return false; return true; }
public TaskLoweringContext(PhysicalObject parentObject) : base(parentObject) { }