Additional Examples
§
Line-Sphere Intersection:
o
Here is the source
o
Here is the accompanied diagram
Some
of the following examples are based on older versions of the libraries. In all
cases, the idea remains the same though.
|
1. Problem with Hardware Shading: Some examples of confusing hardware shading problems. |
|
2. Drawing 2D and
3D in the same window: Pay attention to DrawOnlyHandler::DrawGraphics(),
after we are done drawing 3D is where all the 2D stuff happens. (Download Source Code) |
|
3. Working with 2D
and 3D Windows: Check on 2D Control Window to see the 2D view of the 3D
world. In the 2D window, you can LMB click and drag either the teapot or the
plane. The 2D window is like a 2D plane for supporting UI. (Download Source Code) |
|
4. Shadow
Reflection and Stencil: We will discuss this in class! (Download Source Code) |
|
5. Interesting
Texture Effects: o
Draw textures: (here is
the source code) 1.
TdrawTexture class: now sub-class from Ttexture
.
2.
Tworld:
for any primitive
that we can display textures (primitives with area: i.e. Tfillable): we have
these new attributes:
o
Bubble texture: (here is
the source code): simple tiny changes in
TdrawTexture::UpdateTexture(), now instead of simply copy my 2D numbers into
the hardware
I did a little bit of a trick
floating my texture and
enlighten things a little
ok, pretty lame bubbles, but kind of interesting
isnt it? Now .what if I can control what is in the buffer, such that
o
Fire Texture: (here is
the source code):
|
|
6. Fog: purely
based on distance to camera. If you have ore than one views, the result looks
strange! (here is the source code). |
|
7. X-Ray-light: now
we are really hacking! I will talk about this in class. (here is the source code). |