Exemple #1
0
        protected void LoadModel(GraphicNode graphic_node)
        {
            if (null == graphic_node.Graphic.ModelName)
            {
                return;
            }

            if (null != graphic_node.Graphic.Model)
            {
                return;
            }

            try
            {
                graphic_node.Graphic.Model = (Model)Activator.CreateInstance(Type.GetType(graphic_node.Graphic.ModelName));
            }
            catch
            {
                graphic_node.Graphic.Model = ResourceManager.Models.Load(graphic_node.Graphic.ModelName);
            }
            if (null != graphic_node.Graphic.ProgramName)
            {
                graphic_node.Graphic.Model.Program = ResourceManager.Programs[graphic_node.Graphic.ProgramName];
            }
            if (null != graphic_node.Graphic.TextureName)
            {
                graphic_node.Graphic.Model.Texture = ResourceManager.Textures[graphic_node.Graphic.TextureName];
            }
        }
Exemple #2
0
        protected void InitModelDebugOrientation(GraphicNode graphic_node)
        {
            var b       = graphic_node.Base;
            var forward = new Color4(1.0f, 0.0f, 0.0f, 0.5f);
            var up      = new Color4(0.0f, 1.0f, 0.0f, 0.5f);
            var right   = new Color4(0.0f, 0.0f, 1.0f, 0.5f);

            graphic_node.ModelDebugOrientation = new Model();
            graphic_node.ModelDebugOrientation.Mesh(
                new Mesh <VertexP3C4, uint>()
            {
                Vertices = new VertexP3C4[] {
                    new VertexP3C4(Vector3.Zero, forward),
                    new VertexP3C4((Vector3)b.Forward, forward.Inverted()),
                    new VertexP3C4(Vector3.Zero, up),
                    new VertexP3C4((Vector3)b.Up, up.Inverted()),
                    new VertexP3C4(Vector3.Zero, right),
                    new VertexP3C4((Vector3)b.Right, right.Inverted()),
                },
                Indices = new uint[] {
                    0, 1, 2, 3, 4, 5
                }
            }
                );
            graphic_node.ModelDebugOrientation.Mode    = PrimitiveType.Lines;
            graphic_node.ModelDebugOrientation.Program = ResourceManager.Programs["normal"];
        }
Exemple #3
0
        private List <Guid> copySelection(FlowChart doc)
        {
            if (doc.Selection.Objects.Count == 0)
            {
                return(null);
            }

            List <Guid> copyGuids = new List <Guid>();

            foreach (Box box in doc.Selection.Boxes)
            {
                GraphicNode graphicNode = frmFlowChart.State.GraphicNode(box);
                if (graphicNode != null)
                {
                    copyGuids.Add(graphicNode.Guid);
                }
            }

            foreach (Arrow arrow in doc.Selection.Arrows)
            {
                GraphicLink graphicLink = frmFlowChart.State.GraphicLink(arrow);
                if (graphicLink != null)
                {
                    copyGuids.Add(graphicLink.Guid);
                }
            }

            return(copyGuids);
        }
Exemple #4
0
    // Node Creation ---
    private GraphicNode CreateGNode(NeuralNode n)
    {
        if (n == null)
        {
            return(null);
        }
        GUIStyle style = new GUIStyle();

        if (n.nodeOrder == NeuralNetwork.inputNodeOrder)
        {
            style = inStyle;
        }
        else if (n.nodeOrder == NeuralNetwork.outputNodeOrder)
        {
            style = outStyle;
        }
        else
        {
            style = hlStyle;
        }
        GraphicNode gnode = new GraphicNode(n, new Vector2(0, 0), nodeScale.x, nodeScale.y, style);

        gNodes.Add(gnode);
        return(gnode);
    }
        new internal void Clear()
        {
            graphicNode = null;
            graphicLink = null;
            state       = null;

            base.Clear();
        }
Exemple #6
0
        public EditorNode(State state, GraphicNode graphicNode, ModelNode modelNode)
        {
            this.state       = state;
            this.graphicNode = graphicNode;
            this.modelNode   = modelNode;

            opacityTimer.Interval = 100;
            opacityTimer.Elapsed += new ElapsedEventHandler(opacityTimer_Elapsed);
        }
Exemple #7
0
 public override void DrawSubObjekt(RenderInformation RI, MeshPart M, GraphicNode GN)
 {
     Device.Context.VertexShader.SetConstantBuffer(cBuf, 0);
     Device.Context.PixelShader.SetConstantBuffer(cBuf2, 1);
     if (M == null || M.Buffer == null || M.Buffer.VertexCount == 0) return;
     Device.InputAssembler.SetVertexBuffer(0, M.Buffer.Bindings[0]);
     if(M.Material.DiffuseTexture != null)
         Device.Context.PixelShader.SetShaderResource(M.Material.DiffuseTexture.ShaderResourceView, 0);
     else Device.Context.PixelShader.SetShaderResource(ShaderResourceTexture.WhiteTexture.ShaderResourceView, 0);
     Device.Context.Draw(M.Buffer.VertexCount, 0);
 }
Exemple #8
0
    // Connection Creation ---
    private GraphicConnection CreateGCon(NeuralConnection c, GraphicNode ingn, GraphicNode outgn)
    {
        if (c == null || ingn == null || outgn == null)
        {
            return(null);
        }
        GraphicConnection gc = new GraphicConnection(c, ingn, outgn);

        gCons.Add(gc);
        return(gc);
    }
Exemple #9
0
        private void uploadTree()
        {
            EntityManager entityManager = EntityManager.Instance;
            var           entities      = entityManager.Entities;

            if (entityManager.Player != null)
            {
                entities.Add(entityManager.Player);
            }

            Clear();
            foreach (var entity in entities)
            {
                var graphicComponents = entity.GetComponent(typeof(GraphicComponent));

                foreach (var component in graphicComponents)
                {
                    if (component != null)
                    {
                        GraphicComponent graphicComponent = component as GraphicComponent;
                        RenderService.Models.Position    entityPosition  = new Position(entity.Position.X, entity.Position.Y);
                        RenderService.Models.Position    texturePosition = new Position(graphicComponent.Texture.X, graphicComponent.Texture.Y);
                        RenderService.Enums.DrawPriority priority;
                        switch (graphicComponent.RenderType)
                        {
                        case Rendertype.FirstLevel:
                            priority = RenderService.Enums.DrawPriority.High;
                            break;

                        case Rendertype.Background:
                            priority = RenderService.Enums.DrawPriority.Low;
                            break;

                        case Rendertype.Normal:
                            priority = RenderService.Enums.DrawPriority.Normal;
                            break;

                        default:
                            priority = RenderService.Enums.DrawPriority.Normal;
                            break;
                        }

                        GraphicNode node = new GraphicNode(entityPosition, texturePosition, priority);
                        addNode(node);
                    }
                }
            }
        }
Exemple #10
0
    // Updates ---
    public void UpdateGraphics()
    {
        if (network == null)
        {
            return;
        }
        gNodes.Clear();
        gCons.Clear();
        List <NeuralNode>       closedNodes = new List <NeuralNode>();
        List <NeuralConnection> closedCons  = new List <NeuralConnection>();

        foreach (NeuralNode n in network.neuralNodes)
        {
            GraphicNode gnodeA = null;
            if (IsInClosedNodes(n, closedNodes) == false)
            {
                closedNodes.Add(n);
                gnodeA = CreateGNode(n);
            }
            foreach (NeuralConnection c in n.outCons)
            {
                GraphicNode gnodeB = null;
                if (c.outNode == null)
                {
                    continue;
                }
                if (IsInClosedNodes(c.outNode, closedNodes) == false)
                {
                    closedNodes.Add(c.outNode);
                    gnodeB = CreateGNode(c.outNode);
                }
                if (IsInClosedCons(c, closedCons) == false)
                {
                    closedCons.Add(c);
                    if (gnodeA == null)
                    {
                        gnodeA = GetGNodeByNeuralNode(n);
                    }
                    if (gnodeB == null)
                    {
                        gnodeB = GetGNodeByNeuralNode(c.outNode);
                    }
                    CreateGCon(c, gnodeB, gnodeA);
                }
            }
        }
    }
Exemple #11
0
        protected void InitModelDebugPhysic(GraphicNode graphic_node)
        {
            var physic    = graphic_node.Entity.Get <PhysicComponent>();
            var min       = physic.BoundingBox.Min;
            var max       = physic.BoundingBox.Max;
            var x0        = (float)min.X;
            var y0        = (float)min.Y;
            var z0        = (float)min.Z;
            var x1        = (float)max.X;
            var y1        = (float)max.Y;
            var z1        = (float)max.Z;
            var verticies = new VertexP3[] {
                new VertexP3(x0, y0, z0),
                new VertexP3(x0, y1, z0),
                new VertexP3(x0, y0, z1),
                new VertexP3(x0, y1, z1),
                new VertexP3(x1, y0, z0),
                new VertexP3(x1, y1, z0),
                new VertexP3(x1, y0, z1),
                new VertexP3(x1, y1, z1),
                new VertexP3(x0, y0, z0),
                new VertexP3(x1, y0, z0),
                new VertexP3(x0, y1, z0),
                new VertexP3(x1, y1, z0),
                new VertexP3(x0, y0, z1),
                new VertexP3(x1, y0, z1),
                new VertexP3(x0, y1, z1),
                new VertexP3(x1, y1, z1),
                new VertexP3(x0, y0, z0),
                new VertexP3(x0, y0, z1),
                new VertexP3(x1, y0, z0),
                new VertexP3(x1, y0, z1),
                new VertexP3(x0, y1, z0),
                new VertexP3(x0, y1, z1),
                new VertexP3(x1, y1, z0),
                new VertexP3(x1, y1, z1)
            };

            graphic_node.ModelDebugPhysic = new Model();
            graphic_node.ModelDebugPhysic.Mesh(new Mesh <VertexP3, uint>(verticies));
            graphic_node.ModelDebugPhysic.Mode    = PrimitiveType.Lines;
            graphic_node.ModelDebugPhysic.Program = ResourceManager.Programs["primitive_colored"];
        }
Exemple #12
0
 private void addNode(GraphicNode node)
 {
     tree.Add(node);
 }
Exemple #13
0
 public void AddGraphicNode(GraphicNode node)
 {
 }
        public override void DrawSubObjekt(RenderInformation RI, MeshPart M2, GraphicNode GN)
        {
            ILrentObject O = (GN.Tag as ILrentObject.ObjectTagger).Object;
            Vector4[] buffer = null;
            if (O.getSet<gIPath>() != null)
                buffer = O.getSet<gIPath>().getBuffer();
            else buffer = O.getSet<gIZone>().getBuffer();

            if (buffer == null || buffer.Length > 100) return;

            E.Variables["ColorA"].SetVariable(V);
            E.Variables["WVP"].SetVariable(O.Matrix * RI.ViewMatrix * RI.ProjectionMatrix);
            E.Variables["PointA"].SetVariable(buffer);
            INavBase b = (GN.Tag as ILrentObject.ObjectTagger).Object.getSet<INavBase>();
            mBuffer.DrawBufferNonIndexed(E.Techniques[0].Passes[0], buffer.Length, b is gIPath ? PrimitiveTopology.TriangleList : PrimitiveTopology.LineList);
        }
Exemple #15
0
 public override void PrepareForNode(RenderInformation RI, GraphicNode N)
 {
 }
 bool ComparePredicate(GraphicNode GN)
 {
     if (!(GN.Tag is ILrentObject.ObjectTagger)) return false;
     INavBase b = (GN.Tag as ILrentObject.ObjectTagger).Object.getSet<INavBase>();
     return b != null && !(b is gIColl);
 }
Exemple #17
0
 private void BTN_CLICK_LOAD(object sender, EventArgs e)
 {
     openFileDialog1.Reset();
     DialogResult dr = openFileDialog1.ShowDialog();
     if ((dr == System.Windows.Forms.DialogResult.Cancel) || (dr == System.Windows.Forms.DialogResult.No))
         return;
     if (GNode != null)
     {
         cam.Dispose();
         GNode.Dispose();
     }
     GNode = DAParent.Device.Content.LoadModelFromFile(openFileDialog1.FileName, true);
     GNode.Initialize(null, new Vector3(0), new Vector3(1), true);
     GNode.Visible = false;
     GNode.Rotate(RotationAngle.X_Axis, -90);
     //GNode.Rotate(RotationAngle.Z_Axis, 90);
     cam = new _3d_Person_Cam(GN, 3, MathHelper.PiOver2, this);
 }
Exemple #18
0
 public override void DrawSubObjekt(RenderInformation RI, MeshPart GSO, GraphicNode GN)
 {
 }
        //internal void Initialize()
        //{
        //  BorderStyle = System.Windows.Forms.BorderStyle.None;
        //  CommentsHeight = 70;
        //  CommentsVisibility = true;

        //  Dock = System.Windows.Forms.DockStyle.Fill;
        //  Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
        //  Location = new System.Drawing.Point(0, 0);
        //  Margin = new System.Windows.Forms.Padding(2);
        //}

        internal void SetSelectedObject(GraphicNode graphicNode, ModelNode modelNode, State state)
        {
            Clear();

            this.graphicNode = graphicNode;
            this.state       = state;

            id          = 0;
            itemGraphic = AppendRootCategory(id++, "Graphic");
            //itemGraphicPath =
            AppendProperty(itemGraphic, id++, "Path", graphicNode, "Path", "", new System.ComponentModel.ReadOnlyAttribute(true));
            itemGraphicBoungingRect = AppendProperty(itemGraphic, id++, "Bounding Rectangle", graphicNode, "BoundingRect", "");
            //itemGraphicBoungingRectLeft =
            AppendProperty(itemGraphicBoungingRect, id++, "Left", graphicNode, "X", "");
            //itemGraphicBoungingRectTop =
            AppendProperty(itemGraphicBoungingRect, id++, "Top", graphicNode, "Y", "");
            //itemGraphicBoungingRectWidth =
            AppendProperty(itemGraphicBoungingRect, id++, "Width", graphicNode, "Width", "");
            //itemGraphicBoungingRectHeight =
            AppendProperty(itemGraphicBoungingRect, id++, "Height", graphicNode, "Height", "");
            ExpandProperty(itemGraphicBoungingRect, false);
            //itemGraphicAngle =
            AppendProperty(itemGraphic, id++, "Angle", graphicNode, "Angle", "");
            AppendProperty(itemGraphic, id++, "Opacity", graphicNode, "Opacity", "");

            itemGraphicShape = AppendProperty(itemGraphic, id++, "Stencil", graphicNode, "Stencil", "");
            itemGraphicShape.Property.Feel = GetRegisteredFeel(PropertyGrid.FeelButton);

            itemGraphicTag             = AppendSubCategory(itemGraphic, id++, "Tag");
            itemGraphicTagBoungingRect = AppendProperty(itemGraphicTag, id++, "Bounding Rectangle", graphicNode, "TagArea", "");
            //itemGraphicBoungingRectLeft =
            AppendProperty(itemGraphicTagBoungingRect, id++, "Left", graphicNode, "TagAreaX", "");
            //itemGraphicBoungingRectTop =
            AppendProperty(itemGraphicTagBoungingRect, id++, "Top", graphicNode, "TagAreaY", "");
            //itemGraphicBoungingRectWidth =
            AppendProperty(itemGraphicTagBoungingRect, id++, "Width", graphicNode, "TagAreaWidth", "");
            //itemGraphicBoungingRectHeight =
            AppendProperty(itemGraphicTagBoungingRect, id++, "Height", graphicNode, "TagAreaHeight", "");
            ExpandProperty(itemGraphicTagBoungingRect, false);
            //itemGraphicAngle =
            AppendProperty(itemGraphicTag, id++, "Angle", graphicNode, "TagAngle", "");
            AppendProperty(itemGraphicTag, id++, "Visible", graphicNode, "TagVisible", "");
            ExpandProperty(itemGraphicTag, false);

            itemGraphicFill = AppendSubCategory(itemGraphic, id++, "Fill");
            //itemGraphicFillColor =
            AppendProperty(itemGraphicFill, id++, "Color", graphicNode, "FillColor", "");
            //itemGraphicFillMode =
            AppendProperty(itemGraphicFill, id++, "Mode", graphicNode, "FillMode", "");
            ExpandProperty(itemGraphicFill, false);
            itemGraphicMirror  = AppendSubCategory(itemGraphic, id++, "Mirroring");
            itemGraphicMirrorX = AppendProperty(itemGraphicMirror, id++, "X", graphicNode, "MirrorX", "");
            itemGraphicMirrorX.Property.Feel       = GetRegisteredFeel(FeelCheckbox);
            itemGraphicMirrorX.Property.Value.Look = new PropertyCheckboxLook();
            itemGraphicMirrorY = AppendProperty(itemGraphicMirror, id++, "Y", graphicNode, "MirrorY", "");
            itemGraphicMirrorY.Property.Feel       = GetRegisteredFeel(FeelCheckbox);
            itemGraphicMirrorY.Property.Value.Look = new PropertyCheckboxLook();
            ExpandProperty(itemGraphicMirror, false);

            itemModel = AppendRootCategory(id++, "Model");
            //itemModelGuid =
            AppendProperty(itemModel, id++, "Guid", modelNode, "Guid", "", new System.ComponentModel.ReadOnlyAttribute(true));
            //itemModelClass =
            AppendProperty(itemModel, id++, "Class", modelNode, "NodeClass", "", new System.ComponentModel.ReadOnlyAttribute(true));
            //itemModelTag =
            AppendProperty(itemModel, id++, "Tag", modelNode, "Tag", "");
        }
Exemple #20
0
        public override void PrepareForNode(RenderInformation RI, GraphicNode GN)
        {
            dS.Position = 0L;
            dS.Write<Matrix>(Matrix.Transpose(RI.WorldMatrix * M));
            dS.Write<Matrix>(Matrix.Transpose(RI.WorldMatrix));
            dS.Position = 0L;
            Device.Context.UpdateSubresource(new DataBox(0, 0, dS), cBuf, 0);

            dS2.Position = 0L;
            dS2.Write<Vector3>(RI.CameraPosition);
            dS2.Position = 0L;
            Device.Context.UpdateSubresource(new DataBox(0, 0, dS2), cBuf2, 0);
        }
Exemple #21
0
        private void frmFlowChart_fcFlowChart_SelectionChanged()
        {
            if (!frmFlowChart.State.creatingNode)
            {
                graphicPropertyGrid.Clear();

                frmFlowChart.FlowChart.SelectionChanged -= new SelectionEvent(this.frmFlowChart_fcFlowChart_SelectionChanged);

                if (!frmFlowChart.State.SelectItems)
                {
                    if (frmFlowChart.FlowChart.Selection.Boxes.Count > 1)
                    {
                        BoxCollection boxCollection = frmFlowChart.FlowChart.Selection.Boxes.Clone();

                        foreach (Box box in boxCollection)
                        {
                            box.Selected = false;
                        }
                    }
                }

                if (!frmFlowChart.State.SelectLinks)
                {
                    if (frmFlowChart.FlowChart.Selection.Arrows.Count > 1)
                    {
                        ArrowCollection arrowCollection = frmFlowChart.FlowChart.Selection.Arrows.Clone();

                        foreach (Arrow arrow in arrowCollection)
                        {
                            arrow.Selected = false;
                        }
                    }
                }

                foreach (EditorNode item in frmFlowChart.State.Nodes)
                {
                    if (item.GraphicBox.Selected)
                    {
                        item.Selected = true;
                    }
                    item.UpdateVisibility();
                }

                if (frmFlowChart.FlowChart.ActiveObject is Arrow)
                {
                    Arrow       activeArrow = frmFlowChart.FlowChart.ActiveObject as Arrow;
                    GraphicLink graphicLink = frmFlowChart.State.GraphicLink(activeArrow);

                    if (graphicLink != null)
                    {
                        ModelLink modelLink;
                        if (frmFlowChart.State.ClientProtocol.model.Links.TryGetValue(graphicLink.ModelGuid, out modelLink))
                        {
                            graphicPropertyGrid.SetSelectedObject(graphicLink, modelLink, frmFlowChart.State);
                        }
                        else
                        {
                            frmFlowChart.State.ClientProtocol.LogMessage(out requestId, "ModelLink missing for GraphcLink (Tag: " + graphicLink.Tag + ", Guid: " + graphicLink.Guid + ")", SysCAD.Log.MessageType.Error);
                        }
                    }
                }

                if (frmFlowChart.FlowChart.ActiveObject is Box)
                {
                    Box         activeBox   = frmFlowChart.FlowChart.ActiveObject as Box;
                    GraphicNode graphicNode = frmFlowChart.State.GraphicNode(activeBox);
                    ModelNode   modelNode   = frmFlowChart.State.ModelNode(activeBox);

                    if ((graphicNode != null) && (modelNode != null))
                    {
                        graphicPropertyGrid.SetSelectedObject(graphicNode, modelNode, frmFlowChart.State);
                        modelPropertiesGrid.SetSelectedObject(modelNode, frmFlowChart.State);

                        Int64 requestId;
                        frmFlowChart.State.PropertyList(out requestId, graphicNode.Guid, graphicNode.Tag, graphicNode.Path);
                    }
                }

                frmFlowChart.FlowChart.SelectionChanged += new SelectionEvent(this.frmFlowChart_fcFlowChart_SelectionChanged);
            }
        }
Exemple #22
0
 public VegetationMiniPart(GraphicNode gn, int i)
 {
     mBody = new Mesh(gn.BoundingBox, gn.Mesh.CullMode, gn.Mesh.Parts[i]);
     vPosition = gn.Position_ABS;
     vSize = gn.Size_ABS;
     qOrientation = gn.Orientation_ABS;
     mWorld = gn.ModelMatrix_ABS;
     sPath = gn.Path + i.ToString();
     bb = mBody.BoundingBox.Transform(mWorld);
 }
Exemple #23
0
 protected void AddGraphicNode(GraphicNode node)
 {
 }
Exemple #24
0
 internal void createModelViewer(GraphicNode gn)
 {
     if (mv != null)
     {
         mv.GNode = gn;
         if (mv.WindowState == FormWindowState.Minimized)
             mv.WindowState = FormWindowState.Normal;
     }
     else
     {
         mv = new ModelViewer(this);
         mv.GNode = gn;
     }
 }
Exemple #25
0
 public VegetationMiniPartCollection(ICollection<VegetationMiniPart> ps)
 {
     ManagedWorld.NodeLibrary.RemoveNode(this);
     gps = ps.ToArray<VegetationMiniPart>();
     p = gps[0].sPath;
     D = gps[0].mBody.Device;
     //List<Vector3> ms = new List<Vector3>();
     //List<Quaternion> qs = new List<Quaternion>();
     List<byte> bs = new List<byte>();
     int stride = 3 * 4 + 4 * 4;//float3 + float4
     BoundingBox abs = new BoundingBox(new Vector3(1E10f), new Vector3(-1E10f));
     foreach (VegetationMiniPart gp in gps)
     {
         abs = abs.Extend(gp.bb);
         //ms.Add(gp.vPosition);
         //qs.Add(gp.qOrientation);
         bs.AddRange(gp.vPosition.GetBytes());
         bs.AddRange(gp.qOrientation.GetBytes());
     }
     this.BoundingBox = abs;
     DataStream ds = new DataStream(bs.ToArray(), true, true);
     sBuffer = new ShaderResourceBuffer(ds, SlimDX.Direct3D11.BindFlags.VertexBuffer, SlimDX.Direct3D11.CpuAccessFlags.None, SlimDX.Direct3D11.ResourceUsage.Default, SlimDX.Direct3D11.ResourceOptionFlags.None, stride, D);
     ds.Dispose();
     vb = new SlimDX.Direct3D11.VertexBufferBinding(sBuffer.Buffer, sBuffer.Description.StructureByteStride, 0);
     qTST = new GraphicNode("", null, D); qTST.BoundingBox = this.BoundingBox; qTST.ParentNode = this;
 }
Exemple #26
0
 public GraphicConnection(NeuralConnection c, GraphicNode inp, GraphicNode outp)
 {
     connection = c; inNode = inp;  outNode = outp;
 }
Exemple #27
0
 private void graphicPropertyGrid_NodeChanged(GraphicNode graphicNode)
 {
     SysCAD.Protocol.Action action = new SysCAD.Protocol.Action();
     action.Modify.Add(graphicNode);
     frmFlowChart.AddAction(action);
 }