zoomedit:
* Added 2D vector maths * Made rooms selectable
This commit is contained in:
parent
094c72221e
commit
5bb27d2b6d
20 changed files with 893 additions and 23 deletions
2
aclocal.m4
vendored
2
aclocal.m4
vendored
|
@ -252,7 +252,7 @@ AC_DEFUN([AC_GTKGLEXT_SUPPORTS_MULTIHEAD],
|
||||||
|
|
||||||
# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
|
# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
|
||||||
|
|
||||||
# serial 52 Debian 1.5.26-1 AC_PROG_LIBTOOL
|
# serial 52 Debian 1.5.26-1ubuntu1 AC_PROG_LIBTOOL
|
||||||
|
|
||||||
|
|
||||||
# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
|
# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
|
||||||
|
|
3
configure
vendored
3
configure
vendored
|
@ -20541,7 +20541,7 @@ LIBS="$glademm_LIBS $GTKGLEXT_LIBS $libxml_LIBS $LIBS"
|
||||||
|
|
||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
|
|
||||||
ac_config_files="$ac_config_files Makefile src/Makefile src/Data/Makefile src/Gui/Makefile src/Util/Makefile src/View/Makefile"
|
ac_config_files="$ac_config_files Makefile src/Makefile src/Data/Makefile src/Gui/Makefile src/Math/Makefile src/Util/Makefile src/View/Makefile"
|
||||||
|
|
||||||
cat >confcache <<\_ACEOF
|
cat >confcache <<\_ACEOF
|
||||||
# This file is a shell script that caches the results of configure
|
# This file is a shell script that caches the results of configure
|
||||||
|
@ -21140,6 +21140,7 @@ do
|
||||||
"src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
|
"src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
|
||||||
"src/Data/Makefile") CONFIG_FILES="$CONFIG_FILES src/Data/Makefile" ;;
|
"src/Data/Makefile") CONFIG_FILES="$CONFIG_FILES src/Data/Makefile" ;;
|
||||||
"src/Gui/Makefile") CONFIG_FILES="$CONFIG_FILES src/Gui/Makefile" ;;
|
"src/Gui/Makefile") CONFIG_FILES="$CONFIG_FILES src/Gui/Makefile" ;;
|
||||||
|
"src/Math/Makefile") CONFIG_FILES="$CONFIG_FILES src/Math/Makefile" ;;
|
||||||
"src/Util/Makefile") CONFIG_FILES="$CONFIG_FILES src/Util/Makefile" ;;
|
"src/Util/Makefile") CONFIG_FILES="$CONFIG_FILES src/Util/Makefile" ;;
|
||||||
"src/View/Makefile") CONFIG_FILES="$CONFIG_FILES src/View/Makefile" ;;
|
"src/View/Makefile") CONFIG_FILES="$CONFIG_FILES src/View/Makefile" ;;
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ AC_CONFIG_FILES([
|
||||||
src/Makefile
|
src/Makefile
|
||||||
src/Data/Makefile
|
src/Data/Makefile
|
||||||
src/Gui/Makefile
|
src/Gui/Makefile
|
||||||
|
src/Math/Makefile
|
||||||
src/Util/Makefile
|
src/Util/Makefile
|
||||||
src/View/Makefile
|
src/View/Makefile
|
||||||
])
|
])
|
||||||
|
|
|
@ -130,8 +130,7 @@ bool RenderArea::onScrollEvent(GdkEventScroll *event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderArea::onButtonPressEvent(GdkEventButton *event) {
|
bool RenderArea::onButtonPressEvent(GdkEventButton *event) {
|
||||||
if(view && event->button == 1)
|
view->click(event->x - get_width()/2, event->y - get_height()/2, event->button);
|
||||||
view->click(event->x, event->y);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,9 @@ void Instance::createLevel() {
|
||||||
start->set_attribute("y", "0");
|
start->set_attribute("y", "0");
|
||||||
start->set_attribute("z", "0");
|
start->set_attribute("z", "0");
|
||||||
|
|
||||||
root->add_child("rooms");
|
xmlpp::Element *rooms = root->add_child("rooms");
|
||||||
|
rooms->add_child("floor");
|
||||||
|
|
||||||
root->add_child("gates");
|
root->add_child("gates");
|
||||||
root->add_child("textures");
|
root->add_child("textures");
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
SUBDIRS = Data Gui Util View
|
SUBDIRS = Data Gui Math Util View
|
||||||
|
|
||||||
bin_PROGRAMS = zoomedit
|
bin_PROGRAMS = zoomedit
|
||||||
zoomedit_SOURCES = zoomedit.cpp Instance.cpp
|
zoomedit_SOURCES = zoomedit.cpp Instance.cpp
|
||||||
zoomedit_LDADD = Data/libdata.la Gui/libgui.la Util/libutil.la View/libview.la
|
zoomedit_LDADD = Data/libdata.la Gui/libgui.la Util/libutil.la View/libview.la Math/libmath.la
|
||||||
|
|
|
@ -49,7 +49,7 @@ PROGRAMS = $(bin_PROGRAMS)
|
||||||
am_zoomedit_OBJECTS = zoomedit.$(OBJEXT) Instance.$(OBJEXT)
|
am_zoomedit_OBJECTS = zoomedit.$(OBJEXT) Instance.$(OBJEXT)
|
||||||
zoomedit_OBJECTS = $(am_zoomedit_OBJECTS)
|
zoomedit_OBJECTS = $(am_zoomedit_OBJECTS)
|
||||||
zoomedit_DEPENDENCIES = Data/libdata.la Gui/libgui.la Util/libutil.la \
|
zoomedit_DEPENDENCIES = Data/libdata.la Gui/libgui.la Util/libutil.la \
|
||||||
View/libview.la
|
View/libview.la Math/libmath.la
|
||||||
DEFAULT_INCLUDES = -I.@am__isrc@
|
DEFAULT_INCLUDES = -I.@am__isrc@
|
||||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||||
am__depfiles_maybe = depfiles
|
am__depfiles_maybe = depfiles
|
||||||
|
@ -193,9 +193,9 @@ sysconfdir = @sysconfdir@
|
||||||
target_alias = @target_alias@
|
target_alias = @target_alias@
|
||||||
top_builddir = @top_builddir@
|
top_builddir = @top_builddir@
|
||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
SUBDIRS = Data Gui Util View
|
SUBDIRS = Data Gui Math Util View
|
||||||
zoomedit_SOURCES = zoomedit.cpp Instance.cpp
|
zoomedit_SOURCES = zoomedit.cpp Instance.cpp
|
||||||
zoomedit_LDADD = Data/libdata.la Gui/libgui.la Util/libutil.la View/libview.la
|
zoomedit_LDADD = Data/libdata.la Gui/libgui.la Util/libutil.la View/libview.la Math/libmath.la
|
||||||
all: config.h
|
all: config.h
|
||||||
$(MAKE) $(AM_MAKEFLAGS) all-recursive
|
$(MAKE) $(AM_MAKEFLAGS) all-recursive
|
||||||
|
|
||||||
|
|
3
src/Math/Makefile.am
Normal file
3
src/Math/Makefile.am
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
noinst_LTLIBRARIES = libmath.la
|
||||||
|
|
||||||
|
libmath_la_SOURCES = Triangle2D.cpp Vector2D.cpp Vertex2D.cpp
|
442
src/Math/Makefile.in
Normal file
442
src/Math/Makefile.in
Normal file
|
@ -0,0 +1,442 @@
|
||||||
|
# Makefile.in generated by automake 1.10.1 from Makefile.am.
|
||||||
|
# @configure_input@
|
||||||
|
|
||||||
|
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||||
|
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||||
|
# This Makefile.in is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||||
|
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
# PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
@SET_MAKE@
|
||||||
|
|
||||||
|
VPATH = @srcdir@
|
||||||
|
pkgdatadir = $(datadir)/@PACKAGE@
|
||||||
|
pkglibdir = $(libdir)/@PACKAGE@
|
||||||
|
pkgincludedir = $(includedir)/@PACKAGE@
|
||||||
|
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||||
|
install_sh_DATA = $(install_sh) -c -m 644
|
||||||
|
install_sh_PROGRAM = $(install_sh) -c
|
||||||
|
install_sh_SCRIPT = $(install_sh) -c
|
||||||
|
INSTALL_HEADER = $(INSTALL_DATA)
|
||||||
|
transform = $(program_transform_name)
|
||||||
|
NORMAL_INSTALL = :
|
||||||
|
PRE_INSTALL = :
|
||||||
|
POST_INSTALL = :
|
||||||
|
NORMAL_UNINSTALL = :
|
||||||
|
PRE_UNINSTALL = :
|
||||||
|
POST_UNINSTALL = :
|
||||||
|
build_triplet = @build@
|
||||||
|
host_triplet = @host@
|
||||||
|
subdir = src/Math
|
||||||
|
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||||
|
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||||
|
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||||
|
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||||
|
$(ACLOCAL_M4)
|
||||||
|
mkinstalldirs = $(install_sh) -d
|
||||||
|
CONFIG_HEADER = $(top_builddir)/src/config.h
|
||||||
|
CONFIG_CLEAN_FILES =
|
||||||
|
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||||
|
libmath_la_LIBADD =
|
||||||
|
am_libmath_la_OBJECTS = Triangle2D.lo Vector2D.lo Vertex2D.lo
|
||||||
|
libmath_la_OBJECTS = $(am_libmath_la_OBJECTS)
|
||||||
|
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
|
||||||
|
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||||
|
am__depfiles_maybe = depfiles
|
||||||
|
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||||
|
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||||
|
LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||||
|
--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||||
|
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||||
|
CXXLD = $(CXX)
|
||||||
|
CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||||
|
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
|
||||||
|
$(LDFLAGS) -o $@
|
||||||
|
SOURCES = $(libmath_la_SOURCES)
|
||||||
|
DIST_SOURCES = $(libmath_la_SOURCES)
|
||||||
|
ETAGS = etags
|
||||||
|
CTAGS = ctags
|
||||||
|
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||||
|
ACLOCAL = @ACLOCAL@
|
||||||
|
AMTAR = @AMTAR@
|
||||||
|
AR = @AR@
|
||||||
|
AUTOCONF = @AUTOCONF@
|
||||||
|
AUTOHEADER = @AUTOHEADER@
|
||||||
|
AUTOMAKE = @AUTOMAKE@
|
||||||
|
AWK = @AWK@
|
||||||
|
CC = @CC@
|
||||||
|
CCDEPMODE = @CCDEPMODE@
|
||||||
|
CFLAGS = @CFLAGS@
|
||||||
|
CPP = @CPP@
|
||||||
|
CPPFLAGS = @CPPFLAGS@
|
||||||
|
CXX = @CXX@
|
||||||
|
CXXCPP = @CXXCPP@
|
||||||
|
CXXDEPMODE = @CXXDEPMODE@
|
||||||
|
CXXFLAGS = @CXXFLAGS@
|
||||||
|
CYGPATH_W = @CYGPATH_W@
|
||||||
|
DEFS = @DEFS@
|
||||||
|
DEPDIR = @DEPDIR@
|
||||||
|
DSYMUTIL = @DSYMUTIL@
|
||||||
|
ECHO = @ECHO@
|
||||||
|
ECHO_C = @ECHO_C@
|
||||||
|
ECHO_N = @ECHO_N@
|
||||||
|
ECHO_T = @ECHO_T@
|
||||||
|
EGREP = @EGREP@
|
||||||
|
EXEEXT = @EXEEXT@
|
||||||
|
F77 = @F77@
|
||||||
|
FFLAGS = @FFLAGS@
|
||||||
|
GREP = @GREP@
|
||||||
|
GTKGLEXT_CFLAGS = @GTKGLEXT_CFLAGS@
|
||||||
|
GTKGLEXT_LIBS = @GTKGLEXT_LIBS@
|
||||||
|
INSTALL = @INSTALL@
|
||||||
|
INSTALL_DATA = @INSTALL_DATA@
|
||||||
|
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||||
|
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||||
|
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||||
|
LDFLAGS = @LDFLAGS@
|
||||||
|
LIBOBJS = @LIBOBJS@
|
||||||
|
LIBS = @LIBS@
|
||||||
|
LIBTOOL = @LIBTOOL@
|
||||||
|
LN_S = @LN_S@
|
||||||
|
LTLIBOBJS = @LTLIBOBJS@
|
||||||
|
MAINT = @MAINT@
|
||||||
|
MAKEINFO = @MAKEINFO@
|
||||||
|
MKDIR_P = @MKDIR_P@
|
||||||
|
NMEDIT = @NMEDIT@
|
||||||
|
OBJEXT = @OBJEXT@
|
||||||
|
PACKAGE = @PACKAGE@
|
||||||
|
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||||
|
PACKAGE_NAME = @PACKAGE_NAME@
|
||||||
|
PACKAGE_STRING = @PACKAGE_STRING@
|
||||||
|
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||||
|
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||||
|
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||||
|
PKG_CONFIG = @PKG_CONFIG@
|
||||||
|
RANLIB = @RANLIB@
|
||||||
|
SED = @SED@
|
||||||
|
SET_MAKE = @SET_MAKE@
|
||||||
|
SHELL = @SHELL@
|
||||||
|
STRIP = @STRIP@
|
||||||
|
VERSION = @VERSION@
|
||||||
|
abs_builddir = @abs_builddir@
|
||||||
|
abs_srcdir = @abs_srcdir@
|
||||||
|
abs_top_builddir = @abs_top_builddir@
|
||||||
|
abs_top_srcdir = @abs_top_srcdir@
|
||||||
|
ac_ct_CC = @ac_ct_CC@
|
||||||
|
ac_ct_CXX = @ac_ct_CXX@
|
||||||
|
ac_ct_F77 = @ac_ct_F77@
|
||||||
|
am__include = @am__include@
|
||||||
|
am__leading_dot = @am__leading_dot@
|
||||||
|
am__quote = @am__quote@
|
||||||
|
am__tar = @am__tar@
|
||||||
|
am__untar = @am__untar@
|
||||||
|
bindir = @bindir@
|
||||||
|
build = @build@
|
||||||
|
build_alias = @build_alias@
|
||||||
|
build_cpu = @build_cpu@
|
||||||
|
build_os = @build_os@
|
||||||
|
build_vendor = @build_vendor@
|
||||||
|
builddir = @builddir@
|
||||||
|
datadir = @datadir@
|
||||||
|
datarootdir = @datarootdir@
|
||||||
|
docdir = @docdir@
|
||||||
|
dvidir = @dvidir@
|
||||||
|
exec_prefix = @exec_prefix@
|
||||||
|
glademm_CFLAGS = @glademm_CFLAGS@
|
||||||
|
glademm_LIBS = @glademm_LIBS@
|
||||||
|
host = @host@
|
||||||
|
host_alias = @host_alias@
|
||||||
|
host_cpu = @host_cpu@
|
||||||
|
host_os = @host_os@
|
||||||
|
host_vendor = @host_vendor@
|
||||||
|
htmldir = @htmldir@
|
||||||
|
includedir = @includedir@
|
||||||
|
infodir = @infodir@
|
||||||
|
install_sh = @install_sh@
|
||||||
|
libdir = @libdir@
|
||||||
|
libexecdir = @libexecdir@
|
||||||
|
libxml_CFLAGS = @libxml_CFLAGS@
|
||||||
|
libxml_LIBS = @libxml_LIBS@
|
||||||
|
localedir = @localedir@
|
||||||
|
localstatedir = @localstatedir@
|
||||||
|
mandir = @mandir@
|
||||||
|
mkdir_p = @mkdir_p@
|
||||||
|
oldincludedir = @oldincludedir@
|
||||||
|
pdfdir = @pdfdir@
|
||||||
|
prefix = @prefix@
|
||||||
|
program_transform_name = @program_transform_name@
|
||||||
|
psdir = @psdir@
|
||||||
|
sbindir = @sbindir@
|
||||||
|
sharedstatedir = @sharedstatedir@
|
||||||
|
srcdir = @srcdir@
|
||||||
|
sysconfdir = @sysconfdir@
|
||||||
|
target_alias = @target_alias@
|
||||||
|
top_builddir = @top_builddir@
|
||||||
|
top_srcdir = @top_srcdir@
|
||||||
|
noinst_LTLIBRARIES = libmath.la
|
||||||
|
libmath_la_SOURCES = Triangle2D.cpp Vector2D.cpp Vertex2D.cpp
|
||||||
|
all: all-am
|
||||||
|
|
||||||
|
.SUFFIXES:
|
||||||
|
.SUFFIXES: .cpp .lo .o .obj
|
||||||
|
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
|
||||||
|
@for dep in $?; do \
|
||||||
|
case '$(am__configure_deps)' in \
|
||||||
|
*$$dep*) \
|
||||||
|
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
|
||||||
|
&& exit 0; \
|
||||||
|
exit 1;; \
|
||||||
|
esac; \
|
||||||
|
done; \
|
||||||
|
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Math/Makefile'; \
|
||||||
|
cd $(top_srcdir) && \
|
||||||
|
$(AUTOMAKE) --gnu src/Math/Makefile
|
||||||
|
.PRECIOUS: Makefile
|
||||||
|
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||||
|
@case '$?' in \
|
||||||
|
*config.status*) \
|
||||||
|
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||||
|
*) \
|
||||||
|
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||||
|
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||||
|
esac;
|
||||||
|
|
||||||
|
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||||
|
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||||
|
|
||||||
|
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||||
|
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||||
|
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||||
|
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||||
|
|
||||||
|
clean-noinstLTLIBRARIES:
|
||||||
|
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
|
||||||
|
@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
|
||||||
|
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
|
||||||
|
test "$$dir" != "$$p" || dir=.; \
|
||||||
|
echo "rm -f \"$${dir}/so_locations\""; \
|
||||||
|
rm -f "$${dir}/so_locations"; \
|
||||||
|
done
|
||||||
|
libmath.la: $(libmath_la_OBJECTS) $(libmath_la_DEPENDENCIES)
|
||||||
|
$(CXXLINK) $(libmath_la_OBJECTS) $(libmath_la_LIBADD) $(LIBS)
|
||||||
|
|
||||||
|
mostlyclean-compile:
|
||||||
|
-rm -f *.$(OBJEXT)
|
||||||
|
|
||||||
|
distclean-compile:
|
||||||
|
-rm -f *.tab.c
|
||||||
|
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Triangle2D.Plo@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Vector2D.Plo@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Vertex2D.Plo@am__quote@
|
||||||
|
|
||||||
|
.cpp.o:
|
||||||
|
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||||
|
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||||
|
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||||
|
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
|
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
|
||||||
|
|
||||||
|
.cpp.obj:
|
||||||
|
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
|
||||||
|
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||||
|
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||||
|
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
|
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
|
||||||
|
|
||||||
|
.cpp.lo:
|
||||||
|
@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||||
|
@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
|
||||||
|
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||||
|
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
|
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
|
||||||
|
|
||||||
|
mostlyclean-libtool:
|
||||||
|
-rm -f *.lo
|
||||||
|
|
||||||
|
clean-libtool:
|
||||||
|
-rm -rf .libs _libs
|
||||||
|
|
||||||
|
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||||
|
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||||
|
unique=`for i in $$list; do \
|
||||||
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||||
|
done | \
|
||||||
|
$(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
|
||||||
|
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||||
|
mkid -fID $$unique
|
||||||
|
tags: TAGS
|
||||||
|
|
||||||
|
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||||
|
$(TAGS_FILES) $(LISP)
|
||||||
|
tags=; \
|
||||||
|
here=`pwd`; \
|
||||||
|
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||||
|
unique=`for i in $$list; do \
|
||||||
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||||
|
done | \
|
||||||
|
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||||
|
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||||
|
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
||||||
|
test -n "$$unique" || unique=$$empty_fix; \
|
||||||
|
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||||
|
$$tags $$unique; \
|
||||||
|
fi
|
||||||
|
ctags: CTAGS
|
||||||
|
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||||
|
$(TAGS_FILES) $(LISP)
|
||||||
|
tags=; \
|
||||||
|
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||||
|
unique=`for i in $$list; do \
|
||||||
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||||
|
done | \
|
||||||
|
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||||
|
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||||
|
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
||||||
|
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||||
|
$$tags $$unique
|
||||||
|
|
||||||
|
GTAGS:
|
||||||
|
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||||
|
&& cd $(top_srcdir) \
|
||||||
|
&& gtags -i $(GTAGS_ARGS) $$here
|
||||||
|
|
||||||
|
distclean-tags:
|
||||||
|
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||||
|
|
||||||
|
distdir: $(DISTFILES)
|
||||||
|
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||||
|
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||||
|
list='$(DISTFILES)'; \
|
||||||
|
dist_files=`for file in $$list; do echo $$file; done | \
|
||||||
|
sed -e "s|^$$srcdirstrip/||;t" \
|
||||||
|
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||||
|
case $$dist_files in \
|
||||||
|
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||||
|
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||||
|
sort -u` ;; \
|
||||||
|
esac; \
|
||||||
|
for file in $$dist_files; do \
|
||||||
|
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||||
|
if test -d $$d/$$file; then \
|
||||||
|
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||||
|
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||||
|
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||||
|
fi; \
|
||||||
|
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
|
||||||
|
else \
|
||||||
|
test -f $(distdir)/$$file \
|
||||||
|
|| cp -p $$d/$$file $(distdir)/$$file \
|
||||||
|
|| exit 1; \
|
||||||
|
fi; \
|
||||||
|
done
|
||||||
|
check-am: all-am
|
||||||
|
check: check-am
|
||||||
|
all-am: Makefile $(LTLIBRARIES)
|
||||||
|
installdirs:
|
||||||
|
install: install-am
|
||||||
|
install-exec: install-exec-am
|
||||||
|
install-data: install-data-am
|
||||||
|
uninstall: uninstall-am
|
||||||
|
|
||||||
|
install-am: all-am
|
||||||
|
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||||
|
|
||||||
|
installcheck: installcheck-am
|
||||||
|
install-strip:
|
||||||
|
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||||
|
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||||
|
`test -z '$(STRIP)' || \
|
||||||
|
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||||
|
mostlyclean-generic:
|
||||||
|
|
||||||
|
clean-generic:
|
||||||
|
|
||||||
|
distclean-generic:
|
||||||
|
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||||
|
|
||||||
|
maintainer-clean-generic:
|
||||||
|
@echo "This command is intended for maintainers to use"
|
||||||
|
@echo "it deletes files that may require special tools to rebuild."
|
||||||
|
clean: clean-am
|
||||||
|
|
||||||
|
clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
|
||||||
|
mostlyclean-am
|
||||||
|
|
||||||
|
distclean: distclean-am
|
||||||
|
-rm -rf ./$(DEPDIR)
|
||||||
|
-rm -f Makefile
|
||||||
|
distclean-am: clean-am distclean-compile distclean-generic \
|
||||||
|
distclean-tags
|
||||||
|
|
||||||
|
dvi: dvi-am
|
||||||
|
|
||||||
|
dvi-am:
|
||||||
|
|
||||||
|
html: html-am
|
||||||
|
|
||||||
|
info: info-am
|
||||||
|
|
||||||
|
info-am:
|
||||||
|
|
||||||
|
install-data-am:
|
||||||
|
|
||||||
|
install-dvi: install-dvi-am
|
||||||
|
|
||||||
|
install-exec-am:
|
||||||
|
|
||||||
|
install-html: install-html-am
|
||||||
|
|
||||||
|
install-info: install-info-am
|
||||||
|
|
||||||
|
install-man:
|
||||||
|
|
||||||
|
install-pdf: install-pdf-am
|
||||||
|
|
||||||
|
install-ps: install-ps-am
|
||||||
|
|
||||||
|
installcheck-am:
|
||||||
|
|
||||||
|
maintainer-clean: maintainer-clean-am
|
||||||
|
-rm -rf ./$(DEPDIR)
|
||||||
|
-rm -f Makefile
|
||||||
|
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||||
|
|
||||||
|
mostlyclean: mostlyclean-am
|
||||||
|
|
||||||
|
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
|
||||||
|
mostlyclean-libtool
|
||||||
|
|
||||||
|
pdf: pdf-am
|
||||||
|
|
||||||
|
pdf-am:
|
||||||
|
|
||||||
|
ps: ps-am
|
||||||
|
|
||||||
|
ps-am:
|
||||||
|
|
||||||
|
uninstall-am:
|
||||||
|
|
||||||
|
.MAKE: install-am install-strip
|
||||||
|
|
||||||
|
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
|
||||||
|
clean-libtool clean-noinstLTLIBRARIES ctags distclean \
|
||||||
|
distclean-compile distclean-generic distclean-libtool \
|
||||||
|
distclean-tags distdir dvi dvi-am html html-am info info-am \
|
||||||
|
install install-am install-data install-data-am install-dvi \
|
||||||
|
install-dvi-am install-exec install-exec-am install-html \
|
||||||
|
install-html-am install-info install-info-am install-man \
|
||||||
|
install-pdf install-pdf-am install-ps install-ps-am \
|
||||||
|
install-strip installcheck installcheck-am installdirs \
|
||||||
|
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||||
|
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
|
||||||
|
pdf pdf-am ps ps-am tags uninstall uninstall-am
|
||||||
|
|
||||||
|
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||||
|
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||||
|
.NOEXPORT:
|
47
src/Math/Triangle2D.cpp
Normal file
47
src/Math/Triangle2D.cpp
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Triangle2D.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Triangle2D.h"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
namespace ZoomEdit {
|
||||||
|
namespace Math {
|
||||||
|
|
||||||
|
float Triangle2D::area() const {
|
||||||
|
return std::fabs((vertices[0].getY() + vertices[1].getY())*(vertices[0].getX()-vertices[1].getX())
|
||||||
|
+ (vertices[1].getY() + vertices[2].getY())*(vertices[1].getX()-vertices[2].getX())
|
||||||
|
+ (vertices[2].getY() + vertices[0].getY())*(vertices[2].getX()-vertices[0].getX()))/2;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Triangle2D::contains(const Vertex2D &v) const {
|
||||||
|
for(int i = 0; i < 3; ++i) {
|
||||||
|
Vector2D v1 = vertices[(i+2)%3] - vertices[(i+1)%3];
|
||||||
|
Vector2D v2 = vertices[i] - vertices[(i+1)%3];
|
||||||
|
|
||||||
|
Vector2D vp = v - vertices[(i+1)%3];
|
||||||
|
|
||||||
|
if((v1.getX()*vp.getY()-vp.getX()*v1.getY())*(v1.getX()*v2.getY()-v2.getX()*v1.getY()) < 0)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
61
src/Math/Triangle2D.h
Normal file
61
src/Math/Triangle2D.h
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* Triangle2D.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ZOOMEDIT_MATH_TRIANGLE2D_H_
|
||||||
|
#define ZOOMEDIT_MATH_TRIANGLE2D_H_
|
||||||
|
|
||||||
|
#include "Vertex2D.h"
|
||||||
|
|
||||||
|
namespace ZoomEdit {
|
||||||
|
namespace Math {
|
||||||
|
|
||||||
|
class Triangle2D {
|
||||||
|
private:
|
||||||
|
Vertex2D vertices[3];
|
||||||
|
|
||||||
|
public:
|
||||||
|
Triangle2D() {}
|
||||||
|
|
||||||
|
Triangle2D(const Vertex2D &v1, const Vertex2D &v2, const Vertex2D &v3) {
|
||||||
|
vertices[0] = v1;
|
||||||
|
vertices[1] = v2;
|
||||||
|
vertices[2] = v3;
|
||||||
|
}
|
||||||
|
|
||||||
|
Triangle2D(const Vertex2D *v) {
|
||||||
|
setVertices(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Vertex2D& getVertex(unsigned int i) const {return vertices[i];}
|
||||||
|
void setVertex(unsigned int i, const Vertex2D &v) {vertices[i] = v;}
|
||||||
|
|
||||||
|
void setVertices(const Vertex2D *v) {
|
||||||
|
for(int i = 0; i < 3; ++i)
|
||||||
|
setVertex(i, v[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
float area() const;
|
||||||
|
|
||||||
|
bool contains(const Vertex2D &v) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /*ZOOMEDIT_MATH_TRIANGLE2D_H_*/
|
83
src/Math/Vector2D.cpp
Normal file
83
src/Math/Vector2D.cpp
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
/*
|
||||||
|
* Vector2D.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Vector2D.h"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
namespace ZoomEdit {
|
||||||
|
namespace Math {
|
||||||
|
|
||||||
|
float Vector2D::lengthSq() const {
|
||||||
|
return x*x + y*y;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Vector2D::length() const {
|
||||||
|
return std::sqrt(lengthSq());
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2D Vector2D::operator+(const Vector2D &v) const {
|
||||||
|
return Vector2D(x + v.x, y + v.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2D Vector2D::operator-(const Vector2D &v) const {
|
||||||
|
return Vector2D(x - v.x, y - v.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
float Vector2D::operator*(const Vector2D &v) const {
|
||||||
|
return (x*v.x + y*v.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2D Vector2D::operator*(float f) const {
|
||||||
|
return Vector2D(x*f, y*f);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2D Vector2D::operator/(float f) const {
|
||||||
|
return Vector2D(x/f, y/f);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2D& Vector2D::operator+=(const Vector2D &v) {
|
||||||
|
x += v.x;
|
||||||
|
y += v.y;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2D& Vector2D::operator-=(const Vector2D &v) {
|
||||||
|
x -= v.x;
|
||||||
|
y -= v.y;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2D& Vector2D::operator*=(float f) {
|
||||||
|
x *= f;
|
||||||
|
y *= f;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2D& Vector2D::operator/=(float f) {
|
||||||
|
x /= f;
|
||||||
|
y /= f;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
66
src/Math/Vector2D.h
Normal file
66
src/Math/Vector2D.h
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* Vector2D.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ZOOMEDIT_MATH_VECTOR2D_H_
|
||||||
|
#define ZOOMEDIT_MATH_VECTOR2D_H_
|
||||||
|
|
||||||
|
namespace ZoomEdit {
|
||||||
|
namespace Math {
|
||||||
|
|
||||||
|
class Vector2D {
|
||||||
|
private:
|
||||||
|
float x, y;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Vector2D() : x(0), y(0) {}
|
||||||
|
Vector2D(float x0, float y0) : x(x0), y(y0) {}
|
||||||
|
|
||||||
|
float getX() const {return x;}
|
||||||
|
void setX(float x0) {x = x0;}
|
||||||
|
|
||||||
|
float getY() const {return y;}
|
||||||
|
void setY(float y0) {y = y0;}
|
||||||
|
|
||||||
|
float lengthSq() const;
|
||||||
|
float length() const;
|
||||||
|
|
||||||
|
void normalize() {
|
||||||
|
if(lengthSq())
|
||||||
|
*this /= length();
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2D operator+(const Vector2D &v) const;
|
||||||
|
Vector2D operator-(const Vector2D &v) const;
|
||||||
|
float operator*(const Vector2D &v) const;
|
||||||
|
|
||||||
|
Vector2D operator*(float f) const;
|
||||||
|
Vector2D operator/(float f) const;
|
||||||
|
|
||||||
|
Vector2D& operator+=(const Vector2D &v);
|
||||||
|
Vector2D& operator-=(const Vector2D &v);
|
||||||
|
|
||||||
|
Vector2D& operator*=(float f);
|
||||||
|
Vector2D& operator/=(float f);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /*ZOOMEDIT_MATH_VECTOR2D_H_*/
|
61
src/Math/Vertex2D.cpp
Normal file
61
src/Math/Vertex2D.cpp
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* Vertex2D.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Vertex2D.h"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
namespace ZoomEdit {
|
||||||
|
namespace Math {
|
||||||
|
|
||||||
|
float Vertex2D::distanceSq(const Vertex2D &v) const {
|
||||||
|
return (x - v.x)*(x - v.x) + (y - v.y)*(y - v.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
float Vertex2D::distance(const Vertex2D &v) const {
|
||||||
|
return std::sqrt(distanceSq(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2D Vertex2D::operator-(const Vertex2D &v) const {
|
||||||
|
return Vector2D(x - v.x, y - v.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vertex2D Vertex2D::operator+(const Vector2D &v) const {
|
||||||
|
return Vertex2D(x + v.getX(), y + v.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
Vertex2D Vertex2D::operator-(const Vector2D &v) const {
|
||||||
|
return Vertex2D(x - v.getX(), y - v.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
Vertex2D& Vertex2D::operator+=(const Vector2D &v) {
|
||||||
|
x += v.getX();
|
||||||
|
y += v.getY();
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vertex2D& Vertex2D::operator-=(const Vector2D &v) {
|
||||||
|
x -= v.getX();
|
||||||
|
y -= v.getY();
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
57
src/Math/Vertex2D.h
Normal file
57
src/Math/Vertex2D.h
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
* Vertex2D.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ZOOMEDIT_MATH_VERTEX2D_H_
|
||||||
|
#define ZOOMEDIT_MATH_VERTEX2D_H_
|
||||||
|
|
||||||
|
#include "Vector2D.h"
|
||||||
|
|
||||||
|
namespace ZoomEdit {
|
||||||
|
namespace Math {
|
||||||
|
|
||||||
|
class Vertex2D {
|
||||||
|
private:
|
||||||
|
float x, y;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Vertex2D() : x(0), y(0) {}
|
||||||
|
Vertex2D(float x0, float y0) : x(x0), y(y0) {}
|
||||||
|
|
||||||
|
float getX() const {return x;}
|
||||||
|
void setX(float x0) {x = x0;}
|
||||||
|
|
||||||
|
float getY() const {return y;}
|
||||||
|
void setY(float y0) {y = y0;}
|
||||||
|
|
||||||
|
float distanceSq(const Vertex2D &v) const;
|
||||||
|
float distance(const Vertex2D &v) const;
|
||||||
|
|
||||||
|
Vector2D operator-(const Vertex2D &v) const;
|
||||||
|
|
||||||
|
Vertex2D operator+(const Vector2D &v) const;
|
||||||
|
Vertex2D operator-(const Vector2D &v) const;
|
||||||
|
|
||||||
|
Vertex2D& operator+=(const Vector2D &v);
|
||||||
|
Vertex2D& operator-=(const Vector2D &v);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /*ZOOMEDIT_MATH_VERTEX2D_H_*/
|
|
@ -85,12 +85,12 @@ void MapView::move(float x, float y, unsigned int state) {
|
||||||
mainView->setYCenter(mainView->getYCenter() - y/scale);
|
mainView->setYCenter(mainView->getYCenter() - y/scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapView::click(float x, float y) {
|
void MapView::click(float x, float y, unsigned int button) {
|
||||||
if(!mainView)
|
if(!mainView || button != 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mainView->setXCenter(xCenter + (x - viewWidth/2)/scale);
|
mainView->setXCenter(xCenter + x/scale);
|
||||||
mainView->setYCenter(yCenter + (y - viewHeight/2)/scale);
|
mainView->setYCenter(yCenter + y/scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapView::render() {
|
void MapView::render() {
|
||||||
|
|
|
@ -61,7 +61,7 @@ class MapView : public View {
|
||||||
|
|
||||||
virtual void zoom(int zoom, float, float);
|
virtual void zoom(int zoom, float, float);
|
||||||
virtual void move(float x, float y, unsigned int state);
|
virtual void move(float x, float y, unsigned int state);
|
||||||
virtual void click(float x, float y);
|
virtual void click(float x, float y, unsigned int button);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <Data/Room.h>
|
#include <Data/Room.h>
|
||||||
#include <Data/Triangle.h>
|
#include <Data/Triangle.h>
|
||||||
#include <Gui/RenderArea.h>
|
#include <Gui/RenderArea.h>
|
||||||
|
#include <Math/Triangle2D.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
@ -94,11 +95,14 @@ void TopView::drawGrid() {
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TopView::renderRoom(Data::Room *room) {
|
void TopView::renderRoom(Data::Room *room, bool selected) {
|
||||||
const std::list<Data::Triangle*> &floor = room->getFloorTriangles();
|
const std::list<Data::Triangle*> &floor = room->getFloorTriangles();
|
||||||
std::multiset<Edge> edges;
|
std::multiset<Edge> edges;
|
||||||
|
|
||||||
glColor4f(0.0f, 0.7f, 1.0f, 0.3f);
|
if(selected)
|
||||||
|
glColor4f(0.0f, 0.7f, 1.0f, 0.2f);
|
||||||
|
else
|
||||||
|
glColor4f(0.0f, 0.7f, 1.0f, 0.3f);
|
||||||
|
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
|
|
||||||
|
@ -127,8 +131,14 @@ void TopView::renderRoom(Data::Room *room) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glColor4f(0.0f, 0.7f, 1.0f, 0.7f);
|
if(selected) {
|
||||||
glLineWidth(1.0f);
|
glColor4f(1.0f, 1.0f, 1.0f, 0.9f);
|
||||||
|
glLineWidth(2.0f);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
glColor4f(0.0f, 0.7f, 1.0f, 0.7f);
|
||||||
|
glLineWidth(1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
|
|
||||||
|
@ -206,8 +216,39 @@ void TopView::render() {
|
||||||
const std::list<Data::Room*> &rooms = level->getRooms();
|
const std::list<Data::Room*> &rooms = level->getRooms();
|
||||||
|
|
||||||
for(std::list<Data::Room*>::const_iterator room = rooms.begin(); room != rooms.end(); ++room)
|
for(std::list<Data::Room*>::const_iterator room = rooms.begin(); room != rooms.end(); ++room)
|
||||||
renderRoom(*room);
|
renderRoom(*room, *room == selectedRoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TopView::click(float x, float y, unsigned int button) {
|
||||||
|
if(button != 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Math::Vertex2D v(xCenter + x/scale, yCenter + y/scale);
|
||||||
|
|
||||||
|
selectedRoom = 0;
|
||||||
|
|
||||||
|
const std::list<Data::Room*>& rooms = level->getRooms();
|
||||||
|
|
||||||
|
for(std::list<Data::Room*>::const_iterator room = rooms.begin(); room != rooms.end(); ++room) {
|
||||||
|
const std::list<Data::Triangle*>& triangles = (*room)->getFloorTriangles();
|
||||||
|
|
||||||
|
for(std::list<Data::Triangle*>::const_iterator t = triangles.begin(); t != triangles.end(); ++t) {
|
||||||
|
Math::Vertex2D v1((*t)->getVertex(0).getX(), (*t)->getVertex(0).getZ());
|
||||||
|
Math::Vertex2D v2((*t)->getVertex(1).getX(), (*t)->getVertex(1).getZ());
|
||||||
|
Math::Vertex2D v3((*t)->getVertex(2).getX(), (*t)->getVertex(2).getZ());
|
||||||
|
|
||||||
|
if(Math::Triangle2D(v1, v2, v3).contains(v)) {
|
||||||
|
selectedRoom = *room;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(selectedRoom)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
signalUpdate().emit();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,10 +52,13 @@ class TopView : public View {
|
||||||
int zoomLevel;
|
int zoomLevel;
|
||||||
float scale;
|
float scale;
|
||||||
|
|
||||||
|
Data::Room *selectedRoom;
|
||||||
|
|
||||||
void drawGrid();
|
void drawGrid();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TopView(Data::Level *level0 = 0) : level(level0), viewWidth(0), viewHeight(0), xCenter(0), yCenter(0), zoomLevel(0), scale(100) {}
|
TopView(Data::Level *level0 = 0)
|
||||||
|
: level(level0), viewWidth(0), viewHeight(0), xCenter(0), yCenter(0), zoomLevel(0), scale(100), selectedRoom(0) {}
|
||||||
|
|
||||||
float getWidth() const {return viewWidth;}
|
float getWidth() const {return viewWidth;}
|
||||||
float getHeight() const {return viewHeight;}
|
float getHeight() const {return viewHeight;}
|
||||||
|
@ -67,6 +70,8 @@ class TopView : public View {
|
||||||
|
|
||||||
float getScale() const {return scale;}
|
float getScale() const {return scale;}
|
||||||
|
|
||||||
|
Data::Room* getSelectedRoom() {return selectedRoom;}
|
||||||
|
|
||||||
Data::Level* getLevel() {return level;}
|
Data::Level* getLevel() {return level;}
|
||||||
void setLevel(Data::Level *level0) {level = level0; signalUpdate().emit();}
|
void setLevel(Data::Level *level0) {level = level0; signalUpdate().emit();}
|
||||||
|
|
||||||
|
@ -77,8 +82,9 @@ class TopView : public View {
|
||||||
|
|
||||||
virtual void zoom(int zoom, float x, float y);
|
virtual void zoom(int zoom, float x, float y);
|
||||||
virtual void move(float x, float y, unsigned int state);
|
virtual void move(float x, float y, unsigned int state);
|
||||||
|
virtual void click(float x, float y, unsigned int button);
|
||||||
|
|
||||||
static void renderRoom(Data::Room *room);
|
static void renderRoom(Data::Room *room, bool selected = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class View {
|
||||||
|
|
||||||
virtual void zoom(int, float, float) {}
|
virtual void zoom(int, float, float) {}
|
||||||
virtual void move(float, float, unsigned int) {}
|
virtual void move(float, float, unsigned int) {}
|
||||||
virtual void click(float, float) {}
|
virtual void click(float, float, unsigned int) {}
|
||||||
|
|
||||||
sigc::signal<void> signalUpdate() const {return update;}
|
sigc::signal<void> signalUpdate() const {return update;}
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue