• Print

Author Topic: voxel engine  (Read 173 times)

23452

  • Jr. Member
  • **
  • Posts: 72
    • Email
voxel engine
« on: October 18, 2012, 08:45:11 PM »
I am making a voxel engine, but I have forget a few things because it has been a while since I last used QB.
How do you set a whole array of bools back to false, and also why is the auto spacing spacing the else if statements like this.
 DO UNTIL o >= 0

    IF az(o) <= 1.5790796327 AND (az + wz) <= 1.5790796327 THEN
        IF z(o) >= TAN(az(o)) * (x(o) - ex(o)) + ez(o) AND z(o) <= TAN(az(o) + wz) * (x(o) - ex(o)) + ez(o) THEN
            eyez(o) = true
        END IF

    ELSE IF az(o) <= 1.5790796327 AND (az + wz) >= 1.5790796327 THEN
            IF z(o) >= TAN(az(o)) * (x(o) - ex(o)) + ez(o) AND z(o) >= TAN(az(o) + wz) * (x(o) - ex(o)) + ez(o) THEN
                eyez(o) = true
            END IF

        ELSE IF az(o) >= 1.5790796327 AND (az + wz) <= 4.71238898 THEN
                IF z(o) <= TAN(az(o)) * (x(o) - ex(o)) + ez(o) AND z(o) >= TAN(az(o) + wz) * (x(o) - ex(o)) + ez(o) THEN
                    eyez(o) = true
                END IF

            ELSE IF az(o) >= 1.5790796327 AND (az + wz) >= 4.71238898 THEN
                    IF z(o) <= TAN(az(o)) * (x(o) - ex(o)) + ez(o) AND z(o) <= TAN(az(o) + wz) * (x(o) - ex(o)) + ez(o) THEN
                        eyez(o) = true
                    END IF

                ELSE IF az(o) >= 4.71238898 AND (az + wz) >= 4.71238898 THEN
                        IF z(o) >= TAN(az(o)) * (x(o) - ex(o)) + ez(o) AND z(o) <= TAN(az(o) + wz) * (x(o) - ex(o)) + ez(o) THEN
                            eyez(o) = true
                        END IF
                    END IF




LOOP


TerryRitchie

  • Hero Member
  • *****
  • Posts: 2264
  • FORMAT C:\ /Q /U /AUTOTEST (How to repair Win8)
    • Email
Re: voxel engine
« Reply #1 on: October 18, 2012, 08:58:25 PM »
ELSEIF needs to be one word, then the spacing will be right.

Clippy

  • Hero Member
  • *****
  • Posts: 16431
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: voxel engine
« Reply #2 on: October 18, 2012, 09:42:12 PM »
Too many END IF's
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

Klangaroo

  • Full Member
  • ***
  • Posts: 202
  • Video Game Dad
    • ManFightDragon Indie Dev Blog
Re: voxel engine
« Reply #3 on: October 18, 2012, 09:49:28 PM »
To sent an entire array back to FALSE you can just use ERASE or REDIM or something like that, I can't remember off the top of my head. I use it to re-init my clipping plane when loading new maps.
I make video games over at Man Fight Dragon and I have Twitter so do whatever really.

23452

  • Jr. Member
  • **
  • Posts: 72
    • Email
Re: voxel engine
« Reply #4 on: October 19, 2012, 04:45:55 PM »
what is the easiest way to find the negative reciprocal in QB?   

23452

  • Jr. Member
  • **
  • Posts: 72
    • Email
Re: voxel engine
« Reply #5 on: October 19, 2012, 04:50:03 PM »
never mind that was a stupid question.
It would just be -1*((X)^-1)

SMcNeill

  • Hero Member
  • *****
  • Posts: 2414
    • Email
Re: voxel engine
« Reply #6 on: October 19, 2012, 04:59:01 PM »
Quote from: 23452 on October 19, 2012, 04:50:03 PM
never mind that was a stupid question.
It would just be -1*((X)^-1)

Just use the negative sign by itself.  It's faster.

-((X)^-1)
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.
http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

http://bit.ly/DataToDrive - A set of routines to quickly and easily get data to and from the disk.  BI and BM files

DarthWho

  • Hero Member
  • *****
  • Posts: 3853
  • Timelord of the Sith
Re: voxel engine
« Reply #7 on: October 19, 2012, 05:14:31 PM »
there is an even faster path....   -1/x
Rassilon: My lord Doctor; My lord Master; My lord DarthWho
The Doctor and the master at the same time :WHAT!?!?!

FastMath 1.1.0 released: http://dl.dropbox.com/u/12359848/fastmath.h

23452

  • Jr. Member
  • **
  • Posts: 72
    • Email
Re: voxel engine
« Reply #8 on: October 19, 2012, 09:49:24 PM »
Can anyone think of how to do this;
I have two lines     z(o) = TAN(az) * (x(o) - ex) + ez and z(o) = TAN(az + wz) * (x(o) - ex) + ez
on one side they read all the points inside of the two line.
what I am having trouble with is the other side there needs to be base to the triangle. The base needs to have a slope of
-1/(tan(az + .5wz)), and I need to know the distance between one of the leg vertexes and a point made by a line passing though the vertex of the original two lines (ex, ez ) and a object (x(o), z(o)).

If you are unsure of what I need please ask; I how much it sucks to solve something hard just to find out the question was badly worded.

23452

  • Jr. Member
  • **
  • Posts: 72
    • Email
Re: voxel engine
« Reply #9 on: October 20, 2012, 05:29:52 PM »
Okay I found a way to do that but my code is getting very long.
I have not used  subs or functions on QB. What is the difference between them, and do they slow the program down any.   

  • Print