DOC PREVIEW
GT ECE 4893 - Lecture 9: Drawing Models & Primitives with BasicEffect

This preview shows page 1-2-3 out of 8 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

9/17/08 1 Lecture 9: Drawing Models & Primitives with BasicEffect Prof. Aaron Lanterman School of Electrical and Computer Engineering Georgia Institute of Technology “How to: render a model” 2 http://msdn.microsoft.com/en-us/library/bb203933.aspx How to peek at the model structure 3 http://msdn.microsoft.com/en-us/library/bb203933.aspx Bones & Meshes 4 http://msdn.microsoft.com/en-us/library/bb203933.aspx9/17/08 2 In meshes: BoundingSpheres & Effects http://msdn.microsoft.com/en-us/library/bb203933.aspx In meshes: IndexBuffer & VertexBuffer http://msdn.microsoft.com/en-us/library/bb203933.aspx DrawModel (initialization) http://msdn.microsoft.com/en-us/library/bb203933.aspx CopyAbsoluteBoneTransformsTo http://msdn.microsoft.com/en-us/library/ microsoft.xna.framework.graphics.model.copyabsolutebonetransformsto.aspx9/17/08 3 DrawModel (main loop) http://msdn.microsoft.com/en-us/library/bb203933.aspx How to: use BasicEffect For our purposes, we’re mostly interested in learning how to draw primitives http://msdn.microsoft.com/en-us/library/bb203926.aspx VertexBuffer • Contains list of vertices – 4-D colors (r,g,b,a) – 3-D positions (x,y,z) – 2-D texture coordinates (u,v) – 3-D normals • Structures: – VertexPositionColor – VertexPositionColorTexture – VertexPositionNormalTexture – VertexPositionTexture – Can make your own with VertexElement; see “How To: Create and Use a Custom Vertex” http://msdn.microsoft.com/en-us/library/bb976065.aspx Declare some variables http://msdn.microsoft.com/en-us/library/bb203926.aspx9/17/08 4 Set up cube (1) http://msdn.microsoft.com/en-us/library/bb203926.aspx Set up cube (2) etc. etc. http://msdn.microsoft.com/en-us/library/bb203926.aspx Set up cube (3) http://msdn.microsoft.com/en-us/library/bb203926.aspx Set up basicEffect (instance of BasicEffect) http://msdn.microsoft.com/en-us/library/bb203926.aspx9/17/08 5 PrimitiveType Enumeration http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.priamitivetype.aspx Draw lit cube with BasicEffect startVertex primitiveCount (MaxPrimitiveCount depends on primitiveType) http://msdn.microsoft.com/en-us/library/bb203926.aspx DrawIndexedPrimitives example • Example set up: graphics.GraphicsDevice.Vertices[0].SetSource( vertexBuffer, 0, VertexPositionNormalTexture.SizeInBytes); graphics.GraphicsDevice.Indices = lineListIndexBuffer; • Call structure: public void DrawIndexedPrimitives( PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount ) http://msdn.microsoft.com/en-us/library/ microsoft.xna.framework.graphics.graphicsdevice.drawindexedprimitives.aspx BasicEffect handles 12 different cases • Internally set ShaderIndex parameter: – 0: Flat color – 1: Vertex colors – 2: Textured – 3: Textured + Vertex colors – 4: Lit – 5: Lit + Vertex colors – 6: Lit + Textured – 7: Lit + Textured + Vertex colors – 8: Per-pixel lit – 9: Per-pixel lit + Vertex colors – 10: Per-pixel lit + Textured – 11: Per-pixel lit + Textured + Vertex colors http://creators.xna.com/en-us/utilities/basiceffectshader9/17/08 6 BasicEffect handles 3 directional lights • Parameters: – AmbientLightColor – DirLight0Direction – DirLight0DiffuseColor – DirLight0SpecularColor – DirLight1Direction – DirLight1DiffuseColor – DirLight1SpecularColor – DirLight2Direction – DirLight2DiffuseColor – DirLight2SpecularColor http://creators.xna.com/en-us/utilities/basiceffectshader More BasicEffect parameters • Material properties (colors range 0 to 1) – DiffuseColor – EmissiveColor – SpecularColor – SpecularPower – Alpha • Fog properties – FogEnabled (0 to disable, 1 to enable) – FogStart – FogEnd – FogColor http://creators.xna.com/en-us/utilities/basiceffectshader BasicEffect is just a shader (.fx file) // Texture sampler uniform const texture BasicTexture; uniform const sampler TextureSampler : register(s0) = sampler_state { Texture = (BasicTexture); MipFilter = Linear; MinFilter = Linear; MagFilter = Linear; }; // Fog settings uniform const float FogEnabled : register(c0); uniform const float FogStart : register(c1); uniform const float FogEnd : register(c2); uniform const float3 FogColor : register(c3); uniform const float3 EyePosition : register(c4); // in world space // Material settings uniform const float3 DiffuseColor : register(c5) = 1; uniform const float Alpha : register(c6) = 1; uniform const float3 EmissiveColor : register(c7) = 0; uniform const float3 SpecularColor : register(c8) = 1; uniform const float SpecularPower : register(c9) = 16; http://creators.xna.com/en-us/utilities/basiceffectshader BasicEffect is just a shader (.fx file) // Texture sampler uniform const texture BasicTexture; uniform const sampler TextureSampler : register(s0) = sampler_state { Texture = (BasicTexture); MipFilter = Linear; MinFilter = Linear; MagFilter = Linear; }; // Fog settings uniform const float FogEnabled : register(c0); uniform const float FogStart : register(c1); uniform const float FogEnd : register(c2); uniform const float3 FogColor : register(c3); uniform const float3 EyePosition : register(c4); // in world space // Material settings uniform const float3 DiffuseColor : register(c5) = 1; uniform const float Alpha : register(c6) = 1; uniform const float3 EmissiveColor : register(c7) = 0; uniform const float3 SpecularColor : register(c8) = 1; uniform const float SpecularPower : register(c9) = 16; http://creators.xna.com/en-us/utilities/basiceffectshader9/17/08 7 BasicEffect is just a shader (2) //----------------------------------------------------------------------------- // Vertex shader inputs //----------------------------------------------------------------------------- struct VSInput { float4 Position : POSITION; }; struct VSInputVc { float4 Position : POSITION; float4 Color : COLOR; }; struct VSInputNm { float4 Position : POSITION; float3 Normal : NORMAL; }; struct VSInputNmVc { float4 Position : POSITION; float3 Normal : NORMAL; float4 Color : COLOR; }; http://creators.xna.com/en-us/utilities/basiceffectshader BasicEffect is just a shader (3)


View Full Document

GT ECE 4893 - Lecture 9: Drawing Models & Primitives with BasicEffect

Documents in this Course
Load more
Download Lecture 9: Drawing Models & Primitives with BasicEffect
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 9: Drawing Models & Primitives with BasicEffect and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 9: Drawing Models & Primitives with BasicEffect 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?