gamgi_io_x3d.c (gamgi-all-0.17.4x) | : | gamgi_io_x3d.c (gamgi-all-0.17.5x) | ||
---|---|---|---|---|
skipping to change at line 26 | skipping to change at line 26 | |||
#include "gamgi_math.h" | #include "gamgi_math.h" | |||
#include "gamgi_phys.h" | #include "gamgi_phys.h" | |||
#include "gamgi_global.h" | #include "gamgi_global.h" | |||
#include "gamgi_engine_list.h" | #include "gamgi_engine_list.h" | |||
#include "gamgi_engine_array.h" | #include "gamgi_engine_array.h" | |||
#include "gamgi_mesa_atom.h" | #include "gamgi_mesa_atom.h" | |||
#include "gamgi_mesa_bond.h" | #include "gamgi_mesa_bond.h" | |||
#include "gamgi_math_vector.h" | #include "gamgi_math_vector.h" | |||
#include "gamgi_math_quaternion.h" | #include "gamgi_math_quaternion.h" | |||
#include "gamgi_io_x3d_render.h" | ||||
#include "gamgi_io_file.h" | #include "gamgi_io_file.h" | |||
#include "gamgi_io_error.h" | #include "gamgi_io_error.h" | |||
#include "gamgi_io_x3d_render.h" | ||||
/************* internal function *********** | /************* internal function *********** | |||
* * | * * | |||
* STATIC_SCALE * | * STATIC_SCALE * | |||
* * | * * | |||
* open the scale node of an object * | * open the scale node of an object * | |||
*******************************************/ | *******************************************/ | |||
static void static_scale (FILE *fp, double scale, double *center, | static void static_scale (FILE *fp, double scale, double *center, | |||
gamgi_bool *error) | gamgi_bool *error) | |||
{ | { | |||
char string[GAMGI_ENGINE_LINE]; | char string[GAMGI_ENGINE_LINE]; | |||
/******************* | ||||
* Transform start * | ||||
*******************/ | ||||
/********************************************************* | ||||
* move the object center to the origin, scale the * | ||||
* object, move the object back to its original position * | ||||
*********************************************************/ | ||||
if (fabs (scale - 1.0) > GAMGI_MATH_TOLERANCE) | if (fabs (scale - 1.0) > GAMGI_MATH_TOLERANCE) | |||
{ | { | |||
sprintf (string, "<Transform translation=\"%.*f %.*f %.*f\">\n", | sprintf (string, "<Transform translation=\"%.*f %.*f %.*f\">\n", | |||
gamgi->gamgi->length, center[0], | gamgi->gamgi->length, center[0], | |||
gamgi->gamgi->length, center[1], | gamgi->gamgi->length, center[1], | |||
gamgi->gamgi->length, center[2]); | gamgi->gamgi->length, center[2]); | |||
gamgi_io_file_fprintf (fp, string, error); | gamgi_io_file_fprintf (fp, string, error); | |||
sprintf (string, "<Transform scale=\"%.*f %.*f %.*f\">\n", | sprintf (string, "<Transform scale=\"%.*f %.*f %.*f\">\n", | |||
GAMGI_MATH_DECIMAL_SCALE, scale, | GAMGI_MATH_DECIMAL_SCALE, scale, | |||
skipping to change at line 73 | skipping to change at line 82 | |||
/************* internal function *********** | /************* internal function *********** | |||
* * | * * | |||
* STATIC_UNSCALE * | * STATIC_UNSCALE * | |||
* * | * * | |||
* close the scale node of an object * | * close the scale node of an object * | |||
*******************************************/ | *******************************************/ | |||
static void static_unscale (FILE *fp, double scale, gamgi_bool *error) | static void static_unscale (FILE *fp, double scale, gamgi_bool *error) | |||
{ | { | |||
/***************** | ||||
* Transform end * | ||||
*****************/ | ||||
if (fabs (scale - 1.0) > GAMGI_MATH_TOLERANCE) | if (fabs (scale - 1.0) > GAMGI_MATH_TOLERANCE) | |||
gamgi_io_file_fprintf(fp, "</Transform>\n</Transform>\n</Transform>\n", error) ; | gamgi_io_file_fprintf(fp, "</Transform>\n</Transform>\n</Transform>\n", error) ; | |||
} | } | |||
static void static_line (FILE *fp, gamgi_bool lights, float *color, | static void static_line (FILE *fp, gamgi_bool lights, float *color, | |||
double *start, double *end, int width, gamgi_bool *error) | double *start, double *end, int width, gamgi_bool *error) | |||
{ | { | |||
char string[GAMGI_ENGINE_LINE]; | char string[GAMGI_ENGINE_LINE]; | |||
/*************** | ||||
* Shape start * | ||||
***************/ | ||||
gamgi_io_file_fprintf (fp, "<Shape>\n", error); | gamgi_io_file_fprintf (fp, "<Shape>\n", error); | |||
/************************ | ||||
* Appearance start+end * | ||||
************************/ | ||||
gamgi_io_file_fprintf (fp, "<Appearance>\n", error); | gamgi_io_file_fprintf (fp, "<Appearance>\n", error); | |||
if (lights == TRUE) | if (lights == TRUE) | |||
sprintf (string, "<Material diffuseColor=\"%.*f %.*f %.*f\"/>\n", | sprintf (string, "<Material diffuseColor=\"%.*f %.*f %.*f\"/>\n", | |||
GAMGI_MATH_DECIMAL_COLOR, color[0], | GAMGI_MATH_DECIMAL_COLOR, color[0], | |||
GAMGI_MATH_DECIMAL_COLOR, color[1], | GAMGI_MATH_DECIMAL_COLOR, color[1], | |||
GAMGI_MATH_DECIMAL_COLOR, color[2]); | GAMGI_MATH_DECIMAL_COLOR, color[2]); | |||
else | else | |||
sprintf (string, "<Material emissiveColor=\"%.*f %.*f %.*f\"/>\n", | sprintf (string, "<Material emissiveColor=\"%.*f %.*f %.*f\"/>\n", | |||
GAMGI_MATH_DECIMAL_COLOR, color[0], | GAMGI_MATH_DECIMAL_COLOR, color[0], | |||
GAMGI_MATH_DECIMAL_COLOR, color[1], | GAMGI_MATH_DECIMAL_COLOR, color[1], | |||
GAMGI_MATH_DECIMAL_COLOR, color[2]); | GAMGI_MATH_DECIMAL_COLOR, color[2]); | |||
gamgi_io_file_fprintf (fp, string, error); | gamgi_io_file_fprintf (fp, string, error); | |||
sprintf (string, "<LineProperties linewidthScaleFactor=\"%d\"/>\n", width); | sprintf (string, "<LineProperties linewidthScaleFactor=\"%d\"/>\n", width); | |||
gamgi_io_file_fprintf (fp, string, error); | gamgi_io_file_fprintf (fp, string, error); | |||
gamgi_io_file_fprintf (fp, "</Appearance>\n", error); | gamgi_io_file_fprintf (fp, "</Appearance>\n", error); | |||
/****************** | ||||
* Line start+end * | ||||
******************/ | ||||
gamgi_io_file_fprintf (fp, "<IndexedLineSet coordIndex=\"0 1 -1\">\n", error); | gamgi_io_file_fprintf (fp, "<IndexedLineSet coordIndex=\"0 1 -1\">\n", error); | |||
sprintf (string, "<Coordinate point=\"%.*f %.*f %.*f %.*f %.*f %.*f\"/>\n", | sprintf (string, "<Coordinate point=\"%.*f %.*f %.*f %.*f %.*f %.*f\"/>\n", | |||
gamgi->gamgi->length, start[0], | gamgi->gamgi->length, start[0], | |||
gamgi->gamgi->length, start[1], | gamgi->gamgi->length, start[1], | |||
gamgi->gamgi->length, start[2], | gamgi->gamgi->length, start[2], | |||
gamgi->gamgi->length, end[0], | gamgi->gamgi->length, end[0], | |||
gamgi->gamgi->length, end[1], | gamgi->gamgi->length, end[1], | |||
gamgi->gamgi->length, end[2]); | gamgi->gamgi->length, end[2]); | |||
gamgi_io_file_fprintf (fp, string, error); | gamgi_io_file_fprintf (fp, string, error); | |||
gamgi_io_file_fprintf (fp, "</IndexedLineSet>\n", error); | gamgi_io_file_fprintf (fp, "</IndexedLineSet>\n", error); | |||
/************* | ||||
* Shape end * | ||||
*************/ | ||||
gamgi_io_file_fprintf (fp, "</Shape>\n", error); | gamgi_io_file_fprintf (fp, "</Shape>\n", error); | |||
} | } | |||
static void static_cylinder (FILE *fp, gamgi_bool lights, float *color, | static void static_cylinder (FILE *fp, gamgi_bool lights, float *color, | |||
double length, double radius, gamgi_bool *error) | double length, double radius, gamgi_bool *error) | |||
{ | { | |||
char string[GAMGI_ENGINE_LINE]; | char string[GAMGI_ENGINE_LINE]; | |||
/*************** | ||||
* Shape start * | ||||
***************/ | ||||
gamgi_io_file_fprintf (fp, "<Shape>\n", error); | gamgi_io_file_fprintf (fp, "<Shape>\n", error); | |||
/************************ | ||||
* Appearance start+end * | ||||
************************/ | ||||
gamgi_io_file_fprintf (fp, "<Appearance>\n", error); | gamgi_io_file_fprintf (fp, "<Appearance>\n", error); | |||
if (lights == TRUE) | if (lights == TRUE) | |||
sprintf (string, "<Material shininess=\"%.*f\" diffuseColor=\"%.*f %.*f %.*f\" />\n", | sprintf (string, "<Material shininess=\"%.*f\" diffuseColor=\"%.*f %.*f %.*f\" />\n", | |||
GAMGI_MATH_DECIMAL_SHININESS, gamgi->light->shininess, | GAMGI_MATH_DECIMAL_SHININESS, gamgi->light->shininess, | |||
GAMGI_MATH_DECIMAL_COLOR, color[0], | GAMGI_MATH_DECIMAL_COLOR, color[0], | |||
GAMGI_MATH_DECIMAL_COLOR, color[1], | GAMGI_MATH_DECIMAL_COLOR, color[1], | |||
GAMGI_MATH_DECIMAL_COLOR, color[2]); | GAMGI_MATH_DECIMAL_COLOR, color[2]); | |||
else | else | |||
sprintf (string, "<Material emissiveColor=\"%.*f %.*f %.*f\"/>\n", | sprintf (string, "<Material emissiveColor=\"%.*f %.*f %.*f\"/>\n", | |||
GAMGI_MATH_DECIMAL_COLOR, color[0], | GAMGI_MATH_DECIMAL_COLOR, color[0], | |||
GAMGI_MATH_DECIMAL_COLOR, color[1], | GAMGI_MATH_DECIMAL_COLOR, color[1], | |||
GAMGI_MATH_DECIMAL_COLOR, color[2]); | GAMGI_MATH_DECIMAL_COLOR, color[2]); | |||
gamgi_io_file_fprintf (fp, string, error); | gamgi_io_file_fprintf (fp, string, error); | |||
gamgi_io_file_fprintf (fp, "</Appearance>\n", error); | gamgi_io_file_fprintf (fp, "</Appearance>\n", error); | |||
/********************** | ||||
* Cylinder start+end * | ||||
**********************/ | ||||
sprintf (string, "<Cylinder height=\"%.*f\" radius=\"%.*f\" top=\"false\" bottom =\"false\"/>\n", | sprintf (string, "<Cylinder height=\"%.*f\" radius=\"%.*f\" top=\"false\" bottom =\"false\"/>\n", | |||
gamgi->gamgi->length, length, gamgi->gamgi->length, radius); | gamgi->gamgi->length, length, gamgi->gamgi->length, radius); | |||
gamgi_io_file_fprintf (fp, string, error); | gamgi_io_file_fprintf (fp, string, error); | |||
/************* | ||||
* Shape end * | ||||
*************/ | ||||
gamgi_io_file_fprintf (fp, "</Shape>\n", error); | gamgi_io_file_fprintf (fp, "</Shape>\n", error); | |||
} | } | |||
static void static_text (FILE *fp, gamgi_text *text, | static void static_text (FILE *fp, gamgi_text *text, | |||
gamgi_bool lights, gamgi_bool *error) | gamgi_bool lights, gamgi_bool *error) | |||
{ | { | |||
gamgi_dlist *dlist; | gamgi_dlist *dlist; | |||
char string[GAMGI_ENGINE_LINE]; | char string[GAMGI_ENGINE_LINE]; | |||
double axis[3]; | double axis[3]; | |||
double phi; | double phi; | |||
/********************************************* | /************************* | |||
* start scale, rotate, move Transform nodes * | * scale Transform start * | |||
*********************************************/ | *************************/ | |||
static_scale (fp, text->object.scale, text->center, error); | static_scale (fp, text->object.scale, text->center, error); | |||
gamgi_math_quaternion_to_axis (text->quaternion, &phi, axis); | /******************************* | |||
* rotate+move Transform start * | ||||
*******************************/ | ||||
gamgi_math_quaternion_to_axis (text->quaternion, &phi, axis); | ||||
sprintf (string, "<Transform translation=\"%.*f %.*f %.*f\" rotation=\"%.*f %.*f %.*f %.*f\">\n", | sprintf (string, "<Transform translation=\"%.*f %.*f %.*f\" rotation=\"%.*f %.*f %.*f %.*f\">\n", | |||
gamgi->gamgi->length, text->origin[0], | gamgi->gamgi->length, text->origin[0], | |||
gamgi->gamgi->length, text->origin[1], | gamgi->gamgi->length, text->origin[1], | |||
gamgi->gamgi->length, text->origin[2], | gamgi->gamgi->length, text->origin[2], | |||
gamgi->gamgi->length, axis[0], | gamgi->gamgi->length, axis[0], | |||
gamgi->gamgi->length, axis[1], | gamgi->gamgi->length, axis[1], | |||
gamgi->gamgi->length, axis[2], | gamgi->gamgi->length, axis[2], | |||
gamgi->gamgi->angle, phi); | gamgi->gamgi->angle, phi); | |||
gamgi_io_file_fprintf (fp, string, error); | gamgi_io_file_fprintf (fp, string, error); | |||
/********************************* | /*************** | |||
* start Shape, Appearance nodes * | * Shape start * | |||
*********************************/ | ***************/ | |||
gamgi_io_file_fprintf (fp, "<Shape>\n", error); | ||||
/************************ | ||||
* Appearance start+end * | ||||
************************/ | ||||
gamgi_io_file_fprintf (fp, "<Shape>\n<Appearance>\n", error); | gamgi_io_file_fprintf (fp, "<Appearance>\n", error); | |||
if (lights == TRUE) | if (lights == TRUE) | |||
sprintf (string, "<Material diffuseColor=\"%.*f %.*f %.*f\"/>\n", | sprintf (string, "<Material diffuseColor=\"%.*f %.*f %.*f\"/>\n", | |||
GAMGI_MATH_DECIMAL_COLOR, text->red, | GAMGI_MATH_DECIMAL_COLOR, text->red, | |||
GAMGI_MATH_DECIMAL_COLOR, text->green, | GAMGI_MATH_DECIMAL_COLOR, text->green, | |||
GAMGI_MATH_DECIMAL_COLOR, text->blue); | GAMGI_MATH_DECIMAL_COLOR, text->blue); | |||
else | else | |||
sprintf (string, "<Material emissiveColor=\"%.*f %.*f %.*f\"/>\n", | sprintf (string, "<Material emissiveColor=\"%.*f %.*f %.*f\"/>\n", | |||
GAMGI_MATH_DECIMAL_COLOR, text->red, | GAMGI_MATH_DECIMAL_COLOR, text->red, | |||
GAMGI_MATH_DECIMAL_COLOR, text->green, | GAMGI_MATH_DECIMAL_COLOR, text->green, | |||
GAMGI_MATH_DECIMAL_COLOR, text->blue); | GAMGI_MATH_DECIMAL_COLOR, text->blue); | |||
gamgi_io_file_fprintf(fp, string, error); | gamgi_io_file_fprintf(fp, string, error); | |||
gamgi_io_file_fprintf (fp, "</Appearance>\n", error); | gamgi_io_file_fprintf (fp, "</Appearance>\n", error); | |||
/************************* | ||||
* export geometric data * | ||||
*************************/ | ||||
if (text->font > GAMGI_IO_FONTS_WIRED) | if (text->font > GAMGI_IO_FONTS_WIRED) | |||
gamgi_io_x3d_render_solid (fp, text, error); | gamgi_io_x3d_render_solid (fp, text, error); | |||
else | else | |||
gamgi_io_x3d_render_wired (fp, text, error); | gamgi_io_x3d_render_wired (fp, text, error); | |||
/****************************** | /************************************ | |||
* end Shape, Transform nodes * | * Shape, rotate+move Transform end * | |||
******************************/ | ************************************/ | |||
gamgi_io_file_fprintf (fp, "</Shape>\n</Transform>\n", error); | gamgi_io_file_fprintf (fp, "</Shape>\n", error); | |||
gamgi_io_file_fprintf (fp, "</Transform>\n", error); | ||||
/*********************** | /*********************** | |||
* child objects: text * | * child objects: text * | |||
***********************/ | ***********************/ | |||
for (dlist = text->text_start; dlist != NULL; dlist = dlist->next) | for (dlist = text->text_start; dlist != NULL; dlist = dlist->next) | |||
static_text (fp, GAMGI_CAST_TEXT dlist->data, lights, error); | static_text (fp, GAMGI_CAST_TEXT dlist->data, lights, error); | |||
/*********************** | ||||
* scale Transform end * | ||||
***********************/ | ||||
static_unscale (fp, text->object.scale, error); | static_unscale (fp, text->object.scale, error); | |||
} | } | |||
static void static_orbital (FILE *fp, gamgi_orbital *orbital, | static void static_orbital (FILE *fp, gamgi_orbital *orbital, | |||
gamgi_bool lights, gamgi_bool *error) | gamgi_bool lights, gamgi_bool *error) | |||
{ | { | |||
gamgi_dlist *dlist; | gamgi_dlist *dlist; | |||
int *dots; | int *dots; | |||
char string[GAMGI_ENGINE_LINE]; | char string[GAMGI_ENGINE_LINE]; | |||
double axis[3]; | double axis[3]; | |||
double phi; | double phi; | |||
float background[4]; | float background[4]; | |||
float color[3]; | float color[3]; | |||
/**************************** | /************************* | |||
* scale, translate, rotate * | * scale Transform start * | |||
****************************/ | *************************/ | |||
static_scale (fp, orbital->object.scale, orbital->center, error); | static_scale (fp, orbital->object.scale, orbital->center, error); | |||
gamgi_math_quaternion_to_axis (orbital->quaternion, &phi, axis); | /******************************* | |||
* rotate+move Transform start * | ||||
*******************************/ | ||||
gamgi_math_quaternion_to_axis (orbital->quaternion, &phi, axis); | ||||
sprintf (string, "<Transform translation=\"%.*f %.*f %.*f\" rotation=\"%.*f %.*f %.*f %.*f\">\n", | sprintf (string, "<Transform translation=\"%.*f %.*f %.*f\" rotation=\"%.*f %.*f %.*f %.*f\">\n", | |||
gamgi->gamgi->length, orbital->origin[0], | gamgi->gamgi->length, orbital->origin[0], | |||
gamgi->gamgi->length, orbital->origin[1], | gamgi->gamgi->length, orbital->origin[1], | |||
gamgi->gamgi->length, orbital->origin[2], | gamgi->gamgi->length, orbital->origin[2], | |||
gamgi->gamgi->length, axis[0], | gamgi->gamgi->length, axis[0], | |||
gamgi->gamgi->length, axis[1], | gamgi->gamgi->length, axis[1], | |||
gamgi->gamgi->length, axis[2], | gamgi->gamgi->length, axis[2], | |||
gamgi->gamgi->angle, phi); | gamgi->gamgi->angle, phi); | |||
gamgi_io_file_fprintf (fp, string, error); | gamgi_io_file_fprintf (fp, string, error); | |||
glGetFloatv (GL_COLOR_CLEAR_VALUE, background); | glGetFloatv (GL_COLOR_CLEAR_VALUE, background); | |||
dots = orbital->dots; | dots = orbital->dots; | |||
if (orbital->style == GAMGI_MESA_WIRED) | if (orbital->style == GAMGI_MESA_WIRED) | |||
{ | { | |||
/************************* | ||||
* export geometric data * | ||||
*************************/ | ||||
glLineWidth (4.0); | glLineWidth (4.0); | |||
if (dots[1] > 0) | if (dots[1] > 0) | |||
{ | { | |||
color[0] = orbital->base_r; | color[0] = orbital->base_r; | |||
color[1] = orbital->base_g; | color[1] = orbital->base_g; | |||
color[2] = orbital->base_b; | color[2] = orbital->base_b; | |||
gamgi_io_x3d_render_points (fp, dots[1], | gamgi_io_x3d_render_points (fp, dots[1], | |||
orbital->points + 3 * dots[0], color, error); | orbital->points + 3 * dots[0], color, error); | |||
} | } | |||
skipping to change at line 264 | skipping to change at line 339 | |||
color[2] = orbital->phase_b; | color[2] = orbital->phase_b; | |||
gamgi_io_x3d_render_points (fp, dots[2], | gamgi_io_x3d_render_points (fp, dots[2], | |||
orbital->points + 3 * dots[0] + 3 * dots[1], color, error); | orbital->points + 3 * dots[0] + 3 * dots[1], color, error); | |||
} | } | |||
} | } | |||
if (orbital->style == GAMGI_MESA_SOLID) | if (orbital->style == GAMGI_MESA_SOLID) | |||
{ | { | |||
if (dots[1] > 0) | if (dots[1] > 0) | |||
{ | { | |||
gamgi_io_file_fprintf (fp, "<Shape>\n<Appearance>\n", error); | /*************** | |||
* Shape start * | ||||
***************/ | ||||
/************************ | ||||
* Appearance start+end * | ||||
************************/ | ||||
gamgi_io_file_fprintf (fp, "<Shape>\n", error); | ||||
gamgi_io_file_fprintf (fp, "<Appearance>\n", error); | ||||
if (lights == TRUE) | if (lights == TRUE) | |||
sprintf (string, "<Material diffuseColor=\"%.*f %.*f %.*f\"/>\n", | sprintf (string, "<Material diffuseColor=\"%.*f %.*f %.*f\"/>\n", | |||
GAMGI_MATH_DECIMAL_COLOR, orbital->base_r, | GAMGI_MATH_DECIMAL_COLOR, orbital->base_r, | |||
GAMGI_MATH_DECIMAL_COLOR, orbital->base_g, | GAMGI_MATH_DECIMAL_COLOR, orbital->base_g, | |||
GAMGI_MATH_DECIMAL_COLOR, orbital->base_b); | GAMGI_MATH_DECIMAL_COLOR, orbital->base_b); | |||
else | else | |||
sprintf (string, "<Material emissiveColor=\"%.*f %.*f %.*f\"/>\n", | sprintf (string, "<Material emissiveColor=\"%.*f %.*f %.*f\"/>\n", | |||
GAMGI_MATH_DECIMAL_COLOR, orbital->base_r, | GAMGI_MATH_DECIMAL_COLOR, orbital->base_r, | |||
GAMGI_MATH_DECIMAL_COLOR, orbital->base_g, | GAMGI_MATH_DECIMAL_COLOR, orbital->base_g, | |||
GAMGI_MATH_DECIMAL_COLOR, orbital->base_b); | GAMGI_MATH_DECIMAL_COLOR, orbital->base_b); | |||
gamgi_io_file_fprintf (fp, string, error); | gamgi_io_file_fprintf (fp, string, error); | |||
gamgi_io_file_fprintf (fp, "</Appearance>\n", error); | gamgi_io_file_fprintf (fp, "</Appearance>\n", error); | |||
/************************* | ||||
* export geometric data * | ||||
*************************/ | ||||
gamgi_io_x3d_render_triangles (fp, dots[1] / 3, | gamgi_io_x3d_render_triangles (fp, dots[1] / 3, | |||
orbital->points + 3 * dots[0], error); | orbital->points + 3 * dots[0], error); | |||
gamgi_io_file_fprintf (fp, "</Shape>\n", error); | gamgi_io_file_fprintf (fp, "</Shape>\n", error); | |||
/************* | ||||
* Shape end * | ||||
*************/ | ||||
} | } | |||
if (dots[2] > 0) | if (dots[2] > 0) | |||
{ | { | |||
gamgi_io_file_fprintf (fp, "<Shape>\n<Appearance>\n", error); | /*************** | |||
* Shape start * | ||||
***************/ | ||||
/************************ | ||||
* Appearance start+end * | ||||
************************/ | ||||
gamgi_io_file_fprintf (fp, "<Shape>\n", error); | ||||
gamgi_io_file_fprintf (fp, "<Appearance>\n", error); | ||||
if (lights == TRUE) | if (lights == TRUE) | |||
sprintf (string, "<Material diffuseColor=\"%.*f %.*f %.*f\"/>\n", | sprintf (string, "<Material diffuseColor=\"%.*f %.*f %.*f\"/>\n", | |||
GAMGI_MATH_DECIMAL_COLOR, orbital->phase_r, | GAMGI_MATH_DECIMAL_COLOR, orbital->phase_r, | |||
GAMGI_MATH_DECIMAL_COLOR, orbital->phase_g, | GAMGI_MATH_DECIMAL_COLOR, orbital->phase_g, | |||
GAMGI_MATH_DECIMAL_COLOR, orbital->phase_b); | GAMGI_MATH_DECIMAL_COLOR, orbital->phase_b); | |||
else | else | |||
sprintf (string, "<Material emissiveColor=\"%.*f %.*f %.*f\"/>\n", | sprintf (string, "<Material emissiveColor=\"%.*f %.*f %.*f\"/>\n", | |||
GAMGI_MATH_DECIMAL_COLOR, orbital->phase_r, | GAMGI_MATH_DECIMAL_COLOR, orbital->phase_r, | |||
GAMGI_MATH_DECIMAL_COLOR, orbital->phase_g, | GAMGI_MATH_DECIMAL_COLOR, orbital->phase_g, | |||
GAMGI_MATH_DECIMAL_COLOR, orbital->phase_b); | GAMGI_MATH_DECIMAL_COLOR, orbital->phase_b); | |||
gamgi_io_file_fprintf (fp, string, error); | gamgi_io_file_fprintf (fp, string, error); | |||
gamgi_io_file_fprintf (fp, "</Appearance>\n", error); | gamgi_io_file_fprintf (fp, "</Appearance>\n", error); | |||
/************************* | ||||
* export geometric data * | ||||
*************************/ | ||||
gamgi_io_x3d_render_triangles (fp, dots[2] / 3, | gamgi_io_x3d_render_triangles (fp, dots[2] / 3, | |||
orbital->points + 3 * dots[0] + 3 * dots[1], error); | orbital->points + 3 * dots[0] + 3 * dots[1], error); | |||
gamgi_io_file_fprintf (fp, "</Shape>\n", error); | gamgi_io_file_fprintf (fp, "</Shape>\n", error); | |||
} | ||||
/************* | ||||
* Shape end * | ||||
*************/ | ||||
} | ||||
} | } | |||
/****************************** | /***************************** | |||
* end Shape, Transform nodes * | * rotate+move Transform end * | |||
******************************/ | *****************************/ | |||
gamgi_io_file_fprintf (fp, "</Transform>\n", error); | gamgi_io_file_fprintf (fp, "</Transform>\n", error); | |||
/*********************** | /*********************** | |||
* child objects: text * | * child objects: text * | |||
***********************/ | ***********************/ | |||
for (dlist = orbital->text_start; dlist!=NULL; dlist = dlist->next) | for (dlist = orbital->text_start; dlist!=NULL; dlist = dlist->next) | |||
static_text (fp, GAMGI_CAST_TEXT dlist->data, lights, error); | static_text (fp, GAMGI_CAST_TEXT dlist->data, lights, error); | |||
/*********************** | ||||
* scale Transform end * | ||||
***********************/ | ||||
static_unscale (fp, orbital->object.scale, error); | static_unscale (fp, orbital->object.scale, error); | |||
} | } | |||
static void static_bond (FILE *fp, gamgi_bond *bond, gamgi_atom *atom, | static void static_bond (FILE *fp, gamgi_bond *bond, gamgi_atom *atom, | |||
gamgi_bool lights, gamgi_bool *error) | gamgi_bool lights, gamgi_bool *error) | |||
{ | { | |||
gamgi_dlist *dlist; | gamgi_dlist *dlist; | |||
char string[GAMGI_ENGINE_LINE]; | char string[GAMGI_ENGINE_LINE]; | |||
double endpoint[3]; | double endpoint[3]; | |||
double center[3], sub[3], axis[3]; | double center[3], sub[3], axis[3]; | |||
skipping to change at line 1448 | skipping to change at line 1558 | |||
gamgi->gamgi->length, direction[1], | gamgi->gamgi->length, direction[1], | |||
gamgi->gamgi->length, direction[2], | gamgi->gamgi->length, direction[2], | |||
gamgi->gamgi->length, position[0], | gamgi->gamgi->length, position[0], | |||
gamgi->gamgi->length, position[1], | gamgi->gamgi->length, position[1], | |||
gamgi->gamgi->length, position[2]); | gamgi->gamgi->length, position[2]); | |||
} | } | |||
gamgi_io_file_fprintf (fp, string, error); | gamgi_io_file_fprintf (fp, string, error); | |||
} | } | |||
static void static_layer (FILE * fp, gamgi_layer *layer, gamgi_bool *error) | static void static_layer (FILE *fp, gamgi_layer *layer, gamgi_bool *error) | |||
{ | { | |||
gamgi_dlist *dlist; | gamgi_dlist *dlist; | |||
char string[GAMGI_ENGINE_LINE]; | char string[GAMGI_ENGINE_LINE]; | |||
double normal[3]; | double normal[3]; | |||
double scale; | double scale; | |||
float color[4]; | float color[4]; | |||
gamgi_bool lights; | gamgi_bool lights; | |||
/******************************************************** | /******************************************************** | |||
* The exported scene describes only the current layer! * | * The exported scene describes only the current layer! * | |||
skipping to change at line 1475 | skipping to change at line 1585 | |||
* better simulated in X3D when headLight is set to false. * | * better simulated in X3D when headLight is set to false. * | |||
* * | * * | |||
* Possible values are: WALK, FLY, EXAMINE, LOOKAT, ANY, NONE * | * Possible values are: WALK, FLY, EXAMINE, LOOKAT, ANY, NONE * | |||
* values can be combined, for example: type='"EXAMINE" "ANY"' * | * values can be combined, for example: type='"EXAMINE" "ANY"' * | |||
* * | * * | |||
* Apparently, the GAMGI OpenGL lightning seems to be slightly * | * Apparently, the GAMGI OpenGL lightning seems to be slightly * | |||
* better simulated in X3D when global is set to false, which * | * better simulated in X3D when global is set to false, which * | |||
* means that lights apply only to the local node. * | * means that lights apply only to the local node. * | |||
***************************************************************/ | ***************************************************************/ | |||
gamgi_io_file_fprintf (fp, "<NavigationInfo headlight=\"false\"" | gamgi_io_file_fprintf (fp, "<NavigationInfo headlight=\"false\"", error); | |||
" type=\"ANY\"/>\n", error); | gamgi_io_file_fprintf (fp, " type='\"ANY\"'/>\n", error); | |||
gamgi_io_file_fprintf (fp, "<DirectionalLight global=\"false\"/>\n", error); | gamgi_io_file_fprintf (fp, "<DirectionalLight global=\"false\"/>\n", error); | |||
/************** | /************** | |||
* projection * | * projection * | |||
**************/ | **************/ | |||
if (layer->perspective == TRUE) | if (layer->perspective == TRUE) | |||
{ | { | |||
gamgi_io_file_fprintf (fp, "<Viewpoint description=\"perspective\"", error); | gamgi_io_file_fprintf (fp, "<Viewpoint description=\"perspective\"", error); | |||
End of changes. 40 change blocks. | ||||
26 lines changed or deleted | 136 lines changed or added |