OPENGL mit Visual c++ - Schatten läuft mit :(



  • Hallo,

    Folgendes. Ich habe mein Programm mit Stancil-Shadows ausgestattet - dummerweise bewegen sich die Shadows mit der Kamera mit - weiss jemand was?

    Das Problem hatte ich auch schon als ich Licht mit eingebunden hatte - geloest habe ich es aber mittels MatrixMode, was ich aber aktuell nicht hinbekomme

    Problem mit mitlaufender Lichtquelle so geloest:

    int DrawGLScene(GLvoid)
    {
    	glMatrixMode(GL_PROJECTION);
    		glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);
    
    	glMatrixMode(GL_MODELVIEW);
    		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    		glLoadIdentity();
    
    		person.rot[X] = cos(mouse_x/100);
    		person.rot[Z] = sin(mouse_x/100);
    		gluLookAt(person.pos[X], person.pos[Y]+0.7, person.pos[Z], person.pos[X]-person.rot[X], person.pos[Y]+0.7, person.pos[Z]-person.rot[Z], 0,1,0);
    
    		ZeichneKLEINELANDSCHAFT();
    }
    

    Aktuelles Problem:

    int DrawGLScene(GLvoid)
    {
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    	glLoadIdentity();						
    
    	glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
    	glDepthMask(GL_FALSE);
    	glEnable(GL_STENCIL_TEST);
    	glStencilFunc(GL_ALWAYS, 1, 0xFFFFFFFF);
    	glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
    	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
    	glDepthMask(GL_TRUE);
    	glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF);
    	glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
    
    	// KAMERA: MIT PROBLEM :(
    	person.rot[X] = cos(mouse_x/100);
    	person.rot[Z] = sin(mouse_x/100);
    	gluLookAt(person.pos[X], person.pos[Y]+0.7, person.pos[Z], person.pos[X]-person.rot[X], person.pos[Y]+0.7, person.pos[Z]-person.rot[Z], 0,1,0);
    
    	// BODEN AUF DEN DER SCHATTEN FAELLT ZEICHEN
    	ZeichneRechteck(&person, -200, 200, -1, 0, -200, 200, 0.0f, &texture[0], 0, REPEAT_XZ_Y, 0, 0, 0);
    
    	glPushMatrix();
    		glColor4f(0.0, 0.0, 0.0, 0.5f);
    		glDisable(GL_TEXTURE_2D);
    		glDisable(GL_LIGHTING);
    		glDisable(GL_DEPTH_TEST);
    		glEnable(GL_BLEND);
    		glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
    		shadowmatrix(floorShadow, groundplane, LightPosition);
    		glMultMatrixf((float *)floorShadow);
    
    		// FUER SCHATTENBERECHNUNG LANDSCHAFT LADEN
    		ZeichneKLEINELANDSCHAFT();
    
    		glEnable(GL_TEXTURE_2D);
    		glEnable(GL_DEPTH_TEST);
    		glDisable(GL_BLEND);
    		glEnable(GL_LIGHTING);
    	glPopMatrix();
    
    	glPushMatrix();
    		glDisable(GL_STENCIL_TEST);
    		// AUSGABE DER LANDSCHAFT
    		ZeichneKLEINELANDSCHAFT();
    	glPopMatrix();
    
    }
    

Anmelden zum Antworten