LoginLogin
Might make SBS readonly: thread

Poly3D

Root / Submissions / [.]

kevinfoleyCreated:
Download:CPC3Q3CJ
Version:1.3.0Size:263 KB
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 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.3.0 (12 March 2024)
  • Model Editor: Added buttons for copy/pasting face colors (this was in 1.1.0 release notes but not actually implemented?)
  • Model Editor: You can now press ZL to show vertex IDs for all vertices
  • Model Editor: In Face Mode, added a white line to show face normal (only relevant for 3DO export)
  • Model Editor: Added a button for exporting models in the 3DO format used by Star Wars: Dark Forces. You would then need to transfer the model to a PC using PetitModem or similar.
  • Model Editor: The size of the current model (in numeric values) is shown in the upper-right corner. Each vertex is 3 values (x/y/z) and each face is 6 values (3 vert indices and R/G/B color channels).
  • Model Editor: Added a Help button.
  • Model Editor: Major fixes to Undo/Redo functionality.
  • Model Editor: Other minor UX improvements.
Version 1.1.0 (13 December 2018)
  • Added FIRSTPERSON example game. Move around and shoot targets as fast as possible. Demonstrates depth-sorting, 3D camera movement and rotation, and basic collision detection. 60 fps on a New 3DS
  • (No engine changes)
Version 1.1.0 (2 November 2018)
  • 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
  • Engine, Model Editor: Fixed numerous issues with axes being double-or-triple reversed
  • Model Editor: Fixed vertex movement controls sometimes being reversed
  • Model Editor: Reversed the z-axis. Now the coordinate system behaves like Blender 3D, as I had originally intended
  • Model Editor: Added some parsing code for OBJ files (not tested; how would I get an OBJ file into SB in the first place?)
  • Model Editor: Added buttons for copying and pasting face colors
  • Many other minor bug fixes
Version 1.0.1 (24 October 2018)
  • Fixed error if you deleted all faces from a model
  • Fixed slider values being constantly reapplied until you tapped somewhere else on the touch screen
  • Save/Load remembers the last file name you entered, so that you don't have to keep re-typing it each time you save
  • Added an example model Pumpkin.3D
Version 1.0 (24 October 2018):
  • Rewrote Poly3D into a compact common library that can be easily used by other programs
  • 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
  • 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 Controls for FirstPerson: Circle-pad to move, touch-screen to aim, L or R to shoot 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.
  • To create new vertices, press "Add Vert" while in Vertex mode.
  • 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.
  • 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

Replying to:PixelStudio
"*Actual gameplay features" Hype hype hype
Er, okay?

Replying to:DasEtwas
What happens if two polys overlap?
There's an algorithm to determine the draw order of polygons; if two overlap, it's going to draw one of them on top of the other based on that algorithm. That can look weird but doesn't come up very often.

Replying to:Minxrod
This is so neat :D But I have no idea how the models are made. I don't understand how they are defined... if someone knows can they explain to me please?
They're defined in data at the bottom of the program. Each model consists of a set of vertices and a set of faces that connect the vertices. The way I bundled them together is kind of messy and hard to follow, but I'm hoping to improve it in the next version. If you don't know what "vertices" or "faces" are, you might want to do some research on 3D modelling in general.

Replying to:Defaultio
1 word: a person. Just a person. Do it.
Yes, make a person.. like a polygonal model of a person. doesn't have to be good.

Replying to:Defaultio
1 word: a person. Just a person. Do it.
Sorry, this sounds like a waste of time. A person isn't very interesting unless it's animated, and animating a person in code would be hell.

Replying to:Defaultio
1 word: a person. Just a person. Do it.
It doesn't seem boring to me....

Replying to:Minxrod
This is so neat :D But I have no idea how the models are made. I don't understand how they are defined... if someone knows can they explain to me please?
Oh, you define vertices and then basically sets of those vertices?

You should make a custom model creator. Depending on the scale of this, this could be used to make 3D game pieces in SmileBASIC. Comboned with the raycaster, you have a full 3D game.

Replying to:h267
You should make a custom model creator. Depending on the scale of this, this could be used to make 3D game pieces in SmileBASIC. Comboned with the raycaster, you have a full 3D game.
I think someone is working on one now

Replying to:h267
You should make a custom model creator. Depending on the scale of this, this could be used to make 3D game pieces in SmileBASIC. Comboned with the raycaster, you have a full 3D game.
Well it might be too slow for a 3d polygon and a raycaster all at once. SB can only do so much.

Replying to:h267
You should make a custom model creator. Depending on the scale of this, this could be used to make 3D game pieces in SmileBASIC. Comboned with the raycaster, you have a full 3D game.

Replying to:h267
You should make a custom model creator. Depending on the scale of this, this could be used to make 3D game pieces in SmileBASIC. Comboned with the raycaster, you have a full 3D game.
Where is this program, what happened to it and how? YOU REALLY PROVED ME WRONG.... OMG I WUV DIS

Replying to:h267
You should make a custom model creator. Depending on the scale of this, this could be used to make 3D game pieces in SmileBASIC. Comboned with the raycaster, you have a full 3D game.
Ha.

Replying to:h267
You should make a custom model creator. Depending on the scale of this, this could be used to make 3D game pieces in SmileBASIC. Comboned with the raycaster, you have a full 3D game.
Yes make it please!

Replying to:h267
You should make a custom model creator. Depending on the scale of this, this could be used to make 3D game pieces in SmileBASIC. Comboned with the raycaster, you have a full 3D game.
I have developed a simple 3D model editor and will release it soon.

Several years after the last release, I finally got the urge to start working on this project again. I have completely overhauled the original messy code into a highly streamlined common library. I've also developed a simple 3D model editor to go with the engine. I haven't uploaded the new code yet, but will do so in the next week or two.

Replying to:kevinfoley
Several years after the last release, I finally got the urge to start working on this project again. I have completely overhauled the original messy code into a highly streamlined common library. I've also developed a simple 3D model editor to go with the engine. I haven't uploaded the new code yet, but will do so in the next week or two.
That's exciting! I'll be sure to be one of the first to check it out. No rush!

Replying to:kevinfoley
Several years after the last release, I finally got the urge to start working on this project again. I have completely overhauled the original messy code into a highly streamlined common library. I've also developed a simple 3D model editor to go with the engine. I haven't uploaded the new code yet, but will do so in the next week or two.
I've uploaded the new version with model editor, and updated the download key.

It's a bit difficult to control. but I can see this being really handy for 3D model making! The code is pretty straightforward, and well documented. Can you possibly add an export-to-text option, or a better way to access .3D/.3DM files? If I could have access to every triangle point, then this would be really convenient for me, and other developers here too! Thanks for making this!

Replying to:Simeon
It's a bit difficult to control. but I can see this being really handy for 3D model making! The code is pretty straightforward, and well documented. Can you possibly add an export-to-text option, or a better way to access .3D/.3DM files? If I could have access to every triangle point, then this would be really convenient for me, and other developers here too! Thanks for making this!
Thanks! The code for exporting and importing models is at the bottom of P3DMODELEDITOR. That should give you all the information you need to access the data, and is much faster to work with than text. The save format is really very straightforward, and it should be easy to write a parser (or copy and modify my own parsing code). Is there a reason you wanted text rather than an array of numbers? I am working on an update that fixes some issues with coordinates being double-or-triple-reversed, and will probably release that in the next few days.