QB64.org Forum

Active Forums => Programs => Topic started by: Qwerkey on December 10, 2019, 09:44:13 am

Title: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Qwerkey on December 10, 2019, 09:44:13 am
This is a program which demonstrates the amazing graphics capabilities of QB64, using simple coding techniques and without resorting to the complexities of Open_GL.  Impressive 3D effects can be obtained using the QB64 _MAPTRIANGLE statement: the 3D _MAPTRIANGLE method gives a convincing 3D display along with perspective.

The program features a number of animations (some 2D and some 3D) enhanced with accompanying audio.  In order to run this program you will need to download the zip file from the URL.  Extract the folder "pi in the sky" and place that folder in your QB64 folder – be careful not to create and extra folder layer.  Load the "pi in the sky" bas file and run (QB64v2 or higher).  You will need to have the Run Option "Output EXE to Source Folder" checked.  The program uses quite a bit of processor power (up to nearly 2 CPU's-worth at times on my Core i5 machine) and a lot of memory, so you'll need a modern machine.  At program start there is a delay while the disk files are read and loaded into memory (and there are image manipulations being carried out).

The display shows a landscape within which a variety of animations will occur.  It takes approximately 10 mins to run through all of the animation sequences.  There are earthly animations and celestial animations.  During the celestial animations, there are ghostly appearances in the terrestrial graveyard and related sounds.

In the blue text I give details of the program coding methods, descriptions of the animations and background information.  You do not need to read the blue text to run and enjoy (well, maybe!) the program.

Download:
https://www.dropbox.com/s/goekmtjtmt0n7m1/pi%20in%20the%20sky.zip?dl=1 (https://www.dropbox.com/s/goekmtjtmt0n7m1/pi%20in%20the%20sky.zip?dl=1)

I started this project purely because the phrase "pi in the sky" popped into my head, and so started coding to produce a pi symbol randomly rotating about three axes in 3D.  The obvious QB64 method is _MAPTRIANGLE(3D).  All you have to do is plug in the mathematics of rotations of a rectangle about the three Cartesian co-ordinates and place the resulting corner positions into _MAPTRIANGLE(3D).  The surface of the image is everywhere flat, but its corners move freely in the 3D space of _MAPTRIANGLE(3D), and as (vanishing point) perspective is coded into the _MAPTRIANGLE(3D) method, a very good-looking 3D display is produced.  I must emphasise that this QB64 method is so well produced that it can be used by novice and low-skill coders.  In the Skill Range Venn Diagram, I sit in the low-skill sector, and I cannot do the real-3D (SUB _GL) stuff of our competent members.

To do this project I have had to go back to school-level calculus, geometry & algebra; oh, happy days!  Having got the pi animation working, I then set about adding other features to demonstrate what can done with QB64 graphics.  The final project uses both software and hardware imaging, and for the hardware images both _MAPTRIANGLE(2D) and _MAPTRIANGLE(3D).  The program is designed to show how such images will interact.  The program also uses a load of _MEM object processing in order to manipulate images, both at initiation and on-the-fly in real time.

Background Image
The graphical animations take place in front of a background image.  This background (a landscape with added features) is software (,32 type image) and has a single _PUTIMAGE directly after creating the 32-bit screen.  This image stays displayed despite the running loop executing a _DISPLAY at each cycle (30 fps).  All other images are hardware (,33 type) and are placed in front of the background (naturally!).

pi Animation
In order to change colour as the pi moves around, real-time editing of the image file is required.  This is achieved by _MEM object manipulation at each display cycle.  _MEM processing can only be achieved with software images, whereas the pi image is hardware.  So, firstly a software image is created at initiation and a _MEM object of the software image is taken.  Then at each cycle that object is manipulated and the software image is copied to hardware and that image is displayed.  The hardware image is freed each cycle at the earliest opportunity.  This method is repeated for all other real-time image manipulations.

Earthly and Celestial Animations
There are both earth-bound and celestial animations.  The earth-bound animations (along with clouds and some rain) are continuous, whereas the celestial animations cycle in a random manner.

Earthly Animations

Beehive
Bees emerge and swarm from a suspended beehive in the foreground.  The bees fly in the 3D space of _MAPTRIANGLE(3D) and both the hive and the bee images (QB64 bee logo) are hardware (3D: ,33 image type).  After emerging in an outward direction the bees turn and fly in the opposite direction away from the viewer "into" the screen.  Bees in front of the hive occlude it, and behind the hive they are occluded by it.  As the hive image is a flat object, a bee moving from directly in front of to directly behind the hive travels right through it.  The bees all appear to move to the right as they move away, but this is just the perspective.  All the bees return to the hive after their flight out.  In order to achieve such paths, the bees are flying in parabolic curves in the 3D space.  There is the sound of humming bees, the more bees that are out the louder they sound.

Fountain
A fountain squirts droplets of water into the pond.  There are 500 droplets of water each moving under gravity in the _MAPTRIANGLE(3D) space.  Although as many droplets are sent behind the fountain as in the front, it looks as if they only fall at the front.  This is just an artefact of the perspective.

Windmill
The moving windmill sails clearly show the 3D and perspective effects  of _MAPTRIANGLE(3D).  The sails appear to move in and out as they rotate and are smaller the further away they are.  As the bees, fountain droplets and windmill sails are _MAPTRIANGLE(3D) images, they occlude each other dependent upon which is further away.  The windmill itself is not a 3D object but part of the software background.  The industrious Miller Heitor looks out from the windmill.

Clouds and Rain
Clouds pass above.  They are slightly transparent so that objects behind can still be seen.  One of the clouds is rain-bearing and a shower of 500 raindrops passes along.  The clouds and raindrops are not 3D, and occlusions occur based upon order in which the _PUTIMAGE functions occur.

Flower Growth
As the rain passes, flowers can spring up in the earth.  Flower images are 2D.

Rainbow
When the rain is in just the right place, a rainbow appears.  The rainbow is a _MAPTRIANGLE(3D) image and occlusions with other such objects are dependent upon distance into the screen.

Graveyard
Ghostly images appear in the graveyard when certain celestial events take place.  The gravestones themselves are part of the background 2D image.

Celestial Animations
At times, celestial animations occur.  When a celestial animation takes place, there are accompanying ghostly images in the graveyard.  There is accompanying related audio.

Concorde
Fly-past of a supersonic passenger aircraft.  The Concorde image is 2D.  The aircraft creates a sonic boom.  A ghostly image of Douglas Bader appears in the graveyard.  Eventually the graveyard image gradually disappears into thin air.  This graphic effect is achieved, again, by _MEM object real-time processing (in this case changing alpha sequentially).  Images here are 2D.

ET
A silhouette from a well-known science fiction film travels across the sky.  The image is 2D.  A ghostly film director appears in the graveyard.

Star Trek
The spacecraft from a well-known science-fiction television series moves through the _MAPTRIANGLE(3D) space coming from the far distance.  Members of the crew appear in the graveyard.  Because the graveyard images are small and transparent, it is rather difficult to recognise who they are.  From left to right they are McCoy, Uhura, Kirk, Sulu and Spock.

ISS
The 2D International Space Station passes overhead.  The sound is that of Sputnik 1.  Cosmonaut Yuri Gagarin appears in the graveyard.

Meteors
A 3D meteor shower occurs while Galileo looks on from the grave.

Transit
A transit of Venus occurs.  This is a very rare event, the last occurring in 2012 and the next due in 2117, so we are very privileged.  The goddess appears in the graveyard.  She is The Bringer of Peace and has her appropriate accompanying music.

Thunderbirds
A bomb falls onto the windmill.  Call for action from a well-known science-fiction television series.  Help arrives and the bomb is safely removed.  All images are 2D.  The graveyard crew are Alan, Scott, Virgil, Gordon and John.

Zodiac
The signs of the Zodiac circle in the heavens.  The image is the surface of an open-ended cylinder.  This is the only non-flat 3D image in this program, and the real-3D effect requires multiple _MAPTRIANGLE(3D) processes.  The Zodiac sign at the front is brightened, and this effect is, again, produced by real-time _MEM processing.  Zodiac symbols of the prominent sign appear in the graveyard.  The music is appropriately mystical.
For you I see a romantic liaison with a coach party of ageing workers from the shoe-making industry.  Astrology – what a load of old cobblers!

UFO
An alien spacecraft arrives and settles for a moment, and after probing the environment it lifts off and flies away.  The image is _MAPTRIANGLE(3D) and occlusions with the windmill sails are correct.  In order to make the landing, the spacecraft follows a helical path (circular x-, z- path and linear y- path).  The arrival of this alien craft arouses the interest of two FBI special agents.  As the craft probes the ground, the little green man appears in the graveyard.

Spotlight
A spotlight illuminates the sky and reveals a pertinent message.  The spotlight image is only 2D, and would have been better as 3D but is done this way to show the limitations.  Again, _MEM processing is required to make the message image respond to the spotlight.  The graveyard shows how this program was produced.


Discussion
This has been a tinkering project.  As ideas came, I'd change to new areas of coding and then return to unfinished parts.  This is a bad method to do projects.  Returning to old parts, you don't quite remember exactly what you previously did and end up making mistakes and taking a great deal of time.  The project could still benefit from further improvements/changes and the tinkering could go on for ever (certainly some of the animations are rather naff, if not great fun for the coder).  But I leave it as is so  as to demonstrate where 2D imaging is not good enough to show completely correct perspective/occlusion.


 



Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: OldMoses on December 10, 2019, 11:33:19 am
Amazing is the right word. It's been a long hard pull for me to get my head around graphics programming, but QB64 has fielded everything I've tried so far.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: bplus on December 10, 2019, 12:39:28 pm
Wow Qwerkey, that's some graphics show! A ten on the whimsical scale!
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: SierraKen on December 10, 2019, 01:26:15 pm
Incredible job Qwerkey! Fun to watch and listen too. Someone could make some incredible games with this kind of stuff.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: johnno56 on December 12, 2019, 07:22:19 am
One slight flaw in a brilliant display was... The Starship Enterprise appears and so does a collection of Federation officers... The glitch is: The Enterprise is a Constellation Class Starship from the 'original' TV series and the uniforms, of the officers, were worn on the Galaxy Class Starship, featured on Next Generation....
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Qwerkey on December 12, 2019, 07:38:53 am
Thanks guys, for your positive appraisals.  You may imagine that this project was a huge amount of fun.  Oh, Johnno, very much amused!  The one feature of this project is its complete departure from reality.  Actually, you'll be surprised that I have never seen Star Trek, but was aware of the existence on British TV of the first series.  In collecting images for the program I had to do a lot of googling, of course, and was completely unaware of what was what.  I'm glad, at least, that the crew (incorrectly dressed!) belonged on the right craft.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: johnno56 on December 14, 2019, 05:50:58 am
Oh, I'm not too surprised. After all, not everyone can be a Star Trek nerd, like myself... lol  But, seriously, a REALLY good effort on your part... Well done!
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Ashish on December 14, 2019, 11:03:05 pm
Beautiful and very detailed. I like it very much.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: bplus on April 06, 2020, 01:42:53 pm
As Qwerkey just pointed out to me today, Pi-in-the-sky is not loading all the images for QB64 v 1.4 so here is my copy compiled in v1.3 for Windows:

You will still need all the assets from his download link.

BTW @Qwerkey how did you get Pi Image and Flying Saucer Image in different colors?
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Pete on April 06, 2020, 03:32:25 pm
The program bee hives as advertised.

Pete
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: bplus on April 10, 2020, 10:51:42 am
@Qwerkey,

Have you made any progress determining why some .png's are showing and some are not with v1.4 while all worked fine with 1.3?

Checking image loads are easy enough:
Code: QB64: [Select]
  1. ' created for Johnno Battleship 5-AI b+ 2020-03-09
  2.  
  3. 'this function shuts down a program if an image file isn't loaded
  4. FUNCTION checkImageLoad& (file$)
  5.     IF _FILEEXISTS(file$) THEN
  6.         hdl& = _LOADIMAGE(file$)
  7.         IF hdl& = -1 THEN CLS: PRINT file$ + " can't be loaded.": SLEEP: END ELSE checkImageLoad& = hdl&
  8.     ELSE
  9.         CLS: PRINT file$ + " does nor exist.": SLEEP: END
  10.     END IF
  11.  
  12.  
  13.  

But my guess is you are handling the png for hive with branch and windmill building different than the other pngs. Odd, because these you seem to be manipulating the least they are or could be just part of background setting.

If there is something different between 1.3 and 1.4 it would be important to tease out the exact cause of problem.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: bplus on April 10, 2020, 11:54:54 am
Hey is that Fellippe looking out the Windmill?
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: FellippeHeitor on April 10, 2020, 12:18:22 pm
LOL It's me...
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Qwerkey on April 10, 2020, 01:00:41 pm
@bplus Regret that I've not looked into this yet, working on stuff elsewhere.  It's on my ToDo list (with no urgency).  As Fellippe confirms, it is he - you did point out that this project has a high level of whimsy!
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: bplus on April 10, 2020, 01:27:26 pm
Well so far all I've learned is that my little checkImageLoad& function will throw an error if a graphics screen hasn't been called upon yet.

And commenting CHECKING:OFF didn't reveal any errors not being reported.

Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: johnno56 on April 10, 2020, 06:05:16 pm
Well, I loaded all the images into Gimp, and found that all the images were assigned to the same colour profile. "RGB workspace". Which means that the "missing images", in QB64 1.4, are probably not caused by the images themselves. Sorry I couldn't be more helpful...

J
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: bplus on April 10, 2020, 06:19:15 pm
Yeah the windmill load is working fine all the way through this:
Code: QB64: [Select]
  1. _TITLE "checkImageLoad& test" 'b+ 2020-04-10   in Pi-In-The-Sky folder
  2.  
  3. CONST xmax = 800, ymax = 600
  4. CONST WindX% = 550, WindY% = ymax - 294, WindHeight% = 280
  5. SCREEN _NEWIMAGE(xmax, ymax, 32)
  6.  
  7. tempImg& = checkImageLoad&("windmill.png")
  8. 'PRINT windmill&
  9.  
  10. 'tempImg& = _LOADIMAGE("windmill.png", 32) 'Windmill must not occlude flowers or be occluded by spotlight beam
  11. DIM CMem AS _MEM
  12. CMem = _MEMIMAGE(tempImg&)
  13. WHILE COff < CMem.SIZE
  14.     IF _MEMGET(CMem, CMem.OFFSET + COff + 3, _UNSIGNED _BYTE) < 230 THEN _MEMPUT CMem, CMem.OFFSET + COff + 3, 0 AS _UNSIGNED _BYTE 'Alpha
  15.     COff = COff + 4
  16. _PUTIMAGE (WindX%, WindY%)-(WindX% + CINT(WindHeight% * _WIDTH(tempImg&) / _HEIGHT(tempImg&)), WindY% + WindHeight%), tempImg&
  17. _FREEIMAGE tempImg&
  18.  
  19.  
  20. 'this function shuts down a program if an image file isn't loaded
  21. FUNCTION checkImageLoad& (file$)
  22.     IF _FILEEXISTS(file$) THEN
  23.         hdl& = _LOADIMAGE(file$)
  24.         IF hdl& = -1 THEN CLS: PRINT file$ + " can't be loaded.": SLEEP: END ELSE checkImageLoad& = hdl&
  25.     ELSE
  26.         CLS: PRINT file$ + " does nor exist.": SLEEP: END
  27.     END IF
  28.  
  29.  

Something must be getting lost after the _PUTIMAGE, this is just before the start of the main loop.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Qwerkey on April 18, 2020, 10:53:44 am
The oddity of the v1.4 image display errors is even stranger than we may have thought.  Compare the two images of Pi-in-the-Sky where the spotlight and beam are displayed.  Not only are the beehive and windmill missing, but the spotlight is in the wrong place.  Remember that there is nothing different in the code, only the version of QB64.

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
  [ This attachment cannot be displayed inline in 'Print Page' view ]  

The position of the spotlight is set by two constants LampX% & LampY% which end up with incorrect values in v1.4.

The code (same in both versions) to set CONST values is from lines as follows:
Code: QB64: [Select]
  1. CONST False = 0, True = NOT False, XScreen% = 1100, YScreen% = 800, ZOffset% = -620, PiConst! = 4 * ATN(1)
  2. CONST PiSizeLess1% = 499, PiDisp% = 100, SunSize%% = 500, AmblinHalf%% = 50
  3. CONST Zeta! = 0.07 * PiConst!, RBee% = 120, CBee% = 80, ABee! = -4 * CBee% / (RBee% * RBee%)
  4. CONST BeeEntX% = -350, BeeEntY% = -250, HiveWidth% = 1009, HiveHeight% = 589, BWidth% = 350, HX1% = 0 - 50 - (XScreen% / 2)
  5. CONST HY1% = 300 - (YScreen% / 2), HX2% = HX1% + BWidth%, HY3% = HY1% - (BWidth% * HiveHeight% / HiveWidth%)
  6. CONST FountX% = -128, FountY% = -230, G! = 0.01, ZBow% = ZOffset% + 100
  7. CONST ZodHeight% = 70, ZodWidth% = ZodHeight% * 300 / 240, ZRad! = 12 * ZodWidth% / (2 * PiConst!) 'Can't use CINT() here
  8. CONST SpotRad% = 80, SpotInc! = 2 * PiConst! / 100, LampX% = XScreen% - 50, LampY% = YScreen% - 220
  9. CONST QB64X% = 300, QB64Y% = 50, UFOHalfX% = 150, UFOHalfY% = 60, UFORad% = 700
  10. CONST Iota! = -0.23 * PiConst!, Wind% = 150, WindX% = 550, WindY% = YScreen% - 294, WindHeight% = 280
  11. CONST MillBombX1% = WindX% + 17, MillBombY1% = WindY% + 8, SailX% = 44, SailY% = -154

LampX% & LampY% are set from the Screen dimesions, constants XScreen%&, YScreen% as:
CONST LampX% = XScreen% - 50, LampY% = YScreen% - 220

In v1.4 LampX% has value 1100: should be 1050.  LampY% has value 800: should be 580.
What is happening is that they get values XScreen% and YScreen% respectively.  The program forgets to take off the given values.

This must be some bug in v1.4?

I will continue to hunt down the differences for the beehive and windmill errors.

Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Petr on April 18, 2020, 01:11:05 pm
That's a really very nice program!
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Qwerkey on April 19, 2020, 05:12:24 am
Well, I'll be jiggered!  The v1.4 imaging problems are entirely due to CONST errors - I already mentioned the Spotlight position error.  The table gives  v1.3 and 1.4 values of the program CONST variables.  Where a calculation is involved, v1.4 sometimes gives incorrect values (a selection of CONSTs is given):

CONST Name    V1.3 Value         V1.4 Value         Difference
False                0                       0                      0
True                 -1                     -1                      0 (True & False are OK!)
XScreen%        1100                 1100                  0
YScreen%        800                   800                    0
HX1%              -600                 -600                   0
HY1%              -100                 -100                   0
HX2%              -250                 -250                   0
HY3%              -304                  -100                  -204
LampX%          1050                 1100                 -50
LampY%          580                   800                   -220
Iota!                -0.7225663       -0.7225664        0.0000001 (just rounding error)
Wind%            150                   150                    0
WindX%           550                   550                   0
WindY%           506                   800                   -294
WindHeight%   280                   280                    0
MillBombX1%   567                   567                    0
MillBombY1%   514                   808                    -294

The CONST variables HY3%, LampX%, LampY%, WindY% & MillBombY1% (all involved in position values for the affected images) are not calculated correctly in v1.4.

This is by no means the first time that I've run into problems with CONST.  I would be grateful if someone of skill would check to see if I have been doing something wrong - please check the code given in the Code Box of Reply #17.  I believe that I have not broken any CONST rules.  v1.4 work perfectly if the affected CONSTs are changed to standard variables.

At least there is only 1 problem to be solved.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: STxAxTIC on April 19, 2020, 06:07:25 am
I haven't had opportunity to spit this controversial opinion lately but now's as good as any:

F-o-c-k CONST.

CONST may as well be a DATA statement. We have variables, we know how to use them. That system is constantly checked for error and has been proven to be quite stable.

Here on the other hand we have CONST, with a completely different math subsystem, and has been nothing but trouble for years.

I say we lock CONST at the QB45 standard and never look back. Good thing I'm not a dev though, as this would probably step on some sensitivities out there.

Oh and I can see the responses coming, mostly on Discord, so let me just say this early and here - Just because something is sometimes useful, is NOT an argument. (This is the logic of mentally-ill hoarders.) All the stuff CONST does is redundant to our other tools and should be nerfed down to something that behaves without error.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Qwerkey on April 19, 2020, 07:02:23 am
Well, I have learnt a new verb at any rate:

nerf; verb - informal US
verb: nerf; 3rd person present: nerfs; past tense: nerfed; past participle: nerfing; gerund or present participle: nerfing

    cause to be weak or ineffective.


And we have also learnt its gerund!
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Qwerkey on April 19, 2020, 07:43:05 am
... we have CONST, with a completely different math subsystem, and has been nothing but trouble for years.

A completely different math subsystem.  Really?  I like CONST, but I've always assumed that a CONST is exactly like a standard variable except that you can't change its value.  Does it need to be more complicated that that?  Again, I seem to have been using something about which I know nothing.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: luke on April 19, 2020, 07:45:00 am
A completely different math subsystem.  Really?  I like CONST, but I've always assumed that a CONST is exactly like a standard variable except that you can't change its value.  Does it need to be more complicated that that?  Again, I seem to have been using something about which I know nothing.
It basically has its own parser in the compiler that evaluates expressions entirely independently of regular maths, and has caused no end of annoyances.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Qwerkey on April 19, 2020, 07:56:05 am
It basically has its own parser in the compiler that evaluates expressions entirely independently of regular maths, and has caused no end of annoyances.

What am I saying???  A CONST can't be exactly like a standard variable as it has keep its value in all SUBs and FUNCTIONs.  One of these days, I'm sure that Fellippe will bar me from the site for stupidity!
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: FellippeHeitor on April 19, 2020, 08:31:17 am
While ripping off Steve's system doesn't become consensus, could you tell me if using one line for each const (instead of a sequence of comma-separated consts) fixes it?

With v1.4 we did add Steve's upgraded const evaluator, and those issues seemed to have been fixed, but we hadn't stress-tested it as you have with your code, @Qwerkey

Please let me know.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Qwerkey on April 19, 2020, 09:21:46 am
OK.  I'll do them one line at a time and let you know.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: SMcNeill on April 19, 2020, 09:36:07 am
I'd thought 1.4 had corrected the CONST issues -- it certainly simplified the internal processes -- and I'd love to dig extensively into the root of the issue, but my bleeping PC is still down.   I called a guy last Friday about ordering a new powersupply and fixing it, and haven't heard squat back yet on it because of -- you know -- the coronavirus!!  Shipping takes forever.  Nobody is working.  At this rate, I may be back up and running by Christmas!!

If so, I'll try and take a look into the internals sometime before New Years.   /sigh
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Qwerkey on April 19, 2020, 10:52:58 am
I tried the code with one CONST statement per line.  Still the same problem, so it's not the commas on the CONST statement line which are the problem.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: FellippeHeitor on April 19, 2020, 10:56:57 am
That already steers us in a more accurate direction. Thanks for that.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: bplus on April 19, 2020, 11:45:59 am
It looks to me that all the CONSTs that are focked involve subtractions, good ole - sign a botch to evaluate because of double use as sign for numbers.

MillBombY1% is wrong because it is bossed by WindY% previously focked by missed-subtraction.

Didn't Steve do a correction for multiple - signs? Is this the version of Eval being used in v1.4 for CONSTs?


So @Qwerkey, another test, do all the CONSTs that involve subtraction manually and see how that works with v1.4.

Well I did myself and looks OK?

Reworked CONSTs section
Code: QB64: [Select]
  1. 'Pi-in-the-Sky Graphics Program by Qwerkey 13/12/19
  2. 'Acknowledgements: findsounds.com, freesound.org, freepik.com, pinclipart.com, imgbin.com, kissclipart.com, pngimg.com, vectorstock.com, sciencealert.com, startrek.com
  3.  
  4. CONST False = 0, True = NOT False, XScreen% = 1100, YScreen% = 800, ZOffset% = -620, PiConst! = 4 * ATN(1)
  5. CONST PiSizeLess1% = 499, PiDisp% = 100, SunSize%% = 500, AmblinHalf%% = 50
  6. CONST Zeta! = 0.07 * PiConst!, RBee% = 120, CBee% = 80, ABee! = -4 * CBee% / (RBee% * RBee%)
  7. CONST BeeEntX% = -350, BeeEntY% = -250, HiveWidth% = 1009, HiveHeight% = 589, BWidth% = 350
  8.  
  9. '  , HX1% = 0 - 50 - (XScreen% / 2)
  10. CONST HX1% = -600
  11.  
  12. 'CONST HY1% = 300 - (YScreen% / 2)
  13. CONST HY1% = -100
  14.  
  15. CONST HX2% = HX1% + BWidth%
  16.  
  17. 'HY3% = HY1% - (BWidth% * HiveHeight% / HiveWidth%)   = -100 - 204
  18. CONST HY3% = -304
  19.  
  20. CONST FountX% = -128, FountY% = -230, G! = 0.01, ZBow% = ZOffset% + 100
  21. CONST ZodHeight% = 70, ZodWidth% = ZodHeight% * 300 / 240, ZRad! = 12 * ZodWidth% / (2 * PiConst!) 'Can't use CINT() here
  22. CONST SpotRad% = 80, SpotInc! = 2 * PiConst! / 100
  23.  
  24. ', LampX% = XScreen% - 50
  25. CONST LampX% = 1050
  26.  
  27. ', LampY% = YScreen% - 220
  28. CONST LampY% = 580
  29.  
  30. CONST QB64X% = 300, QB64Y% = 50, UFOHalfX% = 150, UFOHalfY% = 60, UFORad% = 700
  31. CONST Iota! = -0.23 * PiConst!, Wind% = 150, WindX% = 550
  32. ', WindY% = YScreen% - 294,
  33. CONST WindY% = 506
  34.  
  35. CONST WindHeight% = 280
  36. CONST MillBombX1% = WindX% + 17, MillBombY1% = WindY% + 8, SailX% = 44, SailY% = -154
  37.  
  38. 'PRINT MillBombY1%    'OK!
  39. 'END
  40.  
  41.  
  42.  

 
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Pete on April 19, 2020, 01:15:28 pm
Hey is that Fellippe looking out the Windmill?

What? Fell? That's all ya got out ah that thar screen shot? Lookie agin...

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Qwerkey on April 19, 2020, 01:41:37 pm
@bplus Like you I did notice the -ve signs causing problems.  But I now have my own rule that a CONST may not have any maths in it.  Only simple CONST x = 1, and I have altered my pi-in-the-sky code accordingly.  When I have finished adding explanatory comments throughout, it will be ready to update the whole thing for 1.4 compatibility.

Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: bplus on April 19, 2020, 01:56:07 pm
@bplus Like you I did notice the -ve signs causing problems.  But I now have my own rule that a CONST may not have any maths in it.  Only simple CONST x = 1, and I have altered my pi-in-the-sky code accordingly.  When I have finished adding explanatory comments throughout, it will be ready to update the whole thing for 1.4 compatibility.

Well that's a safe rule but having CONST's calculated is convenient if you want to change the size of the screen for instance...

Here is the ScreenY% change and lampY% change so it fits my screen on laptop:
 


Now I can see the dirt at the grave sites.

Rats some Y's are based on ScreenY and some are not, so I fix sails and windmill and then the images in graves are off... oh well.

Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: STxAxTIC on April 19, 2020, 02:32:42 pm
Something tells me we wont learn a lesson from this...
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Qwerkey on April 20, 2020, 06:34:14 am
Here is the ScreenY% change and lampY% change so it fits my screen on laptop:

Rats some Y's are based on ScreenY and some are not, so I fix sails and windmill and then the images in graves are off... oh well.

@bplus  As I (in a cack-handed way without proper project planning) defined variables arbitrarily from top/bottom, left/right, would not RESIZE be something better for you to get the display to fit your screen size without having to manually change certain variable values?
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: bplus on April 20, 2020, 11:59:33 am
@bplus  As I (in a cack-handed way without proper project planning) defined variables arbitrarily from top/bottom, left/right, would not RESIZE be something better for you to get the display to fit your screen size without having to manually change certain variable values?

@Qwerkey,

I've never used _RESIZE before but this gave me idea to try _FULLSCREEN which seems allot easier except some of the Y values are not working correctly while some are.

Man the _RESIZE instructions are complicated, from WIKI example it looks like _RESIZE has to go in main loop and done every loop? How will this mix with all the memory values you are using? There is also _RESIZEWIDH and _RESIZEHEIGHT but what size does it know to resize to?
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Qwerkey on April 20, 2020, 01:05:13 pm
Oh Drat @bplus !  I thought that you'd take the opportunity to examine RESIZE and then instruct me!  Like you, I found the Wiki so complicated that I've never used it.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: bplus on April 20, 2020, 01:49:01 pm
LOL!

Update: Just ran then $RESIZE:ON  example.

Oh! _RESIZE is working with the Windows Max/Min button! Now I see where the _RESIZEWIDTH and _RESIZEHEIGHT numbers are coming from.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Qwerkey on April 22, 2020, 05:49:13 am
CONST (that CONSTANT headache):

Quotes:
STxAxTIC
Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
« Reply #20 on: April 19, 2020, 11:07:25 AM »
CONST may as well be a DATA statement. We have variables, we know how to use them. That system is constantly checked for error and has been proven to be quite stable.
Here on the other hand we have CONST, with a completely different math subsystem, and has been nothing but trouble for years.
I say we lock CONST at the QB45 standard and never look back.

luke
Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
« Reply #23 on: April 19, 2020, 12:45:00 PM »
It basically has its own parser in the compiler that evaluates expressions entirely independently of regular maths, and has caused no end of annoyances.


I'd thought 1.4 had corrected the CONST issues --

Something tells me we wont learn a lesson from this...

From herein, I will only use CONST without any mathematical manipulations: CONST x = 1.  For anything else I will use standard variables, and if it needs to be constant it'll get DIM SHARED.

To satisfy STxAxTIC and to simply developers' lives why not make this the CONST attribution in future?
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: bplus on April 22, 2020, 12:36:22 pm
CONST (that CONSTANT headache):

Quotes:
STxAxTIC
Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
« Reply #20 on: April 19, 2020, 11:07:25 AM »
CONST may as well be a DATA statement. We have variables, we know how to use them. That system is constantly checked for error and has been proven to be quite stable.
Here on the other hand we have CONST, with a completely different math subsystem, and has been nothing but trouble for years.
I say we lock CONST at the QB45 standard and never look back.

luke
Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
« Reply #23 on: April 19, 2020, 12:45:00 PM »
It basically has its own parser in the compiler that evaluates expressions entirely independently of regular maths, and has caused no end of annoyances.


From herein, I will only use CONST without any mathematical manipulations: CONST x = 1.  For anything else I will use standard variables, and if it needs to be constant it'll get DIM SHARED.

To satisfy STxAxTIC and to simply developers' lives why not make this the CONST attribution in future?



Yeah, it is a wonder why two separate Eval systems are being used? No wonder v1.4 is taking noticeably longer to compile and run, it's bloated!

But to me it is more sensible to fix the subtraction problem than to stop using CONST calculations based on other CONST values, that is very handy! IMHO CONSTs are made to be unchanged and variables are made to be changeable. Opinion? isn't it implied in their names?

Since QB64 v1.4 has 2 Eval systems you'd think we could use one of them for a very useful Eval Function as well.

Ah well, just Pi-in-the sky ideas. :)
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: FellippeHeitor on April 22, 2020, 03:10:08 pm
We've had Steve's internal evaluator for CONSTs since v1.0.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: SMcNeill on April 30, 2020, 07:31:43 pm
Question for the CONST glitch, which I just thought of: Does it still occur if the CONST name is all uppercase or lowercase?  It may be an issue of the internal routines trying to compare UCASE$ names verses CaMeLcAsE stored names. 

I finally got my PC in the shop for repairs today, so if I get it back next week, I'll dig into the issue better, but it may just be a simple case of cases not matching, which is causing the issue.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: bplus on April 30, 2020, 08:07:41 pm
Hey Steve,

All caps did not work but quess what? NO %'s did the trick!

Before fix:
Code: QB64: [Select]
  1. CONST False = 0, True = NOT False, XScreen% = 1100, YScreen% = 800, ZOffset% = -620, PiConst! = 4 * ATN(1)
  2. CONST PiSizeLess1% = 499, PiDisp% = 100, SunSize%% = 500, AmblinHalf%% = 50
  3. CONST Zeta! = 0.07 * PiConst!, RBee% = 120, CBee% = 80, ABee! = -4 * CBee% / (RBee% * RBee%)
  4. CONST BeeEntX% = -350, BeeEntY% = -250, HiveWidth% = 1009, HiveHeight% = 589, BWidth% = 350, HX1% = 0 - 50 - (XScreen% / 2)
  5. CONST HY1% = 300 - (YScreen% / 2), HX2% = HX1% + BWidth%, HY3% = HY1% - (BWidth% * HiveHeight% / HiveWidth%)
  6. CONST FountX% = -128, FountY% = -230, G! = 0.01, ZBow% = ZOffset% + 100
  7. CONST ZodHeight% = 70, ZodWidth% = ZodHeight% * 300 / 240, ZRad! = 12 * ZodWidth% / (2 * PiConst!) 'Can't use CINT() here
  8. CONST SpotRad% = 80, SpotInc! = 2 * PiConst! / 100, LampX% = XScreen% - 50, LampY% = YScreen% - 220
  9. CONST QB64X% = 300, QB64Y% = 50, UFOHalfX% = 150, UFOHalfY% = 60, UFORad% = 700
  10. CONST Iota! = -0.23 * PiConst!, Wind% = 150, WindX% = 550, WindY% = YScreen% - 294, WindHeight% = 280
  11. CONST MillBombX1% = WindX% + 17, MillBombY1% = WindY% + 8, SailX% = 44, SailY% = -154
  12.  

After fix:
Code: QB64: [Select]
  1. CONST FALSE = 0, TRUE = NOT FALSE, XSCREEN = 1100, YSCREEN = 800, ZOFFSET = -620, PICONST! = 4 * ATN(1)
  2. CONST PISIZELESS1 = 499, PIDISP = 100, SUNSIZE = 500, AMBLINHALF = 50
  3. CONST ZETA! = 0.07 * PICONST!, RBEE = 120, CBEE = 80, ABEE! = -4 * CBEE / (RBEE * RBEE)
  4. CONST BEEENTX = -350, BEEENTY = -250, HIVEWIDTH = 1009, HIVEHEIGHT = 589, BWIDTH = 350, HX1 = 0 - 50 - (XSCREEN / 2)
  5. CONST HY1 = 300 - (YSCREEN / 2), HX2 = HX1 + BWIDTH, HY3 = HY1 - (BWIDTH * HIVEHEIGHT / HIVEWIDTH)
  6. CONST FOUNTX = -128, FOUNTY = -230, G! = 0.01, ZBOW = ZOFFSET + 100
  7. CONST ZODHEIGHT = 70, ZODWIDTH = ZODHEIGHT * 300 / 240, ZRAD! = 12 * ZODWIDTH / (2 * PICONST!) 'CAN'T USE CINT() HERE
  8. CONST SPOTRAD = 80, SPOTINC! = 2 * PICONST! / 100, LAMPX = XSCREEN - 50, LAMPY = YSCREEN - 220
  9. CONST QB64X = 300, QB64Y = 50, UFOHALFX = 150, UFOHALFY = 60, UFORAD = 700
  10. CONST IOTA! = -0.23 * PICONST!, WIND = 150, WINDX = 550, WINDY = YSCREEN - 294, WINDHEIGHT = 280
  11. CONST MILLBOMBX1 = WINDX + 17, MILLBOMBY1 = WINDY + 8, SAILX = 44, SAILY = -154
  12.  
  13.  

To confirm it's the suffixes I tried this:
Code: QB64: [Select]
  1. CONST False = 0, True = NOT False, XScreen = 1100, YScreen = 800, ZOffset = -620, PiConst = 4 * ATN(1)
  2. CONST PiSizeLess1 = 499, PiDisp = 100, SunSize = 500, AmblinHalf = 50
  3. CONST Zeta = 0.07 * PiConst, RBee = 120, CBee = 80, ABee = -4 * CBee / (RBee * RBee)
  4. CONST BeeEntX = -350, BeeEntY = -250, HiveWidth = 1009, HiveHeight = 589, BWidth = 350, HX1 = 0 - 50 - (XScreen / 2)
  5. CONST HY1 = 300 - (YScreen / 2), HX2 = HX1 + BWidth, HY3 = HY1 - (BWidth * HiveHeight / HiveWidth)
  6. CONST FountX = -128, FountY = -230, G = 0.01, ZBow = ZOffset + 100
  7. CONST ZodHeight = 70, ZodWidth = ZodHeight * 300 / 240, ZRad = 12 * ZodWidth / (2 * PiConst) 'Can't use CINT() here
  8. CONST SpotRad = 80, SpotInc = 2 * PiConst / 100, LampX = XScreen - 50, LampY = YScreen - 220
  9. CONST QB64X = 300, QB64Y = 50, UFOHalfX = 150, UFOHalfY = 60, UFORad = 700
  10. CONST Iota = -0.23 * PiConst, Wind = 150, WindX = 550, WindY = YScreen - 294, WindHeight = 280
  11. CONST MillBombX1 = WindX + 17, MillBombY1 = WindY + 8, SailX = 44, SailY = -154
  12.  
  13.  

And it's running fine as well as far as I can tell.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: SMcNeill on April 30, 2020, 09:14:53 pm
That's what I was kinda thinking: a simple case of names not matching the lookup values.  All we probably need is a simple routine to strip symbols off before looking up the names from our internal list.

Does the following work?

CONST X! = 3.14
CONST Y! = 2 * X
PRINT X, Y

If you notice, the second line is using X without the specific symbol attached.  At the moment, I'm thinking the glitch is probably only on the right side of the = sign. 

(IF it works, try it with X! and see if that breaks it.  If so, I think it'll be a trivial fix once I get my PC back and can address the issue.)
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: bplus on April 30, 2020, 11:06:44 pm
That's what I was kinda thinking: a simple case of names not matching the lookup values.  All we probably need is a simple routine to strip symbols off before looking up the names from our internal list.

Does the following work?

CONST X! = 3.14
CONST Y! = 2 * X
PRINT X, Y

If you notice, the second line is using X without the specific symbol attached.  At the moment, I'm thinking the glitch is probably only on the right side of the = sign. 

(IF it works, try it with X! and see if that breaks it.  If so, I think it'll be a trivial fix once I get my PC back and can address the issue.)

No they are all working (I also tested with % and I put the assignments on same CONST line. I am having a difficult time coming up with a simple example that is not working.

Qwerkey was staying true to suffix endings with his names in the problem set.

I did manage to run across a problem with adding something to a CONST for another CONST and I don't usually worry about suffix endings with CONSTs. Sorry I didn't save the case. I was assigning on the same CONST line, if I recall, and probably using a camelVariableName. That's why I thought you might be onto something with the camel test.

Aha! Caught one, 2nd line sAm%
 


And sAm fixed!
 


But sAm% is OK here
 
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: SMcNeill on April 30, 2020, 11:16:44 pm
From those, it appears to be losing the -5, from the aBel% - 5.  I'll dig into it soonish.  ;)
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: bplus on January 15, 2022, 11:44:31 am
@Qwerkey

Yea! About time you put this in Graphics Library :)
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: Qwerkey on January 15, 2022, 01:25:59 pm
@bplus Fellow Librarian, you always wanted this in the Library.  This is a whimsical output project (although the basis of the project was serious - to demonstrate the power of QB64 in graphics).  I put it into the Graphics Library at this time to show that QB64 is quite definitely for the amateur (as well as quasi-professional): nobody need fear the transition to the new team.  Incidentally, the program is slightly updated: now all the scenes have appropriate audio.
Title: Re: Pi-in-the-Sky Graphics Demonstration Program (with 3D)
Post by: bplus on January 15, 2022, 01:45:39 pm
Quote
Incidentally, the program is slightly updated: now all the scenes have appropriate audio.

Oh good to know, I will update my copy, thanks :)

Should I remind everyone who's looking out the lighthouse window?