예제 #1
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(5, 3, 4) * 0.2f;
            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);
            {
                var manipulater = new ArcBallManipulater(System.Windows.Forms.MouseButtons.Right);
                manipulater.Bind(camera, this.winGLCanvas1);
                var node = RaycastNode.Create();
                node.BindManipulater(manipulater);
                this.scene.RootElement = node;
            }

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

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

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

            this.pickingAction = new PickingAction(scene);

            this.triangleTip = new LegacyTriangleNode();
            this.quadTip     = new LegacyQuadNode();
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static RaycastNode Create()
        {
            var model = new RaycastModel();
            RenderUnitBuilder backfaceBuilder, raycastingBuilder;
            {
                var vs       = new VertexShader(backfaceVert, "position", "boundingBox");
                var fs       = new FragmentShader(backfaceFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add("position", RaycastModel.strposition);
                map.Add("boundingBox", RaycastModel.strcolor);
                backfaceBuilder = new RenderUnitBuilder(provider, map, new CullFaceState(CullFaceMode.Front, true));
            }
            {
                var vs       = new VertexShader(raycastingVert, "position", "boundingBox");
                var fs       = new FragmentShader(raycastingFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add("position", RaycastModel.strposition);
                map.Add("boundingBox", RaycastModel.strcolor);
                raycastingBuilder = new RenderUnitBuilder(provider, map, new CullFaceState(CullFaceMode.Back, true));
            }

            var node = new RaycastNode(model, RaycastModel.strposition, backfaceBuilder, raycastingBuilder);

            node.Initialize();

            return(node);
        }