Example #1
0
        public void CreateVisual3D(Model model)
        {
            UI ui = new UI(UITemplate);

            Viewport2DVisual3D visual = new Viewport2DVisual3D();
            visual.Geometry = Geometry;
            visual.Visual = ui.Visual;
            EmissiveMaterial material = new EmissiveMaterial(Brushes.White);
            Viewport2DVisual3D.SetIsVisualHostMaterial(material, true);
            visual.Material = material;

            model.Children.Add(visual);
        }
Example #2
0
 public Interaction(InteractionTemplate template, Model sender, Model receiver = null)
 {
     Template = template;
     Sender = sender;
     Receiver = receiver;
 }
Example #3
0
 public virtual void Load(Loader l, Instruction i)
 {
     switch (i.Type)
     {
         case "name":
             Name = i.String();
             break;
         case "dim":
             int width = i.Int(), height = i.Int(), length = i.Int();
             Dimension = new Dimension3D(width, height, length);
             models = new Model[width, height, length];
             break;
         case "m": // Model
             {
                 Position3D pos = i.Position3D();
                 ModelTemplate mt = Game.Get<ModelTemplate>(i.String());
                 Model m = new Model(mt);
                 AddModel(m, pos);
                 ProcessModelArgs(i, m);
             }
             break;
         case "r": // Range (multiple models)
             {
                 Position3D origin = i.Position3D();
                 Dimension3D dim = i.Dimension3D();
                 ModelTemplate mt = Game.Get<ModelTemplate>(i.String());
                 origin.ForEachInRange(dim, (loc) =>
                 {
                     Model m = new Model(mt);
                     AddModel(m, loc);
                 });
             }
             break;
         case "a": // Actor
             {
                 Position3D pos = i.Position3D();
                 ActorTemplate at = Game.Get<ActorTemplate>(i.String());
                 Actor actor = new Actor(at);
                 AddActor(actor);
                 ProcessModelArgs(i, actor);
             }
             break;
         case "dl": // Directional light
             {
                 Light light = new DirectionalLight(i.Color(), i.Vector3D());
                 Lamp ls = new Lamp(light);
                 AddLamp(ls);
                 if (i.HasNext)
                     namedElements[i.String()] = ls;
             }
             break;
         case "pl": // Point light
             {
                 Light light = new PointLight(i.Color(), i.Point3D());
                 Lamp ls = new Lamp(light);
                 AddLamp(ls);
                 if (i.HasNext)
                     namedElements[i.String()] = ls;
             }
             break;
         case "al": // Ambient light
             {
                 Light light = new AmbientLight(i.Color());
                 Lamp ls = new Lamp(light);
                 AddLamp(ls);
                 if (i.HasNext)
                     namedElements[i.String()] = ls;
             }
             break;
     }
 }
Example #4
0
 public void RemoveModel(Model Model)
 {
     ClearModel(Model);
     Children.Remove(Model);
 }
Example #5
0
 public void AddModel(Model Model, Position3D location)
 {
     PlaceModel(Model, location);
     Children.Add(Model);
 }
Example #6
0
 public void ClearModel(Model model)
 {
     // Clear area the model was before
     model.Position.ForEachInRange(model.Template.Dimension, (l) => this[l] = null);
 }
Example #7
0
 public void PlaceModel(Model model, Position3D location)
 {
     // Set new location (for visual update)
     model.Position = location;
     // Set new area
     location.ForEachInRange(model.Template.Dimension, (l) =>
     {
         Model m = this[l];
         if (m != null)
         {
             // Remove object being replaced
             RemoveModel(m);
         }
         this[l] = model;
     });
 }
Example #8
0
 public void MoveModelTo(Model model, Position3D location)
 {
     ClearModel(model);
     PlaceModel(model, location);
 }
Example #9
0
 private void ProcessModelArgs(Instruction i, Model m)
 {
     while (i.HasNext)
     {
         switch (i.String())
         {
             case "-id":
                 namedElements[i.String()] = m;
                 break;
             case "-dir":
                 m.Direction = new Direction(i.Int());
                 break;
         }
     }
 }