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 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; }