Archived

This topic is now archived and is closed to further replies.

BGCJR

Lesson 27

Recommended Posts

I have a problem with it not showing shadows after modifing it.
    counter=0;counter2 = 0;
	
	// second pass, stencil operation increases stencil value

	glFrontFace(GL_CCW);
	glStencilOp(GL_KEEP,GL_KEEP, GL_DECR);
	//MessageBox(NULL,"Start Pass2","Layer2",MB_OK);

	for (i=0; i<nPlanes;i++){
		if (planes[i].visible)
			for (j=0;j<3;j++){
				k = planes[i].neigh[j];
				if ((!k) || (!planes[k-1].visible))
				{
					// here we have an edge, we must draw a polygon

					p1 = planes[i].p[j];
					jj = (j+1)%3;
					p2 = planes[i].p[jj];

					
					//calculate the length of the vector

					v1.x = (points[p1].x - lp[0])*100;
					v1.y = (points[p1].y - lp[1])*100;
					v1.z = (points[p1].z - lp[2])*100;

					v2.x = (points[p2].x - lp[0])*100;
					v2.y = (points[p2].y - lp[1])*100;
					v2.z = (points[p2].z - lp[2])*100;
					
					//draw the polygon

					//glEnable(GL_CULL_FACE);

		
					vbuffer[counter] = points[p1].x; counter++;
					vbuffer[counter] = points[p1].y; counter++;
					vbuffer[counter] = points[p1].z; counter++;
                    elements[counter2]= counter2;
					counter2++;
					vbuffer[counter] = points[p1].x+v1.x; counter++;
					vbuffer[counter] = points[p1].y+v1.y; counter++;
					vbuffer[counter] = points[p1].z+v1.z; counter++;
                       elements[counter2]= counter2;
					counter2++;                 
					vbuffer[counter] = points[p2].x; counter++;
					vbuffer[counter] = points[p2].y; counter++;
					vbuffer[counter] = points[p2].z; counter++;
                    elements[counter2]= counter2;
					counter2++;
					vbuffer[counter] = points[p1].x+v1.x; counter++;
					vbuffer[counter] = points[p1].y+v1.y; counter++;
					vbuffer[counter] = points[p1].z+v1.z; counter++;
                    elements[counter2]= counter2;
					counter2++;
					vbuffer[counter] = points[p2].x; counter++;
					vbuffer[counter] = points[p2].y; counter++;
					vbuffer[counter] = points[p2].z; counter++;
                    elements[counter2]= counter2;
					counter2++;
					vbuffer[counter] = points[p2].x + v2.x; counter++;
					vbuffer[counter] = points[p2].y + v2.y; counter++;
					vbuffer[counter] = points[p2].z + v2.z; counter++;
	                elements[counter2]= counter2;
					counter2++;	


					//glDisable(GL_CULL_FACE);

				}
			}
	}
I had to change facing for the model. Disabling the second pass (which is above) looks fine, but when i re-enable it. i get nothing til i move. then i get a stationary black clone of the model. Anyone? Bobby

Share this post


Link to post
Share on other sites
Ehr... if it did show shadows fine before you modified it, why did you modify it, to begin with?

You should try to understand each step first before messing around with it. And, instead of posting the modified code only, it''d be a little more helpfull if you could post something like ''I had this'' - ''I turned it into that'' (line by line! Not two large chunks of code). Would make it easier for people to tell what changes you have done, and what exactly the consequences of those change are.

Share this post


Link to post
Share on other sites
i went through everything with culling, looked up trianglestrip for even is like n+1,n,n+2.
as for the black clone, erasing stencil buffer did help.:S
so now, i use a model with two shadowing lightpoints.
vsync off ranging from 240 to 400 fps.
though, the scene is not complex.
Bobby

Share this post


Link to post
Share on other sites