Skip to main content
gamedev.net
🔒 Locked

glSolidCone

Started by Andrew1979 Jul 1, 2008 at 3:15 AM 2 replies 2.1k views
Original Post
Andrew1979
Andrew1979
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
Lord_Evil
Lord_Evil
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
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
Andrew1979
Andrew1979
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
Lord_Evil
Lord_Evil
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 discglBegin(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();//coneglBegin(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();
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.