private SceneNodeBase GetRootNode(ICamera modelCamera) { var root = new GroupNode(); // render 'scene' to franebuffer. { int width = this.winGLCanvas1.Width, height = this.winGLCanvas1.Height; var rtt = new RenderToTexttureNode(width, height, modelCamera, new ColoredFramebufferProvider()); rtt.BackgroundColor = Color.SkyBlue; { var teapot = TeapotNode.Create(); teapot.RenderWireframe = false; rtt.Children.Add(teapot);// rendered to framebuffer, then to texture. } root.Children.Add(rtt); this.rtt = rtt; } { var group = new GroupNode(); // display 'scene' in rectangle. { var node = RectangleNode.Create(); node.TextureSource = this.rtt; node.Scale = new vec3(1, 1, 1) * 6; node.RotationAxis = new vec3(-1, 0, 0); node.RotationAngle = 90; group.Children.Add(node); } const float radius = 3; // arcball. { var model = new HalfSphere(radius, 40, 40); var node = NoShadowNode.Create(model, HalfSphere.strPosition, HalfSphere.strNormal, model.Size); var list = node.RenderUnit.Methods[0].SwitchList; var list1 = node.RenderUnit.Methods[1].SwitchList; var polygonModeSwitch = new PolygonModeSwitch(PolygonMode.Line); var offsetSwitch = new PolygonOffsetFillSwitch(); list.Add(polygonModeSwitch); list1.Add(polygonModeSwitch); var cmd = node.RenderUnit.Methods[0].VertexArrayObjects[0].DrawCommand as DrawElementsCmd; cmd.VertexCount = cmd.VertexCount / 2; // render only half a sphere. group.Children.Add(node); } // lines. { var node = LinesNode.Create(radius); group.Children.Add(node); this.linesNode = node; } // fan { var node = FanNode.Create(radius); group.Children.Add(node); this.fanNode = node; } root.Children.Add(group); this.groupNode = group; } return(root); }
private SceneNodeBase GetPropellerRTT() { var teapot = TeapotNode.Create(); teapot.Scale *= 0.5f; int width = 600, height = 400; var innerCamera = new Camera(new vec3(0, 2, 5), new vec3(0, 0, 0), new vec3(0, 1, 0), CameraType.Ortho, width, height); var rtt = new RenderToTexttureNode(width, height, innerCamera, new ColoredFramebufferProvider()); rtt.Children.Add(teapot); var billboard = TextureBillboardNode.Create(rtt as ITextureSource, width, height); var group = new GroupNode(); group.Children.Add(rtt); // rtt must be before billboard. group.Children.Add(billboard); group.WorldPosition = new vec3(3, 0.5f, 0); // this looks nice. var propeller = GetPropellerFlabellum(); propeller.Children.Add(group); return(propeller); }
private SceneNodeBase GetRootNode() { TeapotNode node = TeapotNode.Create(); node.RenderWireframe = false; //(new FormProperyGrid(node)).Show(); return(node); }
private SceneNodeBase GetRootNode() { var groupNode = new GroupNode(); { var node = CubeNode.Create(); node.Scale = new vec3(1, 1, 1) * 4; groupNode.Children.Add(node); } { var node = TeapotNode.Create(); node.RenderWireframe = false; groupNode.Children.Add(node); } return(groupNode); }
private void FormMain_Load(object sender, EventArgs e) { var teapot = TeapotNode.Create(); this.teapot = teapot; int width = 400, height = 200; var rtt = new RenderToTexttureNode(width, height, new Camera(new vec3(0, 0, 5), new vec3(0, 0, 0), new vec3(0, 1, 0), CameraType.Perspecitive, width, height), new ColoredFramebufferProvider()); rtt.Children.Add(teapot);// rendered to framebuffer, then to texture. this.rtt = rtt; var rectangle = RectangleNode.Create(); //var rectangle = new LegacyRectangleRenderer();//LegacyRectangleRenderer dosen't work in rendering-to-texture. rectangle.TextureSource = rtt; rectangle.Scale = new vec3(7, 7, 7); this.rectangle = rectangle; var group = new GroupNode(); group.Children.Add(rtt); group.Children.Add(rectangle); var position = new vec3(5, 1, 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) { ClearColor = Color.SkyBlue.ToVec4(), RootElement = group, }; var list = new ActionList(); var transformAction = new TransformAction(scene); list.Add(transformAction); var renderAction = new RenderAction(scene); list.Add(renderAction); this.actionList = list; }
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); this.teapot = TeapotNode.Create(); teapot.Children.Add(new LegacyBoundingBoxNode(teapot.ModelSize)); var ground = GroundNode.Create(); ground.Color = Color.Gray.ToVec4(); ground.Scale *= 10; ground.WorldPosition = new vec3(0, -3, 0); this.textNode = new DirectTextNode() { Text = "Color Coded Picking" }; var group = new GroupNode(this.teapot, ground, this.textNode); this.scene = new Scene(camera, this.winGLCanvas1) { RootElement = group, }; 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(); this.chkRenderWireframe_CheckedChanged(this.chkRenderWireframe, EventArgs.Empty); this.chkRenderBody_CheckedChanged(this.chkRenderBody, EventArgs.Empty); // uncomment these lines to enable manipualter of camera! //var manipulater = new FirstPerspectiveManipulater(); //manipulater.BindingMouseButtons = System.Windows.Forms.MouseButtons.Right; //manipulater.Bind(camera, this.winGLCanvas1); }
private void FormMain_Load(object sender, EventArgs e) { var position = new vec3(8, 6, 4) * 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.teapot = TeapotNode.Create(); this.teapot.Scale *= 3; teapot.Children.Add(new LegacyBoundingBoxNode(teapot.ModelSize)); string folder = System.Windows.Forms.Application.StartupPath; var totalBmp = new Bitmap(System.IO.Path.Combine(folder, @"cubemaps_skybox.png")); this.skybox = SkyboxNode.Create(totalBmp); this.skybox.Scale *= 60; var group = new GroupNode(this.teapot, this.skybox); this.scene = new Scene(camera) { RootNode = group, }; var list = new ActionList(); var transformAction = new TransformAction(scene.RootNode); list.Add(transformAction); var renderAction = new RenderAction(scene); list.Add(renderAction); this.actionList = list; var manipulater = new FirstPerspectiveManipulater(); manipulater.Bind(camera, this.winGLCanvas1); this.pickingAction = new Picking(scene); this.triangleTip = new LegacyTriangleNode(); this.quadTip = new LegacyQuadNode(); this.chkRenderWireframe_CheckedChanged(this.chkRenderWireframe, EventArgs.Empty); this.chkRenderBody_CheckedChanged(this.chkRenderBody, EventArgs.Empty); }