//private SceneNodeBase GetRootNode() //{ // var group = new GroupNode(); // { // Texture texture = this.GetTexture(); // var node = FixedSizeQuadNode.Create(200, 100, texture); // group.Children.Add(node); // this.triangleNode = node; // } // return group; //} private SceneNodeBase GetTree() { const float length = 6; var group = new GroupNode(); { var floor = CubeNode.Create(); floor.Scale = new vec3(length, 0.1f, length); floor.Color = Color.Brown.ToVec4(); group.Children.Add(floor); } Texture texture = this.GetTexture(); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { float x = -length / 2 + length / 2 * i; float y = 0.25f; float z = -length / 2 + length / 2 * j; var stick = CubeNode.Create(); stick.Scale = new vec3(0.1f, y * 2, 0.1f); stick.WorldPosition = new vec3(x, y, z); stick.Color = Color.Green.ToVec4(); group.Children.Add(stick); { var node = FixedSizeQuadNode.Create(200, 70, texture); node.WorldPosition = new vec3(0, y * 4, 0); stick.Children.Add(node); } } } return(group); }
public static FixedSizeQuadNode Create(int width, int height, Texture texture) { var model = new FixedSizeQuadModel(width, height); var vs = new VertexShader(vertexCode); var fs = new FragmentShader(fragmentCode); var array = new ShaderArray(vs, fs); var map = new AttributeMap(); map.Add("inPosition", FixedSizeQuadModel.strPosition); map.Add("inUV", FixedSizeQuadModel.strUV); var builder = new RenderMethodBuilder(array, map); var node = new FixedSizeQuadNode(model, builder); node.texture = texture; node.Initialize(); return(node); }