public PreviewNode Write(PageStructure pageStructure)
        {
            var rootNode = new PreviewNode
            {
                Type          = NodeType.Element,
                IsFromLayout  = true,
                PreviewNodeId = ToGuid(_seq++),
            };

            var bodyNode = new PreviewNode
            {
                Type          = NodeType.LayoutSubtitution,
                IsFromLayout  = true,
                PreviewNodeId = ToGuid(_seq++),
            };

            rootNode.ChildNodes.Add(bodyNode);

            foreach (var node in pageStructure.ChildNodes)
            {
                bodyNode.ChildNodes.Add(Write(node));
            }

            return(rootNode);
        }
Exemple #2
0
    public override int GetWidth()
    {
        PreviewNode noiseNode = target as PreviewNode;

        if (noiseNode != null && noiseNode.HasTexture)
        {
            return((int)(150 * noiseNode.GetGraph.Ratio));
        }
        return(base.GetWidth());
    }
        public void Write(string html)
        {
            var previewNode = new PreviewNode
            {
                PreviewNodeId = ToGuid(_seq++),
                Type          = NodeType.Html,
                Html          = html
            };

            CurrentNode.ChildNodes.Add(previewNode);
        }
Exemple #4
0
        /// <summary>
        /// Creates or destroys preview node in PulseTree.
        /// </summary>
        /// <param name="bIsRoot">True to add at root level, false to add as child.</param>
        /// <param name="bMouseEntering">True to add a node at the correct place, false to remove the previously added node.</param>
        private void ManagePreviewNode(bool bIsRoot, bool bMouseEntering)
        {
            PreviewNode.Remove(); //just to be safe, always remove the node regardless

            if (!bMouseEntering)
            {
                return; //if leaving the button remove the node only then return
            }

            PreviewNode.Text = NameBox.Text;

            if (PulseTree.SelectedNode != null) //make sure there is a node selected
            {
                if (!bIsRoot)
                {
                    if (PulseTree.SelectedNode.Tag is LaserState)
                    {
                        return;
                    }
                    PulseTree.SelectedNode.Nodes.Add(PreviewNode);//create a child node of currently selected node
                    PulseTree.SelectedNode.Expand();
                }
                else //add a sibling to currently selected node.
                {
                    if (PulseTree.SelectedNode.Parent != null) //is node NOT a top-level node?
                    {
                        PulseTree.SelectedNode.Parent.Nodes.Add(PreviewNode); //add as a sibling to selected node
                    }
                    else
                    {
                        PulseTree.Nodes.Add(PreviewNode); //if top-level node then just add to the top-level list
                    }
                }
            }
            else
            {
                PulseTree.Nodes.Add(PreviewNode); //add as top level node if nothing is selected
            }


            if (PulseTypeTabs.SelectedTab == LoopTabPage)
            {
                if (FPGALoopSelect.Checked == true)
                {
                    PreviewNode.Text += " (FPGA Loop x" + LoopNumberBox.Value + ")";
                }
                else
                {
                    PreviewNode.Text += " (Loop x" + LoopNumberBox.Value + ")";
                }
            }
        }
        public void BeginWriting(CompostedContentMetdata metadata)
        {
            var nodeToWrite = new PreviewNode();

            nodeToWrite.PreviewNodeId = ToGuid(_seq++);

            if (Node.Count > 0)
            {
                CurrentNode.ChildNodes.Add(nodeToWrite);
            }
            else
            {
                RootNode = nodeToWrite;
            }

            nodeToWrite.ContentId     = metadata.ContentId;
            nodeToWrite.PlaceHolderId = metadata.PlaceHolderId;

            if (metadata.NodeType == FragmentType.Html)
            {
                nodeToWrite.Type = NodeType.Html;
            }

            if (metadata.NodeType == FragmentType.Element)
            {
                nodeToWrite.Type = NodeType.Element;
            }

            if (metadata.NodeType == FragmentType.LayoutSubtitution)
            {
                nodeToWrite.Type = NodeType.LayoutSubtitution;
            }

            if (metadata.NodeType == FragmentType.GlobalSubstitution)
            {
                nodeToWrite.Type = NodeType.GlobalSubstitution;
            }

            Node.Push(nodeToWrite);

            WriteMetadata();
        }
Exemple #6
0
    public override void OnBodyGUI()
    {
        NodeEditorGUILayout.PortField(target.GetPort("input"));

        PreviewNode noiseNode = target as PreviewNode;

        if (noiseNode != null && noiseNode.HasTexture)
        {
            Rect lastRect    = GUILayoutUtility.GetLastRect();
            Rect textureRect = new Rect(lastRect)
            {
                width  = GetWidth() * 0.95f,
                height = GetWidth() * 0.8f / noiseNode.GetGraph.Ratio,
                y      = lastRect.y + EditorGUIUtility.singleLineHeight * 2
            };
            textureRect.x = (GetWidth() - textureRect.width) / 2;
            GUILayoutUtility.GetRect(textureRect.width, textureRect.height + EditorGUIUtility.singleLineHeight);
            EditorGUI.DrawPreviewTexture(textureRect, noiseNode.GetInputTexture);
        }
    }
Exemple #7
0
        public override void OnBodyGUI()
        {
            base.OnBodyGUI();

            //Update texture if needed
            if (PreviewNode.TextureNeedsUpdating)
            {
                PreviewNode.UpdateTexture();
            }

            //If there is a texture to display, display it.
            if (PreviewNode.HasTexture())
            {
                int  texExtents = GetWidth() - (TEXTURE_PADDING * 2);
                Rect dimensions = new Rect(TEXTURE_PADDING, TEXTURE_HEIGHT_OFFSET, texExtents, texExtents);

                //Expand node size and draw texture
                EditorGUILayout.LabelField("", GUILayout.Height(EXPANDED_HEIGHT));
                GUI.DrawTexture(dimensions, PreviewNode.PreviewTexture);
            }
        }
Exemple #8
0
 public void SelectNode(NodeListUpdatedArgs.NodeInfo nodeInfo)
 {
     InvokeOnMain(() =>
     {
         PreviewNode = _scene.GetNode(nodeInfo.ID);
         if (PreviewNode != null)
         {
             var mat   = ResourceCache.GetMaterial("Materials/_temp.xml");
             var model = PreviewNode.GetComponent <StaticModel>();
             if (model != null)
             {
                 model.SetMaterial(mat);
             }
             var animatedModel = PreviewNode.GetComponent <AnimatedModel>();
             if (animatedModel != null)
             {
                 animatedModel.SetMaterial(mat);
             }
         }
     });
 }
Exemple #9
0
        protected override void OnUpdate(float timeStep)
        {
            if (PreviewNode == null)
            {
                return;
            }

            if (isRotate)
            {
                PreviewNode.Rotate(Quaternion.FromAxisAngle(Vector3.Up, timeStep * 10.0f));
            }
            base.OnUpdate(timeStep);

            MoveCamera2D(timeStep);
            MoveCamera3D(timeStep);

            var animModel = PreviewNode.GetComponent <AnimatedModel>();

            if (animModel != null && animModel.NumAnimationStates > 0)
            {
                var state = animModel.AnimationStates.First();
                state.AddTime(timeStep);
            }
        }
Exemple #10
0
        private void CreateSceneImpl()
        {
            var cache = ResourceCache;

            _scene = new Scene();
            // scene.CreateComponent<Octree>();  scene.CreateComponent<Camera>();

            _scene.CreateComponent <Octree>();
            _scene.CreateComponent <DebugRenderer>();
            var zone = _scene.CreateComponent <Zone>();

            zone.SetBoundingBox(new BoundingBox(new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000)));
            zone.ZoneTexture = ResourceCache.GetTextureCube("Textures/MaterialGraphEditor/Skybox.xml", false);

            CameraNode = _scene.CreateChild("MainCamera");
            var camera = CameraNode.CreateComponent <Camera>();

            CameraNode.Position = new Vector3(0, -0.0860865f, -1.32894f);
            CameraNode.Rotation = new Quaternion(0.0436198f, 0f, 0f, 0.999048f);

            var lightNode = _scene.CreateChild("Light");

            lightNode.Position = new Vector3(-0.909645f, 2f, -2f);
            lightNode.Rotation = new Quaternion(0.416198f, 0.157379f, -0.0733869f, 0.892539f);
            Light             = lightNode.CreateComponent <Light>();
            Light.Color       = Color.White;
            Light.Fov         = 40.0f;
            Light.LightType   = _lightType;
            Light.CastShadows = true;

            var offset = new Vector3(2, 3, 7); //An offset to be sure that shader applies correct model matrix
            var bb     = new BoundingBox(-Vector3.One, Vector3.One);

            PreviewNode = _scene.CreateChild("Preview");

            StaticModel modelComponent;

            if (_animatedModel)
            {
                var animatedModel = PreviewNode.CreateComponent <AnimatedModel>();
                animatedModel.Model = _model;
                modelComponent      = animatedModel;
                if (_animation != null)
                {
                    var state = animatedModel.AddAnimationState(_animation);
                    state.Weight = 1.0f;
                    state.Looped = true;
                }
            }
            else
            {
                modelComponent       = PreviewNode.CreateComponent <StaticModel>();
                modelComponent.Model = _model;
            }

            if (_model != null)
            {
                modelComponent.SetMaterial(ResourceCache.GetMaterial("Materials/_temp.xml", false));
                bb = _model.BoundingBox;
            }

            var bottom = (new Vector3(bb.Min.X, bb.Min.Y, bb.Min.Z) + new Vector3(bb.Max.X, bb.Min.Y, bb.Max.Z)) * 0.5f;

            PreviewNode.Position = offset - bottom;
            CameraTarget         = bb.Center + PreviewNode.Position;
            var size = bb.Size.Length;

            CameraDistance      = size * 1.5f;
            CameraNode.Position = CameraTarget + new Vector3(0, 0.7071f, 0.7071f) * CameraDistance;
            CameraNode.LookAt(CameraTarget, Vector3.Up);
            lightNode.Position = CameraTarget + new Vector3(-0.211157f, 0.73685f, 0.6422342f) * (2.0f * size);
            lightNode.LookAt(CameraTarget, Vector3.Up);
            Yaw   = CameraNode.Rotation.YawAngle;
            Pitch = CameraNode.Rotation.PitchAngle;

            Light.ShadowCascade = new CascadeParameters(size * 2.0f, size * 4.0f, size * 8.0f, size * 16.0f,
                                                        Light.ShadowCascade.FadeStart, Light.ShadowCascade.BiasAutoAdjust);

            modelComponent.CastShadows = true;

            var floorNode = _scene.CreateChild("Preview");
            var scale     = bb.Size.Length;

            floorNode.Position = offset + new Vector3(0, -scale * 0.5f, 0f);
            floorNode.Scale    = new Vector3(scale, scale, scale);
            var floor = floorNode.CreateComponent <StaticModel>();

            floor.Model = ResourceCache.GetModel("Models/MaterialGraphEditor/Box.mdl", false);
            if (floor.Model != null)
            {
                floor.SetMaterial(ResourceCache.GetMaterial("Materials/MaterialGraphEditor/DefaultGray.xml", false));
            }

            floor.CastShadows = true;

            var skyboxNode = _scene.CreateChild("Skybox");
            var skybox     = skyboxNode.CreateComponent <Skybox>();

            skybox.Model = ResourceCache.GetModel("Models/MaterialGraphEditor/Box.mdl", false);
            skybox.SetMaterial(ResourceCache.GetMaterial("Materials/MaterialGraphEditor/Skybox.xml", false));

            //_scene.LoadXml(FileSystem.ProgramDir + "Data/Scenes/Scene.xml");

            //CameraNode = _scene.GetChild("MainCamera", true);
            //PreviewNode = _scene.GetChild("Preview", true);
            //NotifyNodes();
        }
        private PreviewNode Write(StructureNode pageStructure)
        {
            var friendlyName = string.Empty;

            if (pageStructure.WidgetTypeCode != null)
            {
                friendlyName = pageStructure.WidgetTypeCode;
                //friendlyName = new ToolboxManager().GetToolboxItemByCode(pageStructure.WidgetTypeCode).FriendlyName;
            }

            var previewNode = new PreviewNode
            {
                ContentId     = pageStructure.Id,
                Type          = NodeType.Element,
                Parameters    = pageStructure.Parameters,
                PreviewNodeId = ToGuid(_seq++),
                FriendlyName  = friendlyName
            };

            var isRow = "ConfiguratorRow" == pageStructure.WidgetTypeCode;

            if (isRow)
            {
                previewNode.ChildNodes.Add(new PreviewNode {
                    Type = NodeType.Html, Html = "<div class='row'>"
                });

                if (!pageStructure.Parameters.ContainsKey("NumColumns"))
                {
                    return(previewNode);
                }

                var numColumnsRaw = pageStructure.Parameters["NumColumns"];
                int columnCount;
                var isNum = Int32.TryParse(numColumnsRaw, out columnCount);
                if (!isNum)
                {
                    return(previewNode);
                }

                for (int i = 0; i < columnCount; i++)
                {
                    var i1 = i;

                    previewNode.ChildNodes.Add(new PreviewNode
                    {
                        Type          = NodeType.Html,
                        Html          = "<div class='col'>",
                        PreviewNodeId = ToGuid(_seq++)
                    });
                    var newSubstitution = new PreviewNode
                    {
                        Type          = NodeType.LayoutSubtitution,
                        PlaceHolderId = i1.ToString(),
                        PreviewNodeId = ToGuid(_seq++)
                    };
                    previewNode.ChildNodes.Add(newSubstitution);

                    var nodesToPreview =
                        pageStructure.ChildNodes.Where(x => x.PlacementContentPlaceHolderId == i1.ToString());
                    newSubstitution.ChildNodes = nodesToPreview.Select(Write).ToList();
                    previewNode.ChildNodes.Add(new PreviewNode
                    {
                        Type          = NodeType.Html,
                        Html          = "</div>",
                        PreviewNodeId = ToGuid(_seq++)
                    });
                }

                previewNode.ChildNodes.Add(new PreviewNode
                {
                    Type          = NodeType.Html,
                    Html          = "</div>",
                    PreviewNodeId = ToGuid(_seq++)
                });
            }
            else
            {
                previewNode.UseClientRenderer = true;
            }

            return(previewNode);

            //PlaceHolderId = pageStructure.
            //    FriendlyName = pageStructure.WidgetTypeCode

            //ChildNodes = pageStructure.ChildNodes.Select(Write).ToList()
        }
 public void SetBezier(PreviewNode[] nodes)
 {
 }