PennDraken [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=69199 Face Painter for 3D Engine <h1>A Simple Way To Quickly Color Your 3D Models</h1> <p>This entire cart is built upon <a href="https://www.lexaloffle.com/bbs/?tid=28077">electricgryphon's 3D engine</a>. 99% of work was done by him.</p> <img loading="lazy" style="margin-bottom:16px" border=0 src="/media/69199/6_face_paint_2.gif" alt="" /> <img loading="lazy" style="margin-bottom:16px" border=0 src="/media/69199/9_3d_face_painter p8_1.gif" alt="" /> <img loading="lazy" style="margin-bottom:16px" border=0 src="/media/69199/10_face_paint p8_0.gif" alt="" /> <p> <table><tr><td> <a href="/bbs/?pid=142163#p"> <img src="/bbs/thumbs/pico8_face_painter_3d_gryphon-2.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=142163#p"> Face Painter for 3D Engine</a><br><br> by <a href="/bbs/?uid=69199"> PennDraken</a> <br><br><br> <a href="/bbs/?pid=142163#p"> [Click to Play]</a> </td></tr></table> </p> <h2>Controls</h2> <p>-Use arrow keys to orbit around model<br /> -Scroll mouse wheel to zoom in and out on model<br /> -Left click on a face to paint the face<br /> -Left click on a color to select the color<br /> -Left click on 'duplicate' to export your model to clipboard (compressed format)<br /> -Left click on 'scissors' (paste) to import a model from clipboard (compressed format). Note: You might need to press Ctrl+V in window before pressing paste.</p> <h2>Importing your model to a cart</h2> <h3>Loading a model into the editor</h3> <p>In order to convert an .obj file to a format which this editor supports, you can use <a href="https://github.com/PennDraken/Pico-8-Gryphon-3D-Engine-Library/tree/master">this Python script</a>.</p> <h3>Importing a painted model into the Gryphon 3D Engine library</h3> <p><div><div><input type="button" value=" Show " onClick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = ' Hide '; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = ' Show '; }"></div><div><div style="display: none;"><br /> Export your model from this editor. Simply press the 'duplicate' icon. Your model with face data will now be in your clipboard.</p> <p>Paste your model_v_string=&quot;...&quot; and model_f_string=&quot;...&quot; into the engine cart at the top.</p> <p>Add these functions in the <a href="https://www.lexaloffle.com/bbs/?tid=28077">Gryphon 3D engine cart</a>.</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>function read_colored_face() f={} --verts 1 to 3 + 2 color values for i=1,5 do text=sub(cur_string,cur_string_index,cur_string_index+2) value=read_byte(text) f[i]=value cur_string_index+=2 end return f end function read_colored_face_string(string) face_list={} load_string(string) while(cur_string_index&lt;#string)do face=read_colored_face() add(face_list,face) end return face_list end </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Now your model can be loaded like this:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>function load_model_scene() c_mode = k_preset_color -- to show colors of faces model_v = read_vector_string(model_v_string) model_f = read_colored_face_string(model_f_string) model = load_object(model_v, model_f, 0, 0, 0, 0, 0, 0, false, c_mode, 4) end</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Finally add the load function to your scene list.</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>scene_index=1 scene_list= { {load_model_scene, update_model_scene, draw_background} }</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p></div></div></div></p> <h2>Example models you can import (copy to clipboard and then press scissor icon)</h2> <p><a href="https://github.com/PennDraken/Pico-8-Gryphon-3D-Engine-Library/tree/master/models">Available on my github</a></p> <h2>TODO/ Known issues</h2> <p><div><div><input type="button" value=" Show " onClick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = ' Hide '; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = ' Show '; }"></div><div><div style="display: none;"><br /> Allow Ctrl+V pasting of models<br /> Support for importing models from Gryphon that don't already have face color data<br /> More efficient compression<br /> Better UI<br /> Less ugly code<br /> </div></div></div></p> https://www.lexaloffle.com/bbs/?tid=140434 https://www.lexaloffle.com/bbs/?tid=140434 Wed, 28 Feb 2024 23:35:48 UTC