[Gambas-user] glu.wireCube or glu.wireSphere

tommyline at ...2340... tommyline at ...2340...
Fri Sep 30 22:34:16 CEST 2011


I'm sorry, there was a bug.
Instead of
  '/* Pre - computed circle * /
  size = - slices

should be
  '/* Pre - computed circle * /
  size = slices    'No minus here!!! you get sint1[-5] => error.

Regards, Tomek

----- Original Message -----
From: "Girard Henri" <girardhenri at ...402...>
To: gambas-user at lists.sourceforge.net
Sent: Friday, 30 September, 2011 9:24:06 PM
Subject: Re: [Gambas-user] glu.wireCube or glu.wireSphere

Le 30/09/2011 19:44, tommyline at ...2340... a écrit :
Works fine for wirecube but i got an "out of bounds" for the wiresphere at:
  sint1[size] = sint1[0]
Wiresphere(1.0,5,5) for example
Need help
regards
Henri
> Hi Henri,
>
> Unfortunately Wire cube, or WireSphere is a part of the GLUT library which is not implemented in Gambas. But based on Freeglut source, I made my own glut geometry module.
>
> Public Sub WireCube(dSize As Float)
> Dim size As Float = dSize * 0.5
>
>      gl.Begin(gl.LINE_LOOP)
>      gl.Normal3f(1.0, 0.0, 0.0)
>      gl.Vertex3f(size, - size, size)
>      gl.Vertex3f(size, - size, - size)
>      gl.Vertex3f(size, size, - size)
>      gl.Vertex3f(size, size, size)
>      gl.End()
>
>      gl.Begin(gl.LINE_LOOP)
>      gl.Normal3f(0.0, 1.0, 0.0)
>      gl.Vertex3f(size, size, size)
>      gl.Vertex3f(size, size, - size)
>      gl.Vertex3f(- size, size, - size)
>      gl.Vertex3f(- size, size, size)
>      gl.End()
>
>      gl.Begin(gl.LINE_LOOP)
>      gl.Normal3f(0.0, 0.0, 1.0)
>      gl.Vertex3f(size, size, size)
>      gl.Vertex3f(- size, size, size)
>      gl.Vertex3f(- size, - size, size)
>      gl.Vertex3f(size, - size, size)
>      gl.End()
>
>      gl.Begin(gl.LINE_LOOP)
>      gl.Normal3f(1.0, 0.0, 0.0)
>      gl.Vertex3f(- size, - size, size)
>      gl.Vertex3f(- size, size, size)
>      gl.Vertex3f(- size, size, - size)
>      gl.Vertex3f(- size, - size, - size)
>      gl.End()
>
>      gl.Begin(gl.LINE_LOOP)
>      gl.Normal3f(0.0, - 1.0, 0.0)
>      gl.Vertex3f(- size, - size, size)
>      gl.Vertex3f(- size, - size, - size)
>      gl.Vertex3f(size, - size, - size)
>      gl.Vertex3f(size, - size, size)
>      gl.End()
>
>      gl.Begin(gl.LINE_LOOP)
>      gl.Normal3f(0.0, 0.0, 1.0)
>      gl.Vertex3f(- size, - size, - size)
>      gl.Vertex3f(- size, size, - size)
>      gl.Vertex3f(size, size, - size)
>      gl.Vertex3f(size, - size, - size)
>      gl.End()
>
> End
>
> Public Sub WireSphere(radius As Float, slices As Integer, stacks As Integer)
> Dim i, j As Integer
> Dim z, x, r, y As Float
> Dim sint1, sint2 As New Float[360]
> Dim cost1, cost2 As New Float[360]
> Dim size As Integer  ' / * Table size, the sign OF n flips the circle direction * /
> Dim angle As Float ' / * Determine the angle between samples * /
>
>     '/* Pre - computed circle * /
>      size = - slices
>      angle As Float = 2 * Pi / (size)
>      sint1[0] = 0.0
>      cost1[0] = 1.0
>      For i = 1 To size
>          sint1[i] = Sin(angle * i)
>          cost1[i] = Cos(angle * i)
>      Next
>      sint1[size] = sint1[0]
>      cost1[size] = cost1[0]
>
>      size = stacks * 2
>      angle As Float = 2 * Pi / (size)
>      sint2[0] = 0.0
>      cost2[0] = 1.0
>      For i = 1 To size
>          sint2[i] = Sin(angle * i)
>          cost2[i] = Cos(angle * i)
>      Next
>      sint2[size] = sint2[0]
>      cost2[size] = cost2[0]
>
>      '/ * Draw a LINE LOOP FOR EACH stack * /
>
>      For i = 1 To stacks
>          z = cost2[i]
>          r = sint2[i]
>
>          gl.Begin(gl.LINE_LOOP)
>              For j = 0 To slices
>                  x = cost1[j]
>                  y = sint1[j]
>                  gl.Normal3f(x, y, z)
>                  gl.Vertex3f(x * r * radius, y * r * radius, z * radius)
>              Next
>
>          gl.End()
>      Next
>
>      '/ * Draw a LINE LOOP FOR EACH slice * /
>
>      For i = 0 To slices
>           gl.Begin(gl.LINE_STRIP)
>              For j = 0 To stacks
>                  x = cost1[i] * sint2[j]
>                  y = sint1[i] * sint2[j]
>                  z = cost2[j]
>
>                  gl.Normal3f(x, y, z)
>                  gl.Vertex3f(x * radius, y * radius, z * radius)
>              Next
>
>          gl.End()
>      Next
>
> End
>
> Regards,
> Tomek
>
> ----- Original Message -----
> From: "Girard Henri"<girardhenri at ...402...>
> To: gambas-user at lists.sourceforge.net
> Sent: Friday, 30 September, 2011 3:11:29 PM
> Subject: [Gambas-user] glu.wireCube or glu.wireSphere
>
> Hi,
> Is there a way of doing in gambas opengl glu.wireCube (with example)?
> I can't find it anywhere ?
> thanks
> Henri
>
>
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously valuable.
> Why? It contains a definitive record of application performance, security
> threats, fraudulent activity, and more. Splunk takes this data and makes
> sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2dcopy2
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously valuable.
> Why? It contains a definitive record of application performance, security
> threats, fraudulent activity, and more. Splunk takes this data and makes
> sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2dcopy2
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>


------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
Gambas-user mailing list
Gambas-user at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user




More information about the User mailing list