Import Matthew Wong's bsp2bmp utility using quakeio functions, creating an

image_t type for the line point drawing, ditching the raw and bmp formats
in favor of pcx (for now), and renaming to bsp2img. I plan on working on
getopt, bspfile and other image formats in the future as well as generally
cleaning up the code.
This commit is contained in:
Bill Currie 2002-11-18 20:48:29 +00:00
parent 447984226e
commit 2a1d8555d2
7 changed files with 1369 additions and 2 deletions

View file

@ -1469,7 +1469,7 @@ QF_WITH_TARGETS(
QF_WITH_TARGETS( QF_WITH_TARGETS(
tools, tools,
[ --with-tools=<list> compile qf tools:], [ --with-tools=<list> compile qf tools:],
[carne,pak,qfbsp,qfcc,qfdefs,qflight,qfmodelgen,qfprogs,qfvis,qwaq,wav],dummy [bsp2img,carne,pak,qfbsp,qfcc,qfdefs,qflight,qfmodelgen,qfprogs,qfvis,qwaq,wav],dummy
) )
unset CL_TARGETS unset CL_TARGETS
@ -1631,6 +1631,7 @@ if test "x$ENABLE_servers_qw" = xyes; then
QF_NEED(qw, [common net server]) QF_NEED(qw, [common net server])
fi fi
unset BSP2IMG_TARGETS
unset CARNE_TARGETS unset CARNE_TARGETS
unset PAK_TARGETS unset PAK_TARGETS
unset QFCC_TARGETS unset QFCC_TARGETS
@ -1642,6 +1643,9 @@ unset QFVIS_TARGETS
unset QWAQ_TARGETS unset QWAQ_TARGETS
unset WAV_TARGETS unset WAV_TARGETS
unset TOOLS_TARGETS unset TOOLS_TARGETS
if test "x$ENABLE_tools_bsp2img" = xyes; then
TOOLS_TARGETS="$TOOLS_TARGETS bsp2img"
fi
if test "x$ENABLE_tools_carne" = xyes; then if test "x$ENABLE_tools_carne" = xyes; then
TOOLS_TARGETS="$TOOLS_TARGETS carne" TOOLS_TARGETS="$TOOLS_TARGETS carne"
fi fi
@ -1676,6 +1680,7 @@ if test "x$ENABLE_tools_wav" = xyes; then
TOOLS_TARGETS="$TOOLS_TARGETS wav" TOOLS_TARGETS="$TOOLS_TARGETS wav"
fi fi
AM_CONDITIONAL(BUILD_BSP2IMG, test "$ENABLE_tools_bsp2img" = "yes")
AM_CONDITIONAL(BUILD_CARNE, test "$ENABLE_tools_carne" = "yes") AM_CONDITIONAL(BUILD_CARNE, test "$ENABLE_tools_carne" = "yes")
AM_CONDITIONAL(BUILD_PAK, test "$ENABLE_tools_pak" = "yes") AM_CONDITIONAL(BUILD_PAK, test "$ENABLE_tools_pak" = "yes")
AM_CONDITIONAL(BUILD_QFBSP, test "$ENABLE_tools_qfbsp" = "yes") AM_CONDITIONAL(BUILD_QFBSP, test "$ENABLE_tools_qfbsp" = "yes")
@ -1890,6 +1895,11 @@ AC_SUBST(VID_TARGETS)
AC_SUBST(plugin_ldflags) AC_SUBST(plugin_ldflags)
AC_SUBST(plugin_libadd) AC_SUBST(plugin_libadd)
QF_DEPS(BSP2IMG,
[-I$(top_srcdir)/tools/qfbsp/include],
[$(top_builddir)/libs/util/libQFutil.la],
[$(WIN32_LIBS)],
)
QF_DEPS(QFBSP, QF_DEPS(QFBSP,
[-I$(top_srcdir)/tools/qfbsp/include], [-I$(top_srcdir)/tools/qfbsp/include],
[$(top_builddir)/libs/util/libQFutil.la], [$(top_builddir)/libs/util/libQFutil.la],
@ -2007,6 +2017,7 @@ AC_OUTPUT(
qw/source/Makefile qw/source/Makefile
tools/Makefile tools/Makefile
tools/bsp2img/Makefile
tools/carne/Makefile tools/carne/Makefile
tools/pak/Makefile tools/pak/Makefile
tools/qfbsp/Makefile tools/qfbsp/Makefile

View file

@ -1,2 +1,2 @@
SUBDIRS=carne pak qfbsp qfcc qfdefs qflight qfmodelgen qfprogs qfvis qwaq wav SUBDIRS=bsp2img carne pak qfbsp qfcc qfdefs qflight qfmodelgen qfprogs qfvis qwaq wav
bin_SCRIPTS=zpak bin_SCRIPTS=zpak

6
tools/bsp2img/.gitignore vendored Normal file
View file

@ -0,0 +1,6 @@
.deps
.libs
.vimrc
Makefile
Makefile.in
bsp2img

20
tools/bsp2img/CHANGELOG Normal file
View file

@ -0,0 +1,20 @@
0.0.1 - orig program, flat maps
0.0.2 - fixed buggy plotting code
lines overlapped properly now
0.0.3 - added Z-axis handling
0.0.4 - added command-line control of options
0.0.5 - added direction of fake-Z offsetting
0.0.6 - added camera axis, added auto-Z-offset selection
0.0.7 - started implementing extraneous line removal
0.0.8 - option to negate the picture
0.0.9 - name now bsp2bmp, as it writes an (uncompressed) BMP file
0.0.10 - bugfixes in BMP writing
0.0.11 - add option for small polygon removal and small line removal,
more BMP writing bigfixes (but still doesn't seem right).
0.0.12 - fixed a big bug introduced in last version's BMP writing code.
however is still not perfect.
qf cvs - (Bill Currie) bring into QF using quakeio functions, creating an
image_t type for the line point drawing, ditching the raw and bmp
formats in favor of pcx (for now), and renaming to bsp2img. I'll be
working on getopt, bspfile and other image formats in the future as
well as generally cleaning up the code.

18
tools/bsp2img/Makefile.am Normal file
View file

@ -0,0 +1,18 @@
BSP2IMG_LIBS=@BSP2IMG_LIBS@
BSP2IMG_DEPS=@BSP2IMG_DEPS@
BSP2IMG_INCS=@BSP2IMG_INCS@
INCLUDES= -I$(top_srcdir)/include $(BSP2IMG_INCS)
if BUILD_BSP2IMG
bsp2img=bsp2img
else
bsp2img=
endif
bin_PROGRAMS=$(bsp2img)
EXTRA_PROGRAMS=bsp2img
bsp2img_SOURCES= bsp2img.c
bsp2img_LDADD= $(BSP2IMG_LIBS)
bsp2img_DEPENDENCIES= $(BSP2IMG_DEPS)

94
tools/bsp2img/README Normal file
View file

@ -0,0 +1,94 @@
BSP2BMP v0.0.12
How to use:
-----------
bsp2bmp -h
> BSP->bitmap, version 0.0.12
>
> Usage:
> bsp2bmp [options] <bspfile> <outfile>
>
> Options:
> -s<scaledown> default: 4, ie 1/4 scale
> -z<z_scaling> default: 0 for flat map, >0 for iso 3d, -1 for auto
> -p<padding> default: 16-pixel border around final image
> -d<direction> iso 3d direction: 7 0 1
> \ | /
> 6--+--2
> / | \
> 5 4 3
> default: 7
> -c<camera_axis> default: +Z (+/- X/Y/Z axis)
> -t<flatness> threshold of dot product for edge removal;
> default is 0.90
> -e disable extraneous edges removal
> -a<area> minimum area for a polygon to be drawn
> default is 0
> -l<length> minimum length for an edge to be drawn
> default is 0
> -n negative image (black on white)
> -r write raw data, rather than bmp file
Explanation of options:
-----------------------
scaledown - amount by which the bsp map coordinates are scaled down
by when generating the bitmap. The default of 1/4 size
gives a decent compromise between detail and a not-too-
overly large resulting image. Value must be less than 1.
z_scaling - generate isometric-type (well, sorta) 3d look by taking
the Z-coordinate to shift the point when plotting the
bitmap. See <direction> for control of direction of
shift. The number specified is the maximum number of pixels
by which the shift will be done. If equal to 0 (default),
the map will be 'flat'
padding - margin to place around the image, in pixels.
Default is 16.
direction - direction in which shifting will be done for plotting of
Z-axis. Default direction is 1 (up and to the right),
which for a cube will give something like:
+-----+
/| /|
/ | / |
+--|--+ |
| +-----+
| / | /
|/ |/
+-----+
camera axis - axis along which the camera will sit. Valid choices
flatness - extraneous edges are removed by taking the dot product of
the unit vector normals of the faces which use that edge. If
the dot product is less than this threshold, then the line
will be plotted.
A dot product of 1.0 means the two faces are in the
same plane, and hence the edge should be dropped. Anything
less than the threshold will be drawn. A bit of leeway is
allowed with a 0.90 threshold for rounding errors and map
design imperfections (ie. walls not EXACTLY parallel).
area/line minimums - if a given edge is smaller than the line minimum
or a given face is smaller than the area minimum,
the line(s) won't be drawn. This can be used to
get rid of smaller details from cluttering up the
final output. You may have to play around with the
numbers to fine tune the output.
raw data - if specified, output will be the raw bitmap data, not a BMP.
Notes:
------
* NO error checking is done on the bsp file as of this moment. Use at your
own risk, if you plan on (or accidentally) specifiy a non-bsp file, or use
on a buggy (ie. improperly referenced faces/edges/etc.) bsp file.
* Edge removal is still a big buggy... occasionally some edges which should
be kept are removed anyways, or vice versa!

1218
tools/bsp2img/bsp2img.c Normal file

File diff suppressed because it is too large Load diff