commit
600a90924e
@ -0,0 +1,275 @@
|
||||
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
project(WorldSpawn C CXX)
|
||||
|
||||
option(BUILD_RADIANT "Build the GUI" ON)
|
||||
|
||||
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/install" CACHE PATH "..." FORCE)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Version
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
# CMake 3.0+ would allow this in project()
|
||||
set(WorldSpawn_VERSION_MAJOR 1)
|
||||
set(WorldSpawn_VERSION_MINOR 0)
|
||||
set(WorldSpawn_VERSION_PATCH 0)
|
||||
set(WorldSpawn_VERSION "${WorldSpawn_VERSION_MAJOR}.${WorldSpawn_VERSION_MINOR}.${WorldSpawn_VERSION_PATCH}")
|
||||
|
||||
SET(CMAKE_C_COMPILER gcc-9)
|
||||
SET(CMAKE_CXX_COMPILER g++-9)
|
||||
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/WorldSpawn_MAJOR" ${WorldSpawn_VERSION_MAJOR})
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/WorldSpawn_MINOR" ${WorldSpawn_VERSION_MINOR})
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/WorldSpawn_PATCH" ${WorldSpawn_VERSION_PATCH})
|
||||
|
||||
#set(WorldSpawn_ABOUTMSG "Custom build" CACHE STRING "About message")
|
||||
|
||||
find_package(Git REQUIRED)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
set(WorldSpawn_VERSION_STRING "${WorldSpawn_VERSION}n")
|
||||
if (GIT_VERSION)
|
||||
set(WorldSpawn_VERSION_STRING "${WorldSpawn_VERSION_STRING}-git-${GIT_VERSION}")
|
||||
endif ()
|
||||
|
||||
message(STATUS "Building ${PROJECT_NAME} ${WorldSpawn_VERSION_STRING} ${WorldSpawn_ABOUTMSG}")
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Language standard
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
if (CMAKE_VERSION VERSION_LESS "3.1")
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
|
||||
include(CheckCXXCompilerFlag)
|
||||
check_cxx_compiler_flag(--std=c++${CMAKE_CXX_STANDARD} STD_CXX)
|
||||
if (STD_CXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++${CMAKE_CXX_STANDARD}")
|
||||
else ()
|
||||
message(SEND_ERROR "Requires C++${CMAKE_CXX_STANDARD} or better")
|
||||
endif ()
|
||||
else ()
|
||||
message(WARNING "Unrecognized compiler: ${CMAKE_CXX_COMPILER_ID}, make sure it supports C++${CMAKE_CXX_STANDARD}")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Flags
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
|
||||
macro(addflags_c args)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${args}")
|
||||
endmacro()
|
||||
macro(addflags_cxx args)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${args}")
|
||||
endmacro()
|
||||
macro(addflags args)
|
||||
addflags_c("${args}")
|
||||
addflags_cxx("${args}")
|
||||
endmacro()
|
||||
addflags("-fno-strict-aliasing")
|
||||
if (NOT WIN32)
|
||||
addflags("-fvisibility=hidden")
|
||||
endif ()
|
||||
|
||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
#disabled due to GTK bug addflags("-Werror")
|
||||
addflags("-pedantic-errors")
|
||||
endif ()
|
||||
|
||||
addflags("-Wall")
|
||||
addflags("-Wextra")
|
||||
addflags("-pedantic")
|
||||
|
||||
addflags_c("-Wno-deprecated-declarations") # vfs.c: g_strdown
|
||||
|
||||
addflags("-Wno-unused-function")
|
||||
addflags("-Wno-unused-variable")
|
||||
addflags("-Wno-unused-parameter")
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE 1)
|
||||
set(GTK_TARGET 2 CACHE STRING "GTK target")
|
||||
add_definitions(-DGTK_TARGET=${GTK_TARGET})
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Defs
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
add_definitions(-DWorldSpawn_VERSION="${WorldSpawn_VERSION}")
|
||||
add_definitions(-DWorldSpawn_MAJOR_VERSION="${WorldSpawn_VERSION_MAJOR}")
|
||||
add_definitions(-DWorldSpawn_MINOR_VERSION="${WorldSpawn_VERSION_MINOR}")
|
||||
add_definitions(-DWorldSpawn_PATCH_VERSION="${WorldSpawn_VERSION_PATCH}")
|
||||
|
||||
add_definitions(-DWorldSpawn_ABOUTMSG="${WorldSpawn_ABOUT}")
|
||||
|
||||
if (NOT CMAKE_BUILD_TYPE MATCHES Release)
|
||||
add_definitions(-D_DEBUG=1)
|
||||
endif ()
|
||||
|
||||
macro(disable_deprecated name gtk2only)
|
||||
add_definitions(-D${name}_DISABLE_SINGLE_INCLUDES)
|
||||
if ((${gtk2only} EQUAL 0) OR (GTK_TARGET EQUAL 2))
|
||||
add_definitions(-D${name}_DISABLE_DEPRECATED)
|
||||
endif ()
|
||||
endmacro()
|
||||
|
||||
disable_deprecated(ATK 0)
|
||||
disable_deprecated(G 0)
|
||||
disable_deprecated(GDK 0)
|
||||
disable_deprecated(GDK_PIXBUF 0)
|
||||
disable_deprecated(GTK 1)
|
||||
disable_deprecated(PANGO 0)
|
||||
|
||||
if (APPLE)
|
||||
option(XWINDOWS "Build against X11" ON)
|
||||
add_definitions(
|
||||
-DPOSIX=1
|
||||
)
|
||||
elseif (WIN32)
|
||||
add_definitions(
|
||||
-DWIN32=1
|
||||
-D_WIN32=1
|
||||
)
|
||||
else ()
|
||||
set(XWINDOWS ON)
|
||||
add_definitions(
|
||||
-DPOSIX=1
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (XWINDOWS)
|
||||
find_package(X11 REQUIRED)
|
||||
include_directories(${X11_INCLUDE_DIR})
|
||||
add_definitions(-DXWINDOWS=1)
|
||||
endif ()
|
||||
|
||||
include_directories("${PROJECT_SOURCE_DIR}/include")
|
||||
include_directories("${PROJECT_SOURCE_DIR}/libs")
|
||||
|
||||
if (WIN32 AND NOT CMAKE_CROSSCOMPILING)
|
||||
set(BUNDLE_LIBRARIES_DEFAULT ON)
|
||||
else ()
|
||||
set(BUNDLE_LIBRARIES_DEFAULT OFF)
|
||||
endif ()
|
||||
option(BUNDLE_LIBRARIES "Bundle libraries" ${BUNDLE_LIBRARIES_DEFAULT})
|
||||
|
||||
macro(copy_dlls target)
|
||||
if (BUNDLE_LIBRARIES)
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND bash
|
||||
ARGS -c "ldd '$<TARGET_FILE:${target}>' | grep -v /c/Windows | awk '{ print $1 }' | while read dll; do cp \"$(which $dll)\" '${PROJECT_BINARY_DIR}'; done"
|
||||
VERBATIM
|
||||
)
|
||||
endif ()
|
||||
endmacro()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Libraries
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
add_subdirectory(libs)
|
||||
add_subdirectory(include)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Plugins
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
if (BUILD_RADIANT)
|
||||
add_subdirectory(contrib)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Modules
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
if (BUILD_RADIANT)
|
||||
add_subdirectory(plugins)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Radiant
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
if (CMAKE_EXECUTABLE_SUFFIX)
|
||||
string(REGEX REPLACE "^[.]" "" WorldSpawn_EXECUTABLE ${CMAKE_EXECUTABLE_SUFFIX})
|
||||
else ()
|
||||
execute_process(
|
||||
COMMAND uname -m
|
||||
OUTPUT_VARIABLE WorldSpawn_EXECUTABLE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
endif ()
|
||||
|
||||
macro(radiant_tool name)
|
||||
add_executable(${name} ${ARGN})
|
||||
install(
|
||||
TARGETS ${name}
|
||||
RUNTIME DESTINATION .
|
||||
)
|
||||
if (NOT (CMAKE_EXECUTABLE_SUFFIX STREQUAL ".${WorldSpawn_EXECUTABLE}"))
|
||||
add_custom_command(TARGET ${name} POST_BUILD
|
||||
COMMAND ln -f -s "$<TARGET_FILE_NAME:${name}>" "${PROJECT_BINARY_DIR}/${name}.${WorldSpawn_EXECUTABLE}"
|
||||
VERBATIM
|
||||
)
|
||||
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
${name}${CMAKE_EXECUTABLE_SUFFIX} ${CMAKE_INSTALL_PREFIX}/${name}.${WorldSpawn_EXECUTABLE})
|
||||
")
|
||||
endif ()
|
||||
endmacro()
|
||||
|
||||
if (BUILD_RADIANT)
|
||||
add_subdirectory(radiant _radiant)
|
||||
set_target_properties(worldspawn PROPERTIES
|
||||
COMPILE_DEFINITIONS WorldSpawn_EXECUTABLE="${WorldSpawn_EXECUTABLE}"
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Tools
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
add_subdirectory(tools)
|
||||
|
||||
file(GLOB DATA_FILES "${PROJECT_SOURCE_DIR}/resources/*")
|
||||
|
||||
if (NOT (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR))
|
||||
# Copy data files from sources to the build directory
|
||||
message(STATUS "Copying data files")
|
||||
file(COPY ${DATA_FILES} DESTINATION "${PROJECT_BINARY_DIR}")
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Install
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
install(
|
||||
FILES
|
||||
"${PROJECT_BINARY_DIR}/WorldSpawn_MAJOR"
|
||||
"${PROJECT_BINARY_DIR}/WorldSpawn_MINOR"
|
||||
"${PROJECT_BINARY_DIR}/WorldSpawn_PATCH"
|
||||
DESTINATION .
|
||||
)
|
||||
|
||||
install(
|
||||
DIRECTORY
|
||||
resources/
|
||||
DESTINATION .
|
||||
)
|
||||
|
||||
install(
|
||||
DIRECTORY
|
||||
DESTINATION .
|
||||
OPTIONAL
|
||||
)
|
||||
|
||||
include(cmake/scripts/package.cmake)
|
@ -0,0 +1,36 @@
|
||||
LICENSE ( last update: Wed Feb 8 17:16:40 CST 2006 )
|
||||
-----------------------------------------------------
|
||||
|
||||
There are 3 license types used throughout GtkRadiant source code.
|
||||
|
||||
BSD - modified Berkeley Software Distribution license
|
||||
( each BSD licensed source file starts with the appropriate header )
|
||||
LGPL - GNU Lesser General Public License v2.1
|
||||
( see LGPL at the root of the tree )
|
||||
GPL - GNU General Public License
|
||||
( see GPL at the root of the tree )
|
||||
|
||||
How do I check which license applies to a given part of the source code?
|
||||
|
||||
Each source file in the tree comes with a license header which explains what
|
||||
license applies. To sum up shortly:
|
||||
|
||||
GPL: ( except some files contributed by Loki Software under BSD license )
|
||||
GtkRadiant Core
|
||||
GtkRadiant Modules
|
||||
GtkRadiant Libraries
|
||||
Quake III Tools
|
||||
Quake II Tools
|
||||
Background2D Plugin
|
||||
HydraToolz Plugin
|
||||
|
||||
BSD:
|
||||
JPEG Library
|
||||
MD5 Library
|
||||
DDS Library
|
||||
PicoModel Library
|
||||
PrtView Plugin
|
||||
|
||||
LGPL
|
||||
BobToolz Plugin
|
||||
GenSurf Plugin
|
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
zip worldspawn_bin.zip -@ < build_contents.txt
|
@ -0,0 +1,150 @@
|
||||
WorldSpawn.app
|
||||
WorldSpawn.app/base
|
||||
WorldSpawn.app/base/textures
|
||||
WorldSpawn.app/base/textures/radiant
|
||||
WorldSpawn.app/base/textures/radiant/notex.png
|
||||
WorldSpawn.app/base/textures/radiant/shadernotex.png
|
||||
WorldSpawn.app/bitmaps
|
||||
WorldSpawn.app/bitmaps/black.png
|
||||
WorldSpawn.app/bitmaps/brush_flipx.png
|
||||
WorldSpawn.app/bitmaps/brush_flipy.png
|
||||
WorldSpawn.app/bitmaps/brush_flipz.png
|
||||
WorldSpawn.app/bitmaps/brush_rotatex.png
|
||||
WorldSpawn.app/bitmaps/brush_rotatey.png
|
||||
WorldSpawn.app/bitmaps/brush_rotatez.png
|
||||
WorldSpawn.app/bitmaps/cap_bevel.png
|
||||
WorldSpawn.app/bitmaps/cap_curve.png
|
||||
WorldSpawn.app/bitmaps/cap_cylinder.png
|
||||
WorldSpawn.app/bitmaps/cap_endcap.png
|
||||
WorldSpawn.app/bitmaps/cap_ibevel.png
|
||||
WorldSpawn.app/bitmaps/cap_iendcap.png
|
||||
WorldSpawn.app/bitmaps/console.png
|
||||
WorldSpawn.app/bitmaps/dontselectcurve.png
|
||||
WorldSpawn.app/bitmaps/dontselectmodel.png
|
||||
WorldSpawn.app/bitmaps/ellipsis.png
|
||||
WorldSpawn.app/bitmaps/entities.png
|
||||
WorldSpawn.app/bitmaps/file_open.png
|
||||
WorldSpawn.app/bitmaps/file_save.png
|
||||
WorldSpawn.app/bitmaps/icon.png
|
||||
WorldSpawn.app/bitmaps/lightinspector.png
|
||||
WorldSpawn.app/bitmaps/logo.png
|
||||
WorldSpawn.app/bitmaps/modify_edges.png
|
||||
WorldSpawn.app/bitmaps/modify_faces.png
|
||||
WorldSpawn.app/bitmaps/modify_vertices.png
|
||||
WorldSpawn.app/bitmaps/noFalloff.png
|
||||
WorldSpawn.app/bitmaps/notex.png
|
||||
WorldSpawn.app/bitmaps/patch_bend.png
|
||||
WorldSpawn.app/bitmaps/patch_drilldown.png
|
||||
WorldSpawn.app/bitmaps/patch_insdel.png
|
||||
WorldSpawn.app/bitmaps/patch_showboundingbox.png
|
||||
WorldSpawn.app/bitmaps/patch_weld.png
|
||||
WorldSpawn.app/bitmaps/patch_wireframe.png
|
||||
WorldSpawn.app/bitmaps/popup_selection.png
|
||||
WorldSpawn.app/bitmaps/redo.png
|
||||
WorldSpawn.app/bitmaps/refresh_models.png
|
||||
WorldSpawn.app/bitmaps/scalelockx.png
|
||||
WorldSpawn.app/bitmaps/scalelocky.png
|
||||
WorldSpawn.app/bitmaps/scalelockz.png
|
||||
WorldSpawn.app/bitmaps/selection_csgmerge.png
|
||||
WorldSpawn.app/bitmaps/selection_csgsubtract.png
|
||||
WorldSpawn.app/bitmaps/selection_makehollow.png
|
||||
WorldSpawn.app/bitmaps/selection_makeroom.png
|
||||
WorldSpawn.app/bitmaps/selection_selectcompletetall.png
|
||||
WorldSpawn.app/bitmaps/selection_selectinside.png
|
||||
WorldSpawn.app/bitmaps/selection_selectpartialtall.png
|
||||
WorldSpawn.app/bitmaps/selection_selecttouching.png
|
||||
WorldSpawn.app/bitmaps/select_mouseresize.png
|
||||
WorldSpawn.app/bitmaps/select_mouserotate.png
|
||||
WorldSpawn.app/bitmaps/select_mousescale.png
|
||||
WorldSpawn.app/bitmaps/select_mousetranslate.png
|
||||
WorldSpawn.app/bitmaps/shadernotex.png
|
||||
WorldSpawn.app/bitmaps/show_entities.png
|
||||
WorldSpawn.app/bitmaps/splash.png
|
||||
WorldSpawn.app/bitmaps/texture_browser.png
|
||||
WorldSpawn.app/bitmaps/texture_lock.png
|
||||
WorldSpawn.app/bitmaps/textures_popup.png
|
||||
WorldSpawn.app/bitmaps/undo.png
|
||||
WorldSpawn.app/bitmaps/view_cameratoggle.png
|
||||
WorldSpawn.app/bitmaps/view_cameraupdate.png
|
||||
WorldSpawn.app/bitmaps/view_change.png
|
||||
WorldSpawn.app/bitmaps/view_clipper.png
|
||||
WorldSpawn.app/bitmaps/view_cubicclipping.png
|
||||
WorldSpawn.app/bitmaps/view_entity.png
|
||||
WorldSpawn.app/bitmaps/white.png
|
||||
WorldSpawn.app/bitmaps/window1.png
|
||||
WorldSpawn.app/bitmaps/window2.png
|
||||
WorldSpawn.app/bitmaps/window3.png
|
||||
WorldSpawn.app/bitmaps/window4.png
|
||||
WorldSpawn.app/games
|
||||
WorldSpawn.app/games/tw.game
|
||||
WorldSpawn.app/gl
|
||||
WorldSpawn.app/gl/lighting_DBS_omni_fp.glp
|
||||
WorldSpawn.app/gl/lighting_DBS_omni_fp.glsl
|
||||
WorldSpawn.app/gl/lighting_DBS_omni_vp.glp
|
||||
WorldSpawn.app/gl/lighting_DBS_omni_vp.glsl
|
||||
WorldSpawn.app/gl/lighting_DBS_XY_Z_arbfp1.cg
|
||||
WorldSpawn.app/gl/lighting_DBS_XY_Z_arbvp1.cg
|
||||
WorldSpawn.app/gl/utils.cg
|
||||
WorldSpawn.app/gl/zfill_arbfp1.cg
|
||||
WorldSpawn.app/gl/zfill_arbvp1.cg
|
||||
WorldSpawn.app/gl/zfill_fp.glp
|
||||
WorldSpawn.app/gl/zfill_fp.glsl
|
||||
WorldSpawn.app/gl/zfill_vp.glp
|
||||
WorldSpawn.app/gl/zfill_vp.glsl
|
||||
WorldSpawn.app/global.xlink
|
||||
WorldSpawn.app/modules
|
||||
WorldSpawn.app/modules/libarchivezip.so
|
||||
WorldSpawn.app/modules/libentity.so
|
||||
WorldSpawn.app/modules/libimage.so
|
||||
WorldSpawn.app/modules/libiqmmodel.so
|
||||
WorldSpawn.app/modules/libmapq3.so
|
||||
WorldSpawn.app/modules/libmodel.so
|
||||
WorldSpawn.app/modules/libshaders.so
|
||||
WorldSpawn.app/modules/libvfspk3.so
|
||||
WorldSpawn.app/plugins
|
||||
WorldSpawn.app/plugins/bitmaps
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_caulk.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_cleanup.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_dropent.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_merge.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_poly.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_splitcol.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_split.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_splitrow.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_trainpathplot.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_treeplanter.png
|
||||
WorldSpawn.app/plugins/bitmaps/bobtoolz_turnedge.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_actorclip.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_level1.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_level2.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_level3.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_level4.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_level5.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_level6.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_level7.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_level8.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_nodraw.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_stepon.png
|
||||
WorldSpawn.app/plugins/bitmaps/ufoai_weaponclip.png
|
||||
WorldSpawn.app/plugins/bt
|
||||
WorldSpawn.app/plugins/bt/bt-el1.txt
|
||||
WorldSpawn.app/plugins/bt/bt-el2.txt
|
||||
WorldSpawn.app/plugins/bt/door-tex-trim.txt
|
||||
WorldSpawn.app/plugins/bt/door-tex.txt
|
||||
WorldSpawn.app/plugins/bt/tp_ent.txt
|
||||
WorldSpawn.app/plugins/libbobtoolz.so
|
||||
WorldSpawn.app/plugins/libbrushexport.so
|
||||
WorldSpawn.app/plugins/libprtview.so
|
||||
WorldSpawn.app/plugins/libshaderplug.so
|
||||
WorldSpawn.app/plugins/libsunplug.so
|
||||
WorldSpawn.app/tw.game
|
||||
WorldSpawn.app/tw.game/default_build_menu.xml
|
||||
WorldSpawn.app/tw.game/game.xlink
|
||||
WorldSpawn.app/tw.game/wastes
|
||||
WorldSpawn.app/tw.game/wastes/entities.def
|
||||
WorldSpawn.app/Resources
|
||||
WorldSpawn.app/Resources/Info-gnustep.plist
|
||||
WorldSpawn.app/Resources/icon.tiff
|
||||
WorldSpawn.app/vmap
|
||||
WorldSpawn.app/worldspawn
|
||||
WorldSpawn.app/WorldSpawn
|
@ -0,0 +1,21 @@
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
if (GLIB_FIND_REQUIRED)
|
||||
set(_pkgconfig_REQUIRED REQUIRED)
|
||||
endif ()
|
||||
pkg_check_modules(GLIB ${_pkgconfig_REQUIRED} glib-2.0)
|
||||
else ()
|
||||
find_path(GLIB_INCLUDE_DIRS glib.h)
|
||||
find_library(GLIB_LIBRARIES glib-2.0)
|
||||
if (GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES)
|
||||
set(GLIB_FOUND 1)
|
||||
if (NOT GLIB_FIND_QUIETLY)
|
||||
message(STATUS "Found GLIB: ${GLIB_LIBRARIES}")
|
||||
endif ()
|
||||
elseif (GLIB_FIND_REQUIRED)
|
||||
message(SEND_ERROR "Could not find GLIB")
|
||||
elseif (NOT GLIB_FIND_QUIETLY)
|
||||
message(STATUS "Could not find GLIB")
|
||||
endif ()
|
||||
endif ()
|
||||
mark_as_advanced(GLIB_INCLUDE_DIRS GLIB_LIBRARIES)
|
@ -0,0 +1,21 @@
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
if (GTK2_FIND_REQUIRED)
|
||||
set(_pkgconfig_REQUIRED REQUIRED)
|
||||
endif ()
|
||||
pkg_check_modules(GTK2 ${_pkgconfig_REQUIRED} gtk+-2.0)
|
||||
else ()
|
||||
find_path(GTK2_INCLUDE_DIRS gtk.h)
|
||||
# find_library(GTK2_LIBRARIES)
|
||||
if (GTK2_INCLUDE_DIRS AND GTK2_LIBRARIES)
|
||||
set(GTK2_FOUND 1)
|
||||
if (NOT GTK2_FIND_QUIETLY)
|
||||
message(STATUS "Found GTK2: ${GTK2_LIBRARIES}")
|
||||
endif ()
|
||||
elseif (GTK2_FIND_REQUIRED)
|
||||
message(SEND_ERROR "Could not find GTK2")
|
||||
elseif (NOT GTK2_FIND_QUIETLY)
|
||||
message(STATUS "Could not find GTK2")
|
||||
endif ()
|
||||
endif ()
|
||||
mark_as_advanced(GTK2_INCLUDE_DIRS GTK2_LIBRARIES)
|
@ -0,0 +1,21 @@
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
if (GTK3_FIND_REQUIRED)
|
||||
set(_pkgconfig_REQUIRED REQUIRED)
|
||||
endif ()
|
||||
pkg_check_modules(GTK3 ${_pkgconfig_REQUIRED} gtk+-3.0)
|
||||
else ()
|
||||
find_path(GTK3_INCLUDE_DIRS gtk.h)
|
||||
# find_library(GTK3_LIBRARIES)
|
||||
if (GTK3_INCLUDE_DIRS AND GTK3_LIBRARIES)
|
||||
set(GTK3_FOUND 1)
|
||||
if (NOT GTK3_FIND_QUIETLY)
|
||||
message(STATUS "Found GTK3: ${GTK3_LIBRARIES}")
|
||||
endif ()
|
||||
elseif (GTK3_FIND_REQUIRED)
|
||||
message(SEND_ERROR "Could not find GTK3")
|
||||
elseif (NOT GTK3_FIND_QUIETLY)
|
||||
message(STATUS "Could not find GTK3")
|
||||
endif ()
|
||||
endif ()
|
||||
mark_as_advanced(GTK3_INCLUDE_DIRS GTK3_LIBRARIES)
|
@ -0,0 +1,27 @@
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
if (GtkGLExt_FIND_REQUIRED)
|
||||
set(_pkgconfig_REQUIRED REQUIRED)
|
||||
endif ()
|
||||
if (XWINDOWS)
|
||||
pkg_check_modules(GtkGLExt ${_pkgconfig_REQUIRED} gtkglext-x11-1.0)
|
||||
elseif (WIN32)
|
||||
pkg_check_modules(GtkGLExt ${_pkgconfig_REQUIRED} gtkglext-win32-1.0)
|
||||
else ()
|
||||
pkg_check_modules(GtkGLExt ${_pkgconfig_REQUIRED} gtkglext-quartz-1.0)
|
||||
endif ()
|
||||
else ()
|
||||
find_path(GtkGLExt_INCLUDE_DIRS gtkglwidget.h)
|
||||
# find_library(GtkGLExt_LIBRARIES)
|
||||
if (GtkGLExt_INCLUDE_DIRS AND GtkGLExt_LIBRARIES)
|
||||
set(GtkGLExt_FOUND 1)
|
||||
if (NOT GtkGLExt_FIND_QUIETLY)
|
||||
message(STATUS "Found GtkGLExt: ${GtkGLExt_LIBRARIES}")
|
||||
endif ()
|
||||
elseif (GtkGLExt_FIND_REQUIRED)
|
||||
message(SEND_ERROR "Could not find GtkGLExt")
|
||||
elseif (NOT GtkGLExt_FIND_QUIETLY)
|
||||
message(STATUS "Could not find GtkGLExt")
|
||||
endif ()
|
||||
endif ()
|
||||
mark_as_advanced(GtkGLExt_INCLUDE_DIRS GtkGLExt_LIBRARIES)
|
@ -0,0 +1,21 @@
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
if (Minizip_FIND_REQUIRED)
|
||||
set(_pkgconfig_REQUIRED REQUIRED)
|
||||
endif ()
|
||||
pkg_check_modules(Minizip ${_pkgconfig_REQUIRED} minizip)
|
||||
else ()
|
||||
find_path(Minizip_INCLUDE_DIRS unzip.h)
|
||||
# find_library(Minizip_LIBRARIES)
|
||||
if (Minizip_INCLUDE_DIRS AND Minizip_LIBRARIES)
|
||||
set(Minizip_FOUND 1)
|
||||
if (NOT Minizip_FIND_QUIETLY)
|
||||
message(STATUS "Found Minizip: ${Minizip_LIBRARIES}")
|
||||
endif ()
|
||||
elseif (Minizip_FIND_REQUIRED)
|
||||
message(SEND_ERROR "Could not find Minizip")
|
||||
elseif (NOT Minizip_FIND_QUIETLY)
|
||||
message(STATUS "Could not find Minizip")
|
||||
endif ()
|
||||
endif ()
|
||||
mark_as_advanced(Minizip_INCLUDE_DIRS Minizip_LIBRARIES)
|
@ -0,0 +1,23 @@
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
if (Pango_FIND_REQUIRED)
|
||||
set(_pkgconfig_REQUIRED REQUIRED)
|
||||
endif ()
|
||||
pkg_search_module(Pango ${_pkgconfig_REQUIRED} pango pangocairo)
|
||||
pkg_search_module(PangoFT2 ${_pkgconfig_REQUIRED} pangoft2)
|
||||
else ()
|
||||
# find_path(Pango_INCLUDE_DIRS)
|
||||
# find_library(Pango_LIBRARIES)
|
||||
if (Pango_INCLUDE_DIRS AND Pango_LIBRARIES)
|
||||
set(Pango_FOUND 1)
|
||||
if (NOT Pango_FIND_QUIETLY)
|
||||
message(STATUS "Found Pango: ${Pango_LIBRARIES}")
|
||||
endif ()
|
||||
elseif (Pango_FIND_REQUIRED)
|
||||
message(SEND_ERROR "Could not find Pango")
|
||||
elseif (NOT Pango_FIND_QUIETLY)
|
||||
message(STATUS "Could not find Pango")
|
||||
endif ()
|
||||
endif ()
|
||||
mark_as_advanced(Pango_INCLUDE_DIRS Pango_LIBRARIES)
|
||||
mark_as_advanced(PangoFT2_INCLUDE_DIRS PangoFT2_LIBRARIES)
|
@ -0,0 +1,16 @@
|
||||
set(CPACK_PACKAGE_NAME "WorldSpawn")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${WorldSpawn_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${WorldSpawn_VERSION_MINOR}")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "${WorldSpawn_VERSION_PATCH}")
|
||||
|
||||
# binary: --target package
|
||||
set(CPACK_GENERATOR "ZIP")
|
||||
set(CPACK_STRIP_FILES 1)
|
||||
|
||||
# source: --target package_source
|
||||
set(CPACK_SOURCE_GENERATOR "ZIP")
|
||||
set(CPACK_SOURCE_IGNORE_FILES "/\\\\.git/;/build/;/install/")
|
||||
|
||||
# configure
|
||||
include(InstallRequiredSystemLibraries)
|
||||
include(CPack)
|
@ -0,0 +1 @@
|
||||
cmake -G "Unix Makefiles" -H. -Bbuild -DCMAKE_BUILD_TYPE=Debug && cmake --build build -- -j$(nproc)
|
@ -0,0 +1 @@
|
||||
cmake -G "Unix Makefiles" -H. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build -- -j$(nproc)
|
@ -0,0 +1,16 @@
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/plugins")
|
||||
|
||||
add_custom_target(plugins)
|
||||
macro(radiant_plugin name)
|
||||
message(STATUS "Found Plugin ${name}")
|
||||
add_library(${name} MODULE ${ARGN})
|
||||
add_dependencies(plugins ${name})
|
||||
copy_dlls(${name})
|
||||
install(
|
||||
TARGETS ${name}
|
||||
LIBRARY DESTINATION plugins
|
||||
)
|
||||
endmacro()
|
||||
|
||||
add_subdirectory(brushexport)
|
||||
add_subdirectory(prtview)
|
@ -0,0 +1,10 @@
|
||||
radiant_plugin(brushexport
|
||||
callbacks.cpp callbacks.h
|
||||
export.cpp export.h
|
||||
interface.cpp
|
||||
plugin.cpp plugin.h
|
||||
support.cpp support.h
|
||||
)
|
||||
|
||||
target_include_directories(brushexport PRIVATE uilib)
|
||||
target_link_libraries(brushexport PRIVATE uilib)
|
@ -0,0 +1,7 @@
|
||||
; brushexport.def : Declares the module parameters for the DLL.
|
||||
|
||||
LIBRARY "BRUSHEXPORT"
|
||||
|
||||
EXPORTS
|
||||
; Explicit exports can go here
|
||||
Radiant_RegisterModules @1
|
@ -0,0 +1,148 @@
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <set>
|
||||
|
||||
#include "qerplugin.h"
|
||||
#include "debugging/debugging.h"
|
||||
#include "support.h"
|
||||
#include "export.h"
|
||||
|
||||
// stuff from interface.cpp
|
||||
void DestroyWindow();
|
||||
|
||||
|
||||
namespace callbacks {
|
||||
|
||||
void OnDestroy(ui::Widget w, gpointer data)
|
||||
{
|
||||
DestroyWindow();
|
||||
}
|
||||
|
||||
void OnExportClicked(ui::Button button, gpointer user_data)
|
||||
{
|
||||
auto window = ui::Window::from(lookup_widget(button, "w_plugplug2"));
|
||||
ASSERT_TRUE(window);
|
||||
const char *cpath = GlobalRadiant().m_pfnFileDialog(window, false, "Save as Obj", 0, 0, false, false, true);
|
||||
if (!cpath) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string path(cpath);
|
||||
|
||||
// get ignore list from ui
|
||||
std::set<std::string> ignore;
|
||||
|
||||
auto view = ui::TreeView::from(lookup_widget(button, "t_materialist"));
|
||||
ui::ListStore list = ui::ListStore::from(gtk_tree_view_get_model(view));
|
||||
|
||||
GtkTreeIter iter;
|
||||
gboolean valid = gtk_tree_model_get_iter_first(list, &iter);
|
||||
while (valid) {
|
||||
gchar *data;
|
||||
gtk_tree_model_get(list, &iter, 0, &data, -1);
|
||||
globalOutputStream() << data << "\n";
|
||||
ignore.insert(std::string(data));
|
||||
g_free(data);
|
||||
valid = gtk_tree_model_iter_next(list, &iter);
|
||||
}
|
||||
|
||||
for (std::set<std::string>::iterator it(ignore.begin()); it != ignore.end(); ++it) {
|
||||
globalOutputStream() << it->c_str() << "\n";
|
||||
}
|
||||
|
||||
// collapse mode
|
||||
collapsemode mode = COLLAPSE_NONE;
|
||||
|
||||
auto radio = lookup_widget(button, "r_collapse");
|
||||
ASSERT_TRUE(radio);
|
||||
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio))) {
|
||||
mode = COLLAPSE_ALL;
|
||||
} else {
|
||||
radio = lookup_widget(button, "r_collapsebymaterial");
|
||||
ASSERT_TRUE(radio);
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio))) {
|
||||
mode = COLLAPSE_BY_MATERIAL;
|
||||
} else {
|
||||
radio = lookup_widget(button, "r_nocollapse");
|
||||
ASSERT_TRUE(radio);
|
||||
ASSERT_TRUE(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)));
|
||||
mode = COLLAPSE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
// export materials?
|
||||
auto toggle = lookup_widget(button, "t_exportmaterials");
|
||||
ASSERT_TRUE(toggle);
|
||||
|
||||
bool exportmat = FALSE;
|
||||
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle))) {
|
||||
exportmat = TRUE;
|
||||
}
|
||||
|
||||
// limit material names?
|
||||
toggle = lookup_widget(button, "t_limitmatnames");
|
||||
ASSERT_TRUE(toggle);
|
||||
|
||||
bool limitMatNames = FALSE;
|
||||
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle)) && exportmat) {
|
||||
limitMatNames = TRUE;
|
||||
}
|
||||
|
||||
// create objects instead of groups?
|
||||
toggle = lookup_widget(button, "t_objects");
|
||||
ASSERT_TRUE(toggle);
|
||||
|
||||
bool objects = FALSE;
|
||||
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle)) && exportmat) {
|
||||
objects = TRUE;
|
||||
}
|
||||
|
||||
// export
|
||||
ExportSelection(ignore, mode, exportmat, path, limitMatNames, objects);
|
||||
}
|
||||
|
||||
void OnAddMaterial(ui::Button button, gpointer user_data)
|
||||
{
|
||||
auto edit = ui::Entry::from(lookup_widget(button, "ed_materialname"));
|
||||
ASSERT_TRUE(edit);
|
||||
|
||||
const gchar *name = gtk_entry_get_text(edit);
|
||||
if (g_utf8_strlen(name, -1) > 0) {
|
||||
ui::ListStore list = ui::ListStore::from(
|
||||
gtk_tree_view_get_model(ui::TreeView::from(lookup_widget(button, "t_materialist"))));
|
||||
list.append(0, name);
|
||||
gtk_entry_set_text(edit, "");
|
||||
}
|
||||
}
|
||||
|
||||
void OnRemoveMaterial(ui::Button button, gpointer user_data)
|
||||
{
|
||||
ui::TreeView view = ui::TreeView::from(lookup_widget(button, "t_materialist"));
|
||||
ui::ListStore list = ui::ListStore::from(gtk_tree_view_get_model(view));
|
||||
auto sel = ui::TreeSelection::from(gtk_tree_view_get_selection(view));
|
||||
|
||||
GtkTreeIter iter;
|
||||
if (gtk_tree_selection_get_selected(sel, 0, &iter)) {
|
||||
gtk_list_store_remove(list, &iter);
|
||||
}
|
||||
}
|
||||
|
||||
void OnExportMatClicked(ui::Button button, gpointer user_data)
|
||||
{
|
||||
ui::Widget toggleLimit = lookup_widget(button, "t_limitmatnames");
|
||||
ui::Widget toggleObject = lookup_widget(button, "t_objects");
|
||||
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) {
|
||||
gtk_widget_set_sensitive(toggleLimit, TRUE);
|
||||
gtk_widget_set_sensitive(toggleObject, TRUE);
|
||||
} else {
|
||||
gtk_widget_set_sensitive(toggleLimit, FALSE);
|
||||
gtk_widget_set_sensitive(toggleObject, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
} // callbacks
|
@ -0,0 +1,16 @@
|
||||
|
||||
#include <uilib/uilib.h>
|
||||
|
||||
namespace callbacks {
|
||||
|
||||
void OnDestroy(ui::Widget, gpointer);
|
||||
|
||||
void OnExportClicked(ui::Button, gpointer);
|
||||
|
||||
void OnAddMaterial(ui::Button, gpointer);
|
||||
|
||||
void OnRemoveMaterial(ui::Button, gpointer);
|
||||
|
||||
void OnExportMatClicked(ui::Button button, gpointer);
|
||||
|
||||
} // callbacks
|
@ -0,0 +1,365 @@
|
||||
#include "export.h"
|
||||
#include "globaldefs.h"
|
||||
#include "debugging/debugging.h"
|
||||
#include "ibrush.h"
|
||||
#include "iscenegraph.h"
|
||||
#include "iselection.h"
|
||||
#include "stream/stringstream.h"
|
||||
#include "stream/textfilestream.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
// this is very evil, but right now there is no better way
|
||||
#include "../../radiant/brush.h"
|
||||
|
||||
// for limNames
|
||||
const int MAX_MATERIAL_NAME = 20;
|
||||
|
||||
/*
|
||||
Abstract baseclass for modelexporters
|
||||
the class collects all the data which then gets
|
||||
exported through the WriteToFile method.
|
||||
*/
|
||||
class ExportData {
|
||||
public:
|
||||
ExportData(const std::set<std::string> &ignorelist, collapsemode mode, bool limNames, bool objs);
|
||||
|
||||
virtual ~ExportData(void);
|
||||
|
||||
virtual void BeginBrush(Brush &b);
|
||||
|
||||
virtual void AddBrushFace(Face &f);
|
||||
|
||||
virtual void EndBrush(void);
|
||||
|
||||
virtual bool WriteToFile(const std::string &path, collapsemode mode) const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
// a group of faces
|
||||
class group {
|
||||
public:
|
||||
std::string name;
|
||||
std::list<const Face *> faces;
|
||||
};
|
||||
|
||||
std::list<group> groups;
|
||||
|
||||
private:
|
||||
|
||||
// "textures/common/caulk" -> "caulk"
|
||||
void GetShaderNameFromShaderPath(const char *path, std::string &name);
|
||||
|
||||
group *current;
|
||||
collapsemode mode;
|
||||
const std::set<std::string> &ignorelist;
|
||||
};
|
||||
|
||||
ExportData::ExportData(const std::set<std::string> &_ignorelist, collapsemode _mode, bool _limNames, bool _objs)
|
||||
: mode(_mode),
|
||||
ignorelist(_ignorelist)
|
||||
{
|
||||
current = 0;
|
||||
|
||||
// in this mode, we need just one group
|
||||
if (mode == COLLAPSE_ALL) {
|
||||
groups.push_back(group());
|
||||
current = &groups.back();
|
||||
current->name = "all";
|
||||
}
|
||||
}
|
||||
|
||||
ExportData::~ExportData(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ExportData::BeginBrush(Brush &b)
|
||||
{
|
||||
// create a new group for each brush
|
||||
if (mode == COLLAPSE_NONE) {
|
||||
groups.push_back(group());
|
||||
current = &groups.back();
|
||||
|
||||
StringOutputStream str(256);
|
||||
str << "Brush" << (const unsigned int) groups.size();
|
||||
current->name = str.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
void ExportData::EndBrush(void)
|
||||
{
|
||||
// all faces of this brush were on the ignorelist, discard the emptygroup
|
||||
if (mode == COLLAPSE_NONE) {
|
||||
ASSERT_NOTNULL(current);
|
||||
if (current->faces.empty()) {
|
||||
groups.pop_back();
|
||||
current = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExportData::AddBrushFace(Face &f)
|
||||
{
|
||||
std::string shadername;
|
||||
GetShaderNameFromShaderPath(f.GetShader(), shadername);
|
||||
|
||||
// ignore faces from ignore list
|
||||
if (ignorelist.find(shadername) != ignorelist.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode == COLLAPSE_BY_MATERIAL) {
|
||||
// find a group for this material
|
||||
current = 0;
|
||||
const std::list<group>::iterator end(groups.end());
|
||||
for (std::list<group>::iterator it(groups.begin()); it != end; ++it) {
|
||||
if (it->name == shadername) {
|
||||
current = &(*it);
|
||||
}
|
||||
}
|
||||
|
||||
// no group found, create one
|
||||
if (!current) {
|
||||
groups.push_back(group());
|
||||
current = &groups.back();
|
||||
current->name = shadername;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_NOTNULL(current);
|
||||
|
||||
// add face to current group
|
||||
current->faces.push_back(&f);
|
||||
|
||||
#if GDEF_DEBUG
|
||||
globalOutputStream() << "Added Face to group " << current->name.c_str() << "\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
void ExportData::GetShaderNameFromShaderPath(const char *path, std::string &name)
|
||||
{
|
||||
std::string tmp(path);
|
||||
|
||||
size_t last_slash = tmp.find_last_of("/");
|
||||
|
||||
if (last_slash != std::string::npos && last_slash == (tmp.length() - 1)) {
|
||||
name = path;
|
||||
} else {
|
||||
name = tmp.substr(last_slash + 1, tmp.length() - last_slash);
|
||||
}
|
||||
|
||||
#if GDEF_DEBUG
|
||||
globalOutputStream() << "Last: " << (const unsigned int) last_slash << " " << "length: "
|
||||
<< (const unsigned int) tmp.length() << "Name: " << name.c_str() << "\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
Exporter writing facedata as wavefront object
|
||||
*/
|
||||
class ExportDataAsWavefront : public ExportData {
|
||||
private:
|
||||
bool expmat;
|
||||
bool limNames;
|
||||
bool objs;
|
||||
|
||||
public:
|
||||
ExportDataAsWavefront(const std::set<std::string> &_ignorelist, collapsemode _mode, bool _expmat, bool _limNames,
|
||||
bool _objs)
|
||||
: ExportData(_ignorelist, _mode, _limNames, _objs)
|
||||
{
|
||||
expmat = _expmat;
|
||||
limNames = _limNames;
|
||||
objs = _objs;
|
||||
}
|
||||
|
||||
bool WriteToFile(const std::string &path, collapsemode mode) const;
|
||||
};
|
||||
|
||||
bool ExportDataAsWavefront::WriteToFile(const std::string &path, collapsemode mode) const
|
||||
{
|
||||
std::string objFile = path;
|
||||
|
||||
if (path.compare(path.length() - 4, 4, ".obj") != 0) {
|
||||
objFile += ".obj";
|
||||
}
|
||||
|
||||
std::string mtlFile = objFile.substr(0, objFile.length() - 4) + ".mtl";
|
||||
|
||||
std::set<std::string> materials;
|
||||
|
||||
TextFileOutputStream out(objFile.c_str());
|
||||
|
||||
if (out.failed()) {
|
||||
globalErrorStream() << "Unable to open file\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
out
|
||||
<< "# Wavefront Objectfile exported with radiants brushexport plugin 3.0 by Thomas 'namespace' Nitschke, spam@codecreator.net\n\n";
|
||||
|
||||
if (expmat) {
|
||||
size_t last = mtlFile.find_last_of("//");
|
||||
std::string mtllib = mtlFile.substr(last + 1, mtlFile.size() - last).c_str();
|
||||
out << "mtllib " << mtllib.c_str() << "\n";
|
||||
}
|
||||
|
||||
unsigned int vertex_count = 0;
|
||||
|
||||
const std::list<ExportData::group>::const_iterator gend(groups.end());
|
||||
for (std::list<ExportData::group>::const_iterator git(groups.begin()); git != gend; ++git) {
|
||||
typedef std::multimap<std::string, std::string> bm;
|
||||
bm brushMaterials;
|
||||
typedef std::pair<std::string, std::string> String_Pair;
|
||||
|
||||
const std::list<const Face *>::const_iterator end(git->faces.end());
|
||||
|
||||
// submesh starts here
|
||||
if (objs) {
|
||||
out << "\no ";
|
||||
} else {
|
||||
out << "\ng ";
|
||||
}
|
||||
out << git->name.c_str() << "\n";
|
||||
|
||||
// material
|
||||
if (expmat && mode == COLLAPSE_ALL) {
|
||||
out << "usemtl material" << "\n\n";
|
||||
materials.insert("material");
|
||||
}
|
||||
|
||||
for (std::list<const Face *>::const_iterator it(git->faces.begin()); it != end; ++it) {
|
||||
const Winding &w((*it)->getWinding());
|
||||
|
||||
// vertices
|
||||
for (size_t i = 0; i < w.numpoints; ++i) {
|
||||
out << "v " << FloatFormat(w[i].vertex.x(), 1, 6) << " " << FloatFormat(w[i].vertex.z(), 1, 6) << " "
|
||||
<< FloatFormat(w[i].vertex.y(), 1, 6) << "\n";
|
||||
}
|
||||
}
|
||||
out << "\n";
|
||||
|
||||
for (std::list<const Face *>::const_iterator it(git->faces.begin()); it != end; ++it) {
|
||||
const Winding &w((*it)->getWinding());
|
||||
|
||||
// texcoords
|
||||
for (size_t i = 0; i < w.numpoints; ++i) {
|
||||
out << "vt " << FloatFormat(w[i].texcoord.x(), 1, 6) << " " << FloatFormat(w[i].texcoord.y(), 1, 6)
|
||||
<< "\n";
|
||||
}
|
||||
}
|
||||
|
||||
for (std::list<const Face *>::const_iterator it(git->faces.begin()); it != end; ++it) {
|
||||
const Winding &w((*it)->getWinding());
|
||||
|
||||
// faces
|
||||
StringOutputStream faceLine(256);
|
||||
faceLine << "\nf";
|
||||
for (size_t i = 0; i < w.numpoints; ++i, ++vertex_count) {
|
||||
faceLine << " " << vertex_count + 1 << "/" << vertex_count + 1;
|
||||
}
|
||||
|
||||
if (mode != COLLAPSE_ALL) {
|
||||
materials.insert((*it)->getShader().getShader());
|
||||
brushMaterials.insert(String_Pair((*it)->getShader().getShader(), faceLine.c_str()));
|
||||
} else {
|
||||
out << faceLine.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
if (mode != COLLAPSE_ALL) {
|
||||
std::string lastMat;
|
||||
std::string mat;
|
||||