Here's a screensaver I made using the 3d assets from my latest project. Some of the ships are a bit scuffed if you look too closely.
V 1.2.1:
Inspired by Profi06's URL Dodecahedron demo I added a fade in and out for the 3d models.
V 1.2:
Changed engine to use matmul3d() and refined most models to look better on a big screen. Ironically it seems to perform worse in the web browser now...
V 1.1:
Added a few extra ships
Awesome work. Are you making an Elite clone as your current project?
Yes, but not a Picotron clone @SVEDEN11. I'm making it for Pico8.
Oh it's nice! Is it theoretically possible to push your own OBJ files into this?
@maleficmax No, not literal .obj files at least. Each model is a list of points and a list of lines between them stored as a table. I made each of the models in a hacked-together editor. For example, here is the Cobra Mk3:
model={ points={ {-5,2,10.5}, {4,0,-8}, {-4,0,-8}, {0,-3,0}, {5,2,10.5}, {-11.5,-2,10}, {11.5,-2,10}, {15,1,10.5}, {-15,1,10.5}, {0,-3,10}, {14,0,6}, {-14,0,6}, {-2.2459,0.25,10.3719}, {2.2459,-1.5,10.3719}, {-2.2459,-1.5,10.3719}, {5.495,0.25,10.3719}, {2.2459,0.25,10.3719}, {-5.495,-1.25,10.3719}, {-5.495,0.25,10.3719}, {5.495,-1.25,10.3719}, {0,0,-8}, {0,0,-11}, }, lines = { {"a",4,3,2,4}, {"a",5,2,3,1,5}, {"f",2,7,4,2}, {"f",4,6,3,4}, {"a",7,10,4,7}, {"a",10,6,4,10}, {"a",3,6,12,3}, {"a",2,11,7,2}, {"a",7,11,8,7}, {"a",9,12,6,9}, {"a",8,5,1,9,6,10,7,8}, {"f",13,19,18,15,13}, {"f",16,17,14,20,16}, {"l",22,21,8}, {"a",2,5,8,11,2}, {"a",9,1,3,12,9}, } } |
The entire system really needs to be reworked if I ever do anything else with it.
@hwd2002
Thank you for explaining it! I'm thinking of writing some script Into convert obj ton this kind of format...
@maleficmax I don't think such a tool will work well even if you translate every bit of geometry correctly. This rudimentary engine doesn't use triangles for faces, it doesn't understand concave shapes, and it can't tell when one face is in front of another.
The problem is this "format" is made to recreate a single game's aesthetics and nothing more. Translating a 3d model literally is going to look bad because OBJ files are made with an entirely different use in mind.
With all that being said, I'll try to explain a few quirks of the format:
- Faces can have more than 3 corners, but only the first three corners will be used to calculate the normal vector. This means that you need to make sure any face that is 3+ corners is perfectly flat.
- Faces are always drawn line-by-line across each point and don't automatically finish a shape.
- The single-letter string at the start of each face's table defines what it is: "l" is a line, "c" is a curve across four points (used for planet rendering and helicopter rotors), "f" and "a" are for faces, with no difference between them.
- for lines across two points, the engine assumes these are details on the previous face and automatically culls them if the last face wasn't drawn. However, if you want a line to render all the time it needs a 4th entry into its table:
{"l",2,3} --This is only visible when the previous face is visible {"l",2,3,true}--this is visible all the time, including through other faces
- The models in the cartridge are "compressed" and are split apart with imp_obj() during the start of the program. This was for Pico-8's spritesheet and can be ignored in Picotron. If you want to quickly try your own model in this code, just set
ship.model
to your own model in the_init()
function.
I hope this helps!
[Please log in to post a comment]