gamgi_io_x3d_render.c (gamgi-all-0.17.4x) | : | gamgi_io_x3d_render.c (gamgi-all-0.17.5x) | ||
---|---|---|---|---|
skipping to change at line 118 | skipping to change at line 118 | |||
* render a X3D point * | * render a X3D point * | |||
*******************************************/ | *******************************************/ | |||
static void static_point (FILE *fp, int n_points, double *points, | static void static_point (FILE *fp, int n_points, double *points, | |||
float *color, int type, int width, int pattern, gamgi_bool *error) | float *color, int type, int width, int pattern, gamgi_bool *error) | |||
{ | { | |||
char string[GAMGI_ENGINE_LINE]; | char string[GAMGI_ENGINE_LINE]; | |||
float p[3]; | float p[3]; | |||
int i; | int i; | |||
if (n_points > 0) | if (n_points <= 0) return; | |||
{ | ||||
gamgi_io_file_fprintf(fp, "<Shape>\n", error); | ||||
if (color != NULL || width == TRUE || pattern == TRUE) | /*************** | |||
{ | * Shape start * | |||
gamgi_io_file_fprintf(fp, "<Appearance>\n", error); | ***************/ | |||
if (width == TRUE || pattern == TRUE) | gamgi_io_file_fprintf (fp, "<Shape>\n", error); | |||
gamgi_io_file_fprintf(fp, "<LineProperties ", error); | ||||
if (width == TRUE) | /******************** | |||
{ | * Appearance start * | |||
sprintf (string, "linewidthScaleFactor='%d' ", width); | ********************/ | |||
gamgi_io_file_fprintf (fp, string, error); | ||||
} | ||||
if (pattern == TRUE) | ||||
{ | ||||
sprintf (string, "linetype='%d' ", pattern); | ||||
gamgi_io_file_fprintf (fp, string, error); | ||||
} | ||||
if (width == TRUE || pattern == TRUE) | ||||
gamgi_io_file_fprintf(fp, "/>\n", error); | ||||
if (color != NULL) | ||||
{ | ||||
sprintf (string, "<Material emissiveColor='%f %f %f'/>\n", | ||||
color[0], color[1], color[2]); | ||||
gamgi_io_file_fprintf (fp, string, error); | ||||
} | ||||
gamgi_io_file_fprintf (fp, "</Appearance>\n", error); | if (color != NULL || width == TRUE || pattern == TRUE) | |||
} | { | |||
gamgi_io_file_fprintf (fp, "<Appearance>\n", error); | ||||
/************************ | ||||
* LineProperties start * | ||||
************************/ | ||||
gamgi_io_file_fprintf (fp, "<IndexedLineSet coordIndex='", error); | if (width == TRUE || pattern == TRUE) | |||
gamgi_io_file_fprintf (fp, "<LineProperties ", error); | ||||
for (i = 0; i < n_points; i++) | if (width == TRUE) | |||
{ | { | |||
if (type == 1) | sprintf (string, "linewidthScaleFactor=\"%d\" ", width); | |||
sprintf (string, "%d %d -1 %d %d -1 %d %d -1 %d %d -1", | gamgi_io_file_fprintf (fp, string, error); | |||
i*8, i*8+1, i*8+2, i*8+3, i*8+4, i*8+5, i*8+6, i*8+7); | } | |||
else | ||||
sprintf (string, "%d %d -1 %d %d -1 %d %d -1", | ||||
i*6, i*6+1, i*6+2, i*6+3, i*6+4, i*6+5); | ||||
if (pattern == TRUE) | ||||
{ | ||||
sprintf (string, "linetype=\"%d\" ", pattern); | ||||
gamgi_io_file_fprintf (fp, string, error); | gamgi_io_file_fprintf (fp, string, error); | |||
} | ||||
/*********************** | /********************** | |||
* not the last point! * | * LineProperties end * | |||
***********************/ | **********************/ | |||
if (i != n_points - 1) | if (width == TRUE || pattern == TRUE) | |||
gamgi_io_file_fprintf (fp, " ", error); | gamgi_io_file_fprintf (fp, "/>\n", error); | |||
if (color != NULL) | ||||
{ | ||||
sprintf (string, "<Material emissiveColor=\"%f %f %f\"/>\n", | ||||
color[0], color[1], color[2]); | ||||
gamgi_io_file_fprintf (fp, string, error); | ||||
} | } | |||
gamgi_io_file_fprintf (fp, "'>\n<Coordinate point='", error); | gamgi_io_file_fprintf (fp, "</Appearance>\n", error); | |||
} | ||||
/****************** | ||||
* Appearance end * | ||||
******************/ | ||||
/************************ | ||||
* IndexedlineSet start * | ||||
************************/ | ||||
gamgi_io_file_fprintf (fp, "<IndexedLineSet coordIndex=\"\n", error); | ||||
for (i = 0; i < n_points; i++) | ||||
{ | ||||
if (type == 1) | ||||
sprintf (string, "%d %d -1 %d %d -1 %d %d -1 %d %d -1\n", | ||||
i*8 + 0, i*8 + 1, i*8 + 2, i*8 + 3, i*8 + 4, i*8 + 5, i*8 + 6, i*8 + 7); | ||||
else | ||||
sprintf (string, "%d %d -1 %d %d -1 %d %d -1\n", | ||||
i*6 + 0, i*6 + 1, i*6 + 2, i*6 + 3, i*6 + 4, i*6 + 5); | ||||
gamgi_io_file_fprintf (fp, string, error); | ||||
} | ||||
gamgi_io_file_fprintf (fp, "\">\n", error); | ||||
/******************** | ||||
* Coordinate start * | ||||
********************/ | ||||
gamgi_io_file_fprintf (fp, "<Coordinate point=\"\n", error); | ||||
for (i = 0; i < n_points; i++) | ||||
{ | ||||
p[0] = points[3*i + 0]; | ||||
p[1] = points[3*i + 1]; | ||||
p[2] = points[3*i + 2]; | ||||
for (i = 0; i < n_points; i++) | if (type == 1) | |||
{ | { | |||
p[0] = points[3*i + 0]; | sprintf (string, "%f %f %f %f %f %f\n", | |||
p[1] = points[3*i + 1]; | p[0] - GAMGI_IO_X3D_POINT_SIZE, p[1] + GAMGI_IO_X3D_POINT_SIZE, | |||
p[2] = points[3*i + 2]; | p[2] - GAMGI_IO_X3D_POINT_SIZE, p[0] + GAMGI_IO_X3D_POINT_SIZE, | |||
p[1] - GAMGI_IO_X3D_POINT_SIZE, p[2] + GAMGI_IO_X3D_POINT_SIZE); | ||||
if (type == 1) | gamgi_io_file_fprintf (fp, string, error); | |||
sprintf (string, "%f %f %f, %f %f %f, %f %f %f, %f %f %f, %f %f %f, %f %f | ||||
%f, %f %f %f, %f %f %f", | ||||
p[0] - GAMGI_IO_X3D_POINT_SIZE, p[1] + GAMGI_IO_X3D_POINT_SIZE, p[2] - GAM | ||||
GI_IO_X3D_POINT_SIZE, | ||||
p[0] + GAMGI_IO_X3D_POINT_SIZE, p[1] - GAMGI_IO_X3D_POINT_SIZE, p[2] + GAM | ||||
GI_IO_X3D_POINT_SIZE, | ||||
p[0] + GAMGI_IO_X3D_POINT_SIZE, p[1] + GAMGI_IO_X3D_POINT_SIZE, p[2] - GAM | ||||
GI_IO_X3D_POINT_SIZE, | ||||
p[0] - GAMGI_IO_X3D_POINT_SIZE, p[1] - GAMGI_IO_X3D_POINT_SIZE, p[2] + GAM | ||||
GI_IO_X3D_POINT_SIZE, | ||||
p[0] - GAMGI_IO_X3D_POINT_SIZE, p[1] + GAMGI_IO_X3D_POINT_SIZE, p[2] + GAM | ||||
GI_IO_X3D_POINT_SIZE, | ||||
p[0] + GAMGI_IO_X3D_POINT_SIZE, p[1] - GAMGI_IO_X3D_POINT_SIZE, p[2] - GAM | ||||
GI_IO_X3D_POINT_SIZE, | ||||
p[0] + GAMGI_IO_X3D_POINT_SIZE, p[1] + GAMGI_IO_X3D_POINT_SIZE, p[2] + GAM | ||||
GI_IO_X3D_POINT_SIZE, | ||||
p[0] - GAMGI_IO_X3D_POINT_SIZE, p[1] - GAMGI_IO_X3D_POINT_SIZE, p[2] - GAM | ||||
GI_IO_X3D_POINT_SIZE); | ||||
else | ||||
sprintf (string, "%f %f %f, %f %f %f, %f %f %f, %f %f %f, %f %f %f, %f %f | ||||
%f", | ||||
p[0] + GAMGI_IO_X3D_POINT_SIZE, p[1], p[2], | ||||
p[0] - GAMGI_IO_X3D_POINT_SIZE, p[1], p[2], | ||||
p[0], p[1] + GAMGI_IO_X3D_POINT_SIZE, p[2], | ||||
p[0], p[1] - GAMGI_IO_X3D_POINT_SIZE, p[2], | ||||
p[0], p[1], p[2] + GAMGI_IO_X3D_POINT_SIZE, | ||||
p[0], p[1], p[2] - GAMGI_IO_X3D_POINT_SIZE); | ||||
sprintf (string, "%f %f %f %f %f %f\n", | ||||
p[0] + GAMGI_IO_X3D_POINT_SIZE, p[1] + GAMGI_IO_X3D_POINT_SIZE, | ||||
p[2] - GAMGI_IO_X3D_POINT_SIZE, p[0] - GAMGI_IO_X3D_POINT_SIZE, | ||||
p[1] - GAMGI_IO_X3D_POINT_SIZE, p[2] + GAMGI_IO_X3D_POINT_SIZE); | ||||
gamgi_io_file_fprintf (fp, string, error); | gamgi_io_file_fprintf (fp, string, error); | |||
/*********************** | sprintf (string, "%f %f %f %f %f %f\n", | |||
* not the last point! * | p[0] - GAMGI_IO_X3D_POINT_SIZE, p[1] + GAMGI_IO_X3D_POINT_SIZE, | |||
***********************/ | p[2] + GAMGI_IO_X3D_POINT_SIZE, p[0] + GAMGI_IO_X3D_POINT_SIZE, | |||
p[1] - GAMGI_IO_X3D_POINT_SIZE, p[2] - GAMGI_IO_X3D_POINT_SIZE); | ||||
gamgi_io_file_fprintf (fp, string, error); | ||||
if (i != n_points - 1) | sprintf (string, "%f %f %f %f %f %f\n", | |||
gamgi_io_file_fprintf (fp, ", ", error); | p[0] + GAMGI_IO_X3D_POINT_SIZE, p[1] + GAMGI_IO_X3D_POINT_SIZE, | |||
p[2] + GAMGI_IO_X3D_POINT_SIZE, p[0] - GAMGI_IO_X3D_POINT_SIZE, | ||||
p[1] - GAMGI_IO_X3D_POINT_SIZE, p[2] - GAMGI_IO_X3D_POINT_SIZE); | ||||
gamgi_io_file_fprintf (fp, string, error); | ||||
} | } | |||
else | ||||
{ | ||||
sprintf (string, "%f %f %f %f %f %f\n", | ||||
p[0] + GAMGI_IO_X3D_POINT_SIZE, p[1], p[2], | ||||
p[0] - GAMGI_IO_X3D_POINT_SIZE, p[1], p[2]); | ||||
gamgi_io_file_fprintf (fp, string, error); | ||||
sprintf (string, "%f %f %f %f %f %f\n", | ||||
p[0], p[1] + GAMGI_IO_X3D_POINT_SIZE, p[2], | ||||
p[0], p[1] - GAMGI_IO_X3D_POINT_SIZE, p[2]); | ||||
gamgi_io_file_fprintf (fp, string, error); | ||||
gamgi_io_file_fprintf (fp, "'/>\n</IndexedLineSet>\n</Shape>\n", error); | sprintf (string, "%f %f %f %f %f %f\n", | |||
p[0], p[1], p[2] + GAMGI_IO_X3D_POINT_SIZE, | ||||
p[0], p[1], p[2] - GAMGI_IO_X3D_POINT_SIZE); | ||||
gamgi_io_file_fprintf (fp, string, error); | ||||
} | ||||
} | } | |||
/*************************************** | ||||
* Coordinate+IndexedLineSet+Shape end * | ||||
***************************************/ | ||||
gamgi_io_file_fprintf (fp, "\"/>\n", error); | ||||
gamgi_io_file_fprintf (fp, "</IndexedLineSet>\n", error); | ||||
gamgi_io_file_fprintf (fp, "</Shape>\n", error); | ||||
} | } | |||
/************* external function *********** | /************* external function *********** | |||
* * | * * | |||
* GAMGI_IO_X3D_RENDER_CROSS * | * GAMGI_IO_X3D_RENDER_CROSS * | |||
* * | * * | |||
* draws points of the type "cross" * | * draws points of the type "cross" * | |||
*******************************************/ | *******************************************/ | |||
void gamgi_io_x3d_render_cross (FILE *fp, int n_points, | void gamgi_io_x3d_render_cross (FILE *fp, int n_points, | |||
skipping to change at line 608 | skipping to change at line 652 | |||
if(i!=c) | if(i!=c) | |||
gamgi_io_file_fprintf(fp, ", ", error); | gamgi_io_file_fprintf(fp, ", ", error); | |||
} | } | |||
gamgi_io_file_fprintf(fp, "'/>\n</IndexedFaceSet>\n", error); | gamgi_io_file_fprintf(fp, "'/>\n</IndexedFaceSet>\n", error); | |||
for(i=0; i<n_loops; i++) free(point[i]); | for(i=0; i<n_loops; i++) free(point[i]); | |||
free(point); | free(point); | |||
} | } | |||
/* draws wired text */ | /************* internal function *************** | |||
* * | ||||
* GAMGI_IO_X3D_RENDER_WIRED * | ||||
* * | ||||
* draws wired text using the hard coded fonts * | ||||
***********************************************/ | ||||
void gamgi_io_x3d_render_wired (FILE *fp, gamgi_text *text, gamgi_bool *error) | void gamgi_io_x3d_render_wired (FILE *fp, gamgi_text *text, gamgi_bool *error) | |||
{ | { | |||
int c = 0; | int c = 0; | |||
int i, j; | int i, j; | |||
int * driver = 0; | int *driver; | |||
float * points = 0; | float *points; | |||
char str[256]; | char str[256]; | |||
float spacing; | float spacing; | |||
gamgi_mesa_text_data_wired (text->font, (const float **) &points, (const int **) &driver); | printf ("ola\n"); | |||
gamgi_io_file_fprintf(fp, "<IndexedLineSet coordIndex='", error); | gamgi_mesa_text_data_wired (text->font, (const float **) &points, (const int **) | |||
&driver); | ||||
gamgi_io_file_fprintf (fp, "<IndexedLineSet coordIndex='", error); | ||||
for(i=0; i<text->length; i++) | for(i=0; i<text->length; i++) | |||
{ | { | |||
j = driver[text->string[i]-GAMGI_IO_ASCII_START]; | j = driver[text->string[i]-GAMGI_IO_ASCII_START]; | |||
while(points[j] != GAMGI_IO_CHAR) | while(points[j] != GAMGI_IO_CHAR) | |||
{ | { | |||
if(points[j] == GAMGI_IO_STROKE) | if(points[j] == GAMGI_IO_STROKE) | |||
{ | { | |||
gamgi_io_file_fprintf(fp, "-1, ", error); | gamgi_io_file_fprintf(fp, "-1, ", error); | |||
End of changes. 25 change blocks. | ||||
93 lines changed or deleted | 135 lines changed or added |