static int render_teapot_refraction(GzRender* in_renderer) { //setup shader and teapot material in_renderer->v_shader = GouraudVertexShader; in_renderer->p_shader = GouraudAlphaPixelShader; //use the same material for ambient, diffuse and specular GzColor material_color = {0.7f, 0.3f, 0.1f}; for(int i=0; i<3; i++) { in_renderer->Ka[i] = material_color[i]; in_renderer->Kd[i] = material_color[i]; in_renderer->Ks[i] = material_color[i]; } in_renderer->spec = 32; //setup transform GzMatrix m; GzScaleMat(teapot_scale, m); GzPushMatrix(in_renderer, m); GzCoord pos = {teapot_position[0], teapot_position[1]/1.33f, teapot_position[2]}; GzTrxMat(pos, m); GzPushMatrix(in_renderer, m); GzTrxMat(teapot_rotation, m); GzPushMatrix(in_renderer, m); GzPutCamera(renderer, &default_camera); GzBeginRender(in_renderer); GzToken nameListTriangle[4]; /* vertex attribute names */ GzPointer valueListTriangle[4]; /* vertex attribute pointers */ nameListTriangle[0] = GZ_POSITION; nameListTriangle[1] = GZ_NORMAL; nameListTriangle[2] = GZ_TEXTURE_INDEX; nameListTriangle[3] = GZ_RGB_COLOR; const Model::TriangleVector& triangles = teapot_model.GetData(); for(Model::TriangleVector::const_iterator it = triangles.begin(); it != triangles.end(); it++) { valueListTriangle[0] = (GzPointer)(*it)->vertices; valueListTriangle[1] = (GzPointer)(*it)->normals; valueListTriangle[2] = (GzPointer)(*it)->uvs; GzPutTriangle(in_renderer, 3, nameListTriangle, valueListTriangle); } return GZ_SUCCESS; }
// Callback function for Translation void CCS580HWView::OnTranslate() { // TODO: Add your command handler code here CTranslateDlg dlg; GzInput* input; GzMatrix trxMat = { 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 }; if(m_pApplication == NULL) return; input = m_pApplication->m_pUserInput; if(input == NULL) return; // Initialize input->translation[0] = input->translation[1] = input->translation[2] = 0; dlg.Initialize(input->translation[0], input->translation[1], input->translation[2]); if(dlg.DoModal() == IDOK) { // Update input translation value input->translation[0] = dlg.m_fTx; input->translation[1] = dlg.m_fTy; input->translation[2] = dlg.m_fTz; // Create Translation Matrix GzTrxMat(input->translation, trxMat); // Accumulate matrix GzPushMatrix(m_pApplication->m_pRender, trxMat); } }