XNA--camera, lights and effects
2012-04-11 18:29
267 查看
XNA makes it simple to deal with a camera, lights, and special effects, but you do need to know the basics about these to create even a simple 3D game. After all, without a camera and lights, how can you
see what was constructed in your 3D scene.
XNA’s BasicEffect class fulfills all your needs for not only basic games, but also for some complex games. This class offers properties and methods that let youdefine
the final details to render your 3D scene. The following are some of the most important properties of this class:
•
View: The view matrix, which defines the camera position and direction. Usually created using Matrix.CreateLookAt.
• Projection: The projection matrix that’s used tomap the 3D scene coordinates to screen coordinates. Usually created throughMatrix.CreatePerspective,
Matrix.CreateOrthographic, or a similar method.
• World: The world matrix, which is used to apply transformations to all objects in the 3D scene.
• LightingEnabled: If False, the scene is rendered using a base light that illuminates all sides of all objects equally. If True, the light properties of BasicEffect will be used to light
the scene.
• AmbientLightColor: Defines the color of the ambient light, which illuminates all sides of all objects equally. It’s used only when rendering if LightingEnabled is set to True.
•
DirectionalLight0, DirectionalLight1, and DirectionalLight2: Define up to three directional lights used by the effect when rendering. Each directional light is defined by its specular color (color of the light that will have a perfect,
mirror-like reflection), its diffuse color (color of the light that will be reflected diffusely), and the light direction. These properties are used only if LightingEnabled is set to True.
• FogColor, FogStart, and FogEnd: Let you define “fog” for the scene, so objects in the fog range appear to be seen through a dense smoke. You can specify the fog color, along with the
distance in which the fog begins and ends.
see what was constructed in your 3D scene.
XNA’s BasicEffect class fulfills all your needs for not only basic games, but also for some complex games. This class offers properties and methods that let youdefine
the final details to render your 3D scene. The following are some of the most important properties of this class:
•
View: The view matrix, which defines the camera position and direction. Usually created using Matrix.CreateLookAt.
• Projection: The projection matrix that’s used tomap the 3D scene coordinates to screen coordinates. Usually created throughMatrix.CreatePerspective,
Matrix.CreateOrthographic, or a similar method.
• World: The world matrix, which is used to apply transformations to all objects in the 3D scene.
• LightingEnabled: If False, the scene is rendered using a base light that illuminates all sides of all objects equally. If True, the light properties of BasicEffect will be used to light
the scene.
• AmbientLightColor: Defines the color of the ambient light, which illuminates all sides of all objects equally. It’s used only when rendering if LightingEnabled is set to True.
•
DirectionalLight0, DirectionalLight1, and DirectionalLight2: Define up to three directional lights used by the effect when rendering. Each directional light is defined by its specular color (color of the light that will have a perfect,
mirror-like reflection), its diffuse color (color of the light that will be reflected diffusely), and the light direction. These properties are used only if LightingEnabled is set to True.
• FogColor, FogStart, and FogEnd: Let you define “fog” for the scene, so objects in the fog range appear to be seen through a dense smoke. You can specify the fog color, along with the
distance in which the fog begins and ends.
//Set object and camera info effect.World = worldRotation * worldTranslation * worldRotation; effect.View = camera.view; effect.Projection = camera.projection; effect.Texture = texture; effect.TextureEnabled = true;
// Begin effect and draw for each pass foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); //GraphicsDevice.DrawUserPrimitives<VertexPositionTexture> (PrimitiveType.TriangleStrip, verts, 0, 2); }
相关文章推荐
- [论文摘要]Tips and Tricks for D3DX Effects-Based Renders
- CSU 1784 Internet of Lights and Switches(状态压缩+组合计数)
- Unity Shaders and Effects Cookbook (1-3) 创建 Half Lambert 光照模型
- CameraNameAndVersion
- Water-drop 节选翻译 ----Dynamic rain and its effects
- Unity Shaders and Effects Cookbook (2-6) 在 C# 代码中创建 Texture2D 并赋值给 Shader
- Detecting and Probing the Camera(检测,探测相机)
- [转]8 Awesome HTML5 and Javascript Effects
- WHAT IS ISO? A CAMERA’S SENSITIVITY TO LIGHT EXPLAINED, AND HOW TO USE IT
- Android开发指南(32) —— Multimedia and Camera - Audio Capture
- Unity Shaders and Effects Cookbook (3-3) 创建 BlinnPhong 光照模型
- Unity Shaders and Effects Cookbook (3-4) 使用高光贴图
- Unity Shaders and Effects Cookbook (5-1)LitSphere lighting model
- Multimedia and Camera - Media Playback
- Unity Shaders and Effects Cookbook (6-2) 透明裁剪着色器
- Android API Guide for Media and Camera(二)—— 媒体与相机(媒体记录器)
- A. Mashmokh and Lights
- The Design of XNA Camera
- 7.【cocos2d翻译系列】Actions, Transformations and Effects--Composition actions
- 【Unity Shaders】《Unity Shaders and Effects Cookbook》总结篇