wx_BGI_Graphics
Classic BGI-compatible graphics API with modern OpenGL extension API
Loading...
Searching...
No Matches
wx_bgi_3d.h
Go to the documentation of this file.
1#pragma once
2
3#include "bgi_types.h"
4
31// =============================================================================
32// Camera type constants (pass to wxbgi_cam_create)
33// =============================================================================
34
36#define WXBGI_CAM_ORTHO 0
38#define WXBGI_CAM_PERSPECTIVE 1
39
40// =============================================================================
41// Camera lifecycle
42// =============================================================================
43
60BGI_API int BGI_CALL wxbgi_cam_create(const char *name, int type);
61
67BGI_API void BGI_CALL wxbgi_cam_destroy(const char *name);
68
73BGI_API void BGI_CALL wxbgi_cam_set_active(const char *name);
74
82
83// =============================================================================
84// 3-D camera: eye / target / up
85// =============================================================================
86
91BGI_API void BGI_CALL wxbgi_cam_set_eye(const char *name,
92 float x, float y, float z);
93
99 float x, float y, float z);
100
105BGI_API void BGI_CALL wxbgi_cam_set_up(const char *name,
106 float x, float y, float z);
107
109BGI_API void BGI_CALL wxbgi_cam_get_eye(const char *name,
110 float *x, float *y, float *z);
111
114 float *x, float *y, float *z);
115
117BGI_API void BGI_CALL wxbgi_cam_get_up(const char *name,
118 float *x, float *y, float *z);
119
120// =============================================================================
121// Projection
122// =============================================================================
123
133 float fovYDeg,
134 float nearPlane,
135 float farPlane);
136
149 float left, float right,
150 float bottom, float top,
151 float nearPlane, float farPlane);
152
166 float worldUnitsHigh,
167 float nearPlane,
168 float farPlane);
169
170// =============================================================================
171// Screen viewport mapping
172// =============================================================================
173
184 int x, int y,
185 int w, int h);
186
187// =============================================================================
188// Matrix access (column-major float[16], same layout as OpenGL)
189// =============================================================================
190
195BGI_API void BGI_CALL wxbgi_cam_get_view_matrix(const char *name, float *out16);
196
201BGI_API void BGI_CALL wxbgi_cam_get_proj_matrix(const char *name, float *out16);
202
207BGI_API void BGI_CALL wxbgi_cam_get_vp_matrix(const char *name, float *out16);
208
209// =============================================================================
210// Coordinate utilities
211// =============================================================================
212
228 float wx, float wy, float wz,
229 float *screenX, float *screenY);
230
243 float screenX, float screenY,
244 float *rayOx, float *rayOy, float *rayOz,
245 float *rayDx, float *rayDy, float *rayDz);
246
275BGI_API int BGI_CALL wxbgi_cam2d_create(const char *name);
276
281BGI_API void BGI_CALL wxbgi_cam2d_set_pan(const char *name, float x, float y);
282
287BGI_API void BGI_CALL wxbgi_cam2d_pan_by(const char *name, float dx, float dy);
288
295BGI_API void BGI_CALL wxbgi_cam2d_set_zoom(const char *name, float zoom);
296
309 float factor,
310 float pivotX, float pivotY);
311
317BGI_API void BGI_CALL wxbgi_cam2d_set_rotation(const char *name, float angleDeg);
318
321 float *x, float *y);
322
324BGI_API void BGI_CALL wxbgi_cam2d_get_zoom(const char *name, float *zoom);
325
327BGI_API void BGI_CALL wxbgi_cam2d_get_rotation(const char *name, float *angleDeg);
328
340 float worldUnitsHigh);
341
344// =============================================================================
345// Phase 2 — User Coordinate System (UCS) API
346// =============================================================================
347
373BGI_API int BGI_CALL wxbgi_ucs_create(const char *name);
374
380BGI_API void BGI_CALL wxbgi_ucs_destroy(const char *name);
381
385BGI_API void BGI_CALL wxbgi_ucs_set_active(const char *name);
386
394
400 float ox, float oy, float oz);
401
404 float *ox, float *oy, float *oz);
405
419BGI_API void BGI_CALL wxbgi_ucs_set_axes(const char *name,
420 float xx, float xy, float xz,
421 float yx, float yy, float yz,
422 float zx, float zy, float zz);
423
429BGI_API void BGI_CALL wxbgi_ucs_get_axes(const char *name,
430 float *xx, float *xy, float *xz,
431 float *yx, float *yy, float *yz,
432 float *zx, float *zy, float *zz);
433
446 float nx, float ny, float nz,
447 float ox, float oy, float oz);
448
454 float *out16);
455
461 float *out16);
462
471 float wx, float wy, float wz,
472 float *lx, float *ly, float *lz);
473
482 float lx, float ly, float lz,
483 float *wx, float *wy, float *wz);
484
487// =============================================================================
488// Phase 2 — World Extents API
489// =============================================================================
490
506BGI_API void BGI_CALL wxbgi_set_world_extents(float minX, float minY, float minZ,
507 float maxX, float maxY, float maxZ);
508
515BGI_API int BGI_CALL wxbgi_get_world_extents(float *minX, float *minY, float *minZ,
516 float *maxX, float *maxY, float *maxZ);
517
523BGI_API void BGI_CALL wxbgi_expand_world_extents(float x, float y, float z);
524
529
547
548// =============================================================================
549// Phase 3: UCS-to-screen projection + world-coordinate drawing wrappers
550// =============================================================================
551
565BGI_API int BGI_CALL wxbgi_ucs_to_screen(const char *ucsName, const char *camName,
566 float ux, float uy, float uz,
567 float *screenX, float *screenY);
568
569// --- World-space drawing (uses the active camera) ----------------------------
570
573BGI_API void BGI_CALL wxbgi_world_point(float x, float y, float z, int color);
574
576BGI_API void BGI_CALL wxbgi_world_line(float x1, float y1, float z1,
577 float x2, float y2, float z2);
578
581BGI_API void BGI_CALL wxbgi_world_circle(float cx, float cy, float cz, float radius);
582
585BGI_API void BGI_CALL wxbgi_world_ellipse(float cx, float cy, float cz,
586 float rx, float ry,
587 int startAngle, int endAngle);
588
590BGI_API void BGI_CALL wxbgi_world_rectangle(float x1, float y1, float z1,
591 float x2, float y2, float z2);
592
595BGI_API void BGI_CALL wxbgi_world_polyline(const float *xyzTriplets, int pointCount);
596
599BGI_API void BGI_CALL wxbgi_world_fillpoly(const float *xyzTriplets, int pointCount);
600
602BGI_API void BGI_CALL wxbgi_world_outtextxy(float x, float y, float z, const char *text);
603
604// --- UCS-local drawing (transform through named UCS, then project) -----------
605
607BGI_API void BGI_CALL wxbgi_ucs_point(const char *ucsName,
608 float ux, float uy, float uz, int color);
609
611BGI_API void BGI_CALL wxbgi_ucs_line(const char *ucsName,
612 float ux1, float uy1, float uz1,
613 float ux2, float uy2, float uz2);
614
616BGI_API void BGI_CALL wxbgi_ucs_circle(const char *ucsName,
617 float cx, float cy, float cz, float radius);
618
621BGI_API void BGI_CALL wxbgi_ucs_polyline(const char *ucsName,
622 const float *xyzTriplets, int pointCount);
623
625BGI_API void BGI_CALL wxbgi_ucs_outtextxy(const char *ucsName,
626 float ux, float uy, float uz,
627 const char *text);
628
#define BGI_CALL
Definition bgi_types.h:20
#define BGI_API
Definition bgi_types.h:14
BGI_API void BGI_CALL wxbgi_cam2d_set_zoom(const char *name, float zoom)
Sets the zoom level (1 = nominal, 2 = 2× magnification).
BGI_API void BGI_CALL wxbgi_cam2d_set_pan(const char *name, float x, float y)
Sets the 2-D camera pan (world-space centre of the view).
BGI_API void BGI_CALL wxbgi_cam2d_set_world_height(const char *name, float worldUnitsHigh)
Sets the number of world-units visible vertically at zoom = 1.
BGI_API void BGI_CALL wxbgi_cam2d_get_zoom(const char *name, float *zoom)
Retrieves the current zoom level.
BGI_API void BGI_CALL wxbgi_cam2d_get_rotation(const char *name, float *angleDeg)
Retrieves the current rotation in degrees.
BGI_API int BGI_CALL wxbgi_cam2d_create(const char *name)
Creates a 2-D overhead camera.
BGI_API void BGI_CALL wxbgi_cam2d_zoom_at(const char *name, float factor, float pivotX, float pivotY)
Zooms around a pivot point in world space.
BGI_API void BGI_CALL wxbgi_cam2d_pan_by(const char *name, float dx, float dy)
Pans the 2-D camera by a world-space delta.
BGI_API void BGI_CALL wxbgi_cam2d_set_rotation(const char *name, float angleDeg)
Sets the 2-D view rotation around the Z axis.
BGI_API void BGI_CALL wxbgi_cam2d_get_pan(const char *name, float *x, float *y)
Retrieves the current pan position.
BGI_API void BGI_CALL wxbgi_cam_set_active(const char *name)
Sets the active camera used by wxbgi_cam_world_to_screen and related helpers when NULL is passed as t...
BGI_API int BGI_CALL wxbgi_cam_world_to_screen(const char *name, float wx, float wy, float wz, float *screenX, float *screenY)
Projects a world-space point to a screen pixel coordinate.
BGI_API void BGI_CALL wxbgi_cam_get_eye(const char *name, float *x, float *y, float *z)
Retrieves the current eye position.
BGI_API void BGI_CALL wxbgi_cam_set_perspective(const char *name, float fovYDeg, float nearPlane, float farPlane)
Switches a camera to perspective projection.
BGI_API void BGI_CALL wxbgi_cam_get_proj_matrix(const char *name, float *out16)
Writes the projection matrix into out16 (column-major float[16]).
BGI_API void BGI_CALL wxbgi_cam_destroy(const char *name)
Removes a named camera from the registry.
BGI_API void BGI_CALL wxbgi_cam_set_target(const char *name, float x, float y, float z)
Sets the look-at target in world space.
BGI_API int BGI_CALL wxbgi_cam_create(const char *name, int type)
Creates a named camera and adds it to the registry.
BGI_API void BGI_CALL wxbgi_cam_get_vp_matrix(const char *name, float *out16)
Writes the combined view-projection matrix into out16.
BGI_API void BGI_CALL wxbgi_cam_set_screen_viewport(const char *name, int x, int y, int w, int h)
Restricts the camera's output to a sub-rectangle of the window.
BGI_API const char *BGI_CALL wxbgi_cam_get_active(void)
Returns the name of the currently active camera.
BGI_API void BGI_CALL wxbgi_cam_get_up(const char *name, float *x, float *y, float *z)
Retrieves the current up vector.
BGI_API void BGI_CALL wxbgi_cam_set_up(const char *name, float x, float y, float z)
Sets the up vector.
BGI_API void BGI_CALL wxbgi_cam_screen_to_ray(const char *name, float screenX, float screenY, float *rayOx, float *rayOy, float *rayOz, float *rayDx, float *rayDy, float *rayDz)
Unprojects a screen pixel to a world-space ray.
BGI_API void BGI_CALL wxbgi_cam_set_eye(const char *name, float x, float y, float z)
Sets the eye (camera position) in world space.
BGI_API void BGI_CALL wxbgi_cam_set_ortho(const char *name, float left, float right, float bottom, float top, float nearPlane, float farPlane)
Sets explicit orthographic clip extents.
BGI_API void BGI_CALL wxbgi_cam_set_ortho_auto(const char *name, float worldUnitsHigh, float nearPlane, float farPlane)
Sets orthographic projection with automatic aspect-correct extents.
BGI_API void BGI_CALL wxbgi_cam_get_target(const char *name, float *x, float *y, float *z)
Retrieves the current look-at target.
BGI_API void BGI_CALL wxbgi_cam_get_view_matrix(const char *name, float *out16)
Writes the view matrix into out16 (column-major float[16]).
BGI_API void BGI_CALL wxbgi_ucs_set_axes(const char *name, float xx, float xy, float xz, float yx, float yy, float yz, float zx, float zy, float zz)
Sets all three axes of a UCS.
BGI_API void BGI_CALL wxbgi_ucs_get_world_to_local_matrix(const char *name, float *out16)
Writes the world-to-local matrix into out16 (column-major float[16]).
BGI_API void BGI_CALL wxbgi_ucs_set_active(const char *name)
Sets the active UCS used when NULL is passed as the UCS name.
BGI_API int BGI_CALL wxbgi_ucs_create(const char *name)
Creates a named UCS initialised to the world identity frame.
BGI_API void BGI_CALL wxbgi_ucs_get_origin(const char *name, float *ox, float *oy, float *oz)
Retrieves the current UCS origin.
BGI_API void BGI_CALL wxbgi_ucs_local_to_world(const char *name, float lx, float ly, float lz, float *wx, float *wy, float *wz)
Transforms a UCS local point into world-space coordinates.
BGI_API void BGI_CALL wxbgi_ucs_destroy(const char *name)
Removes a named UCS from the registry.
BGI_API void BGI_CALL wxbgi_ucs_get_local_to_world_matrix(const char *name, float *out16)
Writes the local-to-world matrix into out16 (column-major float[16]).
BGI_API void BGI_CALL wxbgi_ucs_world_to_local(const char *name, float wx, float wy, float wz, float *lx, float *ly, float *lz)
Transforms a world-space point into UCS local coordinates.
BGI_API void BGI_CALL wxbgi_ucs_get_axes(const char *name, float *xx, float *xy, float *xz, float *yx, float *yy, float *yz, float *zx, float *zy, float *zz)
Retrieves all three axes of a UCS as world-space unit vectors.
BGI_API void BGI_CALL wxbgi_ucs_set_origin(const char *name, float ox, float oy, float oz)
Sets the origin of a UCS in world space.
BGI_API void BGI_CALL wxbgi_ucs_align_to_plane(const char *name, float nx, float ny, float nz, float ox, float oy, float oz)
Aligns a UCS so that its local Z axis matches a given surface normal.
BGI_API const char *BGI_CALL wxbgi_ucs_get_active(void)
Returns the name of the currently active UCS.
BGI_API void BGI_CALL wxbgi_world_fillpoly(const float *xyzTriplets, int pointCount)
Draws and fills a closed polygon through world-space points.
BGI_API void BGI_CALL wxbgi_world_ellipse(float cx, float cy, float cz, float rx, float ry, int startAngle, int endAngle)
Draws an ellipse arc (world-space centre, world-unit semi-axes rx/ry).
BGI_API void BGI_CALL wxbgi_set_world_extents(float minX, float minY, float minZ, float maxX, float maxY, float maxZ)
Sets the world extents to an explicit AABB.
BGI_API void BGI_CALL wxbgi_world_polyline(const float *xyzTriplets, int pointCount)
Draws an open polyline through world-space points.
BGI_API void BGI_CALL wxbgi_ucs_polyline(const char *ucsName, const float *xyzTriplets, int pointCount)
Draws an open polyline through UCS-local points.
BGI_API void BGI_CALL wxbgi_expand_world_extents(float x, float y, float z)
Expands the world extents to include the point (x, y, z).
BGI_API int BGI_CALL wxbgi_get_world_extents(float *minX, float *minY, float *minZ, float *maxX, float *maxY, float *maxZ)
Retrieves the current world extents.
BGI_API int BGI_CALL wxbgi_cam_fit_to_extents(const char *camName)
Adjusts a camera's projection and position to frame the world extents.
BGI_API void BGI_CALL wxbgi_world_line(float x1, float y1, float z1, float x2, float y2, float z2)
Draws a line segment between two world-space points using the current colour/style.
BGI_API void BGI_CALL wxbgi_ucs_circle(const char *ucsName, float cx, float cy, float cz, float radius)
Draws a circle at a UCS-local centre with a UCS-unit radius.
BGI_API void BGI_CALL wxbgi_ucs_point(const char *ucsName, float ux, float uy, float uz, int color)
Draws a pixel at a UCS-local position.
BGI_API void BGI_CALL wxbgi_world_outtextxy(float x, float y, float z, const char *text)
Draws text at a world-space position using current BGI font/colour settings.
BGI_API void BGI_CALL wxbgi_world_point(float x, float y, float z, int color)
Draws a single pixel at a world-space position.
BGI_API void BGI_CALL wxbgi_world_circle(float cx, float cy, float cz, float radius)
Draws a circle (world-space centre, world-unit radius) via the active camera.
BGI_API void BGI_CALL wxbgi_world_rectangle(float x1, float y1, float z1, float x2, float y2, float z2)
Draws a screen-space rectangle outline from two projected world-space corners.
BGI_API int BGI_CALL wxbgi_ucs_to_screen(const char *ucsName, const char *camName, float ux, float uy, float uz, float *screenX, float *screenY)
Projects a UCS-local point through the named UCS and camera to screen-pixel coordinates.
BGI_API void BGI_CALL wxbgi_ucs_outtextxy(const char *ucsName, float ux, float uy, float uz, const char *text)
Draws text at a UCS-local anchor.
BGI_API void BGI_CALL wxbgi_ucs_line(const char *ucsName, float ux1, float uy1, float uz1, float ux2, float uy2, float uz2)
Draws a line between two UCS-local points.
BGI_API void BGI_CALL wxbgi_reset_world_extents(void)
Resets the world extents to the "empty / no data" state.