Jump to content
  • Advertisement
Sign in to follow this  
Andrew1979

glSolidCone

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I'm wanting to use a solid cone in a game I'm creating. How would I do the following: 1. Create a round shaped code (so far I just get a triangle :-( ) 2. Texture map onto the cone (I can with a cube..so I know the process) 3. Position the cone Thank you in advance. Andrew

Share this post


Link to post
Share on other sites
Advertisement
1.) use glutSolidCone or build it yourself (set the vertices, use a triangle strip and fan)
2.) set the texture coordinates of the vertices accordingly (you might use dupicate vertices for the ground disc)
3.) use glTranslate / glRotate

Share this post


Link to post
Share on other sites
I've managed to use glutSolid cone successfuly in terms of size and position however I'm unaware on how to texture map an object created by glutSolidCone. I can't find tutorials. I can texture map a cube no problem, the vertices are there (accessable) to texture map against.

It could be a better idea going for your idea of a fan and triangle strip. The idea is to add a tree object to my game scene, was going to use a Pyramid but I I'm wanting a rounder shape than blocky.

:)

Andrew

Share this post


Link to post
Share on other sites
Just realized that you need 2 fans instead of a fan and a strip.
Basically it should be doable like this (positions only, texture coords should not be a problem though):

//basic disc
glBegin(GL_TRIANGLE_FAN);
glVertex3f(0.0f, 0.0f, 0.0f);
for(int segment = 0; segment <= numSegments; segment++) //use the second vertex twice
{
float angle = 2.0 * PI * ((double)segment/(double)numSegments); //angle in radians
glVertex3f(radius * sin(angle), 0.0f, radius * cos(angle));
}
glEnd();

//cone
glBegin(GL_TRIANGLE_FAN);
glVertex3f(0.0f, height, 0.0f);
for(int segment = numSegments; segment >= 0; segment--) //reverse order for matching polygon winding
{
float angle = 2.0 * PI * ((double)segment/(double)numSegments); //angle in radians
glVertex3f(radius * sin(angle), 0.0f, radius * cos(angle));
}
glEnd();

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!