Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
		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;
			}
		}
Ejemplo n.º 3
0
 public void Clear()
 {
     physicalObjectInstances.Clear();
     if (TerrainPieces != null)
     {
         TerrainPieces.Clear();
     }
     CurrentAvatar = null;
     if (RenderingScene != null)
     {
         RenderingScene.DropAll();
     }
     Resources.DropAll();
 }
Ejemplo n.º 4
0
        public void Possess(int ObjectInstanceID)
        {
            Object o = physicalObjectInstances[ObjectInstanceID];

            if (o == null)
            {
                Log.ErrorMessage("Failed to possess " + ObjectInstanceID);
                return;
            }
            CurrentAvatar = (PhysicalObjectInstance)o;
            if (cameraMode == EnumCameraMode.FirstPerson)
            {
                CurrentAvatar.model.Visible = false;
            }
            else
            {
                CurrentAvatar.model.Visible = true;
            }
            RepositionCamera();
        }
Ejemplo n.º 5
0
        void Recenter(float x, float y, float z)
        {
            TerrainPieces.Recenter(x, z);
            ArrayList arrayList = new ArrayList(physicalObjectInstances.Keys);

            foreach (object key in arrayList)
            {
                PhysicalObjectInstance poi = (PhysicalObjectInstance)physicalObjectInstances[key];

                float dist = Math.Max(Math.Abs(x - poi.model.Position.X), Math.Abs(z - poi.model.Position.Z));
                dist = Math.Max(dist, Math.Abs(y - poi.model.Position.Y));

                // TODO: really big object should probabbly have a bigger objectscoperadius,
                // and be visible from further away.
                // For this to be efficient, you would probabbly want big objects stored in different memory structures.

                if (dist > Constants.objectScopeRadius * 2)
                {
                    // TODO: make this area the same as that used by the server,
                    // ie: square delimited
                    Remove(poi.physicalObject.ObjectInstanceID);
                }
                else
                {
                    // TODO: evaluate whether the number of vertices should be proportional to sqrt height.
                    // At least it should be proportional to volume, not just height.
                    int lod_vertices;
                    if (dist == 0)
                    {
                        lod_vertices = Constants.mostDetailedLOD;
                    }
                    else
                    {
                        lod_vertices = (int)(Constants.furthestLOD / dist * Constants.mostDetailedLOD * Math.Sqrt(poi.physicalObject.Height));
                        lod_vertices = Math.Min(lod_vertices, Constants.mostDetailedLOD);
                    }
                    poi.model.SetLOD(lod_vertices);
                }
            }
        }
Ejemplo n.º 6
0
		public void Clear() {
			physicalObjectInstances.Clear();
			if ( TerrainPieces != null ) TerrainPieces.Clear();
			CurrentAvatar = null;
			if ( RenderingScene != null ) RenderingScene.DropAll();
			Resources.DropAll();
		}
Ejemplo n.º 7
0
		public void Possess( int ObjectInstanceID ) {
			Object o = physicalObjectInstances[ObjectInstanceID];
			if ( o == null ) {
				Log.ErrorMessage( "Failed to possess " + ObjectInstanceID );
				return;
			}
			CurrentAvatar = (PhysicalObjectInstance)o;
			if ( cameraMode == EnumCameraMode.FirstPerson ) {
				CurrentAvatar.model.Visible = false;
			} else {
				CurrentAvatar.model.Visible = true;
			}
			RepositionCamera();
		}