198 lines
5.1 KiB
OpenEdge ABL
198 lines
5.1 KiB
OpenEdge ABL
%module raytracer
|
|
|
|
%{
|
|
#include "tuples.h"
|
|
#include "lights.h"
|
|
#include "world.h"
|
|
#include "camera.h"
|
|
#include "material.h"
|
|
#include "shape.h"
|
|
#include "sphere.h"
|
|
#include "plane.h"
|
|
#include "cube.h"
|
|
#include "cylinder.h"
|
|
#include "cone.h"
|
|
%}
|
|
|
|
%nodefaultctor;
|
|
|
|
%rename(point) TUPLES_new_point;
|
|
TUPLES_Point *TUPLES_new_point(double x, double y, double z);
|
|
%rename(vector) TUPLES_new_vector;
|
|
TUPLES_Vector *TUPLES_new_vector(double x, double y, double z);
|
|
%rename(color) TUPLES_new_color;
|
|
TUPLES_Color *TUPLES_new_color(double red, double green, double blue);
|
|
|
|
%rename(pointlight) LIGHTS_new_pointlight;
|
|
LIGHTS_Light *LIGHTS_new_pointlight(const TUPLES_Point *point, const TUPLES_Color *color);
|
|
%rename(arealight) LIGHTS_new_arealight;
|
|
LIGHTS_Light *LIGHTS_new_arealight(const TUPLES_Point *corner, const TUPLES_Vector *uvec, unsigned int usteps, const TUPLES_Vector *vvec, unsigned int vsteps, const TUPLES_Color *color);
|
|
|
|
struct WORLD_World { };
|
|
%rename(world) WORLD_new;
|
|
WORLD_World *WORLD_new(LIGHTS_Light *light);
|
|
%extend WORLD_World {
|
|
void add_object(SHAPE_Shape* shape) {
|
|
WORLD_add_object($self, shape);
|
|
}
|
|
void add_object(CYLINDER_Cylinder* shape) {
|
|
WORLD_add_object($self, shape);
|
|
}
|
|
};
|
|
|
|
struct CAMERA_Camera { };
|
|
%rename(camera) CAMERA_new;
|
|
CAMERA_Camera *CAMERA_new(unsigned int hsize, unsigned int vsize, double field_of_view);
|
|
%rename(camera_view_transform) CAMERA_view_transform;
|
|
MATRIX_Matrix *CAMERA_view_transform(const TUPLES_Point *from, const TUPLES_Point *to, const TUPLES_Vector *up);
|
|
%extend CAMERA_Camera {
|
|
void set_transform(MATRIX_Matrix *transform) {
|
|
CAMERA_set_transform($self, transform);
|
|
}
|
|
CANVAS_Canvas *render(const WORLD_World *world) {
|
|
return CAMERA_render($self, world);
|
|
}
|
|
}
|
|
struct CANVAS_Canvas { };
|
|
%extend CANVAS_Canvas {
|
|
void write_to_file(const char *filename) {
|
|
CANVAS_write_to_file($self, filename);
|
|
}
|
|
}
|
|
|
|
struct MATERIAL_Material {
|
|
/* PATTERN_Pattern *pattern; */
|
|
};
|
|
%extend MATERIAL_Material {
|
|
MATERIAL_Material *ambient(double val) {
|
|
$self->ambient = val;
|
|
return $self;
|
|
}
|
|
MATERIAL_Material *diffuse(double val) {
|
|
$self->diffuse = val;
|
|
return $self;
|
|
}
|
|
MATERIAL_Material *specular(double val) {
|
|
$self->specular = val;
|
|
return $self;
|
|
}
|
|
MATERIAL_Material *shininess(double val) {
|
|
$self->shininess = val;
|
|
return $self;
|
|
}
|
|
MATERIAL_Material *reflective(double val) {
|
|
$self->reflective = val;
|
|
return $self;
|
|
}
|
|
MATERIAL_Material *transparency(double val) {
|
|
$self->transparency = val;
|
|
return $self;
|
|
}
|
|
MATERIAL_Material *refractive_index(double val) {
|
|
$self->refractive_index = val;
|
|
return $self;
|
|
}
|
|
MATERIAL_Material *shadow_calc(bool val) {
|
|
$self->shadow_calc = val;
|
|
return $self;
|
|
}
|
|
MATERIAL_Material *color(const TUPLES_Color *color) {
|
|
$self->color = *color;
|
|
return $self;
|
|
}
|
|
MATERIAL_Material *color(double r, double g, double b) {
|
|
TUPLES_init_color(&($self->color), r, g, b);
|
|
return $self;
|
|
}
|
|
}
|
|
%rename(material) MATERIAL_new;
|
|
MATERIAL_Material *MATERIAL_new();
|
|
|
|
struct SHAPE_Shape { };
|
|
struct CYLINDER_Cylinder { };
|
|
%rename(sphere) SPHERE_new;
|
|
SHAPE_Shape* SPHERE_new();
|
|
%rename(plane) PLANE_new;
|
|
SHAPE_Shape* PLANE_new();
|
|
%rename(cube) CUBE_new;
|
|
SHAPE_Shape* CUBE_new();
|
|
%rename(cylinder) CYLINDER_new;
|
|
CYLINDER_Cylinder* CYLINDER_new();
|
|
%rename(cone) CONE_new;
|
|
CYLINDER_Cylinder* CONE_new();
|
|
%extend SHAPE_Shape {
|
|
SHAPE_Shape *set_transform(const MATRIX_Matrix *transformation) {
|
|
SHAPE_set_transform($self, transformation);
|
|
return $self;
|
|
}
|
|
SHAPE_Shape *set_material(const MATERIAL_Material *material) {
|
|
SHAPE_set_material($self, material);
|
|
return $self;
|
|
}
|
|
};
|
|
|
|
%extend CYLINDER_Cylinder {
|
|
CYLINDER_Cylinder *set_transform(const MATRIX_Matrix *transformation) {
|
|
CYLINDER_set_transform($self, transformation);
|
|
return $self;
|
|
}
|
|
|
|
CYLINDER_Cylinder *set_material(const MATERIAL_Material *material) {
|
|
CYLINDER_set_material($self, material);
|
|
return $self;
|
|
}
|
|
|
|
CYLINDER_Cylinder *minimum(double minimum) {
|
|
$self->minimum = minimum;
|
|
return $self;
|
|
}
|
|
|
|
CYLINDER_Cylinder *maximum(double maximum) {
|
|
$self->maximum = maximum;
|
|
return $self;
|
|
}
|
|
|
|
CYLINDER_Cylinder *closed(bool closed) {
|
|
$self->closed = closed;
|
|
return $self;
|
|
}
|
|
};
|
|
|
|
%rename(matrix) MATRIX_Matrix;
|
|
struct MATRIX_Matrix { };
|
|
%extend MATRIX_Matrix {
|
|
static MATRIX_Matrix* identity() {
|
|
return MATRIX_new_identity(4);
|
|
}
|
|
static MATRIX_Matrix* translation(double x, double y, double z) {
|
|
return MATRIX_new_translation(x, y, z);
|
|
}
|
|
static MATRIX_Matrix* scaling(double x, double y, double z) {
|
|
return MATRIX_new_scaling(x, y, z);
|
|
}
|
|
static MATRIX_Matrix* rotation_x(double radians) {
|
|
return MATRIX_new_rotation_x(radians);
|
|
}
|
|
static MATRIX_Matrix* rotation_y(double radians) {
|
|
return MATRIX_new_rotation_y(radians);
|
|
}
|
|
static MATRIX_Matrix* rotation_z(double radians) {
|
|
return MATRIX_new_rotation_z(radians);
|
|
}
|
|
static MATRIX_Matrix* shearing(double xy, double xz, double yx, double yz, double zx, double zy) {
|
|
return MATRIX_new_shearing(xy, xz, yx, yz, zx, zy);
|
|
}
|
|
MATRIX_Matrix* multiply(const MATRIX_Matrix* other_matrix) {
|
|
return MATRIX_multiply($self, other_matrix);
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|