Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ScottyBrosious

Pages: [1] 2
1
C / C++ /C# / Re: Question about VC++
« on: July 16, 2007 »
Thanks Shockwave!
 ^-^

2
C / C++ /C# / Question about VC++
« on: July 15, 2007 »
I am trying to re-compile some OpenGL Tuts.
I think my problem is that when I go to compile
I'm useing Uni-code.
How do I switch to ANSI within the compiler?
MSVC++ Version 8 2005

Thanks

3
Freebasic / Free Code
« on: July 11, 2007 »
Here is a explosion creator program I wrote.
Just make sure to set the path where you want the frames.

Here's a swirl program I made.
Use any picture you want.

Now a Wormhole.

How about Plasma Fractals used to make clouds and heightmaps for mountains.

Old Fire Effect,OpenGL Starfields,OpenGL Snow!

Simple Fractal Von-Bon-Koch

FireWorks!

That's it unless people would like to see more?
Than I'll send more.



4
I know that I've been a pest lately
asking all kinds of stuff so I just wanted to say sorry
and I will try and back off some.
I got help with trees and thank you for that but I got bummed
when I found out I could only render a few in a scene
because theres just way to many polys in all those cylinders
though single models look great.
So I started to think of a scene where a few would look good
because a feild of them in a skybox was really trying.
So I thought some coming out of fog would look nice
but I only know regular fog not volumetric where they would really stand out.
So I asked more questions but I guess the real question should be like how to I get the polygon rate down? 2d images would do this like when I got 1000 in a cubemap but I loose effect when walking up to it it's now flat and 2d and nolonger bulk and 3d.
I know some games find ways around things is there a way around this?
resident evil 4 you walk through the woods/forest and there looks like all kinds of trees but it does'nt bog down like mine does when you try plotting a bunch.

So once again sorry for all the post lately
and thanks for all the help!

Any ideas where to turn now?

5
Freebasic / Volumetric Fog?
« on: July 04, 2007 »
Would anyone know how to code
opengl volumetric fog?
Not the ordinary fog but volumetric fog
I know Nehe has tutorial 41 but I can't find it for freebasic.
Maybe someone in here knows how to code it up in freebasic
maybe jim or someone else can show me how it works in freebasic opengl programming?
thanks
Scott

6
C / C++ /C# / C++ Vs. Freebasic ?
« on: July 03, 2007 »
Is there any  speed difference between
the two like when it comes to simple loops?

Can one's runtime speed beat the other
during program exectution?

How about memory limits?
Can one surpass the other?

Is there proof?

What other differences are there between the two?

If so can someone explain why the jump would be worth it?

Thanks
Scotty B.





7
Freebasic / NeHe Tutorials for FreeBasic?
« on: July 03, 2007 »
Where can I find the NeHe Tutorials for FreeBasic?
Not just the one's that come with Freebasic.
Why? Cuz, I'm looking for 41 Volumetric Fog.
And other as well.
Know where?
Please let me know.
Thanks
Scott B.

8
Freebasic / glfrustum?
« on: July 02, 2007 »
Can someone put this in basic layman's terms for me?

glFrustum(left,right,bottom,top,near,far)

I know there all clipping planes but how do I use them to
define what it see's and what it don't?

I just would like to understand it a bit more before I use it.

Thanks
Scott




9
Could someone please show me how to use
OpenGL's Stencil buffer for doing reflections?

A small example program would be very helpful
not only to me but for other that come to this site just like
so many other programs before help is sometimes needed in codeing things up.

Thanks
Scotty B.

10
Freebasic / Free 3D-Fractal Tree Program
« on: June 28, 2007 »
Here it is!
I fixed the problem.

It's kinda sloppy right now
but it works!

Code: [Select]

'$include: 'GL/gl.bi'
'$include: 'GL/glu.bi'

'' Setup our booleans
const FALSE = 0
const TRUE  = not FALSE

#include once "bmpload.bi"

declare function LoadGLTextures() as integer


dim shared texture(9) as GLuint               '' Storage For One Texture ( NEW )

dim xrot as single                            '' X Rotation ( NEW )
dim yrot as single                            '' Y Rotation ( NEW )
dim zrot as single                            '' Z Rotation ( NEW )

''$include: 'windows.bi'

option explicit

TYPE vector
x AS DOUBLE
y AS DOUBLE
z AS DOUBLE
END TYPE

declare sub drawblob(byval p as vector, byval colour as uinteger)
declare sub readinput()

dim camang as single
dim screenwidth as uinteger
dim screenheight as uinteger
dim shared init as integer
dim shared ox as integer
dim shared oy as integer

DIM shared O AS vector
DIM shared P as vector

DIM X as vector
dim Y as vector
dim Y2 as vector
dim Z as vector

dim matrix(16) as GLfloat
dim d as single

dim shared sphere as GLUQuadricObj ptr

dim radius as GLdouble
dim length as GLdouble
dim segments as GLint
dim stacks as GLint
dim cylinder as GLUQuadricObj ptr

screenwidth = 640
screenheight = 480
init = 0


SCREEN 18,32,,2

glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(60,cast(single, screenwidth)/screenheight,1,1024)

glEnable(GL_DEPTH_TEST)
glDepthFunc(GL_LEQUAL)
glClearDepth(1)

'glEnable(GL_TEXTURE_2D)

glClearColor(0,1,0,1)

sphere = gluNewQuadric()
'---------------------------------------------------------------------------------------
' cylinder params
'---------------------------------------------------------------------------------------
cylinder = gluNewQuadric()
gluQuadricNormals(cylinder, GLU_SMOOTH)
gluQuadricTexture(cylinder, GL_TRUE)

radius = 10
segments = 9
stacks = 2
         
dim nopts = 2046

dim which(nopts)

dim bt#(nopts)

dim xtemp(nopts)
dim ytemp(nopts)

dim ztemp(nopts)

dim xtemp2(nopts)
dim ytemp2(nopts)

dim mag#(nopts)

dim size#(nopts)

dim ang#(nopts)

dim perb#(nopts)

dim angle = 0

dim mult = 1
dim add  = 1

dim yr#

dim i,j,k
dim a,b,c
dim mult1,mult2

dim pi#

dim x1,y1,z1

dim lenght2

dim a1#
dim count#

dim count2#

dim l#,l2#
dim s#
dim s1#,s2#

dim x3d1,y3d1,z3d1

dim rand1

dim x3,y3,z3
dim e

Dim As Single LightPos(3) => {-100,100, 1024, 0 }
Dim As Single Ambient(3) => { .7, .7, .7, 1}

glEnable(GL_LIGHTING)  ' Turn on OpenGL Lighting
glEnable(GL_LIGHT0)  ' Light Source 0 (0-7)
glLightfv(GL_LIGHT0,GL_POSITION,@LightPos(0))  ' Light Position
glLightfv(GL_LIGHT0,GL_AMBIENT,@Ambient(0))  ' Ambient Light Source (Overall Scene)

'glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
'glEnable (GL_BLEND)

'' Jump To Texture Loading Routine
if (not LoadGLTextures()) then
      end 1                                        '' If Texture Didn't Load Quit
end if

glEnable(GL_DEPTH_TEST)
glDepthFunc(GL_LEQUAL)
glClearDepth(1)

glEnable(GL_TEXTURE_2D)

'glEnable(GL_CULL_FACE)

glClearColor(0,0,1,1)


do

glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)

glMatrixMode(GL_MODELVIEW)
glLoadIdentity()

glRotatef(-camang, 0, 0, 1)
glTranslatef(0,-256,-1024)

glTranslatef(0,0,512)
glRotatef(yr#,0,1,0)

randomize timer

gosub math

gosub rendertrunk

gosub renderbranches

flip

yr# = yr# + 1

loop until inkey$ = chr$(27)

end

math:

dim a#(nopts)

for i = 0 to nopts

xtemp(i) = 0
ytemp(i) = 0
ztemp(i) = 0

which(i) = 0

next i

a = 1
b = 2
c = 0
e = 0

mult1 = 2
mult2 = 4

pi# = 3.1415926

x1 = 0
y1 = 0

lenght2 = screenheight / 4

xtemp(0) = x1 '+ -cos(bt#(0) * pi# / 180) * lenght2
ytemp(0) = y1 + lenght2'+  sin(bt#(0) * pi# / 180) * lenght2

size#(0) = 12

'gosub trunk1

mag#(0) = lenght2 / 2

'glLineWidth(size#(0))

'y1 = size#(0)
Z1 = 0

gosub bulk

which(0) = 1

for j = 0 to 9
   
for i = a to b

if j > 0 and e = 0 then c = c + 1

'randomize timer

if e = 0 then a1# = rnd(1) * 1

if e = 0 then bt#(i) = bt#(c) + (45*a1#):a#(i) = a#(c) + (45*a1#)
if e = 1 then bt#(i) = bt#(i-1) - 45:a#(i) = a#(i-1) -45 

if e = 0 then count# = bt#(i) - bt#(c)
if e = 1 then count# = bt#(c) - bt#(i)

'if d = 0 then count2# = a#(c) - a#(i)
'if d = 1 then count2# = a#(c) + a#(i)

l# = 1 - (count# / 90)

mag#(i) = mag#(c) * l#

size#(i) = size#(c) * l#

if e = 0 then s1# = size#(i)
if e = 1 then s2# = size#(i)

xtemp(i) = xtemp(c) + bt#(i)

ytemp(i) = ytemp(c) + mag#(c)

'gosub trunk2

if e = 1 and which(c) = 1 and s1# >= s2# then which(i-1) = 1
if e = 1 and which(c) = 1 and s1# < s2# then which(i) = 1

e = e + 1
if e = 2 then e = 0

next i
 
if j > 0 then mult1 = mult1 * 2
if j > 0 then mult2 = mult2 * 2

a = a + mult1
b = b + mult2

next j

return

rendertrunk:

a = 1
b = 2
c = 0
e = 0

mult1 = 2
mult2 = 4

for j = 0 to 9
   
for i = a to b

if j > 0 and e = 0 then c = c + 1

if which(c) = 1 and which(i) = 1 then gosub trunk2

if which(c) > 1 then gosub more

e = e + 1
if e = 2 then e = 0

next i
 
if j > 0 then mult1 = mult1 * 2
if j > 0 then mult2 = mult2 * 2

a = a + mult1
b = b + mult2

next j

return

trunk1:

'glRotatef (-90, 1, 0, 0)

'gluCylinder(quadric1,size#(c),size#(c),lenght,16,16)

'glRotatef ( 90, 1, 0, 0)

return

trunk2:

'glLineWidth(size#(i))

'glBegin(GL_LINES)

'glColor3f(1,1,1)

'glVertex3f(xtemp(c),ytemp(c),0)
'glVertex3f(xtemp(i),ytemp(i),0)

gosub bulk2

'glEnd()

'glTranslatef(xtemp(c),ytemp(c),0)
'glRotatef (-90, 1, 0, 0)
'glRotatef ( a#(i), 0, 1 ,0)

'glColor3f(0,0,1)
'gluCylinder(quadric1,size#(c),size#(c),mag#(c),16,16)

'glRotatef (-a#(i), 0, 1, 0)
'glRotatef ( 90, 1, 0, 0)
'glTranslatef(-xtemp(c),-ytemp(c),0)

return

renderbranches:

for k = 0 to 1

a = 1
b = 2
c = 0
e = 0

mult1 = 2
mult2 = 4

for j = 0 to 9
   
for i = a to b

if j > 0 and e = 0 then c = c + 1

if which(c) = 1 and which(i) = 0 then gosub branches
'if which(c) = 2 and which(i) = 2 then gosub more

if which(c) > 1 then gosub more

'gosub branches

e = e + 1
if e = 2 then e = 0

next i

if j > 0 then mult1 = mult1 * 2
if j > 0 then mult2 = mult2 * 2

a = a + mult1
b = b + mult2

next j
next k

return

branches:

ang#(c) = rnd(1) * 360

x3d1 = xtemp(c) + cos(ang#(c) * pi# / 180) * mag#(c)
y3d1 = ytemp(i)
z3d1 = ztemp(c) + -sin(ang#(c) * pi# / 180) * mag#(c)

gosub bulk3

ang#(i) = ang#(c)

xtemp(i) = x3d1
ytemp(i) = y3d1
ztemp(i) = z3d1

which(i) = 2

return

more:

rand1 = int(rnd(1) * 2 ) + 1

if e = 0 and rand1 = 1 then ang#(i) = ang#(c) + a#(c)'(a#(c) / 2)
if e = 0 and rand1 = 2 then ang#(i) = ang#(c) - a#(c)'(a#(c) / 2)

if e = 1 and rand1 = 1 then ang#(i) = ang#(c) + a#(c)'(a#(c) / 2)
if e = 1 and rand1 = 2 then ang#(i) = ang#(c) - a#(c)'(a#(c) / 2)

x3d1 = xtemp(c) + cos(ang#(i) * pi# / 180) * mag#(c)
y3d1 = ytemp(i)
z3d1 = ztemp(c) + -sin(ang#(i) * pi# / 180) * mag#(c)

gosub bulk3

glLineWidth(size#(c))

glBegin(GL_LINES)

glColor3f(1,1,1)
'glVertex3f(xtemp(c),ytemp(c),ztemp(c))
'glVertex3f(x3d1,y3d1,z3d1)

glEnd()

'ba# = 0'rnd(1) * 360

'glTranslatef(xtemp(c),ytemp(c),ztemp(c))
'glRotatef ( ang#(i)+90, 0, 1 ,0)

'gluCylinder(quadric1,size#(i),size#(i),mag#(c),16,16)

'glRotatef ( -ang#(i)-90, 0, 1, 0)
'glTranslatef(-xtemp(c),-ytemp(c),-ztemp(c))

xtemp(i) = x3d1
ytemp(i) = y3d1
ztemp(i) = z3d1

which(i) = 2

return

bulk:

glBindTexture(GL_TEXTURE_2D, texture(0))

O.x = x1
O.y = y1
O.z = 0

P.x = xtemp(0)
P.y = ytemp(0)
P.z = 0

gosub cylinder

return

bulk2:

glBindTexture(GL_TEXTURE_2D, texture(0))

O.x = xtemp(c)
O.y = ytemp(c)
O.z = 0

P.x = xtemp(i)
P.y = ytemp(i)
P.z = 0

gosub cylinder

'p1.x = xtemp(c) + xscale
'p1.y = ytemp(c)
'p1.z = z - zscale

'p2.x = xtemp(i) + xscale
'p2.y = ytemp(i)
'p2.z = z - zscale

'p3.x = xtemp(i) + xscale
'p3.y = ytemp(i)
'p3.z = z + zscale

return

bulk3:

glBindTexture(GL_TEXTURE_2D, texture(0))

O.x = xtemp(c)
O.y = ytemp(c)
O.z = ztemp(c)

P.x = x3d1
P.y = y3d1
P.z = z3d1

gosub cylinder

'1.x = xtemp(c) + xscale
'p1.y = ytemp(c)
'p1.z = ztemp(c) - zscale

'p2.x = x3d1 + xscale
'p2.y = y3d1
'p2.z = z3d1 - zscale

'p3.x = x3d1 + xscale
'p3.y = y3d1
'p3.z = z3d1 + zscale


return

cylinder:

  glPushMatrix()

glTranslatef(O.x, O.y, O.z)
       
Z.x = P.x - O.x
Z.y = P.y - O.y
Z.z = P.z - O.z

'make it a unit
d = sqr(Z.x * Z.x + Z.y * Z.y + Z.z * Z.z)

'store the cylinder's length
length = d

Z.x = Z.x / d
Z.y = Z.y / d
Z.z = Z.z / d

Y.x = Z.y
Y.y = -Z.z
Y.z = 0

'make it a unit
d = sqr(Y.x * Y.x + Y.y * Y.y + Y.z * Y.z)

'check for special case
if d < 0.1 then
Y.x = -Z.z
Y.y = 0
Y.z = Z.x
d = sqr(Y.x * Y.x + Y.y * Y.y + Y.z * Y.z)
end if
Y.x = Y.x / d
Y.y = Y.y / d
Y.z = Y.z / d

'cross product
X.x = Y.y * Z.z - Y.z * Z.y
X.y = Y.z * Z.x - Y.x * Z.z
X.z = Y.x * Z.y - Y.y * Z.x

'make it a unit
d = sqr(X.x * X.x + X.y * X.y + X.z * X.z)
X.x = X.x / d
X.y = X.y / d
X.z = X.z / d

'cross product
Y2.x = X.y * Z.z - X.z * Z.y
Y2.y = X.z * Z.x - X.x * Z.z
Y2.z = X.x * Z.y - X.y * Z.x
Y2 = Y

matrix( 0)=X.x
matrix( 1)=X.y
matrix( 2)=X.z
matrix( 3)=0

matrix( 4)=Y2.x
matrix( 5)=Y2.y
matrix( 6)=Y2.z
matrix( 7)=0

matrix( 8)=Z.x
matrix( 9)=Z.y
matrix(10)=Z.z
matrix(11)=0

matrix(12)=0
matrix(13)=0
matrix(14)=0
matrix(15)=1

glMultMatrixf(@matrix(0))

glColor3f(1,1,1)
   
    gluCylinder(cylinder,size#(c), size#(c), length, segments, stacks)
                   
   glPopMatrix()
   
     
return   

'' Load Bitmaps And Convert To Textures
function LoadGLTextures() as integer
  dim Status as integer = FALSE                     '' Status Indicator
  dim TextureImage(9) as BITMAP_RGBImageRec ptr     '' Create Storage Space For The Texture

  ' Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
' TextureImage(0) = LoadBMP(exepath + "/textures/demon.bmp")
  TextureImage(0) = LoadBMP("c:\FBFiles\textures\bark03.bmp")
  TextureImage(1) = LoadBMP("c:\FBFiles\Maps\venus.bmp")
  TextureImage(2) = LoadBMP("c:\FBFiles\Maps\earth.bmp")
  'TextureImage(3) = LoadBMP("c:\FBFiles\Maps\moon24.bmp")
  'TextureImage(4) = LoadBMP("c:\FBFiles\Maps\earth.bmp")
  'TextureImage(5) = LoadBMP("c:\FBFiles\Maps\mars.bmp")
  'TextureImage(6) = LoadBMP("c:\FBFiles\Maps\jupiter.bmp") ' also jupiter2
  'TextureImage(7) = LoadBMP("c:\FBFiles\Maps\moon24.bmp")
  'TextureImage(8) = LoadBMP("c:\FBFiles\Maps\earth.bmp")
  TextureImage(9) = LoadBMP("c:\FBFiles\Maps\pluto.bmp")
  dim h
  for h = 0 to 9
  if TextureImage(h) then
    Status = TRUE                                   '' Set The Status To TRUE
    glGenTextures 1, @texture(h)                    '' Create The Texture
    ' Typical Texture Generation Using Data From The Bitmap
    glBindTexture GL_TEXTURE_2D, texture(h)
    glTexImage2D GL_TEXTURE_2D, 0, 3, TextureImage(h)->sizeX, TextureImage(h)->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage(h)->buffer
    glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR
    glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR
  end if

  if TextureImage(h) then                           '' If Texture Exists
    if TextureImage(h)->buffer then                 '' If Texture Image Exist
      deallocate(TextureImage(h)->buffer)           '' Free The Texture Image Memory
    end if
    deallocate(TextureImage(h))                     '' Free The Image Structure
  end if
  next
  return Status                                     '' Return The Status
end function


Now, Thanks Jim for the help with the glucylinders
It makes it so it's lit and textured.

Now, Not to be a newcince.
But what shall we do about leaves?
A tree needs leaves unless it's winter.

Any ideas?
Thanks

It also needs a little more randomness in the Y-Height factor.


Scotty B.

11
Freebasic / Re-OpenGL glucylinders for 3D Trees
« on: June 27, 2007 »
Thanks for helping me draw glucylinders from point to point!
Really

now got other problem

Have a look.

Code: [Select]

'$include: 'GL/gl.bi'
'$include: 'GL/glu.bi'

'' Setup our booleans
const FALSE = 0
const TRUE  = not FALSE

#include once "bmpload.bi"

declare function LoadGLTextures() as integer


dim shared texture(9) as GLuint               '' Storage For One Texture ( NEW )

dim xrot as single                            '' X Rotation ( NEW )
dim yrot as single                            '' Y Rotation ( NEW )
dim zrot as single                            '' Z Rotation ( NEW )

''$include: 'windows.bi'

option explicit

TYPE vector
x AS DOUBLE
y AS DOUBLE
z AS DOUBLE
END TYPE

declare sub drawblob(byval p as vector, byval colour as uinteger)
declare sub readinput()

dim camang as single
dim screenwidth as uinteger
dim screenheight as uinteger
dim shared init as integer
dim shared ox as integer
dim shared oy as integer

DIM shared O AS vector
DIM shared P as vector

DIM X as vector
dim Y as vector
dim Y2 as vector
dim Z as vector

dim matrix(16) as GLfloat
dim d as single

dim shared sphere as GLUQuadricObj ptr

dim radius as GLdouble
dim length as GLdouble
dim segments as GLint
dim stacks as GLint
dim cylinder as GLUQuadricObj ptr

screenwidth = 640
screenheight = 480
init = 0


SCREEN 18,32,,2

glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(60,cast(single, screenwidth)/screenheight,1,1024)

glEnable(GL_DEPTH_TEST)
glDepthFunc(GL_LEQUAL)
glClearDepth(1)

'glEnable(GL_TEXTURE_2D)

glClearColor(0,1,0,1)

sphere = gluNewQuadric()
'---------------------------------------------------------------------------------------
' cylinder params
'---------------------------------------------------------------------------------------
cylinder = gluNewQuadric()
gluQuadricNormals(cylinder, GLU_SMOOTH)
gluQuadricTexture(cylinder, GL_TRUE)

radius = 10
segments = 9
stacks = 2
         
dim nopts = 2046

dim which(nopts)

dim bt#(nopts)

dim xtemp(nopts)
dim ytemp(nopts)

dim ztemp(nopts)

dim xtemp2(nopts)
dim ytemp2(nopts)

dim mag#(nopts)

dim size#(nopts)

dim ang#(nopts)

dim perb#(nopts)

dim angle = 0

dim mult = 1
dim add  = 1

dim yr#

dim i,j,k
dim a,b,c
dim mult1,mult2

dim pi#

dim x1,y1,z1

dim lenght2

dim a1#
dim count#
dim l#
dim s#
dim s1#,s2#

dim x3d1,y3d1,z3d1

dim rand1

dim x3,y3,z3

Dim As Single LightPos(3) => {-100,100, 1024, 0 }
Dim As Single Ambient(3) => { .7, .7, .7, 1}

glEnable(GL_LIGHTING)  ' Turn on OpenGL Lighting
glEnable(GL_LIGHT0)  ' Light Source 0 (0-7)
glLightfv(GL_LIGHT0,GL_POSITION,@LightPos(0))  ' Light Position
glLightfv(GL_LIGHT0,GL_AMBIENT,@Ambient(0))  ' Ambient Light Source (Overall Scene)

'glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
'glEnable (GL_BLEND)

'' Jump To Texture Loading Routine
if (not LoadGLTextures()) then
      end 1                                        '' If Texture Didn't Load Quit
end if

glEnable(GL_DEPTH_TEST)
glDepthFunc(GL_LEQUAL)
glClearDepth(1)

glEnable(GL_TEXTURE_2D)

'glEnable(GL_CULL_FACE)

glClearColor(0,0,1,1)

do

glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)

glMatrixMode(GL_MODELVIEW)
glLoadIdentity()

glRotatef(-camang, 0, 0, 1)
glTranslatef(0,-256,-1024)

randomize timer

glTranslatef(0,0,512)
glRotatef(yr#,0,1,0)

gosub math

gosub rendertrunk

gosub renderbranches

flip

yr# = yr# + 1

loop until inkey$ = chr$(27)

end

math:

dim a#(nopts)

for i = 0 to nopts

xtemp(i) = 0
ytemp(i) = 0
ztemp(i) = 0

which(i) = 0

next i

a = 1
b = 2
c = 0

mult1 = 2
mult2 = 4

pi# = 3.1415926

x1 = 0
y1 = 0

lenght2 = screenheight / 4

xtemp(0) = x1 + -cos(bt#(0) * pi# / 180) * lenght2
ytemp(0) = y1 +  sin(bt#(0) * pi# / 180) * lenght2

size#(0) = 12

'gosub trunk1

mag#(0) = lenght2 / 2

'glLineWidth(size#(0))

'y1 = size#(0)
Z1 = 0

gosub bulk

which(0) = 1

for j = 0 to 9
   
for i = a to b

if j > 0 and d = 0 then c = c + 1

if d = 0 then a1# = rnd(1) * 1

if d = 0 then bt#(i) = bt#(c) + (45*a1#):a#(i) = a#(c) + (45*a1#)
if d = 1 then bt#(i) = bt#(i-1) - 45:a#(i) = a#(i-1) -45 


if d = 0 then count# = bt#(i) - bt#(c)
if d = 1 then count# = bt#(c) - bt#(i)

'if d = 1 and count1# > count2# then goto trunk2

'gosub trunk2

l# = count# / 90

mag#(i) = mag#(c) * (1-l#)

xtemp(i) = xtemp(c) + -cos(bt#(i) * pi# / 180) * mag#(i)
ytemp(i) = ytemp(c) +  sin(bt#(i) * pi# / 180) * mag#(i)

size#(i) = size#(c) * (1-l#)

if d = 0 then s1# = size#(i)
if d = 1 then s2# = size#(i)

if d = 1 and which(c) = 1 and s1# >= s2# then which(i-1) = 1
if d = 1 and which(c) = 1 and s1# < s2# then which(i) = 1

'if d = 1 and which(c) = 1 and s1# = s2# then which(i-1) = 1:which(i) = 1

glLineWidth(size#(i))

glBegin(GL_LINES)

glColor3f(1,1,1)

'glVertex3f(xtemp(c),ytemp(c),0)
'glVertex3f(xtemp(i),ytemp(i),0)

glEnd()

d = d + 1
if d = 2 then d = 0

next i
 
if j > 0 then mult1 = mult1 * 2
if j > 0 then mult2 = mult2 * 2

a = a + mult1
b = b + mult2

next j

return

rendertrunk:

a = 1
b = 2
c = 0

mult1 = 2
mult2 = 4

for j = 0 to 9
   
for i = a to b

if j > 0 and d = 0 then c = c + 1

if which(c) = 1 and which(i) = 1 then gosub trunk2

'gosub trunk2

d = d + 1
if d = 2 then d = 0

next i
 
if j > 0 then mult1 = mult1 * 2
if j > 0 then mult2 = mult2 * 2

a = a + mult1
b = b + mult2

next j

return

trunk1:

'glRotatef (-90, 1, 0, 0)

'gluCylinder(quadric1,size#(c),size#(c),lenght,16,16)

'glRotatef ( 90, 1, 0, 0)

return

trunk2:

'glLineWidth(size#(i))

'glBegin(GL_LINES)

'glColor3f(1,1,1)

'glVertex3f(xtemp(c),ytemp(c),0)
'glVertex3f(xtemp(i),ytemp(i),0)

gosub bulk2

'glEnd()

'glTranslatef(xtemp(c),ytemp(c),0)
'glRotatef (-90, 1, 0, 0)
'glRotatef ( a#(i), 0, 1 ,0)

'glColor3f(0,0,1)
'gluCylinder(quadric1,size#(c),size#(c),mag#(c),16,16)

'glRotatef (-a#(i), 0, 1, 0)
'glRotatef ( 90, 1, 0, 0)
'glTranslatef(-xtemp(c),-ytemp(c),0)

return

renderbranches:

for k = 0 to 1

a = 1
b = 2
c = 0

mult1 = 2
mult2 = 4

for j = 0 to 9
   
for i = a to b

if j > 0 and d = 0 then c = c + 1

'if which(c) = 1 and which(i) = 0 then gosub branches
'if which(c) = 2 and which(i) = 0 then gosub more

'if which(c) > 1 then gosub more

'gosub branches

d = d + 1
if d = 2 then d = 0

next i

if j > 0 then mult1 = mult1 * 2
if j > 0 then mult2 = mult2 * 2

a = a + mult1
b = b + mult2

next j
next k

return

branches:

ang#(c) = rnd(1) * 360

x3d1 = xtemp(c) + cos(ang#(c) * pi# / 180) * mag#(c)
y3d1 = ytemp(i)
z3d1 = ztemp(c) + -sin(ang#(c) * pi# / 180) * mag#(c)

gosub bulk3

ang#(i) = ang#(c)

xtemp(i) = x3d1
ytemp(i) = y3d1
ztemp(i) = z3d1

which(i) = 2

return

more:

rand1 = int(rnd(1) * 2 ) + 1

if d = 0 and rand1 = 1 then ang#(i) = ang#(c) + a#(c)'(a#(c) / 2)
if d = 0 and rand1 = 2 then ang#(i) = ang#(c) - a#(c)'(a#(c) / 2)

if d = 1 and rand1 = 1 then ang#(i) = ang#(c) + a#(c)'(a#(c) / 2)
if d = 1 and rand1 = 2 then ang#(i) = ang#(c) - a#(c)'(a#(c) / 2)

x3d1 = xtemp(c) + cos(ang#(i) * pi# / 180) * mag#(c)
y3d1 = ytemp(i)
z3d1 = ztemp(c) + -sin(ang#(i) * pi# / 180) * mag#(c)

gosub bulk3

glLineWidth(size#(c))

glBegin(GL_LINES)

glColor3f(1,1,1)
'glVertex3f(xtemp(c),ytemp(c),ztemp(c))
'glVertex3f(x3d1,y3d1,z3d1)

glEnd()

'ba# = 0'rnd(1) * 360

'glTranslatef(xtemp(c),ytemp(c),ztemp(c))
'glRotatef ( ang#(i)+90, 0, 1 ,0)

'gluCylinder(quadric1,size#(i),size#(i),mag#(c),16,16)

'glRotatef ( -ang#(i)-90, 0, 1, 0)
'glTranslatef(-xtemp(c),-ytemp(c),-ztemp(c))

xtemp(i) = x3d1
ytemp(i) = y3d1
ztemp(i) = z3d1

which(i) = 2

return

bulk:

glBindTexture(GL_TEXTURE_2D, texture(0))

O.x = 0
O.y = y1
O.z = 0

P.x = 0
P.y = y1 + lenght2
P.z = 0

gosub cylinder

return

bulk2:

glBindTexture(GL_TEXTURE_2D, texture(0))

O.x = xtemp(c)
O.y = ytemp(c)
O.z = 0

P.x = xtemp(i)
P.y = ytemp(i)
P.z = 0

gosub cylinder

'p1.x = xtemp(c) + xscale
'p1.y = ytemp(c)
'p1.z = z - zscale

'p2.x = xtemp(i) + xscale
'p2.y = ytemp(i)
'p2.z = z - zscale

'p3.x = xtemp(i) + xscale
'p3.y = ytemp(i)
'p3.z = z + zscale

return

bulk3:

glBindTexture(GL_TEXTURE_2D, texture(0))

O.x = xtemp(c)
O.y = ytemp(c)
O.z = ztemp(c)

P.x = x3d1
P.y = y3d1
P.z = z3d1

gosub cylinder

'1.x = xtemp(c) + xscale
'p1.y = ytemp(c)
'p1.z = ztemp(c) - zscale

'p2.x = x3d1 + xscale
'p2.y = y3d1
'p2.z = z3d1 - zscale

'p3.x = x3d1 + xscale
'p3.y = y3d1
'p3.z = z3d1 + zscale


return

cylinder:

  glPushMatrix()

glTranslatef(O.x, O.y, O.z)
       
Z.x = P.x - O.x
Z.y = P.y - O.y
Z.z = P.z - O.z

'make it a unit
d = sqr(Z.x * Z.x + Z.y * Z.y + Z.z * Z.z)

'store the cylinder's length
length = d

Z.x = Z.x / d
Z.y = Z.y / d
Z.z = Z.z / d

Y.x = Z.y
Y.y = -Z.z
Y.z = 0

'make it a unit
d = sqr(Y.x * Y.x + Y.y * Y.y + Y.z * Y.z)

'check for special case
if d < 0.1 then
Y.x = -Z.z
Y.y = 0
Y.z = Z.x
d = sqr(Y.x * Y.x + Y.y * Y.y + Y.z * Y.z)
end if
Y.x = Y.x / d
Y.y = Y.y / d
Y.z = Y.z / d

'cross product
X.x = Y.y * Z.z - Y.z * Z.y
X.y = Y.z * Z.x - Y.x * Z.z
X.z = Y.x * Z.y - Y.y * Z.x

'make it a unit
d = sqr(X.x * X.x + X.y * X.y + X.z * X.z)
X.x = X.x / d
X.y = X.y / d
X.z = X.z / d

'cross product
Y2.x = X.y * Z.z - X.z * Z.y
Y2.y = X.z * Z.x - X.x * Z.z
Y2.z = X.x * Z.y - X.y * Z.x
Y2 = Y

matrix( 0)=X.x
matrix( 1)=X.y
matrix( 2)=X.z
matrix( 3)=0

matrix( 4)=Y2.x
matrix( 5)=Y2.y
matrix( 6)=Y2.z
matrix( 7)=0

matrix( 8)=Z.x
matrix( 9)=Z.y
matrix(10)=Z.z
matrix(11)=0

matrix(12)=0
matrix(13)=0
matrix(14)=0
matrix(15)=1

glMultMatrixf(@matrix(0))

glColor3f(1,1,1)
   
    gluCylinder(cylinder,size#(c), size#(c), length, segments, stacks)
           
   glPopMatrix()
   
     
return   

'' Load Bitmaps And Convert To Textures
function LoadGLTextures() as integer
  dim Status as integer = FALSE                     '' Status Indicator
  dim TextureImage(9) as BITMAP_RGBImageRec ptr     '' Create Storage Space For The Texture

  ' Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
' TextureImage(0) = LoadBMP(exepath + "/textures/demon.bmp")
  TextureImage(0) = LoadBMP("c:\FBFiles\textures\bark03.bmp")
  TextureImage(1) = LoadBMP("c:\FBFiles\Maps\venus.bmp")
  TextureImage(2) = LoadBMP("c:\FBFiles\Maps\earth.bmp")
  'TextureImage(3) = LoadBMP("c:\FBFiles\Maps\moon24.bmp")
  'TextureImage(4) = LoadBMP("c:\FBFiles\Maps\earth.bmp")
  'TextureImage(5) = LoadBMP("c:\FBFiles\Maps\mars.bmp")
  'TextureImage(6) = LoadBMP("c:\FBFiles\Maps\jupiter.bmp") ' also jupiter2
  'TextureImage(7) = LoadBMP("c:\FBFiles\Maps\moon24.bmp")
  'TextureImage(8) = LoadBMP("c:\FBFiles\Maps\earth.bmp")
  TextureImage(9) = LoadBMP("c:\FBFiles\Maps\pluto.bmp")
  dim h
  for h = 0 to 9
  if TextureImage(h) then
    Status = TRUE                                   '' Set The Status To TRUE
    glGenTextures 1, @texture(h)                    '' Create The Texture
    ' Typical Texture Generation Using Data From The Bitmap
    glBindTexture GL_TEXTURE_2D, texture(h)
    glTexImage2D GL_TEXTURE_2D, 0, 3, TextureImage(h)->sizeX, TextureImage(h)->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage(h)->buffer
    glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR
    glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR
  end if

  if TextureImage(h) then                           '' If Texture Exists
    if TextureImage(h)->buffer then                 '' If Texture Image Exist
      deallocate(TextureImage(h)->buffer)           '' Free The Texture Image Memory
    end if
    deallocate(TextureImage(h))                     '' Free The Image Structure
  end if
  next
  return Status                                     '' Return The Status
end function


The subrountine to draw the cylinders in not accepting my points.

Any suggestions?

Sorry to bug you again.



12
Freebasic / Please Help Me
« on: June 26, 2007 »
Sorry to post another topic on the subject for glucylinders
but I really could use a small program that lets me plot a glucylinder
for one 3d point to another 3d point.
Can someone please help me I am not understanding the last post.
I promise to give credit to who ever helps me.
I am trying to make real nice looking trees but right now
they look blocky because I am useing rectangles instead of
cylinders.
I've looked all over the net but I can't find much that helps
because I don't have a working program that does this in freebasic.
So for nicer looking 3d trees in freebasic could someone please code
a fragment up for me?

Thanks
And to those who help
the project's code will be free for the downloading.

Thanks Again

Scott B.

13
Freebasic / Re: glucylinder?
« on: June 26, 2007 »
Thanks for the explanation.
Could you code me up a small program
showing the code in action?
All's I need is to be able to draw a glucylinder from a 3d point to another.
Thanks

14
Freebasic / 3D Trees?
« on: June 25, 2007 »
Here is the code.

Code: [Select]
'$include: 'GL/gl.bi'
'$include: 'GL/glu.bi'

'' Setup our booleans
const FALSE = 0
const TRUE  = not FALSE

#include once "bmpload.bi"

declare function LoadGLTextures() as integer


dim shared texture(9) as GLuint               '' Storage For One Texture ( NEW )

dim xrot as single                            '' X Rotation ( NEW )
dim yrot as single                            '' Y Rotation ( NEW )
dim zrot as single                            '' Z Rotation ( NEW )

TYPE vector
    x AS SINGLE
    y AS SINGLE
    z AS SINGLE   
END TYPE

DIM p1 AS vector
DIM p2 as vector
DIM p3 AS vector

DIM SHARED norm(2) AS SINGLE

FUNCTION getnorm(p1 AS vector,p2 AS vector,p3 AS vector)

v1x# = p1.x - p2.x
v1y# = p1.y - p2.y
v1z# = p1.z - p2.z

v2x# = p2.x - p3.x
v2y# = p2.y - p3.y
v2z# = p2.z - p3.z

nx# = (v1y# * v2z#) - (v1z# * v2y#)
ny# = (v1z# * v2x#) - (v1x# * v2z#)
nz# = (v1x# * v2y#) - (v1y# * v2x#)

lenght# = SQR((nx# * nx#) + (ny# * ny#) + (nz# * nz#))

norm(0) = nx# / lenght#
norm(1) = ny# / lenght#
norm(2) = nz# / lenght#

END FUNCTION

screenwidth  = 640
screenheight = 480

SCREEN 18,32,,2

glMatrixMode (GL_PROJECTION)           
glLoadIdentity ()                     
gluPerspective(60,screenwidth/screenheight,1,1024)
glMatrixMode (GL_MODELVIEW)           

nopts = 2046

dim which(nopts)

dim bt#(nopts)

dim xtemp(nopts)
dim ytemp(nopts)

dim ztemp(nopts)

dim xtemp2(nopts)
dim ytemp2(nopts)

dim mag#(nopts)

dim size#(nopts)

dim ang#(nopts)

dim perb#(nopts)

angle = 0

mult = 1
add  = 1

bt#(0) = 90

bt#(index + mult + position) = bt#(0) + angle
bt#(index + mult + position + add) = bt#(0) - angle

'print bt(0)

mult = mult * 2
num2 = 2

a = 1

for j = 0 to 9

num = mult - 1

for i = num to num2

if i <  mult then position = 0
if i >= mult then position = position + 1

bt#(i + mult + position) = bt#(a) + angle
bt#(i + mult + position + add) = bt#(a) - angle

'print bt(i);" ";

a = a + 1

next i

print

old = old + mult
mult = mult * 2

num2 = old + mult

next j

'print

Dim As Single LightPos(3) => {-100,100, 1024, 0 }
Dim As Single Ambient(3) => { .7, .7, .7, 1}

glEnable(GL_LIGHTING)  ' Turn on OpenGL Lighting
glEnable(GL_LIGHT0)  ' Light Source 0 (0-7)
glLightfv(GL_LIGHT0,GL_POSITION,@LightPos(0))  ' Light Position
glLightfv(GL_LIGHT0,GL_AMBIENT,@Ambient(0))  ' Ambient Light Source (Overall Scene)

'glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
'glEnable (GL_BLEND)

'' Jump To Texture Loading Routine
if (not LoadGLTextures()) then
      end 1                                        '' If Texture Didn't Load Quit
end if

glEnable(GL_DEPTH_TEST)
glDepthFunc(GL_LEQUAL)
glClearDepth(1)

glEnable(GL_TEXTURE_2D)

'glEnable(GL_CULL_FACE)

glClearColor(0,0,1,1)

do

' Position camera
glLoadIdentity ()
glRotatef (-camang#, 0, 0, 1)
glTranslatef (0,-256,-1024)

randomize timer

glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)

glTranslatef(0,0,512)
glRotatef(y#,0,1,0)

gosub math

gosub rendertrunk

gosub renderbranches

flip

y# = y# + 1

loop until inkey$ = chr$(27)

end

math:

dim a#(nopts)

for i = 0 to nopts

xtemp(i) = 0
ytemp(i) = 0
ztemp(i) = 0

which(i) = 0

next i

a = 1
b = 2
c = 0

mult1 = 2
mult2 = 4

pi# = 3.1415926

x1 = 0
y1 = 0

lenght = screenheight / 4

xtemp(0) = x1 + -cos(bt#(0) * pi# / 180) * lenght
ytemp(0) = y1 +  sin(bt#(0) * pi# / 180) * lenght

size#(0) = 12

'gosub trunk1

mag#(0) = lenght / 2

'glLineWidth(size#(0))

xscale = size#(0)
'yscale = size#(0)
zscale = size#(0)

'y1 = size#(0)
Z = 0

gosub bulk

which(0) = 1

for j = 0 to 9
   
for i = a to b

if j > 0 and d = 0 then c = c + 1

if d = 0 then a1# = rnd(1) * 1

if d = 0 then bt#(i) = bt#(c) + (45*a1#):a#(i) = a#(c) + (45*a1#)
if d = 1 then bt#(i) = bt#(i-1) - 45:a#(i) = a#(i-1) -45 


if d = 0 then count# = bt#(i) - bt#(c)
if d = 1 then count# = bt#(c) - bt#(i)

'if d = 1 and count1# > count2# then goto trunk2

'gosub trunk2

l# = count# / 90

mag#(i) = mag#(c) * (1-l#)

xtemp(i) = xtemp(c) + -cos(bt#(i) * pi# / 180) * mag#(i)
ytemp(i) = ytemp(c) +  sin(bt#(i) * pi# / 180) * mag#(i)

size#(i) = size#(c) * (1-l#)

if d = 0 then s1# = size#(i)
if d = 1 then s2# = size#(i)

if d = 1 and which(c) = 1 and s1# >= s2# then which(i-1) = 1
if d = 1 and which(c) = 1 and s1# < s2# then which(i) = 1

'if d = 1 and which(c) = 1 and s1# = s2# then which(i-1) = 1:which(i) = 1

glLineWidth(size#(i))

glBegin(GL_LINES)

glColor3f(1,1,1)

'glVertex3f(xtemp(c),ytemp(c),0)
'glVertex3f(xtemp(i),ytemp(i),0)

glEnd()

d = d + 1
if d = 2 then d = 0

next i
 
if j > 0 then mult1 = mult1 * 2
if j > 0 then mult2 = mult2 * 2

a = a + mult1
b = b + mult2

next j

return

rendertrunk:

a = 1
b = 2
c = 0

mult1 = 2
mult2 = 4

for j = 0 to 9
   
for i = a to b

if j > 0 and d = 0 then c = c + 1

if which(c) = 1 and which(i) = 1 then gosub trunk2

'gosub trunk2

d = d + 1
if d = 2 then d = 0

next i
 
if j > 0 then mult1 = mult1 * 2
if j > 0 then mult2 = mult2 * 2

a = a + mult1
b = b + mult2

next j

return

trunk1:

'glRotatef (-90, 1, 0, 0)

'gluCylinder(quadric1,size#(c),size#(c),lenght,16,16)

'glRotatef ( 90, 1, 0, 0)

return

trunk2:

'glLineWidth(size#(i))

'glBegin(GL_LINES)

'glColor3f(1,1,1)

'glVertex3f(xtemp(c),ytemp(c),0)
'glVertex3f(xtemp(i),ytemp(i),0)

xscale = size#(c)
'yscale = 'mag#(c)
zscale = size#(c)

gosub bulk2

'glEnd()

'glTranslatef(xtemp(c),ytemp(c),0)
'glRotatef (-90, 1, 0, 0)
'glRotatef ( a#(i), 0, 1 ,0)

'glColor3f(0,0,1)
'gluCylinder(quadric1,size#(c),size#(c),mag#(c),16,16)

'glRotatef (-a#(i), 0, 1, 0)
'glRotatef ( 90, 1, 0, 0)
'glTranslatef(-xtemp(c),-ytemp(c),0)

return

renderbranches:

for k = 0 to 1

a = 1
b = 2
c = 0

mult1 = 2
mult2 = 4

for j = 0 to 9
   
for i = a to b

if j > 0 and d = 0 then c = c + 1

if which(c) = 1 and which(i) = 0 then gosub branches
'if which(c) = 2 and which(i) = 0 then gosub more

if which(c) > 1 then gosub more

'gosub branches

d = d + 1
if d = 2 then d = 0

next i

if j > 0 then mult1 = mult1 * 2
if j > 0 then mult2 = mult2 * 2

a = a + mult1
b = b + mult2

next j
next k

return

branches:

ang#(c) = rnd(1) * 360

x3d1 = xtemp(c) + cos(ang#(c) * pi# / 180) * mag#(c)
y3d1 = ytemp(i)
z3d1 = ztemp(c) + -sin(ang#(c) * pi# / 180) * mag#(c)


xscale = size#(c)
'yscale = 'mag#(c)
zscale = size#(c)

gosub bulk3

glLineWidth(size#(c))

glBegin(GL_LINES)

glColor3f(1,1,1)
'glVertex3f(xtemp(c),ytemp(c),ztemp(c))
'glVertex3f(x3d1,y3d1,z3d1)

glEnd()

ba# = 0'rnd(1) * 360

'glTranslatef(xtemp(c),ytemp(c),0)
'glRotatef (-90, 1, 0, 0)
'glRotatef ( ang#(c)+90, 0, 1 ,0)

'glColor3f(1,1,1)
'gluCylinder(quadric1,size#(i),size#(i),mag#(c),16,16)

'glRotatef ( -ang#(c)-90, 0, 1, 0)
'glRotatef ( 90, 1, 0, 0)
'glTranslatef(-xtemp(c),-ytemp(c),0)

ang#(i) = ang#(c)

xtemp(i) = x3d1
ytemp(i) = y3d1
ztemp(i) = z3d1

which(i) = 2

return

more:

rand1 = int(rnd(1) * 2 ) + 1

if d = 0 and rand1 = 1 then ang#(i) = ang#(c) + a#(c)'(a#(c) / 2)
if d = 0 and rand1 = 2 then ang#(i) = ang#(c) - a#(c)'(a#(c) / 2)

if d = 1 and rand1 = 1 then ang#(i) = ang#(c) + a#(c)'(a#(c) / 2)
if d = 1 and rand1 = 2 then ang#(i) = ang#(c) - a#(c)'(a#(c) / 2)

'p# = rnd(1) * 1

'perb#(c) = p# * 5

x3d1 = xtemp(c) + cos(ang#(i) * pi# / 180) * mag#(c)
y3d1 = ytemp(i) - perb#(c)
z3d1 = ztemp(c) + -sin(ang#(i) * pi# / 180) * mag#(c)

'perb#(i) = perb#(c)

'gosub bulk2
xscale = size#(c)
'yscale = 'mag#(c)
zscale = size#(c)

gosub bulk3

glLineWidth(size#(c))

glBegin(GL_LINES)

glColor3f(1,1,1)
'glVertex3f(xtemp(c),ytemp(c),ztemp(c))
'glVertex3f(x3d1,y3d1,z3d1)

glEnd()

'ba# = 0'rnd(1) * 360

'glTranslatef(xtemp(c),ytemp(c),ztemp(c))
'glRotatef ( ang#(i)+90, 0, 1 ,0)

'gluCylinder(quadric1,size#(i),size#(i),mag#(c),16,16)

'glRotatef ( -ang#(i)-90, 0, 1, 0)
'glTranslatef(-xtemp(c),-ytemp(c),-ztemp(c))

xtemp(i) = x3d1
ytemp(i) = y3d1
ztemp(i) = z3d1

which(i) = 2

return

bulk:

glBindTexture(GL_TEXTURE_2D, texture(0))

glBegin(GL_QUADS)

p1.x = x1 + xscale
p1.y = y1
p1.z = z - zscale

p2.x = xtemp(0) + xscale
p2.y = ytemp(0)
p2.z = z - zscale

p3.x = xtemp(0) + xscale
p3.y = ytemp(0)
p3.z = z + zscale

getnorm(p1,p2,p3)
glNormal3f(norm(0),norm(1),norm(2))

' right face
glTexCoord2f(0,0)
glVertex3f(x1+xscale,y1,z-zscale)
glTexCoord2f(0,1)
glVertex3f(xtemp(0)+xscale,ytemp(0),z-zscale)
glTexCoord2f(1,1)
glVertex3f(xtemP(0)+xscale,ytemp(0),z+zscale)
glTexCoord2f(1,0)
glVertex3f(x1+xscale,y1,z+zscale)

p1.x = x1 - xscale
p1.y = y1
p1.z = z - zscale

p2.x = xtemp(0) - xscale
p2.y = ytemp(0)
p2.z = z - zscale

p3.x = xtemp(0) - xscale
p3.y = ytemp(0)
p3.z = z + zscale

getnorm(p1,p2,p3)
glNormal3f(norm(0),norm(1),norm(2))

' left face
glTexCoord2f(0,0)
glVertex3f(x1-xscale,y1,z-zscale)
glTexCoord2f(0,1)
glVertex3f(xtemp(0)-xscale,ytemp(0),z-zscale)
glTexCoord2f(1,1)
glVertex3f(xtemP(0)-xscale,ytemp(0),z+zscale)
glTexCoord2f(1,0)
glVertex3f(x1-xscale,y1,z+zscale)

p1.x = x1 - xscale
p1.y = y1
p1.z = z - zscale

p2.x = x1 + xscale
p2.y = y1
p2.z = z - zscale

p3.x = xtemp(0) + xscale
p3.y = ytemp(0)
p3.z = z - zscale

getnorm(p1,p2,p3)
glNormal3f(norm(0),norm(1),norm(2))

' back
glTexCoord2f(0,0)
glVertex3f(x1-xscale,y1,z-zscale)
glTexCoord2f(1,0)
glVertex3f(x1+xscale,y1,z-zscale)
glTexCoord2f(1,1)
glVertex3f(xtemp(0)+xscale,ytemp(0),z-zscale)
glTexCoord2f(0,1)
glVertex3f(xtemp(0)-xscale,ytemp(0),z-zscale)

p1.x = x1 - xscale
p1.y = y1
p1.z = z + zscale

p2.x = x1 + xscale
p2.y = y1
p2.z = z + zscale

p3.x = xtemp(0) + xscale
p3.y = ytemp(0)
p3.z = z + zscale

getnorm(p1,p2,p3)
glNormal3f(norm(0),norm(1),norm(2))

' front
glTexCoord2f(0,0)
glVertex3f(x1-xscale,y1,z+zscale)
glTexCoord2f(1,0)
glVertex3f(x1+xscale,y1,z+zscale)
glTexCoord2f(1,1)
glVertex3f(xtemp(0)+xscale,ytemp(0),z+zscale)
glTexCoord2f(0,1)
glVertex3f(xtemp(0)-xscale,ytemp(0),z+zscale)

glEnd()

return

bulk2:

glBindTexture(GL_TEXTURE_2D, texture(0))

glBegin(GL_QUADS)

p1.x = xtemp(c) + xscale
p1.y = ytemp(c)
p1.z = z - zscale

p2.x = xtemp(i) + xscale
p2.y = ytemp(i)
p2.z = z - zscale

p3.x = xtemp(i) + xscale
p3.y = ytemp(i)
p3.z = z + zscale

getnorm(p1,p2,p3)
glNormal3f(norm(0),norm(1),norm(2))

' right face
glTexCoord2f(0,0)
glVertex3f(xtemp(c)+xscale,ytemp(c),z-zscale)
glTexCoord2f(0,1)
glVertex3f(xtemp(i)+xscale,ytemp(i),z-zscale)
glTexCoord2f(1,1)
glVertex3f(xtemP(i)+xscale,ytemp(i),z+zscale)
glTexCoord2f(1,0)
glVertex3f(xtemp(c)+xscale,ytemp(c),z+zscale)

p1.x = xtemp(c) - xscale
p1.y = ytemp(c)
p1.z = z - zscale

p2.x = xtemp(i) - xscale
p2.y = ytemp(i)
p2.z = z - zscale

p3.x = xtemp(i) - xscale
p3.y = ytemp(i)
p3.z = z + zscale

getnorm(p1,p2,p3)
glNormal3f(norm(0),norm(1),norm(2))

' left face

glTexCoord2f(0,0)
glVertex3f(xtemp(c)-xscale,ytemp(c),z-zscale)
glTexCoord2f(0,1)
glVertex3f(xtemp(i)-xscale,ytemp(i),z-zscale)
glTexCoord2f(1,1)
glVertex3f(xtemP(i)-xscale,ytemp(i),z+zscale)
glTexCoord2f(1,0)
glVertex3f(xtemp(c)-xscale,ytemP(c),z+zscale)

p1.x = xtemp(c) - xscale
p1.y = ytemp(c)
p1.z = z - zscale

p2.x = xtemp(c) + xscale
p2.y = ytemp(c)
p2.z = z - zscale

p3.x = xtemp(i) + xscale
p3.y = ytemp(i)
p3.z = z - zscale

getnorm(p1,p2,p3)
glNormal3f(norm(0),norm(1),norm(2))

' back

glTexCoord2f(0,0)
glVertex3f(xtemp(c)-xscale,ytemp(c),z-zscale)
glTexCoord2f(1,0)
glVertex3f(xtemp(c)+xscale,ytemp(c),z-zscale)
glTexCoord2f(1,1)
glVertex3f(xtemp(i)+xscale,ytemp(i),z-zscale)
glTexCoord2f(0,1)
glVertex3f(xtemp(i)-xscale,ytemp(i),z-zscale)

p1.x = xtemp(c) - xscale
p1.y = ytemp(c)
p1.z = z + zscale

p2.x = xtemp(c) + xscale
p2.y = ytemp(c)
p2.z = z + zscale

p3.x = xtemp(i) + xscale
p3.y = ytemp(i)
p3.z = z + zscale

getnorm(p1,p2,p3)
glNormal3f(norm(0),norm(1),norm(2))

' front

glTexCoord2f(0,0)
glVertex3f(xtemp(c)-xscale,ytemp(c),z+zscale)
glTexCoord2f(1,0)
glVertex3f(xtemp(c)+xscale,ytemp(c),z+zscale)
glTexCoord2f(1,1)
glVertex3f(xtemp(i)+xscale,ytemp(i),z+zscale)
glTexCoord2f(0,1)
glVertex3f(xtemp(i)-xscale,ytemp(i),z+zscale)

glEnd()

return

bulk3:

glBindTexture(GL_TEXTURE_2D, texture(0))

glBegin(GL_QUADS)

p1.x = xtemp(c) + xscale
p1.y = ytemp(c)
p1.z = ztemp(c) - zscale

p2.x = x3d1 + xscale
p2.y = y3d1
p2.z = z3d1 - zscale

p3.x = x3d1 + xscale
p3.y = y3d1
p3.z = z3d1 + zscale

getnorm(p1,p2,p3)
glNormal3f(norm(0),norm(1),norm(2))

' right face
glTexCoord2f(0,0)
glVertex3f(xtemp(c)+xscale,ytemp(c),ztemp(c)-zscale)
glTexCoord2f(1,0)
glVertex3f(x3d1+xscale,y3d1,z3d1-zscale)
glTexCoord2f(1,1)
glVertex3f(x3d1+xscale,y3d1,z3d1+zscale)
glTexCoord2f(0,1)
glVertex3f(xtemp(c)+xscale,ytemp(c),ztemp(c)+zscale)

p1.x = xtemp(c) - xscale
p1.y = ytemp(c)
p1.z = ztemp(c) - zscale

p2.x = x3d1 - xscale
p2.y = y3d1
p2.z = z3d1 - zscale

p3.x = x3d1 - xscale
p3.y = y3d1
p3.z = z3d1 + zscale

getnorm(p1,p2,p3)
glNormal3f(norm(0),norm(1),norm(2))

' left face

glTexCoord2f(0,0)
glVertex3f(xtemp(c)-xscale,ytemp(c),ztemp(c)-zscale)
glTexCoord2f(1,0)
glVertex3f(x3d1-xscale,y3d1,z3d1-zscale)
glTexCoord2f(1,1)
glVertex3f(x3d1-xscale,y3d1,z3d1+zscale)
glTexCoord2f(0,1)
glVertex3f(xtemp(c)-xscale,ytemp(c),ztemp(c)+zscale)

p1.x = xtemp(c) - xscale
p1.y = ytemp(c)
p1.z = ztemp(c) - zscale

p2.x = xtemp(c) + xscale
p2.y = ytemp(c)
p2.z = ztemp(c) - zscale

p3.x = x3d1 + xscale
p3.y = y3d1
p3.z = z3d1 - zscale

getnorm(p1,p2,p3)
glNormal3f(norm(0),norm(1),norm(2))

' back

glTexCoord2f(0,0)
glVertex3f(xtemp(c)-xscale,ytemp(c),ztemp(c)-zscale)
glTexCoord2f(1,0)
glVertex3f(xtemp(c)+xscale,ytemp(c),ztemp(c)-zscale)
glTexCoord2f(1,1)
glVertex3f(x3d1+xscale,y3d1,z3d1-zscale)
glTexCoord2f(0,1)
glVertex3f(x3d1-xscale,y3d1,z3d1-zscale)

p1.x = xtemp(c) - xscale
p1.y = ytemp(c)
p1.z = ztemp(c) + zscale

p2.x = xtemp(c) + xscale
p2.y = ytemp(c)
p2.z = ztemp(c) + zscale

p3.x = x3d1 + xscale
p3.y = y3d1
p3.z = z3d1 + zscale

getnorm(p1,p2,p3)
glNormal3f(norm(0),norm(1),norm(2))

' front

glTexCoord2f(0,0)
glVertex3f(xtemp(c)-xscale,ytemp(c),ztemp(c)+zscale)
glTexCoord2f(1,0)
glVertex3f(xtemp(c)+xscale,ytemp(c),ztemp(c)+zscale)
glTexCoord2f(1,1)
glVertex3f(x3d1+xscale,y3d1,z3d1+zscale)
glTexCoord2f(0,1)
glVertex3f(x3d1-xscale,y3d1,z3d1+zscale)

glEnd()

return

'' Load Bitmaps And Convert To Textures
function LoadGLTextures() as integer
  dim Status as integer = FALSE                     '' Status Indicator
  dim TextureImage(9) as BITMAP_RGBImageRec ptr     '' Create Storage Space For The Texture

  ' Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
' TextureImage(0) = LoadBMP(exepath + "/textures/demon.bmp")
  TextureImage(0) = LoadBMP("c:\FBFiles\textures\bark03.bmp")
  TextureImage(1) = LoadBMP("c:\FBFiles\Maps\venus.bmp")
  TextureImage(2) = LoadBMP("c:\FBFiles\Maps\earth.bmp")
  'TextureImage(3) = LoadBMP("c:\FBFiles\Maps\moon24.bmp")
  'TextureImage(4) = LoadBMP("c:\FBFiles\Maps\earth.bmp")
  'TextureImage(5) = LoadBMP("c:\FBFiles\Maps\mars.bmp")
  'TextureImage(6) = LoadBMP("c:\FBFiles\Maps\jupiter.bmp") ' also jupiter2
  'TextureImage(7) = LoadBMP("c:\FBFiles\Maps\moon24.bmp")
  'TextureImage(8) = LoadBMP("c:\FBFiles\Maps\earth.bmp")
  TextureImage(9) = LoadBMP("c:\FBFiles\Maps\pluto.bmp")
 
  for i = 0 to 9
  if TextureImage(i) then
    Status = TRUE                                   '' Set The Status To TRUE
    glGenTextures 1, @texture(i)                    '' Create The Texture
    ' Typical Texture Generation Using Data From The Bitmap
    glBindTexture GL_TEXTURE_2D, texture(i)
    glTexImage2D GL_TEXTURE_2D, 0, 3, TextureImage(i)->sizeX, TextureImage(i)->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage(i)->buffer
    glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR
    glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR
  end if

  if TextureImage(i) then                           '' If Texture Exists
    if TextureImage(i)->buffer then                 '' If Texture Image Exist
      deallocate(TextureImage(i)->buffer)           '' Free The Texture Image Memory
    end if
    deallocate(TextureImage(i))                     '' Free The Image Structure
  end if
  next
  return Status                                     '' Return The Status
end function
********************************************************
Now, How can I do this with glucylinders?



15
Freebasic / glucylinder?
« on: June 25, 2007 »
I am useing opengl.
Is there a way to plot a cylinder from one 3d point to another?
I am getting confused always trying to translatef and rotatef.
Is there an easier way?

16
Freebasic / Tree Trouble
« on: June 18, 2007 »
I am haveing trouble makeing this look like a real tree.
Can anyone help?

dim bt(126)

dim xtemp(126)
dim ytemp(126)

screen 18

screenwidth  = 640
screenheight = 480

angle = 35

mult = 1
add  = 1

bt(0) = 90

bt(index + mult + position) = bt(0) + angle
bt(index + mult + position + add) = bt(0) - angle

print bt(0)

mult = mult * 2
num2 = 2

a = 1

for j = 0 to 4

num = mult - 1

for i = num to num2

if i <  mult then position = 0
if i >= mult then position = position + 1

bt(i + mult + position) = bt(a) + angle
bt(i + mult + position + add) = bt(a) - angle

print bt(i);" ";

a = a + 1

next i

print

old = old + mult
mult = mult * 2

num2 = old + mult

next j

print

gosub render

sleep

end

render:

a = 1
b = 2
c = 0

mult1 = 2
mult2 = 4

pi# = 3.1415926

x1 = screenwidth / 2
y1 = screenheight

lenght = screenheight / 4

xtemp(0) = x1 + -cos(bt(0) * pi# / 180) * lenght
ytemp(0) = y1 + -sin(bt(0) * pi# / 180) * lenght

line(x1,y1)-(xtemp(0),ytemp(0)),15

for j = 0 to 4

lenght = lenght / 1.4

for i = a to b

if j > 0 and d = 0 then c = c + 1

xtemp(i) = xtemp(c) + -cos(bt(i) * pi# / 180) * lenght
ytemp(i) = ytemp(c) + -sin(bt(i) * pi# / 180) * lenght

line(xtemp(c),ytemp(c))-(xtemp(i),ytemp(i)),15

d = d + 1
if d = 2 then d = 0

next i

if j > 0 then mult1 = mult1 * 2
if j > 0 then mult2 = mult2 * 2

a = a + mult1
b = b + mult2

next j

return



17
Freebasic / 3D-Bounding Box Collision-detection?
« on: January 26, 2007 »
O.k. I have this city where each building is only a
3D-Box.

Would anyone know how I could do collision-detection
on 3D-Box?

That is a 3D-Bounding Box collision-detection.
So I will not (won't) be able to walk right through a building.

Some code would be useful.
Please help me if you can.
Thanks
 

18
Freebasic / New Game Ideas
« on: January 16, 2007 »
Recently I've been working on a new game for freebasic.
It uses opengl for graphics.
Though I don't know everything about opengl in freebasic
I am still trying to develope a game.

The premise for the game is...
You control a 3D-Ball through a maze with the mouse by tilting the game board.

I don't got much right now because I've been working on the collision detection mostly.

Some of the ideas I've got for this game are...

Other balls in the maze that try to smack you around.
Holes that you fall through.
Power-up's to somehow give you energy.
Game within a skybox.
Flags that you have to reach as checkpoints.

That about all I can think of.
So I've left this post so anyone can post a reply to let me know other
things that I might be able to add to it or subtract from it.
I would like to hear some new ideas and thoughts from other people.
Feedback on what they think.

Thanks
And have a great day!

19
Freebasic / Collision Detection?
« on: January 11, 2007 »
I'm createing a program where you
control a ball through a maze and avoid the traps.

It's 3D
I thought create an array that show where walls are
and map that to screen position and cells within array.

I left a post and someone said in onpengl you could do it
faster by setting material flag and then create a function that
returns material.id does anyone know how do this?

Is it a better way,faster?

I don't know a whole world about opengl so if anyone could
help me it would be nice.
Thanks

20
Freebasic / glAccum?
« on: January 07, 2007 »
I can't seem to find no tutorials on OpenGL Accum buffer.
I heard it can be use for things like motion blur, anti-aliasing ect...
Can someone please show me the basics of it?
I have a fireworks demo that is slowed down because the
motion blur is done by remembering points but it could be
speeded up with OpenGL's Accum buffer if only I knew how to
use it.
So could someone please teach me about it?
please

Pages: [1] 2