? Poly3D ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Poly3D

Submitted
Updated
Author
kevinfoley
Public Key
E5533VQV
Min. Compat.
All
Version
1.1.0
Size
263 KB
Rating
20 votes
Description Poly3D is a flat-shaded 3D engine for SmileBASIC. The engine supports flat-shaded polygonal 3D models defined with triangles (no lighting support). It is a lightweight engine optimized for performance. This engine evolved from my earlier Wire3D engine. Performance tests (New 3DS, rendering some rotating models, no gameplay code): 0 - 190 triangles onscreen: 60fps 190 - 390 triangles onscreen: 30fps 390 - 630 triangles onscreen: 20fps 660 triangles onscreen: 15fps Version 1.1.0 (2 November 2018)
  1. Added STARBLITZ example game. Fly your spaceship and avoid the obstacles. Demonstrates depth-sorting, 3D movement and rotation, and basic collision detection. 60 fps on a New 3DS
  2. Engine, Model Editor: Fixed numerous issues with axes being double-or-triple reversed
  3. Model Editor: Fixed vertex movement controls sometimes being reversed
  4. Model Editor: Reversed the z-axis. Now the coordinate system behaves like Blender 3D, as I had originally intended
  5. Model Editor: Added some parsing code for OBJ files (not tested; how would I get an OBJ file into SB in the first place?)
  6. Model Editor: Added buttons for copying and pasting face colors
  7. Many other minor bug fixes Version 1.0.1 (24 October 2018)
    1. Fixed error if you deleted all faces from a model
    2. Fixed slider values being constantly reapplied until you tapped somewhere else on the touch screen
    3. Save/Load remembers the last file name you entered, so that you don't have to keep re-typing it each time you save
    4. Added an example model Pumpkin.3D
    Version 1.0 (24 October 2018):
    1. Rewrote Poly3D into a compact common library that can be easily used by other programs
    2. Added Poly3D Model Editor v1.0 (compatible with New 3DS or Circle Pad Pro). This is a simple model editor with limited features, but should be good enough for creating simple models. - Create 3D models with colored faces - Save / Load 3D model files - Camera controls - In addition to the main camera, the model is displayed as a wireframe in three orthogonal views (Front, Left, Top) on the touch screen - Undo / Redo functionality
    3. Added a GUI library which can be used to draw interactive buttons, checkboxes, and sliders on the touch screen Note: I released this latest update much earlier than I was planning, so that others can use the included model editor. This version does not contain any other example projects. I am hoping to release another update sometime in the next month or so with additional examples of the engine in use, but can't make any promises. Hopefully I won't disappear for 3 years again! :)
    Version 0.8 update: *Supports rotation on all 3 axes (uses Euler rotation and suffers from gimbal lock, so I don't recommend rotating on all 3 axes at the same time) *Uses GPAGE buffer to eliminate draw flicker (thanks Trinitro!) *Fixed support for multiple models in a single scene *Added two new models, a cube and a Starwing, which definitely isn't borrowed from any old Nintendo games *Added more models and animations to the sample scene to better demonstrate the engine. The sample scene includes over 200 polys and runs at 60fps on a New 3DS Version 0.7 (initial): *Supports 3D models with per-face coloration *Supports instancing models, reducing memory usage *Models can be translated and rotated *Depth-sorting so faces are rendered in the correct order *Screen-space culling - models that lie outside the screen coordinates are not processed, reducing render time *User can walk around with D-pad or analog stick and aim with touch-screen or gyro controls *Faces darken with distance, so models gradually fade into background *Radar on lower screen shows player position in relation to models *Code is reasonably well-documented *Sample scene included Planned features for the future: *Support for lighting *Scaling support for models *Actual gameplay features Known issues: *There is some distortion to the models when rotating on X and Y axis at the same time; I'm looking into it
Instructions Controls for Starblitz: D-Pad moves camera, Circle Pad moves ship Instructions for using the model editor: Load P3DModelEditor into Slot 0, and press Start. The model editor launches with a default cube model. The general idea is that you position points, called "vertices", and then connect them with triangles, called "faces". For example, a cube has 8 corners, so it has 8 vertices. Each side of a cube is a square, which requires two triangles to draw, so 12 faces in total. Controls: - A: Start moving vertex; confirm vertex position (Vertex mode). Confirm selected vertex (Add Face mode) - B: Cancel moving vertex (Vertex mode) - X: Select next vertex/face - Y: Select previous vertex/face - L: (hold) Increase movement speed (while moving vertex in Vertex mode) - R: (hold) Decrease movement speed (while moving vertex in Vertex mode) Touch screen controls should be mostly self-explanatory.
  1. To create new vertices, press "Add Vert" while in Vertex mode.
  2. To create new faces, press "Add Face". Select the first vertex and press "A". Repeat for two more vertices. When three have been selected, a new face (triangle) is created that connects the three selected vertices.
  3. The RGB sliders can be used to edit the color of the selected face in Face mode. They have no effect in other modes.
Note: this engine is unrelated to the P3D engine; the "P3D" in "P3DModelEditor" is short for "Poly3D".
Notes Includes: - POLY3D.LIB: Engine library - GUILIB.LIB: Touchscreen GUI library - P3DMODELEDITOR: Model editor for Poly3D - STARBLITZ: simple example game, fly your ship and avoid crashing into obstacles
Categories
Keywords
  • 3d
  • engine
  • render
  • model
  • editor
82 Comment(s) Ptcguy Ptcguy First Week Joined in the very first week of SmileBASIC Source Website Minecraft Is Awesome! I love Minecraft! Express Yourself Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength With my 3ds (non-new) I get 10-12 fps (when looking at all of the models at once). kevinfoley kevinfoley Does anyone know if SmileBoom might reject this because it includes Arwings and TIE Fighters? They didn't reject the old version which only included TIEs, but maybe I'm pushing my luck here. TheRealGamerBoy07 TheRealGamerBoy07 You can fix it, I know you can! It's just buggy at the moment! kevinfoley kevinfoley Well, I just issued an update. Which bugs are you referring to? JustGreat JustGreat First Month Joined in the very first month of SmileBASIC Source Website Avatar Taboo I didn't change my avatar for 180 days Website Night Person I like the quiet night and sleep late. Express Yourself This is the first programming language that I've really done much with, so I'm still learning the ropes. JustGreat JustGreat First Month Joined in the very first month of SmileBASIC Source Website Avatar Taboo I didn't change my avatar for 180 days Website Night Person I like the quiet night and sleep late. Express Yourself I should have replied to my own comment... Shoot JustGreat JustGreat First Month Joined in the very first month of SmileBASIC Source Website Avatar Taboo I didn't change my avatar for 180 days Website Night Person I like the quiet night and sleep late. Express Yourself I added "wait 1" to the beginning of the loop, and I can confirm that this program runs perfectly at 30fps on the original non-xl 3DS. 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 VSYNC would've been better. WAIT 1 just introduces another frame bottleneck. 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 wait this is a troll isn't it cj add comment editing Chemicalex Chemicalex Drawing I like to draw! Hobbies RNG Hidden Easter Eggs Video Games I like to play video games! Hobbies No, his idea does work. 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 WAIT 1 explicitly forces a frame, while VSYNC will not wait that frame if the display refresh already happened or whatever. Different things are going on. SamKitsune SamKitsune It's good to have another person working on a 3D tool. Let's see how far it goes. Super_Defaultio Super_Defaultio Video Games I like to play video games! Hobbies Day Person I like the warm sunshine and wake up early! Express Yourself Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself YES OH MY GAD! I remember when trinitro did this in ptc but with an oddly shaped rhombus. Its so cool that you can now texture polygons? in sb now. Also, will test on old 3ds non xl. Super_Defaultio Super_Defaultio Video Games I like to play video games! Hobbies Day Person I like the warm sunshine and wake up early! Express Yourself Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Test results: 60 fps on old non-xl 3ds confirmed. But it flickers, a lot. Just like trinitro 3d engine. Check his engine to solve the problem please. Super_Defaultio Super_Defaultio Video Games I like to play video games! Hobbies Day Person I like the warm sunshine and wake up early! Express Yourself Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself You can use HARDWARE to check to see what the users' 3ds is so you can then make it run specific code to make the tie fighters not flicker. triangle triangle First Week Joined in the very first week of SmileBASIC Source Website Query Denied Hidden Easter Eggs Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength I use a buffer. In my case it's using SPPAGE, but this application would probably use a GPAGE buffer. You draw on one graphic page while displaying the other, then switch it around for the next frame and repeat. It guarantees no flicker, no matter how laggy and what system. kevinfoley kevinfoley I don't understand. You're saying Trinitro's 3D engine flickers, so I should check his 3D engine to solve the flickering in my engine? Either way, he has a different engine rendering different things, so we wouldn't likely have the same solution. Try turning the radar off and see if that fixes the flickering for you. It's also possible I put the VSYNC in the wrong spot; I remember with Wire3D I found that flickering varied depending on where I put the VSYNC. kevinfoley kevinfoley Missed your reply. Oi, why didn't I think of adding a buffer? I'll have to look into that. jamieyello jamieyello First Day Joined on the very first day of SmileBASIC Source Website Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies If you want to add a buffer you can do it with gpage. We use to do it with gcopy until we found out gpage was a lot faster. 1 2