Ejemplo n.º 1
0
        public void Attach(SceneNode parent)
        {
            localParent = parent;
            localRoot = parent = new SceneNode(parent);
            var physicsComponent = Record.GetComponent<PhysicsComponent>();
            if (physicsComponent != null) new DebugDrawNode(parent, physicsComponent.Body);

            var transformComponent = Record.GetComponent<TransformComponent>();
            if (meshData == null) return;
            parent = new TransformNode(parent, transformComponent ?? new TransformComponent());
            var animationComponent = Record.GetComponent(default(AnimationComponent), true);
            if (animationComponent != null) parent = new AnimationNode(parent, animationComponent);
            var tri = meshData.Submeshes[0].Triangles;
            var vert = meshData.Submeshes[0].Vertices;
            var vbo = new VertexBuffer(vert.Length * SkinnedVertex.Size, BufferTarget.ArrayBuffer,
                                       BufferUsageHint.StaticDraw);
            var ibo = new VertexBuffer(tri.Length * Vector3i.Size, BufferTarget.ElementArrayBuffer,
                                       BufferUsageHint.StaticDraw);
            vbo.Write(0, vert);
            ibo.Write(0, tri);
            var vboNode = new VBONode(parent, vbo, ibo);
            foreach (var matGroup in from g in meshData.Submeshes group g by g.Material)
            {
                foreach (var geometry in matGroup)
                {
                    var mat = matGroup.Key;
                    new SubmeshNode(new MaterialNode(vboNode, mat), geometry);
                }
            }
        }
Ejemplo n.º 2
0
 public virtual void Visit(TransformNode node)
 {
     this.Visit((SceneNode)node);
 }