Revision: 73020
http://sourceforge.net/p/brlcad/code/73020
Author: brlcad
Date: 2019-05-08 06:02:19 +0000 (Wed, 08 May 2019)
Log Message:
-----------
get a move on commits, stash uv texture coordinate data via new
mk_bot_w_normals_and_uvs() so api remains backwards compatible.
Modified Paths:
--------------
brlcad/trunk/include/rt/geom.h
brlcad/trunk/include/wdb.h
brlcad/trunk/src/libwdb/bot.c
Modified: brlcad/trunk/include/rt/geom.h
===================================================================
--- brlcad/trunk/include/rt/geom.h 2019-05-08 05:58:50 UTC (rev 73019)
+++ brlcad/trunk/include/rt/geom.h 2019-05-08 06:02:19 UTC (rev 73020)
@@ -808,6 +808,14 @@
* texturing coordinates [num_uvs*3]
*/
+ size_t num_face_uvs; /**< @brief current size of the
+ * face_uvs array below (number of
+ * faces in the array)
+ */
+ int *face_uvs; /**< @brief array of indices into the
+ * "uvs" array, one per face vertex
+ * [num_uvs*3] */
+
void *tie; /* FIXME: blind casting. TIE needs to move from TIE_FUNC to
XGLUE before this can not suck. */
};
Modified: brlcad/trunk/include/wdb.h
===================================================================
--- brlcad/trunk/include/wdb.h 2019-05-08 05:58:50 UTC (rev 73019)
+++ brlcad/trunk/include/wdb.h 2019-05-08 06:02:19 UTC (rev 73020)
@@ -470,6 +470,44 @@
);
/**
+ * Create a BOT (Bag O'Triangles) solid with face normals and uv texture
coordinates
+ */
+WDB_EXPORT int mk_bot_w_normals_and_uvs(
+ struct rt_wdb *fp, /**< database file pointer to write to
*/
+ const char *name, /**< name of bot object to write out */
+ unsigned char mode, /**< bot mode */
+ unsigned char orientation, /**< bot orientation */
+ unsigned char flags, /**< additional bot flags */
+ size_t num_vertices, /**< number of bot vertices */
+ size_t num_faces, /**< number of bot faces */
+ const fastf_t *vertices, /**< array of floats for
vertices [num_vertices*3] */
+ const int *faces, /**< array of ints for faces
[num_faces*3] */
+ const fastf_t *thickness, /**< array of plate mode
+ * thicknesses (corresponds to
+ * array of faces) NULL for
+ * modes RT_BOT_SURFACE and
+ * RT_BOT_SOLID.
+ */
+ struct bu_bitv *face_mode, /**< a flag for each face
+ * indicating thickness is
+ * appended to hit point,
+ * otherwise thickness is
+ * centered about hit point
+ */
+ size_t num_normals, /**< number of unit normals in normals
array */
+ fastf_t *normals, /**< array of floats for normals
[num_normals*3] */
+ int *face_normals, /**< array of ints (indices
+ * into normals array), must
+ * have 3*num_faces entries
+ */
+ size_t num_uvs, /* number of uv texture coordinates in uvs array */
+ fastf_t *uvs, /* array of floats for uv texture coordinates [num_uvs*3]
*/
+ int *face_uvs /* array of ints (indices into uvs array),
+ * must have 3*num_faces entries
+ */
+ );
+
+/**
* Create a brep in the geometry file. vbrep must be a void cast pointer to
* an ON_Brep shape.
*/
Modified: brlcad/trunk/src/libwdb/bot.c
===================================================================
--- brlcad/trunk/src/libwdb/bot.c 2019-05-08 05:58:50 UTC (rev 73019)
+++ brlcad/trunk/src/libwdb/bot.c 2019-05-08 06:02:19 UTC (rev 73020)
@@ -40,7 +40,7 @@
int
-mk_bot_w_normals(
+mk_bot_w_normals_and_uvs(
struct rt_wdb *fp,
const char *name,
unsigned char mode,
@@ -61,17 +61,31 @@
*/
size_t num_normals, /* number of unit normals in normals array */
fastf_t *normals, /* array of floats for normals [num_normals*3] */
- int *face_normals) /* array of ints (indices into normals array),
+ int *face_normals, /* array of ints (indices into normals array),
* must have 3*num_faces entries.
*/
+ size_t num_uvs, /* number of uv texture coordinates in uvs array */
+ fastf_t *uvs, /* array of floats for uv texture coordinates [num_uvs*3]
*/
+ int *face_uvs) /* array of ints (indices into uvs array),
+ * must have 3*num_faces entries
+ */
{
struct rt_bot_internal *bot;
size_t i;
- if ((num_normals > 0) && (db_version(fp->dbip) < 5)) {
- bu_log("You are using an old database format which does not support
surface normals for BOT primitives\n");
- bu_log("You are attempting to create a BOT primitive named \"%s\" with
surface normals\n", name);
- bu_log("The surface normals will not be saved\n");
+ if (db_version(fp->dbip) < 5) {
+ bu_log("NOTE: You are using an old database format which does not
support.\n"
+ " surface normals or uv texture coordinates for BOT
primitives.\n\n");
+ if (num_normals && num_uvs) {
+ bu_log("You are attempting to create a BOT named \"%s\" with
normals and uv texture coordinates.\n", name);
+ bu_log("WARNING: The surface normals and uv texture coordindates
will NOT be saved.\n");
+ } else if (num_normals) {
+ bu_log("You are attempting to create a BOT named \"%s\" with
normals.\n", name);
+ bu_log("WARNING: The surface normals will NOT be saved.\n");
+ } else if (num_uvs) {
+ bu_log("You are attempting to create a BOT named \"%s\" with uv
texture coordinates.\n", name);
+ bu_log("WARNING: The surface uv texture coordinates will NOT be
saved.\n");
+ }
bu_log("Please upgrade to the current database format by using
\"dbupgrade\"\n");
}
@@ -82,12 +96,15 @@
bot->bot_flags = flags;
bot->num_vertices = num_vertices;
bot->num_faces = num_faces;
+
bot->vertices = (fastf_t *)bu_calloc(num_vertices * 3, sizeof(fastf_t),
"bot->vertices");
for (i=0; i<num_vertices*3; i++)
bot->vertices[i] = vertices[i];
+
bot->faces = (int *)bu_calloc(num_faces * 3, sizeof(int), "bot->faces");
for (i=0; i<num_faces*3; i++)
bot->faces[i] = faces[i];
+
if (mode == RT_BOT_PLATE) {
bot->thickness = (fastf_t *)bu_calloc(num_faces, sizeof(fastf_t),
"bot->thickness");
for (i=0; i<num_faces; i++)
@@ -98,19 +115,37 @@
bot->face_mode = (struct bu_bitv *)NULL;
}
- if ((num_normals > 0) && (db_version(fp->dbip) > 4)) {
- bot->num_normals = num_normals;
- bot->num_face_normals = bot->num_faces;
- bot->normals = (fastf_t *)bu_calloc(bot->num_normals * 3,
sizeof(fastf_t), "BOT normals");
- bot->face_normals = (int *)bu_calloc(bot->num_faces * 3, sizeof(int),
"BOT face normals");
- memcpy(bot->normals, normals, bot->num_normals * 3 * sizeof(fastf_t));
- memcpy(bot->face_normals, face_normals, bot->num_faces * 3 *
sizeof(int));
- } else {
+ if (db_version(fp->dbip) < 5) {
bot->bot_flags = 0;
+
bot->num_normals = 0;
+ bot->normals = (fastf_t *)NULL;
bot->num_face_normals = 0;
- bot->normals = (fastf_t *)NULL;
bot->face_normals = (int *)NULL;
+
+ bot->num_uvs = 0;
+ bot->uvs = (fastf_t *)NULL;
+ bot->num_face_uvs = 0;
+ bot->face_uvs = (int *)NULL;
+ } else {
+ if (num_normals > 0) {
+ bot->num_normals = num_normals;
+ bot->normals = (fastf_t *)bu_calloc(bot->num_normals * 3,
sizeof(fastf_t), "BOT normals");
+ memcpy(bot->normals, normals, bot->num_normals * 3 *
sizeof(fastf_t));
+
+ bot->num_face_normals = bot->num_faces;
+ bot->face_normals = (int *)bu_calloc(bot->num_faces * 3,
sizeof(int), "BOT face normals");
+ memcpy(bot->face_normals, face_normals, bot->num_faces * 3 *
sizeof(int));
+ }
+ if (num_uvs > 0) {
+ bot->num_uvs = num_uvs;
+ bot->uvs = (fastf_t *)bu_calloc(bot->num_uvs * 3, sizeof(fastf_t),
"BOT uvs");
+ memcpy(bot->uvs, uvs, bot->num_uvs * 3 * sizeof(fastf_t));
+
+ bot->num_face_uvs = bot->num_faces;
+ bot->face_uvs = (int *)bu_calloc(bot->num_faces * 3, sizeof(int),
"BOT face uvs");
+ memcpy(bot->face_uvs, face_uvs, bot->num_faces * 3 * sizeof(int));
+ }
}
return wdb_export(fp, name, (void *)bot, ID_BOT, mk_conv2mm);
@@ -118,6 +153,37 @@
int
+mk_bot_w_normals(
+ struct rt_wdb *fp,
+ const char *name,
+ unsigned char mode,
+ unsigned char orientation,
+ unsigned char flags,
+ size_t num_vertices,
+ size_t num_faces,
+ const fastf_t *vertices, /* array of floats for vertices
[num_vertices*3] */
+ const int *faces, /* array of ints for faces [num_faces*3] */
+ const fastf_t *thickness, /* array of plate mode thicknesses
+ * (corresponds to array of faces) NULL for
+ * modes RT_BOT_SURFACE and RT_BOT_SOLID.
+ */
+ struct bu_bitv *face_mode, /* a flag for each face indicating
+ * thickness is appended to hit point,
+ * otherwise thickness is centered
+ * about hit point
+ */
+ size_t num_normals, /* number of unit normals in normals array */
+ fastf_t *normals, /* array of floats for normals [num_normals*3] */
+ int *face_normals) /* array of ints (indices into normals array),
+ * must have 3*num_faces entries.
+ */
+{
+ return (mk_bot_w_normals_and_uvs(fp, name, mode, orientation, flags,
num_vertices, num_faces, vertices,
+ faces, thickness, face_mode, num_normals,
normals, face_normals, 0, NULL, NULL));
+}
+
+
+int
mk_bot(
struct rt_wdb *fp,
const char *name,
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits