Coloring a 3D Surface
Coloring a 3D Surface
Coloring a 3D Surface
Coloring a 3D Surface
Coloring a 3D Surface
Coloring a 3D Surface Coloring a 3D Surface Coloring a 3D Surface Coloring a 3D Surface Coloring a 3D Surface Coloring a 3D Surface Coloring a 3D Surface Coloring a 3D Surface
Coloring a 3D Surface Coloring a 3D Surface
Coloring a 3D Surface
Go Back  Xtreme Visual Basic Talk > > > > Coloring a 3D Surface


Reply
 
Thread Tools Display Modes
  #1  
Old 07-31-2007, 02:50 AM
tfm tfm is offline
Newcomer
 
Join Date: Jul 2007
Posts: 2
Default Coloring a 3D Surface


I have a 3D surface which is just created of polygons, currently I can see black lines polygon like the following:
http://tabishfayyaz.googlepages.com/blackGraph.JPG

How do I color them to give a picture like the following:
http://tabishfayyaz.googlepages.com/colorGraph.JPG



In my code I create a mesh from a set of vertices I receive for a 3D surface.
Reply With Quote
  #2  
Old 10-31-2007, 08:48 AM
fixitchris's Avatar
fixitchris fixitchris is offline
Contributor
 
Join Date: Dec 2004
Posts: 418
Default

MDX9:

"lighting only works when there is normal data stored for our vertices, and since there is some normal data for our cube, maybe we should just turn lighting back on. The default lighting value for a device is enabled, so you can either remove the line setting it to false, or set it to true.

Well, we've successfully turned our white cubes into black cubes now. Hopefully you guessed this is because we have no lights in our scene, so everything is "dark," thus rendered black. Now rather than specifying specific lights, wouldn't it be great if we could just have a constant light around our entire scene? Welcome to ambient lighting.

Ambient lights provide a constant source of light for a scene. All objects in the scene will be lit exactly the same way since ambient light isn't dependent on any factors that the other lighting methods are (such as position, direction, or attenuation). You don't even really need normal data in order to use an ambient light. Ambient light is highly efficient, but doesn't produce "realistic" results. For now, though, it will produce sufficient results. Add the following line where your lighting render state was:

device.RenderState.Ambient = Color.Red;" - Tom Miller

Still Black?

"So what's different now than when we were first using lights? The only major difference (other than the fact that we are using a mesh) is the lack of color in our vertex data. This is the cause of the light "failing" now.

In order for Direct3D to correctly calculate the color of a particular point on a 3D object, it must not only know the color of the light, but how that object will reflect the color of that light. In the real world if you shine a red light on a light blue surface, that surface will appear a soft purple color. You need to describe how our "surface" (our cube) reflects light.

In Direct3D, materials describe this property. You can specify how the object will reflect ambient and diffuse lighting, what the specular highlights (discussed later) will look like, and whether the object appears to emit light at all. Add the following code to your DrawBox call (before the DrawSubset call).

Material boxMaterial = new Material();
boxMaterial.Ambient = Color.White;
boxMaterial.Diffuse = Color.White;
device.Material = boxMaterial;

Here we create a new material, and set its ambient and diffuse color values to white. Using white means we will reflect all ambient and diffuse lighting that hits these objects. We then use the Material property on the device so that Direct3D knows which material to use while rendering its data." -Tom Miller
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Coloring a 3D Surface
Coloring a 3D Surface
Coloring a 3D Surface Coloring a 3D Surface
Coloring a 3D Surface
Coloring a 3D Surface
Coloring a 3D Surface Coloring a 3D Surface Coloring a 3D Surface Coloring a 3D Surface Coloring a 3D Surface Coloring a 3D Surface Coloring a 3D Surface
Coloring a 3D Surface
Coloring a 3D Surface
 
Coloring a 3D Surface
Coloring a 3D Surface
 
-->