# How to Morph Bezier-aligned texture?

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

## Recommended Posts

Hey, I got more interested in implementing the "morphing" on those bezier control points(tutorial #28). It doesn't work though. I have tried almost everything. Now I have a function like this: GLuint GenerateDisplaylistFromBezierPatch4X4(int _divs) { CPoint3D q; for(int k = 0; k < 4; k++) { for(int l = 0; l < 4; l++) { q = MorphBezier(k, l); anchors[k][l].SetX(anchors[k][l].GetX() - q.GetX()); anchors[k][l].SetY(anchors[k][l].GetY() - q.GetY()); anchors[k][l].SetZ(anchors[k][l].GetZ() - q.GetZ()); } } CPoint3D helpers[4][4]; for(int m = 0; m < 4; m++) { for(int n = 0; n < 4; n++) { helpers[m][n] = anchors[m][n]; } } int u = 0, v; float py, px, pyold; GLuint drawlist = glGenLists(1); CPoint3D temp[4]; CPoint3D *last = (CPoint3D*)malloc(sizeof(CPoint3D)* (_divs+1)); CFace face; if(displayList != NULL) { glDeleteLists(displayList, 1); } temp[0] = helpers[0][3]; // x remains constant (refer to InitBezier()) temp[1] = helpers[1][3]; temp[2] = helpers[2][3]; temp[3] = helpers[3][3]; for(v=0;v<=_divs;v++) { px = ((float)v)/((float)_divs); // percent along x axis last[v] = temp[0].Bernstein(px, temp); } glNewList(drawlist, GL_COMPILE); glBindTexture(GL_TEXTURE_2D, texture); for (u=1;u<=_divs;u++) { py = ((float)u)/((float)_divs); // percent along y axis pyold = ((float)u-1.0f)/((float)_divs); temp[0] = temp[0].Bernstein(py, helpers[0]); temp[1] = temp[0].Bernstein(py, helpers[1]); temp[2] = temp[0].Bernstein(py, helpers[2]); temp[3] = temp[0].Bernstein(py, helpers[3]); glBegin(GL_TRIANGLE_STRIP); for(v=0; v<=_divs; v++) { px = ((float)v)/((float)_divs); // along x- axis glTexCoord2f(pyold, px); // apply old texture coords glVertex3d(last[v].GetX(), last[v].GetY(), last [v].GetZ()); // old point if(face.numOfInitVerts == 0) { // old point face.AddVertice(last[v].GetX(), last [v].GetY(), last[v].GetZ()); } last[v] = temp[0].Bernstein(px, temp); if(face.numOfInitVerts == 1 || face.numOfInitVerts == 2) { // new point face.AddVertice(last[v].GetX(), last [v].GetY(), last[v].GetZ()); } if(face.numOfInitVerts == 3) { face.ComputeNormal(); face.numOfInitVerts = 0; } glNormal3f(face.normal.GetX(), face.normal.GetY (), face.normal.GetZ()); glTexCoord2f(py, px); // apply new texture coords glVertex3d(last[v].GetX(), last[v].GetY(), last [v].GetZ()); // new point } glEnd(); } glEndList(); free(last); return(drawlist); } // end GenerateDisplaylistFromBezierPatch4X4 //////////////////////////// as you maybe notice, it is almost the same than you wrote for nehe. I have also function like this: CPoint3D MorphBezier(int _i, int _j) { CPoint3D temporaryVertex; temporaryVertex.SetX( (source[_i][_j].GetX() - morphObjAnchors[_i][_j].GetX ())/gMorphSteps); temporaryVertex.SetY( (source[_i][_j].GetY() - morphObjAnchors[_i][_j].GetY ())/gMorphSteps); temporaryVertex.SetZ( (source[_i][_j].GetZ() - morphObjAnchors[_i][_j].GetZ ())/gMorphSteps); return(temporaryVertex); } Which is from Nehe tutorial #25. So.. what I think is the problem: source[4][4], anchors[4][4], morphObjAnchors[4][4] and helpers[4][4] get mixed up at some point. As you see, I only use source and morphObjAnchors in MorphBezier() method, so I think they don't get mixed up with anything. The thing I am not sure of, is that where should I use anchors[4][4] and where should I use helpers[4][4]. I am afraid of changing the values of anchors[4] [4], but Am I supposed to change them instead? -teemu, aka Jamcar / LAG

##### Share on other sites

Okey guys, simply put: My texture-object remains the same, no matter what operations I perform to it. That is a problem, considering that I want to morph it.
Anybody out there who can help me out?

Thank you in advance, Teemu Turkki

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633297
• Total Posts
3011248
• ### Who's Online (See full list)

There are no registered users currently online

×