   [C++]LOTS of basic DirectX lighting questions...
  im viewing a tutorial on lightning and i dont understand it... #ifndef CUCUSTOMVERTEX_H#define CUCUSTOMVERTEX_H#include "stdafx.h"namespace cuCustomVertex{/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *Summary: Position* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */typedef struct Position{public:   Position() : X(0), Y(0), Z(0) {}   Position( float x, float y, float z )  : X(x), Y(y), Z(z) {}   float X, Y, Z;} Position;/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *Summary: Position and color* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */typedef struct PositionColor{public:   PositionColor() : X(0), Y(0), Z(0), Color(0) {}   PositionColor( float x, float y, float z, DWORD color )  : X(x), Y(y), Z(z), Color(color) {}   float X, Y, Z;   DWORD Color;} PositionColor;/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *Summary: Position, color, texture coordinates* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */typedef struct PositionColorTextured{public:   PositionColorTextured() : X(0), Y(0), Z(0), Color(0), Tu(0), Tv(0) {}   PositionColorTextured( float x, float y, float z, DWORD color, float tu, float tv )  : X(x), Y(y), Z(z), Color(color), Tu(tu), Tv(tv) {}   float X, Y, Z;   DWORD Color;   float Tu, Tv;} PositionColorTextured;/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *Summary: Position, color, texture coordinates* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */typedef struct PositionNormalTextured{public:   PositionNormalTextured() : X(0), Y(0), Z(0), Nx(0), Ny(0), Nz(0), Tu(0), Tv(0) {}   PositionNormalTextured( float x, float y, float z, float nx, float ny, float nz, float tu, float tv )  : X(x), Y(y), Z(z), Nx(nx), Ny(ny), Nz(nz), Tu(tu), Tv(tv) {}   float X, Y, Z;   float Nx, Ny, Nz;   float Tu, Tv;} PositionNormalTextured;}#endif my first question is i dont get how this worksFunction() : X(0), Y(0) etc..thenFunction(arguments) : X(x), Y(y) etc..i dont get that.does it have to do with (if-this ? do this : otherwise this)??now with lighting.i dont get what normals are and how they effect lighting can anone expplain normals to me?ZeroMemory( &m_light, sizeof( D3DLIGHT9 ) );m_light.Type = D3DLIGHT_SPOT;m_light.Diffuse.r = 1.0f;m_light.Diffuse.g = 1.0f;m_light.Diffuse.b = 1.0f;m_light.Direction.x = 0.0f;m_light.Direction.y = -0.5f;m_light.Direction.z = 1.0f;m_light.Range = 1000.0f;m_light.Falloff = 1.0f;m_light.Attenuation0 = 1.0f;m_light.Theta = D3DXToRadian( 10.0f );m_light.Phi = D3DXToRadian( 15.0f ); i dont know what Phi, Theta, Attenuation, Falloff, and Range doalso what is the difference between ambient and diffuse light?and what types of lights are there and how do you use them?thanks in advance!   
  God; those are a lot of questions. I'd suggest that you focus on one part at the time. Some questions are simply C++ related, some are general 3D graphics theory and some are lighing specific. You'd be better off learning basic C++ and ignoring some more advanced constructs for a while, then study basic 3D graphics theory and then dive into lighting if you wish. That said, here are some short replies.Quote:my first question is i dont get how this worksFunction() : X(0), Y(0) etc..These are not simply functions but constructors and the things following the colon are an initializer list. They allow you to immediately set the value for variables instead of explicitly initializing them in the constructor. This is slightly more efficient. Example:class Vector{protected:  int x;  int y;public:  Vector( int _x, int _y )  {    x = _x;    y = _y;  }  // Equivalent results:  Vector( int _x, int _y ) : x(_x), y(_y)  {  }}Quote:i dont get what normals are and how they effect lighting can anone expplain normals to me?Normals are vectors pointing outwards of a surface (triangle, polygon, etc) in a perpendicular way. So, for a sphere they would point in all directions, for a cube there would be six general directions, etc. At each point of the surface they point right away from it.In lighting, they are used to compute the amount of light reflected. This is done by taking the vector that represents the incoming light direction and computing a dot product with the normal. The normal is usually unit length for lighting.Quote:i dont know what Phi, Theta, Attenuation, Falloff, and Range doFor spotlights, Phi and Theta determine the angle of the inner and outer light cones. Refer to the SDK for explanations with pictures. Falloff indicates the amount of light decay between the (bright) inner cone and the (darker) outer cone. Attenuation is general light decay for all light types, thus how much the light becomes darker when an object is further away. Range specifies a hard limit on the light influence (so within the range an object is attenuated i.e. smoothly decayed if you wish, outside the range it is simply not lit).Quote:also what is the difference between ambient and diffuse light?Ambient light is light that contributes to all surfaces equally, regardless of directions and calculations. It is a constant amount that is added to all surfaces. Ambient light can be used to increase the global illumination a bit.Diffuse light is light that is scattered off of a surface depending on the direction of the incoming rays and the surface orientation (its normal). So, diffuse light is different for each surface and depends on its context.Quote:and what types of lights are there and how do you use them?Many, but most common are:- directonal light (light coming from a general direction, and coming in parallel rays, much like the sun)- point lights (a sphere of light around a single point)- spot lights (a cone of light targeted to a specific point)Refer to the SDK documentation to see how they work. There are many explanations in there, with pictures and all, which will do much better than what I can do here.Good luck. Illco.PS: I've tried to give intuitive answers, not exact definitions or such because I figured this would be more useful. For definitions etc. also see the SDK.[Edited by - Illco on December 28, 2005 5:00:17 AM];  Thank you so much that answered all my questions i really appreciate it+rating   