It is currently Fri May 26, 2017 8:06 am

All times are UTC - 5 hours




 Page 1 of 1 [ 11 posts ] 
Author Message
 Post subject: Physics VMK 2 - Sphere Geometry
PostPosted: Tue Jan 22, 2008 11:13 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
In VMK 2A/B, I show you how to generate the vertices and normals for a general sphere shape. The sphere object builds on top of the existing game engine framework.

I add texture coordinates to the sphere so that we can apply a texture over top of our geometry in VMK 2C. At the end of VMK2D I show you how to add this new geometry to the lvl parser. Found within VMK 2D, you will see there is an updated pdf showing the new lvl file format spec and some additional files that I used in this VMK.


Last edited by Marek on Fri Jan 25, 2008 7:57 am, edited 1 time in total.

Offline
 Profile  
 
 Post subject:
PostPosted: Wed Jan 23, 2008 9:22 am 

Joined: Sat Jun 23, 2007 7:56 pm
Posts: 145
Hi Marek,
Great video there! Was glad to see that I had implemented my sphere correctly:D
I used a different approach though,
1. Did not calculate the inner radius for the upper and lower hemispheres, just used the radius as supplied by the user.
2. Used Quad Stips when rendering the sphere mid-section and triangle fans for the top and bottom caps.

My question is - Why did you render the sphere using single triangles instead of triangle or quad strips? (strips would have meant less data being sent per triangle)
Does using single triangles help with lighting and shading? (I know that openGL converts quads to triangles internally)

Am glad you implemented a sphere, now I have something to compare my implementation against.


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Jan 23, 2008 10:38 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
codeslasher wrote:
Why did you render the sphere using single triangles instead of triangle or quad strips?


Good question! My first implementation of the sphere was exactly how you described your implementation. However when I tried to texture the triangle fans and quad strips I got all confused with the array indices. So to fix it, I converted everything to triangles and then it was easy to define all the texture coordinates.

VMK 2c will show you how to texture the sphere. You will notice that the north and south poles actually have iNumDivHorizontally texture coordinates for those vertices.


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Jan 23, 2008 12:23 pm 

Joined: Tue May 01, 2007 2:55 pm
Posts: 96
Location: Behind you
codeslasher wrote:
(I know that openGL converts quads to triangles internally)


I don't think that's true, really. From what I have heard OpenGL does not convert them but some video cards do, but not all and only after OpenGL sends them to the card.


Offline
 Profile  
 
 Post subject:
PostPosted: Sun Mar 09, 2008 10:41 am 

Joined: Sun Mar 09, 2008 9:52 am
Posts: 3
Am I correct to assume that you could also use subdivision (recursively, even (as produced in the OpenGL red book)) to produce something similar? Is there a reason you chose to use this method instead?

Is the implementation of subdivision more difficult? Costly?

I'm relatively new and was reading a little bit about subdivision and was just curious as to your thought process.


Offline
 Profile  
 
 Post subject:
PostPosted: Sun Mar 09, 2008 12:17 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
I don't have the OpenGL red book and I am not familiar with the term subdivision in the sense that you are using it in. Do you have a url reference that I could look at to see in depth what you mean.


Offline
 Profile  
 
 Post subject:
PostPosted: Sun Mar 09, 2008 12:41 pm 

Joined: Sun Mar 09, 2008 9:52 am
Posts: 3
Marek wrote:
I don't have the OpenGL red book and I am not familiar with the term subdivision in the sense that you are using it in. Do you have a url reference that I could look at to see in depth what you mean.


Sure. I'm just getting started and really haven't had a chance to read through that entire section so I may be incorrectly throwing around terminology. If that's the case, I apologize in advance and feel free to correct me.

A copy of the red book can be found at http://www.glprogramming.com/red. It is an early edition but I am just curious with the concept. Hopefully it is still up to date (?). You could probably find later editions elsewhere.

The section I am talking about is titled "An Example: Building an Icosahedron". It is at the very bottom of the second chapter (find should bring you to it).

If I understand it correctly, it starts with that basic shape (icosahedron?) and continues to divide through the equilateral triangles multiple times to form a basic sphere.

Is this more/less/similarly complex? Is it too rigid in comparison to what you made? Would texturing be difficult?

Image


Thanks for your time, Marek.


Offline
 Profile  
 
 Post subject:
PostPosted: Sun Mar 09, 2008 2:45 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
Ahh I see now what you mean by subdivisions.

Using this method to generate a sphere is definitely more complex. Generating texture coordinates would also be very difficult to do because you don't have an easy set of reference points (ie north pole, equator etc) that you can relate to a texture.


Offline
 Profile  
 
 Post subject:
PostPosted: Sun Mar 09, 2008 3:04 pm 

Joined: Sun Mar 09, 2008 9:52 am
Posts: 3
Marek wrote:
Ahh I see now what you mean by subdivisions.

Using this method to generate a sphere is definitely more complex. Generating texture coordinates would also be very difficult to do because you don't have an easy set of reference points (ie north pole, equator etc) that you can relate to a texture.


Good to know!

:)


Offline
 Profile  
 
 Post subject: error?
PostPosted: Sun May 31, 2009 9:22 pm 

Joined: Sun May 31, 2009 9:19 pm
Posts: 1
Sure looks like these two are backwards:

      // Upper Hemisphere
      else if( v + 1 <= divisions >> 1 )
      {
         double y = cos(v * sliceAngleXY);
         double ringRadius = sin(v * sliceAngleXY);


How in the world is the radius of the inner ring the height of an angle in the XY plane?

I'd think it would be the X coordinate in the XY plane.

If I am wrong please explain.


Offline
 Profile  
 
 Post subject:
PostPosted: Thu Jun 04, 2009 7:30 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
Remember that the sliceAngleXY is wrt the vertical line running from the centre of the sphere up to the north pole. An angle of 90 degrees means that we are at the equator.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 11 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron