Пример #1
0
        private void createVertexBuffer(Model model)
        {
            MeshData meshTeapot = model.Mesh;

            // teapot
            vbTeapot = new VertexBuffer(meshTeapot.VertexCount,
                                        meshTeapot.IndexCount,
                                        VertexFormat.Float3,
                                        VertexFormat.Float3,
                                        VertexFormat.Float3,
                                        VertexFormat.Float2);
            vbTeapot.SetVertices(0, meshTeapot.Positions);
            vbTeapot.SetVertices(1, meshTeapot.Normals);
            vbTeapot.SetVertices(2, meshTeapot.Tangents);
            vbTeapot.SetVertices(3, meshTeapot.TexCoords);
            vbTeapot.SetIndices(meshTeapot.Indices);


            // grid
            meshGrid = BasicMeshFactory.CreatePlane(40.0f, 40.0f,
                                                    10, 10, 0.25f, 0.25f);


            vbGrid = new VertexBuffer(meshGrid.VertexCount,
                                      meshGrid.IndexCount,
                                      VertexFormat.Float3,
                                      VertexFormat.Float3,
                                      VertexFormat.Float3,
                                      VertexFormat.Float2);
            vbGrid.SetVertices(0, meshGrid.Positions);
            vbGrid.SetVertices(1, meshGrid.Normals);
            vbGrid.SetVertices(2, meshGrid.Tangents);
            vbGrid.SetVertices(3, meshGrid.TexCoords);
            vbGrid.SetIndices(meshGrid.Indices);
        }
Пример #2
0
        public BgModel(float width, float depth, int divW, int divH)
        {
            // grid
#if false
            meshGrid = BasicMeshFactory.CreateGrid(width, depth,
                                                   divW, divH,
                                                   new Rgba(128, 128, 128, 255),
                                                   new Rgba(255, 0, 0, 255),
                                                   new Rgba(0, 255, 0, 255));
#else
            meshGrid = BasicMeshFactory.CreatePlane(width, depth,
                                                    divW, divH, 0.25f, 0.25f);
#endif

            vbGrid = new VertexBuffer(meshGrid.VertexCount,
                                      meshGrid.IndexCount,
                                      VertexFormat.Float3,
                                      VertexFormat.Float2);
            vbGrid.SetVertices(0, meshGrid.Positions);
            vbGrid.SetVertices(1, meshGrid.TexCoords);

            vbGrid.SetIndices(meshGrid.Indices);


            // vertex color shader
            shaderVtxColor = new ShaderProgram("/Application/Sample/Graphics/ShaderCatalogSample/shaders/Texture.cgx");
            shaderVtxColor.SetAttributeBinding(0, "a_Position");
            shaderVtxColor.SetAttributeBinding(1, "a_TexCoord");
            texture = new Texture2D("/Application/Sample/Graphics/ShaderCatalogSample/data/renga.png", false);
            texture.SetWrap(TextureWrapMode.Repeat);

            posture = Matrix4.Translation(new Vector3(0.0f, 0.0f, 0.0f));
        }
Пример #3
0
    private void createVertexBuffer( MeshData meshTeapot )
    {
        // teapot
		vbTeapot = new VertexBuffer( meshTeapot.VertexCount,
                                     meshTeapot.IndexCount,
                                     VertexFormat.Float3,
                                     VertexFormat.Float2 );
		vbTeapot.SetVertices( 0, meshTeapot.Positions );
        vbTeapot.SetVertices( 1, meshTeapot.TexCoords );
		vbTeapot.SetIndices( meshTeapot.Indices );


        // shadow map(simple)
        shaderShadowMap = new ShaderProgram( "/Application/Sample/Graphics/ShaderCatalogSample/shaders/Simple.cgx" );
		shaderShadowMap.SetAttributeBinding( 0, "a_Position" );

        // texture
        shaderTexture = new ShaderProgram( "/Application/Sample/Graphics/ShaderCatalogSample/shaders/Texture.cgx" );
        shaderTexture.SetAttributeBinding( 0, "a_Position" );
        shaderTexture.SetAttributeBinding( 1, "a_TexCoord" );
        texColorMap = new Texture2D( "/Application/Sample/Graphics/ShaderCatalogSample/data/renga.png", false );
        texColorMap.SetWrap( TextureWrapMode.Repeat );

        // grid
        meshGrid = BasicMeshFactory.CreatePlane( 40.0f, 40.0f,
                                                 10, 10, 0.25f, 0.25f );

        vbGrid = new VertexBuffer( meshGrid.VertexCount,
                                   meshGrid.IndexCount,
                                   VertexFormat.Float3,
                                   VertexFormat.Float2 );

		vbGrid.SetVertices( 0, meshGrid.Positions );
		vbGrid.SetVertices( 1, meshGrid.TexCoords );
		vbGrid.SetIndices( meshGrid.Indices ) ;

        // projection shadow
        shaderProjectionShadow = new ShaderProgram( "/Application/Sample/Graphics/ShaderCatalogSample/shaders/ProjectionShadow.cgx" );
        shaderProjectionShadow.SetAttributeBinding( 0, "a_Position" );
        shaderProjectionShadow.SetAttributeBinding( 1, "a_TexCoord0" );
    }