/* dodecahedron: * * Draws an dodecahedron with center at 0.0. The radius * is sqrt(3). */ static void dodecahedron(GLdouble center[3], GLdouble sc, GLenum type) { static int inited = 0; if ( inited == 0) { inited = 1; initdodec(); } m_pushmatrix(); m_translate(center[0], center[1], center[2]); m_scale(sc, sc, sc); pentagon(0, 1, 9, 16, 5, type); pentagon(1, 0, 3, 18, 7, type); pentagon(1, 7, 11, 10, 9, type); pentagon(11, 7, 18, 19, 6, type); pentagon(8, 17, 16, 9, 10, type); pentagon(2, 14, 15, 6, 19, type); pentagon(2, 13, 12, 4, 14, type); pentagon(2, 19, 18, 3, 13, type); pentagon(3, 0, 5, 12, 13, type); pentagon(6, 15, 8, 10, 11, type); pentagon(4, 17, 8, 15, 14, type); pentagon(4, 12, 5, 16, 17, type); m_popmatrix(); }
void sm_frame(sm_t *sm,int from,int to,float frame) { int i,frame0,frame1; if(from == -1) from = 0; if(to == -1) to = sm->num_frame; frame0 = (int)frame; frame -= frame0; frame0 += from; if(frame0 >= to) frame0 = ((frame0 - from) % (to - from)) + from; frame1 = frame0 + 1; if(frame1 >= to) frame1 = from; for(i = 0; i < sm->num_bone; i++) { float m0[16],m1[16]; float xyz0[3],xyz1[3],xyz[3],rot[4]; v_scale(sm->frame[frame0][i].xyz,1.0 - frame,xyz0); v_scale(sm->frame[frame1][i].xyz,frame,xyz1); v_add(xyz0,xyz1,xyz); q_slerp(sm->frame[frame0][i].rot,sm->frame[frame1][i].rot,frame,rot); m_translate(xyz,m0); q_to_matrix(rot,m1); m_multiply(m0,m1,sm->bone[i].matrix); } for(i = 0; i < sm->num_surface; i++) { int j; sm_surface_t *s = sm->surface[i]; for(j = 0; j < s->num_vertex; j++) { int k; v_set(0,0,0,s->vertex[j].xyz); v_set(0,0,0,s->vertex[j].normal); for(k = 0; k < s->vertex[j].num_weight; k++) { float v[3]; sm_weight_t *w = &s->vertex[j].weight[k]; v_transform(w->xyz,sm->bone[w->bone].matrix,v); v_scale(v,w->weight,v); v_add(s->vertex[j].xyz,v,s->vertex[j].xyz); v_transform_normal(w->normal,sm->bone[w->bone].matrix,v); v_scale(v,w->weight,v); v_add(s->vertex[j].normal,v,s->vertex[j].normal); } } } }