Recent posts

#11
OxygenBasic Examples / Barnsley fern fractal to gener...
Last post by Theo Gottwald - April 13, 2024, 09:32:30 AM
Here's an example program that uses the Barnsley fern fractal to generate a 3D model of a fern leaf. The Barnsley fern is a fractal that is generated using an iterated function system (IFS), which is a set of affine transformations that are applied repeatedly to generate a complex shape.

' Barnsley Fern Fractal in 3D
' Oxygen Basic, ConsoleG, OpenGL

#compact
%filename "barnsley_fern.exe"
'uses RTL64
% Title "Barnsley Fern Fractal in 3D"

'% WindowStyle WS_OVERLAPPEDWINDOW
'% Animated
'% ScaleUp
% PlaceCentral
% AnchorCentral

% shaders

uses consoleG

BeginScript

const int MAX_ITER = 100000
const int MAX_POINTS = 10000

struct Point {
    float x, y, z;
};

Point points[MAX_POINTS];
int numPoints = 0;

procedure applyTransform(Point *p, float a, float b, float c, float d, float e, float f) {
    float x = p->x;
    float y = p->y;
    float z = p->z;
    p->x = a*x + b*y + c*z + d;
    p->y = e*x + f*y + z + 1;
}

procedure drawFern() {
    if (numPoints <= 0) {
        return;
    }

    glBegin(GL_LINES);
    for (int i = 0; i < numPoints-1; i++) {
        glVertex3f(points[i].x, points[i].y, points[i].z);
        glVertex3f(points[i+1].x, points[i+1].y, points[i+1].z);
    }
    glEnd();
}

procedure generateFern() {
    Point p;
    p.x = 0;
    p.y = 0;
    p.z = 0;

    for (int i = 0; i < MAX_ITER; i++) {
        int transform = int(rnd*100);
        if (transform < 1) {
            applyTransform(&p, 0, 0, 0, 0, 0, 0.16);
        } else if (transform < 8) {
            applyTransform(&p, 0.85, 0.04, -0.04, 0, -0.85, 1.6);
        } else if (transform < 15) {
            applyTransform(&p, 0.2, -0.26, 0.23, 0, 0.22, 1.6);
        } else if (transform < 85) {
            applyTransform(&p, -0.15, 0.28, 0.26, 0, 0.24, 0.44);
        } else {
            applyTransform(&p, 0, 0, 0, 0, 0, 1.6);
        }

        if (numPoints < MAX_POINTS) {
            points[numPoints++] = p;
        }
    }
}

procedure main() {
    cls();
    shading();

    generateFern();

    while (not key[KB_ESC]) {
        drawFern();
        wait(0.01);
    }
}

EndScript
```
In this program, we define a `Point` struct to represent a 3D point in space. We also define a `MAX_ITER` constant to control the number of iterations used to generate the fern, and a `MAX_POINTS` constant to limit the number of points stored in memory.

The `applyTransform` procedure takes a `Point` pointer and six coefficients that define an affine transformation, and applies the transformation to the point. The `drawFern` procedure draws lines between adjacent points in the `points` array to create the 3D model of the fern.

The `generateFern` procedure generates the Barnsley fern fractal by repeatedly applying a set of four affine transformations to an initial point, and storing the resulting points in the `points` array. The probability of each transformation being applied is controlled by a random number generator.

Finally, the `main` procedure generates the fern using `generateFern`, and then enters a loop that repeatedly calls `drawFern` to display the 3D model of the fern. The loop continues until the user presses the Escape key.

When you run this program, you should see a 3D model of a fern leaf that is generated using the Barnsley fern fractal. You can experiment with different coefficients and probabilities for the affine transformations to create different variations of the fern.
#12
OxygenBasic Examples / Re: House: creating lines cube...
Last post by Theo Gottwald - April 13, 2024, 09:29:25 AM
To draw a more complex building, we can use a combination of simple shapes and more detailed modeling techniques. Here's an example of how you could extend the code to draw a more complex building:

In this example, we've added several new features to the building:

* A base platform for the building to sit on.
* Walls that are drawn as quadrilaterals and textured with a brick-like pattern.
* A roof made up of two triangles.
* Windows represented by small cubes.
* Doors represented by quads with a different color.
* Balconies represented by quads with a different color and position.
* An antenna represented by a cylinder.

We've also added some additional loops and transformations to position and orient the various parts of the building correctly.


' complex building part one, 12-04-2024
' oxygen basic, consoleG, openGL, frank bruebach
'
#compact
%filename "t.exe"
'uses RTL64
% Title "Complex Building: Create Points and Lines Demo"

'% WindowStyle WS_OVERLAPPEDWINDOW
'% Animated
'% ScaleUp
% PlaceCentral
% AnchorCentral

% shaders

uses consoleG

'Keys: Esc, arrow-keys, n,m, F4

BeginScript

procedure main
================

'WaitForEvent '0 off 1 on (default on)
static quad t1,t2

if opening then 'FIRST CALL ONLY
    'picked=100
    'mbox "helo"
end if

if closing then 'FINAL CALL BEFORE SHUTDOWN
    'mbox "Bye!"
    exit sub
end if

cls 0,.4,0
shading

'CREATE POINTS
if opening
    %n 100
    static MoveableObject mu[n]
    '#recordof a
    scope
        int i=n
        int k=100
        for i=1 to n
            mu[i].mode=0x101
            k+=100
            mu[i].id=k
        next
    end scope
end if

scale 1
int i, j
thickness 3

' DRAW BUILDING BASE
pushstate
color .9,.9,.9,1
glbegin GL_QUADS
glVertex3f -50, 0, 50
glVertex3f 50, 0, 50
glVertex3f 50, 0, -50
glVertex3f -50, 0, -50
glend
popstate

' DRAW BUILDING WALLS
for i=1 to 4
    pushstate
    rotate i*90, 0, 1, 0
    translate 0, 0, 25
    color .9,.5,0,1
    glbegin GL_QUADS
    glVertex3f -50, 0, 50
    glVertex3f 50, 0, 50
    glVertex3f 50, 100, 50
    glVertex3f -50, 100, 50
    glend
    popstate
next

' DRAW BUILDING ROOF
pushstate
translate 0, 100, 0
color .5,.5,.5,1
glbegin GL_TRIANGLES
glVertex3f -50, 0, 50
glVertex3f 50, 0, 50
glVertex3f 0, 50, 0
glVertex3f -50, 0, -50
glVertex3f 50, 0, -50
glVertex3f 0, 50, 0
glend
popstate

' DRAW BUILDING WINDOWS
for i=1 to 20
    pushstate
    translate mu[i].x, mu[i].y, 0
    if mu[i].x + mu[i].y = 0 then
        color .2,.2,.2,1
    else
        color .9,.9,.9,1
    endif
    scale 0.5
    go cube
    popstate
next

' DRAW BUILDING DOORS
for i=1 to 4
    pushstate
    translate (i-2.5)*20, 0, 25
    rotate 90, 0, 1, 0
    color .5,.2,.2,1
    glbegin GL_QUADS
    glVertex3f -5, 0, 10
    glVertex3f 5, 0, 10
    glVertex3f 5, 50, 10
    glVertex3f -5, 50,
```
10
glend
popstate
next

' DRAW BUILDING BALCONIES
for i=1 to 4
pushstate
translate (i-2.5)\*20, 75, 25
rotate 90, 0, 1, 0
color .5,.5,.5,1
glbegin GL\_QUADS
glVertex3f -10, 0, 10
glVertex3f 10, 0, 10
glVertex3f 10, 10, 10
glVertex3f -10, 10, 10
glend
popstate
next

' DRAW BUILDING ANTENNA
pushstate
translate 0, 150, 0
color .2,.2,.2,1
cylinder 1, 50, 32
popstate

flat
for i=1 to 20
j=i+1
if mu[i].x + mu[i].y <> 0
if mu[j].x + mu[j].y <> 0
'DRAW LINE BETWEEN POINTS
'INCLUDE D.X D.Y MOUSE DRAG
glbegin GL\_LINES
glVertex3f mu[i].x+mu[i].d.x, mu[i].y+mu[i].d.y, 0
glVertex3f mu[j].x+mu[j].d.x, mu[j].y+mu[j].d.y, 0
glend
endif
endif
next

shading
picklabel 0

move 5,0

'if not pick then
if key[49] then picked=100 'keypress '1'
if key[50] then picked=200 'kypress '2'
pushstate
move -20,12
static sys tally
timemark t2
scale 1.0
'
macro pr(a,b) 'PRINTING LIST
----------------------------
pushstate : color .5,1,1 : print a : popstate
pushstate : color 1,1,.5 : move 8 : print b : popstate
printl ""
end macro
picklabel 10
pr "Picked ID: ", str(picked)
pr "Keyboard Code: ", str(keyd)
picklabel 0
popstate
'end if

cls .1, .4, 0
shading

'------------------- complex building with simple lines and shapes ------- //

' Clear the screen with a green color
cls .1, .4, 0
shading

scale 2
int i
thickness 2
move 0, 0
scale 3

' DRAW BUILDING BASE
pushstate
color .9, .9, .9, 1
glbegin GL\_QUADS
glVertex3f -50, 0, 50
glVertex3f 50, 0, 50
glVertex3f 50, 0, -50
glVertex3f -50, 0, -50
glend
popstate

' DRAW BUILDING WALLS
for i=1 to 4
pushstate
rotate i\*90, 0, 1, 0
translate 0, 0, 25
color .9,.5,0,1
glbegin GL\_QUADS
glVertex3f -50, 0, 50
glVertex3f 50, 0, 50
glVertex3f 50, 100, 50
glVertex3f -50, 100, 50
glend
popstate
next

' DRAW BUILDING ROOF
pushstate
translate 0, 100, 0
color .5,.5,.5,1
glbegin GL\_TRIANGLES
glVertex3f -50, 0, 50
glVertex3f 50, 0, 50
glVertex3f 0, 50, 0
glVertex3f -50, 0, -50
glVertex3f 50, 0, -50
glVertex3f 0, 50, 0
glend
popstate

' DRAW BUILDING WINDOWS
for i=1 to 20
pushstate
translate mu[i].x, mu[i].y, 0
```
if mu[i].x + mu[i].y = 0 then
    color .2,.2,.2,1
else
    color .9,.9,.9,1
endif
scale 0.5
go cube
popstate
next

' DRAW BUILDING DOORS
for i=1 to 4
pushstate
translate (i-2.5)\*20, 0, 25
rotate 90, 0, 1, 0
color .5,.2,.2,1
glbegin GL\_QUADS
glVertex3f -5, 0, 10
glVertex3f 5, 0, 10
glVertex3f 5, 50, 10
glVertex3f -5, 50, 10
glend
popstate
next

' DRAW BUILDING BALCONIES
for i=1 to 4
pushstate
translate (i-2.5)\*20, 75, 25
rotate 90, 0, 1, 0
color .5,.5,.5,1
glbegin GL\_QUADS
glVertex3f -10, 0, 10
glVertex3f 10, 0, 10
glVertex3f 10, 10, 10
glVertex3f -10, 10, 10
glend
popstate
next

' DRAW BUILDING ANTENNA
pushstate
translate 0, 150, 0
color .2,.2,.2,1
cylinder 1, 50, 32
popstate

end procedure 'main

EndScript

#13
OxygenBasic Examples / Re: House: creating lines cube...
Last post by Frank Brübach - April 12, 2024, 08:09:11 PM
Good evening

Made a little church building only with gl_lines
It's only a Demo Not more 

Charles do you think its possible to create such a building with the Setup of creating lines in this Demo or do you have a Code snippet?
I know already to build a House Like my example before or a House with cubes but how to start a new Second or third House building with If opening... Begin ?

Thanks Frank

  ' church building part one, 12-04-2024
  ' oxygen basic, consoleG, openGL, frank bruebach
  '
  #compact
  %filename "t.exe"
 'uses RTL64
  % Title "Church: Create Points and Lines Demo"
  '% Title "ConsoleG Demo:  Move text with mouse and arrow keys etc"

 '% WindowStyle WS_OVERLAPPEDWINDOW
 '% Animated
 '% ScaleUp
  % PlaceCentral
  % AnchorCentral

  % shaders

  uses consoleG
 
  'Keys: Esc, arrow-keys, n,m, F4

  BeginScript

  procedure main
  ==============

  'WaitForEvent '0 off 1 on (default on)
  static quad t1,t2

  if opening then 'FIRST CALL ONLY
    'picked=100
    'mbox "helo"
  end if
  '
  if closing then 'FINAL CALL BEFORE SHUTDOWN
    'mbox "Bye!"
    exit sub
  end if
  cls 0,.4,0
  shading
  'CREATE POINTS
  if opening
    %n 100
    static MoveableObject mu[n]
    '#recordof a
    scope
      int i=n
      int k=100
      for i=1 to n
        mu[i].mode=0x101
        k+=100
        mu[i].id=k
      next
    end scope
  endif
  scale 1
  int i, j
  thickness 3
  for i=1 to 20
    pushstate
    mu[i].act 'FIXES LOCATION
    if mu[i].x + mu[i].y = 0
      color .9,.9,.9,1
    else
      color .9,.5,0,1
    endif
    scale 0.5
    go cube 'sphere
    popstate
  next
  '
  flat
  for i=1 to 20
    j=i+1
    if mu[i].x + mu[i].y <> 0
      if mu[j].x + mu[j].y <> 0
        'DRAW LINE BETWEEN POINTS
        'INCLUDE D.X D.Y MOUSE DRAG
        glbegin GL_LINES
        glVertex3f mu[i].x+mu[i].d.x, mu[i].y+mu[i].d.y, 0
        glVertex3f mu[j].x+mu[j].d.x, mu[j].y+mu[j].d.y, 0
        glend
      endif
    endif
  next
  shading
  picklabel 0

  move 5,0

  'if not pick then
    if key[49] then picked=100 'keypress '1'
    if key[50] then picked=200 'kypress  '2'
    pushstate
    move -20,12
    static sys tally
    timemark t2
    scale 1.0
    '
    macro pr(a,b) 'PRINTING LIST
    ----------------------------
      pushstate : color .5,1,1 : print a : popstate
      pushstate : color 1,1,.5 : move 8 : print b : popstate
      printl ""
    end macro
    picklabel 10
  'pr "Action Code:  ", str(act)
  'pr "indexbase      ", str(indexbase)
    pr "Picked ID:    ", str(picked)
    pr "Keyboard Code: ", str(keyd)
    picklabel 0
    popstate
  'end if

' Clear the screen with a green color
cls .1, .4, 0
shading

'------------------- house like church with simple lines ------- //

' Clear the screen with a green color
cls .1, .4, 0
shading

scale 2
int i
thickness 2
move 0, 0
scale 3

gllineWidth 8
' Draw the main church building
color .9, .5, 0, 1
glbegin GL_LINES
' Front side of the church
glvertex3f -1, -1, 0
glvertex3f 1, -1, 0
glvertex3f -1, -1, 0
glvertex3f -1, 1, 0
glvertex3f 1, -1, 0
glvertex3f 1, 1, 0
glvertex3f -1, 1, 0
glvertex3f 1, 1, 0

' Roof of the church
glvertex3f -1, 1, 0
glvertex3f 0, 2, 0
glvertex3f 1, 1, 0
glvertex3f 0, 2, 0


' Door
glvertex3f -0.3, -1, 0
glvertex3f -0.3, 0.5, 0
glvertex3f 0.3, -1, 0
glvertex3f 0.3, 0.5, 0

glvertex3f -0.3, 0.1, 0
glvertex3f 0.3, 0.1, 0
glend

' Draw windows on the church
'color 1, 1, 1, 1
color 0.5, 0.21, 1, 1
glbegin GL_LINES
' First window
glvertex3f -0.6, 0, 0
glvertex3f -0.4, 0, 0
glvertex3f -0.5, 0.2, 0
glvertex3f -0.5, -0.2, 0
' Second window
glvertex3f 0.4, 0, 0
glvertex3f 0.6, 0, 0
glvertex3f 0.5, 0.2, 0
glvertex3f 0.5, -0.2, 0
glend

' Draw the second building beside the church
color .6, .3, 0, 1
glbegin GL_LINES
' Front side of the second building
glvertex3f 1.2, -1, 0
glvertex3f 2.2, -1, 0
glvertex3f 1.2, -1, 0
glvertex3f 1.2, 1, 0
glvertex3f 2.2, -1, 0
glvertex3f 2.2, 1, 0
glvertex3f 1.2, 1, 0
glvertex3f 2.2, 1, 0

' Roof of the second building
glvertex3f 1.2, 1, 0
glvertex3f 1.7, 2, 0
glvertex3f 2.2, 1, 0
glvertex3f 1.7, 2, 0

' Draw windows on the second building
color 0.2, 0.31, 1, 1
glbegin GL_LINES
glvertex3f 1.35, 0.5, 0
glvertex3f 1.45, 0.5, 0
glvertex3f 1.35, 0, 0
glvertex3f 1.45, 0, 0
glvertex3f 1.55, 0.5, 0
glvertex3f 1.65, 0.5, 0
glvertex3f 1.55, 0, 0
glvertex3f 1.65, 0, 0
glend

' Draw the garage on the left side
color .4, .4, .4, 1
glbegin GL_LINES
' Front side of the garage
glvertex3f -2, -1, 0
glvertex3f -1.2, -1, 0
glvertex3f -2, -1, 0
glvertex3f -2, 1, 0
glvertex3f -1.2, -1, 0
glvertex3f -1.2, 1, 0
glvertex3f -2, 1, 0
glvertex3f -1.2, 1, 0
glend

  end procedure 'main

  EndScript
#14
OxygenBasic Examples / Re: House: Creating lines cube...
Last post by Frank Brübach - April 10, 2024, 07:51:01 PM
House: Here's a little example how to build a House shape with seven Points .. some month ago I have built several examples with House buildings ..

In this example the Last Point closes to the Fürst Point

This however IS a new one and more simple the complex structures will still come

ConsoleG ( openGl)

  ' 10-04-24, create a house with 7 points
  ' oxgen basic, consoleG, openGL, by frank bruebach
  '
  #compact
  %filename "t.exe"
 'uses RTL64
  % Title "House: Create Points and Lines Demo"
  '% Title "ConsoleG Demo:  Move text with mouse and arrow keys etc"

 '% WindowStyle WS_OVERLAPPEDWINDOW
 '% Animated
 '% ScaleUp
  % PlaceCentral
  % AnchorCentral

  % shaders

  uses consoleG
 
  'Keys: Esc, arrow-keys, n,m, F4

  BeginScript

  procedure main
  ==============

  'WaitForEvent '0 off 1 on (default on)
  static quad t1,t2

  if opening then 'FIRST CALL ONLY
    'picked=100
    'mbox "helo"
  end if
  '
  if closing then 'FINAL CALL BEFORE SHUTDOWN
    'mbox "Bye!"
    exit sub
  end if
  cls 0,.4,0
  shading


' CREATE POINTS
if opening
  %n 100
  static MoveableObject mu[n]

  scope
    int i=n
    int k=100
    for i=1 to n
      mu[i].mode=0x101
      k+=100
      mu[i].id=k
    next
  end scope
endif

scale 1
int i, j
thickness 3
move -4,-4

'WaitForEvent '0 off 1 on (default on)
static quad t1,t2

if opening then 'FIRST CALL ONLY
  'picked=100
  'mbox "hello"
end if
'
if closing then 'FINAL CALL BEFORE SHUTDOWN
  'mbox "Bye!"
  exit sub
end if

' Clear the screen with a greenish color
cls 0,.4,0
shading

' CREATE POINTS
if opening
  %n 100
  static MoveableObject mu[n]

  scope
    int i=n
    int k=100
    for i=1 to n
      mu[i].mode=0x101
      k+=100
      mu[i].id=k
    next
  end scope
endif

scale 1
int i, j
thickness 3
move -2,-2

' Draw 7 cubes (houses) with different colors
for i=1 to 7
  pushstate
  mu[i].act ' FIXES LOCATION
  if mu[i].x + mu[i].y = 0 then
    color .9,.9,.9,1
  else
    color .85,.25,0,1 ' color .9,.5,0,1
  endif
  scale 0.5,0.5
  go cube ' sphere
  popstate
next

' Draw lines between points to form house outlines
flat
glbegin GL_LINE_LOOP ' Draw lines to form closed plane face
for i=1 to 20
  if mu[i].x + mu[i].y <> 0 then
    ' DRAW LINE BETWEEN POINTS
    ' INCLUDE D.X D.Y MOUSE DRAG
    glVertex3f mu[i].x+mu[i].d.x, mu[i].y+mu[i].d.y, 0
  endif
next
glend

shading
picklabel 0
move 5,0


' Print information about the picked object and keyboard input
if key[49] then picked=100 ' keypress '1'
if key[50] then picked=200 ' keypress '2'
pushstate
move -20,12
static sys tally
timemark t2
scale 1.0


macro pr(a,b) ' PRINTING LIST
---------------------------
  pushstate : color .5,1,1 : print a : popstate
  pushstate : color 1,1,.5 : move 8 : print b : popstate
  printl ""
end macro

picklabel 10
' pr "Action Code: ", str(act)
' pr "indexbase ", str(indexbase)
pr "Picked ID: ", str(picked)
pr "Keyboard Code: ", str(keyd)
picklabel 0
popstate


  end procedure 'main

  EndScript
#15
OxygenBasic Examples / House: creating lines cubes et...
Last post by Frank Brübach - April 10, 2024, 05:33:50 PM
Update will come :)
#16
General Discussion / James Webb Telescope PROVED Us...
Last post by Charles Pegge - April 09, 2024, 10:28:21 AM
Michio Kaku: "Time Does NOT EXIST! James Webb Telescope PROVED Us Wrong!"

Space Voyager
31 mar 2024

#17
OxygenBasic Examples / Re: OpenGl Grid Inputs
Last post by Frank Brübach - April 07, 2024, 08:39:23 PM
Hello theo.. you have sent the Code of AI Claude AS you mentioned already and its in my eyes Not so good for using this example cause a Lot of Errors occured and you must adept twice. I supposed you must give detailed Infos about Code language to the AI to get a useful reply.

Myself I took and asked Chat gtp two month ago for help to translate a french Song to German and that was OK but Same Problem I must correct IT too. Mistral I didnt know. And I didnt want to use IT. I am learning more about programming by doing mistakes and I am Not a Professional programmer so I dont have Higher skills to adept IT all for my favourite Basic language or other Software package. For some Users it May be a benefit to ASK an AI for Help or learning a new Basic language or quite other daily Things  but I have much more a distant and critical view at These intelligent Machines ;)
#18
Hi Charles
I am not any kind of academic or i have such a educations
BUT i like Sabine and like to watch her youtube videos. :)
#19
General Discussion / A Tour of Earth's Ancient Sup...
Last post by Charles Pegge - April 07, 2024, 10:17:19 AM
History of the Earth
26 jun 2021


#20
OxygenBasic Examples / Re: OpenGl Grid Inputs
Last post by Theo Gottwald - April 07, 2024, 07:52:40 AM
Hallo Frank, which #AI?

Lastly people found that AMAZON's AI consists of 2500 poor Indians in a Call-Center Room answering silly questions as good as they an.

So don't talk generally about #AI tell us which one.
Did you Try #Mistral?