We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › rendering quad_strip (or quads)
Page Index Toggle Pages: 1
rendering quad_strip (or quads) (Read 1107 times)
rendering quad_strip (or quads)
Jul 7th, 2008, 7:05am
 
hi;
i'm trying to render an octohedron with a QUAD_STRIP shape...
i know that there is something obvious i am missing here, so i thought i would post it;
my length is defined in another area of my code, but you get the idea; the problem is that it's not "wrapped" correctly...
could someone please either expound upon the standards used to do this type of thing with a given number of vertices or point me to a good web resource?

fwiw, my cd3 function just maps signed, normalized floats to processing coords.

Code:
beginShape(QUAD_STRIP);
c3d(len,0.0,0.0,'v');
c3d(-len,0.0,0.0,'v');
c3d(0.0,len,0.0,'v');
c3d(0.0,-len,0.0,'v');
c3d(0.0,0.0,len,'v');
c3d(len,0.0,0.0,'v');
endShape();


thanks
e
Re: rendering quad_strip (or quads)
Reply #1 - Jul 7th, 2008, 7:52am
 
I think you're going to have a hard time making an octahedron out of quadrilaterals, as the constituent part is a triangle.  Here's some code that does it with TRIANGLE_STRIP:

 beginShape(TRIANGLE_STRIP);
 vertex(len, 0.0, 0.0);  
 vertex(0.0, len, 0.0);
 vertex(0.0, 0.0, len);
 vertex(-len, 0.0, 0.0);
 vertex(0.0, -len, 0.0);
 vertex(0.0, 0.0, len);  
 vertex(len, 0.0, 0.0);
 endShape();
 
 beginShape(TRIANGLE_STRIP);
 vertex(len, 0.0, 0.0);  
 vertex(0.0, len, 0.0);
 vertex(0.0, 0.0, -len);
 vertex(-len, 0.0, 0.0);
 vertex(0.0, -len, 0.0);
 vertex(0.0, 0.0, -len);  
 vertex(len, 0.0, 0.0);
 endShape();

Re: rendering quad_strip (or quads)
Reply #2 - Jul 7th, 2008, 9:44am
 
how are you getting an octahedron from 6 points (2 of which are the same)?

with openGL quad strips are specified as follows with the points zigzagging, if you see what i mean.

Code:

1--3--5--7
| | | |
0--2--4--6


search for quad strip here for better, non-ascii diagram
http://web.cs.wpi.edu/~matt/courses/cs563/talks/OpenGL_Presentation/OpenGL_Presentation.html

but processing may be different
Re: rendering quad_strip (or quads)
Reply #3 - Jul 7th, 2008, 1:19pm
 
koogy wrote on Jul 7th, 2008, 9:44am:
how are you getting an octahedron from 6 points (2 of which are the same)


ah, i see, now that i have woken up.

i think you need two TRIANGLE_FAN shapes and not TRIANGLE_STRIPs. first vertex should be the centre.

Re: rendering quad_strip (or quads)
Reply #4 - Jul 7th, 2008, 6:06pm
 
@Hacker-- good point.

Sorry that I missed that-- I never understood the principle behind the different drawing modes in the first place.

I suppose if I really wanted an all-in-one solution, I could use POLYGONs all the time, but I know from a bit of reading that this is way more expensive...

Interesting.

@Hacker/Koogs
Do either of you have a solid reference for this type of thing outside of the OGL redbook/guide?  I suppose I'm looking for info on computational geometry, eh?

Thanks,
e
Re: rendering quad_strip (or quads)
Reply #5 - Jul 7th, 2008, 6:37pm
 
This page is absolutely fantastic, though it gets quite dense at times --   http://www.euclideanspace.com/    

I have also consulted this page -- http://www.lighthouse3d.com/opengl/tutorials.shtml

You can also try reading the forums of various 3D game engines ( Irrlicht, CrystalSpace, JavaMonkey Engine) which have been known to contain nuggets of wisdom.

Borrowing a book on 3D programming wouldn't be a bad idea if you have no clue how 3D math works, though in general I find the 3D programming doorstops overpriced and light on information.

On another note, while I consulted earlier code to write that (my first 3D form was an octahedron), I drew a simple diagram to get everything sorted out.  Without fail, making simple drawings or diagrams is the best help -- you can wing 2D but 3D is just too complicated!
                                                                                               
Re: rendering quad_strip (or quads)
Reply #6 - Jul 7th, 2008, 6:49pm
 
awesome.
that first link contains exactly what i was looking for (i don't really understand 4d points yet, so i don't want to even look at them! Smiley )...

i really appreciate the references; this will get me going.
btw: i agree with you that many times 3d gaming books can be overwhelming for the wrong reasons.

thanks
e
Page Index Toggle Pages: 1