Goblin3D 0.0.2
Graphics engine for rendering 3D wireframe on monochromatic displays and TFT LCDs without any dependency required for Arduino platform.
goblin3d.h
Go to the documentation of this file.
1/*
2 * This file is part of the Goblin3D.
3 * Copyright (c) 2024 Nathanne Isip
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 */
23
59#ifndef GOBLIN3D_H
60#define GOBLIN3D_H
61
62#include <stdbool.h>
63#include <stdint.h>
64
72typedef struct {
73 float** points;
74 uint32_t** edges;
75 float** orig_points;
78 float x_offset;
79 float y_offset;
80 float z_offset;
85 uint32_t point_count;
86 uint32_t edge_count;
87 float scale_size;
89
101typedef void (*goblin3d_obj_draw_fn)(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
102
115bool goblin3d_init(goblin3d_obj_t* obj, uint32_t point_count, uint32_t edge_count);
116
128
138
210
222
237bool goblin3d_add_point(goblin3d_obj_t* obj, float x, float y, float z);
238
252bool goblin3d_edge_exists(goblin3d_obj_t* obj, uint32_t v1, uint32_t v2);
253
268bool goblin3d_add_edge(goblin3d_obj_t* obj, uint32_t v1, uint32_t v2);
269
283bool goblin3d_parse_obj_file(const char* filename, goblin3d_obj_t* obj);
284
285#endif /* GOBLIN3D_H */
void goblin3d_free(goblin3d_obj_t *obj)
Frees the memory associated with a 3D object structure.
Definition: goblin3d.cpp:116
void goblin3d_precalculate(goblin3d_obj_t *obj)
Precalculates the rotated and projected points for a 3D object.
Definition: goblin3d.cpp:145
bool goblin3d_edge_exists(goblin3d_obj_t *obj, uint32_t v1, uint32_t v2)
Checks if an edge exists between two vertices in a Goblin3D object.
Definition: goblin3d.cpp:233
bool goblin3d_parse_obj_file(const char *filename, goblin3d_obj_t *obj)
Parses an OBJ file to construct a Goblin3D object.
Definition: goblin3d.cpp:261
void(* goblin3d_obj_draw_fn)(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
Type definition for a callback function used to draw lines between points.
Definition: goblin3d.h:101
void goblin3d_init_empty(goblin3d_obj_t *obj)
Initializes an empty Goblin3D object.
Definition: goblin3d.cpp:106
void goblin3d_render(goblin3d_obj_t *obj, goblin3d_obj_draw_fn draw)
Renders the 3D object by drawing its edges on a 2D plane.
Definition: goblin3d.cpp:185
bool goblin3d_init(goblin3d_obj_t *obj, uint32_t point_count, uint32_t edge_count)
Initializes a 3D object structure.
Definition: goblin3d.cpp:36
bool goblin3d_add_point(goblin3d_obj_t *obj, float x, float y, float z)
Adds a 3D point to a Goblin3D object.
Definition: goblin3d.cpp:199
bool goblin3d_add_edge(goblin3d_obj_t *obj, uint32_t v1, uint32_t v2)
Adds an edge between two vertices in a Goblin3D object.
Definition: goblin3d.cpp:245
Structure representing a 3D object for rendering using the Goblin3D library.
Definition: goblin3d.h:72
uint32_t point_count
Definition: goblin3d.h:85
float ** orig_points
Definition: goblin3d.h:75
float z_angle_deg
Definition: goblin3d.h:83
float scale_size
Definition: goblin3d.h:87
float y_offset
Definition: goblin3d.h:79
float ** points
Definition: goblin3d.h:73
uint32_t ** edges
Definition: goblin3d.h:74
float x_offset
Definition: goblin3d.h:78
float z_offset
Definition: goblin3d.h:80
float x_angle_deg
Definition: goblin3d.h:81
float ** rotated_points
Definition: goblin3d.h:76
uint32_t edge_count
Definition: goblin3d.h:86
float y_angle_deg
Definition: goblin3d.h:82