.obj File Viewer
I made a small viewer for wireframe .obj files in 560 characters!
Controls:
Arrow keys: rotate object.
Z/X: Zoom in/out
How to use
To use this program, you need to do a few steps (I've got a few premade examples, don't worry!):
1. Using the modelling program of your choice (I recommend Blender), create a model and make it wireframe (I.E. only edges and vertices, no faces).
2. Export the model as a .obj file to the directory of your choosing.
3. Right click on the .obj file, choose "Open With", then choose "Notepad." This will open up the .obj file in it's plaintext form. You should see a bunch of lines starting with "V" and a bunch of lines starting with "L" (both lowercase). If you do not see any starting with "L", please make sure you exported your model properly.
4. Select the entire file, copy, and then in the Pico-8 program, paste the data. This should automatically start running and rendering your model!
Examples:
Cube Example
# Blender v2.80 (sub 75) OBJ File: '' # <a href="http://www.blender.org">www.blender.org</a> mtllib cube.mtl o Cube v 1.000000 1.000000 0.000000 v 1.000000 0.000000 0.000000 v 1.000000 1.000000 1.000000 v 1.000000 0.000000 1.000000 v 0.000000 1.000000 0.000000 v 0.000000 0.000000 0.000000 v 0.000000 1.000000 1.000000 v 0.000000 0.000000 1.000000 l 6 8 l 2 6 l 1 2 l 8 7 l 3 4 l 5 6 l 3 7 l 1 3 l 8 4 l 7 5 l 5 1 l 4 2
Blender's Suzanne Example (Monkey)
# Blender v2.80 (sub 75) OBJ File: '' # www.blender.org mtllib monkey.mtl o Suzanne v 0.610885 0.131629 0.586442 v -0.610937 0.131039 0.587046 v -0.359883 -0.031818 0.628930 v 0.357651 -0.031414 0.630139 v 0.243007 0.197760 0.806968 v 0.104181 0.124650 0.688257 v -0.103398 0.123882 0.687603 v 0.310483 0.366450 0.801374 v 0.164324 0.426898 0.686335 v -0.165266 0.426212 0.688179 v -0.507601 0.476156 0.599886 v -0.312893 0.368176 0.801237 v 0.440061 0.338759 0.774757 v 0.476393 0.499536 0.596389 v 0.467226 0.195792 0.765747 v -0.266359 0.152231 0.816919 v 0.359225 0.127989 0.810862 v -0.482189 0.245834 0.760820 v 0.019565 0.342362 0.826742 v 0.000000 -0.187500 0.796875 v 0.011302 0.428559 0.631357 v 0.000000 0.898438 -0.546875 v 0.000000 0.562500 -0.851562 v 0.000000 -0.382812 -0.351562 v -0.223556 -0.201501 0.529773 v 0.224471 -0.188691 0.533773 v -0.382367 -0.901417 0.537600 v 0.364604 -0.932295 0.529003 v 0.805412 0.161779 0.424668 v 0.839258 0.392556 0.623111 v 0.252652 0.768536 0.744766 v -0.254959 0.768787 0.746361 v 0.000160 0.419944 0.745291 v -0.167964 0.346756 0.780286 v 0.190078 0.143213 0.762819 v 0.380631 0.061210 0.732077 v 0.633963 -0.049547 0.564063 v 0.590127 0.326440 0.675980 v 0.326178 0.445843 0.756755 v -0.067289 -0.763500 0.733078 v -0.082174 -0.859123 0.701864 v 0.000000 -0.195312 0.750000 v 0.000000 -0.140625 0.742188 v -0.626528 -0.046442 0.565679 v -0.721560 0.394926 0.688836 v -0.251849 0.649591 0.847767 v 0.252314 0.656193 0.850292 v -0.100128 -0.119634 0.797787 v 0.137008 -0.240840 0.736493 v 0.271362 -0.883045 0.653126 v -0.273018 -0.887842 0.648691 v -0.006535 -0.986594 0.588254 v 0.010499 0.056596 0.733748 v 0.108266 -0.222724 0.824441 v 0.100718 -0.120293 0.795323 v -0.012610 -0.337904 0.759037 v -0.133592 -0.238482 0.761221 v 0.088700 -0.846101 0.709877 v 0.095970 -0.794843 0.642880 v -0.077156 -0.822747 0.635515 v -0.325356 0.444610 0.756732 v -0.600128 0.320131 0.675418 v -0.395396 0.059328 0.727195 v 0.189889 0.364514 0.779985 v -0.186725 0.138914 0.765533 v -0.261462 0.709033 0.606235 v 0.261293 0.709077 0.606394 v -0.465446 0.526295 0.475370 v -0.847713 0.411333 0.564887 v -0.803836 0.161472 0.420019 v -0.507134 -0.059427 0.441865 v 0.448686 -0.091515 0.446359 v 0.000000 0.984375 -0.078125 v -0.006435 -0.066002 -0.786360 v 0.004324 -0.498594 0.307540 v 0.845894 0.230519 0.070208 v -0.857556 0.262268 0.029464 v -0.833837 0.352678 -0.389041 v 0.460938 0.437500 -0.703125 v -0.475168 0.415371 -0.698173 v -0.703371 -0.057951 -0.130756 v 0.682397 -0.070674 -0.169580 v -0.538245 -0.137530 -0.165934 v -0.214040 -0.412683 0.345372 v 0.308338 -0.895445 0.400086 v -0.323732 -0.902985 0.403462 v 0.019839 -0.968054 0.440766 v 0.202435 -0.410482 0.307899 v 0.357511 -0.254903 -0.238203 v -0.350930 -0.234859 -0.432622 v 0.390516 -0.062333 -0.584546 v 0.453125 0.867188 -0.382812 v -0.479574 0.910625 -0.276136 v 0.468870 0.899754 0.154037 v -0.347536 0.881526 0.300212 v 0.462767 0.523681 0.467527 v 0.708940 0.405706 0.304794 v -0.709371 0.412748 0.285817 v -0.775505 0.572333 0.111207 v 0.777596 0.570639 0.110377 v 0.794794 0.599280 -0.315884 v -0.781255 0.611861 -0.341845 v -0.520739 0.006918 -0.524089 v -0.819314 -0.102497 -0.124482 v -1.032358 -0.049233 -0.305543 v -1.239188 0.057363 -0.405821 v -1.362860 0.314011 -0.444806 v -1.210292 0.488812 -0.397984 v 0.858121 0.361751 -0.197084 v -0.978155 0.375529 -0.256633 v 1.209058 0.488063 -0.396949 v 1.233473 0.248501 -0.434293 v 1.150649 0.050186 -0.439663 v 1.045250 -0.076586 -0.315569 v 0.792882 -0.112899 -0.120632 v 0.854918 -0.000661 -0.289537 v -1.211675 0.314717 -0.443951 v -0.959377 0.304765 -0.343029 v 0.792365 0.103191 -0.305231 v 0.728137 -0.047455 0.061854 v -0.840617 0.359861 -0.192483 v -0.852142 -0.002097 -0.291164 v -0.792301 0.103898 -0.308172 v 0.961921 0.300994 -0.348691 v 1.168777 0.332948 -0.431998 v -1.161751 0.058561 -0.468347 v -1.063109 0.215490 -0.383200 v 0.827606 0.361028 -0.412941 v -1.221069 0.490628 -0.543556 v 1.250000 0.468750 -0.546875 v 1.363109 0.310932 -0.444560 v 1.319944 0.077403 -0.488282 v -1.220812 -0.012531 -0.548603 v 1.039062 -0.085938 -0.492188 v 0.738105 -0.086049 -0.332369 v -0.789062 -0.125000 -0.328125 l 2 18 l 1 4 l 2 3 l 17 4 l 3 16 l 5 6 l 6 4 l 7 16 l 3 7 l 5 8 l 8 9 l 9 6 l 7 10 l 8 14 l 14 9 l 10 11 l 11 12 l 8 13 l 13 14 l 13 1 l 1 14 l 12 16 l 16 18 l 15 17 l 17 5 l 17 8 l 17 13 l 52 28 l 50 52 l 52 51 l 27 52 l 28 50 l 28 26 l 26 49 l 49 50 l 51 57 l 57 27 l 55 26 l 37 55 l 48 44 l 25 48 l 29 37 l 44 70 l 29 30 l 44 45 l 45 69 l 30 31 l 47 30 l 45 46 l 32 69 l 31 33 l 19 47 l 33 32 l 33 19 l 46 19 l 39 47 l 34 46 l 46 61 l 39 38 l 38 30 l 45 62 l 38 37 l 37 36 l 44 63 l 36 35 l 35 55 l 48 65 l 53 55 l 48 53 l 19 64 l 34 19 l 35 64 l 19 53 l 41 51 l 41 40 l 40 51 l 58 50 l 40 56 l 54 49 l 43 55 l 43 42 l 42 20 l 48 20 l 20 54 l 54 55 l 48 54 l 57 54 l 54 56 l 53 43 l 49 55 l 48 57 l 25 27 l 58 41 l 58 59 l 60 40 l 60 59 l 34 65 l 63 62 l 61 34 l 33 21 l 21 66 l 66 32 l 31 96 l 96 67 l 66 68 l 68 32 l 68 69 l 30 97 l 69 70 l 70 71 l 71 44 l 37 72 l 84 75 l 86 84 l 85 86 l 87 86 l 87 28 l 85 28 l 87 85 l 88 28 l 85 88 l 88 26 l 71 25 l 91 74 l 74 90 l 24 74 l 91 89 l 89 24 l 24 90 l 75 24 l 89 88 l 88 75 l 84 90 l 76 29 l 72 120 l 81 71 l 70 77 l 74 23 l 23 79 l 79 91 l 74 80 l 80 23 l 95 94 l 93 95 l 22 73 l 94 92 l 92 22 l 22 93 l 23 22 l 92 79 l 80 93 l 69 98 l 98 99 l 100 101 l 99 102 l 101 128 l 80 78 l 78 102 l 128 79 l 94 101 l 94 100 l 99 95 l 94 96 l 96 97 l 98 68 l 68 95 l 95 21 l 21 96 l 68 21 l 76 97 l 98 77 l 99 77 l 76 109 l 109 101 l 102 121 l 78 121 l 72 88 l 84 83 l 89 82 l 81 83 l 83 25 l 135 91 l 91 128 l 80 103 l 103 78 l 74 103 l 83 103 l 103 90 l 108 110 l 121 108 l 111 112 l 112 131 l 107 117 l 117 108 l 108 107 l 112 113 l 113 132 l 107 106 l 114 132 l 113 114 l 106 105 l 114 115 l 105 104 l 116 115 l 126 106 l 126 117 l 111 125 l 117 118 l 118 110 l 82 115 l 104 83 l 77 81 l 110 121 l 81 122 l 119 82 l 116 119 l 81 123 l 109 82 l 121 123 l 110 123 l 121 77 l 118 123 l 105 126 l 113 116 l 122 126 l 127 122 l 116 125 l 113 125 l 127 117 l 125 124 l 134 114 l 115 135 l 135 134 l 133 136 l 136 104 l 105 133 l 134 132 l 106 133 l 132 131 l 107 133 l 130 111 l 131 130 l 128 109 l 130 128 l 121 129 l 78 129 l 128 134 l 135 128 l 130 132 l 103 136 l 1 15 l 13 15 l 12 10 l 11 2 l 18 12 l 18 11 l 75 85 l 52 87 l 58 52 l 58 56 l 40 58 l 58 60 l 41 60 l 27 51 l 25 57 l 44 25 l 43 48 l 43 20 l 20 55 l 56 49 l 56 57 l 58 49 l 26 72 l 37 26 l 72 29 l 120 76 l 82 120 l 135 82 l 125 112 l 131 111 l 111 109 l 119 109 l 82 116 l 119 124 l 109 124 l 76 100 l 29 97 l 37 30 l 100 97 l 72 89 l 27 84 l 25 84 l 90 83 l 71 83 l 102 93 l 80 102 l 101 92 l 93 73 l 95 73 l 46 33 l 46 32 l 44 62 l 65 63 l 53 65 l 34 53 l 62 61 l 35 53 l 38 36 l 64 39 l 31 47 l 67 31 l 73 94 l 67 21 l 78 136 l 104 81 l 122 104 l 123 122 l 121 81 l 122 105 l 127 126 l 118 127 l 106 117 l 129 107 l 129 108 l 133 129 l 27 86
Source:
cls()u=unpack
p={}e={}q=0w=0m=1s=split::x::
o=stat(4)print("paste in .obj file",28,61)
if(#o<1)goto x
for i in all(s(o,"\n"))do
d=s(i," ")
if(ord(i)==118)add(p,d)
if(ord(i)==108)add(e,d)end
camera(-64,-64)::_::
cls()s=sin(q)d=cos(q)f=sin(w)g=cos(w)for i in all(e)do
_,x,y,z=u(p[i[2]])_,a,b,c=u(p[i[3]])x,z=x*d+z*s,d*z-x*s
a,c=a*d+c*s,d*c-a*s
y,z=y*g-z*f,y*f+z*g
b,c=b*g-c*f,b*f+c*g
a*=m
b*=m
c*=m
x*=m
y*=m
z*=m
c-=4z-=4x=x/z*64y=y/z*64a=a/c*64b=b/c*64line(x,y,a,b)end
b=btn()q+=(b\2%2-b%2)/30w+=(b\8%2-b\4%2)/30
if(btn(4))m+=.01
if(btn(5))m-=.01
flip()goto _
Comments
Log in with itch.io to leave a comment.
where can I download this?
there's not a download link for the executable, but if you own Pico-8 you can copy-paste the source code directly into a new cart file! That'll run it exactly as it runs in the browser.
Thanks, I'll try that :)
BK
This is sooo cool!
This is quite a unique idea for a tweetcart. It's an interesting use of Pico-8's ability to be pasted into.