Log In  
Follow
PennDraken
Face Painter for 3D Engine
by
[ :: Read More :: ]

A Simple Way To Quickly Color Your 3D Models

This entire cart is built upon electricgryphon's 3D engine. 99% of work was done by him.

Cart #face_painter_3d_gryphon-2 | 2024-02-29 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
7

Controls

-Use arrow keys to orbit around model
-Scroll mouse wheel to zoom in and out on model
-Left click on a face to paint the face
-Left click on a color to select the color
-Left click on 'duplicate' to export your model to clipboard (compressed format)
-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.

Importing your model to a cart

Loading a model into the editor

In order to convert an .obj file to a format which this editor supports, you can use this Python script.

Importing a painted model into the Gryphon 3D Engine library


Export your model from this editor. Simply press the 'duplicate' icon. Your model with face data will now be in your clipboard.

Paste your model_v_string="..." and model_f_string="..." into the engine cart at the top.

Add these functions in the Gryphon 3D engine cart.

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<#string)do
        face=read_colored_face()
        add(face_list,face)
    end
        return face_list
end

Now your model can be loaded like this:

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

Finally add the load function to your scene list.

scene_index=1
scene_list=
{
{load_model_scene, update_model_scene, draw_background}
}

Example models you can import (copy to clipboard and then press scissor icon)

Available on my github

TODO/ Known issues


Allow Ctrl+V pasting of models
Support for importing models from Gryphon that don't already have face color data
More efficient compression
Better UI
Less ugly code

P#142163 2024-02-28 23:35 ( Edited 2024-03-03 16:04)