Jump to content
  • Advertisement
Sign in to follow this  

OpenGL interpolate and skinning

This topic is 3767 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm an Italian Student and I have to do a function in openGL that calculate a interpolated surface between a grid of point of an immagine in .ppm. How Can I do this?? It's similar to skinning...but I dont know... Interpolated points are in input Through a ppm file, and I've to do a curves that interpolate this points! For skinning I have this: int skinning(struct snurbs* surf, GLfloat** CPcurve, int n, GLfloat* U, int nu, int ncpc, GLfloat* dist, int orderv, int dim) { int orderu = nu - ncpc; GLfloat* CP,*v_n,*V,*P,*Q,*CQ; int i,j,k; int nv; if (orderv>n) return 0; if ((dim != 3) && (dim != 4)) return 0; nv = n + orderv; CP = malloc(dim*ncpc*n*sizeof(GLfloat)); CQ = malloc(dim*ncpc*n*sizeof(GLfloat)); v_n = malloc(n*sizeof(GLfloat)); V = malloc(nv*sizeof(GLfloat)); P = malloc(dim*n*sizeof(GLfloat)); Q = malloc(dim*n*sizeof(GLfloat)); // inizializzazione della matrice dei punti di controllo delle curve sezione if (dim == 3) for (i=0;i<n;i++) for (j=0;j<ncpc;j++) { CP[dim*(ncpc*i+j)]=CPcurve[3*j]; CP[dim*(ncpc*i+j)+1]=CPcurve[3*j+1]; CP[dim*(ncpc*i+j)+2]=dist; } else for (i=0;i<n;i++) for (j=0;j<ncpc;j++) { CP[dim*(ncpc*i+j)]=CPcurve[4*j]; CP[dim*(ncpc*i+j)+1]=CPcurve[4*j+1]; CP[dim*(ncpc*i+j)+2]=dist; CP[dim*(ncpc*i+j)+3]=CPcurve[4*j+3]; } // calcolo del vettore nodale V del vettore v_n dei valori del parametro per cui si ha interpolazione find_node_V(CP,n,ncpc,orderv,dim,v_n,V); for (i=0;i<ncpc;i++) { for (j=0;j<n;j++) for (k=0;k<dim;k++) P[dim*j+k]=CP[dim*(ncpc*j+i)+k]; // calcolo dei punti di controllo della superficie interpolante curve_interp(P,v_n,n,dim,V,nv,Q); for (j=0;j<n;j++) for (k=0;k<dim;k++) CQ[dim*(ncpc*j+i)+k]=Q[dim*j+k]; } free(CP); free(v_n); free(P); free(Q); surf->CP = CQ; surf->dim = dim; surf->ncpu = ncpc; surf->ncpv = n; surf->nu = nu; surf->nv = nv; surf->orderu = orderu; surf->orderv = orderv; surf->U = malloc(nu*sizeof(GLfloat)); for (i=0;i<nu;i++) surf->U = U; surf->V = V; return 1; } My new function is: int gridInterp(GLuint *image,?????) { int n; int m; FILE *fd; int k, nm; char c; int i; char b[100]; float s; int red, green, blue; printf("enter file name\n"); scanf("%s", b); fd = fopen(b, "r"); fscanf(fd,"%[^\n] ",b); if(b[0]!='P'|| b[1] != '3') { printf("%s is not a PPM file!\n", b); exit(0); } printf("%s is a PPM file\n",b); fscanf(fd, "%c",&c); while(c == '#') { fscanf(fd, "%[^\n] ", b); printf("%s\n",b); fscanf(fd, "%c",&c); } ungetc(c,fd); //reinserisce c nello strem fscanf(fd, "%d %d %d", &n, &m, &k);//larghezza altezza massimo valore di colore printf("%d rows %d columns max value= %d\n",n,m,k); nm = n*m; image=malloc(3*sizeof(GLuint)*nm); s=255./k; //terne di RGB (una per ogni pixel) for(i=0;i<nm;i++) { fscanf(fd,"%d %d %d",&red, &green, &blue ); image[3*nm-3*i-3]=red; image[3*nm-3*i-2]=green; image[3*nm-3*i-1]=blue; } //in image ho i punti da interpolare and now???? How can i do??? } Thanks Carmen

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!