Roy Triesscheijn’s Weblog

My programming world

Archive for April, 2011

Codesnippet: VertexPositionColorNormal

Posted by Roy Triesscheijn on 13th April 2011

For some prototyping I needed a struct like VertexPositionColor, but I also needed a normal, after a minute of Googling I found out that nobody wrote a small (XNA4) compatible snippet) for this. So here I give you my own snippet. (Which also is a handy reference to see how the ‘new’ IVertexType interface in XNA4 works (yes I still think of XNA4 as new).

Anyway the source code:

    public struct VertexPositionColorNormal : IVertexType
    {
        public Vector3 Position;
        public Color Color;
        public Vector3 Normal;

        public VertexPositionColorNormal(Vector3 position, Color color, Vector3 normal)
        {
            this.Position = position;
            this.Color = color;
            this.Normal = normal;
        }

        public static readonly VertexElement[] VertexElements =
        {
            new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
            new VertexElement(sizeof(float)*3, VertexElementFormat.Color, VertexElementUsage.Color, 0),
            new VertexElement(sizeof(float)*4, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0)
        };
        public static readonly VertexDeclaration vertexDeclaration = new VertexDeclaration(VertexElements);

        public VertexDeclaration VertexDeclaration
        {
           get { return vertexDeclaration; }
        }
    }

Tags: , , ,
Posted in Blog, XNA | No Comments »

OpenGL Slides #2, Gooch Illumination and edge detection

Posted by Roy Triesscheijn on 9th April 2011

As I’ve mentioned in a previous post I’ve been working a lot with OpenGL lately for a CG class. Every week we gave a presentation about some features and implementation details, to bad a lot of it is too much out of context if you haven’t followed the class. However I’ve found a few slides about cool-to-warm shading (a technique by Amy Gooch) and edge detection that are separate enough to post here, I hope it’s useful!

Tags: , , ,
Posted in Blog | No Comments »