void renderStudentScene(S_Renderer *pRenderer, S_Model *pModel) { /* test existence frame bufferu a modelu */ IZG_ASSERT(pModel && pRenderer); /* nastavit projekcni matici */ trProjectionPerspective(pRenderer->camera_dist, pRenderer->frame_w, pRenderer->frame_h); /* vycistit model matici */ trLoadIdentity(); /* nejprve nastavime posuv cele sceny od/ke kamere */ trTranslate(0.0, 0.0, pRenderer->scene_move_z); /* nejprve nastavime posuv cele sceny v rovine XY */ trTranslate(pRenderer->scene_move_x, pRenderer->scene_move_y, 0.0); /* natoceni cele sceny - jen ve dvou smerech - mys je jen 2D... :( */ trRotateX(pRenderer->scene_rot_x); trRotateY(pRenderer->scene_rot_y); /* nastavime material */ /* renMatAmbient(pRenderer, &MAT_RED_AMBIENT); renMatDiffuse(pRenderer, &MAT_RED_DIFFUSE); renMatSpecular(pRenderer, &MAT_RED_SPECULAR); //*/ renMatAmbient(pRenderer, &MAT_WHITE_AMBIENT); renMatDiffuse(pRenderer, &MAT_WHITE_DIFFUSE); renMatSpecular(pRenderer, &MAT_WHITE_SPECULAR); /* a vykreslime nas model (ve vychozim stavu kreslime pouze snimek 0) */ renderModel(pRenderer, pModel, myStudFrame); }
void renderScene() { /* test existence frame bufferu a modelu */ IZG_ASSERT(polymodel && renderer); /* nastavit projekcni matici */ trProjectionPerspective(renderer->camera_dist, renderer->frame_w, renderer->frame_h); /* vycistit model matici */ trLoadIdentity(); /* nejprve nastavime posuv cele sceny od/ke kamere */ trTranslate(0.0, 0.0, renderer->scene_move_z); /* natoceni cele sceny - jen ve dvou smerech - mys je jen 2D... :( */ trRotateX(renderer->scene_rot_x); trRotateY(renderer->scene_rot_y); /* nastavime material */ renMatAmbient(renderer, &MAT_RED_AMBIENT); renMatDiffuse(renderer, &MAT_RED_DIFFUSE); renMatSpecular(renderer, &MAT_RED_SPECULAR); /* a vykreslime nas model */ renderModel(); }
void renSetupTrackball(S_Renderer *pRenderer) { IZG_ASSERT(pRenderer); /* nejprve nastavime posuv cele sceny od/ke kamere */ trTranslate(0.0, 0.0, pRenderer->scene_move_z); /* natoceni cele sceny - jen ve dvou smerech - mys je jen 2D... :( */ trRotateX(pRenderer->scene_rot_x); trRotateY(pRenderer->scene_rot_y); }
void renderStudentScene(S_Renderer *pRenderer, S_Model *pModel) { S_StudentRenderer * renderer = (S_StudentRenderer *) pRenderer; S_Frag * frag; S_RGBA resultColor; int x = 0; int y = 0; int i = 0; double transparency = 0.0; /* test existence frame bufferu a modelu */ IZG_ASSERT(pModel && pRenderer); /* nastavit projekcni matici */ trProjectionPerspective(pRenderer->camera_dist, pRenderer->frame_w, pRenderer->frame_h); /* vycistit model matici */ trLoadIdentity(); /* nejprve nastavime posuv cele sceny od/ke kamere */ trTranslate(0.0, 0.0, pRenderer->scene_move_z); /* nejprve nastavime posuv cele sceny v rovine XY */ trTranslate(pRenderer->scene_move_x, pRenderer->scene_move_y, 0.0); /* natoceni cele sceny - jen ve dvou smerech - mys je jen 2D... :( */ trRotateX(pRenderer->scene_rot_x); trRotateY(pRenderer->scene_rot_y); ///////////////////////////////// cerveny kralik /////////////////////////////////// /* nastavime material */ renMatAmbient(pRenderer, &MAT_RED_AMBIENT); renMatDiffuse(pRenderer, &MAT_RED_DIFFUSE); renMatSpecular(pRenderer, &MAT_RED_SPECULAR); /* nejprve nastavime posuv cele sceny v rovine XY */ trTranslate(pRenderer->scene_move_x - 1.2, pRenderer->scene_move_y, 0.0); /* a vykreslime nas model */ renderModel(pRenderer, pModel); ///////////////////////////////// zeleny kralik /////////////////////////////////// /* nastavime material */ renMatAmbient(pRenderer, &MAT_STUD_AMBIENT); renMatDiffuse(pRenderer, &MAT_STUD_DIFFUSE); renMatSpecular(pRenderer, &MAT_STUD_SPECULAR); /* nejprve nastavime posuv cele sceny v rovine XY */ trTranslate(pRenderer->scene_move_x + 2.4, pRenderer->scene_move_y, 0.0); /* a vykreslime nas model */ renderModel(pRenderer, pModel); /////////////////////////////////////////////////////////////////////////////////// // vypocet barvy a jeji vykresleni for(x = 0; x < pRenderer->frame_h; x++) { for(y = 0; y < pRenderer->frame_w; y++) { // inicializace transparency = 1.0; resultColor.red = 0; resultColor.green = 0; resultColor.blue = 0; resultColor.alpha = 0; i = renderer->hBuffer[y * pRenderer->frame_w + x]; if(i < 0) resultColor = COLOR_BLACK; // vypocet smichane barvy while(i >= 0) { frag = fragvecGetPtr(renderer->nBuffer, i); resultColor.blue += transparency * frag->color.blue; resultColor.red += transparency * frag->color.red; resultColor.green += transparency * frag->color.green; transparency *= (1.0 - (frag->color.alpha / 255.0)); i = frag->next; } // vykresleni vypocteneho pixelu PIXEL(pRenderer, x, y) = resultColor; } } }