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.Perspective, this.winGLCanvas1.Width, this.winGLCanvas1.Height); this.scene = new Scene(camera); { var manipulater = new ArcBallManipulater(GLMouseButtons.Left | GLMouseButtons.Right); manipulater.Bind(camera, this.winGLCanvas1); manipulater.Rotated += manipulater_Rotated; var node = RaycastNode.Create(); this.scene.RootNode = node; (new FormProperyGrid(node)).Show(); } 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 Picking(scene); this.triangleTip = new LegacyTriangleNode(); this.quadTip = new LegacyQuadNode(); }
/// <summary> /// /// </summary> /// <returns></returns> public static RaycastNode Create() { var model = new BoundingBoxModel(); RenderMethodBuilder backfaceBuilder, raycastingBuilder; { var vs = new VertexShader(backfaceVert); var fs = new FragmentShader(backfaceFrag); var provider = new ShaderArray(vs, fs); var map = new AttributeMap(); map.Add("inPosition", BoundingBoxModel.strPosition); map.Add("inBoundingBox", BoundingBoxModel.strColor); backfaceBuilder = new RenderMethodBuilder(provider, map, new CullFaceSwitch(CullFaceMode.Front, true)); } { var vs = new VertexShader(raycastingVert); var fs = new FragmentShader(raycastingFrag); var provider = new ShaderArray(vs, fs); var map = new AttributeMap(); map.Add("inPosition", BoundingBoxModel.strPosition); map.Add("inBoundingBox", BoundingBoxModel.strColor); raycastingBuilder = new RenderMethodBuilder(provider, map, new CullFaceSwitch(CullFaceMode.Back, true)); } var node = new RaycastNode(model, BoundingBoxModel.strPosition, backfaceBuilder, raycastingBuilder); node.Initialize(); return(node); }