Exemple #1
0
        void manipulater_Rotated(object sender, ArcBallManipulater.Rotation e)
        {
            SceneNodeBase node = this.scene.RootNode;

            node.RotationAngle = e.angleInDegree;
            node.RotationAxis  = e.axis;
        }
Exemple #2
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            SceneNodeBase rootElement = GetRootElement();

            var position = new vec3(1, 0, 4);
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspecitive, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene = new Scene(camera, this.winGLCanvas1)
            {
                RootElement = rootElement,
                ClearColor  = Color.SkyBlue.ToVec4(),
            };

            var list = new ActionList();

            var transformAction = new TransformAction(scene);

            list.Add(transformAction);
            var renderAction = new RenderAction(scene);

            list.Add(renderAction);

            var guiLayoutAction = new GUILayoutAction(scene);

            list.Add(guiLayoutAction);
            var guiRenderAction = new GUIRenderAction(scene);

            list.Add(guiRenderAction);

            this.actionList = list;

            MessageBox.Show("Press 'n' to switch texture indexes!");
        }
Exemple #3
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            SceneNodeBase rootElement = GetRootElement();

            var position = new vec3(1, 2, 4);
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspecitive, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene = new Scene(camera, this.winGLCanvas1)
            {
                RootElement = rootElement,
                ClearColor  = Color.SkyBlue.ToVec4(),
            };

            var list            = new ActionList();
            var transformAction = new TransformAction(scene);

            list.Add(transformAction);
            var renderAction = new RenderAction(scene);

            list.Add(renderAction);
            this.actionList = list;

            Match(this.trvScene, scene.RootElement);
            this.trvScene.ExpandAll();
        }
        private void FormMain_Load(object sender, EventArgs e)
        {
            var     position = new vec3(5, 3, 4) * 0.5f;
            var     center   = new vec3(0, 0, 0);
            var     up       = new vec3(0, 1, 0);
            var     camera   = new Camera(position, center, up, CameraType.Perspective, this.winGLCanvas1.Width, this.winGLCanvas1.Height);
            Texture texture  = GetCubemapTexture();

            this.node = CubemapViewerNode.Create(texture);
            var scene = new Scene(camera);

            scene.RootNode = node;
            this.scene     = scene;

            var list            = new ActionList();
            var transformAction = new TransformAction(scene);

            list.Add(transformAction);
            var renderAction = new RenderAction(scene);

            list.Add(renderAction);
            this.actionList = list;

            //// uncomment these lines to enable manipualter of camera!
            //var manipulater = new FirstPerspectiveManipulater();
            //manipulater.BindingMouseButtons = System.Windows.Forms.MouseButtons.Right;
            //manipulater.Bind(camera, this.winGLCanvas1);
        }
Exemple #5
0
 private void Match(TreeView treeView, SceneNodeBase nodeBase)
 {
     treeView.Nodes.Clear();
     var node = new TreeNode(nodeBase.ToString()) { Tag = nodeBase };
     treeView.Nodes.Add(node);
     Match(node, nodeBase);
 }
Exemple #6
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(5, 3, 4);
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspecitive, this.winGLCanvas1.Width, this.winGLCanvas1.Height);
            var scene    = new Scene(camera);
            var rootNode = GetRootNode();

            scene.RootNode = rootNode;
            this.scene     = scene;
            this.rootNode  = rootNode;

            var list            = new ActionList();
            var transformAction = new TransformAction(scene.RootNode);

            list.Add(transformAction);
            var renderAction = new RenderAction(scene);

            list.Add(renderAction);
            this.actionList = list;

            // Enable manipualter of camera!
            var manipulater = new FirstPerspectiveManipulater();

            manipulater.BindingMouseButtons = GLMouseButtons.Right;
            manipulater.Bind(camera, this.winGLCanvas1);
        }
Exemple #7
0
 private void Match(TreeNode node, SceneNodeBase nodeBase)
 {
     try
     {
         foreach (var item in nodeBase.Children) // item is based off of SceneNodeBase
         {
             var child = new TreeNode(item.Name)
             {
                 Tag = item
             };                                                  // add a node, set its name to the Name field of item
             node.Nodes.Add(child);
             child.ImageIndex         = DeviconServe.GetDeviconIndex(item.GetType().Name);
             child.SelectedImageIndex = DeviconServe.GetDeviconIndex(item.GetType().Name);
             Match(child, item);
         }
     }
     catch (Exception ex)
     {
         if (throwFatalInsteadOfMsg)
         {
             throw;
         }
         GameFatal gf = new GameFatal(ex);
         gf.Show();
     }
 }
Exemple #8
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            SceneNodeBase rootElement = GetRootElement();

            var position = new vec3(1, 0, 4);
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspective, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene = new Scene(camera)
            {
                RootNode   = rootElement,
                ClearColor = Color.SkyBlue.ToVec4(),
            };
            var list = new ActionList();

            var transformAction = new TransformAction(scene);

            list.Add(transformAction);
            var renderAction = new RenderAction(scene);

            list.Add(renderAction);

            this.actionList = list;

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
            manipulater.StepLength = 0.1f;
        }
Exemple #9
0
 private void Match(TreeNode node, SceneNodeBase nodeBase)
 {
     foreach (var item in nodeBase.Children)
     {
         var child = new TreeNode(item.ToString()) { Tag = item };
         node.Nodes.Add(child);
         Match(child, item);
     }
 }
Exemple #10
0
        private byte[] SerializeData(SceneNodeBase node)
        {
            byte[] data = new byte[1024];
            foreach (SceneNodeBase child in node.Children)
            {
                SerializeData(child);
            }

            return(data);
        }
Exemple #11
0
 void thisManipulater_Rotated(object sender, ArcBallManipulater.Rotation e)
 {
     {
         SceneNodeBase node = this.groupNode;
         if (node != null)
         {
             node.RotationAngle = e.angleInDegree;
             node.RotationAxis  = e.axis;
         }
     }
 }
Exemple #12
0
        private void UpdateAnimationIndex(SceneNodeBase sceneNodeBase, int index)
        {
            var node = sceneNodeBase as AnimationNode;

            if (node != null)
            {
                node.AnimationIndex = index;
            }

            foreach (var item in sceneNodeBase.Children)
            {
                UpdateAnimationIndex(item, index);
            }
        }
Exemple #13
0
        private void TraverseNodes(SceneNodeBase sceneNodeBase, LogicOperationCode op)
        {
            var node = sceneNodeBase as LogicOperationNode;

            if (node != null)
            {
                node.SetOperation(op);
            }

            foreach (var item in sceneNodeBase.Children)
            {
                TraverseNodes(item, op);
            }
        }
Exemple #14
0
        private void UpdateAnimationDefaultPose(SceneNodeBase sceneNodeBase, bool defaultPose)
        {
            var node = sceneNodeBase as AnimationNode;

            if (node != null)
            {
                node.DefaultPose = defaultPose;
            }

            foreach (var item in sceneNodeBase.Children)
            {
                UpdateAnimationDefaultPose(item, defaultPose);
            }
        }
Exemple #15
0
        private void SetupBlending(SceneNodeBase sceneNodeBase, BlendSrcFactor sf, BlendDestFactor df)
        {
            var node = sceneNodeBase as RectGlassNode;

            if (node != null)
            {
                node.Blend.SourceFactor = sf;
                node.Blend.DestFactor   = df;
            }

            foreach (var item in sceneNodeBase.Children)
            {
                SetupBlending(item, sf, df);
            }
        }
Exemple #16
0
        private void SetupBlending(SceneNodeBase sceneNodeBase, BlendSrcFactor s, BlendDestFactor d)
        {
            var node = sceneNodeBase as TextBillboardNode;

            if (node != null)
            {
                node.Blend.SourceFactor = s;
                node.Blend.DestFactor   = d;
            }

            foreach (var item in sceneNodeBase.Children)
            {
                SetupBlending(item, s, d);
            }
        }
Exemple #17
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            SceneNodeBase rootElement = GetRootElement();
            WinCtrlRoot   rootControl = GetRootControl();

            var position = new vec3(1, 0, 4);
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspecitive, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene = new Scene(camera)
            {
                RootNode    = rootElement,
                RootControl = rootControl,
                ClearColor  = Color.SkyBlue.ToVec4(),
            };
            rootControl.Bind(this.winGLCanvas1);

            var list = new ActionList();

            var transformAction = new TransformAction(scene);

            list.Add(transformAction);
            var renderAction = new RenderAction(scene);

            list.Add(renderAction);

            //var guiLayoutAction = new GUILayoutAction(scene.RootControl);
            //list.Add(guiLayoutAction);
            var guiRenderAction = new GUIRenderAction(scene.RootControl);

            list.Add(guiRenderAction);

            this.actionList = list;

            Match(this.trvSceneObject, scene.RootNode);
            this.trvSceneObject.ExpandAll();

            Match(this.trvSceneGUI, scene.RootControl);
            this.trvSceneGUI.ExpandAll();

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
            manipulater.StepLength = 0.1f;
        }
Exemple #18
0
 public void Match(TreeView treeView, SceneNodeBase nodeBase)
 {
     try
     {
         treeView.Nodes.Clear(); // clear everything in the treeview
         var node = new TreeNode(nodeBase.Name)
         {
             Tag = nodeBase
         };                                                                               // add a node, set its name to the Name field of nodebase
         treeView.Nodes.Add(node);
         node.ImageIndex         = DeviconServe.GetDeviconIndex(nodeBase.GetType().Name); // get the devicon of this node
         node.SelectedImageIndex = DeviconServe.GetDeviconIndex(nodeBase.GetType().Name);
         var anode = new TreeNode(actionlist.GetType().Name)
         {
             Tag = actionlist
         };                                                                                  // anode is just the action list
         treeView.Nodes.Add(anode);
         anode.ImageIndex         = DeviconServe.GetDeviconIndex(actionlist.GetType().Name); // get the devicon of anode
         anode.SelectedImageIndex = DeviconServe.GetDeviconIndex(actionlist.GetType().Name);
         var cam = new TreeNode(pcam.GetType().Name)
         {
             Tag = pcam
         };
         treeView.Nodes.Add(cam);
         cam.ImageIndex         = DeviconServe.GetDeviconIndex(pcam.GetType().Name);
         cam.SelectedImageIndex = DeviconServe.GetDeviconIndex(pcam.GetType().Name);
         var scn = new TreeNode(scene.GetType().Name)
         {
             Tag = scene
         };
         treeView.Nodes.Add(scn);
         scn.ImageIndex         = DeviconServe.GetDeviconIndex(scn.GetType().Name);
         scn.SelectedImageIndex = DeviconServe.GetDeviconIndex(scn.GetType().Name);
         Match(node, nodeBase);    // call for each child
         Match(anode, actionlist); // call for each child
         treeView.ExpandAll();
     }
     catch (Exception ex)
     {
         GameFatal gf = new GameFatal(ex);
         gf.Show();
     }
 }
Exemple #19
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(5, 3, 4) * 0.6f;
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Ortho, this.winGLCanvas1.Width, this.winGLCanvas1.Height);
            var scene    = new Scene(camera);
            var rootNode = GetRootNode();

            scene.RootNode = rootNode;
            this.scene     = scene;
            this.rootNode  = rootNode;

            var list            = new ActionList();
            var transformAction = new TransformAction(scene);

            list.Add(transformAction);
            var renderAction = new RenderAction(scene);

            list.Add(renderAction);
            this.actionList = list;

            // Enable manipualter of camera!
            var manipulater = new FirstPerspectiveManipulater();

            manipulater.StepLength         *= 0.1f;
            manipulater.BindingMouseButtons = GLMouseButtons.Right;
            manipulater.Bind(camera, this.winGLCanvas1);

            {
                this.trackX.Value = (int)(precision * 2.5f);
                this.trackY.Value = (int)(precision * 2.5f);
                this.trackZ.Value = (int)(precision * 2.5f);
                float x = (float)this.trackX.Value / precision;
                float y = (float)this.trackY.Value / precision;
                float z = (float)this.trackZ.Value / precision;
                this.intersectionNode.SetSlicePlane(x, y, z);
                this.sliceNode.SetX(x);
                this.sliceNode.SetY(x);
                this.sliceNode.SetZ(x);
            }
        }
Exemple #20
0
 private void destroyToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         SceneNodeBase node = (SceneNodeBase)treeView1.SelectedNode.Tag;
         if (node != scene.RootNode)
         {
             node.Parent.Children.Remove(node);
             node.Dispose();
             Match(treeView1, rootElement);
         }
         else
         {
             MessageBox.Show("You cant delete the workspace, silly!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemple #21
0
        private SceneNodeBase GetRootElement()
        {
            int   lengthX = 50;
            int   lengthY = 40;
            int   lengthZ = 30;
            float scale   = 1.5f;
            var   model   = new ManyCubesModel((int)(lengthX * scale), (int)(lengthY * scale), (int)(lengthZ * scale));

            var manyCubesNode       = ManyCubesNode.Create(model);
            var deferredShadingNode = new DeferredShadingNode();

            deferredShadingNode.Children.Add(manyCubesNode);
            var fullScreenNode = FullScreenNode.Create(deferredShadingNode as ITextureSource);
            var groupNode      = new GroupNode(deferredShadingNode, fullScreenNode);

            this.deferredShadingNode = groupNode;

            var manyCubesNode0 = ManyCubesNode0.Create(model);

            this.regularNode = manyCubesNode0;

            return(groupNode);
        }
Exemple #22
0
        public void gInit(Camera pcam, DateTime time, SceneNodeBase rootElement, Client client, Server server, FirstPerspectiveManipulater camManip, ActionList actionlist, Scene scene, WinGLCanvas canvas)
        {
            var position = new vec3(5, 3, 4);
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);

            pcam        = new Camera(position, center, up, CameraType.Perspective, canvas.Width, canvas.Height); // create the camera
            rootElement = new GroupNode();                                                                       // this will be the rootnode of the scene
            //CreateGameTree(rootElement);
            scene = new Scene(pcam)                                                                              // initialises the scene, use pcam as camera
            {
                RootNode   = rootElement,
                ClearColor = Color.Black.ToVec4(),
            };
            actionlist = new ActionList();
            //treeView1.ExpandAll();
            time = new DateTime();

            var list            = new ActionList();           // iniitialise the actionlist
            var transformAction = new TransformAction(scene); // transform action

            list.Add(transformAction);
            var billboardSortAction = new BillboardSortAction(scene.RootNode, scene.Camera); // billboard sort

            list.Add(billboardSortAction);
            var renderAction = new RenderAction(scene); // render

            list.Add(renderAction);
            var billboardRenderAction = new BillboardRenderAction(scene.Camera, billboardSortAction); // billboard render

            list.Add(billboardRenderAction);
            actionlist = list;
            camManip   = new FirstPerspectiveManipulater(); // allows moving the camera
            camManip.BindingMouseButtons = GLMouseButtons.Right;
            camManip.StepLength          = 0.1f;
            camManip.Bind(pcam, canvas);
        }
Exemple #23
0
        private void BuildNode(Assimp.Node aiNode, mat4 parentTransform, AnimationModel[] models, SceneNodeBase rootElement, ref vec3 max, ref vec3 min, ref bool first)
        {
            mat4 thisTransform = parentTransform * aiNode.Transform.ToMat4();

            if (aiNode.HasMeshes)
            {
                vec3 worldPosition, scale; vec4 rotation;
                thisTransform.ParseRST(out worldPosition, out scale, out rotation);
                foreach (int meshIndex in aiNode.MeshIndices)
                {
                    AnimationModel model = models[meshIndex];
                    GetBound(model.mesh, ref max, ref min, ref first);
                    var node   = AnimationNode.Create(model);
                    var random = new Random();
                    node.DiffuseColor = Color.FromArgb(
                        (byte)random.Next(0, 256),
                        (byte)random.Next(0, 256),
                        (byte)random.Next(0, 256),
                        (byte)random.Next(0, 256)
                        );
                    node.WorldPosition = worldPosition;
                    node.Scale         = scale;
                    node.RotationAxis  = new vec3(rotation.x, rotation.y, rotation.z);
                    node.RotationAngle = rotation.w;
                    rootElement.Children.Add(node);
                }
            }

            if (aiNode.HasChildren)
            {
                foreach (Assimp.Node child in aiNode.Children)
                {
                    BuildNode(child, thisTransform, models, rootElement, ref max, ref min, ref first);
                }
            }
        }
Exemple #24
0
 public NewInstance(SceneNodeBase select, Form1 form)
 {
     InitializeComponent();
     nodebase = select;
     src_form = form;
 }