? SIM.3D ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password
[Help Wanted] SmileBASIC Documentation Project

SIM.3D

Submitted
Updated
Author
Simeon
Public Key
HEAEP3
Min. Compat.
All
Version
1.5
Size
90.4KB
Rating
30 votes
Description

A lightweight yet powerful 3D game engine

Instructions

What's New

_____________________

Version 1.5 - The physics update

  1. Although only bounding box physics are currently supported, it has been implemented in such a way that more complex shapes will soon be supported.
  2. Many performance improvements
  3. Now supports split-screen gameplay as well as quadruple-screen gameplay. Using two or four screens does not noticably change the overall framerate!
  4. Added the ability to merge objects into one, and split them (MERGEOBJ,SPLITOBJ).
  5. Added object bounding box variables (OBJMINX,Y,Z,OBJMAXX,Y,Z).
  6. An object's center is not longer its center of mass, but rather the center of its bounding box.
  7. Added a wireframe cube object (called WCUBE) as well as UPDATEWCUBETOOBJ to set the wireframe position ans size to match another object's bounding box.
  8. Added CHECKCOLLISION to check every object in the world to check for collisions.
  9. Added ISCOLLIDING to check if two objects are intersecting.
  10. Added RAYTHROUGHOBJ to check if an infinite ray is intersecting an object.
  11. Added COLOROBJAB function to color a specific range of triangles in an object.
  12. Added a FLAG object (the main character of 3D Parkour).
  13. Added 3D Parkour 2 Alpha as a demo.
  14. Instead of typing GCLS:BUFFER:RENDER you now just type RENDER to do everything.
  15. GETRAY2D now only takes in X,Z as opposed to X,Y,Z.
  16. Added variables to keep track of an object's scale.
  17. Added OBJSTR$ variables, which work the same as the OBJTAG$ variables.
  18. Added SETSTATICOBJ function to set if an object is affected by physics or not.
  19. Added variables to define the velocity for each object.

Version 1.4

  1. Added TEXT as a new object type! Check the documentation for more details! Game worlds can easily display messages as 3D objects.
  2. CHESS.3D has been worked on, the AI is more intelligent and uses alpha-beta pruning to simulate ahead in the future to find how to maximize the minimum score. In the first few lines you can set the AI_VS_AI to watch it play against itself.
  3. Every demo has been updated to make use of the new features.
  4. Fixed the randomly-appearing-flickering-lines-bug for DLC users.
  5. Fixed triangles-sometimes-not-rendering-glitch for non-DLC users.
  6. Also non-DLC users run at a fairly higher framerate due to less function calls.
  7. Perspective calculations and rendering have been worked on a lot, graphics are much smoother.
  8. Added a new demo to showcase 3D randomized fractal tree generation.
  9. Spheres now render without borders to improve the look of scenes.
  10. Changed the way object tags work, instead of saving TAG$ to every triangle it saves it in the objects themselves. Also triangles no longer carry a second color (the sphere border color). Triangles only carry the most necessary data now.
  11. FPS is more smooth/stabilized.
  12. Added the ability to change the view distance to make programs run faster for o3DS users.
  13. Added function APPLYSURFACEEQUATION to automatically set a SURFACE object to mimic a mathematical equation. This makes the code for the GRAPH_3D demo much simpler and gives users much more power to simulate terrain.
  14. Added lots of new functions!

Version 1.3

  1. Added a fully functional 3D chess game against a real AI that looks a few moves ahead to determine the best way to move.
  2. Added an first person shooter game demo.
  3. Added support for 3D lines using ADDLINE(X1,Y1,Z1,X2,Y2,Z2,COLOR).
  4. Added a surface object, which is a grid plane with multiple sections (used in the 3D grapher).
  5. Fixed a few bugs when deleting an object.
  6. Added some new functions.
  7. BUFFERing only buffers the top screen, use BUFFERBOTTOM to buffer the lower screen.
  8. Other small tweaks and optimizations.

Version 1.2

  1. Framerate has been doubled and possibly tripled, especially for DLC users. The engine runs incredibly fast for users that have purchased the SmileBASIC DLC!
  2. SIM.3D no longer needs any other program slots other than 3. So this update makes it a lot more compact and simple.
  3. Hue, saturation, and value are now optional by using HSV(H,S,V) just like RGB(R,G,B). Objects only need a single color value to be initialized. So #RED, #GREEN, #BLUE, etc... can work too.
  4. Field of view (FOV), world scale constant (WSC), and the cutoff ratio (CUTOFF_RATIO) are modifiable. Cutoff ratio is the ratio between the camera and the object of focus in which polygons will no longer be drawn. Default is 0.5.
  5. Lots of new functions that give more power to the user, such as finding the closest/furthest objects to a point, and making an object rotate to face a given point in the world.
  6. Behind the scenes optimizations for maximum performance.

Version 1.1

  1. DLC is fully implemented! The engine runs much smoother when the Advanced Sound DLC is purchased, the application now only needs to run a few ARYOP operations each frame.
  2. Performance without DLC has also been improved, but DLC gives much higher performance.
  3. Circles have been removed, and re-implemented as triangle objects. Now that there is complete consistency with objects, huge performance advancements have been made.
  4. The flickering graphics bug has been targeted and removed. Graphics feel cleaner with modified algorithms.
  5. Example programs have been modified a little bit. Please feel free to view the code for those, and use them to implement your own games. I do not require any credit. Everything is free for everybody.
  6. Triangles are now sorted by the furthest away Z point.
  7. CIRCLE functions are now called SPHERE functions.
  8. All future updates from this point forward will minimize the modifications required for a game to run on the updated engine. Any modifications required will be listed down here for you.

Version 1.0

  1. Application is stable.
Notes This application was designed specifically to teach the idea of 3D game design. While this engine was built with simplicity in mind, it was also built to maximize efficiency and minimize the computation required to display good looking graphics. With that said this is an excellent engine to make 3D games, I don't ask for any credit, and anyone can use this program for their own purposes. Use the comment section below for help, or if you have any questions, I'll be glad to help! To see the power of SIM.3D, I added some regular demos that will give a better idea on how to use SIM.3D. The files include:
  1. 3D.ENGINE - The engine in all it's glory.
  2. BOX_O_GEMS - A demo to show all the different kinds of objects, and how fast they render.
  3. CHESS.3D - A rather complex program to show what can be made with SIM.3D.
  4. FPS_DEMO - A first-person-shooter-styled simulation, on a Perlin-noise-generated map.
  5. GRAPH_3D - A powerful yet simple 3D equation grapher.
  6. PARKOUR2_ALPHA - The new development of 3D Parkour 2, in alpha state.
  7. SIERPINSKI - Using simple code to generate a Sierpinski pyramid.
  8. SIMPLE_CUBES - A short code demo to show how SIM.3D is used.
  9. SPIRAL_SPHERE - Generate colorful sphere-spirals of spheres.
  10. SPLIT_SCREEN - Example of using splitscreen (with 3D Parkour 2 Alpha)
  11. TREE_OF_WISDOM - Showcasing three dimensional fractal tree generation using simple recursion.
To use this engine, simply add this to the first line of your code PRGEDIT 3 EXEC "PRG3:3D.ENGINE" ENDDoing so will load the 3D engine into program slot 3, then insert the code from program slot 0 into program slot 3, then execute itself. The most basic application to rotate a cube in the center of the screen is as follows: PRGEDIT 3 EXEC "PRG3:3D.ENGINE" END 'S1M.3D VAR C=ADDCUBE(0,0,0,1,1,1,#GRAY) 'C CONTAINS A REFERENCE TO THE CUBE @LOOP VSYNC 'STABALIZE THE FRAMERATE ROTOBJ C,0,1,0 'ROTATE THE CUBE AROUND THE Y AXIS RENDER 'RENDER THE WORLD GOTO @LOOP 'REPEAT There are a few things to be aware of before diving into the 3D engine
  1. One in-world unit is the equivalent of 50 pixels from the default camera position. Adding a scale definition like this makes the game feel more realistic. This can be customized by changing the WSC (world scaling constant) variable.
  2. When working with SIM.3D, you must work in the default program slot 0, you will need to save every time you run the code. Any errors can be traced to your code in program slot 3 where the actual engine is.
  3. Or you could work directly in the 3D engine and avoid the use of the loader. There's a spot in the beginning of the code dedicated for user programs to go.
  4. Every object is composed of triangles. If a triangle is defined clockwise then it will be visible from the outside of the object. There are preset objects to make this easier to work with.
  5. So triangles can only be seen from one side (for higher performance), using STRETCHOBJ with negative values to stretch an object inside-out will let you see the object's back faces instead of front
  6. Every object is given an index. This index will never change until the object is deleted, in which case the ID will be given to the next future object to be defined.
Engine variables:VAR CAMX,CAMY,CAMZ 'THE FOCUS POSITION OF THE CAMERA (DEFAULT: 0,0,0) VAR CAMRX,CAMRY,CAMRZ 'ROTATION OF THE CAMERA (IN DEGREES) AROUND THE CAMERA FOCUS (DEFAULT: 0,20,0) VAR CAMDIST 'DISTANCE AWAY FROM CAMERA'S FOCUS POINT (DEFAULT: 10) VAR FOV 'FIELD OF VIEW (DEFAULT: 5) VAR WSC 'WORLD SCALING CONSTANT IN PIXELS (DEFAULT: 50) VAR CUTOFF_RATIO 'THE RATIO BETWEEN CAMERA AND FOCUS IN WHICH THINGS STOP RENDERING (DEFAULT: 0.7) VAR BOUNDCAMANGLES 'TRUE/FALSE, TELL IF THE CAMERA SHOULD BE BOUNDED BETWEEN -180 AND 180 (DEFAULT: 1) VAR RENDERDIST 'HOW FAR THE PLACER CAN SEE, 0=INFINITE (DEFAULT: 0) VAR ACCELERATED_RENDERING 'TRUE/FALSE TO USE ADVANCED SOUND DLC (DEFAULT: 1 IF POSSIBLE) VAR FPS 'FRAMES PER SECOND VAR GMW0,GMH0 'WHERE THE SCREEN STARTS (DEFAULT: 0,0) VAR GMW1,GMH1 'WHERE THE SCREEN ENDS (DEFAULT: 400,240) VAR GMW05,GMH05 'DEFINES THE CENTER OF THE SCREEN TO SAVE COMPUTATIONAL OVERHEAD Here are the preset object definitions:ADDCUBE(X,Y,Z,LENGTH,WIDTH,HEIGHT,COLOR) 'CREATE A RECTANGULAR PRISM, RETURN ITS INDEX ADDWCUBE(X,Y,Z,LENGTH,WIDTH,HEIGHT,COLOR) 'CREATE A WIREFRAME RECTANGULAR PRISM, RETURN ITS INDEX ADDSPHERE(X,Y,Z,RADIUS,COLOR) 'CREATE A SPHERE, RETURN ITS INDEX ADDLINE(X1,Y1,Z1,X2,Y2,Z2,COLOR) 'CREATE A LINE, RETURN ITS INDEX ADDPYRAMID(X,Y,Z,WIDTH,HEIGHT,COLOR) 'CREATE A SQUARE PYRAMID, WHERE THE BASE OF THE BOTTOM IS X,Y,Z 'RETURNS THE OBJECT'S INDEX ADDDIAMOND(X,Y,Z,WIDTH,HEIGHT,COLOR) 'CREATE A DIAMOND SHAPE (A.K.A OCTAHEDRON) 'RETURNS THE OBJECT'S INDEX ADDCRYSTAL(X,Y,Z,WIDTH,HEIGHT,COLOR) 'CREATE A DIFFERENT TYPE OF "DIAMOND" SHAPE 'RETURNS THE OBJECT'S INDEX ADDSKYBOX(X,Y,Z,LENGTH,WIDTH,HEIGHT,COLOR) 'CREATE AN INSIDE-OUT CUBE THAT ACTS AS A SKYBOX WHEN LARGE 'RETURNS THE OBJECT'S INDEX ADDSURFACE(X,Y,Z,GRIDX,GRIDY,LENGTH,WIDTH,COLOR) 'CREATE A FLAT GRID PLANE THAT CAN HAVE MATH EQUATIONS APPLIED TO IT 'RETURNS ITS INDEX ADDFLAG(X,Y,Z,COLOR) 'CREATE A FLAG CHARACTER OBJECT (FROM 3D PARKOUR) 'RETURNS ITS INDEX ADDTEXT X,Y,Z,TEXT$,COLOR 'MAKE A TEXT OBJECT IN THE WORLD 'RETURNS THE OBJECT'S INDEX You may also consider defining your own objectADDOBJ(TYPE$,X[],Y[],Z[],COLOR) 'X[],Y[],Z[] DEFINE EACH TRIANGLE. THESE ARRAYS MUST BE IN SETS OF 3, SO LENGTH=3,6,9,12,15,18,... Every object contains these variables:OBJX 'CENTER OF MASS X POSITION OBJY 'CENTER OF MASS Y POSITION OBJZ 'CENTER OF MASS Z POSITION OBJTEXT$ 'A STRING (USED IN TEXT OBJECTS) OBJTAG$ 'A STRING ONJTYPE$ 'A STRING TELLING WHAT TYPE OF OBJECT IT IS OBJINDEX 'THE INDEX POINTING TO WHICH TRIANGLES BELONG TO THIS OBJECT OBJLENGTH 'THE LENGTH OF HOW MANY TRIANGLES BELONG TO THIS OBJECT OBJRX 'GET (NO SET) THE OBJECT'S X ROTATION OBJRY 'GET (NO SET) THE OBJECT'S Y ROTATION OBJRZ 'GET (NO SET) THE OBJECT'S Z ROTATION OBJSX 'GET (NO SET) THE OBJECT'S X SCALE (WIDTH) OBJSY 'GET (NO SET) THE OBJECT'S Y SCALE (HEIGHT) OBJRZ 'GET (NO SET) THE OBJECT'S Z SCALE (LENGTH) OBJMINX 'GET (NO SET) THE OBJECT'S MINIMUM X VALUE OBJMINY 'GET (NO SET) THE OBJECT'S MINIMUM Y VALUE OBJMINZ 'GET (NO SET) THE OBJECT'S MINIMUM Z VALUE OBJMAXX 'GET (NO SET) THE OBJECT'S MAXIMUM X VALUE OBJMAXY 'GET (NO SET) THE OBJECT'S MAXIMUM Y VALUE OBJMAXZ 'GET (NO SET) THE OBJECT'S MAXIMUM Z VALUE OBJVX 'THE OBJECT'S X VELOCITY OBJVY 'THE OBJECT'S Y VELOCITY OBJVZ 'THE OBJECT'S Z VELOCITY OBJVISSTATIC 'TRUE/FALSE, IF THE OBJECT IS AFFECTED BY PHYSICS OBJMASK 'WHEN YOU DEFINE AN OBJECT YOU ARE GIVEN A MASK INDEX WHICH WILL NEVER 'CHANGE, SO YOU CAN ONLY ACCESS THE VARIABLES ABOVE BY GOING THROUGH THE OBJECT MASK 'FIRST: OBX[OBJMASK[MY_OBJECT_INDEX]]=FOO 'BY USING THIS MASK, WE CAN GUARANTEE THAT AN OBJECT INDEX WILL NEVER CHANGE 'EVEN IF OBJECTS BEFORE IT ARE DELETED. Here is a list of object functionsSTRETCHOBJ INDEX,SCALEX,SCALEY,SCALEZ 'SQUISHES OR STRETCHES AN OBJECT'S POINTS BY A GIVEN SCALE MOVEOBJ INDEX,DX,DY,DZ 'INCREMENT AN OBJECT'S POSITION RELATIVE TO ITS CURRENT POSITION MOVEOBJTO INDEX,X,Y,Z 'TELEPORT AN OBJECT SOMEWHERE (NOT RELATIVE) ROTOBJ INDEX,AX,AY,AZ 'INCREMENT THE ROTATION OF AN OBJECT AROUND ITS CENTER OF MASS RELATIVE TO ITS CURRENT ROTATION ROTOBJTO INDEX,AX,AY,AZ 'SET THE ROTATION OF AN OBJECT AROUND ITS CENTER OF MASS (NOT RELATIVE) 'THIS WILL RESET THE OBJECT'S ROTATION TO ITS DEFAULT, THEN ROTATE IT AX,AY,AZ ROTOBJAROUND INDEX,X,Y,Z,AX,AY,AZ 'ROTATE AN OBJECT AROUND (X,Y,Z) ROTOBJAROUNDOBJ INDEX,INDEX2,AX,AY,AZ 'ROTATE AN OBJECT AROUND ANOTHER OBJECT ROTOBJTOPOINT INDEX,X,Y,Z 'ROTATE AN OBJECT SO THAT IT FACES THE POINT X,Y,Z MERGEOBJS(INDEX1,INDEX2) 'MERGE TWO OBJECTS INTO ONE, RETURNS THE NEW INDEX SPLITOBJ INDEX,TRIANGLES OUT INDEX1,INDEX2 'SPLIT AN OBJECT AT A TRIANGLE INDEX, DEFINING THE AMOUNT OF TRIANGLES FOR THE FIRST OBJECT DELOBJ INDEX : INDEX=-1 'DELETE AN OBJECT FROM THE WORLD 'THEN IT IS RECOMMENDED TO SET THE INDEX TO -1 CHANGEOBJCOLOR INDEX,COLOR 'SET AN OBJECT'S COLOR CHANGEOBJFACECOLOR INDEX,FACE,COLOR 'SET THE COLOR OF A SINGLE TRIANGLE ON AN OBJECT CHANGEOBJCOLORAB OBJECT,INDEX1,INDEX2,COLOR 'SET AN OBJECT'S COLOR FROM INDEX1 TO INDEX2 INSIDE THE OBJECT 'OBJECT TRIANGLE INDEXES START AT 0 FOR EACH OBJECT SETTAG INDEX,TAG$ 'GIVE AN OBJECT A STRING, DEFAULT="" 'THIS CAN BE ANYTHING, IT DOESN'T AFFECT THE 3D ENGINE AT ALL 'DESIGNED TO BE USED BY THE DEVELOPER GETTAG$(INDEX) 'GET THE TAG$ VALUE OF AN OBJECT FINDIBJBYTAG(TAG$) 'QUICKLY FIND AN OBJECT WITH A SPECIFIC TAG$ VALUE 'RETURNS -1 IF NO OBJECT EXISTS WITH THIS TAG SETSTR INDEX,S$ 'GIVE AN OBJECT A STRING, DEFAULT="" 'THIS IS USED TO STORE THE VALUE IN TEXT OBJECTS 'THERE IS NO USE OUTSIDE OF TEXT OBJECTS, SO THIS IS ANOTHER FREE VARIABLE GETSTR$(INDEX) 'GET THE STRING VALUE OF AN OBJECT FINDIBJBYSTR(S$) 'FIND AN OBJECT WITH A SPECIFIC STRING$ VALUE 'RETURNS -1 IF NO OBJECT EXISTS WITH THIS STRING 'OTHERWISE RETURN THE OBJECT INDEX GETOBJTYPE$(INDEX) 'RETURNS THE STRING DEFINING WHAT TYPE OF OBJECT IT IS 'POSSIBLE RESULTS ARE: "CUBE","SPHERE","DIAMOND","CRYSTAL","PYRAMID","SKYBOX","LINE","SURFACE","TEXT",etc... GETOBJSBYDIST(X,Y,Z) 'RETURNS A SORTED ARRAY OF OBJECT INDEXES SUCH THAT THE FIRST ITEM IS CLOSEST 'TO (X,Y,Z) AND THE LAST ITEM IS FURTHEST AWAY FROM (X,Y,Z) 'THIS FUNCTION TAKES ADVANTAGE OF DLC USERS TO GIVE MUCH FASTER PERFORMANCE UPDATEWCUBEAROUNDOBJ INDEX1,INDEX2 'CHANGE THE WIREFRAME CUBE OBJECT INSIDE INDEX1 TO THE SAME SHAPE AND 'SIZE OF THE OBJECT INSIDE INDEX2 (INDEX1 MUST BE A WCUBE OBJECT) 'IN OTHER WORDS, THIS IS AN ADD-ON TO THE WCUBE OBJECT TO ALLOW IT TO 'PERFECTLY MASK THE BOUNDING BOX OF ANOTHER OBJECT APPLYSURFACEEQUATION INDEX,EQU$,MINY,MAXY,SCX,SCY,SCZ 'APPLY A MATH EXPRESSION TO A SURFACE OBJECT 'EQU$ IS AN EQUATION WITH X,Y, AND Z IN IT 'EQU$="SIN(X)+COS(Z)" MAKES A WAVY SURFACE 'MINY AND MAXY DEFINE THE OBJECT'S Y BOUNDS 'SCX,SCY,SCZ ARE THE ZOOM FACTORS, 0.1=>10X ZOOM 'IN OTHER WORDS, THIS IS AN ADD-ON TO SURFACES, ALLOWING 'THEM TO TAKE ON THE FORM OF ANY EQUATION GETUNMASKEDINDEX(MASKEDINDEX) 'SAME AS SAYING OBJMASK[MASKEDINDEX] 'CONVERTS A STABLE OBJECT ID (THAT DOESN'T CHANGE) INTO 'THE ACTUAL INDEX USED IN OBJX,OBJY,OBJZ,OBJROT,etc... UPDATEOBJCENTER INDEX 'UPDATES THE CENTER OF MASS OF AN OBJECT (DONE AUTOMATICALLY) SETSTATICOBJ INDEX,STATE 'SET IF AN OBJECT IS AFFECTED BY GRAVITY AND COLLISIONS 'STATE IS EITHER 1 OR 0 (WHERE 0=AFFECTED BY GRAVITY) ADDVEL INDEX,VX,VY,VZ 'ADD VELOCITY TO A NON-STATIC OBJECT 'YOU COULD ALSO JUST DO: 'INC OBJVX[OBJMASK[INDEX]],VX 'INC OBJVY[OBJMASK[INDEX]],VY 'INC OBJVZ[OBJMASK[INDEX]],VZ And a few other functions, slightly unrelated, but implemented nonetheless:RENDER 'DRAWS THE CURRENT WORLD STATE, REQUIRED TO RUN ONCE EVERY FRAME BUFFER 'PREVENTS FLICKERING BY SWAPPING GPAGES EACH FRAME, DRAWING TO THE ONE NOT 'BEING SHOWN. THIS SHOULD BE RAN ONCE EVERY FRAME, WITH A GCLS DIRECTLY AFTER IT 'THIS ONLY AFFECTS THE TOP SCREEN 'THIS IS AUTOMATICALLY CALLED INSIDE RENDER _RENDER 'RENDERS THE SCENE WITHOUT CALLING BUFFER AND CLEARING THE SCREEN BUFFERBOTTOM 'PREVENT FLICKERING ON THE LOWER SCREEN, PUT GCLS DIRECTLY AFTER IT GETCAMRAY OUT X,Y,Z 'RETURNS THE NORMALIZED DIRECTION THE CAMERA IS FACING GETCAMRAY2D OUT X,Z 'RETURNS THE NORMALIZED DIRECTION THE CAMERA IS FACING EXCLUDING Y RAYTHROUGHOBJ(X,Y,Z,RX,RY,RZ,INDEX) 'CHECK IF THE RAY STARTING AT X,Y,Z AT THE ANGLE RX,RY,RZ 'IS COLLIDING WITH THE OBJECT INSIDE INDEX NORMALIZE X,Y,Z OUT X,Y,Z 'SET THE DISTANCE OF AN X,Y,Z DISPLACEMENT EQUAL TO 1 'WHILE MAINTAINING THE ANGLE CLEARWORLD 'DELETES EVERYTHING IN THE WORLD 'TRIANGLE OPERATION FUNCTIONS ADDTRI INDEX,TAG$,X1,Y1,Z1,X2,Y2,Z2,X3,Y3,Z3,COLOR SETTRI INDEX,X1,Y1,Z1,X2,Y2,Z2,X3,Y3,Z3 'SET A TRIANGLES POSITION DELTRI TRIANGLEINDEX 'DELETE A TRIANGLE SPLITSCREENDRAW X1,Y1,Z1,RX1,RY1,RZ1,X2,Y2,Z2,RX2,RY2,RZ2 'REPLACES THE RENDER FUNCTION 'DRAWS TWO PERSPECTIVES FROM TWO CAMERA POSITIONS AND ANGLES '[ UNDER CONSTRUCTION, STILL A BIT BUGGY ] QUADRUPLEDRAW X1,Y1,Z1,RX1,RY1,RZ1,X2,Y2,Z2,RX2,RY2,RZ2,X3,Y3,Z3,RX3,RY3,RZ3,X4,Y4,Z4,RX4,RY4,RZ4 'REPLACES THE RENDER FUNCTION 'DRAWS FOUR PERSPECTIVES FROM FOUR CAMERA POSITIONS AND ANGLES '3D POINT ROTATION FUNCTIONS ROT X,Y,Z,ORIGINX,ORIGINY,ORIGINZ,ANGLEX,ANGLEY,ANGLEZ OUT X,Y,Z ROTX X,Y,Z,ANGLE OUT X,Y,Z 'ROTATE A POINT JUST AROUND X AXIS ROTY X,Y,Z,ANGLE OUT X,Y,Z 'ROTATE A POINT JUST AROUND Y AXIS ROTZ X,Y,Z,ANGLE OUT X,Y,Z 'ROTATE A POINT JUST AROUND Z AXIS INSERT ARRAY[],INDEX,VALUE 'QUICKLY INSERT AN ELEMENT INTO AN ARRAY REMOVE ARRAY[],INDEX 'QUICKLY REMOVE AN ELEMENT FROM AN ARRAY TRIM$(S$) 'REMOVE SPACES AND NEW LINES FROM THE FRONT AND END OF A STRING 'HSV OPERATIONS HSV2RGB HUE,SATURATION,VALUE OUT RED,GREEN,BLUE RGB2HSV RED,GREEN,BLUE OUT HUE,SATURATION,VALUE HSV(HUE,SATURATION,VALUE) 'RETURNS THE COLOR AS A SINGLE NUMBER, JUST LIKE RGB(R,G,B) DOES FCIRCLE X,Y,RADIUS,FILLCOLOR,BORDERCOLOR 'DRAW A FILLED CIRCLE TEXT X,Y,TEXT$,COLOR 'DRAW CENTERED TEXT ON THE SCREEN PERSPECTIVE X,Y,Z OUT X,Y,Z 'CONVERT IN-WORLD COORDINATES TO SCREEN COORDINATES PERSPECTIVEZ(X,Y,Z) 'QUICKLY JUST CALCULATE THE Z VALUE AFTER PERSPECTIVE ARYOP_PERSPECTIVE X[],Y[],Z[] OUT X[],Y[],Z[] 'CALCULATE FASTER PERSPECTIVE
Four cubes with one smaller one orbiting around it, supports moving the camera using the circle padPRGEDIT 3 EXEC "PRG3:3D.ENGINE" END 'SIM.3D VAR STX,STY,C 'POSITION (0,0,0) SIZE (1,1,1) C=ADDCUBE(0,0,0,1,1,1,#GRAY) C=ADDCUBE(0,1.5,0,1,1,1,#GREEN) C=ADDCUBE(1.5,0,0,1,1,1,#CYAN) C=ADDCUBE(0,0,1.5,1,1,1,#WHITE) C=ADDCUBE(0,0,3,0.5,0.5,0.5,HSV(0,255,255)) 'THE VARIABLE C WAS OVERWRITTEN OVER AND OVER, BUT THIS ONE WE'LL KEEP @LOOP VSYNC STICK OUT STX,STY 'CAMRX,CAMRY ARE USED BY SIM.3D CAMRX=CAMRX-STX*5 CAMRY=CAMRY-STY*5 'ROTATE THE CUBE AROUND THE POINT (0,0,0) ROTATING AROUND THE X AND Y AXIS ROTOBJAROUND C,0,0,0,1,1,0 RENDER GOTO @LOOP You are a cube, you can rotate your camera and move around the world. In the world there is a large 3D Sierpinski tetrahedron fractal generated recursivelyPRGEDIT 3 EXEC "PRG3:3D.ENGINE" VAR I,J 'MAKE AN INSIDE OUT CUBE CENTERED AT POSITION (0,5,50) AND SIZE (120,120,120) I=ADDSKYBOX(0,5,50,120,120,120,RGB(60,60,60)) VAR PLAYER=ADDCUBE(0,0,0,1,1,1,#WHITE) VAR BTN,STX,STY,X,Y,Z 'CALL THE FUNCTION THAT GENERATES THE FRACTAL 'POSITION=(0,30,50) 'SIZE=(40,50) 'DEPTH=3 '(HUE,SATURATION,VALUE)=(RND(360),150,255) SIERPINSKI 0,30,50,40,50,3,RND(360),150,255 @LOOP VSYNC CLS PRINT "FPS ";FPS 'FPS IS CALCULATED INSIDE SIM.3D 'EVERY FRAME, SET THE PLAYER CUBE TO THE SAME POSITION AS THE CAMERA MOVEOBJTO PLAYER,CAMX,CAMY,CAMZ CONTROLS 'CALL THE FUNCTION THAT HANDLES CONTROLS 'PREVENT THE CAMERA FROM GOING UPSIDE DOWN IF CAMRY<-90 THEN CAMRY=-90 IF CAMRY>90 THEN CAMRY=90 RENDER 'CALL THE RENDER FUNCTION IN SIM.3D GOTO @LOOP 'HANDLE DEVICE CONTROLS DEF CONTROLS STICK OUT STX,STY 'CIRCLE PAD INPUT BTN=BUTTON() 'INPUT FOR BUTTONS 'ROTATE THE CAMERA, USE COSINE TO ENSURE IT IS ALIGNED DEC CAMRX,STX*6*COSCAMRZ DEC CAMRY,STY*6*COSCAMRZ IF BTN AND #UP THEN CAMDIST=CAMDIST/1.05 'ZOOMING IN/OUT IF BTN AND #DOWN THEN CAMDIST=CAMDIST*1.05 IF BTN AND #X THEN 'MOVING FORWARD VAR X,Y,Z GETCAMRAY OUT X,Y,Z 'THIS WILL GIVE THE X,Y,Z UNIT ROTATION FACING OUT OF THE CAMERA INC CAMX,X/2 'INCREMENT THE CAMERA POSITION INC CAMY,Y/2 INC CAMZ,Z/2 ENDIF IF BTN AND #B THEN 'MOVING BACKWARD VAR X,Y,Z GETCAMRAY OUT X,Y,Z 'THIS WILL GIVE THE X,Y,Z UNIT ROTATION FACING OUT OF THE CAMERA DEC CAMX,X/2 'DECREMENT THE CAMERA POSITION DEC CAMY,Y/2 DEC CAMZ,Z/2 ENDIF END 'GENERATE A SIERPINSKI TETRAHEDRON FRACTAL 'POSITION=(X,Y,Z) 'SIZE=(WIDTH,HEIGHT) (LENGTH ISN'T INCLUDED SINCE ITS A SQUARE BASE) 'DEPTH IS HOW MANY ITERATIONS TO GO IN (PERFORMANCE TAKES A HUGE HIT, INCREMENTING) 'COLOR=(HUE,SATURATION,VALUE) DEF SIERPINSKI X,Y,Z,W_,H_,DEPTH,HU,SA,VA VAR I,W=W_*0.5,H=H_*0.5 IF DEPTH==0 THEN 'BASE CASE I=ADDPYRAMID(X,Y,Z,W_*2,H_,HSV(HU,SA,VA)) ELSE SIERPINSKI X,Y-H,Z,W,H,DEPTH-1,HU+100,SA,VA SIERPINSKI X-W,Y,Z-W,W,H,DEPTH-1,HU,SA,VA SIERPINSKI X-W,Y,Z+W,W,H,DEPTH-1,HU,SA,VA SIERPINSKI X+W,Y,Z-W,W,H,DEPTH-1,HU,SA,VA SIERPINSKI X+W,Y,Z+W,W,H,DEPTH-1,HU,SA,VA ENDIF END
Categories
Keywords
  • 3D
  • game
  • engine
227 Comment(s) 12Me21 12Me21 Head Admin Second Year My account is over 2 years old Website Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself I thought I should mention this, since it might be useful. ARYOP is a *LOT* slower when working with integer arrays, since it uses a built in feature of the 3DS to perform operations on lists of floating point numbers. So if you give it an integer array, it has to convert it first. (It's still faster than a FOR loop though). Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies Hmm I didn't know that Thanks for the advice! I'll look into it 12Me21 12Me21 Head Admin Second Year My account is over 2 years old Website Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Another interesting ARYOP trick: You can use ARYOP #AOPCLP, OUTPUT, ARRAY1,ARRAY2,ARRAY2 to get the minimum elements. DFrost DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength how do you know? Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies I used this instead of MIN and MAX, clip a number between A and infinity, then infinity and B to get a number between A and B. 12Me21 12Me21 Head Admin Second Year My account is over 2 years old Website Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself why not just clip between A and B directly? Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies Oh, I explained that wrong I meant by clamping A to infinity, then B to infinity, you get MAX(A,B) for every item within A and B, then MIN(A,B) by swapping it. I wonder if it would be possible to make an expression parser/evaluator that converts an equation [of arrays] into a series of ARYOPs. That might actually work Guzzler Guzzler First Week Joined in the very first week of SmileBASIC Source Website Drawing I like to draw! Hobbies Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength This is wonderful, but I believe you knowledge of chess is a little off. The enemy king moved straight into check, and I captured him with a pawn. snail_ snail_ Helper Received for being very helpful around SmileBASIC Source Achievements OSP Contest 2 Contest Participant I participated in the second SmileBASIC Source OSP Contest! Night Person I like the quiet night and sleep late. Express Yourself You can't really blame him for the AI being too dumb unless it made an illegal move. idk how good he claims the AI really is. Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies Oh, hehe Hey, the king tries hard to survive and avoid getting taken down before deciding to commit suicide I'm pretty sure I know the cause, there's a section where I make another capable piece stand in the way to save the king, but I forgot to check if the king was that piece standing in the way to protect the king lmao oops. Guzzler Guzzler First Week Joined in the very first week of SmileBASIC Source Website Drawing I like to draw! Hobbies Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength I see. Anyway, it said I won when I captured him lol. niconii niconii Video Games I like to play video games! Hobbies Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Drawing I like to draw! Hobbies Just for the record, putting your own king in check actually is an illegal move. snail_ snail_ Helper Received for being very helpful around SmileBASIC Source Achievements OSP Contest 2 Contest Participant I participated in the second SmileBASIC Source OSP Contest! Night Person I like the quiet night and sleep late. Express Yourself Oh. I didn't know that was against the rules. Is there some high level strategy that would actually make that advantageous? niconii niconii Video Games I like to play video games! Hobbies Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Drawing I like to draw! Hobbies Nah, if you were allowed to put yourself in check, doing so would just make you lose immediately, since the opponent would then capture your king. I think the point of it is just to keep games interesting. It would be boring to win just from your opponent making a simple mistake like that. Making it an illegal move means they don't lose from doing it, they just have to take it back and make a different move. Another consequence of it being illegal is that stalemates become possible, where if your opponent has no legal moves they can make, the game is declared a draw. This requires more strategy on your part to win a game, because it's not enough to put your opponent in a position where they'd have to move their own king into check, because that's a stalemate and results in a draw. You must put your opponent in check yourself without leaving a way for them to escape to achieve a checkmate. amihart amihart The poll lacks options. I use SmileBASIC on both an original 3DS and a new 3DS. Plus you are missing the Pasocom Mini as an option there (I guess you can just pick "Other" but still). Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies Oh, so let's see, New 3DS, Original 3DS, Switch, New 2DS, Original 2DS, Wii U, Pasocom Mini, Emulator, and Other? What am I missing If someone used a Pasocom Mini I'm gonna be impressed 12Me21 12Me21 Head Admin Second Year My account is over 2 years old Website Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself well, there are the XL versions of the 3DS/new3DS. Is there even a way to transfer programs to the pasocom mini? Y_ack Y_ack If you really want to cover all possible platforms, it might be good to distinguish "3DS Emulator" e.g. Citra and "SmileBASIC Emulator" e.g. otyaSMILEBASIC 12Me21 12Me21 Head Admin Second Year My account is over 2 years old Website Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Well in that case we might as well include my syntax highlighter as well amihart amihart I'm sure you could run PetitModem on the Pasocom Mini, even if you couldn't you could just load programs on it with USB Rubber Ducky. snail_ snail_ Helper Received for being very helpful around SmileBASIC Source Achievements OSP Contest 2 Contest Participant I participated in the second SmileBASIC Source OSP Contest! Night Person I like the quiet night and sleep late. Express Yourself They didn't make a non-XL version of the new2DS by the way. random_god random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Video Games I like to play video games! Hobbies new 2ds is new 2ds xl. snail_ snail_ Helper Received for being very helpful around SmileBASIC Source Achievements OSP Contest 2 Contest Participant I participated in the second SmileBASIC Source OSP Contest! Night Person I like the quiet night and sleep late. Express Yourself New 2DS and New 2DS XL are listed on the poll seperately. Minaboo Minaboo Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Forum Contributor Hidden Achievements Second Year My account is over 2 years old Website Love the project Simeon! I love all your projects because I know you put so much work into them! More than I could ever do haha. I'm just working on a text adventure game! :3 Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies Thanks Mina! DFrost DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength He's a math demigod. Stuff I can't comprehend! DFrost DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Simeon, since I know you made the fractal canvas, so I know you'll get this: DEF DRAWTRI I 'Triangle drawing stuff IF I<LEN(TRIS) THEN DRAWTRI I+1' Make it call itself I used this on a tree - fractal program: GCOLOR RGB(105, 83, 47); DEF Draw X, Y, ROT, L GLINE X,Y,X+SIN(RAD(ROT)),Y+COS(RAD(ROT)) VAR HOLDER = L; IF L>0 THEN DRAW X+SIN(ROT)*L,Y+COS(ROT)*L, ROT - (5,L-5 L = HOLDER IF L<5 THEN GCOLOR RGB(50, 107, 47); DRAW X+SIN(ROT)*L,Y+COS(ROT)*l,ROT + 15,l-5); ENDIF END DRAW 200,400,180,50 'I had to convert from JS Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies That's pretty cool, you should try working in three dimensions! Like, if you look at the code for SIERPINSKI in SIM.3D, you'll see a similar implementation, which can make way cooler 3D shapes too, than just a Sierpinski pyramid DFrost DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength The bad thing is I'm HORRIBLE with 3D. I don't know how to make a perspective projection program. It took me ~2 years to learn how to use trig for triangles. I'm not a trig guy(yet) DFrost DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength (I'm talking about recursion) DFrost DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength How about you use recursion conditionally? DEF DRAWTRI I 'STUFF IF I<LEN(TRIS)-2 THEN DRAWTRI I+1 That would cause recursion. Don't know if it affects speed, though Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies I could but that's way slower and risks getting a stack overflow error (unless SmileBASIC supports tail-recursion) Also I removed the DRAWTRI function and just cut and pasted the code to the one place that used it, to reduce function calls Private message me if you have any more proposals, because they are helping a lot (they just clutter the comment section a little) Thanks for all the feedback! DFrost DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength I wonder if GCLIP could make it faster... DFrost DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength (I think)this is how it goes(by speed):
  1. WHILE
  2. REPEAT
  3. FOR
  4. GOTO
DFrost DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength I might have confused WHILE && REPEAT. MasterR3C0RD MasterR3C0RD Helper Received for being very helpful around SmileBASIC Source Achievements Third Year My account is over 3 years old Website osu! Is Awesome! I love osu! Express Yourself Ummmm GOTO is 100% faster than WHILE tf are you talking about random_god random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Video Games I like to play video games! Hobbies faster but less efficient. spaceturtles spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength What do you mean about efficiency? The amount of space taken up? IAmRalsei IAmRalsei Forum Leader Hidden Achievements First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength true rg DFrost DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Ill test it tomorrow 12Me21 12Me21 Head Admin Second Year My account is over 2 years old Website Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself It depends on what you're doing for an infinite loop, I'd guess it goes GOTO REPEAT WHILE FOR but if you want to repeat code multiple times the fastest way is to just put the code more than once spaceturtles spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength That could be viable but a little difficult maybe. One way I guess this could be done is using the prgedit commands to jump to different lines and to insert any commands or something. Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies So converting a FOR loop into a GOTO or REPEAT loop would be ideal? snail_ snail_ Helper Received for being very helpful around SmileBASIC Source Achievements OSP Contest 2 Contest Participant I participated in the second SmileBASIC Source OSP Contest! Night Person I like the quiet night and sleep late. Express Yourself If you want to rewrite a bunch of boilerplate logic for a millisecond more of processing time, yeah. 12Me21 12Me21 Head Admin Second Year My account is over 2 years old Website Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself No, FOR is the fastest way to make a for loop (of course) The order I listed was just for an infinite loop like FOR I=0 TO 0 STEP 0 which would be slower than something like WHILE 1 DFrost DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength You can do this: VAR I FOR I = 1 TO 5 PRINT I NEXT 'OR... VAR I 'declaration takes time, so this makes it an even fight PRINT 1 PRINT 2 PRINT 3 PRINT 4 PRINT 5 this is because it doesn't have to execute the FOR loop too.(And because it doesn't have to get the value of the variable I (EDIT) Just realized you said the exact same thing. Sorry. Also, I am working on a program that draws textured quads. Very slow. 3 16x16 textures drop FPS from ~60 to ~40. But... if I change the step size from 1 to 2 it goes back to ~60FPS and the textures are dithered effectivly for a good cost of resolution. Also,the way I did it was I first made this code to get GRP5: 'initializing stuff FOR I = 0 TO 511 FOR J = 0 TO 511 ARRAY[I,J] = GSPOIT(I,J) NEXT NEXT to get textures onto an array. (it's better to use an array for textures instead of switching GRPS, GSPOITing, and then rendering due to speed.) I added a few boolean variables for it so you can control how it renders. (it even has animations, too) it runs through the textures multiple times to promote caching on the textures. Also,if a color at(x,y) is transparent black(RGB(0,0,0,0)), it will just go to the next pixel to be rendered the way this dithers is it will draw every other pixel at double the size. I will post screenshots soon.
DFrost DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength @Simeon: I am going to modify the code for: INC FPS,SOME All I'm doing is changing FOR loops to WHILE loops. Never mind. Simeon's code + me = headache *that's a compliment* DFrost DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Not to mention changing from a FOR loop to a WHILE loop will increase FPS, too DFrost DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength I noticed something: I have thought of this: in many 3D engines, there is only one instruction to draw being called at a time. Some examples of this: Raycaster: it only draws one sprite at a time. One "guy" to do all the work. Mode7: one drawing instruction is called in a loop. Only one "guy" to render the whole screen. To fix this, make it render 2 times in a loop or more.One renders the left, the other doing the right for better performance: FOR I = 0 TO LEN(TRIS) STEP 2 DRAWTRI I IF LEN(TRIS) - 1 > 1 THEN DRAWTRI I + 1 NEXT instead of FOR I = 0 TO LEN(TRIS) DRAWTRI I NEXT here is how I know it will improve: First, run this program: ACLS M = MILLISEC FOR I = 0 TO 10000 GLINE RND(400),RND(240),RND(400,RND(240) NEXT GCLS PRINT MILLISEC - M Then, run this: ACLS FOR I = 0 TO 10000 STEP 2 GLINE RND(400),RND(240),RND(400),RND(240) GLINE RND(400),RND(240),RND(400),RND(240) NEXT GCLS PRINT MILLISEC - M Notice the change in FPS... spaceturtles spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength So that "doubles" the fps? DFrost DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength No, just increases. The increase is small but the more polygons drawn increases the saved FPS. Run it and post the results, please.(I'm sneaking on my school com) Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies Hmm Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies That's a really strange improvement I was not aware of, I'll see what I can do... Y_ack Y_ack Be skeptical. DFrost DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength The reason why it is to loop 10001 times is so you can see there is a massive change 12Me21 12Me21 Head Admin Second Year My account is over 2 years old Website Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Reversing the loop probably has a decent effect on speed. FOR I=LEN(whatever)-1 TO 0 STEP -1only has to check the length once rather than every time. snail_ snail_ Helper Received for being very helpful around SmileBASIC Source Achievements OSP Contest 2 Contest Participant I participated in the second SmileBASIC Source OSP Contest! Night Person I like the quiet night and sleep late. Express Yourself Don't bother with this, you're only "saving time" by eliminating half the FOR interations, which are only worth nanoseconds at best, while the quality and maintainability of your code plummets significantly. You should ONLY consider code repetition a valid optimization in extreme cases, such as embedded applications and compilers (compilers might even do this for you with function inlining and related, they're smarter than you.) There are far greater optimization targets to look at. snail_ snail_ Helper Received for being very helpful around SmileBASIC Source Achievements OSP Contest 2 Contest Participant I participated in the second SmileBASIC Source OSP Contest! Night Person I like the quiet night and sleep late. Express Yourself I disabled DLC acceleration and the engine seems to be significantly slower, like 60% drop in performance. This is probably a big area of optimization and you should be stress-testing it with the acceleration turned off (if you aren't already.) I suspect the projection calculation is very slow (or the accelerated version is "too fast", or skipping something.) How are you dealing with unseen geometry? I know you have backface culling, but what about things that you otherwise can't see? If you haven't been working towards it, you should try to entirely avoid handling of tris that aren't inside the view frustum. You can probably avoid projecting them too, but I can't say I have much experience I have with this. It could be a very simple check, or it could be very expensive. It would also be very interesting if you figured out how to throw away occluded geometry, but I'm sure that's siginificantly more complicated. snail_ snail_ Helper Received for being very helpful around SmileBASIC Source Achievements OSP Contest 2 Contest Participant I participated in the second SmileBASIC Source OSP Contest! Night Person I like the quiet night and sleep late. Express Yourself On a side note, why draw a border on the spheres? Aesthetically it's a bit inconsistent. Nothing else has outlines, and a flat-shaded perfect sphere, much like everything else in the engine, would just look like a plain, solid circle. They don't look like they have any depth (not that removing the outline would help significantly, but it would be more consistent with the illusion.) snail_ snail_ Helper Received for being very helpful around SmileBASIC Source Achievements OSP Contest 2 Contest Participant I participated in the second SmileBASIC Source OSP Contest! Night Person I like the quiet night and sleep late. Express Yourself I also noticed a weird graphical bug when geometry is rendered really close to the camera or at a weird/low angle. It looks almost like it "bends" to get out of the way of the camera and it's pretty noticeable in certain situations. It doesn't happen with acceleration disabled. You can see this most obviously with chess, if you zoom up right on top of a piece. I encountered another weird render bug playing chess with acceleration off; the geometry of the other pieces went absolutely crazy and triangles crept onto the edges of the screen when I zoomed in. Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies I've been working on these comments for a few days Yeah I figured out those issues and I'm working on better looking spheres Performance is still extremely important, I made quite a lot of optimizations and my goal here is to exchange memory for performance I also added a render distance limit, so it can run fast but be less visible The slightest changes in an if statement increase the FPS by 1 or 2 frames faster alone, and for that reason, checking if a triangle is on the screen is actually slower than just drawing the triangles regardless 12Me21 12Me21 Head Admin Second Year My account is over 2 years old Website Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself The graphics commands may already check if they are on screen before drawing, so doing your own check might just make things worse. MochaProbably MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies It could be possible though when he was checking for triangles off the screen he may of not rendered it but still performed position calculations on it, but i’d need to check the code to confirm that. snail_ snail_ Helper Received for being very helpful around SmileBASIC Source Achievements OSP Contest 2 Contest Participant I participated in the second SmileBASIC Source OSP Contest! Night Person I like the quiet night and sleep late. Express Yourself I was referring specifically to simple checks in world-space to completely avoid transforms and rendering on certain triangles, if it's trivial. Projection is definitely the bottleneck in this engine. Shelly Shelly What's the FPS like? I haven't had a chance to test it yet. Oh yeah, and good job on progress! hanzo hanzo Even the old 3DS runs fast enough. And I'm sorry if it isn't available in US yet but I've tried it on SmileBASIC for WiiU. It keeps 60fps constantly. I'm looking forward to reading your 3D tutorial. Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies The chess AI is really good at offense, but not as good at defense cause it takes more computing You guys should try it it's fun! UnderCake UnderCake Halloween 2017 Contest Runner Up I placed 2nd in the SmileBASIC Source Halloween 2017 Contest! Programming Contest Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength First Year My account is over 1 year old Website Ooh, I am indeed loving this version spaceturtles spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength You put a chess ai in this? Shelly Shelly Tutorial? spaceturtles spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength I'm guessing being able to understand the documentation will be enough of a tutorial as well as looking at the code. Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies I was working on a tutorial to describe how a 3D engine works but I'm bad at explaining things in that way It's easy to grasp, given a 3D point X,Y,Z you can rotate it around any other point, subtracting the camera angle, then rotating the X,Y,Z around the camera angle, then dividing X and Y by Z+FOV makes it into screen coordinates. Idk how in-depth you want a tutorial to be, I just want the reader to be able to make a 3D triangle that can be moved around and rotated, and only one side of the triangle visible to the camera. I'll release the tutorial soon. CosmicTacoCat CosmicTacoCat Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Video Games I like to play video games! Hobbies Night Person I like the quiet night and sleep late. Express Yourself I'm learning a lot from the 3d engine file! I want to know, are things off screen still being drawn? spaceturtles spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength I think it would be a waste of resources to draw things that aren't visible, but if they actually are drawn off screen they would likely be drawn the same way as they were on screen. CosmicTacoCat CosmicTacoCat Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Video Games I like to play video games! Hobbies Night Person I like the quiet night and sleep late. Express Yourself Yeah I was wondering for that reason. The framerate on some of the sample programs are terrible and I'm hoping part of the problem is just unneeded stuff being drawn. snail_ snail_ Helper Received for being very helpful around SmileBASIC Source Achievements OSP Contest 2 Contest Participant I participated in the second SmileBASIC Source OSP Contest! Night Person I like the quiet night and sleep late. Express Yourself What system are you using? They seem to run great for me. Do you own the DLC pack? IAmRalsei IAmRalsei Forum Leader Hidden Achievements First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength And it runs great on new 3ds with no dlc (I have 1.0) spaceturtles spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Define "great". 100 objects with 10 fps or 100 objects with a lot more? Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies Well the goal here was to have it run 30-60fps on New 3DS with DLC A new version will come soon that only draws the triangles on the screen Currently it only draws triangles on the correct side of the camera, which can also mean off screen The performance improvement isn't much But it fixed lots of graphics glitches But these examples were designed to run well on the New 3DS at minimum, preferred with DLC But that's just because there's a lot more polygons than the o3DS likes to support So it's probably slow for them IAmRalsei IAmRalsei Forum Leader Hidden Achievements First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength i don't know, spaceturtles EDIT:Added a comma so the sentence is grammatically correct spaceturtles spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength It's a pretty cool engine nonetheless. Will it be possible to give the models textures? I'm not sure if using sprites would be faster than a bunch of GPSETs. MochaProbably MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies Sprites without doubt would be faster CosmicTacoCat CosmicTacoCat Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Video Games I like to play video games! Hobbies Night Person I like the quiet night and sleep late. Express Yourself Cool. I'm using an O3DS so it is slow for sure but any improvement to the engine would probably still improve performance on O3DS. Glad to hear it can still be improved. Keep up the good work Simeon. Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies From last night to this morning I've traveled all across the country, 1700 miles gimme some grace, the tutorial wasn't as high of a priority as getting home safely spaceturtles spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength All fifty states? Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies 16 out of 50 states spaceturtles spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Nice Shelly Shelly Did you enjoy your trip? What was it for? UnderCake UnderCake Halloween 2017 Contest Runner Up I placed 2nd in the SmileBASIC Source Halloween 2017 Contest! Programming Contest Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength First Year My account is over 1 year old Website "A professional programming job!" jk Idk but sounds like something I would do. Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies It was literally just for fun, my first time traveling all by myself, skipping school. I spent all of my savings, I met my long distance girlfriend for the first time for our anniversary and was really nervous and everything was perfect spaceturtles spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Has anyone taken the time to actually play that game of hide and seek? IAmRalsei IAmRalsei Forum Leader Hidden Achievements First Year My account is over 1 year old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength i have it's the eleventh one UnderCake UnderCake Halloween 2017 Contest Runner Up I placed 2nd in the SmileBASIC Source Halloween 2017 Contest! Programming Contest Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength First Year My account is over 1 year old Website Awwwh nice, I for one am planning to do the same in about 4.7 years, though probably not quite the same.. But you know many steps to it, like uh getting driving license, getting good at driving and getting my .. well you know who to come with me :) . Which honestly.. yeah that would take a miracle but who cares, if you put your heart to it anything is possible! .. (then we have that one guy complaining that not everything is possible.. wheres King when I need him..) (but still lol) Hope it was a good time though! (I love long car trips!) KingCo KingCo Avatar Taboo I didn't change my avatar for 180 days Website RNG Hidden Easter Eggs Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength @SwanBot, I know this is unrelated to the conversation, but you are taking what I said previously out of context. What I meant was that not everything feels possible for me, not everyone else in existence. UnderCake UnderCake Halloween 2017 Contest Runner Up I placed 2nd in the SmileBASIC Source Halloween 2017 Contest! Programming Contest Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength First Year My account is over 1 year old Website Lol no sorry I was not trying to, I was just saying you have a tendency to argue on things a lot which is totally fine. If that came out wrong I am sorry, I simply meant it as a joke because a lot of times you do argue about things, sorry bout that. MasterR3C0RD MasterR3C0RD Helper Received for being very helpful around SmileBASIC Source Achievements Third Year My account is over 3 years old Website osu! Is Awesome! I love osu! Express Yourself Awwwwwww that's really cute Simeon! It's really cool that it went well! Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies :) MikeATD MikeATD I loaded the 3d engine and entered the code on the first line. It errored by mentioning a duplicate variable. Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies Should be fixed now. Shelly Shelly How does the sound dlc help? spaceturtles spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Under 'What's New" version 1.1; "DLC is fully implemented! The engine runs much smoother when the Advanced Sound DLC is purchased, the application now only needs to run a few ARYOP operations each frame." Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies It let's you do mass calculations instantly on arrays The calculations are limited to adding, multiplying, subtracting, clamping, multiply&adding, or linear interpolating arrays but if you can build an algorithm with only ARYOP, avoiding loops all together, then that's like infinite power of processing And the only thing making the algorithm slow is the overhead of filling the arrays in the first place And the FOR loop for drawing the triangles :/ That's the SmileBASIC devs giving us the full power of the 3DS in a limited little function 12Me21 12Me21 Head Admin Second Year My account is over 2 years old Website Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself You might be able to reduce the number of required slots (useful if you're using more than 1 other library) by doing PRGEDIT 2:EXEC "PRG2:3D.LOADER"And then in the engine loader: PRGDEL -1 PRGSET CODE$ EXEC 2 Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies Oh, I thought it was impossible to do that (without having the loader inside the user's program) Thanks that really helps!
1 2 3