   Ugh, problems
  Ugh, im trying to implement catmull rom in place of bresenheim curves in my landscape engine, but im hitting visual anomolies, it just doesnt seem to create the right kind of geometry, i mean, fair enough, the surface is curved, but its kinda screwed up, if i can find any webhosting, i''ll upload a picture to demonstrate, so heres the code, im sure its here, can anyone spot my glaring errors? I think 3 days of no sleep is my problem, and caffeine is definately not a substitute for a good nights sleep. Thanks a lot to those of you who are willing to help..... VECTOR3D cBezier::Catmull( VECTOR3D *points, float scale )//Needs to take 4 vectors only! No more, no less.{//A catmull spline being just a cardinal spline with a 0.5 coefficient in the tangent calculation//is pretty simple to calculate once you have your head around it. Derived from hermite splines.VECTOR3Da, b, c, d, ret;//4 temporary vectors, just to keep code cleana = 2 * points[1];b = ( -points[0] + points[2] ) * scale;c = ( (2*points[0]) - (5*points[1]) + (4*points[2]) - points[3] ) * (pow(scale, 2));d = ( -points[0] + (3*points[1]) - (3*points[2]) + points[3] ) * (pow(scale, 3));ret = 0.5*( a + b + c + d );return ret;//And thats it, some f*****g ugly math involved though :(}  
  Your code seems ok. I only think you better do * scale * scale * scale instead of * pow(scale,3);I think you should post the images. If you can''t find any webspace, email them to me@quasar3d.nl, and I''ll post them    My Site;quote:Original post by quasar3d   Your code seems ok. I only think you better do * scale * scale * scale instead of * pow(scale,3);I think you should post the images. If you can't find any webspace, email them to me@quasar3d.nl, and I'll post them    My Site  I had that before(scale*scale*scale), and it worked the same, i'll send you a screenshot of a single patch, done with bresenheim, and the same patch, as its supposed to be done with catmull rom  Thanks man if you can host it [edited by - hairybudda on May 10, 2003 5:40:54 PM]; My Site;quote:Original post by quasar3d    My Site  Thanks man So you guys can see the anomolies im experiencing, is there any reason this is happening do you think?[edited by - hairybudda on May 10, 2003 5:59:28 PM];  I just tested catmull rom patches, and they work fine for me, so I don''t think the problem is in this function.I used this function, but if I am not mistaking, it does the same as yours   template <class T> T CatmullRom(T x1,T x2,T x3,T x4,float t){T ret;ret = (-x1 + x2 * 3 - x3 * 3 + x4) * (t * t * t);ret += (x1 * 2 - x2 * 5 + x3 * 4 - x4) * (t * t);ret += (-x1 + x3) * t;ret += x2 * 2;ret *= .5f;return ret;}  When I look at your image, the only thing I can think of is you are passing the points in the wrong order. (1,0,3,2, instead of 0,1,2,3)    My Site;quote:Original post by quasar3d  I just tested catmull rom patches, and they work fine for me, so I don''t think the problem is in this function.I used this function, but if I am not mistaking, it does the same as yours template <class T> T CatmullRom(T x1,T x2,T x3,T x4,float t){T ret;ret = (-x1 + x2 * 3 - x3 * 3 + x4) * (t * t * t);ret += (x1 * 2 - x2 * 5 + x3 * 4 - x4) * (t * t);ret += (-x1 + x3) * t;ret += x2 * 2;ret *= .5f;return ret;}    When I look at your image, the only thing I can think of is you are passing the points in the wrong order. (1,0,3,2, instead of 0,1,2,3)    My Site Thanks man, i really appreciate that. I''ll tinker a little with it if i get the chance and see what im doing wrong. I might of jumped in the deep end by attempting to tristrip it, i''ll try immediate mode for rendering and make sure i have the right control point order set up.Thanks again for your help ;  I figured it out, i was being an ass about it, i forgot that the curve doesnt actuallt pass through points[0] and points[3] and i''ve set the patch geometry up as a linked list, with each patch knowing about its 4 neighbours. Man, too little sleep was a pain.Now i need to figure out a nice efficient way of calculating the normals.....  