• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

Acer

GL_POINTS Sphere

3 posts in this topic

I have some code that if I dont touch it, it makes a Cube made up of GL_POINTS. Here is some of the code I remember. Const N = 10000 Dim G(C) as Double Dim X(C) as Double Dim Y(C) as Double .... The it has glVertex3D TmpX, TmpY, TmpZ I can alter that buy adding a * TmpZ * TmpX etc. I want to make a Sphere with the GL_POINTS. And maybe make it morph into a Cube and then maybe into a Pyramid. I really just care for the Sphere.
0

Share this post


Link to post
Share on other sites
Here is the code to modify:
Const N = 1000

Dim D(N) As Double
Dim x(N) As Double
Dim Y(N) As Double
Dim Z(N) As Double
Dim G(N) As Byte
Dim TmpX As Double
Dim TmpY As Double
Dim TmpZ As Double
Dim C As Double

Private Sub Form_Click()
wglDeleteContext hRC
wglMakeCurrent 0, 0
End
End Sub

Private Sub Form_Load()
Me.Move 0, 0, Screen.Width, Screen.Height
On Error Resume Next
Dim RotX As Double
Dim RotY As Double

InitOpenGL
Me.Show: DoEvents


For C = 0 To N
x(C) = Rnd * 360
Y(C) = Rnd * 360
Z(C) = Rnd * 360 '' C
D(C) = 1
G(C) = Rnd * 250
Next C
glEnable GL_DEPTH_TEST
Do
RotX = RotX + 2 ''4
RotY = RotY + 2.5 ''5
glClear GL_COLOR_BUFFER_BIT Or GL_DEPTH_BUFFER_BIT
glPushMatrix
glRotated RotX, 1, 0, 0
glRotated RotY, 0, 1, 1
glScalef 0.6, 0.6, 0.6 ''Size
glBegin GL_POINTS ''Object to make shape



For C = 0 To N

TmpX = Cos(x(C) * (100.14 / 280)) * D(C)
TmpY = -Sin(Y(C) * (100.14 / 280)) * D(C)
TmpZ = Cos(Z(C) * (100.14 / 280)) * D(C)

''X(C) = X(C) + 1
''Y(C) = Y(C) + 1
''Z(C) = Z(C) + 1
glColor3ub 200, 75, 100
glVertex3d TmpX, TmpY, TmpZ

''D(C) = D(C) + ((Rnd / 10) - (0.5 / 10))
''X(C) = X(C) + 1
Next C
glEnd
glPopMatrix
SwapBuffers Me.hDC
DoEvents
Loop




End Sub

Private Function InitOpenGL()
Dim PFD As PIXELFORMATDESCRIPTOR
PFD.nVersion = 1
PFD.nSize = Len(PFD)
PFD.dwFlags = PFD_DRAW_TO_WINDOW Or _
PFD_SUPPORT_OPENGL Or PFD_DOUBLEBUFFER
PFD.iLayerType = PFD_MAIN_PLANE
PFD.iPixelType = PFD_TYPE_RGBA
PFD.cColorBits = 16
PFD.cDepthBits = 16

Dim pixelformat As Long

pixelformat = ChoosePixelFormat(Me.hDC, PFD)
SetPixelFormat Me.hDC, pixelformat, PFD

hRC = wglCreateContext(Me.hDC)
wglMakeCurrent Me.hDC, hRC
End Function


Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
''Render Y / 30, X / 30
End Sub

Private Sub Form_Unload(Cancel As Integer)
wglDeleteContext hRC
wglMakeCurrent 0, 0
End
End Sub

Private Sub Render(RotX As Double, RotY As Double)
glClear GL_COLOR_BUFFER_BIT Or GL_DEPTH_BUFFER_BIT
glPushMatrix
glRotated RotX, 1, 2, 3
glRotated RotY, 2, 1, 1
glScalef 0.5, 0.6, 0.7
glBegin GL_LINES
For C = 0 To N
TmpX = Cos(x(C) * (3.14 / 180)) * D(C)
TmpY = -Sin(Y(C) * (3.14 / 180)) * D(C)
TmpZ = Cos(Z(C) * (3.14 / 180)) * D(C)
''X(C) = X(C) + 1
''Y(C) = Y(C) + 1
''Z(C) = Z(C) + 1
glColor3f 0, 1, 0

glColor3ub 0, G(C), G(C)
glVertex3d TmpX, TmpY, TmpX * TmpX * TmpZ * TmpY * TmpX * TmpZ
''D(C) = D(C) + ((Rnd / 100) - (0.5 / 100))
x(C) = x(C) + 1
Next C
glEnd
glPopMatrix
SwapBuffers Me.hDC
DoEvents
End Sub
0

Share this post


Link to post
Share on other sites
This will generate a whole bunch of random points on the surface of a sphere:


Const radius = 10
Const numPoints = 1000

Dim x As Double
Dim y As Double
Dim z As Double
Dim dist As Double

For i = 1 To numPoints

x = rand
y = rand
z = rand

dist = sqr(x ^ 2 + y ^ 2 + z ^ 2)

x = (x / dist) * radius
y = (y / dist) * radius
z = (z / dist) * radius

glVertex3f(x, y, z)

Next i


If you want to morph from a cube to a sphere, just put a sixth of your sphere verteces at each cube vertex, then generate sphere positions for each, and linearly interpolate between the two. This only works with points.

Edited by - TerranFury on October 5, 2001 7:16:07 PM
0

Share this post


Link to post
Share on other sites
You''ll have to convert it to BASIC, but...

// 0.0174532925199432 is just pi/180
// draws a sphere with tex coords
// radius - radius
// lat_step - number of horizontal sections
// long_step - number of vertical sections
// draw_type - how the sphere is to be rendered
void DrawSphere(double radius, int lat_step, int long_step, bool lighting, int draw_type)
{
double DEGTORAD = 0.0174532925199432;
glPushMatrix();
glBegin(draw_type);

for (double i = 0; i < 180; i += 180/lat_step)
{
for (double j = 0; j < 360; j += 360/long_step)
{
if (lighting)
glNormal3d(cos(DEGTORAD * (j + 360/(long_step * 2))) * sin((i + 180/(lat_step * 2)) * DEGTORAD),
cos((i + 180/(lat_step * 2)) * DEGTORAD),
-sin(DEGTORAD * (j + 360/(long_step * 2))) * sin((i + 180/(lat_step * 2)) * DEGTORAD));

glTexCoord2d(j/360, i/180);
glVertex3d(cos(DEGTORAD * j) * radius * sin(i * DEGTORAD),
cos(i * DEGTORAD) * radius,
-sin(DEGTORAD * j) * radius * sin(i * DEGTORAD));

glTexCoord2d(j/360, (i + 180/lat_step)/180);
glVertex3d(cos(DEGTORAD * j) * radius * sin((i + 180/lat_step) * DEGTORAD),
cos((i + 180/lat_step) * DEGTORAD) * radius,
-sin(DEGTORAD * j) * radius * sin((i + 180/lat_step) * DEGTORAD));

glTexCoord2d((j + 360/long_step)/360, (i + 180/lat_step)/180);
glVertex3d(cos(DEGTORAD * (j + 360/long_step)) * radius * sin((i + 180/lat_step) * DEGTORAD),
cos((i + 180/lat_step) * DEGTORAD) * radius,
-sin(DEGTORAD * (j + 360/long_step)) * radius * sin((i + 180/lat_step) * DEGTORAD));

glTexCoord2d((j + 360/long_step)/360, i/180);
glVertex3d(cos(DEGTORAD * (j + 360/long_step)) * radius * sin(i * DEGTORAD),
cos(i * DEGTORAD) * radius,
-sin(DEGTORAD * (j + 360/long_step)) * radius * sin(i * DEGTORAD));
}
}

glEnd();
glPopMatrix();
}

0

Share this post


Link to post
Share on other sites