Presentation is loading. Please wait.

Presentation is loading. Please wait.

3D Part3 CMT3317.

Similar presentations


Presentation on theme: "3D Part3 CMT3317."— Presentation transcript:

1 3D Part3 CMT3317

2 Scene objects Some cheap world objects can be made with simple shapes like planes and transparency – like transparency is used in 2D Far away objects that the player will never be let near can be approximated by images or photos attached to planes

3 Fir tree This cheap fir tree is an image attached to a plane

4 Oak tree This slightly more complex example uses two planes
Many other simple shapes can be used to make objects e.g. cones etc In the game the black areas need to be transparent

5 Class changes Since 3D step1 some classes have changed. The helper class() has been removed and simpleObject updated. It seem logical to revise the ship class to input handing is done in the main program The ship class now has function to rotate around each axis in a positive or negative direction – and to advance, retreat and reset its position.

6 Ship: rotation around the y axis – x and z are similar

7 Ship: advance, retreat, reset

8 Input handling Input handling is now done in Game1.cs

9

10 Simple object SimpleObject() is as it was but the functions …
SetupEffectTransformDefaults() Draw() … have been moved out of the Helper Class and into SimpleObject()

11 SimpleBlendedObject()
In order to use transparency we need to turn on alpha blending in the Draw() function We create a new class SimpleBlendedObject which is subclassed from SimpleObject and contains a draw function DrawBlendedModel()

12 DrawBlendedModel DrawBlendedModel() turns on alpha blending
Draws as usual Then turns alpha blending off

13 Class SimpleBlendedObject

14 Objects with alpha blending

15 Billboarding A billboard is a plane with a texture on it that always rotates to face the camera so that the player never sees that it is just a plane We make a class BillboardObject which is a subclass of SimpleBlendedObject () The matrix class has a method to rotate the object based on the camera parameters: Matrix.CreateConstrainedBillboard()

16 Billboard: draw() and billboard() functions

17 The fir tree always faces the camera. See Step3_3D_Billboard.zip

18 Lighting problem One problem with billboarding is that the lighting of the object means that its brightness changes as it rotates To stop this we turn of lighting inside the SetupEffectTransformDefaults() function, so the Billboard class overrides the inherited version of this function

19 Beware of textures on plane
Mathematically planes only have an inside and an outside - they are one sided -which means textured planes disappear when viewed from the wrong side, as with this red tree

20 MS example There is a nice example also at XNA creators club
Its complex though, nearly all the work is done in the shader – it includes a wind model that appears to blow the trees and grass around

21 MS Example


Download ppt "3D Part3 CMT3317."

Similar presentations


Ads by Google