Sign in to follow this  

problem with the shadow effect

This topic is 3737 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have oppened another thread where i asked for help on how to find the plane equation wich is : AX+BY+CZ+d = 0. fist thanks for the help , second i found that the equation is very simple and can be reduce to : A = y1* ( z2 - z3 ) + y2 *( z3 - z1 ) + y3 *( z1 - z2 ); B = z1 *( x2 - x3 ) + z2 *( x3 - x1 ) + z3 *( x1 - x2 ); C= x1 *( y2 - y3 ) + x2 *( y3 - y1 ) + x3 *( y1 - y2 ); D = - x1 *( y2*z3 - y3*z2 ) - x2* ( y3*z1 - y1*z3 ) - x3* ( y1*z2 - y2*z1 ); as it is written in the article in : http://www.gamedev.net/reference/articles/article415.asp No i have a new problem : it doesnt show the shadow , i'm working with the book :"Advanced Graphic Programming " and it's not working . it show the object (that for know is a simple rectangle ) but it doesnt show the shadow projection . thanks in advance .

Share this post


Link to post
Share on other sites
hi!

I misread your first post, as I didn't understand you were looking for plane equation :$
First I think you should reply in the same thread for keeping things together.
Without any calculation I can told you that your plane normal is (0, 0, 1) (or (0,0, -1), depending on the order of the point).
Can you give us the piece of code that do the projection? (and other rendering)

Share this post


Link to post
Share on other sites
Sorry for the late reply , the piece of code is :

void LoadShadowMatrix()
{
float p1[3] = {-3,3,0},p2[3] = {3,3,0},p3[3] = {3,-3,0};
float x1,x2,x3,y1,y2,y3,z1,z2,z3;
float A,B,C,D;
float dot;
float shadowMat[4][4];
float ground[4], light[4];


x1 = p1[0];x2 = p2[0];x3 = p3[0];
y1 = p1[1];y2 = p2[1];y3 = p3[1];
z1 = p1[2];z2 = p2[2];z3 = p3[2];
A = y1* ( z2 - z3 ) + y2 *( z3 - z1 ) + y3 *( z1 - z2 );
B = z1 *( x2 - x3 ) + z2 *( x3 - x1 ) + z3 *( x1 - x2 );
C= x1 *( y2 - y3 ) + x2 *( y3 - y1 ) + x3 *( y1 - y2 );
D = - x1 *( y2*z3 - y3*z2 ) - x2* ( y3*z1 - y1*z3 ) - x3* ( y1*z2 - y2*z1 );

ground[0] = A;ground[1] = B;ground[2] = C;ground[3] = D;
light[0] = pos[0];light[1] = pos[1];light[2] = pos[2];light[3] = pos[3];
dot = ground[0] * light[0] + ground[1] * light[1] + ground[2] * light[2] + ground[3] * light[3];

shadowMat[0][0] = dot - light[0] * ground[0];
shadowMat[1][0] = 0.0 - light[0] * ground[1];
shadowMat[2][0] = 0.0 - light[0] * ground[2];
shadowMat[3][0] = 0.0 - light[0] * ground[3];
shadowMat[0][1] = 0.0 - light[1] * ground[0];
shadowMat[1][1] = dot - light[1] * ground[1];
shadowMat[2][1] = 0.0 - light[1] * ground[2];
shadowMat[3][1] = 0.0 - light[1] * ground[3];
shadowMat[0][2] = 0.0 - light[2] * ground[0];
shadowMat[1][2] = 0.0 - light[2] * ground[1];
shadowMat[2][2] = dot - light[2] * ground[2];
shadowMat[3][2] = 0.0 - light[2] * ground[3];
shadowMat[0][3] = 0.0 - light[3] * ground[0];
shadowMat[1][3] = 0.0 - light[3] * ground[1];
shadowMat[2][3] = 0.0 - light[3] * ground[2];
shadowMat[3][3] = dot - light[3] * ground[3];

glMultMatrixf((const GLfloat*)shadowMat); // Load The shadowMatrix .

}

in the glScene function i do :

void glscene()
{
...
...
...
DrawObject(false) ; // Draw Object , False means not for shadow
LoadShadowMatrix();
DrawObject(true) ; // Draw Object , true means for shadows
...
...
}

the DrawObject() function receive as argument true or false and i use it to determine the color of the objects . Yellow when false or black when true.




Share this post


Link to post
Share on other sites

This topic is 3737 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this