Jump to content
  • Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

114 Neutral

About lehthanis

  • Rank
  1. I have code that draws a parabola given two end points and a value for droop/sag to simulate a wire.  I'm currently using a GL_LINE_STRIP to draw it, but it's limited to pixel thicknesses, and I need world coordinate thickness.  So what I need to do is pass in a radius for thickness and draw a cylinder with it's segments at each point on this parabola. In this coordinate system +Y is up.  Here's my code: const double pPrecision = 50; double wx1, wy1, wz1, wx2, wy2, wz2, wx3, wy3, wz3; double wa = gWires[i].Sag; WorldToLocal(gWires[i].Lat1, gWires[i].Lon1, (gWires[i].El1 * FtToMtrs), &wx1, &wy1, &wz1); WorldToLocal(gWires[i].Lat2, gWires[i].Lon2, (gWires[i].El2 * FtToMtrs), &wx3, &wy3, &wz3); double mXZ = (wz3-wz1)/(wx3-wx1); double mXY = (wy3-wy1)/(wx3-wx1); wx2 = wx1 + ((wx3 - wx1) / 2.0); wy2 = (mXY * (wx2 - wx1) + wy1) - wa; wz2 = (mXZ * (wx2 - wx1) + wz1); double denom = (wx1 - wx2) * (wx1 - wx3) * (wx2 - wx3); double A = (wx3 * (wy2 - wy1) + wx2 * (wy1 - wy3) + wx1 * (wy3 - wy2)) / denom; double B = (wx3*wx3 * (wy1 - wy2) + wx2*wx2 * (wy3 - wy1) + wx1*wx1 * (wy2 - wy3)) / denom; double C = (wx2 * wx3 * (wx2 - wx3) * wy1 + wx3 * wx1 * (wx3 - wx1) * wy2 + wx1 * wx2 * (wx1 - wx2) * wy3) / denom; double px = wx1; glLineWidth(gWires[i].Thickness); glColor4f(gWires[i].R, gWires[i].G, gWires[i].B, 1.0f); glBegin( GL_LINE_STRIP ); for ( int p = 0; p <= pPrecision; ++p) { double thisZ = (mXZ * (px - wx1) + wz1); double thisY = (A * (px*px)) + (B * px) + C; glVertex3f(px, thisY, thisZ); px = px + ((wx3 - wx1) / pPrecision); } glEnd(); gWires.Thickness on line 21 will be used as a radius once this is converted.  This code is in a loop of gWires with i being the current wire being drawn...each wire is a parabola with two fixed end points.   As you can see, I have a WorldToLocal that converts Lat/Long/El to local opengl coordinates...wx1, wy1, wz1 is one end point while wx3, wy3, wz3 is the other end point. Assume a cylinder precision of say 6 vertices per segment...I'm thinking due to the GL_TRIANGLE_STRIP plot method, I'll need to add these parabola points to an array and use them in some form of lofted draw method like a parallel transport frame.  I've seen a bunch of code that calculated parallel transport frames, but nothing that draws them.  I'm limited to immediate mode, so I can't create a VAO or anything, it has to be done in a loop of sorts.   Where do I begin?  I know I need to start by adding the points created on the glVertex3f on line 28 to an array and then calling a whole new set of routines to draw the cylinder but as for the math/drawing, I've no clue.
  2. Hi all, sorry for the super noob post...I'm just getting started but I have a very short turnaround time needed for this for my boss. I'm modifying something in X-Plane, and drawing a really large set of quads that cover the sky...it works....here's the code:     glColor4f(1.0f, 1.0f, 1.0f, 1.0f);     glBegin( GL_QUADS );         glVertex3f( xt+150000.0f, yt, zt-150000.0f );         glVertex3f( xt+150000.0f, yt, zt+150000.0f );         glVertex3f( xt-150000.0f, yt, zt+150000.0f );         glVertex3f( xt-150000.0f, yt, zt-150000.0f );     glEnd();     glColor4f(0.8f, 0.8f, 0.8f, 0.5f);     glBegin( GL_QUADS );         glVertex3f( xt+150000.0f, yt+1, zt-150000.0f );         glVertex3f( xt+150000.0f, yt+1, zt+150000.0f );         glVertex3f( xt-150000.0f, yt+1, zt+150000.0f );         glVertex3f( xt-150000.0f, yt+1, zt-150000.0f );     glEnd();     glColor4f(0.5f, 0.5f, 0.5f, 0.2f);     glBegin( GL_QUADS );         glVertex3f( xt+150000.0f, yt+2, zt-150000.0f );         glVertex3f( xt+150000.0f, yt+2, zt+150000.0f );         glVertex3f( xt-150000.0f, yt+2, zt+150000.0f );         glVertex3f( xt-150000.0f, yt+2, zt-150000.0f );     glEnd(); I know, it's the old glBegin method, but that's how the code I have is written for X-Plane... Anyways...I need to apply a texture to those 3 quads. And I need it to be a png texture. I've downloaded and compiled libpng, and linked it to my project, but I need a quick and dirty way to load a png file and apply it to the quads. Is there an easy way to do this without using any additional libraries? Or perhaps a simple header file I could drop in that someone has layign around? Sorry again for the frantic-ness...once I get a quick and dirty png loader, I'll definitely be able to spend some time learning more about libpng, but for now, I need a quick fix. Thanks so much to anyone that can help.
  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!