diff --git a/Android_Engine.mk b/Android_Engine.mk new file mode 100644 index 0000000..67778df --- /dev/null +++ b/Android_Engine.mk @@ -0,0 +1,340 @@ +#Engine and libs path for Android projects + + +ENGINE_PATH = $(SalmonEnginePathCygwin) + +#BOOST_PATH = $(LibsPathCygwin)/boost_1_47_0 +BOOST_PATH = $(LibsPathCygwin)/boost_1_52_0 + +OGG_PATH = $(LibsPathCygwin)/libogg-1.3.0 + +VORBIS_PATH = $(LibsPathCygwin)/libvorbis-1.3.2 + +SQUIRREL_PATH = $(LibsPathCygwin)/sqplus + +LIBPNG_PATH = $(LibsPathCygwin)/libpng_1.4.1_android + +ZIP_PATH = $(LibsPathCygwin)/julienr-libzip-android/jni + +#ENGINE_PATH = $(SalmonEnginePath) + +#BOOST_PATH = $(LibsPath)/boost_1_47_0 + +#OGG_PATH = $(LibsPath)/libogg-1.3.0 + +#VORBIS_PATH = $(LibsPath)/libvorbis-1.3.2 + +#SQUIRREL_PATH = $(LibsPath)/sqplus + +#LIBPNG_PATH = $(LibsPath)/libpng_1.4.1_android + +#ZIP_PATH = $(LibsPath)/julienr-libzip-android/jni + + +#================== ZIP ================= + +LOCAL_PATH := $(ZIP_PATH) + +include $(CLEAR_VARS) + +LOCAL_MODULE := zip + +LOCAL_SRC_FILES :=\ + zip_add.c \ + zip_add_dir.c \ + zip_close.c \ + zip_delete.c \ + zip_dirent.c \ + zip_entry_free.c \ + zip_entry_new.c \ + zip_err_str.c \ + zip_error.c \ + zip_error_clear.c \ + zip_error_get.c \ + zip_error_get_sys_type.c \ + zip_error_strerror.c \ + zip_error_to_str.c \ + zip_fclose.c \ + zip_file_error_clear.c \ + zip_file_error_get.c \ + zip_file_get_offset.c \ + zip_file_strerror.c \ + zip_filerange_crc.c \ + zip_fopen.c \ + zip_fopen_index.c \ + zip_fread.c \ + zip_free.c \ + zip_get_archive_comment.c \ + zip_get_archive_flag.c \ + zip_get_file_comment.c \ + zip_get_num_files.c \ + zip_get_name.c \ + zip_memdup.c \ + zip_name_locate.c \ + zip_new.c \ + zip_open.c \ + zip_rename.c \ + zip_replace.c \ + zip_set_archive_comment.c \ + zip_set_archive_flag.c \ + zip_set_file_comment.c \ + zip_source_buffer.c \ + zip_source_file.c \ + zip_source_filep.c \ + zip_source_free.c \ + zip_source_function.c \ + zip_source_zip.c \ + zip_set_name.c \ + zip_stat.c \ + zip_stat_index.c \ + zip_stat_init.c \ + zip_strerror.c \ + zip_unchange.c \ + zip_unchange_all.c \ + zip_unchange_archive.c \ + zip_unchange_data.c + +LOCAL_LDLIBS := -lz + +#debug +#LOCAL_CFLAGS := -g -ggdb -O0 +#LOCAL_LDLIBS += -g -ggdb + +include $(BUILD_STATIC_LIBRARY) + +#================== PNG ================= + +LOCAL_PATH := $(LIBPNG_PATH) +include $(CLEAR_VARS) + +LOCAL_MODULE := png_lib +LOCAL_SRC_FILES :=\ + png.c \ + pngerror.c \ + pngget.c \ + pngmem.c \ + pngpread.c \ + pngread.c \ + pngrio.c \ + pngrtran.c \ + pngrutil.c \ + pngset.c \ + pngtrans.c \ + pngwio.c \ + pngwrite.c \ + pngwtran.c \ + pngwutil.c + +LOCAL_LDLIBS := -lz + +#debug +#LOCAL_CFLAGS := -g -ggdb -O0 +#LOCAL_LDLIBS += -g -ggdb + +include $(BUILD_STATIC_LIBRARY) + + +#================== SQUIRREL ================= + + +include $(CLEAR_VARS) + +LOCAL_MODULE := squirrel +LOCAL_PATH := $(SQUIRREL_PATH) +LOCAL_C_INCLUDES := $(SQUIRREL_PATH)/include $(SQUIRREL_PATH)/sqplus/sqplus $(SQUIRREL_PATH)/squirrel $(SQUIRREL_PATH)/sqstdlib +LOCAL_SRC_FILES := squirrel/sqapi.cpp \ + squirrel/sqbaselib.cpp \ + squirrel/sqclass.cpp \ + squirrel/sqcompiler.cpp \ + squirrel/sqdebug.cpp \ + squirrel/sqfuncstate.cpp \ + squirrel/sqlexer.cpp \ + squirrel/sqmem.cpp \ + squirrel/sqobject.cpp \ + squirrel/sqstate.cpp \ + squirrel/sqtable.cpp \ + squirrel/sqvm.cpp \ + sqplus/SqPlus.cpp \ + sqplus/SqPlusOCharBuf.cpp \ + sqplus/SqPlusUtf8.cpp \ + sqplus/SquirrelBindingsUtils.cpp \ + sqplus/SquirrelObject.cpp \ + sqplus/SquirrelVM.cpp \ + sqstdlib/sqstdblob.cpp \ + sqstdlib/sqstdio.cpp \ + sqstdlib/sqstdmath.cpp \ + sqstdlib/sqstdrex.cpp \ + sqstdlib/sqstdstream.cpp \ + sqstdlib/sqstdstring.cpp \ + sqstdlib/sqstdsystem.cpp \ + sqstdlib/sqstdaux.cpp \ + + +#debug +#LOCAL_CFLAGS := -g -ggdb -O0 +#LOCAL_LDLIBS := -g -ggdb + +include $(BUILD_STATIC_LIBRARY) + + +#================== OGG / VORBIS / VORBISFILE =================== + +include $(CLEAR_VARS) + +LOCAL_MODULE := vorbis + +LOCAL_PATH := $(VORBIS_PATH)/lib +LOCAL_C_INCLUDES := $(VORBIS_PATH)/include +LOCAL_C_INCLUDES += $(VORBIS_PATH)/include/vorbis +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/src +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/books +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/modes +LOCAL_C_INCLUDES += $(OGG_PATH)/include +LOCAL_C_INCLUDES += $(OGG_PATH)/include/ogg +LOCAL_SRC_FILES := ../../libogg-1.3.0/src/framing.c ../../libogg-1.3.0/src/bitwise.c +LOCAL_SRC_FILES += mdct.c smallft.c block.c envelope.c window.c lsp.c \ + lpc.c analysis.c synthesis.c psy.c info.c \ + floor1.c floor0.c\ + res0.c mapping0.c registry.c codebook.c sharedbook.c\ + lookup.c bitrate.c +LOCAL_SRC_FILES += vorbisfile.c + +#debug +#LOCAL_CFLAGS := -g -ggdb -O0 +#LOCAL_LDLIBS := -g -ggdb + +include $(BUILD_STATIC_LIBRARY) + + +#================== BOOST ==================== + +LOCAL_PATH := $(BOOST_PATH) + +include $(CLEAR_VARS) + +LOCAL_MODULE := boost +LOCAL_C_INCLUDES := $(BOOST_PATH) + +LOCAL_CFLAGS := -std=gnu++11 --std=c++11 + +#thread +LOCAL_SRC_FILES := /libs/thread/src/pthread/thread.cpp +LOCAL_SRC_FILES += /libs/thread/src/pthread/once.cpp + +#signals +LOCAL_SRC_FILES += /libs/signals/src/connection.cpp +LOCAL_SRC_FILES += /libs/signals/src/named_slot_map.cpp +LOCAL_SRC_FILES += /libs/signals/src/signal_base.cpp +LOCAL_SRC_FILES += /libs/signals/src/slot.cpp +LOCAL_SRC_FILES += /libs/signals/src/trackable.cpp + +#system +LOCAL_SRC_FILES += /libs/system/src/error_code.cpp + +#regex +LOCAL_SRC_FILES += /libs/regex/src/c_regex_traits.cpp +LOCAL_SRC_FILES += /libs/regex/src/cpp_regex_traits.cpp +LOCAL_SRC_FILES += /libs/regex/src/cregex.cpp +LOCAL_SRC_FILES += /libs/regex/src/fileiter.cpp +LOCAL_SRC_FILES += /libs/regex/src/icu.cpp +LOCAL_SRC_FILES += /libs/regex/src/instances.cpp +LOCAL_SRC_FILES += /libs/regex/src/posix_api.cpp +LOCAL_SRC_FILES += /libs/regex/src/regex.cpp +LOCAL_SRC_FILES += /libs/regex/src/regex_debug.cpp +LOCAL_SRC_FILES += /libs/regex/src/regex_raw_buffer.cpp +LOCAL_SRC_FILES += /libs/regex/src/regex_traits_defaults.cpp +LOCAL_SRC_FILES += /libs/regex/src/static_mutex.cpp +LOCAL_SRC_FILES += /libs/regex/src/usinstances.cpp +LOCAL_SRC_FILES += /libs/regex/src/w32_regex_traits.cpp +LOCAL_SRC_FILES += /libs/regex/src/wc_regex_traits.cpp +LOCAL_SRC_FILES += /libs/regex/src/wide_posix_api.cpp +LOCAL_SRC_FILES += /libs/regex/src/winstances.cpp + +#date_time +LOCAL_SRC_FILES += /libs/date_time/src/gregorian/greg_month.cpp +LOCAL_SRC_FILES += /libs/date_time/src/gregorian/greg_weekday.cpp +LOCAL_SRC_FILES += /libs/date_time/src/gregorian/date_generators.cpp + +#asio +#nothing + + + +LOCAL_LDLIBS := -llog -Wl + +#debug +#LOCAL_CFLAGS += -g -ggdb -O0 +#LOCAL_LDLIBS += -g -ggdb + + +include $(BUILD_STATIC_LIBRARY) + + +#============= HALIBUT ENGINE ================ + +LOCAL_PATH := $(ENGINE_PATH) + +include $(CLEAR_VARS) + +LOCAL_MODULE := HalibutEngine +LOCAL_CFLAGS := -DTARGET_ANDROID -DTARGET_HALIBUT -std=gnu++11 --std=c++11 + +LOCAL_STATIC_LIBRARIES := boost +LOCAL_STATIC_LIBRARIES += ogg +LOCAL_STATIC_LIBRARIES += vorbis +LOCAL_STATIC_LIBRARIES += squirrel +LOCAL_STATIC_LIBRARIES += png_lib +LOCAL_STATIC_LIBRARIES += zip +LOCAL_SHARED_LIBRARIES := gnustl_shared +LOCAL_C_INCLUDES := $(BOOST_PATH) +LOCAL_C_INCLUDES += $(VORBIS_PATH)/include +LOCAL_C_INCLUDES += $(VORBIS_PATH)/include/vorbis +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/books +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/modes +LOCAL_C_INCLUDES += $(OGG_PATH)/include +LOCAL_C_INCLUDES += $(OGG_PATH)/include/ogg +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/include +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/sqplus +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/sqstdlib +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/squirrel +LOCAL_C_INCLUDES += $(LIBPNG_PATH) +LOCAL_C_INCLUDES += $(ZIP_PATH) +LOCAL_SRC_FILES := src/Utils/DataTypes/DataTypes.cpp +LOCAL_SRC_FILES += src/Utils/DataTypes/NewDataTypes.cpp +LOCAL_SRC_FILES += src/Utils/FileUtils/FileUtils.cpp +LOCAL_SRC_FILES += src/Utils/JniApi/JniApi.cpp +LOCAL_SRC_FILES += src/Utils/Console/Console.cpp +LOCAL_SRC_FILES += src/Utils/SerializeInterface/SerializeInterface.cpp +LOCAL_SRC_FILES += src/Utils/PngHelper.cpp +LOCAL_SRC_FILES += src/Utils/SimpleTimer.cpp +LOCAL_SRC_FILES += src/TextureManager/SalmonTexture.cpp +LOCAL_SRC_FILES += src/ShaderManager/ShaderManager.cpp +LOCAL_SRC_FILES += src/FrameManager/FrameManager.cpp +LOCAL_SRC_FILES += src/SoundManager/SoundManagerAndroid.cpp +LOCAL_SRC_FILES += src/SoundManager/SoundManagerDataTypes.cpp +LOCAL_SRC_FILES += src/FontManager/FontManager.cpp +LOCAL_SRC_FILES += src/ScriptManager/ScriptManager.cpp +LOCAL_SRC_FILES += src/GUIManager/GUIManager.cpp +LOCAL_SRC_FILES += src/GUIManager/ButtonWidget.cpp +LOCAL_SRC_FILES += src/GUIManager/WidgetXmlParsers.cpp +LOCAL_SRC_FILES += src/HalibutAnimation/HalibutAnimation.cpp +LOCAL_SRC_FILES += src/SmartValueManager/SmartValueManager.cpp +LOCAL_SRC_FILES += src/ApplicationInterface.cpp +LOCAL_SRC_FILES += src/Render/RenderInterface.cpp +LOCAL_SRC_FILES += src/Render/HalibutRender/HalibutRenderInterface.cpp +LOCAL_SRC_FILES += src/Render/HalibutRender/HalibutRenderGLES20.cpp +LOCAL_SRC_FILES += src/Render/HalibutRender/HalibutRenderAndroid.cpp +LOCAL_SRC_FILES += src/Render/RenderMisc.cpp +LOCAL_SRC_FILES += src/HalibutEngineAndroid.cpp +LOCAL_SRC_FILES += src/HalibutEngineInterface.cpp +LOCAL_LDLIBS := -lGLESv2 + +LOCAL_LDLIBS += -llog -Wl -lz + +#debug +#LOCAL_CFLAGS += -g -ggdb -O0 +#LOCAL_LDLIBS += -g -ggdb +#no -s cause no need stripping!!!! + +include $(BUILD_SHARED_LIBRARY) diff --git a/Android_Salmon_Engine.mk b/Android_Salmon_Engine.mk new file mode 100644 index 0000000..e4b15d3 --- /dev/null +++ b/Android_Salmon_Engine.mk @@ -0,0 +1,351 @@ +#Engine and libs path for Android projects + + +ENGINE_PATH = $(SalmonEnginePathCygwin) + +BOOST_PATH = $(LibsPathCygwin)/boost_1_52_0 + +OGG_PATH = $(LibsPathCygwin)/libogg-1.3.0 + +VORBIS_PATH = $(LibsPathCygwin)/libvorbis-1.3.2 + +SQUIRREL_PATH = $(LibsPathCygwin)/sqplus + +LIBPNG_PATH = $(LibsPathCygwin)/libpng_1.4.1_android + +ZIP_PATH = $(LibsPathCygwin)/julienr-libzip-android/jni + +#ENGINE_PATH = $(SalmonEnginePath) + +#BOOST_PATH = $(LibsPath)/boost_1_52_0 + +#OGG_PATH = $(LibsPath)/libogg-1.3.0 + +#VORBIS_PATH = $(LibsPath)/libvorbis-1.3.2 + +#SQUIRREL_PATH = $(LibsPath)/sqplus + +#LIBPNG_PATH = $(LibsPath)/libpng_1.4.1_android + +#ZIP_PATH = $(LibsPath)/julienr-libzip-android/jni + + +#================== ZIP ================= + +LOCAL_PATH := $(ZIP_PATH) + +include $(CLEAR_VARS) + +LOCAL_MODULE := zip + +LOCAL_SRC_FILES :=\ + zip_add.c \ + zip_add_dir.c \ + zip_close.c \ + zip_delete.c \ + zip_dirent.c \ + zip_entry_free.c \ + zip_entry_new.c \ + zip_err_str.c \ + zip_error.c \ + zip_error_clear.c \ + zip_error_get.c \ + zip_error_get_sys_type.c \ + zip_error_strerror.c \ + zip_error_to_str.c \ + zip_fclose.c \ + zip_file_error_clear.c \ + zip_file_error_get.c \ + zip_file_get_offset.c \ + zip_file_strerror.c \ + zip_filerange_crc.c \ + zip_fopen.c \ + zip_fopen_index.c \ + zip_fread.c \ + zip_free.c \ + zip_get_archive_comment.c \ + zip_get_archive_flag.c \ + zip_get_file_comment.c \ + zip_get_num_files.c \ + zip_get_name.c \ + zip_memdup.c \ + zip_name_locate.c \ + zip_new.c \ + zip_open.c \ + zip_rename.c \ + zip_replace.c \ + zip_set_archive_comment.c \ + zip_set_archive_flag.c \ + zip_set_file_comment.c \ + zip_source_buffer.c \ + zip_source_file.c \ + zip_source_filep.c \ + zip_source_free.c \ + zip_source_function.c \ + zip_source_zip.c \ + zip_set_name.c \ + zip_stat.c \ + zip_stat_index.c \ + zip_stat_init.c \ + zip_strerror.c \ + zip_unchange.c \ + zip_unchange_all.c \ + zip_unchange_archive.c \ + zip_unchange_data.c + +LOCAL_LDLIBS := -lz + +#debug +#LOCAL_CFLAGS := -g -ggdb -O0 +#LOCAL_LDLIBS += -g -ggdb + + +include $(BUILD_STATIC_LIBRARY) + +#================== PNG ================= + +LOCAL_PATH := $(LIBPNG_PATH) +include $(CLEAR_VARS) + +LOCAL_MODULE := png_lib +LOCAL_SRC_FILES :=\ + png.c \ + pngerror.c \ + pngget.c \ + pngmem.c \ + pngpread.c \ + pngread.c \ + pngrio.c \ + pngrtran.c \ + pngrutil.c \ + pngset.c \ + pngtrans.c \ + pngwio.c \ + pngwrite.c \ + pngwtran.c \ + pngwutil.c + +LOCAL_LDLIBS := -lz + +#debug +#LOCAL_CFLAGS := -g -ggdb -O0 +#LOCAL_LDLIBS += -g -ggdb + +include $(BUILD_STATIC_LIBRARY) + + +#================== SQUIRREL ================= + + +include $(CLEAR_VARS) + +LOCAL_MODULE := squirrel +LOCAL_PATH := $(SQUIRREL_PATH) +LOCAL_C_INCLUDES := $(SQUIRREL_PATH)/include $(SQUIRREL_PATH)/sqplus/sqplus $(SQUIRREL_PATH)/squirrel $(SQUIRREL_PATH)/sqstdlib +LOCAL_SRC_FILES := squirrel/sqapi.cpp \ + squirrel/sqbaselib.cpp \ + squirrel/sqclass.cpp \ + squirrel/sqcompiler.cpp \ + squirrel/sqdebug.cpp \ + squirrel/sqfuncstate.cpp \ + squirrel/sqlexer.cpp \ + squirrel/sqmem.cpp \ + squirrel/sqobject.cpp \ + squirrel/sqstate.cpp \ + squirrel/sqtable.cpp \ + squirrel/sqvm.cpp \ + sqplus/SqPlus.cpp \ + sqplus/SqPlusOCharBuf.cpp \ + sqplus/SqPlusUtf8.cpp \ + sqplus/SquirrelBindingsUtils.cpp \ + sqplus/SquirrelObject.cpp \ + sqplus/SquirrelVM.cpp \ + sqstdlib/sqstdblob.cpp \ + sqstdlib/sqstdio.cpp \ + sqstdlib/sqstdmath.cpp \ + sqstdlib/sqstdrex.cpp \ + sqstdlib/sqstdstream.cpp \ + sqstdlib/sqstdstring.cpp \ + sqstdlib/sqstdsystem.cpp \ + sqstdlib/sqstdaux.cpp \ + + +#debug +#LOCAL_CFLAGS := -g -ggdb -O0 +#LOCAL_LDLIBS := -g -ggdb + +include $(BUILD_STATIC_LIBRARY) + + +#================== OGG / VORBIS / VORBISFILE =================== + +include $(CLEAR_VARS) + +LOCAL_MODULE := vorbis + +LOCAL_PATH := $(VORBIS_PATH)/lib +LOCAL_C_INCLUDES := $(VORBIS_PATH)/include +LOCAL_C_INCLUDES += $(VORBIS_PATH)/include/vorbis +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/src +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/books +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/modes +LOCAL_C_INCLUDES += $(OGG_PATH)/include +LOCAL_C_INCLUDES += $(OGG_PATH)/include/ogg +LOCAL_SRC_FILES := ../../libogg-1.3.0/src/framing.c ../../libogg-1.3.0/src/bitwise.c +LOCAL_SRC_FILES += mdct.c smallft.c block.c envelope.c window.c lsp.c \ + lpc.c analysis.c synthesis.c psy.c info.c \ + floor1.c floor0.c\ + res0.c mapping0.c registry.c codebook.c sharedbook.c\ + lookup.c bitrate.c +LOCAL_SRC_FILES += vorbisfile.c + +#debug +#LOCAL_CFLAGS := -g -ggdb -O0 +#LOCAL_LDLIBS := -g -ggdb + +include $(BUILD_STATIC_LIBRARY) + + +#================== BOOST ==================== + +LOCAL_PATH := $(BOOST_PATH) + +include $(CLEAR_VARS) + +LOCAL_MODULE := boost +LOCAL_C_INCLUDES := $(BOOST_PATH) + +LOCAL_CFLAGS := -std=gnu++11 --std=c++11 + + +#thread +LOCAL_SRC_FILES := /libs/thread/src/pthread/thread.cpp +LOCAL_SRC_FILES += /libs/thread/src/pthread/once.cpp + +#signals +LOCAL_SRC_FILES += /libs/signals/src/connection.cpp +LOCAL_SRC_FILES += /libs/signals/src/named_slot_map.cpp +LOCAL_SRC_FILES += /libs/signals/src/signal_base.cpp +LOCAL_SRC_FILES += /libs/signals/src/slot.cpp +LOCAL_SRC_FILES += /libs/signals/src/trackable.cpp + +#system +LOCAL_SRC_FILES += /libs/system/src/error_code.cpp + +#regex +LOCAL_SRC_FILES += /libs/regex/src/c_regex_traits.cpp +LOCAL_SRC_FILES += /libs/regex/src/cpp_regex_traits.cpp +LOCAL_SRC_FILES += /libs/regex/src/cregex.cpp +LOCAL_SRC_FILES += /libs/regex/src/fileiter.cpp +LOCAL_SRC_FILES += /libs/regex/src/icu.cpp +LOCAL_SRC_FILES += /libs/regex/src/instances.cpp +LOCAL_SRC_FILES += /libs/regex/src/posix_api.cpp +LOCAL_SRC_FILES += /libs/regex/src/regex.cpp +LOCAL_SRC_FILES += /libs/regex/src/regex_debug.cpp +LOCAL_SRC_FILES += /libs/regex/src/regex_raw_buffer.cpp +LOCAL_SRC_FILES += /libs/regex/src/regex_traits_defaults.cpp +LOCAL_SRC_FILES += /libs/regex/src/static_mutex.cpp +LOCAL_SRC_FILES += /libs/regex/src/usinstances.cpp +LOCAL_SRC_FILES += /libs/regex/src/w32_regex_traits.cpp +LOCAL_SRC_FILES += /libs/regex/src/wc_regex_traits.cpp +LOCAL_SRC_FILES += /libs/regex/src/wide_posix_api.cpp +LOCAL_SRC_FILES += /libs/regex/src/winstances.cpp + +#date_time +LOCAL_SRC_FILES += /libs/date_time/src/gregorian/greg_month.cpp +LOCAL_SRC_FILES += /libs/date_time/src/gregorian/greg_weekday.cpp +LOCAL_SRC_FILES += /libs/date_time/src/gregorian/date_generators.cpp + +#asio +#nothing + +LOCAL_LDLIBS := -llog -Wl + +#debug +#LOCAL_CFLAGS += -g -ggdb -O0 +#LOCAL_LDLIBS += -g -ggdb + + +include $(BUILD_STATIC_LIBRARY) + + +#============= SALMON ENGINE ================ + +LOCAL_PATH := $(ENGINE_PATH) + +include $(CLEAR_VARS) + +LOCAL_MODULE := SalmonEngine + + +LOCAL_CFLAGS := -DTARGET_ANDROID -DTARGET_SALMON -std=gnu++11 --std=c++11 + +LOCAL_STATIC_LIBRARIES := boost +LOCAL_STATIC_LIBRARIES += ogg +LOCAL_STATIC_LIBRARIES += vorbis +LOCAL_STATIC_LIBRARIES += squirrel +LOCAL_STATIC_LIBRARIES += png_lib +LOCAL_STATIC_LIBRARIES += zip +LOCAL_SHARED_LIBRARIES := gnustl_shared +LOCAL_C_INCLUDES := $(BOOST_PATH) +LOCAL_C_INCLUDES += $(VORBIS_PATH)/include +LOCAL_C_INCLUDES += $(VORBIS_PATH)/include/vorbis +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/books +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/modes +LOCAL_C_INCLUDES += $(OGG_PATH)/include +LOCAL_C_INCLUDES += $(OGG_PATH)/include/ogg +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/include +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/sqplus +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/sqstdlib +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/squirrel +LOCAL_C_INCLUDES += $(LIBPNG_PATH) +LOCAL_C_INCLUDES += $(ZIP_PATH) +LOCAL_SRC_FILES := src/Utils/DataTypes/DataTypes.cpp +LOCAL_SRC_FILES += src/Utils/DataTypes/NewDataTypes.cpp +LOCAL_SRC_FILES += src/Utils/FileUtils/FileUtils.cpp +LOCAL_SRC_FILES += src/Utils/JniApi/JniApi.cpp +LOCAL_SRC_FILES += src/Utils/Console/Console.cpp +LOCAL_SRC_FILES += src/Utils/SerializeInterface/SerializeInterface.cpp +LOCAL_SRC_FILES += src/Utils/PngHelper.cpp +LOCAL_SRC_FILES += src/Utils/SimpleTimer.cpp +LOCAL_SRC_FILES += src/TextureManager/SalmonTexture.cpp +LOCAL_SRC_FILES += src/ShaderManager/ShaderManager.cpp +LOCAL_SRC_FILES += src/FrameManager/FrameManager.cpp +LOCAL_SRC_FILES += src/LightManager/LightManager.cpp +LOCAL_SRC_FILES += src/SoundManager/SoundManagerAndroid.cpp +LOCAL_SRC_FILES += src/SoundManager/SoundManagerDataTypes.cpp +LOCAL_SRC_FILES += src/FontManager/FontManager.cpp +LOCAL_SRC_FILES += src/ScriptManager/ScriptManager.cpp +LOCAL_SRC_FILES += src/SmartValueManager/SmartValueManager.cpp +#LOCAL_SRC_FILES += src/GUIManager/GUIManager.cpp +#LOCAL_SRC_FILES += src/GUIManager/ButtonWidget.cpp + +LOCAL_SRC_FILES += src/ModelManager/ModelManager.cpp +LOCAL_SRC_FILES += src/ModelManager/NewModelManager.cpp +LOCAL_SRC_FILES += src/SimpleLand/SimpleLand.cpp + + +LOCAL_SRC_FILES += src/Render/RenderMisc.cpp +LOCAL_SRC_FILES += src/Render/RenderParams.cpp +LOCAL_SRC_FILES += src/Render/SalmonRender/BackgroundCubemap.cpp + +LOCAL_SRC_FILES += src/Animation/SalmonAnimation.cpp +LOCAL_SRC_FILES += src/Render/RenderInterface.cpp +LOCAL_SRC_FILES += src/ApplicationInterface.cpp +LOCAL_SRC_FILES += src/Render/SalmonRender/SalmonRenderInterface.cpp +LOCAL_SRC_FILES += src/Render/SalmonRender/SalmonRenderGLES20.cpp +LOCAL_SRC_FILES += src/Render/SalmonRender/SalmonRenderAndroid.cpp +LOCAL_SRC_FILES += src/SalmonEngineAndroid.cpp +LOCAL_SRC_FILES += src/SalmonEngineInterface.cpp +LOCAL_LDLIBS := -lGLESv2 + +LOCAL_LDLIBS += -llog -Wl -lz + +#debug +#LOCAL_CFLAGS += -g -ggdb -O0 +#LOCAL_LDLIBS += -g -ggdb + +#no -s cause no need stripping!!!! + +include $(BUILD_SHARED_LIBRARY) diff --git a/Halibut Engine/Halibut Engine.vcxproj b/Halibut Engine/Halibut Engine.vcxproj new file mode 100644 index 0000000..37620a9 --- /dev/null +++ b/Halibut Engine/Halibut Engine.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug_nosound + Win32 + + + Debug + Win32 + + + Release + Win32 + + + + {4E274B19-10B2-4987-96C5-76F35A149502} + HalibutEngine + + + + StaticLibrary + true + NotSet + + + StaticLibrary + true + NotSet + + + StaticLibrary + false + true + NotSet + + + + + + + + + + + + + + + + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SolutionDir)include;$(SolutionDir)include\Animation;$(SolutionDir)include\FrameManager;$(SolutionDir)include\LightManager;$(SolutionDir)include\ModelManager;$(SolutionDir)include\OpenGLExt;$(SolutionDir)include\SalmonRender;$(SolutionDir)include\ShaderManager;$(SolutionDir)include\TextureManager;$(SolutionDir)include\Utils;$(SolutionDir)include\Utils\Console;$(SolutionDir)include\Utils\DataTypes;$(SolutionDir)include\Utils\ErrorTypes;$(SolutionDir)include\Utils\FileUtils + $(SalmonEnginePath)$(Configuration)\ + + + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SolutionDir)include;$(SolutionDir)include\Animation;$(SolutionDir)include\FrameManager;$(SolutionDir)include\LightManager;$(SolutionDir)include\ModelManager;$(SolutionDir)include\OpenGLExt;$(SolutionDir)include\SalmonRender;$(SolutionDir)include\ShaderManager;$(SolutionDir)include\TextureManager;$(SolutionDir)include\Utils;$(SolutionDir)include\Utils\Console;$(SolutionDir)include\Utils\DataTypes;$(SolutionDir)include\Utils\ErrorTypes;$(SolutionDir)include\Utils\FileUtils + $(SalmonEnginePath)$(Configuration)\ + + + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SolutionDir)include;$(SolutionDir)include\Animation;$(SolutionDir)include\FrameManager;$(SolutionDir)include\LightManager;$(SolutionDir)include\ModelManager;$(SolutionDir)include\OpenGLExt;$(SolutionDir)include\SalmonRender;$(SolutionDir)include\ShaderManager;$(SolutionDir)include\TextureManager;$(SolutionDir)include\Utils;$(SolutionDir)include\Utils\Console;$(SolutionDir)include\Utils\DataTypes;$(SolutionDir)include\Utils\ErrorTypes;$(SolutionDir)include\Utils\FileUtils + $(SalmonEnginePath)$(Configuration)\ + + + + Level3 + Disabled + TARGET_HALIBUT;TARGET_WIN32;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501;DEBUG + $(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\openal\OpenAL11_windows_sdk;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;$(LibsPath)\DirectXsdk\Include;$(LibsPath)\lpng1510 + + + true + + + + + Level3 + Disabled + TARGET_HALIBUT;TARGET_WIN32;NOSOUND;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501;DEBUG + $(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\openal\OpenAL11_windows_sdk;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;$(LibsPath)\lpng1510 + + + true + + + + + Level3 + MaxSpeed + true + true + TARGET_HALIBUT;TARGET_WIN32;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501;NDEBUG + $(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\openal\OpenAL11_windows_sdk;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;$(LibsPath)\DirectXsdk\Include;$(LibsPath)\lpng1510 + + + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Salmon Engine.sln b/Salmon Engine.sln new file mode 100644 index 0000000..95c1256 --- /dev/null +++ b/Salmon Engine.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Halibut Engine", "Halibut Engine\Halibut Engine.vcxproj", "{4E274B19-10B2-4987-96C5-76F35A149502}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Salmon Engine", "Salmon Engine\Salmon Engine.vcxproj", "{48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug_nosound|Win32 = Debug_nosound|Win32 + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4E274B19-10B2-4987-96C5-76F35A149502}.Debug_nosound|Win32.ActiveCfg = Debug_nosound|Win32 + {4E274B19-10B2-4987-96C5-76F35A149502}.Debug_nosound|Win32.Build.0 = Debug_nosound|Win32 + {4E274B19-10B2-4987-96C5-76F35A149502}.Debug|Win32.ActiveCfg = Debug|Win32 + {4E274B19-10B2-4987-96C5-76F35A149502}.Debug|Win32.Build.0 = Debug|Win32 + {4E274B19-10B2-4987-96C5-76F35A149502}.Release|Win32.ActiveCfg = Release|Win32 + {4E274B19-10B2-4987-96C5-76F35A149502}.Release|Win32.Build.0 = Release|Win32 + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Debug_nosound|Win32.ActiveCfg = Debug_nosound|Win32 + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Debug_nosound|Win32.Build.0 = Debug_nosound|Win32 + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Debug|Win32.ActiveCfg = Debug|Win32 + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Debug|Win32.Build.0 = Debug|Win32 + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Release|Win32.ActiveCfg = Release|Win32 + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Salmon Engine/Salmon Engine.vcxproj b/Salmon Engine/Salmon Engine.vcxproj new file mode 100644 index 0000000..d651766 --- /dev/null +++ b/Salmon Engine/Salmon Engine.vcxproj @@ -0,0 +1,175 @@ + + + + + Debug_nosound + Win32 + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20} + SalmonEngine + + + + StaticLibrary + true + NotSet + + + StaticLibrary + true + NotSet + + + StaticLibrary + false + true + NotSet + + + + + + + + + + + + + + + + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SolutionDir)include;$(SolutionDir)include\Animation;$(SolutionDir)include\FrameManager;$(SolutionDir)include\LightManager;$(SolutionDir)include\ModelManager;$(SolutionDir)include\OpenGLExt;$(SolutionDir)include\SalmonRender;$(SolutionDir)include\ShaderManager;$(SolutionDir)include\TextureManager;$(SolutionDir)include\Utils;$(SolutionDir)include\Utils\Console;$(SolutionDir)include\Utils\DataTypes;$(SolutionDir)include\Utils\ErrorTypes;$(SolutionDir)include\Utils\FileUtils + $(SalmonEnginePath)$(Configuration)\ + + + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SolutionDir)include;$(SolutionDir)include\Animation;$(SolutionDir)include\FrameManager;$(SolutionDir)include\LightManager;$(SolutionDir)include\ModelManager;$(SolutionDir)include\OpenGLExt;$(SolutionDir)include\SalmonRender;$(SolutionDir)include\ShaderManager;$(SolutionDir)include\TextureManager;$(SolutionDir)include\Utils;$(SolutionDir)include\Utils\Console;$(SolutionDir)include\Utils\DataTypes;$(SolutionDir)include\Utils\ErrorTypes;$(SolutionDir)include\Utils\FileUtils + $(SalmonEnginePath)$(Configuration)\ + + + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SolutionDir)include;$(SolutionDir)include\Animation;$(SolutionDir)include\FrameManager;$(SolutionDir)include\LightManager;$(SolutionDir)include\ModelManager;$(SolutionDir)include\OpenGLExt;$(SolutionDir)include\SalmonRender;$(SolutionDir)include\ShaderManager;$(SolutionDir)include\TextureManager;$(SolutionDir)include\Utils;$(SolutionDir)include\Utils\Console;$(SolutionDir)include\Utils\DataTypes;$(SolutionDir)include\Utils\ErrorTypes;$(SolutionDir)include\Utils\FileUtils + $(SalmonEnginePath)$(Configuration)\ + + + + Level3 + Disabled + TARGET_SALMON;TARGET_WIN32;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501;DEBUG + $(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\openal\OpenAL11_windows_sdk;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;$(LibsPath)\DirectXsdk\Include;$(LibsPath)\lpng1510 + + + true + + + + + Level3 + Disabled + TARGET_SALMON;TARGET_WIN32;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501;DEBUG;NOSOUND + $(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\openal\OpenAL11_windows_sdk;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;C:\Program Files (x86)\Microsoft DirectX SDK (February 2010)\Include;$(LibsPath)\lpng1510 + + + true + + + + + Level3 + MaxSpeed + true + true + MultiThreaded + TARGET_SALMON;TARGET_WIN32;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501;NDEBUG + $(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\openal\OpenAL11_windows_sdk;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;$(LibsPath)\DirectXsdk\Include;$(LibsPath)\lpng1510 + + + true + true + true + + + + + + \ No newline at end of file diff --git a/Templates/HalibutUniversalTemplate/.classpath b/Templates/HalibutUniversalTemplate/.classpath new file mode 100644 index 0000000..36de7ba --- /dev/null +++ b/Templates/HalibutUniversalTemplate/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/Templates/HalibutUniversalTemplate/.project b/Templates/HalibutUniversalTemplate/.project new file mode 100644 index 0000000..4c7a50f --- /dev/null +++ b/Templates/HalibutUniversalTemplate/.project @@ -0,0 +1,33 @@ + + + EngineWrapper + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/Templates/HalibutUniversalTemplate/AndroidManifest.xml b/Templates/HalibutUniversalTemplate/AndroidManifest.xml new file mode 100644 index 0000000..215d567 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/AndroidManifest.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + diff --git a/Templates/HalibutUniversalTemplate/assets/console_bkg.bmp b/Templates/HalibutUniversalTemplate/assets/console_bkg.bmp new file mode 100644 index 0000000..d32ee4c Binary files /dev/null and b/Templates/HalibutUniversalTemplate/assets/console_bkg.bmp differ diff --git a/Templates/HalibutUniversalTemplate/assets/droid_sans14_font_bitmap.bmp32 b/Templates/HalibutUniversalTemplate/assets/droid_sans14_font_bitmap.bmp32 new file mode 100644 index 0000000..b9f2b1f Binary files /dev/null and b/Templates/HalibutUniversalTemplate/assets/droid_sans14_font_bitmap.bmp32 differ diff --git a/Templates/HalibutUniversalTemplate/assets/droid_sans14_font_charmap.txt b/Templates/HalibutUniversalTemplate/assets/droid_sans14_font_charmap.txt new file mode 100644 index 0000000..f17cd0b --- /dev/null +++ b/Templates/HalibutUniversalTemplate/assets/droid_sans14_font_charmap.txt @@ -0,0 +1,95 @@ +32 0.00976562 0.0195312 0 0.0546875 0 0 0.0078125 +49 0.0195312 0.0195312 0.00390625 0.015625 0.0078125 0.0390625 0.015625 +50 0.0371094 0.0195312 0.00195312 0.015625 0.0136719 0.0390625 0.015625 +51 0.0605469 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625 +52 0.0820312 0.0195312 0.00195312 0.015625 0.0136719 0.0390625 0.015625 +53 0.105469 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625 +54 0.126953 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625 +55 0.148438 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625 +56 0.169922 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625 +57 0.191406 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625 +48 0.212891 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625 +97 0.234375 0.0195312 0.00195312 0.0234375 0.00976562 0.03125 0.0136719 +98 0.253906 0.0195312 0.00195312 0.0117188 0.0117188 0.0429688 0.015625 +99 0.275391 0.0195312 0.00195312 0.0234375 0.00976562 0.03125 0.0136719 +100 0.294922 0.0195312 0.00195312 0.0117188 0.0117188 0.0429688 0.015625 +101 0.316406 0.0195312 0.00195312 0.0234375 0.0117188 0.03125 0.015625 +102 0.337891 0.0195312 0 0.0117188 0.00976562 0.0429688 0.0078125 +103 0.357422 0.0195312 0.00195312 0.0234375 0.0136719 0.0429688 0.0136719 +104 0.380859 0.0195312 0.00195312 0.0117188 0.0117188 0.0429688 0.015625 +105 0.402344 0.0195312 0 0.0117188 0.00585938 0.0429688 0.0078125 +106 0.417969 0.0195312 -0.00195312 0.0117188 0.0078125 0.0546875 0.0078125 +107 0.435547 0.0195312 0.00195312 0.0117188 0.0136719 0.0429688 0.0136719 +108 0.458984 0.0195312 0.00195312 0.0117188 0.00390625 0.0429688 0.0078125 +109 0.472656 0.0195312 0.00195312 0.0234375 0.0214844 0.03125 0.0253906 +110 0.503906 0.0195312 0.00195312 0.0234375 0.0117188 0.03125 0.015625 +111 0.525391 0.0195312 0.00195312 0.0234375 0.0117188 0.03125 0.015625 +112 0.546875 0.0195312 0.00195312 0.0234375 0.0117188 0.0429688 0.015625 +113 0.568359 0.0195312 0.00195312 0.0234375 0.0117188 0.0429688 0.015625 +114 0.589844 0.0195312 0.00195312 0.0234375 0.0078125 0.03125 0.00976562 +115 0.607422 0.0195312 0 0.0234375 0.0117188 0.03125 0.0136719 +116 0.628906 0.0195312 0 0.015625 0.00976562 0.0390625 0.00976562 +117 0.648438 0.0195312 0.00195312 0.0234375 0.0117188 0.03125 0.015625 +118 0.669922 0.0195312 -0.00195312 0.0234375 0.0175781 0.03125 0.0136719 +119 0.697266 0.0195312 -0.00195312 0.0234375 0.0234375 0.03125 0.0195312 +120 0.730469 0.0195312 0 0.0234375 0.0136719 0.03125 0.0136719 +121 0.753906 0.0195312 -0.00195312 0.0234375 0.0175781 0.0429688 0.0136719 +122 0.78125 0.0195312 0.00195312 0.0234375 0.0117188 0.03125 0.0136719 +65 0.802734 0.0195312 -0.00195312 0.015625 0.0214844 0.0390625 0.0175781 +66 0.833984 0.0195312 0.00195312 0.015625 0.0136719 0.0390625 0.0175781 +67 0.857422 0.0195312 0.00195312 0.015625 0.0136719 0.0390625 0.015625 +68 0.880859 0.0195312 0.00195312 0.015625 0.015625 0.0390625 0.0195312 +69 0.90625 0.0195312 0.00195312 0.015625 0.00976562 0.0390625 0.0136719 +70 0.925781 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.0136719 +71 0.947266 0.0195312 0.00195312 0.015625 0.015625 0.0390625 0.0195312 +72 0.00976562 0.09375 0.00195312 0.015625 0.015625 0.0390625 0.0195312 +73 0.0351562 0.09375 0 0.015625 0.00976562 0.0390625 0.00976562 +74 0.0546875 0.09375 -0.00390625 0.015625 0.00976562 0.0507812 0.00585938 +75 0.0742188 0.09375 0.00195312 0.015625 0.015625 0.0390625 0.015625 +76 0.0996094 0.09375 0.00195312 0.015625 0.0117188 0.0390625 0.0136719 +77 0.121094 0.09375 0.00195312 0.015625 0.0195312 0.0390625 0.0234375 +78 0.150391 0.09375 0.00195312 0.015625 0.015625 0.0390625 0.0195312 +79 0.175781 0.09375 0.00195312 0.015625 0.0175781 0.0390625 0.0214844 +80 0.203125 0.09375 0.00195312 0.015625 0.0117188 0.0390625 0.015625 +81 0.224609 0.09375 0.00195312 0.015625 0.0175781 0.046875 0.0214844 +82 0.251953 0.09375 0.00195312 0.015625 0.0136719 0.0390625 0.015625 +83 0.275391 0.09375 0 0.015625 0.0136719 0.0390625 0.0136719 +84 0.298828 0.09375 0 0.015625 0.0136719 0.0390625 0.0136719 +85 0.322266 0.09375 0.00195312 0.015625 0.015625 0.0390625 0.0195312 +86 0.347656 0.09375 -0.00195312 0.015625 0.0195312 0.0390625 0.015625 +87 0.376953 0.09375 -0.00195312 0.015625 0.0292969 0.0390625 0.0253906 +88 0.416016 0.09375 -0.00195312 0.015625 0.0195312 0.0390625 0.015625 +89 0.445312 0.09375 -0.00195312 0.015625 0.0175781 0.0390625 0.0136719 +90 0.472656 0.09375 0.00195312 0.015625 0.0117188 0.0390625 0.015625 +46 0.494141 0.09375 0.00195312 0.046875 0.00390625 0.0078125 0.0078125 +44 0.507812 0.09375 0.00195312 0.046875 0.00390625 0.0117188 0.0078125 +58 0.521484 0.09375 0.00195312 0.0234375 0.00390625 0.03125 0.0078125 +59 0.535156 0.09375 0.00195312 0.0234375 0.00390625 0.0351562 0.0078125 +64 0.548828 0.09375 0.00195312 0.015625 0.0195312 0.0429688 0.0234375 +35 0.578125 0.09375 0 0.015625 0.015625 0.0390625 0.0175781 +36 0.603516 0.09375 0.00195312 0.0117188 0.0117188 0.046875 0.015625 +37 0.625 0.09375 0.00195312 0.015625 0.0195312 0.0390625 0.0234375 +94 0.654297 0.09375 0 0.015625 0.0136719 0.0234375 0.0136719 +38 0.677734 0.09375 0.00195312 0.015625 0.0175781 0.0390625 0.0195312 +42 0.705078 0.09375 0 0.0117188 0.0136719 0.0234375 0.015625 +33 0.728516 0.09375 0.00195312 0.015625 0.00390625 0.0390625 0.0078125 +63 0.742188 0.09375 0 0.015625 0.00976562 0.0390625 0.0117188 +40 0.761719 0.09375 0.00195312 0.015625 0.0078125 0.046875 0.0078125 +41 0.779297 0.09375 0 0.015625 0.00585938 0.046875 0.0078125 +91 0.794922 0.09375 0.00195312 0.015625 0.00585938 0.046875 0.0078125 +93 0.810547 0.09375 0 0.015625 0.00585938 0.046875 0.0078125 +123 0.826172 0.09375 0 0.015625 0.00976562 0.046875 0.00976562 +125 0.845703 0.09375 0 0.015625 0.00976562 0.046875 0.00976562 +60 0.865234 0.09375 0.00195312 0.0234375 0.0117188 0.0273438 0.015625 +62 0.886719 0.09375 0.00195312 0.0234375 0.0117188 0.0273438 0.015625 +95 0.908203 0.09375 0 0.0585938 0.0117188 0.00390625 0.0117188 +45 0.929688 0.09375 0.00195312 0.0390625 0.00585938 0.0078125 0.00976562 +43 0.945312 0.09375 0 0.0234375 0.0136719 0.0273438 0.015625 +61 0.00976562 0.167969 0 0.0273438 0.0136719 0.0195312 0.015625 +124 0.0332031 0.167969 0.00585938 0.0117188 0.00390625 0.0546875 0.0136719 +92 0.046875 0.167969 -0.00195312 0.015625 0.0136719 0.0390625 0.00976562 +47 0.0703125 0.167969 -0.00195312 0.015625 0.0136719 0.0390625 0.00976562 +126 0.09375 0.167969 0.00195312 0.03125 0.0117188 0.0117188 0.015625 +96 0.115234 0.167969 0.00585938 0.0117188 0.00585938 0.0078125 0.015625 +34 0.130859 0.167969 0.00195312 0.015625 0.00976562 0.015625 0.0117188 +39 0.150391 0.167969 0.00195312 0.015625 0.00390625 0.015625 0.00585938 \ No newline at end of file diff --git a/Templates/HalibutUniversalTemplate/assets/shader_fragment.txt b/Templates/HalibutUniversalTemplate/assets/shader_fragment.txt new file mode 100644 index 0000000..523790e --- /dev/null +++ b/Templates/HalibutUniversalTemplate/assets/shader_fragment.txt @@ -0,0 +1,14 @@ +precision mediump float; +uniform sampler2D Texture; +uniform float Transparency; +varying vec2 texCoord; + +void main() +{ + vec4 color = texture2D(Texture,texCoord).rgba; + + gl_FragColor = vec4(color.rgb, color.a * Transparency); + + + +} \ No newline at end of file diff --git a/Templates/HalibutUniversalTemplate/assets/shader_vertex.txt b/Templates/HalibutUniversalTemplate/assets/shader_vertex.txt new file mode 100644 index 0000000..72d9f46 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/assets/shader_vertex.txt @@ -0,0 +1,12 @@ +attribute vec3 vPosition; +attribute vec2 vTexCoord; +varying vec2 texCoord; + +uniform mat4 ProjectionMatrix; + +void main() +{ + //480x320 + gl_Position = ProjectionMatrix * vec4(vPosition.xyz, 1.0); + texCoord = vTexCoord; +} \ No newline at end of file diff --git a/Templates/HalibutUniversalTemplate/default.properties b/Templates/HalibutUniversalTemplate/default.properties new file mode 100644 index 0000000..94a5300 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/default.properties @@ -0,0 +1,11 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "build.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-8 diff --git a/Templates/HalibutUniversalTemplate/iOS/AppDelegate.h b/Templates/HalibutUniversalTemplate/iOS/AppDelegate.h new file mode 100644 index 0000000..4237984 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/iOS/AppDelegate.h @@ -0,0 +1,19 @@ +// +// AppDelegate.h +// doublehitballs +// +// Created by vvv ооо on 13.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import + +@class ViewController; + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@property (strong, nonatomic) ViewController *viewController; + +@end diff --git a/Templates/HalibutUniversalTemplate/iOS/AppDelegate.m b/Templates/HalibutUniversalTemplate/iOS/AppDelegate.m new file mode 100644 index 0000000..1283115 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/iOS/AppDelegate.m @@ -0,0 +1,59 @@ +// +// AppDelegate.m +// doublehitballs +// +// Created by vvv ооо on 13.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import "AppDelegate.h" + +#import "ViewController.h" + +@implementation AppDelegate + +@synthesize window = _window; +@synthesize viewController = _viewController; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + // Override point for customization after application launch. + if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { + self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil]; + } else { + self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil]; + } + self.window.rootViewController = self.viewController; + [self.window makeKeyAndVisible]; + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application +{ + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application +{ + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application +{ + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application +{ + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *)application +{ + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + +@end diff --git a/Templates/HalibutUniversalTemplate/iOS/CustomGLKView.h b/Templates/HalibutUniversalTemplate/iOS/CustomGLKView.h new file mode 100644 index 0000000..59184d3 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/iOS/CustomGLKView.h @@ -0,0 +1,17 @@ +// +// CustomGLKView.h +// doublehitballs +// +// Created by vvv ооо on 15.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import + +@interface CustomGLKView : GLKView + +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; + +@end diff --git a/Templates/HalibutUniversalTemplate/iOS/CustomGLKView.m b/Templates/HalibutUniversalTemplate/iOS/CustomGLKView.m new file mode 100644 index 0000000..130b654 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/iOS/CustomGLKView.m @@ -0,0 +1,68 @@ +// +// CustomGLKView.m +// doublehitballs +// +// Created by vvv ооо on 15.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import "CustomGLKView.h" +#import "ios_api.h" + +bool touchMoved = false; +CGPoint prev_loc; + + +@implementation CustomGLKView + +- (id)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + // Initialization code + } + return self; +} + + +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event +{ + + CGPoint location = [[[touches allObjects] objectAtIndex:0] locationInView:self]; + + prev_loc = location; + + touchMoved = false; + + AppOnTapDown(location.x, self.bounds.size.height - location.y); + +} + +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event +{ + CGPoint location = [[[touches allObjects] objectAtIndex:0] locationInView:self]; + + CGPoint prevLocation = [[[touches allObjects] objectAtIndex:0] previousLocationInView:self]; + + if (abs(prev_loc.x - location.x) > 10 || abs(prev_loc.y - location.y) > 10) + { + touchMoved = true; + } + + AppOnScroll(prevLocation.x - location.x, prevLocation.y - location.y); +} + +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event +{ + CGPoint location = [[[touches allObjects] objectAtIndex:0] locationInView:self]; + + if (!touchMoved) + { + AppOnTapUp(location.x, self.bounds.size.height - location.y); + } +} + + + + +@end diff --git a/Templates/HalibutUniversalTemplate/iOS/ViewController.h b/Templates/HalibutUniversalTemplate/iOS/ViewController.h new file mode 100644 index 0000000..e7f9748 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/iOS/ViewController.h @@ -0,0 +1,14 @@ +// +// ViewController.h +// doublehitballs +// +// Created by vvv ооо on 13.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import +#import + +@interface ViewController : GLKViewController + +@end diff --git a/Templates/HalibutUniversalTemplate/iOS/ViewController.m b/Templates/HalibutUniversalTemplate/iOS/ViewController.m new file mode 100644 index 0000000..b04f1d3 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/iOS/ViewController.m @@ -0,0 +1,106 @@ +// +// ViewController.m +// doublehitballs +// +// Created by vvv ооо on 13.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import "ViewController.h" +#import "ios_api.h" + +@interface ViewController () { +} + +@property (strong, nonatomic) EAGLContext *context; +@property (strong, nonatomic) GLKBaseEffect *effect; + +- (void)setupGL; +- (void)tearDownGL; + +@end + +@implementation ViewController + +@synthesize context = _context; +@synthesize effect = _effect; + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; + + if (!self.context) { + NSLog(@"Failed to create ES context"); + } + + GLKView *view = (GLKView *)self.view; + view.context = self.context; + view.drawableDepthFormat = GLKViewDrawableDepthFormat24; + + + [self setupGL]; +} + +- (void)viewDidUnload +{ + [super viewDidUnload]; + + [self tearDownGL]; + + if ([EAGLContext currentContext] == self.context) { + [EAGLContext setCurrentContext:nil]; + } + self.context = nil; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Release any cached data, images, etc. that aren't in use. +} + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +{ + /* + if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { + return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); + } else { + return YES; + }*/ + return UIInterfaceOrientationIsLandscape(interfaceOrientation); +} + +- (void)setupGL +{ + [EAGLContext setCurrentContext:self.context]; + + AppInit(); + } + +- (void)tearDownGL +{ + [EAGLContext setCurrentContext:self.context]; + + AppDeinit(); + +} + +#pragma mark - GLKView and GLKViewController delegate methods + +- (void)update +{ + + AppUpdate(self.timeSinceLastUpdate * 1000); +} + +- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect +{ + + AppDraw(); + +} + + +@end diff --git a/Templates/HalibutUniversalTemplate/iOS/en.lproj/InfoPlist.strings b/Templates/HalibutUniversalTemplate/iOS/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..0f167df --- /dev/null +++ b/Templates/HalibutUniversalTemplate/iOS/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/Templates/HalibutUniversalTemplate/iOS/en.lproj/ViewController_iPad.xib b/Templates/HalibutUniversalTemplate/iOS/en.lproj/ViewController_iPad.xib new file mode 100644 index 0000000..eb81e88 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/iOS/en.lproj/ViewController_iPad.xib @@ -0,0 +1,133 @@ + + + + 1296 + 11E53 + 2182 + 1138.47 + 569.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 1181 + + + IBProxyObject + IBUIView + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBIPadFramework + + + IBFirstResponder + IBIPadFramework + + + + 274 + {{0, 20}, {768, 1004}} + + + + 3 + MQA + + 2 + + + + 2 + + IBIPadFramework + + + + + + + view + + + + 3 + + + + + + 0 + + + + + + 1 + + + + + -1 + + + File's Owner + + + -2 + + + + + + + ViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + CustomGLKView + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + 3 + + + + + CustomGLKView + GLKView + + IBProjectSource + ./Classes/CustomGLKView.h + + + + ViewController + GLKViewController + + IBProjectSource + ./Classes/ViewController.h + + + + + 0 + IBIPadFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + YES + 3 + 1181 + + diff --git a/Templates/HalibutUniversalTemplate/iOS/en.lproj/ViewController_iPhone.xib b/Templates/HalibutUniversalTemplate/iOS/en.lproj/ViewController_iPhone.xib new file mode 100644 index 0000000..96a4a92 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/iOS/en.lproj/ViewController_iPhone.xib @@ -0,0 +1,111 @@ + + + + 1296 + 11E53 + 2182 + 1138.47 + 569.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 1181 + + + IBProxyObject + IBUIView + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 274 + {320, 460} + + + 3 + MQA + + 2 + + + NO + IBCocoaTouchFramework + + + + + + + view + + + + 3 + + + + + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 2 + + + + + + + ViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + CustomGLKView + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + 4 + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + YES + 3 + 1181 + + diff --git a/Templates/HalibutUniversalTemplate/iOS/halibuttemplate.xcodeproj/project.pbxproj b/Templates/HalibutUniversalTemplate/iOS/halibuttemplate.xcodeproj/project.pbxproj new file mode 100644 index 0000000..870664f --- /dev/null +++ b/Templates/HalibutUniversalTemplate/iOS/halibuttemplate.xcodeproj/project.pbxproj @@ -0,0 +1,504 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 4C49B2BE15B0991B003512CD /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C49B2BD15B0991B003512CD /* UIKit.framework */; }; + 4C49B2C015B0991B003512CD /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C49B2BF15B0991B003512CD /* Foundation.framework */; }; + 4C49B2C215B0991B003512CD /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C49B2C115B0991B003512CD /* CoreGraphics.framework */; }; + 4C49B2C415B0991B003512CD /* GLKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C49B2C315B0991B003512CD /* GLKit.framework */; }; + 4C49B2C615B0991B003512CD /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C49B2C515B0991B003512CD /* OpenGLES.framework */; }; + 4C49B2CC15B0991B003512CD /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4C49B2CA15B0991B003512CD /* InfoPlist.strings */; }; + 4C49B2CE15B0991B003512CD /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C49B2CD15B0991B003512CD /* main.m */; }; + 4C49B2D215B0991B003512CD /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C49B2D115B0991B003512CD /* AppDelegate.m */; }; + 4C49B2D915B0991B003512CD /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C49B2D815B0991B003512CD /* ViewController.m */; }; + 4C49B2DC15B0991B003512CD /* ViewController_iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C49B2DA15B0991B003512CD /* ViewController_iPhone.xib */; }; + 4C49B2DF15B0991B003512CD /* ViewController_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C49B2DD15B0991B003512CD /* ViewController_iPad.xib */; }; + 4C4C807515BA8F460037C6CE /* libsquirrel.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C4C807415BA8F460037C6CE /* libsquirrel.a */; }; + 4C4C807715BA8F5B0037C6CE /* libz.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C4C807615BA8F5B0037C6CE /* libz.a */; }; + 4C6EB44515C3CFD300316CB6 /* libpng.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C6EB44415C3CFD300316CB6 /* libpng.a */; }; + 4C74848615C5AD6E0056EC44 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 4C74848315C5AD6E0056EC44 /* Icon.png */; }; + 4C74848715C5AD6E0056EC44 /* iTunesArtwork in Resources */ = {isa = PBXBuildFile; fileRef = 4C74848415C5AD6E0056EC44 /* iTunesArtwork */; }; + 4C74848815C5AD6E0056EC44 /* Splash-landscape.png in Resources */ = {isa = PBXBuildFile; fileRef = 4C74848515C5AD6E0056EC44 /* Splash-landscape.png */; }; + 4C74849815C5AF7C0056EC44 /* main_code.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C74849615C5AF7C0056EC44 /* main_code.cpp */; }; + 4C7484AC15C5BF580056EC44 /* libHalibut Engine.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C7484AB15C5BDD70056EC44 /* libHalibut Engine.a */; }; + 4C77831315BABD68003D5142 /* libvorbis-tremor-ios.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C77831215BABD68003D5142 /* libvorbis-tremor-ios.a */; }; + 4C77831815BABE26003D5142 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C77831415BABD8B003D5142 /* AudioToolbox.framework */; }; + 4C77831915BABE26003D5142 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C77831515BABD8B003D5142 /* OpenAL.framework */; }; + 4C7AD44C15B1D77700A599F6 /* ios_api.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C7AD44B15B1D77700A599F6 /* ios_api.cpp */; }; + 4C7C584B15C31E6500CAE4F4 /* libboost.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C7C584A15C31E6500CAE4F4 /* libboost.a */; }; + 4CCC0ECC15B30D6B005432FB /* CustomGLKView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CCC0ECB15B30D6B005432FB /* CustomGLKView.m */; }; + 4CE6A9D215B2F979006A3965 /* assets in Resources */ = {isa = PBXBuildFile; fileRef = 4CE6A9D115B2F979006A3965 /* assets */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 4C7484AA15C5BDD70056EC44 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 4C7484A315C5BDD60056EC44 /* Halibut Engine.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 4C8CE90215B0A0F400078175; + remoteInfo = "Halibut Engine"; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 4C49B2B915B0991B003512CD /* halibuttemplate.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = halibuttemplate.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 4C49B2BD15B0991B003512CD /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 4C49B2BF15B0991B003512CD /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 4C49B2C115B0991B003512CD /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + 4C49B2C315B0991B003512CD /* GLKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLKit.framework; path = System/Library/Frameworks/GLKit.framework; sourceTree = SDKROOT; }; + 4C49B2C515B0991B003512CD /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; + 4C49B2C915B0991B003512CD /* template-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "template-Info.plist"; sourceTree = ""; }; + 4C49B2CB15B0991B003512CD /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 4C49B2CD15B0991B003512CD /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 4C49B2CF15B0991B003512CD /* template-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "template-Prefix.pch"; sourceTree = ""; }; + 4C49B2D015B0991B003512CD /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 4C49B2D115B0991B003512CD /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 4C49B2D715B0991B003512CD /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 4C49B2D815B0991B003512CD /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 4C49B2DB15B0991B003512CD /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController_iPhone.xib; sourceTree = ""; }; + 4C49B2DE15B0991B003512CD /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController_iPad.xib; sourceTree = ""; }; + 4C4C807415BA8F460037C6CE /* libsquirrel.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libsquirrel.a; path = "../../libs/SQUIRREL2_1_1_sqplus/build-ios/ios-device/libsquirrel.a"; sourceTree = ""; }; + 4C4C807615BA8F5B0037C6CE /* libz.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libz.a; path = "../../libs/zlib-1.2.7/build-ios/ios-device/libz.a"; sourceTree = ""; }; + 4C6EB44415C3CFD300316CB6 /* libpng.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpng.a; path = "../../libs/libpng-1.5.12/build-ios/ios-simulator/libpng.a"; sourceTree = ""; }; + 4C74848315C5AD6E0056EC44 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon.png; path = res/Icon.png; sourceTree = ""; }; + 4C74848415C5AD6E0056EC44 /* iTunesArtwork */ = {isa = PBXFileReference; lastKnownFileType = file; name = iTunesArtwork; path = res/iTunesArtwork; sourceTree = ""; }; + 4C74848515C5AD6E0056EC44 /* Splash-landscape.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Splash-landscape.png"; path = "res/Splash-landscape.png"; sourceTree = ""; }; + 4C74849615C5AF7C0056EC44 /* main_code.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main_code.cpp; path = ../jni/main_code.cpp; sourceTree = ""; }; + 4C74849715C5AF7C0056EC44 /* main_code.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = main_code.h; path = ../jni/main_code.h; sourceTree = ""; }; + 4C7484A315C5BDD60056EC44 /* Halibut Engine.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "Halibut Engine.xcodeproj"; path = "../../Engine/iOS/Halibut Engine/Halibut Engine.xcodeproj"; sourceTree = ""; }; + 4C77831215BABD68003D5142 /* libvorbis-tremor-ios.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libvorbis-tremor-ios.a"; path = "../../libs/vorbis-tremor-ios/build-ios/ios-device/libvorbis-tremor-ios.a"; sourceTree = ""; }; + 4C77831415BABD8B003D5142 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; + 4C77831515BABD8B003D5142 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; + 4C7AD44B15B1D77700A599F6 /* ios_api.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ios_api.cpp; sourceTree = ""; }; + 4C7C584A15C31E6500CAE4F4 /* libboost.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libboost.a; path = "../../libs/boost_1_47_0/build-ios/ios-simulator/libboost.a"; sourceTree = ""; }; + 4CCC0ECA15B30D6A005432FB /* CustomGLKView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomGLKView.h; sourceTree = ""; }; + 4CCC0ECB15B30D6B005432FB /* CustomGLKView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomGLKView.m; sourceTree = ""; }; + 4CCC0ECD15B310FB005432FB /* ios_api.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ios_api.h; sourceTree = ""; }; + 4CE6A9D115B2F979006A3965 /* assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = assets; path = ../assets; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 4C49B2B615B0991B003512CD /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 4C7484AC15C5BF580056EC44 /* libHalibut Engine.a in Frameworks */, + 4C77831815BABE26003D5142 /* AudioToolbox.framework in Frameworks */, + 4C77831915BABE26003D5142 /* OpenAL.framework in Frameworks */, + 4C49B2BE15B0991B003512CD /* UIKit.framework in Frameworks */, + 4C49B2C015B0991B003512CD /* Foundation.framework in Frameworks */, + 4C49B2C215B0991B003512CD /* CoreGraphics.framework in Frameworks */, + 4C49B2C415B0991B003512CD /* GLKit.framework in Frameworks */, + 4C49B2C615B0991B003512CD /* OpenGLES.framework in Frameworks */, + 4C4C807515BA8F460037C6CE /* libsquirrel.a in Frameworks */, + 4C4C807715BA8F5B0037C6CE /* libz.a in Frameworks */, + 4C77831315BABD68003D5142 /* libvorbis-tremor-ios.a in Frameworks */, + 4C7C584B15C31E6500CAE4F4 /* libboost.a in Frameworks */, + 4C6EB44515C3CFD300316CB6 /* libpng.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 4C49B2AE15B0991B003512CD = { + isa = PBXGroup; + children = ( + 4C7484A315C5BDD60056EC44 /* Halibut Engine.xcodeproj */, + 4C7B819515C40F770024D61A /* Libs */, + 4CC1FC3415B200130025C6F7 /* Resources */, + 4C49B2C715B0991B003512CD /* Sources */, + 4C49B2BC15B0991B003512CD /* Frameworks */, + 4C49B2BA15B0991B003512CD /* Products */, + ); + sourceTree = ""; + }; + 4C49B2BA15B0991B003512CD /* Products */ = { + isa = PBXGroup; + children = ( + 4C49B2B915B0991B003512CD /* halibuttemplate.app */, + ); + name = Products; + sourceTree = ""; + }; + 4C49B2BC15B0991B003512CD /* Frameworks */ = { + isa = PBXGroup; + children = ( + 4C77831415BABD8B003D5142 /* AudioToolbox.framework */, + 4C77831515BABD8B003D5142 /* OpenAL.framework */, + 4C49B2BD15B0991B003512CD /* UIKit.framework */, + 4C49B2BF15B0991B003512CD /* Foundation.framework */, + 4C49B2C115B0991B003512CD /* CoreGraphics.framework */, + 4C49B2C315B0991B003512CD /* GLKit.framework */, + 4C49B2C515B0991B003512CD /* OpenGLES.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 4C49B2C715B0991B003512CD /* Sources */ = { + isa = PBXGroup; + children = ( + 4CE6A9E315B2F9A4006A3965 /* Game */, + 4CCC0ECD15B310FB005432FB /* ios_api.h */, + 4C7AD44B15B1D77700A599F6 /* ios_api.cpp */, + 4C49B2D015B0991B003512CD /* AppDelegate.h */, + 4C49B2D115B0991B003512CD /* AppDelegate.m */, + 4C49B2D715B0991B003512CD /* ViewController.h */, + 4C49B2D815B0991B003512CD /* ViewController.m */, + 4C49B2DA15B0991B003512CD /* ViewController_iPhone.xib */, + 4C49B2DD15B0991B003512CD /* ViewController_iPad.xib */, + 4C49B2C815B0991B003512CD /* Supporting Files */, + 4CCC0ECA15B30D6A005432FB /* CustomGLKView.h */, + 4CCC0ECB15B30D6B005432FB /* CustomGLKView.m */, + ); + name = Sources; + sourceTree = ""; + }; + 4C49B2C815B0991B003512CD /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 4C49B2C915B0991B003512CD /* template-Info.plist */, + 4C49B2CA15B0991B003512CD /* InfoPlist.strings */, + 4C49B2CD15B0991B003512CD /* main.m */, + 4C49B2CF15B0991B003512CD /* template-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 4C7484A415C5BDD60056EC44 /* Products */ = { + isa = PBXGroup; + children = ( + 4C7484AB15C5BDD70056EC44 /* libHalibut Engine.a */, + ); + name = Products; + sourceTree = ""; + }; + 4C7B819515C40F770024D61A /* Libs */ = { + isa = PBXGroup; + children = ( + 4C6EB44415C3CFD300316CB6 /* libpng.a */, + 4C7C584A15C31E6500CAE4F4 /* libboost.a */, + 4C77831215BABD68003D5142 /* libvorbis-tremor-ios.a */, + 4C4C807615BA8F5B0037C6CE /* libz.a */, + 4C4C807415BA8F460037C6CE /* libsquirrel.a */, + ); + name = Libs; + sourceTree = ""; + }; + 4CC1FC3415B200130025C6F7 /* Resources */ = { + isa = PBXGroup; + children = ( + 4C74848315C5AD6E0056EC44 /* Icon.png */, + 4C74848415C5AD6E0056EC44 /* iTunesArtwork */, + 4C74848515C5AD6E0056EC44 /* Splash-landscape.png */, + 4CE6A9D115B2F979006A3965 /* assets */, + ); + name = Resources; + sourceTree = ""; + }; + 4CE6A9E315B2F9A4006A3965 /* Game */ = { + isa = PBXGroup; + children = ( + 4C74849615C5AF7C0056EC44 /* main_code.cpp */, + 4C74849715C5AF7C0056EC44 /* main_code.h */, + ); + name = Game; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 4C49B2B815B0991B003512CD /* halibuttemplate */ = { + isa = PBXNativeTarget; + buildConfigurationList = 4C49B2E215B0991B003512CD /* Build configuration list for PBXNativeTarget "halibuttemplate" */; + buildPhases = ( + 4C49B2B515B0991B003512CD /* Sources */, + 4C49B2B615B0991B003512CD /* Frameworks */, + 4C49B2B715B0991B003512CD /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = halibuttemplate; + productName = doublehitballs; + productReference = 4C49B2B915B0991B003512CD /* halibuttemplate.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 4C49B2B015B0991B003512CD /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0430; + }; + buildConfigurationList = 4C49B2B315B0991B003512CD /* Build configuration list for PBXProject "halibuttemplate" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 4C49B2AE15B0991B003512CD; + productRefGroup = 4C49B2BA15B0991B003512CD /* Products */; + projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 4C7484A415C5BDD60056EC44 /* Products */; + ProjectRef = 4C7484A315C5BDD60056EC44 /* Halibut Engine.xcodeproj */; + }, + ); + projectRoot = ""; + targets = ( + 4C49B2B815B0991B003512CD /* halibuttemplate */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXReferenceProxy section */ + 4C7484AB15C5BDD70056EC44 /* libHalibut Engine.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libHalibut Engine.a"; + remoteRef = 4C7484AA15C5BDD70056EC44 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + +/* Begin PBXResourcesBuildPhase section */ + 4C49B2B715B0991B003512CD /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4C49B2CC15B0991B003512CD /* InfoPlist.strings in Resources */, + 4C49B2DC15B0991B003512CD /* ViewController_iPhone.xib in Resources */, + 4C49B2DF15B0991B003512CD /* ViewController_iPad.xib in Resources */, + 4CE6A9D215B2F979006A3965 /* assets in Resources */, + 4C74848615C5AD6E0056EC44 /* Icon.png in Resources */, + 4C74848715C5AD6E0056EC44 /* iTunesArtwork in Resources */, + 4C74848815C5AD6E0056EC44 /* Splash-landscape.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 4C49B2B515B0991B003512CD /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4C49B2CE15B0991B003512CD /* main.m in Sources */, + 4C49B2D215B0991B003512CD /* AppDelegate.m in Sources */, + 4C49B2D915B0991B003512CD /* ViewController.m in Sources */, + 4C7AD44C15B1D77700A599F6 /* ios_api.cpp in Sources */, + 4CCC0ECC15B30D6B005432FB /* CustomGLKView.m in Sources */, + 4C74849815C5AF7C0056EC44 /* main_code.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 4C49B2CA15B0991B003512CD /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 4C49B2CB15B0991B003512CD /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + 4C49B2DA15B0991B003512CD /* ViewController_iPhone.xib */ = { + isa = PBXVariantGroup; + children = ( + 4C49B2DB15B0991B003512CD /* en */, + ); + name = ViewController_iPhone.xib; + sourceTree = ""; + }; + 4C49B2DD15B0991B003512CD /* ViewController_iPad.xib */ = { + isa = PBXVariantGroup; + children = ( + 4C49B2DE15B0991B003512CD /* en */, + ); + name = ViewController_iPad.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 4C49B2E015B0991B003512CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 4C49B2E115B0991B003512CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 4C49B2E315B0991B003512CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "template-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + TARGET_IOS, + TARGET_HALIBUT, + DEBUG, + "$(inherited)", + BOOST_NO_CXX11_NUMERIC_LIMITS, + ); + GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = ""; + "GCC_THUMB_SUPPORT[arch=armv6]" = ""; + HEADER_SEARCH_PATHS = ( + "$(SalmonEnginePath)", + "$(LibsPath)/lpng1510", + "$(LibsPath)/sqplus/sqplus", + "$(LibsPath)/sqplus/include", + "$(LibsPath)/boost_1_52_0", + ../jni, + "$(LibsPath)/vorbis-tremor-ios/vorbis", + ); + INFOPLIST_FILE = "template-Info.plist"; + LIBRARY_SEARCH_PATHS = ""; + "LIBRARY_SEARCH_PATHS[sdk=iphoneos*]" = ( + "$(LibsPath)/lpng1510/build-ios/ios-device", + "$(LibsPath)/boost_1_52_0/build-ios/ios-device", + "$(LibsPath)/sqplus/build-ios/ios-device", + "$(LibsPath)/zlib-1.2.6/build-ios/ios-device", + "$(LibsPath)/vorbis-tremor-ios/build-ios/ios-device", + ); + "LIBRARY_SEARCH_PATHS[sdk=iphonesimulator*]" = ( + "$(LibsPath)/lpng1510/build-ios/ios-simulator", + "$(LibsPath)/sqplus/build-ios/ios-simulator", + "$(LibsPath)/boost_1_52_0/build-ios/ios-simulator", + "$(LibsPath)/zlib-1.2.6/build-ios/ios-simulator", + "$(LibsPath)/vorbis-tremor-ios/build-ios/ios-simulator", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + SYMROOT = build; + TARGETED_DEVICE_FAMILY = 1; + USER_HEADER_SEARCH_PATHS = ""; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + 4C49B2E415B0991B003512CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "template-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + TARGET_IOS, + TARGET_HALIBUT, + BOOST_NO_CXX11_NUMERIC_LIMITS, + ); + GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = ""; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + "GCC_THUMB_SUPPORT[arch=armv6]" = ""; + HEADER_SEARCH_PATHS = ( + "$(SalmonEnginePath)", + "$(LibsPath)/lpng1510", + "$(LibsPath)/sqplus/sqplus", + "$(LibsPath)/sqplus/include", + "$(LibsPath)/boost_1_52_0", + ../jni, + "$(LibsPath)/vorbis-tremor-ios/vorbis", + ); + INFOPLIST_FILE = "template-Info.plist"; + LIBRARY_SEARCH_PATHS = ""; + "LIBRARY_SEARCH_PATHS[sdk=iphoneos*]" = ( + "$(LibsPath)/lpng1510/build-ios/ios-device", + "$(LibsPath)/boost_1_52_0/build-ios/ios-device", + "$(LibsPath)/sqplus/build-ios/ios-device", + "$(LibsPath)/zlib-1.2.6/build-ios/ios-device", + "$(LibsPath)/vorbis-tremor-ios/build-ios/ios-device", + ); + "LIBRARY_SEARCH_PATHS[sdk=iphonesimulator*]" = ( + "$(LibsPath)/lpng1510/build-ios/ios-simulator", + "$(LibsPath)/sqplus/build-ios/ios-simulator", + "$(LibsPath)/boost_1_52_0/build-ios/ios-simulator", + "$(LibsPath)/zlib-1.2.6/build-ios/ios-simulator", + "$(LibsPath)/vorbis-tremor-ios/build-ios/ios-simulator", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = 1; + USER_HEADER_SEARCH_PATHS = ""; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 4C49B2B315B0991B003512CD /* Build configuration list for PBXProject "halibuttemplate" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4C49B2E015B0991B003512CD /* Debug */, + 4C49B2E115B0991B003512CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 4C49B2E215B0991B003512CD /* Build configuration list for PBXNativeTarget "halibuttemplate" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4C49B2E315B0991B003512CD /* Debug */, + 4C49B2E415B0991B003512CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 4C49B2B015B0991B003512CD /* Project object */; +} diff --git a/Templates/HalibutUniversalTemplate/iOS/ios_api.cpp b/Templates/HalibutUniversalTemplate/iOS/ios_api.cpp new file mode 100644 index 0000000..e8c79cc --- /dev/null +++ b/Templates/HalibutUniversalTemplate/iOS/ios_api.cpp @@ -0,0 +1,47 @@ +#include "include/Engine.h" +#include "main_code.h" + +TMyApplication App; + + +extern "C" void AppInit() +{ + + App.OuterInit(480, 320, 480, 320); +} + + +extern "C" void AppDeinit() +{ + App.OuterDeinit(); + +} + + +extern "C" void AppUpdate(int dt) +{ + App.OuterUpdate(dt); +} + + + +extern "C" void AppDraw() +{ + App.OuterDraw(); +} + +extern "C" void AppOnTapDown(int posx, int posy) +{ + //App.OuterOnTapDown(vec2(posx, posy)); +} + +extern "C" void AppOnTapUp(int posx, int posy) +{ + //App.OuterOnTapUp(vec2(posx, posy)); +} + +extern "C" void AppOnScroll(int shiftx, int shifty) +{ + //App.OuterOnMove(vec2(shiftx, shifty)); +} + diff --git a/Templates/HalibutUniversalTemplate/iOS/ios_api.h b/Templates/HalibutUniversalTemplate/iOS/ios_api.h new file mode 100644 index 0000000..66b7e7f --- /dev/null +++ b/Templates/HalibutUniversalTemplate/iOS/ios_api.h @@ -0,0 +1,15 @@ +// +// Header.h +// doublehitballs +// +// Created by vvv ооо on 15.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +void AppInit(); +void AppDeinit(); +void AppUpdate(int dt); +void AppDraw(); +void AppOnTapDown(int posx, int posy); +void AppOnTapUp(int posx, int posy); +void AppOnScroll(int shiftx, int shifty); \ No newline at end of file diff --git a/Templates/HalibutUniversalTemplate/iOS/main.m b/Templates/HalibutUniversalTemplate/iOS/main.m new file mode 100644 index 0000000..f8b2c00 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/iOS/main.m @@ -0,0 +1,18 @@ +// +// main.m +// doublehitballs +// +// Created by vvv ооо on 13.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import + +#import "AppDelegate.h" + +int main(int argc, char *argv[]) +{ + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/Templates/HalibutUniversalTemplate/iOS/res/Icon.png b/Templates/HalibutUniversalTemplate/iOS/res/Icon.png new file mode 100644 index 0000000..b6880bf Binary files /dev/null and b/Templates/HalibutUniversalTemplate/iOS/res/Icon.png differ diff --git a/Templates/HalibutUniversalTemplate/iOS/res/Splash-landscape.png b/Templates/HalibutUniversalTemplate/iOS/res/Splash-landscape.png new file mode 100644 index 0000000..61dbcaa Binary files /dev/null and b/Templates/HalibutUniversalTemplate/iOS/res/Splash-landscape.png differ diff --git a/Templates/HalibutUniversalTemplate/iOS/res/iTunesArtwork b/Templates/HalibutUniversalTemplate/iOS/res/iTunesArtwork new file mode 100644 index 0000000..876e97d Binary files /dev/null and b/Templates/HalibutUniversalTemplate/iOS/res/iTunesArtwork differ diff --git a/Templates/HalibutUniversalTemplate/iOS/template-Info.plist b/Templates/HalibutUniversalTemplate/iOS/template-Info.plist new file mode 100644 index 0000000..84a7bd1 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/iOS/template-Info.plist @@ -0,0 +1,50 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + Halibut Universal Template + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + Icon.png + CFBundleIdentifier + fishrungames.template + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + UILaunchImageFile + Splash-landscape.png + UIPrerenderedIcon + + UIRequiredDeviceCapabilities + + armv7 + + UIStatusBarHidden + + UISupportedInterfaceOrientations + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Templates/HalibutUniversalTemplate/iOS/template-Prefix.pch b/Templates/HalibutUniversalTemplate/iOS/template-Prefix.pch new file mode 100644 index 0000000..cd479f5 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/iOS/template-Prefix.pch @@ -0,0 +1,14 @@ +// +// Prefix header for all source files of the 'doublehitballs' target in the 'doublehitballs' project +// + +#import + +#ifndef __IPHONE_5_0 +#warning "This project uses features only available in iOS SDK 5.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/Templates/HalibutUniversalTemplate/jni/Android.mk b/Templates/HalibutUniversalTemplate/jni/Android.mk new file mode 100644 index 0000000..8c48b8f --- /dev/null +++ b/Templates/HalibutUniversalTemplate/jni/Android.mk @@ -0,0 +1,72 @@ +# Copyright (C) 2009 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +LPATH := $(call my-dir) + +ENGINE_PATH = $(SalmonEnginePathCygwin) + +BOOST_PATH = $(LibsPathCygwin)/boost_1_47_0 + +OGG_PATH = $(LibsPathCygwin)/libogg-1.3.0 + +VORBIS_PATH = $(LibsPathCygwin)/libvorbis-1.3.2 + +SQUIRREL_PATH = $(LibsPathCygwin)/sqplus + +LIBPNG_PATH = $(LibsPathCygwin)/libpng_1.4.1_android + +ZIP_PATH = $(LibsPathCygwin)/julienr-libzip-android/jni + +#====== ENGINE AND LIBS ===================== + +include $(ENGINE_PATH)/Android_Engine.mk + +#================= THE GAME ======================= + + +LOCAL_PATH:= $(LPATH) + +include $(CLEAR_VARS) + +LOCAL_CFLAGS := -DTARGET_ANDROID -DTARGET_HALIBUT -DNOSOUND -std=gnu++11 --std=c++11 +LOCAL_STATIC_LIBRARIES := boost +LOCAL_STATIC_LIBRARIES += squirrel +LOCAL_STATIC_LIBRARIES += png_lib +LOCAL_STATIC_LIBRARIES += zip +LOCAL_SHARED_LIBRARIES := HalibutEngine +LOCAL_C_INCLUDES := $(ENGINE_PATH) +LOCAL_C_INCLUDES += $(BOOST_PATH) +LOCAL_C_INCLUDES += $(VORBIS_PATH)/include +LOCAL_C_INCLUDES += $(VORBIS_PATH)/include/vorbis +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/books +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/modes +LOCAL_C_INCLUDES += $(OGG_PATH)/include +LOCAL_C_INCLUDES += $(OGG_PATH)/include/ogg +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/include +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/sqplus +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/squirrel +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/sqstdlib +LOCAL_C_INCLUDES += $(LIBPNG_PATH) +LOCAL_C_INCLUDES += $(ZIP_PATH) +LOCAL_MODULE := AndroidJniTemplate +LOCAL_SRC_FILES := main_code.cpp +LOCAL_SRC_FILES += android_api.cpp + +LOCAL_LDLIBS := -lGLESv2 +LOCAL_LDLIBS += -llog -Wl,-s + +include $(BUILD_SHARED_LIBRARY) diff --git a/Templates/HalibutUniversalTemplate/jni/Application.mk b/Templates/HalibutUniversalTemplate/jni/Application.mk new file mode 100644 index 0000000..3ef733b --- /dev/null +++ b/Templates/HalibutUniversalTemplate/jni/Application.mk @@ -0,0 +1,3 @@ +APP_STL := gnustl_static +APP_CPPFLAGS += -fexceptions +APP_CPPFLAGS += -frtti \ No newline at end of file diff --git a/Templates/HalibutUniversalTemplate/jni/android_api.cpp b/Templates/HalibutUniversalTemplate/jni/android_api.cpp new file mode 100644 index 0000000..94536a2 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/jni/android_api.cpp @@ -0,0 +1,116 @@ +#include "android_api.h" + +#include "main_code.h" + +boost::shared_ptr App(new TMyApplication); + +JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height) +{ + try + { + if (App->IsInited()) + { + App->OuterDeinit(); //Clean up what is left at previous launch (if applicable) + } + + App->OuterInit(width, height, 480.f, 320.f); + + App->Inited = true; + } + catch (...) + { + throw; + } +} + +JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_StopSounds(JNIEnv * env, jobject obj) +{ + +} + + +JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_Update(JNIEnv * env, jobject obj, long dt) +{ + try + { + if (App->IsInited()) + { + App->OuterDraw(); + App->OuterUpdate(dt); + } + + } + catch (...) + { + throw; + } + +} + +JNIEXPORT int JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_IsInited(JNIEnv * env, jobject obj) +{ + + if (App->IsInited()) + { + return 1; + } + else + { + return 0; + } + +} + +JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_Destroy(JNIEnv * env, jobject obj) +{ + try + { + if (App->IsInited()) + { + App->OuterDeinit(); + } + + } + catch (...) + { + throw; + } +} + + +JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_OnTapDown(JNIEnv * env, jobject obj, float x, float y, long time) +{ + + try + { + + } + catch (...) + { + throw; + } +} + + +JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_OnTapUp(JNIEnv * env, jobject obj, float x, float y, long time) +{ +} + +JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, float x, float y, long time) +{ +} + +JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_OnFling(JNIEnv * env, jobject obj, jfloat velocityX, jfloat velocityY, long time) +{ + +} + +JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_OnScroll(JNIEnv * env, jobject obj, jfloat distanceX, jfloat distanceY, long time) +{ + +} + +JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_OnKeyPress(JNIEnv * env, jobject obj, jint keyCode) +{ + App->OnKeyPress(keyCode); +} diff --git a/Templates/HalibutUniversalTemplate/jni/android_api.h b/Templates/HalibutUniversalTemplate/jni/android_api.h new file mode 100644 index 0000000..e74ec9b --- /dev/null +++ b/Templates/HalibutUniversalTemplate/jni/android_api.h @@ -0,0 +1,32 @@ +#ifndef ANDROID_API_H_INCLUDED +#define ANDROID_API_H_INCLUDED + +#include +#include + +#include +#include +#include + +#include "boost/shared_ptr.hpp" + +#include "main_code.h" + +using namespace SE; + +extern "C" { + JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height); + JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_StopSounds(JNIEnv * env, jobject obj); + JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_Update(JNIEnv * env, jobject obj, long dt); + JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_Destroy(JNIEnv * env, jobject obj); + JNIEXPORT int JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_IsInited(JNIEnv * env, jobject obj); + JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_OnTapDown(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time); + JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_OnTapUp(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time); + JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time); + JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_OnFling(JNIEnv * env, jobject obj, jfloat velocityX, jfloat velocityY, long time); + JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_OnScroll(JNIEnv * env, jobject obj, jfloat distanceX, jfloat distanceY, long time); + JNIEXPORT void JNICALL Java_fishrungames_halibutjnitemplate_JniWrapper_OnKeyPress(JNIEnv * env, jobject obj, jint keyCode); +}; + + +#endif diff --git a/Templates/HalibutUniversalTemplate/jni/main_code.cpp b/Templates/HalibutUniversalTemplate/jni/main_code.cpp new file mode 100644 index 0000000..7af2b88 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/jni/main_code.cpp @@ -0,0 +1,60 @@ +#include "main_code.h" + +#ifdef TARGET_ANDROID +#include "android_api.h" +#endif + +#include +#include +#include +#include + +#include "include/Engine.h" + +#include "main_code.h" + +void TMyApplication::InnerInit() +{ +#ifdef TARGET_ANDROID + ResourceManager->PathToResources = ""; +#endif +#ifdef TARGET_IOS + ResourceManager->PathToResources = "assets/"; +#endif +#ifdef TARGET_WIN32 +#ifdef NDEBUG + ResourceManager->PathToResources = "resources/"; +#else + ResourceManager->PathToResources = "../../../assets/"; +#endif +#endif + + ResourceManager->ShaderManager.AddShader("DefaultShader", "shader_vertex.txt", "shader_fragment.txt"); + Renderer->PushShader("DefaultShader"); + + + ResourceManager->TexList.AddTexture(CONST_CONSOLE_TEX_NAME); + + ResourceManager->FontManager.AddFont("droid_sans14", "droid_sans14_font_bitmap.bmp32", "droid_sans14_font_charmap.txt"); + ResourceManager->FontManager.PushFont("droid_sans14"); + + //Inited = true; Must be set in android_api.cpp manually +} + +void TMyApplication::InnerDeinit() +{ + Inited = false; +} + + +void TMyApplication::InnerDraw() +{ + //Console->Draw(); +} + + +void TMyApplication::InnerUpdate(cardinal dt) +{ + +} + diff --git a/Templates/HalibutUniversalTemplate/jni/main_code.h b/Templates/HalibutUniversalTemplate/jni/main_code.h new file mode 100644 index 0000000..e30d979 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/jni/main_code.h @@ -0,0 +1,47 @@ +#ifndef GL_CODE_H_INCLUDED +#define GL_CODE_H_INCLUDED + + +#include +#include +#include + +#include "boost/shared_ptr.hpp" +#include "boost/thread/thread.hpp" +#include "boost/asio.hpp" +#include "boost/signal.hpp" +#include "boost/assign.hpp" +#include "boost/bind.hpp" + +#include "include/Engine.h" + +using namespace SE; + + +class TMyApplication : public TApplication +{ +protected: + +public: + bool Inited; + + TMyApplication() : TApplication(), Inited(false) { } + + + virtual void InnerInit(); + + virtual void InnerDeinit(); + + virtual void InnerDraw(); + + virtual void InnerUpdate(cardinal dt); + + bool IsInited() { return Inited; } + +}; + + +static void checkGlError(const std::string& op); + + +#endif diff --git a/Templates/HalibutUniversalTemplate/res/drawable-hdpi/ic_menu_template.png b/Templates/HalibutUniversalTemplate/res/drawable-hdpi/ic_menu_template.png new file mode 100644 index 0000000..1e28f93 Binary files /dev/null and b/Templates/HalibutUniversalTemplate/res/drawable-hdpi/ic_menu_template.png differ diff --git a/Templates/HalibutUniversalTemplate/res/drawable-ldpi/ic_menu_template.png b/Templates/HalibutUniversalTemplate/res/drawable-ldpi/ic_menu_template.png new file mode 100644 index 0000000..6a93cf2 Binary files /dev/null and b/Templates/HalibutUniversalTemplate/res/drawable-ldpi/ic_menu_template.png differ diff --git a/Templates/HalibutUniversalTemplate/res/drawable-mdpi/ic_menu_template.png b/Templates/HalibutUniversalTemplate/res/drawable-mdpi/ic_menu_template.png new file mode 100644 index 0000000..7c1cab2 Binary files /dev/null and b/Templates/HalibutUniversalTemplate/res/drawable-mdpi/ic_menu_template.png differ diff --git a/Templates/HalibutUniversalTemplate/res/values/strings.xml b/Templates/HalibutUniversalTemplate/res/values/strings.xml new file mode 100644 index 0000000..33d1455 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/res/values/strings.xml @@ -0,0 +1,4 @@ + + + AndroidJniTemplate + diff --git a/Templates/HalibutUniversalTemplate/src/fishrungames/halibutjnitemplate/GLView.java b/Templates/HalibutUniversalTemplate/src/fishrungames/halibutjnitemplate/GLView.java new file mode 100644 index 0000000..bbfa76d --- /dev/null +++ b/Templates/HalibutUniversalTemplate/src/fishrungames/halibutjnitemplate/GLView.java @@ -0,0 +1,72 @@ +package fishrungames.halibutjnitemplate; + + +import java.util.Calendar; + +import android.content.Context; +import android.opengl.GLSurfaceView; + +import javax.microedition.khronos.egl.EGLConfig; +import javax.microedition.khronos.opengles.GL10; + +import fishrungames.engine.GLViewAncestor; + +class GLView extends GLViewAncestor +{ + static long lastTimeStamp; + static boolean gameIsInited = false; + + public GLView(Context context) + { + //Change this method? Don't forget to change method below! + super(context); + init(false, 0, 0); + } + + public GLView(Context context, boolean translucent, int depth, int stencil) + { + //Change this method? Don't forget to change method above! + super(context); + init(translucent, depth, stencil); + } + + public void init(boolean translucent, int depth, int stencil) + { + super.init(translucent, depth, stencil); + setRenderer(new Renderer()); + Calendar c = Calendar.getInstance(); + lastTimeStamp = c.getTimeInMillis(); + gameIsInited = true; + } + + private static class Renderer implements GLSurfaceView.Renderer + { + public void onDrawFrame(GL10 gl) + { + if (gameIsInited) + { + Calendar c = Calendar.getInstance(); + + long currentTimeStamp = c.getTimeInMillis(); + + JniWrapper.Update(currentTimeStamp - lastTimeStamp); + + lastTimeStamp = currentTimeStamp; + } + } + + public void onSurfaceChanged(GL10 gl, int width, int height) + { + + + //JniWrapper.Destroy(); + + JniWrapper.Init(width,height); + } + + public void onSurfaceCreated(GL10 gl, EGLConfig config) + { + //Do nothing. + } + } +} \ No newline at end of file diff --git a/Templates/HalibutUniversalTemplate/src/fishrungames/halibutjnitemplate/JniWrapper.java b/Templates/HalibutUniversalTemplate/src/fishrungames/halibutjnitemplate/JniWrapper.java new file mode 100644 index 0000000..e44c8b2 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/src/fishrungames/halibutjnitemplate/JniWrapper.java @@ -0,0 +1,23 @@ +package fishrungames.halibutjnitemplate; + +public class JniWrapper +{ + static { + System.loadLibrary("AndroidJniTemplate"); + } + + + public static native void Init(int width, int height); + public static native void Update(long dt); + public static native void StopSounds(); + public static native void Destroy(); + public static native int IsInited(); + public static native void OnTapDown(float x, float y, long time); + public static native void OnTapUp(float x, float y, long time); + public static native void OnTapMove(float x, float y, long time); + + public static native void OnFling(float velocityX, float velocityY, long time); + public static native void OnScroll(float distanceX, float distanceY, long time); + + public static native void OnKeyPress(int keyCode); +} \ No newline at end of file diff --git a/Templates/HalibutUniversalTemplate/src/fishrungames/halibutjnitemplate/MainActivity.java b/Templates/HalibutUniversalTemplate/src/fishrungames/halibutjnitemplate/MainActivity.java new file mode 100644 index 0000000..c167356 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/src/fishrungames/halibutjnitemplate/MainActivity.java @@ -0,0 +1,191 @@ +package fishrungames.halibutjnitemplate; + +import fishrungames.engine.FileWrapper; + +//Deprecated +//import fishrungames.androidjnitemplate.R; + +import android.app.Activity; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.os.Bundle; + +import android.view.GestureDetector; +import android.view.KeyEvent; +import android.view.GestureDetector.SimpleOnGestureListener; +import android.view.MotionEvent; +/* +import android.content.res.Resources; +import android.content.res.XmlResourceParser; +import android.util.AttributeSet; +import android.util.Xml; +import android.inputmethodservice.Keyboard; +import android.inputmethodservice.KeyboardView; +import android.view.ViewGroup.LayoutParams; +import android.widget.LinearLayout; +*/ + +//Deprecated +//import java.lang.reflect.Field; + + +public class MainActivity extends Activity +{ + + GLView mView; + + boolean IsScrolling = false; + + private GestureDetector gestureDetector; + + @Override + protected void onCreate(Bundle icicle) + { + + super.onCreate(icicle); + + gestureDetector = new GestureDetector(new MyGestureListener()); + + FileWrapper.LoadHalibutEngineLibrary(); + + FileWrapper.SetActivityInstance(this); + FileWrapper.SetupEnviroment(); + + /* + * Deprecated + try + { + for (Field f : R.raw.class.getFields()) + { + FileWrapper.AddToFileMap(f.getName(), f.getInt(null)); + } + + + } catch (IllegalArgumentException e) + { + FileWrapper.ConsoleOut("IllegalArgumentException\n"); + onStop(); + } catch (IllegalAccessException e) + { + FileWrapper.ConsoleOut("IllegalAccessException\n"); + onStop(); + }*/ + + String apkFilePath = null; + ApplicationInfo appInfo = null; + PackageManager packMgmr = this.getPackageManager(); + try { + appInfo = packMgmr.getApplicationInfo("fishrungames.halibutjnitemplate", 0); + } catch (NameNotFoundException e) { + + e.printStackTrace(); + throw new RuntimeException("Unable to locate assets, aborting..."); + } + apkFilePath = appInfo.sourceDir; + + FileWrapper.SetupApkFilePath(apkFilePath); + + mView = new GLView(getApplication()); + + setContentView(mView); + + } + + @Override + protected void onPause() + { + JniWrapper.Destroy(); + super.onPause(); + mView.onPause(); + } + + @Override + protected void onResume() + { + //Don't write anything here! + super.onResume(); + mView.onResume(); + } + + @Override + protected void onStop() + { + //Don't write anything here! + super.onStop(); + } + + public boolean onKeyDown(int keyCode, KeyEvent event) + { + int ascii_keycode = keyCode; + + if (keyCode == KeyEvent.KEYCODE_DEL) + { + ascii_keycode = 8; //Hack - getUnicodeChar does not recognize backspace + } + else + { + ascii_keycode = event.getUnicodeChar(); + } + + JniWrapper.OnKeyPress(ascii_keycode); + return super.onKeyDown(keyCode, event); + } + + public boolean onTouchEvent(MotionEvent event) + { + if (gestureDetector.onTouchEvent(event)) + { + return true; + } + + if (event.getAction() == MotionEvent.ACTION_UP) + { + float x = event.getX(); + float y = (float) mView.getHeight() - event.getY(); + + if (IsScrolling) + { + IsScrolling = false; + } + + JniWrapper.OnTapUp(x, y, event.getEventTime()); + + } + return true; + } + + class MyGestureListener extends SimpleOnGestureListener + { + + @Override + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, + float velocityY) + { + JniWrapper.OnFling(velocityX, velocityY, e2.getEventTime()); + return true; + } + + public boolean onScroll(MotionEvent e1, MotionEvent e2, + float distanceX, float distanceY) + { + + JniWrapper.OnScroll(distanceX, distanceY, e2.getEventTime()); + IsScrolling = true; + return true; + } + + public boolean onDown(MotionEvent event) + { + + float x = event.getX(); + float y = (float) mView.getHeight() - event.getY(); + + JniWrapper.OnTapDown(x, y, event.getEventTime()); + + return true; + } + + } + +} \ No newline at end of file diff --git a/Templates/HalibutUniversalTemplate/windows/HalibutTemplate/Template.sln b/Templates/HalibutUniversalTemplate/windows/HalibutTemplate/Template.sln new file mode 100644 index 0000000..554803f --- /dev/null +++ b/Templates/HalibutUniversalTemplate/windows/HalibutTemplate/Template.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Template", "Template\Template.vcxproj", "{0080A3E1-DFBF-4557-B198-E6D5D7724393}" + ProjectSection(ProjectDependencies) = postProject + {4E274B19-10B2-4987-96C5-76F35A149502} = {4E274B19-10B2-4987-96C5-76F35A149502} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Halibut Engine", "..\..\..\..\Engine\Halibut Engine\Halibut Engine.vcxproj", "{4E274B19-10B2-4987-96C5-76F35A149502}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug_nosound|Win32 = Debug_nosound|Win32 + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug_nosound|Win32.ActiveCfg = Debug|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug_nosound|Win32.Build.0 = Debug|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug|Win32.ActiveCfg = Debug|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug|Win32.Build.0 = Debug|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Release|Win32.ActiveCfg = Release|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Release|Win32.Build.0 = Release|Win32 + {4E274B19-10B2-4987-96C5-76F35A149502}.Debug_nosound|Win32.ActiveCfg = Debug_nosound|Win32 + {4E274B19-10B2-4987-96C5-76F35A149502}.Debug_nosound|Win32.Build.0 = Debug_nosound|Win32 + {4E274B19-10B2-4987-96C5-76F35A149502}.Debug|Win32.ActiveCfg = Debug|Win32 + {4E274B19-10B2-4987-96C5-76F35A149502}.Debug|Win32.Build.0 = Debug|Win32 + {4E274B19-10B2-4987-96C5-76F35A149502}.Release|Win32.ActiveCfg = Release|Win32 + {4E274B19-10B2-4987-96C5-76F35A149502}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Templates/HalibutUniversalTemplate/windows/HalibutTemplate/Template/Template.vcxproj b/Templates/HalibutUniversalTemplate/windows/HalibutTemplate/Template/Template.vcxproj new file mode 100644 index 0000000..db75789 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/windows/HalibutTemplate/Template/Template.vcxproj @@ -0,0 +1,88 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {0080A3E1-DFBF-4557-B198-E6D5D7724393} + Template + + + + Application + true + NotSet + + + Application + false + true + NotSet + + + + + + + + + + + + + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SalmonEnginePath)include + $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(SalmonEnginePath)$(Configuration) + + + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SalmonEnginePath)include + $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(SalmonEnginePath)$(Configuration) + + + + Level3 + Disabled + ../../../jni;$(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;$(LibsPath)\DirectXsdk\Include;$(LibsPath)\lpng1510 + TARGET_WIN32;TARGET_HALIBUT;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501;DEBUG + + + true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;opengl32.lib;glu32.lib;Halibut Engine.lib;libogg_static.lib;libvorbis_static.lib;libvorbisfile_static.lib;zlib.lib;libpng15.lib;sqplusD.lib;squirrelD.lib;sqdbglibD.lib;sqstdlibD.lib;dsound.lib;dxguid.lib;%(AdditionalDependencies) + $(LibsPath)\boost_1_52_0\boost_windows\libs_engine\$(Configuration);$(LibsPath)\libogg-1.3.0\win32\VS2010\Win32\$(Configuration);$(LibsPath)\libvorbis-1.3.2\win32\VS2010\Win32\$(Configuration);$(LibsPath)\sqplus\lib;$(LibsPath)\DirectXsdk\Lib\x86;$(LibsPath)\lpng1510\projects\vstudio\Debug Library + + + + + Level3 + MaxSpeed + true + true + ../../../jni;$(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;$(LibsPath)\DirectXsdk\Include;$(LibsPath)\lpng1510 + TARGET_WIN32;TARGET_HALIBUT;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501;NDEBUG + + + true + true + true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;opengl32.lib;glu32.lib;Halibut Engine.lib;libogg_static.lib;libvorbis_static.lib;libvorbisfile_static.lib;zlib.lib;libpng15.lib;sqplus.lib;squirrel.lib;sqdbglib.lib;sqstdlib.lib;dsound.lib;dxguid.lib;%(AdditionalDependencies) + $(LibsPath)\boost_1_52_0\boost_windows\libs_engine\$(Configuration);$(LibsPath)\libogg-1.3.0\win32\VS2010\Win32\$(Configuration);$(LibsPath)\libvorbis-1.3.2\win32\VS2010\Win32\$(Configuration);$(LibsPath)\sqplus\lib;$(LibsPath)\DirectXsdk\Lib\x86;$(LibsPath)\lpng1510\projects\vstudio\Release Library + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Templates/HalibutUniversalTemplate/windows/HalibutTemplate/Template/main.cpp b/Templates/HalibutUniversalTemplate/windows/HalibutTemplate/Template/main.cpp new file mode 100644 index 0000000..1eb1c2b --- /dev/null +++ b/Templates/HalibutUniversalTemplate/windows/HalibutTemplate/Template/main.cpp @@ -0,0 +1,16 @@ +#include "main.h" + +#include "main_code.h" + +int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst, + LPSTR lpszCmdLine, int nCmdShow) +{ + //Create application + TMyApplication Application; + + Application.Width = 480; + Application.Height = 320; + + //Start application + return MainLoop(Application); +} \ No newline at end of file diff --git a/Templates/HalibutUniversalTemplate/windows/HalibutTemplate/Template/main.h b/Templates/HalibutUniversalTemplate/windows/HalibutTemplate/Template/main.h new file mode 100644 index 0000000..9939a50 --- /dev/null +++ b/Templates/HalibutUniversalTemplate/windows/HalibutTemplate/Template/main.h @@ -0,0 +1,3 @@ +#pragma once + +#include "Engine.h" diff --git a/Templates/SalmonUniversalTemplate/.classpath b/Templates/SalmonUniversalTemplate/.classpath new file mode 100644 index 0000000..36de7ba --- /dev/null +++ b/Templates/SalmonUniversalTemplate/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/Templates/SalmonUniversalTemplate/.project b/Templates/SalmonUniversalTemplate/.project new file mode 100644 index 0000000..4c7a50f --- /dev/null +++ b/Templates/SalmonUniversalTemplate/.project @@ -0,0 +1,33 @@ + + + EngineWrapper + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/Templates/SalmonUniversalTemplate/AndroidManifest.xml b/Templates/SalmonUniversalTemplate/AndroidManifest.xml new file mode 100644 index 0000000..cd9d963 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/AndroidManifest.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + diff --git a/Templates/SalmonUniversalTemplate/assets/bt_box_yellow.bmp b/Templates/SalmonUniversalTemplate/assets/bt_box_yellow.bmp new file mode 100644 index 0000000..b7a2d6f Binary files /dev/null and b/Templates/SalmonUniversalTemplate/assets/bt_box_yellow.bmp differ diff --git a/Templates/SalmonUniversalTemplate/assets/console_bkg.bmp b/Templates/SalmonUniversalTemplate/assets/console_bkg.bmp new file mode 100644 index 0000000..d32ee4c Binary files /dev/null and b/Templates/SalmonUniversalTemplate/assets/console_bkg.bmp differ diff --git a/Templates/SalmonUniversalTemplate/assets/droid_sans14_font_bitmap.bmp32 b/Templates/SalmonUniversalTemplate/assets/droid_sans14_font_bitmap.bmp32 new file mode 100644 index 0000000..b9f2b1f Binary files /dev/null and b/Templates/SalmonUniversalTemplate/assets/droid_sans14_font_bitmap.bmp32 differ diff --git a/Templates/SalmonUniversalTemplate/assets/droid_sans14_font_charmap.txt b/Templates/SalmonUniversalTemplate/assets/droid_sans14_font_charmap.txt new file mode 100644 index 0000000..f17cd0b --- /dev/null +++ b/Templates/SalmonUniversalTemplate/assets/droid_sans14_font_charmap.txt @@ -0,0 +1,95 @@ +32 0.00976562 0.0195312 0 0.0546875 0 0 0.0078125 +49 0.0195312 0.0195312 0.00390625 0.015625 0.0078125 0.0390625 0.015625 +50 0.0371094 0.0195312 0.00195312 0.015625 0.0136719 0.0390625 0.015625 +51 0.0605469 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625 +52 0.0820312 0.0195312 0.00195312 0.015625 0.0136719 0.0390625 0.015625 +53 0.105469 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625 +54 0.126953 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625 +55 0.148438 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625 +56 0.169922 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625 +57 0.191406 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625 +48 0.212891 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.015625 +97 0.234375 0.0195312 0.00195312 0.0234375 0.00976562 0.03125 0.0136719 +98 0.253906 0.0195312 0.00195312 0.0117188 0.0117188 0.0429688 0.015625 +99 0.275391 0.0195312 0.00195312 0.0234375 0.00976562 0.03125 0.0136719 +100 0.294922 0.0195312 0.00195312 0.0117188 0.0117188 0.0429688 0.015625 +101 0.316406 0.0195312 0.00195312 0.0234375 0.0117188 0.03125 0.015625 +102 0.337891 0.0195312 0 0.0117188 0.00976562 0.0429688 0.0078125 +103 0.357422 0.0195312 0.00195312 0.0234375 0.0136719 0.0429688 0.0136719 +104 0.380859 0.0195312 0.00195312 0.0117188 0.0117188 0.0429688 0.015625 +105 0.402344 0.0195312 0 0.0117188 0.00585938 0.0429688 0.0078125 +106 0.417969 0.0195312 -0.00195312 0.0117188 0.0078125 0.0546875 0.0078125 +107 0.435547 0.0195312 0.00195312 0.0117188 0.0136719 0.0429688 0.0136719 +108 0.458984 0.0195312 0.00195312 0.0117188 0.00390625 0.0429688 0.0078125 +109 0.472656 0.0195312 0.00195312 0.0234375 0.0214844 0.03125 0.0253906 +110 0.503906 0.0195312 0.00195312 0.0234375 0.0117188 0.03125 0.015625 +111 0.525391 0.0195312 0.00195312 0.0234375 0.0117188 0.03125 0.015625 +112 0.546875 0.0195312 0.00195312 0.0234375 0.0117188 0.0429688 0.015625 +113 0.568359 0.0195312 0.00195312 0.0234375 0.0117188 0.0429688 0.015625 +114 0.589844 0.0195312 0.00195312 0.0234375 0.0078125 0.03125 0.00976562 +115 0.607422 0.0195312 0 0.0234375 0.0117188 0.03125 0.0136719 +116 0.628906 0.0195312 0 0.015625 0.00976562 0.0390625 0.00976562 +117 0.648438 0.0195312 0.00195312 0.0234375 0.0117188 0.03125 0.015625 +118 0.669922 0.0195312 -0.00195312 0.0234375 0.0175781 0.03125 0.0136719 +119 0.697266 0.0195312 -0.00195312 0.0234375 0.0234375 0.03125 0.0195312 +120 0.730469 0.0195312 0 0.0234375 0.0136719 0.03125 0.0136719 +121 0.753906 0.0195312 -0.00195312 0.0234375 0.0175781 0.0429688 0.0136719 +122 0.78125 0.0195312 0.00195312 0.0234375 0.0117188 0.03125 0.0136719 +65 0.802734 0.0195312 -0.00195312 0.015625 0.0214844 0.0390625 0.0175781 +66 0.833984 0.0195312 0.00195312 0.015625 0.0136719 0.0390625 0.0175781 +67 0.857422 0.0195312 0.00195312 0.015625 0.0136719 0.0390625 0.015625 +68 0.880859 0.0195312 0.00195312 0.015625 0.015625 0.0390625 0.0195312 +69 0.90625 0.0195312 0.00195312 0.015625 0.00976562 0.0390625 0.0136719 +70 0.925781 0.0195312 0.00195312 0.015625 0.0117188 0.0390625 0.0136719 +71 0.947266 0.0195312 0.00195312 0.015625 0.015625 0.0390625 0.0195312 +72 0.00976562 0.09375 0.00195312 0.015625 0.015625 0.0390625 0.0195312 +73 0.0351562 0.09375 0 0.015625 0.00976562 0.0390625 0.00976562 +74 0.0546875 0.09375 -0.00390625 0.015625 0.00976562 0.0507812 0.00585938 +75 0.0742188 0.09375 0.00195312 0.015625 0.015625 0.0390625 0.015625 +76 0.0996094 0.09375 0.00195312 0.015625 0.0117188 0.0390625 0.0136719 +77 0.121094 0.09375 0.00195312 0.015625 0.0195312 0.0390625 0.0234375 +78 0.150391 0.09375 0.00195312 0.015625 0.015625 0.0390625 0.0195312 +79 0.175781 0.09375 0.00195312 0.015625 0.0175781 0.0390625 0.0214844 +80 0.203125 0.09375 0.00195312 0.015625 0.0117188 0.0390625 0.015625 +81 0.224609 0.09375 0.00195312 0.015625 0.0175781 0.046875 0.0214844 +82 0.251953 0.09375 0.00195312 0.015625 0.0136719 0.0390625 0.015625 +83 0.275391 0.09375 0 0.015625 0.0136719 0.0390625 0.0136719 +84 0.298828 0.09375 0 0.015625 0.0136719 0.0390625 0.0136719 +85 0.322266 0.09375 0.00195312 0.015625 0.015625 0.0390625 0.0195312 +86 0.347656 0.09375 -0.00195312 0.015625 0.0195312 0.0390625 0.015625 +87 0.376953 0.09375 -0.00195312 0.015625 0.0292969 0.0390625 0.0253906 +88 0.416016 0.09375 -0.00195312 0.015625 0.0195312 0.0390625 0.015625 +89 0.445312 0.09375 -0.00195312 0.015625 0.0175781 0.0390625 0.0136719 +90 0.472656 0.09375 0.00195312 0.015625 0.0117188 0.0390625 0.015625 +46 0.494141 0.09375 0.00195312 0.046875 0.00390625 0.0078125 0.0078125 +44 0.507812 0.09375 0.00195312 0.046875 0.00390625 0.0117188 0.0078125 +58 0.521484 0.09375 0.00195312 0.0234375 0.00390625 0.03125 0.0078125 +59 0.535156 0.09375 0.00195312 0.0234375 0.00390625 0.0351562 0.0078125 +64 0.548828 0.09375 0.00195312 0.015625 0.0195312 0.0429688 0.0234375 +35 0.578125 0.09375 0 0.015625 0.015625 0.0390625 0.0175781 +36 0.603516 0.09375 0.00195312 0.0117188 0.0117188 0.046875 0.015625 +37 0.625 0.09375 0.00195312 0.015625 0.0195312 0.0390625 0.0234375 +94 0.654297 0.09375 0 0.015625 0.0136719 0.0234375 0.0136719 +38 0.677734 0.09375 0.00195312 0.015625 0.0175781 0.0390625 0.0195312 +42 0.705078 0.09375 0 0.0117188 0.0136719 0.0234375 0.015625 +33 0.728516 0.09375 0.00195312 0.015625 0.00390625 0.0390625 0.0078125 +63 0.742188 0.09375 0 0.015625 0.00976562 0.0390625 0.0117188 +40 0.761719 0.09375 0.00195312 0.015625 0.0078125 0.046875 0.0078125 +41 0.779297 0.09375 0 0.015625 0.00585938 0.046875 0.0078125 +91 0.794922 0.09375 0.00195312 0.015625 0.00585938 0.046875 0.0078125 +93 0.810547 0.09375 0 0.015625 0.00585938 0.046875 0.0078125 +123 0.826172 0.09375 0 0.015625 0.00976562 0.046875 0.00976562 +125 0.845703 0.09375 0 0.015625 0.00976562 0.046875 0.00976562 +60 0.865234 0.09375 0.00195312 0.0234375 0.0117188 0.0273438 0.015625 +62 0.886719 0.09375 0.00195312 0.0234375 0.0117188 0.0273438 0.015625 +95 0.908203 0.09375 0 0.0585938 0.0117188 0.00390625 0.0117188 +45 0.929688 0.09375 0.00195312 0.0390625 0.00585938 0.0078125 0.00976562 +43 0.945312 0.09375 0 0.0234375 0.0136719 0.0273438 0.015625 +61 0.00976562 0.167969 0 0.0273438 0.0136719 0.0195312 0.015625 +124 0.0332031 0.167969 0.00585938 0.0117188 0.00390625 0.0546875 0.0136719 +92 0.046875 0.167969 -0.00195312 0.015625 0.0136719 0.0390625 0.00976562 +47 0.0703125 0.167969 -0.00195312 0.015625 0.0136719 0.0390625 0.00976562 +126 0.09375 0.167969 0.00195312 0.03125 0.0117188 0.0117188 0.015625 +96 0.115234 0.167969 0.00585938 0.0117188 0.00585938 0.0078125 0.015625 +34 0.130859 0.167969 0.00195312 0.015625 0.00976562 0.015625 0.0117188 +39 0.150391 0.167969 0.00195312 0.015625 0.00390625 0.015625 0.00585938 \ No newline at end of file diff --git a/Templates/SalmonUniversalTemplate/assets/gui_transparent.fragment b/Templates/SalmonUniversalTemplate/assets/gui_transparent.fragment new file mode 100644 index 0000000..fb7c2a6 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/assets/gui_transparent.fragment @@ -0,0 +1,10 @@ +precision highp float; + +uniform sampler2D Texture; +varying vec2 texCoord; + +void main() +{ + vec4 texColor = texture2D(Texture,texCoord).rgba; + gl_FragColor = vec4(texColor.rgb, texColor.a); +} diff --git a/Templates/SalmonUniversalTemplate/assets/gui_transparent.vertex b/Templates/SalmonUniversalTemplate/assets/gui_transparent.vertex new file mode 100644 index 0000000..ad425c2 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/assets/gui_transparent.vertex @@ -0,0 +1,11 @@ +attribute vec3 vPosition; +attribute vec2 vTexCoord; +varying vec2 texCoord; +uniform mat4 ProjectionMatrix; + +void main() +{ + //480x320 + gl_Position = ProjectionMatrix * vec4(vPosition.xyz, 1.0); + texCoord = vTexCoord; +} \ No newline at end of file diff --git a/Templates/SalmonUniversalTemplate/assets/level1ogg.ogg b/Templates/SalmonUniversalTemplate/assets/level1ogg.ogg new file mode 100644 index 0000000..ce86d31 Binary files /dev/null and b/Templates/SalmonUniversalTemplate/assets/level1ogg.ogg differ diff --git a/Templates/SalmonUniversalTemplate/assets/model.xml b/Templates/SalmonUniversalTemplate/assets/model.xml new file mode 100644 index 0000000..a406ac9 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/assets/model.xml @@ -0,0 +1,1725 @@ + + + + + + +1.15, 0.0, 0.15 +1.15, 0.0, 6.05 +-1.15, 0.0, 6.05 +-1.15, 0.0, 6.05 +-1.15, 0.0, 0.15 +1.15, 0.0, 0.15 +1.15, 2.2, 0.15 +-1.15, 2.2, 0.15 +-1.15, 2.2, 6.05 +-1.15, 2.2, 6.05 +1.15, 2.2, 6.05 +1.15, 2.2, 0.15 +1.15, 2.2, 0.15 +1.15, 2.2, 6.05 +1.15, 0.0, 6.05 +1.15, 0.0, 6.05 +1.15, 0.0, 0.15 +1.15, 2.2, 0.15 +-1.15, 2.2, 0.15 +1.15, 2.2, 0.15 +1.15, 0.0, 0.15 +1.15, 0.0, 0.15 +-1.15, 0.0, 0.15 +-1.15, 2.2, 0.15 +-1.15, 2.2, 6.05 +-1.15, 2.2, 0.15 +-1.15, 0.0, 0.15 +-1.15, 0.0, 0.15 +-1.15, 0.0, 6.05 +-1.15, 2.2, 6.05 +-1.15, 0.0, 6.05 +1.15, 0.0, 6.05 +1.05, 0.0900212, 6.05 +1.05, 0.0900212, 6.05 +-1.05, 0.0900212, 6.05 +-1.15, 0.0, 6.05 +1.15, 0.0, 6.05 +1.15, 2.2, 6.05 +1.05, 2.09437, 6.05 +1.05, 2.09437, 6.05 +1.05, 0.0900212, 6.05 +1.15, 0.0, 6.05 +1.15, 2.2, 6.05 +-1.15, 2.2, 6.05 +-1.05, 2.09437, 6.05 +-1.05, 2.09437, 6.05 +1.05, 2.09437, 6.05 +1.15, 2.2, 6.05 +-1.15, 2.2, 6.05 +-1.15, 0.0, 6.05 +-1.05, 0.0900212, 6.05 +-1.05, 0.0900212, 6.05 +-1.05, 2.09437, 6.05 +-1.15, 2.2, 6.05 +0.61422, 0.0, 6.07288 +0.611504, 0.0, 6.06452 +0.611504, 2.18832, 6.06452 +0.611504, 2.18832, 6.06452 +0.61422, 2.18832, 6.07288 +0.61422, 0.0, 6.07288 +0.588496, 0.0, 6.06452 +0.58578, 0.0, 6.07288 +0.58578, 2.18832, 6.07288 +0.58578, 2.18832, 6.07288 +0.588496, 2.18832, 6.06452 +0.588496, 0.0, 6.06452 +0.58578, 0.0, 6.07288 +0.588496, 0.0, 6.08123 +0.588496, 2.18832, 6.08123 +0.588496, 2.18832, 6.08123 +0.58578, 2.18832, 6.07288 +0.58578, 0.0, 6.07288 +0.588496, 0.0, 6.08123 +0.595606, 0.0, 6.0864 +0.595606, 2.18832, 6.0864 +0.595606, 2.18832, 6.0864 +0.588496, 2.18832, 6.08123 +0.588496, 0.0, 6.08123 +0.595606, 0.0, 6.0864 +0.604394, 0.0, 6.0864 +0.604394, 2.18832, 6.0864 +0.604394, 2.18832, 6.0864 +0.595606, 2.18832, 6.0864 +0.595606, 0.0, 6.0864 +0.604394, 0.0, 6.0864 +0.611504, 0.0, 6.08123 +0.611504, 2.18832, 6.08123 +0.611504, 2.18832, 6.08123 +0.604394, 2.18832, 6.0864 +0.604394, 0.0, 6.0864 +0.604394, 0.0, 6.0864 +0.595606, 0.0, 6.0864 +0.588496, 0.0, 6.08123 +0.588496, 0.0, 6.08123 +0.58578, 0.0, 6.07288 +0.588496, 0.0, 6.06452 +0.588496, 0.0, 6.06452 +0.595606, 0.0, 6.05935 +0.604394, 0.0, 6.05935 +0.604394, 0.0, 6.05935 +0.611504, 0.0, 6.06452 +0.61422, 0.0, 6.07288 +0.588496, 0.0, 6.06452 +0.604394, 0.0, 6.05935 +0.61422, 0.0, 6.07288 +0.588496, 0.0, 6.08123 +0.588496, 0.0, 6.06452 +0.61422, 0.0, 6.07288 +0.604394, 0.0, 6.0864 +0.588496, 0.0, 6.08123 +0.61422, 0.0, 6.07288 +0.611504, 0.0, 6.08123 +0.604394, 0.0, 6.0864 +0.61422, 0.0, 6.07288 +0.611504, 2.18832, 6.06452 +0.604394, 2.18832, 6.05935 +0.595606, 2.18832, 6.05935 +0.595606, 2.18832, 6.05935 +0.588496, 2.18832, 6.06452 +0.58578, 2.18832, 6.07288 +0.58578, 2.18832, 6.07288 +0.588496, 2.18832, 6.08123 +0.595606, 2.18832, 6.0864 +0.595606, 2.18832, 6.0864 +0.604394, 2.18832, 6.0864 +0.611504, 2.18832, 6.08123 +0.58578, 2.18832, 6.07288 +0.595606, 2.18832, 6.0864 +0.611504, 2.18832, 6.08123 +0.595606, 2.18832, 6.05935 +0.58578, 2.18832, 6.07288 +0.611504, 2.18832, 6.08123 +0.611504, 2.18832, 6.06452 +0.595606, 2.18832, 6.05935 +0.611504, 2.18832, 6.08123 +0.61422, 2.18832, 6.07288 +0.611504, 2.18832, 6.06452 +0.611504, 2.18832, 6.08123 +0.215692, 0.0, 6.07288 +0.212695, 0.0, 6.06365 +0.212695, 2.18832, 6.06365 +0.212695, 2.18832, 6.06365 +0.215692, 2.18832, 6.07288 +0.215692, 0.0, 6.07288 +0.187305, 0.0, 6.06365 +0.184308, 0.0, 6.07288 +0.184308, 2.18832, 6.07288 +0.184308, 2.18832, 6.07288 +0.187305, 2.18832, 6.06365 +0.187305, 0.0, 6.06365 +0.184308, 0.0, 6.07288 +0.187305, 0.0, 6.0821 +0.187305, 2.18832, 6.0821 +0.187305, 2.18832, 6.0821 +0.184308, 2.18832, 6.07288 +0.184308, 0.0, 6.07288 +0.187305, 0.0, 6.0821 +0.195151, 0.0, 6.0878 +0.195151, 2.18832, 6.0878 +0.195151, 2.18832, 6.0878 +0.187305, 2.18832, 6.0821 +0.187305, 0.0, 6.0821 +0.195151, 0.0, 6.0878 +0.204849, 0.0, 6.0878 +0.204849, 2.18832, 6.0878 +0.204849, 2.18832, 6.0878 +0.195151, 2.18832, 6.0878 +0.195151, 0.0, 6.0878 +0.204849, 0.0, 6.0878 +0.212695, 0.0, 6.0821 +0.212695, 2.18832, 6.0821 +0.212695, 2.18832, 6.0821 +0.204849, 2.18832, 6.0878 +0.204849, 0.0, 6.0878 +0.204849, 0.0, 6.0878 +0.195151, 0.0, 6.0878 +0.187305, 0.0, 6.0821 +0.187305, 0.0, 6.0821 +0.184308, 0.0, 6.07288 +0.187305, 0.0, 6.06365 +0.187305, 0.0, 6.06365 +0.195151, 0.0, 6.05795 +0.204849, 0.0, 6.05795 +0.204849, 0.0, 6.05795 +0.212695, 0.0, 6.06365 +0.215692, 0.0, 6.07288 +0.187305, 0.0, 6.06365 +0.204849, 0.0, 6.05795 +0.215692, 0.0, 6.07288 +0.187305, 0.0, 6.0821 +0.187305, 0.0, 6.06365 +0.215692, 0.0, 6.07288 +0.204849, 0.0, 6.0878 +0.187305, 0.0, 6.0821 +0.215692, 0.0, 6.07288 +0.212695, 0.0, 6.0821 +0.204849, 0.0, 6.0878 +0.215692, 0.0, 6.07288 +0.212695, 2.18832, 6.06365 +0.204849, 2.18832, 6.05795 +0.195151, 2.18832, 6.05795 +0.195151, 2.18832, 6.05795 +0.187305, 2.18832, 6.06365 +0.184308, 2.18832, 6.07288 +0.184308, 2.18832, 6.07288 +0.187305, 2.18832, 6.0821 +0.195151, 2.18832, 6.0878 +0.195151, 2.18832, 6.0878 +0.204849, 2.18832, 6.0878 +0.212695, 2.18832, 6.0821 +0.184308, 2.18832, 6.07288 +0.195151, 2.18832, 6.0878 +0.212695, 2.18832, 6.0821 +0.195151, 2.18832, 6.05795 +0.184308, 2.18832, 6.07288 +0.212695, 2.18832, 6.0821 +0.212695, 2.18832, 6.06365 +0.195151, 2.18832, 6.05795 +0.212695, 2.18832, 6.0821 +0.215692, 2.18832, 6.07288 +0.212695, 2.18832, 6.06365 +0.212695, 2.18832, 6.0821 +-0.184136, 0.0, 6.07288 +-0.187166, 0.0, 6.06355 +-0.187166, 2.18832, 6.06355 +-0.187166, 2.18832, 6.06355 +-0.184136, 2.18832, 6.07288 +-0.184136, 0.0, 6.07288 +-0.215864, 0.0, 6.07288 +-0.212834, 0.0, 6.0822 +-0.212834, 2.18832, 6.0822 +-0.212834, 2.18832, 6.0822 +-0.215864, 2.18832, 6.07288 +-0.215864, 0.0, 6.07288 +-0.212834, 0.0, 6.0822 +-0.204902, 0.0, 6.08796 +-0.204902, 2.18832, 6.08796 +-0.204902, 2.18832, 6.08796 +-0.212834, 2.18832, 6.0822 +-0.212834, 0.0, 6.0822 +-0.204902, 0.0, 6.08796 +-0.195098, 0.0, 6.08796 +-0.195098, 2.18832, 6.08796 +-0.195098, 2.18832, 6.08796 +-0.204902, 2.18832, 6.08796 +-0.204902, 0.0, 6.08796 +-0.195098, 0.0, 6.08796 +-0.187166, 0.0, 6.0822 +-0.187166, 2.18832, 6.0822 +-0.187166, 2.18832, 6.0822 +-0.195098, 2.18832, 6.08796 +-0.195098, 0.0, 6.08796 +-0.187166, 0.0, 6.0822 +-0.184136, 0.0, 6.07288 +-0.184136, 2.18832, 6.07288 +-0.184136, 2.18832, 6.07288 +-0.187166, 2.18832, 6.0822 +-0.187166, 0.0, 6.0822 +-0.195098, 0.0, 6.08796 +-0.204902, 0.0, 6.08796 +-0.212834, 0.0, 6.0822 +-0.212834, 0.0, 6.0822 +-0.215864, 0.0, 6.07288 +-0.212834, 0.0, 6.06355 +-0.212834, 0.0, 6.06355 +-0.204902, 0.0, 6.05779 +-0.195098, 0.0, 6.05779 +-0.195098, 0.0, 6.05779 +-0.187166, 0.0, 6.06355 +-0.184136, 0.0, 6.07288 +-0.212834, 0.0, 6.06355 +-0.195098, 0.0, 6.05779 +-0.184136, 0.0, 6.07288 +-0.212834, 0.0, 6.0822 +-0.212834, 0.0, 6.06355 +-0.184136, 0.0, 6.07288 +-0.195098, 0.0, 6.08796 +-0.212834, 0.0, 6.0822 +-0.184136, 0.0, 6.07288 +-0.187166, 0.0, 6.0822 +-0.195098, 0.0, 6.08796 +-0.184136, 0.0, 6.07288 +-0.187166, 2.18832, 6.06355 +-0.195098, 2.18832, 6.05779 +-0.204902, 2.18832, 6.05779 +-0.204902, 2.18832, 6.05779 +-0.212834, 2.18832, 6.06355 +-0.215864, 2.18832, 6.07288 +-0.215864, 2.18832, 6.07288 +-0.212834, 2.18832, 6.0822 +-0.204902, 2.18832, 6.08796 +-0.204902, 2.18832, 6.08796 +-0.195098, 2.18832, 6.08796 +-0.187166, 2.18832, 6.0822 +-0.215864, 2.18832, 6.07288 +-0.204902, 2.18832, 6.08796 +-0.187166, 2.18832, 6.0822 +-0.204902, 2.18832, 6.05779 +-0.215864, 2.18832, 6.07288 +-0.187166, 2.18832, 6.0822 +-0.187166, 2.18832, 6.06355 +-0.204902, 2.18832, 6.05779 +-0.187166, 2.18832, 6.0822 +-0.184136, 2.18832, 6.07288 +-0.187166, 2.18832, 6.06355 +-0.187166, 2.18832, 6.0822 +-0.585371, 0.0, 6.07288 +-0.588165, 0.0, 6.06428 +-0.588165, 2.18832, 6.06428 +-0.588165, 2.18832, 6.06428 +-0.585371, 2.18832, 6.07288 +-0.585371, 0.0, 6.07288 +-0.614629, 0.0, 6.07288 +-0.611835, 0.0, 6.08148 +-0.611835, 2.18832, 6.08148 +-0.611835, 2.18832, 6.08148 +-0.614629, 2.18832, 6.07288 +-0.614629, 0.0, 6.07288 +-0.611835, 0.0, 6.08148 +-0.604521, 0.0, 6.08679 +-0.604521, 2.18832, 6.08679 +-0.604521, 2.18832, 6.08679 +-0.611835, 2.18832, 6.08148 +-0.611835, 0.0, 6.08148 +-0.604521, 0.0, 6.08679 +-0.595479, 0.0, 6.08679 +-0.595479, 2.18832, 6.08679 +-0.595479, 2.18832, 6.08679 +-0.604521, 2.18832, 6.08679 +-0.604521, 0.0, 6.08679 +-0.595479, 0.0, 6.08679 +-0.588165, 0.0, 6.08148 +-0.588165, 2.18832, 6.08148 +-0.588165, 2.18832, 6.08148 +-0.595479, 2.18832, 6.08679 +-0.595479, 0.0, 6.08679 +-0.588165, 0.0, 6.08148 +-0.585371, 0.0, 6.07288 +-0.585371, 2.18832, 6.07288 +-0.585371, 2.18832, 6.07288 +-0.588165, 2.18832, 6.08148 +-0.588165, 0.0, 6.08148 +-0.595479, 0.0, 6.08679 +-0.604521, 0.0, 6.08679 +-0.611835, 0.0, 6.08148 +-0.611835, 0.0, 6.08148 +-0.614629, 0.0, 6.07288 +-0.611835, 0.0, 6.06428 +-0.611835, 0.0, 6.06428 +-0.604521, 0.0, 6.05896 +-0.595479, 0.0, 6.05896 +-0.595479, 0.0, 6.05896 +-0.588165, 0.0, 6.06428 +-0.585371, 0.0, 6.07288 +-0.611835, 0.0, 6.06428 +-0.595479, 0.0, 6.05896 +-0.585371, 0.0, 6.07288 +-0.611835, 0.0, 6.08148 +-0.611835, 0.0, 6.06428 +-0.585371, 0.0, 6.07288 +-0.595479, 0.0, 6.08679 +-0.611835, 0.0, 6.08148 +-0.585371, 0.0, 6.07288 +-0.588165, 0.0, 6.08148 +-0.595479, 0.0, 6.08679 +-0.585371, 0.0, 6.07288 +-0.588165, 2.18832, 6.06428 +-0.595479, 2.18832, 6.05896 +-0.604521, 2.18832, 6.05896 +-0.604521, 2.18832, 6.05896 +-0.611835, 2.18832, 6.06428 +-0.614629, 2.18832, 6.07288 +-0.614629, 2.18832, 6.07288 +-0.611835, 2.18832, 6.08148 +-0.604521, 2.18832, 6.08679 +-0.604521, 2.18832, 6.08679 +-0.595479, 2.18832, 6.08679 +-0.588165, 2.18832, 6.08148 +-0.614629, 2.18832, 6.07288 +-0.604521, 2.18832, 6.08679 +-0.588165, 2.18832, 6.08148 +-0.604521, 2.18832, 6.05896 +-0.614629, 2.18832, 6.07288 +-0.588165, 2.18832, 6.08148 +-0.588165, 2.18832, 6.06428 +-0.604521, 2.18832, 6.05896 +-0.588165, 2.18832, 6.08148 +-0.585371, 2.18832, 6.07288 +-0.588165, 2.18832, 6.06428 +-0.588165, 2.18832, 6.08148 +1.03278, 0.0984738, 6.052 +1.03278, 2.08558, 6.052 +0.00136847, 2.08558, 6.052 +0.00136847, 2.08558, 6.052 +0.00136847, 0.0984738, 6.052 +1.03278, 0.0984738, 6.052 +-0.0122491, 2.08558, 6.052 +-1.04367, 2.08558, 6.052 +-1.04367, 0.0984738, 6.052 +-1.04367, 0.0984738, 6.052 +-0.0122491, 0.0984738, 6.052 +-0.0122491, 2.08558, 6.052 +0.61422, 0.0, 6.07288 +0.61422, 2.18832, 6.07288 +0.61422, 0.569992, 6.07288 +0.61422, 0.569992, 6.07288 +0.61422, 0.543543, 6.07288 +0.61422, 0.0, 6.07288 +0.61422, 2.18832, 6.07288 +0.611504, 2.18832, 6.08123 +0.611504, 0.569992, 6.08123 +0.611504, 0.569992, 6.08123 +0.61422, 0.569992, 6.07288 +0.61422, 2.18832, 6.07288 +0.611504, 2.18832, 6.08123 +0.611504, 0.0, 6.08123 +0.611504, 0.543543, 6.08123 +0.611504, 0.543543, 6.08123 +0.611504, 0.569992, 6.08123 +0.611504, 2.18832, 6.08123 +0.611504, 0.0, 6.08123 +0.61422, 0.0, 6.07288 +0.61422, 0.543543, 6.07288 +0.61422, 0.543543, 6.07288 +0.611504, 0.543543, 6.08123 +0.611504, 0.0, 6.08123 +0.61422, 0.543543, 6.07288 +0.61422, 0.569992, 6.07288 +0.892061, 0.569992, 6.05618 +0.892061, 0.569992, 6.05618 +0.892061, 0.543543, 6.05618 +0.61422, 0.543543, 6.07288 +0.61422, 0.569992, 6.07288 +0.611504, 0.569992, 6.08123 +0.892061, 0.569992, 6.05618 +0.611504, 0.569992, 6.08123 +0.611504, 0.543543, 6.08123 +0.892061, 0.543543, 6.05618 +0.892061, 0.543543, 6.05618 +0.892061, 0.569992, 6.05618 +0.611504, 0.569992, 6.08123 +0.611504, 0.543543, 6.08123 +0.61422, 0.543543, 6.07288 +0.892061, 0.543543, 6.05618 +0.215692, 0.0, 6.07288 +0.215692, 2.18832, 6.07288 +0.215692, 0.576822, 6.07288 +0.215692, 0.576822, 6.07288 +0.215692, 0.546241, 6.07288 +0.215692, 0.0, 6.07288 +0.215692, 2.18832, 6.07288 +0.212695, 2.18832, 6.0821 +0.212695, 0.576822, 6.0821 +0.212695, 0.576822, 6.0821 +0.215692, 0.576822, 6.07288 +0.215692, 2.18832, 6.07288 +0.212695, 2.18832, 6.0821 +0.212695, 0.0, 6.0821 +0.212695, 0.546241, 6.0821 +0.212695, 0.546241, 6.0821 +0.212695, 0.576822, 6.0821 +0.212695, 2.18832, 6.0821 +0.212695, 0.0, 6.0821 +0.215692, 0.0, 6.07288 +0.215692, 0.546241, 6.07288 +0.215692, 0.546241, 6.07288 +0.212695, 0.546241, 6.0821 +0.212695, 0.0, 6.0821 +0.215692, 0.546241, 6.07288 +0.215692, 0.576822, 6.07288 +0.480489, 0.576822, 6.06799 +0.480489, 0.576822, 6.06799 +0.480489, 0.546241, 6.06799 +0.215692, 0.546241, 6.07288 +0.215692, 0.576822, 6.07288 +0.212695, 0.576822, 6.0821 +0.480489, 0.576822, 6.06799 +0.212695, 0.576822, 6.0821 +0.212695, 0.546241, 6.0821 +0.480489, 0.546241, 6.06799 +0.480489, 0.546241, 6.06799 +0.480489, 0.576822, 6.06799 +0.212695, 0.576822, 6.0821 +0.212695, 0.546241, 6.0821 +0.215692, 0.546241, 6.07288 +0.480489, 0.546241, 6.06799 +-0.212834, 2.18832, 6.06355 +-0.212834, 0.0, 6.06355 +-0.212834, 0.537944, 6.06355 +-0.212834, 0.537944, 6.06355 +-0.212834, 0.572329, 6.06355 +-0.212834, 2.18832, 6.06355 +-0.212834, 0.0, 6.06355 +-0.215864, 0.0, 6.07288 +-0.215864, 0.537944, 6.07288 +-0.215864, 0.537944, 6.07288 +-0.212834, 0.537944, 6.06355 +-0.212834, 0.0, 6.06355 +-0.215864, 0.0, 6.07288 +-0.215864, 2.18832, 6.07288 +-0.215864, 0.572329, 6.07288 +-0.215864, 0.572329, 6.07288 +-0.215864, 0.537944, 6.07288 +-0.215864, 0.0, 6.07288 +-0.215864, 2.18832, 6.07288 +-0.212834, 2.18832, 6.06355 +-0.212834, 0.572329, 6.06355 +-0.212834, 0.572329, 6.06355 +-0.215864, 0.572329, 6.07288 +-0.215864, 2.18832, 6.07288 +-0.212834, 0.572329, 6.06355 +-0.212834, 0.537944, 6.06355 +-0.480645, 0.537944, 6.05698 +-0.480645, 0.537944, 6.05698 +-0.480645, 0.572329, 6.05698 +-0.212834, 0.572329, 6.06355 +-0.212834, 0.537944, 6.06355 +-0.215864, 0.537944, 6.07288 +-0.480645, 0.537944, 6.05698 +-0.215864, 0.537944, 6.07288 +-0.215864, 0.572329, 6.07288 +-0.480645, 0.572329, 6.05698 +-0.480645, 0.572329, 6.05698 +-0.480645, 0.537944, 6.05698 +-0.215864, 0.537944, 6.07288 +-0.215864, 0.572329, 6.07288 +-0.212834, 0.572329, 6.06355 +-0.480645, 0.572329, 6.05698 +-0.611835, 2.18832, 6.06428 +-0.611835, 0.0, 6.06428 +-0.611835, 0.532442, 6.06428 +-0.611835, 0.532442, 6.06428 +-0.611835, 0.577831, 6.06428 +-0.611835, 2.18832, 6.06428 +-0.611835, 0.0, 6.06428 +-0.614629, 0.0, 6.07288 +-0.614629, 0.532442, 6.07288 +-0.614629, 0.532442, 6.07288 +-0.611835, 0.532442, 6.06428 +-0.611835, 0.0, 6.06428 +-0.614629, 0.0, 6.07288 +-0.614629, 2.18832, 6.07288 +-0.614629, 0.577831, 6.07288 +-0.614629, 0.577831, 6.07288 +-0.614629, 0.532442, 6.07288 +-0.614629, 0.0, 6.07288 +-0.614629, 2.18832, 6.07288 +-0.611835, 2.18832, 6.06428 +-0.611835, 0.577831, 6.06428 +-0.611835, 0.577831, 6.06428 +-0.614629, 0.577831, 6.07288 +-0.614629, 2.18832, 6.07288 +-0.611835, 0.577831, 6.06428 +-0.611835, 0.532442, 6.06428 +-0.879528, 0.532442, 6.05519 +-0.879528, 0.532442, 6.05519 +-0.879528, 0.577831, 6.05519 +-0.611835, 0.577831, 6.06428 +-0.611835, 0.532442, 6.06428 +-0.614629, 0.532442, 6.07288 +-0.879528, 0.532442, 6.05519 +-0.614629, 0.532442, 6.07288 +-0.614629, 0.577831, 6.07288 +-0.879528, 0.577831, 6.05519 +-0.879528, 0.577831, 6.05519 +-0.879528, 0.532442, 6.05519 +-0.614629, 0.532442, 6.07288 +-0.614629, 0.577831, 6.07288 +-0.611835, 0.577831, 6.06428 +-0.879528, 0.577831, 6.05519 + + +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +1.0, 0.0, 0.0 +1.0, 0.0, 0.0 +1.0, 0.0, 0.0 +1.0, 0.0, 0.0 +1.0, 0.0, 0.0 +1.0, 0.0, 0.0 +0.0, 0.0, -1.0 +0.0, 0.0, -1.0 +0.0, 0.0, -1.0 +0.0, 0.0, -1.0 +0.0, 0.0, -1.0 +0.0, 0.0, -1.0 +-1.0, 0.0, 0.0 +-1.0, 0.0, 0.0 +-1.0, 0.0, 0.0 +-1.0, 0.0, 0.0 +-1.0, 0.0, 0.0 +-1.0, 0.0, 0.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.951054, 0.0, -0.309026 +0.951054, 0.0, -0.309026 +0.951054, 0.0, -0.309026 +0.951054, 0.0, -0.309026 +0.951054, 0.0, -0.309026 +0.951054, 0.0, -0.309026 +-0.951056, 0.0, -0.30902 +-0.994186, 0.0, 0.107678 +-0.994186, 0.0, -0.107678 +-0.994186, 0.0, -0.107678 +-0.951056, 0.0, -0.30902 +-0.951056, 0.0, -0.30902 +-0.994186, 0.0, 0.107678 +-0.741036, 0.0, 0.671465 +-0.867608, 0.0, 0.497249 +-0.867608, 0.0, 0.497249 +-0.994186, 0.0, -0.107678 +-0.994186, 0.0, 0.107678 +-0.741036, 0.0, 0.671465 +-0.204823, 0.0, 0.978799 +-0.409646, 0.0, 0.912244 +-0.409646, 0.0, 0.912244 +-0.867608, 0.0, 0.497249 +-0.741036, 0.0, 0.671465 +-0.204823, 0.0, 0.978799 +0.409646, 0.0, 0.912244 +0.204823, 0.0, 0.978799 +0.204823, 0.0, 0.978799 +-0.409646, 0.0, 0.912244 +-0.204823, 0.0, 0.978799 +0.409646, 0.0, 0.912244 +0.58781, 0.0, 0.808999 +0.58781, 0.0, 0.808999 +0.58781, 0.0, 0.808999 +0.204823, 0.0, 0.978799 +0.409646, 0.0, 0.912244 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.951056, 0.0, -0.309018 +0.951056, 0.0, -0.309018 +0.951056, 0.0, -0.309018 +0.951056, 0.0, -0.309018 +0.951056, 0.0, -0.309018 +0.951056, 0.0, -0.309018 +-0.951057, 0.0, -0.309016 +-0.994187, 0.0, 0.107666 +-0.994185, 0.0, -0.107681 +-0.994185, 0.0, -0.107681 +-0.951057, 0.0, -0.309016 +-0.951057, 0.0, -0.309016 +-0.994187, 0.0, 0.107666 +-0.741014, 0.0, 0.67149 +-0.867605, 0.0, 0.497253 +-0.867605, 0.0, 0.497253 +-0.994185, 0.0, -0.107681 +-0.994187, 0.0, 0.107666 +-0.741014, 0.0, 0.67149 +-0.204805, 0.0, 0.978803 +-0.409611, 0.0, 0.91226 +-0.409611, 0.0, 0.91226 +-0.867605, 0.0, 0.497253 +-0.741014, 0.0, 0.67149 +-0.204805, 0.0, 0.978803 +0.409611, 0.0, 0.91226 +0.204806, 0.0, 0.978803 +0.204806, 0.0, 0.978803 +-0.409611, 0.0, 0.91226 +-0.204805, 0.0, 0.978803 +0.409611, 0.0, 0.91226 +0.587765, 0.0, 0.809032 +0.587765, 0.0, 0.809032 +0.587765, 0.0, 0.809032 +0.204806, 0.0, 0.978803 +0.409611, 0.0, 0.91226 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.994184, 0.0, -0.107692 +0.951052, 0.0, -0.309032 +0.951052, 0.0, -0.309032 +0.951052, 0.0, -0.309032 +0.994188, 0.0, 0.107662 +0.994184, 0.0, -0.107692 +-0.951061, 0.0, 0.309003 +-0.740996, 0.0, 0.671509 +-0.867599, 0.0, 0.497264 +-0.867599, 0.0, 0.497264 +-0.951061, 0.0, 0.309003 +-0.951061, 0.0, 0.309003 +-0.740996, 0.0, 0.671509 +-0.204794, 0.0, 0.978805 +-0.409587, 0.0, 0.912271 +-0.409587, 0.0, 0.912271 +-0.867599, 0.0, 0.497264 +-0.740996, 0.0, 0.671509 +-0.204794, 0.0, 0.978805 +0.409588, 0.0, 0.912271 +0.204794, 0.0, 0.978805 +0.204794, 0.0, 0.978805 +-0.409587, 0.0, 0.912271 +-0.204794, 0.0, 0.978805 +0.409588, 0.0, 0.912271 +0.867599, 0.0, 0.497264 +0.740997, 0.0, 0.671509 +0.740997, 0.0, 0.671509 +0.204794, 0.0, 0.978805 +0.409588, 0.0, 0.912271 +0.867599, 0.0, 0.497264 +0.994184, 0.0, -0.107692 +0.994188, 0.0, 0.107662 +0.994188, 0.0, 0.107662 +0.740997, 0.0, 0.671509 +0.867599, 0.0, 0.497264 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.994185, 0.0, -0.107687 +0.951052, 0.0, -0.309031 +0.951052, 0.0, -0.309031 +0.951052, 0.0, -0.309031 +0.994187, 0.0, 0.107671 +0.994185, 0.0, -0.107687 +-0.951057, 0.0, 0.309016 +-0.741023, 0.0, 0.67148 +-0.867605, 0.0, 0.497254 +-0.867605, 0.0, 0.497254 +-0.951057, 0.0, 0.309016 +-0.951057, 0.0, 0.309016 +-0.741023, 0.0, 0.67148 +-0.204814, 0.0, 0.978801 +-0.409628, 0.0, 0.912253 +-0.409628, 0.0, 0.912253 +-0.867605, 0.0, 0.497254 +-0.741023, 0.0, 0.67148 +-0.204814, 0.0, 0.978801 +0.409628, 0.0, 0.912253 +0.204814, 0.0, 0.978801 +0.204814, 0.0, 0.978801 +-0.409628, 0.0, 0.912253 +-0.204814, 0.0, 0.978801 +0.409628, 0.0, 0.912253 +0.867605, 0.0, 0.497254 +0.741023, 0.0, 0.67148 +0.741023, 0.0, 0.67148 +0.204814, 0.0, 0.978801 +0.409628, 0.0, 0.912253 +0.867605, 0.0, 0.497254 +0.994185, 0.0, -0.107687 +0.994187, 0.0, 0.107671 +0.994187, 0.0, 0.107671 +0.741023, 0.0, 0.67148 +0.867605, 0.0, 0.497254 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +-0.0599835, 0.0, -0.998199 +-0.0599835, 0.0, -0.998199 +-0.0599835, 0.0, -0.998199 +-0.0599835, 0.0, -0.998199 +-0.0599835, 0.0, -0.998199 +-0.0599835, 0.0, -0.998199 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0889468, 0.0, 0.996036 +0.0889468, 0.0, 0.996036 +0.0889468, 0.0, 0.996036 +0.0889468, 0.0, 0.996036 +0.0889468, 0.0, 0.996036 +0.0889468, 0.0, 0.996036 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +-0.0184439, 0.0, -0.99983 +-0.0184439, 0.0, -0.99983 +-0.0184439, 0.0, -0.99983 +-0.0184439, 0.0, -0.99983 +-0.0184439, 0.0, -0.99983 +-0.0184439, 0.0, -0.99983 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0526117, 0.0, 0.998615 +0.0526117, 0.0, 0.998615 +0.0526117, 0.0, 0.998615 +0.0526117, 0.0, 0.998615 +0.0526117, 0.0, 0.998615 +0.0526117, 0.0, 0.998615 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +0.0245422, 0.0, -0.999699 +0.0245422, 0.0, -0.999699 +0.0245422, 0.0, -0.999699 +0.0245422, 0.0, -0.999699 +0.0245422, 0.0, -0.999699 +0.0245422, 0.0, -0.999699 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +-0.0599369, 0.0, 0.998202 +-0.0599369, 0.0, 0.998202 +-0.0599369, 0.0, 0.998202 +-0.0599369, 0.0, 0.998202 +-0.0599369, 0.0, 0.998202 +-0.0599369, 0.0, 0.998202 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +0.0339176, 0.0, -0.999425 +0.0339176, 0.0, -0.999425 +0.0339176, 0.0, -0.999425 +0.0339176, 0.0, -0.999425 +0.0339176, 0.0, -0.999425 +0.0339176, 0.0, -0.999425 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +-0.0666057, 0.0, 0.997779 +-0.0666057, 0.0, 0.997779 +-0.0666057, 0.0, 0.997779 +-0.0666057, 0.0, 0.997779 +-0.0666057, 0.0, 0.997779 +-0.0666057, 0.0, 0.997779 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 + + + + +0.996648, 0.355226 +0.0979369, 0.355226 +0.0979369, 0.0048809 +0.0979369, 0.0048809 +0.996648, 0.00488085 +0.996648, 0.355226 +0.996643, 0.00482193 +0.996644, 0.355167 +0.0979327, 0.355167 +0.0979327, 0.355167 +0.0979326, 0.00482197 +0.996643, 0.00482193 +0.995325, 0.693698 +0.0952358, 0.693696 +0.0952372, 0.358069 +0.0952372, 0.358069 +0.995326, 0.358072 +0.995325, 0.693698 +0.995712, 0.994161 +0.697017, 0.994161 +0.697017, 0.709019 +0.697017, 0.709019 +0.995712, 0.709019 +0.995712, 0.994161 +0.994841, 0.693621 +0.0947512, 0.693619 +0.0947528, 0.357992 +0.0947528, 0.357992 +0.994842, 0.357995 +0.994841, 0.693621 +0.0445547, 0.707523 +0.695375, 0.712237 +0.666895, 0.737505 +0.666895, 0.737505 +0.072667, 0.733201 +0.0445547, 0.707523 +0.0524875, 0.741276 +0.675028, 0.740186 +0.645188, 0.768535 +0.645188, 0.768535 +0.0780106, 0.769529 +0.0524875, 0.741276 +0.0483286, 0.805124 +0.68021, 0.805144 +0.652737, 0.834161 +0.652737, 0.834161 +0.0758014, 0.834144 +0.0483286, 0.805124 +0.673981, 0.802663 +0.0514405, 0.801571 +0.0769636, 0.773319 +0.0769636, 0.773319 +0.644141, 0.774314 +0.673981, 0.802663 +0.0320342, 0.0043303 +0.0352626, 0.0043303 +0.0352626, 0.808058 +0.0352626, 0.808058 +0.0320342, 0.808058 +0.0320342, 0.0043303 +0.0126548, 0.0043303 +0.0158832, 0.0043303 +0.0158832, 0.808058 +0.0158832, 0.808058 +0.0126548, 0.808058 +0.0126548, 0.0043303 +0.0158832, 0.0043303 +0.0191126, 0.0043303 +0.0191126, 0.808058 +0.0191126, 0.808058 +0.0158832, 0.808058 +0.0158832, 0.0043303 +0.0191126, 0.0043303 +0.022343, 0.0043303 +0.022343, 0.808058 +0.022343, 0.808058 +0.0191126, 0.808058 +0.0191126, 0.0043303 +0.022343, 0.0043303 +0.0255743, 0.0043303 +0.0255743, 0.808058 +0.0255743, 0.808058 +0.022343, 0.808058 +0.022343, 0.0043303 +0.0255743, 0.0043303 +0.0288048, 0.0043303 +0.0288048, 0.808058 +0.0288048, 0.808058 +0.0255743, 0.808058 +0.0255743, 0.0043303 +0.0281171, 0.20497 +0.0290044, 0.208058 +0.0279071, 0.211078 +0.0279071, 0.211078 +0.0252445, 0.212876 +0.0220335, 0.212766 +0.0220335, 0.212766 +0.0195005, 0.210789 +0.0186132, 0.207701 +0.0186132, 0.207701 +0.0197105, 0.204681 +0.0223732, 0.202885 +0.0220335, 0.212766 +0.0186132, 0.207701 +0.0223732, 0.202885 +0.0279071, 0.211078 +0.0220335, 0.212766 +0.0223732, 0.202885 +0.0281171, 0.20497 +0.0279071, 0.211078 +0.0223732, 0.202885 +0.0255843, 0.202992 +0.0281171, 0.20497 +0.0223732, 0.202885 +0.0190881, 0.218049 +0.0204065, 0.220979 +0.0197509, 0.224124 +0.0197509, 0.224124 +0.0173717, 0.226283 +0.0141777, 0.226632 +0.0141777, 0.226632 +0.011389, 0.225036 +0.0100705, 0.222106 +0.0100705, 0.222106 +0.0107261, 0.218961 +0.0147068, 0.216693 +0.0141777, 0.226632 +0.0100705, 0.222106 +0.0147068, 0.216693 +0.0197509, 0.224124 +0.0141777, 0.226632 +0.0147068, 0.216693 +0.0190881, 0.218049 +0.0197509, 0.224124 +0.0147068, 0.216693 +0.0146979, 0.216562 +0.0190881, 0.218049 +0.0147068, 0.216693 +0.0328696, 0.0043303 +0.036432, 0.0043303 +0.036432, 0.808058 +0.036432, 0.808058 +0.0328696, 0.808058 +0.0328696, 0.0043303 +0.0114858, 0.0043303 +0.0150483, 0.0043303 +0.0150483, 0.808058 +0.0150483, 0.808058 +0.0114858, 0.808058 +0.0114858, 0.0043303 +0.0150483, 0.0043303 +0.0186118, 0.0043303 +0.0186118, 0.808058 +0.0186118, 0.808058 +0.0150483, 0.808058 +0.0150483, 0.0043303 +0.0186118, 0.0043303 +0.0221764, 0.0043303 +0.0221763, 0.808058 +0.0221763, 0.808058 +0.0186118, 0.808058 +0.0186118, 0.0043303 +0.0221764, 0.0043303 +0.0257418, 0.0043303 +0.0257418, 0.808058 +0.0257418, 0.808058 +0.0221763, 0.808058 +0.0221764, 0.0043303 +0.0257418, 0.0043303 +0.0293064, 0.0043303 +0.0293063, 0.808058 +0.0293063, 0.808058 +0.0257418, 0.808058 +0.0257418, 0.0043303 +0.0285426, 0.20616 +0.0295102, 0.209571 +0.0282882, 0.212899 +0.0282882, 0.212899 +0.0253432, 0.214874 +0.0218002, 0.21474 +0.0218002, 0.21474 +0.0190125, 0.212549 +0.0180449, 0.209138 +0.0180449, 0.209138 +0.0192669, 0.20581 +0.0222121, 0.203838 +0.0218002, 0.21474 +0.0180449, 0.209138 +0.0222121, 0.203838 +0.0282882, 0.212899 +0.0218002, 0.21474 +0.0222121, 0.203838 +0.0285426, 0.20616 +0.0282882, 0.212899 +0.0222121, 0.203838 +0.0257553, 0.203968 +0.0285426, 0.20616 +0.0222121, 0.203838 +0.0200101, 0.220638 +0.0215053, 0.223853 +0.0208253, 0.227333 +0.0208253, 0.227333 +0.0182299, 0.229748 +0.0147104, 0.230177 +0.0147104, 0.230177 +0.0116111, 0.228455 +0.0101159, 0.22524 +0.0101159, 0.22524 +0.0107959, 0.22176 +0.015157, 0.219214 +0.0147104, 0.230177 +0.0101159, 0.22524 +0.015157, 0.219214 +0.0208253, 0.227333 +0.0147104, 0.230177 +0.015157, 0.219214 +0.0200101, 0.220638 +0.0208253, 0.227333 +0.015157, 0.219214 +0.0151446, 0.219047 +0.0200101, 0.220638 +0.015157, 0.219214 +0.0329622, 0.0043303 +0.0365634, 0.0043303 +0.0365634, 0.808058 +0.0365634, 0.808058 +0.0329622, 0.808058 +0.0329622, 0.0043303 +0.0149465, 0.0043303 +0.018549, 0.0043303 +0.018549, 0.808058 +0.018549, 0.808058 +0.0149465, 0.808058 +0.0149465, 0.0043303 +0.018549, 0.0043303 +0.0221527, 0.0043303 +0.0221529, 0.808058 +0.0221529, 0.808058 +0.018549, 0.808058 +0.018549, 0.0043303 +0.0221527, 0.0043303 +0.0257568, 0.0043303 +0.0257571, 0.808058 +0.0257571, 0.808058 +0.0221529, 0.808058 +0.0221527, 0.0043303 +0.0257568, 0.0043303 +0.0293601, 0.0043303 +0.0293601, 0.808058 +0.0293601, 0.808058 +0.0257571, 0.808058 +0.0257568, 0.0043303 +0.0293601, 0.0043303 +0.0329622, 0.0043303 +0.0329622, 0.808058 +0.0329622, 0.808058 +0.0293601, 0.808058 +0.0293601, 0.0043303 +0.00872991, 0.210054 +0.00752289, 0.206679 +0.00853017, 0.203239 +0.00853017, 0.203239 +0.0113624, 0.201022 +0.014946, 0.200969 +0.014946, 0.200969 +0.0179101, 0.202964 +0.0191171, 0.206339 +0.0191171, 0.206339 +0.0181098, 0.209779 +0.015273, 0.21197 +0.014946, 0.200969 +0.0191171, 0.206339 +0.015273, 0.21197 +0.00853017, 0.203239 +0.014946, 0.200969 +0.015273, 0.21197 +0.00872991, 0.210054 +0.00853017, 0.203239 +0.015273, 0.21197 +0.0116902, 0.212075 +0.00872991, 0.210054 +0.015273, 0.21197 +0.0173309, 0.226479 +0.0139519, 0.225284 +0.0119209, 0.22233 +0.0119209, 0.22233 +0.0134691, 0.218018 +0.0127676, 0.216596 +0.0127676, 0.216596 +0.0176317, 0.214884 +0.0210108, 0.21608 +0.0210108, 0.21608 +0.0230417, 0.219033 +0.0229487, 0.222616 +0.0127676, 0.216596 +0.0210108, 0.21608 +0.0229487, 0.222616 +0.0119209, 0.22233 +0.0127676, 0.216596 +0.0229487, 0.222616 +0.0173309, 0.226479 +0.0119209, 0.22233 +0.0229487, 0.222616 +0.0207674, 0.22546 +0.0173309, 0.226479 +0.0229487, 0.222616 +0.0322638, 0.0043303 +0.0355849, 0.0043303 +0.0355849, 0.808058 +0.0355849, 0.808058 +0.0322638, 0.808058 +0.0322638, 0.0043303 +0.0156493, 0.0043303 +0.0189715, 0.0043303 +0.0189716, 0.808058 +0.0189716, 0.808058 +0.0156493, 0.808058 +0.0156493, 0.0043303 +0.0189715, 0.0043303 +0.0222948, 0.0043303 +0.0222948, 0.808058 +0.0222948, 0.808058 +0.0189716, 0.808058 +0.0189715, 0.0043303 +0.0222948, 0.0043303 +0.0256186, 0.0043303 +0.0256186, 0.808058 +0.0256186, 0.808058 +0.0222948, 0.808058 +0.0222948, 0.0043303 +0.0256186, 0.0043303 +0.0289416, 0.0043303 +0.0289416, 0.808058 +0.0289416, 0.808058 +0.0256186, 0.808058 +0.0256186, 0.0043303 +0.0289416, 0.0043303 +0.0322638, 0.0043303 +0.0322638, 0.808058 +0.0322638, 0.808058 +0.0289416, 0.808058 +0.0289416, 0.0043303 +0.00988939, 0.207325 +0.00878603, 0.204209 +0.00972486, 0.20104 +0.00972486, 0.20104 +0.0123434, 0.199006 +0.0156482, 0.198963 +0.0156482, 0.198963 +0.0183755, 0.200813 +0.0194788, 0.203929 +0.0194788, 0.203929 +0.01854, 0.207098 +0.0159177, 0.209111 +0.0156482, 0.198963 +0.0194788, 0.203929 +0.0159177, 0.209111 +0.00972486, 0.20104 +0.0156482, 0.198963 +0.0159177, 0.209111 +0.00988939, 0.207325 +0.00972486, 0.20104 +0.0159177, 0.209111 +0.0126135, 0.209197 +0.00988939, 0.207325 +0.0159177, 0.209111 +0.0171257, 0.22806 +0.014114, 0.226698 +0.0124783, 0.223826 +0.0124783, 0.223826 +0.014237, 0.219918 +0.0136974, 0.218696 +0.0136974, 0.218696 +0.0183066, 0.217429 +0.0213182, 0.218791 +0.0213182, 0.218791 +0.0229539, 0.221664 +0.022589, 0.224949 +0.0136974, 0.218696 +0.0213182, 0.218791 +0.022589, 0.224949 +0.0124783, 0.223826 +0.0136974, 0.218696 +0.022589, 0.224949 +0.0171257, 0.22806 +0.0124783, 0.223826 +0.022589, 0.224949 +0.0203628, 0.227392 +0.0171257, 0.22806 +0.022589, 0.224949 +0.99556, 0.708874 +0.995362, 0.993985 +0.849113, 0.993985 +0.849113, 0.993985 +0.84931, 0.708874 +0.99556, 0.708874 +0.849122, 0.994505 +0.696954, 0.99411 +0.697152, 0.709 +0.697152, 0.709 +0.84932, 0.709394 +0.849122, 0.994505 +0.0320342, 0.0043303 +0.0320342, 0.808058 +0.0320342, 0.808058 +0.0320342, 0.808058 +0.0320342, 0.0043303 +0.0320342, 0.0043303 +0.0146979, 0.216562 +0.0147068, 0.216693 +0.0288048, 0.808058 +0.0288048, 0.808058 +0.0320342, 0.808058 +0.0146979, 0.216562 +0.0288048, 0.808058 +0.0288048, 0.0043303 +0.0288048, 0.0043303 +0.0288048, 0.0043303 +0.0288048, 0.808058 +0.0288048, 0.808058 +0.0255843, 0.202992 +0.0223732, 0.202885 +0.0320342, 0.0043303 +0.0320342, 0.0043303 +0.0288048, 0.0043303 +0.0255843, 0.202992 +0.0320342, 0.0043303 +0.0320342, 0.808058 +0.0304195, 0.808058 +0.0304195, 0.808058 +0.0304195, 0.0043303 +0.0320342, 0.0043303 +0.0320342, 0.808058 +0.0288048, 0.808058 +0.0304195, 0.808058 +0.0288048, 0.808058 +0.0288048, 0.0043303 +0.0304195, 0.0043303 +0.0304195, 0.0043303 +0.0304195, 0.808058 +0.0288048, 0.808058 +0.0288048, 0.0043303 +0.0320342, 0.0043303 +0.0304195, 0.0043303 +0.0328696, 0.0043303 +0.0328696, 0.808058 +0.0328696, 0.808058 +0.0328696, 0.808058 +0.0328696, 0.0043303 +0.0328696, 0.0043303 +0.0151446, 0.219047 +0.015157, 0.219214 +0.0293063, 0.808058 +0.0293063, 0.808058 +0.0328696, 0.808058 +0.0151446, 0.219047 +0.0293063, 0.808058 +0.0293064, 0.0043303 +0.0293064, 0.0043303 +0.0293064, 0.0043303 +0.0293063, 0.808058 +0.0293063, 0.808058 +0.0257553, 0.203968 +0.0222121, 0.203838 +0.0328696, 0.0043303 +0.0328696, 0.0043303 +0.0293064, 0.0043303 +0.0257553, 0.203968 +0.0328696, 0.0043303 +0.0328696, 0.808058 +0.0310879, 0.808058 +0.0310879, 0.808058 +0.031088, 0.0043303 +0.0328696, 0.0043303 +0.0328696, 0.808058 +0.0293063, 0.808058 +0.0310879, 0.808058 +0.0293063, 0.808058 +0.0293064, 0.0043303 +0.031088, 0.0043303 +0.031088, 0.0043303 +0.0310879, 0.808058 +0.0293063, 0.808058 +0.0293064, 0.0043303 +0.0328696, 0.0043303 +0.031088, 0.0043303 +0.011345, 0.808058 +0.011345, 0.0043303 +0.011345, 0.0043303 +0.011345, 0.0043303 +0.011345, 0.808058 +0.011345, 0.808058 +0.014946, 0.200969 +0.0113624, 0.201022 +0.0149465, 0.0043303 +0.0149465, 0.0043303 +0.011345, 0.0043303 +0.014946, 0.200969 +0.0149465, 0.0043303 +0.0149465, 0.808058 +0.0149465, 0.808058 +0.0149465, 0.808058 +0.0149465, 0.0043303 +0.0149465, 0.0043303 +0.0127676, 0.216596 +0.0134691, 0.218018 +0.011345, 0.808058 +0.011345, 0.808058 +0.0149465, 0.808058 +0.0127676, 0.216596 +0.011345, 0.808058 +0.011345, 0.0043303 +0.0131458, 0.0043303 +0.0131458, 0.0043303 +0.0131458, 0.808058 +0.011345, 0.808058 +0.011345, 0.0043303 +0.0149465, 0.0043303 +0.0131458, 0.0043303 +0.0149465, 0.0043303 +0.0149465, 0.808058 +0.0131458, 0.808058 +0.0131458, 0.808058 +0.0131458, 0.0043303 +0.0149465, 0.0043303 +0.0149465, 0.808058 +0.011345, 0.808058 +0.0131458, 0.808058 +0.0123284, 0.808058 +0.0123284, 0.0043303 +0.0123284, 0.0043303 +0.0123284, 0.0043303 +0.0123284, 0.808058 +0.0123284, 0.808058 +0.0156482, 0.198963 +0.0123434, 0.199006 +0.0156493, 0.0043303 +0.0156493, 0.0043303 +0.0123284, 0.0043303 +0.0156482, 0.198963 +0.0156493, 0.0043303 +0.0156493, 0.808058 +0.0156493, 0.808058 +0.0156493, 0.808058 +0.0156493, 0.0043303 +0.0156493, 0.0043303 +0.0136974, 0.218696 +0.014237, 0.219918 +0.0123284, 0.808058 +0.0123284, 0.808058 +0.0156493, 0.808058 +0.0136974, 0.218696 +0.0123284, 0.808058 +0.0123284, 0.0043303 +0.0139889, 0.0043303 +0.0139889, 0.0043303 +0.0139889, 0.808058 +0.0123284, 0.808058 +0.0123284, 0.0043303 +0.0156493, 0.0043303 +0.0139889, 0.0043303 +0.0156493, 0.0043303 +0.0156493, 0.808058 +0.0139889, 0.808058 +0.0139889, 0.808058 +0.0139889, 0.0043303 +0.0156493, 0.0043303 +0.0156493, 0.808058 +0.0123284, 0.808058 +0.0139889, 0.808058 + + + diff --git a/Templates/SalmonUniversalTemplate/assets/shot.wav b/Templates/SalmonUniversalTemplate/assets/shot.wav new file mode 100644 index 0000000..883edf0 Binary files /dev/null and b/Templates/SalmonUniversalTemplate/assets/shot.wav differ diff --git a/Templates/SalmonUniversalTemplate/default.properties b/Templates/SalmonUniversalTemplate/default.properties new file mode 100644 index 0000000..94a5300 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/default.properties @@ -0,0 +1,11 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "build.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-8 diff --git a/Templates/SalmonUniversalTemplate/iOS/AppDelegate.h b/Templates/SalmonUniversalTemplate/iOS/AppDelegate.h new file mode 100644 index 0000000..4237984 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/iOS/AppDelegate.h @@ -0,0 +1,19 @@ +// +// AppDelegate.h +// doublehitballs +// +// Created by vvv ооо on 13.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import + +@class ViewController; + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@property (strong, nonatomic) ViewController *viewController; + +@end diff --git a/Templates/SalmonUniversalTemplate/iOS/AppDelegate.m b/Templates/SalmonUniversalTemplate/iOS/AppDelegate.m new file mode 100644 index 0000000..1283115 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/iOS/AppDelegate.m @@ -0,0 +1,59 @@ +// +// AppDelegate.m +// doublehitballs +// +// Created by vvv ооо on 13.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import "AppDelegate.h" + +#import "ViewController.h" + +@implementation AppDelegate + +@synthesize window = _window; +@synthesize viewController = _viewController; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + // Override point for customization after application launch. + if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { + self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil]; + } else { + self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil]; + } + self.window.rootViewController = self.viewController; + [self.window makeKeyAndVisible]; + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application +{ + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application +{ + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application +{ + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application +{ + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *)application +{ + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + +@end diff --git a/Templates/SalmonUniversalTemplate/iOS/CustomGLKView.h b/Templates/SalmonUniversalTemplate/iOS/CustomGLKView.h new file mode 100644 index 0000000..59184d3 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/iOS/CustomGLKView.h @@ -0,0 +1,17 @@ +// +// CustomGLKView.h +// doublehitballs +// +// Created by vvv ооо on 15.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import + +@interface CustomGLKView : GLKView + +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; + +@end diff --git a/Templates/SalmonUniversalTemplate/iOS/CustomGLKView.m b/Templates/SalmonUniversalTemplate/iOS/CustomGLKView.m new file mode 100644 index 0000000..130b654 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/iOS/CustomGLKView.m @@ -0,0 +1,68 @@ +// +// CustomGLKView.m +// doublehitballs +// +// Created by vvv ооо on 15.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import "CustomGLKView.h" +#import "ios_api.h" + +bool touchMoved = false; +CGPoint prev_loc; + + +@implementation CustomGLKView + +- (id)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + // Initialization code + } + return self; +} + + +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event +{ + + CGPoint location = [[[touches allObjects] objectAtIndex:0] locationInView:self]; + + prev_loc = location; + + touchMoved = false; + + AppOnTapDown(location.x, self.bounds.size.height - location.y); + +} + +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event +{ + CGPoint location = [[[touches allObjects] objectAtIndex:0] locationInView:self]; + + CGPoint prevLocation = [[[touches allObjects] objectAtIndex:0] previousLocationInView:self]; + + if (abs(prev_loc.x - location.x) > 10 || abs(prev_loc.y - location.y) > 10) + { + touchMoved = true; + } + + AppOnScroll(prevLocation.x - location.x, prevLocation.y - location.y); +} + +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event +{ + CGPoint location = [[[touches allObjects] objectAtIndex:0] locationInView:self]; + + if (!touchMoved) + { + AppOnTapUp(location.x, self.bounds.size.height - location.y); + } +} + + + + +@end diff --git a/Templates/SalmonUniversalTemplate/iOS/ViewController.h b/Templates/SalmonUniversalTemplate/iOS/ViewController.h new file mode 100644 index 0000000..e7f9748 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/iOS/ViewController.h @@ -0,0 +1,14 @@ +// +// ViewController.h +// doublehitballs +// +// Created by vvv ооо on 13.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import +#import + +@interface ViewController : GLKViewController + +@end diff --git a/Templates/SalmonUniversalTemplate/iOS/ViewController.m b/Templates/SalmonUniversalTemplate/iOS/ViewController.m new file mode 100644 index 0000000..b04f1d3 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/iOS/ViewController.m @@ -0,0 +1,106 @@ +// +// ViewController.m +// doublehitballs +// +// Created by vvv ооо on 13.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import "ViewController.h" +#import "ios_api.h" + +@interface ViewController () { +} + +@property (strong, nonatomic) EAGLContext *context; +@property (strong, nonatomic) GLKBaseEffect *effect; + +- (void)setupGL; +- (void)tearDownGL; + +@end + +@implementation ViewController + +@synthesize context = _context; +@synthesize effect = _effect; + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; + + if (!self.context) { + NSLog(@"Failed to create ES context"); + } + + GLKView *view = (GLKView *)self.view; + view.context = self.context; + view.drawableDepthFormat = GLKViewDrawableDepthFormat24; + + + [self setupGL]; +} + +- (void)viewDidUnload +{ + [super viewDidUnload]; + + [self tearDownGL]; + + if ([EAGLContext currentContext] == self.context) { + [EAGLContext setCurrentContext:nil]; + } + self.context = nil; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Release any cached data, images, etc. that aren't in use. +} + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +{ + /* + if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { + return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); + } else { + return YES; + }*/ + return UIInterfaceOrientationIsLandscape(interfaceOrientation); +} + +- (void)setupGL +{ + [EAGLContext setCurrentContext:self.context]; + + AppInit(); + } + +- (void)tearDownGL +{ + [EAGLContext setCurrentContext:self.context]; + + AppDeinit(); + +} + +#pragma mark - GLKView and GLKViewController delegate methods + +- (void)update +{ + + AppUpdate(self.timeSinceLastUpdate * 1000); +} + +- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect +{ + + AppDraw(); + +} + + +@end diff --git a/Templates/SalmonUniversalTemplate/iOS/en.lproj/InfoPlist.strings b/Templates/SalmonUniversalTemplate/iOS/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..0f167df --- /dev/null +++ b/Templates/SalmonUniversalTemplate/iOS/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/Templates/SalmonUniversalTemplate/iOS/en.lproj/ViewController_iPad.xib b/Templates/SalmonUniversalTemplate/iOS/en.lproj/ViewController_iPad.xib new file mode 100644 index 0000000..eb81e88 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/iOS/en.lproj/ViewController_iPad.xib @@ -0,0 +1,133 @@ + + + + 1296 + 11E53 + 2182 + 1138.47 + 569.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 1181 + + + IBProxyObject + IBUIView + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBIPadFramework + + + IBFirstResponder + IBIPadFramework + + + + 274 + {{0, 20}, {768, 1004}} + + + + 3 + MQA + + 2 + + + + 2 + + IBIPadFramework + + + + + + + view + + + + 3 + + + + + + 0 + + + + + + 1 + + + + + -1 + + + File's Owner + + + -2 + + + + + + + ViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + CustomGLKView + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + 3 + + + + + CustomGLKView + GLKView + + IBProjectSource + ./Classes/CustomGLKView.h + + + + ViewController + GLKViewController + + IBProjectSource + ./Classes/ViewController.h + + + + + 0 + IBIPadFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + YES + 3 + 1181 + + diff --git a/Templates/SalmonUniversalTemplate/iOS/en.lproj/ViewController_iPhone.xib b/Templates/SalmonUniversalTemplate/iOS/en.lproj/ViewController_iPhone.xib new file mode 100644 index 0000000..96a4a92 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/iOS/en.lproj/ViewController_iPhone.xib @@ -0,0 +1,111 @@ + + + + 1296 + 11E53 + 2182 + 1138.47 + 569.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 1181 + + + IBProxyObject + IBUIView + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 274 + {320, 460} + + + 3 + MQA + + 2 + + + NO + IBCocoaTouchFramework + + + + + + + view + + + + 3 + + + + + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 2 + + + + + + + ViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + CustomGLKView + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + 4 + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + YES + 3 + 1181 + + diff --git a/Templates/SalmonUniversalTemplate/iOS/ios_api.cpp b/Templates/SalmonUniversalTemplate/iOS/ios_api.cpp new file mode 100644 index 0000000..e8c79cc --- /dev/null +++ b/Templates/SalmonUniversalTemplate/iOS/ios_api.cpp @@ -0,0 +1,47 @@ +#include "include/Engine.h" +#include "main_code.h" + +TMyApplication App; + + +extern "C" void AppInit() +{ + + App.OuterInit(480, 320, 480, 320); +} + + +extern "C" void AppDeinit() +{ + App.OuterDeinit(); + +} + + +extern "C" void AppUpdate(int dt) +{ + App.OuterUpdate(dt); +} + + + +extern "C" void AppDraw() +{ + App.OuterDraw(); +} + +extern "C" void AppOnTapDown(int posx, int posy) +{ + //App.OuterOnTapDown(vec2(posx, posy)); +} + +extern "C" void AppOnTapUp(int posx, int posy) +{ + //App.OuterOnTapUp(vec2(posx, posy)); +} + +extern "C" void AppOnScroll(int shiftx, int shifty) +{ + //App.OuterOnMove(vec2(shiftx, shifty)); +} + diff --git a/Templates/SalmonUniversalTemplate/iOS/ios_api.h b/Templates/SalmonUniversalTemplate/iOS/ios_api.h new file mode 100644 index 0000000..66b7e7f --- /dev/null +++ b/Templates/SalmonUniversalTemplate/iOS/ios_api.h @@ -0,0 +1,15 @@ +// +// Header.h +// doublehitballs +// +// Created by vvv ооо on 15.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +void AppInit(); +void AppDeinit(); +void AppUpdate(int dt); +void AppDraw(); +void AppOnTapDown(int posx, int posy); +void AppOnTapUp(int posx, int posy); +void AppOnScroll(int shiftx, int shifty); \ No newline at end of file diff --git a/Templates/SalmonUniversalTemplate/iOS/main.m b/Templates/SalmonUniversalTemplate/iOS/main.m new file mode 100644 index 0000000..f8b2c00 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/iOS/main.m @@ -0,0 +1,18 @@ +// +// main.m +// doublehitballs +// +// Created by vvv ооо on 13.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import + +#import "AppDelegate.h" + +int main(int argc, char *argv[]) +{ + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/Templates/SalmonUniversalTemplate/iOS/res/Icon.png b/Templates/SalmonUniversalTemplate/iOS/res/Icon.png new file mode 100644 index 0000000..b6880bf Binary files /dev/null and b/Templates/SalmonUniversalTemplate/iOS/res/Icon.png differ diff --git a/Templates/SalmonUniversalTemplate/iOS/res/Splash-landscape.png b/Templates/SalmonUniversalTemplate/iOS/res/Splash-landscape.png new file mode 100644 index 0000000..61dbcaa Binary files /dev/null and b/Templates/SalmonUniversalTemplate/iOS/res/Splash-landscape.png differ diff --git a/Templates/SalmonUniversalTemplate/iOS/res/iTunesArtwork b/Templates/SalmonUniversalTemplate/iOS/res/iTunesArtwork new file mode 100644 index 0000000..876e97d Binary files /dev/null and b/Templates/SalmonUniversalTemplate/iOS/res/iTunesArtwork differ diff --git a/Templates/SalmonUniversalTemplate/iOS/salmontemplate.xcodeproj/project.pbxproj b/Templates/SalmonUniversalTemplate/iOS/salmontemplate.xcodeproj/project.pbxproj new file mode 100644 index 0000000..0bb983d --- /dev/null +++ b/Templates/SalmonUniversalTemplate/iOS/salmontemplate.xcodeproj/project.pbxproj @@ -0,0 +1,502 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 4C49B2BE15B0991B003512CD /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C49B2BD15B0991B003512CD /* UIKit.framework */; }; + 4C49B2C015B0991B003512CD /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C49B2BF15B0991B003512CD /* Foundation.framework */; }; + 4C49B2C215B0991B003512CD /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C49B2C115B0991B003512CD /* CoreGraphics.framework */; }; + 4C49B2C415B0991B003512CD /* GLKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C49B2C315B0991B003512CD /* GLKit.framework */; }; + 4C49B2C615B0991B003512CD /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C49B2C515B0991B003512CD /* OpenGLES.framework */; }; + 4C49B2CC15B0991B003512CD /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4C49B2CA15B0991B003512CD /* InfoPlist.strings */; }; + 4C49B2CE15B0991B003512CD /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C49B2CD15B0991B003512CD /* main.m */; }; + 4C49B2D215B0991B003512CD /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C49B2D115B0991B003512CD /* AppDelegate.m */; }; + 4C49B2D915B0991B003512CD /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C49B2D815B0991B003512CD /* ViewController.m */; }; + 4C49B2DC15B0991B003512CD /* ViewController_iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C49B2DA15B0991B003512CD /* ViewController_iPhone.xib */; }; + 4C49B2DF15B0991B003512CD /* ViewController_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C49B2DD15B0991B003512CD /* ViewController_iPad.xib */; }; + 4C4C807515BA8F460037C6CE /* libsquirrel.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C4C807415BA8F460037C6CE /* libsquirrel.a */; }; + 4C4C807715BA8F5B0037C6CE /* libz.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C4C807615BA8F5B0037C6CE /* libz.a */; }; + 4C6EB44515C3CFD300316CB6 /* libpng.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C6EB44415C3CFD300316CB6 /* libpng.a */; }; + 4C74848615C5AD6E0056EC44 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 4C74848315C5AD6E0056EC44 /* Icon.png */; }; + 4C74848715C5AD6E0056EC44 /* iTunesArtwork in Resources */ = {isa = PBXBuildFile; fileRef = 4C74848415C5AD6E0056EC44 /* iTunesArtwork */; }; + 4C74848815C5AD6E0056EC44 /* Splash-landscape.png in Resources */ = {isa = PBXBuildFile; fileRef = 4C74848515C5AD6E0056EC44 /* Splash-landscape.png */; }; + 4C74849815C5AF7C0056EC44 /* main_code.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C74849615C5AF7C0056EC44 /* main_code.cpp */; }; + 4C77831315BABD68003D5142 /* libvorbis-tremor-ios.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C77831215BABD68003D5142 /* libvorbis-tremor-ios.a */; }; + 4C77831815BABE26003D5142 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C77831415BABD8B003D5142 /* AudioToolbox.framework */; }; + 4C77831915BABE26003D5142 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C77831515BABD8B003D5142 /* OpenAL.framework */; }; + 4C7AD44C15B1D77700A599F6 /* ios_api.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C7AD44B15B1D77700A599F6 /* ios_api.cpp */; }; + 4C7C584B15C31E6500CAE4F4 /* libboost.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C7C584A15C31E6500CAE4F4 /* libboost.a */; }; + 4CC971AC15C57DCE00359A2B /* libSalmon Engine.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C902A7815C5735700FBC901 /* libSalmon Engine.a */; }; + 4CCC0ECC15B30D6B005432FB /* CustomGLKView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CCC0ECB15B30D6B005432FB /* CustomGLKView.m */; }; + 4CE6A9D215B2F979006A3965 /* assets in Resources */ = {isa = PBXBuildFile; fileRef = 4CE6A9D115B2F979006A3965 /* assets */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 4C902A7715C5735700FBC901 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 4C902A7015C5735500FBC901 /* Salmon Engine.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 4C8CE90215B0A0F400078175; + remoteInfo = "Salmon Engine"; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 4C49B2B915B0991B003512CD /* salmontemplate.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = salmontemplate.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 4C49B2BD15B0991B003512CD /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 4C49B2BF15B0991B003512CD /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 4C49B2C115B0991B003512CD /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + 4C49B2C315B0991B003512CD /* GLKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLKit.framework; path = System/Library/Frameworks/GLKit.framework; sourceTree = SDKROOT; }; + 4C49B2C515B0991B003512CD /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; + 4C49B2C915B0991B003512CD /* template-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "template-Info.plist"; sourceTree = ""; }; + 4C49B2CB15B0991B003512CD /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 4C49B2CD15B0991B003512CD /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 4C49B2CF15B0991B003512CD /* template-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "template-Prefix.pch"; sourceTree = ""; }; + 4C49B2D015B0991B003512CD /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 4C49B2D115B0991B003512CD /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 4C49B2D715B0991B003512CD /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 4C49B2D815B0991B003512CD /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 4C49B2DB15B0991B003512CD /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController_iPhone.xib; sourceTree = ""; }; + 4C49B2DE15B0991B003512CD /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController_iPad.xib; sourceTree = ""; }; + 4C4C807415BA8F460037C6CE /* libsquirrel.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libsquirrel.a; path = "../../libs/SQUIRREL2_1_1_sqplus/build-ios/ios-device/libsquirrel.a"; sourceTree = ""; }; + 4C4C807615BA8F5B0037C6CE /* libz.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libz.a; path = "../../libs/zlib-1.2.7/build-ios/ios-device/libz.a"; sourceTree = ""; }; + 4C6EB44415C3CFD300316CB6 /* libpng.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpng.a; path = "../../libs/libpng-1.5.12/build-ios/ios-simulator/libpng.a"; sourceTree = ""; }; + 4C74848315C5AD6E0056EC44 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon.png; path = res/Icon.png; sourceTree = ""; }; + 4C74848415C5AD6E0056EC44 /* iTunesArtwork */ = {isa = PBXFileReference; lastKnownFileType = file; name = iTunesArtwork; path = res/iTunesArtwork; sourceTree = ""; }; + 4C74848515C5AD6E0056EC44 /* Splash-landscape.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Splash-landscape.png"; path = "res/Splash-landscape.png"; sourceTree = ""; }; + 4C74849615C5AF7C0056EC44 /* main_code.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main_code.cpp; path = ../jni/main_code.cpp; sourceTree = ""; }; + 4C74849715C5AF7C0056EC44 /* main_code.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = main_code.h; path = ../jni/main_code.h; sourceTree = ""; }; + 4C77831215BABD68003D5142 /* libvorbis-tremor-ios.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libvorbis-tremor-ios.a"; path = "../../libs/vorbis-tremor-ios/build-ios/ios-device/libvorbis-tremor-ios.a"; sourceTree = ""; }; + 4C77831415BABD8B003D5142 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; + 4C77831515BABD8B003D5142 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; + 4C7AD44B15B1D77700A599F6 /* ios_api.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ios_api.cpp; sourceTree = ""; }; + 4C7C584A15C31E6500CAE4F4 /* libboost.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libboost.a; path = "../../libs/boost_1_47_0/build-ios/ios-simulator/libboost.a"; sourceTree = ""; }; + 4C902A7015C5735500FBC901 /* Salmon Engine.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "Salmon Engine.xcodeproj"; path = "../../Engine/iOS/Salmon Engine/Salmon Engine.xcodeproj"; sourceTree = ""; }; + 4CCC0ECA15B30D6A005432FB /* CustomGLKView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomGLKView.h; sourceTree = ""; }; + 4CCC0ECB15B30D6B005432FB /* CustomGLKView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomGLKView.m; sourceTree = ""; }; + 4CCC0ECD15B310FB005432FB /* ios_api.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ios_api.h; sourceTree = ""; }; + 4CE6A9D115B2F979006A3965 /* assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = assets; path = ../assets; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 4C49B2B615B0991B003512CD /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 4CC971AC15C57DCE00359A2B /* libSalmon Engine.a in Frameworks */, + 4C77831815BABE26003D5142 /* AudioToolbox.framework in Frameworks */, + 4C77831915BABE26003D5142 /* OpenAL.framework in Frameworks */, + 4C49B2BE15B0991B003512CD /* UIKit.framework in Frameworks */, + 4C49B2C015B0991B003512CD /* Foundation.framework in Frameworks */, + 4C49B2C215B0991B003512CD /* CoreGraphics.framework in Frameworks */, + 4C49B2C415B0991B003512CD /* GLKit.framework in Frameworks */, + 4C49B2C615B0991B003512CD /* OpenGLES.framework in Frameworks */, + 4C4C807515BA8F460037C6CE /* libsquirrel.a in Frameworks */, + 4C4C807715BA8F5B0037C6CE /* libz.a in Frameworks */, + 4C77831315BABD68003D5142 /* libvorbis-tremor-ios.a in Frameworks */, + 4C7C584B15C31E6500CAE4F4 /* libboost.a in Frameworks */, + 4C6EB44515C3CFD300316CB6 /* libpng.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 4C49B2AE15B0991B003512CD = { + isa = PBXGroup; + children = ( + 4C902A7015C5735500FBC901 /* Salmon Engine.xcodeproj */, + 4C7B819515C40F770024D61A /* Libs */, + 4CC1FC3415B200130025C6F7 /* Resources */, + 4C49B2C715B0991B003512CD /* Sources */, + 4C49B2BC15B0991B003512CD /* Frameworks */, + 4C49B2BA15B0991B003512CD /* Products */, + ); + sourceTree = ""; + }; + 4C49B2BA15B0991B003512CD /* Products */ = { + isa = PBXGroup; + children = ( + 4C49B2B915B0991B003512CD /* salmontemplate.app */, + ); + name = Products; + sourceTree = ""; + }; + 4C49B2BC15B0991B003512CD /* Frameworks */ = { + isa = PBXGroup; + children = ( + 4C77831415BABD8B003D5142 /* AudioToolbox.framework */, + 4C77831515BABD8B003D5142 /* OpenAL.framework */, + 4C49B2BD15B0991B003512CD /* UIKit.framework */, + 4C49B2BF15B0991B003512CD /* Foundation.framework */, + 4C49B2C115B0991B003512CD /* CoreGraphics.framework */, + 4C49B2C315B0991B003512CD /* GLKit.framework */, + 4C49B2C515B0991B003512CD /* OpenGLES.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 4C49B2C715B0991B003512CD /* Sources */ = { + isa = PBXGroup; + children = ( + 4CE6A9E315B2F9A4006A3965 /* Game */, + 4CCC0ECD15B310FB005432FB /* ios_api.h */, + 4C7AD44B15B1D77700A599F6 /* ios_api.cpp */, + 4C49B2D015B0991B003512CD /* AppDelegate.h */, + 4C49B2D115B0991B003512CD /* AppDelegate.m */, + 4C49B2D715B0991B003512CD /* ViewController.h */, + 4C49B2D815B0991B003512CD /* ViewController.m */, + 4C49B2DA15B0991B003512CD /* ViewController_iPhone.xib */, + 4C49B2DD15B0991B003512CD /* ViewController_iPad.xib */, + 4C49B2C815B0991B003512CD /* Supporting Files */, + 4CCC0ECA15B30D6A005432FB /* CustomGLKView.h */, + 4CCC0ECB15B30D6B005432FB /* CustomGLKView.m */, + ); + name = Sources; + sourceTree = ""; + }; + 4C49B2C815B0991B003512CD /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 4C49B2C915B0991B003512CD /* template-Info.plist */, + 4C49B2CA15B0991B003512CD /* InfoPlist.strings */, + 4C49B2CD15B0991B003512CD /* main.m */, + 4C49B2CF15B0991B003512CD /* template-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 4C7B819515C40F770024D61A /* Libs */ = { + isa = PBXGroup; + children = ( + 4C6EB44415C3CFD300316CB6 /* libpng.a */, + 4C7C584A15C31E6500CAE4F4 /* libboost.a */, + 4C77831215BABD68003D5142 /* libvorbis-tremor-ios.a */, + 4C4C807615BA8F5B0037C6CE /* libz.a */, + 4C4C807415BA8F460037C6CE /* libsquirrel.a */, + ); + name = Libs; + sourceTree = ""; + }; + 4C902A7115C5735500FBC901 /* Products */ = { + isa = PBXGroup; + children = ( + 4C902A7815C5735700FBC901 /* libSalmon Engine.a */, + ); + name = Products; + sourceTree = ""; + }; + 4CC1FC3415B200130025C6F7 /* Resources */ = { + isa = PBXGroup; + children = ( + 4C74848315C5AD6E0056EC44 /* Icon.png */, + 4C74848415C5AD6E0056EC44 /* iTunesArtwork */, + 4C74848515C5AD6E0056EC44 /* Splash-landscape.png */, + 4CE6A9D115B2F979006A3965 /* assets */, + ); + name = Resources; + sourceTree = ""; + }; + 4CE6A9E315B2F9A4006A3965 /* Game */ = { + isa = PBXGroup; + children = ( + 4C74849615C5AF7C0056EC44 /* main_code.cpp */, + 4C74849715C5AF7C0056EC44 /* main_code.h */, + ); + name = Game; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 4C49B2B815B0991B003512CD /* salmontemplate */ = { + isa = PBXNativeTarget; + buildConfigurationList = 4C49B2E215B0991B003512CD /* Build configuration list for PBXNativeTarget "salmontemplate" */; + buildPhases = ( + 4C49B2B515B0991B003512CD /* Sources */, + 4C49B2B615B0991B003512CD /* Frameworks */, + 4C49B2B715B0991B003512CD /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = salmontemplate; + productName = doublehitballs; + productReference = 4C49B2B915B0991B003512CD /* salmontemplate.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 4C49B2B015B0991B003512CD /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0430; + }; + buildConfigurationList = 4C49B2B315B0991B003512CD /* Build configuration list for PBXProject "salmontemplate" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 4C49B2AE15B0991B003512CD; + productRefGroup = 4C49B2BA15B0991B003512CD /* Products */; + projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 4C902A7115C5735500FBC901 /* Products */; + ProjectRef = 4C902A7015C5735500FBC901 /* Salmon Engine.xcodeproj */; + }, + ); + projectRoot = ""; + targets = ( + 4C49B2B815B0991B003512CD /* salmontemplate */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXReferenceProxy section */ + 4C902A7815C5735700FBC901 /* libSalmon Engine.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libSalmon Engine.a"; + remoteRef = 4C902A7715C5735700FBC901 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + +/* Begin PBXResourcesBuildPhase section */ + 4C49B2B715B0991B003512CD /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4C49B2CC15B0991B003512CD /* InfoPlist.strings in Resources */, + 4C49B2DC15B0991B003512CD /* ViewController_iPhone.xib in Resources */, + 4C49B2DF15B0991B003512CD /* ViewController_iPad.xib in Resources */, + 4CE6A9D215B2F979006A3965 /* assets in Resources */, + 4C74848615C5AD6E0056EC44 /* Icon.png in Resources */, + 4C74848715C5AD6E0056EC44 /* iTunesArtwork in Resources */, + 4C74848815C5AD6E0056EC44 /* Splash-landscape.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 4C49B2B515B0991B003512CD /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4C49B2CE15B0991B003512CD /* main.m in Sources */, + 4C49B2D215B0991B003512CD /* AppDelegate.m in Sources */, + 4C49B2D915B0991B003512CD /* ViewController.m in Sources */, + 4C7AD44C15B1D77700A599F6 /* ios_api.cpp in Sources */, + 4CCC0ECC15B30D6B005432FB /* CustomGLKView.m in Sources */, + 4C74849815C5AF7C0056EC44 /* main_code.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 4C49B2CA15B0991B003512CD /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 4C49B2CB15B0991B003512CD /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + 4C49B2DA15B0991B003512CD /* ViewController_iPhone.xib */ = { + isa = PBXVariantGroup; + children = ( + 4C49B2DB15B0991B003512CD /* en */, + ); + name = ViewController_iPhone.xib; + sourceTree = ""; + }; + 4C49B2DD15B0991B003512CD /* ViewController_iPad.xib */ = { + isa = PBXVariantGroup; + children = ( + 4C49B2DE15B0991B003512CD /* en */, + ); + name = ViewController_iPad.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 4C49B2E015B0991B003512CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 4C49B2E115B0991B003512CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 4C49B2E315B0991B003512CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "template-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + TARGET_IOS, + TARGET_SALMON, + DEBUG, + "$(inherited)", + BOOST_NO_CXX11_NUMERIC_LIMITS, + ); + GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = ""; + "GCC_THUMB_SUPPORT[arch=armv6]" = ""; + HEADER_SEARCH_PATHS = ( + "$(SalmonEnginePath)", + "$(LibsPath)/lpng1510", + "$(LibsPath)/sqplus/sqplus", + "$(LibsPath)/sqplus/include", + "$(LibsPath)/boost_1_52_0", + ../jni, + "$(LibsPath)/vorbis-tremor-ios/vorbis", + ); + INFOPLIST_FILE = "template-Info.plist"; + LIBRARY_SEARCH_PATHS = ""; + "LIBRARY_SEARCH_PATHS[sdk=iphoneos*]" = ( + "$(LibsPath)/lpng1510/build-ios/ios-device", + "$(LibsPath)/boost_1_52_0/build-ios/ios-device", + "$(LibsPath)/sqplus/build-ios/ios-device", + "$(LibsPath)/zlib-1.2.6/build-ios/ios-device", + "$(LibsPath)/vorbis-tremor-ios/build-ios/ios-device", + ); + "LIBRARY_SEARCH_PATHS[sdk=iphonesimulator*]" = ( + "$(LibsPath)/lpng1510/build-ios/ios-simulator", + "$(LibsPath)/sqplus/build-ios/ios-simulator", + "$(LibsPath)/boost_1_52_0/build-ios/ios-simulator", + "$(LibsPath)/zlib-1.2.6/build-ios/ios-simulator", + "$(LibsPath)/vorbis-tremor-ios/build-ios/ios-simulator", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + SYMROOT = build; + TARGETED_DEVICE_FAMILY = 1; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + 4C49B2E415B0991B003512CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "template-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + TARGET_IOS, + TARGET_SALMON, + BOOST_NO_CXX11_NUMERIC_LIMITS, + ); + GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = ""; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + "GCC_THUMB_SUPPORT[arch=armv6]" = ""; + HEADER_SEARCH_PATHS = ( + "$(SalmonEnginePath)", + "$(LibsPath)/lpng1510", + "$(LibsPath)/sqplus/sqplus", + "$(LibsPath)/sqplus/include", + "$(LibsPath)/boost_1_52_0", + ../jni, + "$(LibsPath)/vorbis-tremor-ios/vorbis", + ); + INFOPLIST_FILE = "template-Info.plist"; + LIBRARY_SEARCH_PATHS = ""; + "LIBRARY_SEARCH_PATHS[sdk=iphoneos*]" = ( + "$(LibsPath)/lpng1510/build-ios/ios-device", + "$(LibsPath)/boost_1_52_0/build-ios/ios-device", + "$(LibsPath)/sqplus/build-ios/ios-device", + "$(LibsPath)/zlib-1.2.6/build-ios/ios-device", + "$(LibsPath)/vorbis-tremor-ios/build-ios/ios-device", + ); + "LIBRARY_SEARCH_PATHS[sdk=iphonesimulator*]" = ( + "$(LibsPath)/lpng1510/build-ios/ios-simulator", + "$(LibsPath)/sqplus/build-ios/ios-simulator", + "$(LibsPath)/boost_1_52_0/build-ios/ios-simulator", + "$(LibsPath)/zlib-1.2.6/build-ios/ios-simulator", + "$(LibsPath)/vorbis-tremor-ios/build-ios/ios-simulator", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = 1; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 4C49B2B315B0991B003512CD /* Build configuration list for PBXProject "salmontemplate" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4C49B2E015B0991B003512CD /* Debug */, + 4C49B2E115B0991B003512CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 4C49B2E215B0991B003512CD /* Build configuration list for PBXNativeTarget "salmontemplate" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4C49B2E315B0991B003512CD /* Debug */, + 4C49B2E415B0991B003512CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 4C49B2B015B0991B003512CD /* Project object */; +} diff --git a/Templates/SalmonUniversalTemplate/iOS/template-Info.plist b/Templates/SalmonUniversalTemplate/iOS/template-Info.plist new file mode 100644 index 0000000..d06ba45 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/iOS/template-Info.plist @@ -0,0 +1,50 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + Salmon Universal Template + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + Icon.png + CFBundleIdentifier + fishrungames.template + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + UILaunchImageFile + Splash-landscape.png + UIPrerenderedIcon + + UIRequiredDeviceCapabilities + + armv7 + + UIStatusBarHidden + + UISupportedInterfaceOrientations + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Templates/SalmonUniversalTemplate/iOS/template-Prefix.pch b/Templates/SalmonUniversalTemplate/iOS/template-Prefix.pch new file mode 100644 index 0000000..cd479f5 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/iOS/template-Prefix.pch @@ -0,0 +1,14 @@ +// +// Prefix header for all source files of the 'doublehitballs' target in the 'doublehitballs' project +// + +#import + +#ifndef __IPHONE_5_0 +#warning "This project uses features only available in iOS SDK 5.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/Templates/SalmonUniversalTemplate/jni/Android.mk b/Templates/SalmonUniversalTemplate/jni/Android.mk new file mode 100644 index 0000000..4b85a29 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/jni/Android.mk @@ -0,0 +1,77 @@ +# Copyright (C) 2009 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +LPATH := $(call my-dir) + +ENGINE_PATH = $(SalmonEnginePathCygwin) + +BOOST_PATH = $(LibsPathCygwin)/boost_1_47_0 + +OGG_PATH = $(LibsPathCygwin)/libogg-1.3.0 + +VORBIS_PATH = $(LibsPathCygwin)/libvorbis-1.3.2 + +SQUIRREL_PATH = $(LibsPathCygwin)/sqplus + +LIBPNG_PATH = $(LibsPathCygwin)/libpng_1.4.1_android + +ZIP_PATH = $(LibsPathCygwin)/julienr-libzip-android/jni + +#====== ENGINE AND LIBS ===================== + +include $(ENGINE_PATH)/Android_Salmon_Engine.mk + +#================= THE GAME ======================= + + +LOCAL_PATH:= $(LPATH) + +include $(CLEAR_VARS) + +LOCAL_CFLAGS := -DTARGET_ANDROID -DNOSOUND -DTARGET_SALMON -std=gnu++11 --std=c++11 +LOCAL_STATIC_LIBRARIES := boost +LOCAL_STATIC_LIBRARIES += squirrel +LOCAL_STATIC_LIBRARIES += png_lib +LOCAL_STATIC_LIBRARIES += zip +LOCAL_SHARED_LIBRARIES := SalmonEngine +LOCAL_SHARED_LIBRARIES += gnustl_shared +LOCAL_C_INCLUDES := $(ENGINE_PATH) +LOCAL_C_INCLUDES += $(BOOST_PATH) +LOCAL_C_INCLUDES += $(VORBIS_PATH)/include +LOCAL_C_INCLUDES += $(VORBIS_PATH)/include/vorbis +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/books +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/modes +LOCAL_C_INCLUDES += $(OGG_PATH)/include +LOCAL_C_INCLUDES += $(OGG_PATH)/include/ogg +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/include +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/sqplus +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/squirrel +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/sqstdlib +LOCAL_C_INCLUDES += $(LIBPNG_PATH) +LOCAL_C_INCLUDES += $(ZIP_PATH) +LOCAL_MODULE := SalmonJniTemplate +LOCAL_SRC_FILES := main_code.cpp +LOCAL_SRC_FILES += android_api.cpp + +LOCAL_LDLIBS := -lGLESv2 +LOCAL_LDLIBS += -llog -Wl + +#debug +#LOCAL_CFLAGS += -g -ggdb -O0 +#LOCAL_LDLIBS += -g -ggdb + +include $(BUILD_SHARED_LIBRARY) diff --git a/Templates/SalmonUniversalTemplate/jni/Application.mk b/Templates/SalmonUniversalTemplate/jni/Application.mk new file mode 100644 index 0000000..22476ec --- /dev/null +++ b/Templates/SalmonUniversalTemplate/jni/Application.mk @@ -0,0 +1,3 @@ +APP_STL := gnustl_shared +APP_CPPFLAGS += -fexceptions +APP_CPPFLAGS += -frtti diff --git a/Templates/SalmonUniversalTemplate/jni/android_api.cpp b/Templates/SalmonUniversalTemplate/jni/android_api.cpp new file mode 100644 index 0000000..93f9f2f --- /dev/null +++ b/Templates/SalmonUniversalTemplate/jni/android_api.cpp @@ -0,0 +1,128 @@ +#include "android_api.h" + +#include "main_code.h" +#include "boost\thread.hpp" + +boost::shared_ptr App(new TMyApplication); + +boost::mutex m; + +JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height) +{ + + m.lock(); + try + { + if (App->IsInited()) + { + App->OuterDeinit(); //Clean up what is left at previous launch (if applicable) + } + + App->OuterInit(width, height, 480.f, 320.f); + + App->Inited = true; + } + catch (...) + { + throw; + } + m.unlock(); +} + +JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_StopSounds(JNIEnv * env, jobject obj) +{ + +} + + +JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Update(JNIEnv * env, jobject obj, long dt) +{ +m.lock(); + try + { + if (App->IsInited()) + { + App->OuterDraw(); + App->OuterUpdate(dt); + } + + } + catch (...) + { + throw; + } + m.unlock(); + +} + +JNIEXPORT int JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_IsInited(JNIEnv * env, jobject obj) +{ + + if (App->IsInited()) + { + return 1; + } + else + { + return 0; + } + +} + +JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Destroy(JNIEnv * env, jobject obj) +{ +m.lock(); + try + { + if (App->IsInited()) + { + App->OuterDeinit(); + App->Inited = false; + } + + } + catch (...) + { + throw; + } + m.unlock(); +} + + +JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapDown(JNIEnv * env, jobject obj, float x, float y, long time) +{ +m.lock(); + try + { + Renderer->MoveDist(1.0f); + } + catch (...) + { + throw; + } + m.unlock(); +} + + +JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapUp(JNIEnv * env, jobject obj, float x, float y, long time) +{ +} + +JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, float x, float y, long time) +{ +} + +JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnFling(JNIEnv * env, jobject obj, jfloat velocityX, jfloat velocityY, long time) +{ + +} + +JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnScroll(JNIEnv * env, jobject obj, jfloat distanceX, jfloat distanceY, long time) +{ + +} + +JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnKeyPress(JNIEnv * env, jobject obj, jint keyCode) +{ + //App->OnKeyPress(keyCode); +} diff --git a/Templates/SalmonUniversalTemplate/jni/android_api.h b/Templates/SalmonUniversalTemplate/jni/android_api.h new file mode 100644 index 0000000..c67dcd6 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/jni/android_api.h @@ -0,0 +1,33 @@ +#ifndef ANDROID_API_H_INCLUDED +#define ANDROID_API_H_INCLUDED + +#include +#include + +#include +#include +#include + +#include "boost/shared_ptr.hpp" + +#include "main_code.h" + +using namespace SE; + + +extern "C" { + JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height); + JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_StopSounds(JNIEnv * env, jobject obj); + JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Update(JNIEnv * env, jobject obj, long dt); + JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_Destroy(JNIEnv * env, jobject obj); + JNIEXPORT int JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_IsInited(JNIEnv * env, jobject obj); + JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapDown(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time); + JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapUp(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time); + JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, jfloat x, jfloat y, long time); + JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnFling(JNIEnv * env, jobject obj, jfloat velocityX, jfloat velocityY, long time); + JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnScroll(JNIEnv * env, jobject obj, jfloat distanceX, jfloat distanceY, long time); + JNIEXPORT void JNICALL Java_fishrungames_salmonjnitemplate_JniWrapper_OnKeyPress(JNIEnv * env, jobject obj, jint keyCode); +}; + + +#endif diff --git a/Templates/SalmonUniversalTemplate/jni/main_code.cpp b/Templates/SalmonUniversalTemplate/jni/main_code.cpp new file mode 100644 index 0000000..3acf7e2 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/jni/main_code.cpp @@ -0,0 +1,91 @@ +#include "main_code.h" + +#ifdef TARGET_ANDROID +#include "android_api.h" +#endif + +#include +#include +#include +#include + +#include "include/Engine.h" + +#include "main_code.h" + + +void TMyApplication::InnerInit() +{ + + *Console<<"Inner init go!\n"; + +#ifdef TARGET_ANDROID + ResourceManager->PathToResources = ""; +#endif +#ifdef TARGET_WIN32 +#ifdef NDEBUG + ResourceManager->PathToResources = "resources/"; +#else + ResourceManager->PathToResources = "../../../assets/"; +#endif +#endif +#ifdef TARGET_IOS + ResourceManager->PathToResources = "assets/"; +#endif + + ResourceManager->TexList.AddTexture(CONST_CONSOLE_TEX_NAME); + + ResourceManager->ShaderManager.AddShader("DefaultShader", "gui_transparent.vertex", "gui_transparent.fragment"); + + Renderer->PushShader("DefaultShader"); + + ResourceManager->FontManager.AddFont("droid_sans14", "droid_sans14_font_bitmap.bmp32", "droid_sans14_font_charmap.txt"); + ResourceManager->FontManager.PushFont("droid_sans14"); + + ResourceManager->SoundManager.LoadMusic("level1ogg.ogg"); + + ResourceManager->SoundManager.LoadSound("shot.wav"); + + Renderer->MovePhi(pi/6); + Renderer->MoveDist(6.f); + + ResourceManager->LightManager.SetLightDirection(vec3(-1,0,-1)); + ResourceManager->LightManager.SetLightColor(vec4(1,0,0,1)); + + ResourceManager->TexList.AddTexture("bt_box_yellow.bmp"); + ResourceManager->FlexModelManager.LoadModelFromXml("model.xml"); + + FlexModel = ResourceManager->FlexModelManager.InstanciateModel("model.xml"); + + FlexModel.MoveModel(vec3(1, -4, -4)); + FlexModel.ScaleModel(0.4f); + FlexModel.RefreshBuffer(); + + //Uncomment to start music playing + //ResourceManager->SoundManager.PlayMusic("level1ogg.ogg"); + + *Console<<"Inner init end!\n"; +} + +void TMyApplication::InnerDeinit() +{ +} + + +void TMyApplication::InnerDraw() +{ + + glClearColor(0,0,0,1); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + Renderer->SetGLCamView(); + FlexModel.Draw(); + +} + + +void TMyApplication::InnerUpdate(cardinal dt) +{ + +} + diff --git a/Templates/SalmonUniversalTemplate/jni/main_code.h b/Templates/SalmonUniversalTemplate/jni/main_code.h new file mode 100644 index 0000000..b5346c3 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/jni/main_code.h @@ -0,0 +1,54 @@ +#ifndef MAIN_CODE_H_INCLUDED +#define MAIN_CODE_H_INCLUDED + + +#include +#include +#include + +#ifdef TARGET_ANDROID + +#include +#include +#include +#endif + +#include "boost/shared_ptr.hpp" +#include "boost/thread/thread.hpp" +#include "boost/assign.hpp" +#include "boost/bind.hpp" +#include "boost/asio.hpp" +#include "boost/signal.hpp" + +#include "include/Engine.h" + +using namespace SE; + + +class TMyApplication : public TApplication +{ +protected: + +public: + bool Inited; + + TFlexModel FlexModel; + + TMyApplication() : TApplication(), Inited(false) { } + + + virtual void InnerInit(); + + virtual void InnerDeinit(); + + virtual void InnerDraw(); + + virtual void InnerUpdate(cardinal dt); + + bool IsInited() { return Inited; } + + +}; + + +#endif diff --git a/Templates/SalmonUniversalTemplate/res/drawable-hdpi/ic_menu_template.png b/Templates/SalmonUniversalTemplate/res/drawable-hdpi/ic_menu_template.png new file mode 100644 index 0000000..1e28f93 Binary files /dev/null and b/Templates/SalmonUniversalTemplate/res/drawable-hdpi/ic_menu_template.png differ diff --git a/Templates/SalmonUniversalTemplate/res/drawable-ldpi/ic_menu_template.png b/Templates/SalmonUniversalTemplate/res/drawable-ldpi/ic_menu_template.png new file mode 100644 index 0000000..6a93cf2 Binary files /dev/null and b/Templates/SalmonUniversalTemplate/res/drawable-ldpi/ic_menu_template.png differ diff --git a/Templates/SalmonUniversalTemplate/res/drawable-mdpi/ic_menu_template.png b/Templates/SalmonUniversalTemplate/res/drawable-mdpi/ic_menu_template.png new file mode 100644 index 0000000..7c1cab2 Binary files /dev/null and b/Templates/SalmonUniversalTemplate/res/drawable-mdpi/ic_menu_template.png differ diff --git a/Templates/SalmonUniversalTemplate/res/values/strings.xml b/Templates/SalmonUniversalTemplate/res/values/strings.xml new file mode 100644 index 0000000..33d1455 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/res/values/strings.xml @@ -0,0 +1,4 @@ + + + AndroidJniTemplate + diff --git a/Templates/SalmonUniversalTemplate/src/fishrungames/salmonjnitemplate/GLView.java b/Templates/SalmonUniversalTemplate/src/fishrungames/salmonjnitemplate/GLView.java new file mode 100644 index 0000000..32ac866 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/src/fishrungames/salmonjnitemplate/GLView.java @@ -0,0 +1,72 @@ +package fishrungames.salmonjnitemplate; + + +import java.util.Calendar; + +import android.content.Context; +import android.opengl.GLSurfaceView; + +import javax.microedition.khronos.egl.EGLConfig; +import javax.microedition.khronos.opengles.GL10; + +import fishrungames.engine.GLViewAncestor; + +class GLView extends GLViewAncestor +{ + static long lastTimeStamp; + static boolean gameIsInited = false; + + public GLView(Context context) + { + //Change this method? Don't forget to change method below! + super(context); + init(false, 0, 0); + } + + public GLView(Context context, boolean translucent, int depth, int stencil) + { + //Change this method? Don't forget to change method above! + super(context); + init(translucent, depth, stencil); + } + + public void init(boolean translucent, int depth, int stencil) + { + super.init(translucent, depth, stencil); + setRenderer(new Renderer()); + Calendar c = Calendar.getInstance(); + lastTimeStamp = c.getTimeInMillis(); + gameIsInited = true; + } + + private static class Renderer implements GLSurfaceView.Renderer + { + public void onDrawFrame(GL10 gl) + { + if (gameIsInited) + { + Calendar c = Calendar.getInstance(); + + long currentTimeStamp = c.getTimeInMillis(); + + JniWrapper.Update(currentTimeStamp - lastTimeStamp); + + lastTimeStamp = currentTimeStamp; + } + } + + public void onSurfaceChanged(GL10 gl, int width, int height) + { + + + //JniWrapper.Destroy(); + + JniWrapper.Init(width,height); + } + + public void onSurfaceCreated(GL10 gl, EGLConfig config) + { + //Do nothing. + } + } +} \ No newline at end of file diff --git a/Templates/SalmonUniversalTemplate/src/fishrungames/salmonjnitemplate/JniWrapper.java b/Templates/SalmonUniversalTemplate/src/fishrungames/salmonjnitemplate/JniWrapper.java new file mode 100644 index 0000000..c52c10f --- /dev/null +++ b/Templates/SalmonUniversalTemplate/src/fishrungames/salmonjnitemplate/JniWrapper.java @@ -0,0 +1,23 @@ +package fishrungames.salmonjnitemplate; + +public class JniWrapper +{ + static { + System.loadLibrary("SalmonJniTemplate"); + } + + + public static native void Init(int width, int height); + public static native void Update(long dt); + public static native void StopSounds(); + public static native void Destroy(); + public static native int IsInited(); + public static native void OnTapDown(float x, float y, long time); + public static native void OnTapUp(float x, float y, long time); + public static native void OnTapMove(float x, float y, long time); + + public static native void OnFling(float velocityX, float velocityY, long time); + public static native void OnScroll(float distanceX, float distanceY, long time); + + public static native void OnKeyPress(int keyCode); +} \ No newline at end of file diff --git a/Templates/SalmonUniversalTemplate/src/fishrungames/salmonjnitemplate/MainActivity.java b/Templates/SalmonUniversalTemplate/src/fishrungames/salmonjnitemplate/MainActivity.java new file mode 100644 index 0000000..0d74bb5 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/src/fishrungames/salmonjnitemplate/MainActivity.java @@ -0,0 +1,191 @@ +package fishrungames.salmonjnitemplate; + +import fishrungames.engine.FileWrapper; + +//Deprecated +//import fishrungames.androidjnitemplate.R; + +import android.app.Activity; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.os.Bundle; + +import android.view.GestureDetector; +import android.view.KeyEvent; +import android.view.GestureDetector.SimpleOnGestureListener; +import android.view.MotionEvent; +/* +import android.content.res.Resources; +import android.content.res.XmlResourceParser; +import android.util.AttributeSet; +import android.util.Xml; +import android.inputmethodservice.Keyboard; +import android.inputmethodservice.KeyboardView; +import android.view.ViewGroup.LayoutParams; +import android.widget.LinearLayout; +*/ + +//Deprecated +//import java.lang.reflect.Field; + + +public class MainActivity extends Activity +{ + + GLView mView; + + boolean IsScrolling = false; + + private GestureDetector gestureDetector; + + @Override + protected void onCreate(Bundle icicle) + { + + super.onCreate(icicle); + + gestureDetector = new GestureDetector(new MyGestureListener()); + + FileWrapper.LoadSalmonEngineLibrary(); + + FileWrapper.SetActivityInstance(this); + FileWrapper.SetupEnviroment(); + + /* + * Deprecated + try + { + for (Field f : R.raw.class.getFields()) + { + FileWrapper.AddToFileMap(f.getName(), f.getInt(null)); + } + + + } catch (IllegalArgumentException e) + { + FileWrapper.ConsoleOut("IllegalArgumentException\n"); + onStop(); + } catch (IllegalAccessException e) + { + FileWrapper.ConsoleOut("IllegalAccessException\n"); + onStop(); + }*/ + + String apkFilePath = null; + ApplicationInfo appInfo = null; + PackageManager packMgmr = this.getPackageManager(); + try { + appInfo = packMgmr.getApplicationInfo("fishrungames.salmonjnitemplate", 0); + } catch (NameNotFoundException e) { + + e.printStackTrace(); + throw new RuntimeException("Unable to locate assets, aborting..."); + } + apkFilePath = appInfo.sourceDir; + + FileWrapper.SetupApkFilePath(apkFilePath); + + mView = new GLView(getApplication()); + + setContentView(mView); + + } + + @Override + protected void onPause() + { + JniWrapper.Destroy(); + super.onPause(); + mView.onPause(); + } + + @Override + protected void onResume() + { + //Don't write anything here! + super.onResume(); + mView.onResume(); + } + + @Override + protected void onStop() + { + //Don't write anything here! + super.onStop(); + } + + public boolean onKeyDown(int keyCode, KeyEvent event) + { + int ascii_keycode = keyCode; + + if (keyCode == KeyEvent.KEYCODE_DEL) + { + ascii_keycode = 8; //Hack - getUnicodeChar does not recognize backspace + } + else + { + ascii_keycode = event.getUnicodeChar(); + } + + JniWrapper.OnKeyPress(ascii_keycode); + return super.onKeyDown(keyCode, event); + } + + public boolean onTouchEvent(MotionEvent event) + { + if (gestureDetector.onTouchEvent(event)) + { + return true; + } + + if (event.getAction() == MotionEvent.ACTION_UP) + { + float x = event.getX(); + float y = (float) mView.getHeight() - event.getY(); + + if (IsScrolling) + { + IsScrolling = false; + } + + JniWrapper.OnTapUp(x, y, event.getEventTime()); + + } + return true; + } + + class MyGestureListener extends SimpleOnGestureListener + { + + @Override + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, + float velocityY) + { + JniWrapper.OnFling(velocityX, velocityY, e2.getEventTime()); + return true; + } + + public boolean onScroll(MotionEvent e1, MotionEvent e2, + float distanceX, float distanceY) + { + + JniWrapper.OnScroll(distanceX, distanceY, e2.getEventTime()); + IsScrolling = true; + return true; + } + + public boolean onDown(MotionEvent event) + { + + float x = event.getX(); + float y = (float) mView.getHeight() - event.getY(); + + JniWrapper.OnTapDown(x, y, event.getEventTime()); + + return true; + } + + } + +} \ No newline at end of file diff --git a/Templates/SalmonUniversalTemplate/windows/SalmonTemplate/Template.sln b/Templates/SalmonUniversalTemplate/windows/SalmonTemplate/Template.sln new file mode 100644 index 0000000..2f41155 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/windows/SalmonTemplate/Template.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Template", "Template\Template.vcxproj", "{0080A3E1-DFBF-4557-B198-E6D5D7724393}" + ProjectSection(ProjectDependencies) = postProject + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20} = {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Salmon Engine", "..\..\..\..\Engine\Salmon Engine\Salmon Engine.vcxproj", "{48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug_nosound|Win32 = Debug_nosound|Win32 + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug_nosound|Win32.ActiveCfg = Debug|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug_nosound|Win32.Build.0 = Debug|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug|Win32.ActiveCfg = Debug|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug|Win32.Build.0 = Debug|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Release|Win32.ActiveCfg = Release|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Release|Win32.Build.0 = Release|Win32 + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Debug_nosound|Win32.ActiveCfg = Debug_nosound|Win32 + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Debug_nosound|Win32.Build.0 = Debug_nosound|Win32 + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Debug|Win32.ActiveCfg = Debug|Win32 + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Debug|Win32.Build.0 = Debug|Win32 + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Release|Win32.ActiveCfg = Release|Win32 + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Templates/SalmonUniversalTemplate/windows/SalmonTemplate/Template/Template.vcxproj b/Templates/SalmonUniversalTemplate/windows/SalmonTemplate/Template/Template.vcxproj new file mode 100644 index 0000000..5da6070 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/windows/SalmonTemplate/Template/Template.vcxproj @@ -0,0 +1,88 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {0080A3E1-DFBF-4557-B198-E6D5D7724393} + Template + + + + Application + true + NotSet + + + Application + false + true + NotSet + + + + + + + + + + + + + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SalmonEnginePath)include + $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(SalmonEnginePath)$(Configuration) + + + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SalmonEnginePath)include + $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(SalmonEnginePath)$(Configuration) + + + + Level3 + Disabled + ../../../jni;$(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;$(LibsPath)\DirectXsdk\Include;$(LibsPath)\lpng1510 + TARGET_WIN32;TARGET_SALMON;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501;DEBUG + + + true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;opengl32.lib;glu32.lib;Salmon Engine.lib;libogg_static.lib;libvorbis_static.lib;libvorbisfile_static.lib;zlib.lib;libpng15.lib;sqplusD.lib;squirrelD.lib;sqdbglibD.lib;sqstdlibD.lib;dsound.lib;dxguid.lib;%(AdditionalDependencies) + $(LibsPath)\boost_1_52_0\boost_windows\libs_engine\$(Configuration);$(LibsPath)\libogg-1.3.0\win32\VS2010\Win32\$(Configuration);$(LibsPath)\libvorbis-1.3.2\win32\VS2010\Win32\$(Configuration);$(LibsPath)\sqplus\lib;$(LibsPath)\DirectXsdk\Lib\x86;$(LibsPath)\lpng1510\projects\vstudio\Debug Library + + + + + Level3 + MaxSpeed + true + true + ../../../jni;$(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;$(LibsPath)\DirectXsdk\Include;$(LibsPath)\lpng1510 + TARGET_WIN32;TARGET_SALMON;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501;NDEBUG + + + true + true + true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;opengl32.lib;glu32.lib;Salmon Engine.lib;libogg_static.lib;libvorbis_static.lib;libvorbisfile_static.lib;zlib.lib;libpng15.lib;sqplus.lib;squirrel.lib;sqdbglib.lib;sqstdlib.lib;dsound.lib;dxguid.lib;%(AdditionalDependencies) + $(LibsPath)\boost_1_52_0\boost_windows\libs_engine\$(Configuration);$(LibsPath)\libogg-1.3.0\win32\VS2010\Win32\$(Configuration);$(LibsPath)\libvorbis-1.3.2\win32\VS2010\Win32\$(Configuration);$(LibsPath)\sqplus\lib;$(LibsPath)\DirectXsdk\Lib\x86;$(LibsPath)\lpng1510\projects\vstudio\Release Library + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Templates/SalmonUniversalTemplate/windows/SalmonTemplate/Template/main.cpp b/Templates/SalmonUniversalTemplate/windows/SalmonTemplate/Template/main.cpp new file mode 100644 index 0000000..1eb1c2b --- /dev/null +++ b/Templates/SalmonUniversalTemplate/windows/SalmonTemplate/Template/main.cpp @@ -0,0 +1,16 @@ +#include "main.h" + +#include "main_code.h" + +int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst, + LPSTR lpszCmdLine, int nCmdShow) +{ + //Create application + TMyApplication Application; + + Application.Width = 480; + Application.Height = 320; + + //Start application + return MainLoop(Application); +} \ No newline at end of file diff --git a/Templates/SalmonUniversalTemplate/windows/SalmonTemplate/Template/main.h b/Templates/SalmonUniversalTemplate/windows/SalmonTemplate/Template/main.h new file mode 100644 index 0000000..9939a50 --- /dev/null +++ b/Templates/SalmonUniversalTemplate/windows/SalmonTemplate/Template/main.h @@ -0,0 +1,3 @@ +#pragma once + +#include "Engine.h" diff --git a/Templates/SalmonWallpaperTemplate/.classpath b/Templates/SalmonWallpaperTemplate/.classpath new file mode 100644 index 0000000..5bdb3d8 --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/Templates/SalmonWallpaperTemplate/.project b/Templates/SalmonWallpaperTemplate/.project new file mode 100644 index 0000000..d1ffe54 --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/.project @@ -0,0 +1,33 @@ + + + SLWP + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/Templates/SalmonWallpaperTemplate/AndroidManifest.xml b/Templates/SalmonWallpaperTemplate/AndroidManifest.xml new file mode 100644 index 0000000..816781c --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Templates/SalmonWallpaperTemplate/assets/bkg_blue.png b/Templates/SalmonWallpaperTemplate/assets/bkg_blue.png new file mode 100644 index 0000000..893a6a5 Binary files /dev/null and b/Templates/SalmonWallpaperTemplate/assets/bkg_blue.png differ diff --git a/Templates/SalmonWallpaperTemplate/assets/bkg_red.png b/Templates/SalmonWallpaperTemplate/assets/bkg_red.png new file mode 100644 index 0000000..cd1d8c3 Binary files /dev/null and b/Templates/SalmonWallpaperTemplate/assets/bkg_red.png differ diff --git a/Templates/SalmonWallpaperTemplate/assets/bt_box_yellow.bmp b/Templates/SalmonWallpaperTemplate/assets/bt_box_yellow.bmp new file mode 100644 index 0000000..b7a2d6f Binary files /dev/null and b/Templates/SalmonWallpaperTemplate/assets/bt_box_yellow.bmp differ diff --git a/Templates/SalmonWallpaperTemplate/assets/console_bkg.bmp b/Templates/SalmonWallpaperTemplate/assets/console_bkg.bmp new file mode 100644 index 0000000..d32ee4c Binary files /dev/null and b/Templates/SalmonWallpaperTemplate/assets/console_bkg.bmp differ diff --git a/Templates/SalmonWallpaperTemplate/assets/gui_transparent.fragment b/Templates/SalmonWallpaperTemplate/assets/gui_transparent.fragment new file mode 100644 index 0000000..bd2926c --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/assets/gui_transparent.fragment @@ -0,0 +1,10 @@ +precision lowp float; + +uniform sampler2D Texture; +varying vec2 texCoord; + +void main() +{ + vec4 texColor = texture2D(Texture,texCoord).rgba; + gl_FragColor = vec4(texColor.rgb, texColor.a); +} diff --git a/Templates/SalmonWallpaperTemplate/assets/gui_transparent.vertex b/Templates/SalmonWallpaperTemplate/assets/gui_transparent.vertex new file mode 100644 index 0000000..ad425c2 --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/assets/gui_transparent.vertex @@ -0,0 +1,11 @@ +attribute vec3 vPosition; +attribute vec2 vTexCoord; +varying vec2 texCoord; +uniform mat4 ProjectionMatrix; + +void main() +{ + //480x320 + gl_Position = ProjectionMatrix * vec4(vPosition.xyz, 1.0); + texCoord = vTexCoord; +} \ No newline at end of file diff --git a/Templates/SalmonWallpaperTemplate/assets/model.xml b/Templates/SalmonWallpaperTemplate/assets/model.xml new file mode 100644 index 0000000..a406ac9 --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/assets/model.xml @@ -0,0 +1,1725 @@ + + + + + + +1.15, 0.0, 0.15 +1.15, 0.0, 6.05 +-1.15, 0.0, 6.05 +-1.15, 0.0, 6.05 +-1.15, 0.0, 0.15 +1.15, 0.0, 0.15 +1.15, 2.2, 0.15 +-1.15, 2.2, 0.15 +-1.15, 2.2, 6.05 +-1.15, 2.2, 6.05 +1.15, 2.2, 6.05 +1.15, 2.2, 0.15 +1.15, 2.2, 0.15 +1.15, 2.2, 6.05 +1.15, 0.0, 6.05 +1.15, 0.0, 6.05 +1.15, 0.0, 0.15 +1.15, 2.2, 0.15 +-1.15, 2.2, 0.15 +1.15, 2.2, 0.15 +1.15, 0.0, 0.15 +1.15, 0.0, 0.15 +-1.15, 0.0, 0.15 +-1.15, 2.2, 0.15 +-1.15, 2.2, 6.05 +-1.15, 2.2, 0.15 +-1.15, 0.0, 0.15 +-1.15, 0.0, 0.15 +-1.15, 0.0, 6.05 +-1.15, 2.2, 6.05 +-1.15, 0.0, 6.05 +1.15, 0.0, 6.05 +1.05, 0.0900212, 6.05 +1.05, 0.0900212, 6.05 +-1.05, 0.0900212, 6.05 +-1.15, 0.0, 6.05 +1.15, 0.0, 6.05 +1.15, 2.2, 6.05 +1.05, 2.09437, 6.05 +1.05, 2.09437, 6.05 +1.05, 0.0900212, 6.05 +1.15, 0.0, 6.05 +1.15, 2.2, 6.05 +-1.15, 2.2, 6.05 +-1.05, 2.09437, 6.05 +-1.05, 2.09437, 6.05 +1.05, 2.09437, 6.05 +1.15, 2.2, 6.05 +-1.15, 2.2, 6.05 +-1.15, 0.0, 6.05 +-1.05, 0.0900212, 6.05 +-1.05, 0.0900212, 6.05 +-1.05, 2.09437, 6.05 +-1.15, 2.2, 6.05 +0.61422, 0.0, 6.07288 +0.611504, 0.0, 6.06452 +0.611504, 2.18832, 6.06452 +0.611504, 2.18832, 6.06452 +0.61422, 2.18832, 6.07288 +0.61422, 0.0, 6.07288 +0.588496, 0.0, 6.06452 +0.58578, 0.0, 6.07288 +0.58578, 2.18832, 6.07288 +0.58578, 2.18832, 6.07288 +0.588496, 2.18832, 6.06452 +0.588496, 0.0, 6.06452 +0.58578, 0.0, 6.07288 +0.588496, 0.0, 6.08123 +0.588496, 2.18832, 6.08123 +0.588496, 2.18832, 6.08123 +0.58578, 2.18832, 6.07288 +0.58578, 0.0, 6.07288 +0.588496, 0.0, 6.08123 +0.595606, 0.0, 6.0864 +0.595606, 2.18832, 6.0864 +0.595606, 2.18832, 6.0864 +0.588496, 2.18832, 6.08123 +0.588496, 0.0, 6.08123 +0.595606, 0.0, 6.0864 +0.604394, 0.0, 6.0864 +0.604394, 2.18832, 6.0864 +0.604394, 2.18832, 6.0864 +0.595606, 2.18832, 6.0864 +0.595606, 0.0, 6.0864 +0.604394, 0.0, 6.0864 +0.611504, 0.0, 6.08123 +0.611504, 2.18832, 6.08123 +0.611504, 2.18832, 6.08123 +0.604394, 2.18832, 6.0864 +0.604394, 0.0, 6.0864 +0.604394, 0.0, 6.0864 +0.595606, 0.0, 6.0864 +0.588496, 0.0, 6.08123 +0.588496, 0.0, 6.08123 +0.58578, 0.0, 6.07288 +0.588496, 0.0, 6.06452 +0.588496, 0.0, 6.06452 +0.595606, 0.0, 6.05935 +0.604394, 0.0, 6.05935 +0.604394, 0.0, 6.05935 +0.611504, 0.0, 6.06452 +0.61422, 0.0, 6.07288 +0.588496, 0.0, 6.06452 +0.604394, 0.0, 6.05935 +0.61422, 0.0, 6.07288 +0.588496, 0.0, 6.08123 +0.588496, 0.0, 6.06452 +0.61422, 0.0, 6.07288 +0.604394, 0.0, 6.0864 +0.588496, 0.0, 6.08123 +0.61422, 0.0, 6.07288 +0.611504, 0.0, 6.08123 +0.604394, 0.0, 6.0864 +0.61422, 0.0, 6.07288 +0.611504, 2.18832, 6.06452 +0.604394, 2.18832, 6.05935 +0.595606, 2.18832, 6.05935 +0.595606, 2.18832, 6.05935 +0.588496, 2.18832, 6.06452 +0.58578, 2.18832, 6.07288 +0.58578, 2.18832, 6.07288 +0.588496, 2.18832, 6.08123 +0.595606, 2.18832, 6.0864 +0.595606, 2.18832, 6.0864 +0.604394, 2.18832, 6.0864 +0.611504, 2.18832, 6.08123 +0.58578, 2.18832, 6.07288 +0.595606, 2.18832, 6.0864 +0.611504, 2.18832, 6.08123 +0.595606, 2.18832, 6.05935 +0.58578, 2.18832, 6.07288 +0.611504, 2.18832, 6.08123 +0.611504, 2.18832, 6.06452 +0.595606, 2.18832, 6.05935 +0.611504, 2.18832, 6.08123 +0.61422, 2.18832, 6.07288 +0.611504, 2.18832, 6.06452 +0.611504, 2.18832, 6.08123 +0.215692, 0.0, 6.07288 +0.212695, 0.0, 6.06365 +0.212695, 2.18832, 6.06365 +0.212695, 2.18832, 6.06365 +0.215692, 2.18832, 6.07288 +0.215692, 0.0, 6.07288 +0.187305, 0.0, 6.06365 +0.184308, 0.0, 6.07288 +0.184308, 2.18832, 6.07288 +0.184308, 2.18832, 6.07288 +0.187305, 2.18832, 6.06365 +0.187305, 0.0, 6.06365 +0.184308, 0.0, 6.07288 +0.187305, 0.0, 6.0821 +0.187305, 2.18832, 6.0821 +0.187305, 2.18832, 6.0821 +0.184308, 2.18832, 6.07288 +0.184308, 0.0, 6.07288 +0.187305, 0.0, 6.0821 +0.195151, 0.0, 6.0878 +0.195151, 2.18832, 6.0878 +0.195151, 2.18832, 6.0878 +0.187305, 2.18832, 6.0821 +0.187305, 0.0, 6.0821 +0.195151, 0.0, 6.0878 +0.204849, 0.0, 6.0878 +0.204849, 2.18832, 6.0878 +0.204849, 2.18832, 6.0878 +0.195151, 2.18832, 6.0878 +0.195151, 0.0, 6.0878 +0.204849, 0.0, 6.0878 +0.212695, 0.0, 6.0821 +0.212695, 2.18832, 6.0821 +0.212695, 2.18832, 6.0821 +0.204849, 2.18832, 6.0878 +0.204849, 0.0, 6.0878 +0.204849, 0.0, 6.0878 +0.195151, 0.0, 6.0878 +0.187305, 0.0, 6.0821 +0.187305, 0.0, 6.0821 +0.184308, 0.0, 6.07288 +0.187305, 0.0, 6.06365 +0.187305, 0.0, 6.06365 +0.195151, 0.0, 6.05795 +0.204849, 0.0, 6.05795 +0.204849, 0.0, 6.05795 +0.212695, 0.0, 6.06365 +0.215692, 0.0, 6.07288 +0.187305, 0.0, 6.06365 +0.204849, 0.0, 6.05795 +0.215692, 0.0, 6.07288 +0.187305, 0.0, 6.0821 +0.187305, 0.0, 6.06365 +0.215692, 0.0, 6.07288 +0.204849, 0.0, 6.0878 +0.187305, 0.0, 6.0821 +0.215692, 0.0, 6.07288 +0.212695, 0.0, 6.0821 +0.204849, 0.0, 6.0878 +0.215692, 0.0, 6.07288 +0.212695, 2.18832, 6.06365 +0.204849, 2.18832, 6.05795 +0.195151, 2.18832, 6.05795 +0.195151, 2.18832, 6.05795 +0.187305, 2.18832, 6.06365 +0.184308, 2.18832, 6.07288 +0.184308, 2.18832, 6.07288 +0.187305, 2.18832, 6.0821 +0.195151, 2.18832, 6.0878 +0.195151, 2.18832, 6.0878 +0.204849, 2.18832, 6.0878 +0.212695, 2.18832, 6.0821 +0.184308, 2.18832, 6.07288 +0.195151, 2.18832, 6.0878 +0.212695, 2.18832, 6.0821 +0.195151, 2.18832, 6.05795 +0.184308, 2.18832, 6.07288 +0.212695, 2.18832, 6.0821 +0.212695, 2.18832, 6.06365 +0.195151, 2.18832, 6.05795 +0.212695, 2.18832, 6.0821 +0.215692, 2.18832, 6.07288 +0.212695, 2.18832, 6.06365 +0.212695, 2.18832, 6.0821 +-0.184136, 0.0, 6.07288 +-0.187166, 0.0, 6.06355 +-0.187166, 2.18832, 6.06355 +-0.187166, 2.18832, 6.06355 +-0.184136, 2.18832, 6.07288 +-0.184136, 0.0, 6.07288 +-0.215864, 0.0, 6.07288 +-0.212834, 0.0, 6.0822 +-0.212834, 2.18832, 6.0822 +-0.212834, 2.18832, 6.0822 +-0.215864, 2.18832, 6.07288 +-0.215864, 0.0, 6.07288 +-0.212834, 0.0, 6.0822 +-0.204902, 0.0, 6.08796 +-0.204902, 2.18832, 6.08796 +-0.204902, 2.18832, 6.08796 +-0.212834, 2.18832, 6.0822 +-0.212834, 0.0, 6.0822 +-0.204902, 0.0, 6.08796 +-0.195098, 0.0, 6.08796 +-0.195098, 2.18832, 6.08796 +-0.195098, 2.18832, 6.08796 +-0.204902, 2.18832, 6.08796 +-0.204902, 0.0, 6.08796 +-0.195098, 0.0, 6.08796 +-0.187166, 0.0, 6.0822 +-0.187166, 2.18832, 6.0822 +-0.187166, 2.18832, 6.0822 +-0.195098, 2.18832, 6.08796 +-0.195098, 0.0, 6.08796 +-0.187166, 0.0, 6.0822 +-0.184136, 0.0, 6.07288 +-0.184136, 2.18832, 6.07288 +-0.184136, 2.18832, 6.07288 +-0.187166, 2.18832, 6.0822 +-0.187166, 0.0, 6.0822 +-0.195098, 0.0, 6.08796 +-0.204902, 0.0, 6.08796 +-0.212834, 0.0, 6.0822 +-0.212834, 0.0, 6.0822 +-0.215864, 0.0, 6.07288 +-0.212834, 0.0, 6.06355 +-0.212834, 0.0, 6.06355 +-0.204902, 0.0, 6.05779 +-0.195098, 0.0, 6.05779 +-0.195098, 0.0, 6.05779 +-0.187166, 0.0, 6.06355 +-0.184136, 0.0, 6.07288 +-0.212834, 0.0, 6.06355 +-0.195098, 0.0, 6.05779 +-0.184136, 0.0, 6.07288 +-0.212834, 0.0, 6.0822 +-0.212834, 0.0, 6.06355 +-0.184136, 0.0, 6.07288 +-0.195098, 0.0, 6.08796 +-0.212834, 0.0, 6.0822 +-0.184136, 0.0, 6.07288 +-0.187166, 0.0, 6.0822 +-0.195098, 0.0, 6.08796 +-0.184136, 0.0, 6.07288 +-0.187166, 2.18832, 6.06355 +-0.195098, 2.18832, 6.05779 +-0.204902, 2.18832, 6.05779 +-0.204902, 2.18832, 6.05779 +-0.212834, 2.18832, 6.06355 +-0.215864, 2.18832, 6.07288 +-0.215864, 2.18832, 6.07288 +-0.212834, 2.18832, 6.0822 +-0.204902, 2.18832, 6.08796 +-0.204902, 2.18832, 6.08796 +-0.195098, 2.18832, 6.08796 +-0.187166, 2.18832, 6.0822 +-0.215864, 2.18832, 6.07288 +-0.204902, 2.18832, 6.08796 +-0.187166, 2.18832, 6.0822 +-0.204902, 2.18832, 6.05779 +-0.215864, 2.18832, 6.07288 +-0.187166, 2.18832, 6.0822 +-0.187166, 2.18832, 6.06355 +-0.204902, 2.18832, 6.05779 +-0.187166, 2.18832, 6.0822 +-0.184136, 2.18832, 6.07288 +-0.187166, 2.18832, 6.06355 +-0.187166, 2.18832, 6.0822 +-0.585371, 0.0, 6.07288 +-0.588165, 0.0, 6.06428 +-0.588165, 2.18832, 6.06428 +-0.588165, 2.18832, 6.06428 +-0.585371, 2.18832, 6.07288 +-0.585371, 0.0, 6.07288 +-0.614629, 0.0, 6.07288 +-0.611835, 0.0, 6.08148 +-0.611835, 2.18832, 6.08148 +-0.611835, 2.18832, 6.08148 +-0.614629, 2.18832, 6.07288 +-0.614629, 0.0, 6.07288 +-0.611835, 0.0, 6.08148 +-0.604521, 0.0, 6.08679 +-0.604521, 2.18832, 6.08679 +-0.604521, 2.18832, 6.08679 +-0.611835, 2.18832, 6.08148 +-0.611835, 0.0, 6.08148 +-0.604521, 0.0, 6.08679 +-0.595479, 0.0, 6.08679 +-0.595479, 2.18832, 6.08679 +-0.595479, 2.18832, 6.08679 +-0.604521, 2.18832, 6.08679 +-0.604521, 0.0, 6.08679 +-0.595479, 0.0, 6.08679 +-0.588165, 0.0, 6.08148 +-0.588165, 2.18832, 6.08148 +-0.588165, 2.18832, 6.08148 +-0.595479, 2.18832, 6.08679 +-0.595479, 0.0, 6.08679 +-0.588165, 0.0, 6.08148 +-0.585371, 0.0, 6.07288 +-0.585371, 2.18832, 6.07288 +-0.585371, 2.18832, 6.07288 +-0.588165, 2.18832, 6.08148 +-0.588165, 0.0, 6.08148 +-0.595479, 0.0, 6.08679 +-0.604521, 0.0, 6.08679 +-0.611835, 0.0, 6.08148 +-0.611835, 0.0, 6.08148 +-0.614629, 0.0, 6.07288 +-0.611835, 0.0, 6.06428 +-0.611835, 0.0, 6.06428 +-0.604521, 0.0, 6.05896 +-0.595479, 0.0, 6.05896 +-0.595479, 0.0, 6.05896 +-0.588165, 0.0, 6.06428 +-0.585371, 0.0, 6.07288 +-0.611835, 0.0, 6.06428 +-0.595479, 0.0, 6.05896 +-0.585371, 0.0, 6.07288 +-0.611835, 0.0, 6.08148 +-0.611835, 0.0, 6.06428 +-0.585371, 0.0, 6.07288 +-0.595479, 0.0, 6.08679 +-0.611835, 0.0, 6.08148 +-0.585371, 0.0, 6.07288 +-0.588165, 0.0, 6.08148 +-0.595479, 0.0, 6.08679 +-0.585371, 0.0, 6.07288 +-0.588165, 2.18832, 6.06428 +-0.595479, 2.18832, 6.05896 +-0.604521, 2.18832, 6.05896 +-0.604521, 2.18832, 6.05896 +-0.611835, 2.18832, 6.06428 +-0.614629, 2.18832, 6.07288 +-0.614629, 2.18832, 6.07288 +-0.611835, 2.18832, 6.08148 +-0.604521, 2.18832, 6.08679 +-0.604521, 2.18832, 6.08679 +-0.595479, 2.18832, 6.08679 +-0.588165, 2.18832, 6.08148 +-0.614629, 2.18832, 6.07288 +-0.604521, 2.18832, 6.08679 +-0.588165, 2.18832, 6.08148 +-0.604521, 2.18832, 6.05896 +-0.614629, 2.18832, 6.07288 +-0.588165, 2.18832, 6.08148 +-0.588165, 2.18832, 6.06428 +-0.604521, 2.18832, 6.05896 +-0.588165, 2.18832, 6.08148 +-0.585371, 2.18832, 6.07288 +-0.588165, 2.18832, 6.06428 +-0.588165, 2.18832, 6.08148 +1.03278, 0.0984738, 6.052 +1.03278, 2.08558, 6.052 +0.00136847, 2.08558, 6.052 +0.00136847, 2.08558, 6.052 +0.00136847, 0.0984738, 6.052 +1.03278, 0.0984738, 6.052 +-0.0122491, 2.08558, 6.052 +-1.04367, 2.08558, 6.052 +-1.04367, 0.0984738, 6.052 +-1.04367, 0.0984738, 6.052 +-0.0122491, 0.0984738, 6.052 +-0.0122491, 2.08558, 6.052 +0.61422, 0.0, 6.07288 +0.61422, 2.18832, 6.07288 +0.61422, 0.569992, 6.07288 +0.61422, 0.569992, 6.07288 +0.61422, 0.543543, 6.07288 +0.61422, 0.0, 6.07288 +0.61422, 2.18832, 6.07288 +0.611504, 2.18832, 6.08123 +0.611504, 0.569992, 6.08123 +0.611504, 0.569992, 6.08123 +0.61422, 0.569992, 6.07288 +0.61422, 2.18832, 6.07288 +0.611504, 2.18832, 6.08123 +0.611504, 0.0, 6.08123 +0.611504, 0.543543, 6.08123 +0.611504, 0.543543, 6.08123 +0.611504, 0.569992, 6.08123 +0.611504, 2.18832, 6.08123 +0.611504, 0.0, 6.08123 +0.61422, 0.0, 6.07288 +0.61422, 0.543543, 6.07288 +0.61422, 0.543543, 6.07288 +0.611504, 0.543543, 6.08123 +0.611504, 0.0, 6.08123 +0.61422, 0.543543, 6.07288 +0.61422, 0.569992, 6.07288 +0.892061, 0.569992, 6.05618 +0.892061, 0.569992, 6.05618 +0.892061, 0.543543, 6.05618 +0.61422, 0.543543, 6.07288 +0.61422, 0.569992, 6.07288 +0.611504, 0.569992, 6.08123 +0.892061, 0.569992, 6.05618 +0.611504, 0.569992, 6.08123 +0.611504, 0.543543, 6.08123 +0.892061, 0.543543, 6.05618 +0.892061, 0.543543, 6.05618 +0.892061, 0.569992, 6.05618 +0.611504, 0.569992, 6.08123 +0.611504, 0.543543, 6.08123 +0.61422, 0.543543, 6.07288 +0.892061, 0.543543, 6.05618 +0.215692, 0.0, 6.07288 +0.215692, 2.18832, 6.07288 +0.215692, 0.576822, 6.07288 +0.215692, 0.576822, 6.07288 +0.215692, 0.546241, 6.07288 +0.215692, 0.0, 6.07288 +0.215692, 2.18832, 6.07288 +0.212695, 2.18832, 6.0821 +0.212695, 0.576822, 6.0821 +0.212695, 0.576822, 6.0821 +0.215692, 0.576822, 6.07288 +0.215692, 2.18832, 6.07288 +0.212695, 2.18832, 6.0821 +0.212695, 0.0, 6.0821 +0.212695, 0.546241, 6.0821 +0.212695, 0.546241, 6.0821 +0.212695, 0.576822, 6.0821 +0.212695, 2.18832, 6.0821 +0.212695, 0.0, 6.0821 +0.215692, 0.0, 6.07288 +0.215692, 0.546241, 6.07288 +0.215692, 0.546241, 6.07288 +0.212695, 0.546241, 6.0821 +0.212695, 0.0, 6.0821 +0.215692, 0.546241, 6.07288 +0.215692, 0.576822, 6.07288 +0.480489, 0.576822, 6.06799 +0.480489, 0.576822, 6.06799 +0.480489, 0.546241, 6.06799 +0.215692, 0.546241, 6.07288 +0.215692, 0.576822, 6.07288 +0.212695, 0.576822, 6.0821 +0.480489, 0.576822, 6.06799 +0.212695, 0.576822, 6.0821 +0.212695, 0.546241, 6.0821 +0.480489, 0.546241, 6.06799 +0.480489, 0.546241, 6.06799 +0.480489, 0.576822, 6.06799 +0.212695, 0.576822, 6.0821 +0.212695, 0.546241, 6.0821 +0.215692, 0.546241, 6.07288 +0.480489, 0.546241, 6.06799 +-0.212834, 2.18832, 6.06355 +-0.212834, 0.0, 6.06355 +-0.212834, 0.537944, 6.06355 +-0.212834, 0.537944, 6.06355 +-0.212834, 0.572329, 6.06355 +-0.212834, 2.18832, 6.06355 +-0.212834, 0.0, 6.06355 +-0.215864, 0.0, 6.07288 +-0.215864, 0.537944, 6.07288 +-0.215864, 0.537944, 6.07288 +-0.212834, 0.537944, 6.06355 +-0.212834, 0.0, 6.06355 +-0.215864, 0.0, 6.07288 +-0.215864, 2.18832, 6.07288 +-0.215864, 0.572329, 6.07288 +-0.215864, 0.572329, 6.07288 +-0.215864, 0.537944, 6.07288 +-0.215864, 0.0, 6.07288 +-0.215864, 2.18832, 6.07288 +-0.212834, 2.18832, 6.06355 +-0.212834, 0.572329, 6.06355 +-0.212834, 0.572329, 6.06355 +-0.215864, 0.572329, 6.07288 +-0.215864, 2.18832, 6.07288 +-0.212834, 0.572329, 6.06355 +-0.212834, 0.537944, 6.06355 +-0.480645, 0.537944, 6.05698 +-0.480645, 0.537944, 6.05698 +-0.480645, 0.572329, 6.05698 +-0.212834, 0.572329, 6.06355 +-0.212834, 0.537944, 6.06355 +-0.215864, 0.537944, 6.07288 +-0.480645, 0.537944, 6.05698 +-0.215864, 0.537944, 6.07288 +-0.215864, 0.572329, 6.07288 +-0.480645, 0.572329, 6.05698 +-0.480645, 0.572329, 6.05698 +-0.480645, 0.537944, 6.05698 +-0.215864, 0.537944, 6.07288 +-0.215864, 0.572329, 6.07288 +-0.212834, 0.572329, 6.06355 +-0.480645, 0.572329, 6.05698 +-0.611835, 2.18832, 6.06428 +-0.611835, 0.0, 6.06428 +-0.611835, 0.532442, 6.06428 +-0.611835, 0.532442, 6.06428 +-0.611835, 0.577831, 6.06428 +-0.611835, 2.18832, 6.06428 +-0.611835, 0.0, 6.06428 +-0.614629, 0.0, 6.07288 +-0.614629, 0.532442, 6.07288 +-0.614629, 0.532442, 6.07288 +-0.611835, 0.532442, 6.06428 +-0.611835, 0.0, 6.06428 +-0.614629, 0.0, 6.07288 +-0.614629, 2.18832, 6.07288 +-0.614629, 0.577831, 6.07288 +-0.614629, 0.577831, 6.07288 +-0.614629, 0.532442, 6.07288 +-0.614629, 0.0, 6.07288 +-0.614629, 2.18832, 6.07288 +-0.611835, 2.18832, 6.06428 +-0.611835, 0.577831, 6.06428 +-0.611835, 0.577831, 6.06428 +-0.614629, 0.577831, 6.07288 +-0.614629, 2.18832, 6.07288 +-0.611835, 0.577831, 6.06428 +-0.611835, 0.532442, 6.06428 +-0.879528, 0.532442, 6.05519 +-0.879528, 0.532442, 6.05519 +-0.879528, 0.577831, 6.05519 +-0.611835, 0.577831, 6.06428 +-0.611835, 0.532442, 6.06428 +-0.614629, 0.532442, 6.07288 +-0.879528, 0.532442, 6.05519 +-0.614629, 0.532442, 6.07288 +-0.614629, 0.577831, 6.07288 +-0.879528, 0.577831, 6.05519 +-0.879528, 0.577831, 6.05519 +-0.879528, 0.532442, 6.05519 +-0.614629, 0.532442, 6.07288 +-0.614629, 0.577831, 6.07288 +-0.611835, 0.577831, 6.06428 +-0.879528, 0.577831, 6.05519 + + +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +1.0, 0.0, 0.0 +1.0, 0.0, 0.0 +1.0, 0.0, 0.0 +1.0, 0.0, 0.0 +1.0, 0.0, 0.0 +1.0, 0.0, 0.0 +0.0, 0.0, -1.0 +0.0, 0.0, -1.0 +0.0, 0.0, -1.0 +0.0, 0.0, -1.0 +0.0, 0.0, -1.0 +0.0, 0.0, -1.0 +-1.0, 0.0, 0.0 +-1.0, 0.0, 0.0 +-1.0, 0.0, 0.0 +-1.0, 0.0, 0.0 +-1.0, 0.0, 0.0 +-1.0, 0.0, 0.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.951054, 0.0, -0.309026 +0.951054, 0.0, -0.309026 +0.951054, 0.0, -0.309026 +0.951054, 0.0, -0.309026 +0.951054, 0.0, -0.309026 +0.951054, 0.0, -0.309026 +-0.951056, 0.0, -0.30902 +-0.994186, 0.0, 0.107678 +-0.994186, 0.0, -0.107678 +-0.994186, 0.0, -0.107678 +-0.951056, 0.0, -0.30902 +-0.951056, 0.0, -0.30902 +-0.994186, 0.0, 0.107678 +-0.741036, 0.0, 0.671465 +-0.867608, 0.0, 0.497249 +-0.867608, 0.0, 0.497249 +-0.994186, 0.0, -0.107678 +-0.994186, 0.0, 0.107678 +-0.741036, 0.0, 0.671465 +-0.204823, 0.0, 0.978799 +-0.409646, 0.0, 0.912244 +-0.409646, 0.0, 0.912244 +-0.867608, 0.0, 0.497249 +-0.741036, 0.0, 0.671465 +-0.204823, 0.0, 0.978799 +0.409646, 0.0, 0.912244 +0.204823, 0.0, 0.978799 +0.204823, 0.0, 0.978799 +-0.409646, 0.0, 0.912244 +-0.204823, 0.0, 0.978799 +0.409646, 0.0, 0.912244 +0.58781, 0.0, 0.808999 +0.58781, 0.0, 0.808999 +0.58781, 0.0, 0.808999 +0.204823, 0.0, 0.978799 +0.409646, 0.0, 0.912244 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.951056, 0.0, -0.309018 +0.951056, 0.0, -0.309018 +0.951056, 0.0, -0.309018 +0.951056, 0.0, -0.309018 +0.951056, 0.0, -0.309018 +0.951056, 0.0, -0.309018 +-0.951057, 0.0, -0.309016 +-0.994187, 0.0, 0.107666 +-0.994185, 0.0, -0.107681 +-0.994185, 0.0, -0.107681 +-0.951057, 0.0, -0.309016 +-0.951057, 0.0, -0.309016 +-0.994187, 0.0, 0.107666 +-0.741014, 0.0, 0.67149 +-0.867605, 0.0, 0.497253 +-0.867605, 0.0, 0.497253 +-0.994185, 0.0, -0.107681 +-0.994187, 0.0, 0.107666 +-0.741014, 0.0, 0.67149 +-0.204805, 0.0, 0.978803 +-0.409611, 0.0, 0.91226 +-0.409611, 0.0, 0.91226 +-0.867605, 0.0, 0.497253 +-0.741014, 0.0, 0.67149 +-0.204805, 0.0, 0.978803 +0.409611, 0.0, 0.91226 +0.204806, 0.0, 0.978803 +0.204806, 0.0, 0.978803 +-0.409611, 0.0, 0.91226 +-0.204805, 0.0, 0.978803 +0.409611, 0.0, 0.91226 +0.587765, 0.0, 0.809032 +0.587765, 0.0, 0.809032 +0.587765, 0.0, 0.809032 +0.204806, 0.0, 0.978803 +0.409611, 0.0, 0.91226 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.994184, 0.0, -0.107692 +0.951052, 0.0, -0.309032 +0.951052, 0.0, -0.309032 +0.951052, 0.0, -0.309032 +0.994188, 0.0, 0.107662 +0.994184, 0.0, -0.107692 +-0.951061, 0.0, 0.309003 +-0.740996, 0.0, 0.671509 +-0.867599, 0.0, 0.497264 +-0.867599, 0.0, 0.497264 +-0.951061, 0.0, 0.309003 +-0.951061, 0.0, 0.309003 +-0.740996, 0.0, 0.671509 +-0.204794, 0.0, 0.978805 +-0.409587, 0.0, 0.912271 +-0.409587, 0.0, 0.912271 +-0.867599, 0.0, 0.497264 +-0.740996, 0.0, 0.671509 +-0.204794, 0.0, 0.978805 +0.409588, 0.0, 0.912271 +0.204794, 0.0, 0.978805 +0.204794, 0.0, 0.978805 +-0.409587, 0.0, 0.912271 +-0.204794, 0.0, 0.978805 +0.409588, 0.0, 0.912271 +0.867599, 0.0, 0.497264 +0.740997, 0.0, 0.671509 +0.740997, 0.0, 0.671509 +0.204794, 0.0, 0.978805 +0.409588, 0.0, 0.912271 +0.867599, 0.0, 0.497264 +0.994184, 0.0, -0.107692 +0.994188, 0.0, 0.107662 +0.994188, 0.0, 0.107662 +0.740997, 0.0, 0.671509 +0.867599, 0.0, 0.497264 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.994185, 0.0, -0.107687 +0.951052, 0.0, -0.309031 +0.951052, 0.0, -0.309031 +0.951052, 0.0, -0.309031 +0.994187, 0.0, 0.107671 +0.994185, 0.0, -0.107687 +-0.951057, 0.0, 0.309016 +-0.741023, 0.0, 0.67148 +-0.867605, 0.0, 0.497254 +-0.867605, 0.0, 0.497254 +-0.951057, 0.0, 0.309016 +-0.951057, 0.0, 0.309016 +-0.741023, 0.0, 0.67148 +-0.204814, 0.0, 0.978801 +-0.409628, 0.0, 0.912253 +-0.409628, 0.0, 0.912253 +-0.867605, 0.0, 0.497254 +-0.741023, 0.0, 0.67148 +-0.204814, 0.0, 0.978801 +0.409628, 0.0, 0.912253 +0.204814, 0.0, 0.978801 +0.204814, 0.0, 0.978801 +-0.409628, 0.0, 0.912253 +-0.204814, 0.0, 0.978801 +0.409628, 0.0, 0.912253 +0.867605, 0.0, 0.497254 +0.741023, 0.0, 0.67148 +0.741023, 0.0, 0.67148 +0.204814, 0.0, 0.978801 +0.409628, 0.0, 0.912253 +0.867605, 0.0, 0.497254 +0.994185, 0.0, -0.107687 +0.994187, 0.0, 0.107671 +0.994187, 0.0, 0.107671 +0.741023, 0.0, 0.67148 +0.867605, 0.0, 0.497254 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 1.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +0.951054, 0.0, 0.309026 +-0.0599835, 0.0, -0.998199 +-0.0599835, 0.0, -0.998199 +-0.0599835, 0.0, -0.998199 +-0.0599835, 0.0, -0.998199 +-0.0599835, 0.0, -0.998199 +-0.0599835, 0.0, -0.998199 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0889468, 0.0, 0.996036 +0.0889468, 0.0, 0.996036 +0.0889468, 0.0, 0.996036 +0.0889468, 0.0, 0.996036 +0.0889468, 0.0, 0.996036 +0.0889468, 0.0, 0.996036 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +0.951061, 0.0, 0.309003 +-0.0184439, 0.0, -0.99983 +-0.0184439, 0.0, -0.99983 +-0.0184439, 0.0, -0.99983 +-0.0184439, 0.0, -0.99983 +-0.0184439, 0.0, -0.99983 +-0.0184439, 0.0, -0.99983 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0526117, 0.0, 0.998615 +0.0526117, 0.0, 0.998615 +0.0526117, 0.0, 0.998615 +0.0526117, 0.0, 0.998615 +0.0526117, 0.0, 0.998615 +0.0526117, 0.0, 0.998615 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +-0.951052, 0.0, -0.309032 +0.0245422, 0.0, -0.999699 +0.0245422, 0.0, -0.999699 +0.0245422, 0.0, -0.999699 +0.0245422, 0.0, -0.999699 +0.0245422, 0.0, -0.999699 +0.0245422, 0.0, -0.999699 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +-0.0599369, 0.0, 0.998202 +-0.0599369, 0.0, 0.998202 +-0.0599369, 0.0, 0.998202 +-0.0599369, 0.0, 0.998202 +-0.0599369, 0.0, 0.998202 +-0.0599369, 0.0, 0.998202 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +0.0, 0.0, 0.0 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +-0.951052, 0.0, -0.309031 +0.0339176, 0.0, -0.999425 +0.0339176, 0.0, -0.999425 +0.0339176, 0.0, -0.999425 +0.0339176, 0.0, -0.999425 +0.0339176, 0.0, -0.999425 +0.0339176, 0.0, -0.999425 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +0.0, -1.0, 0.0 +-0.0666057, 0.0, 0.997779 +-0.0666057, 0.0, 0.997779 +-0.0666057, 0.0, 0.997779 +-0.0666057, 0.0, 0.997779 +-0.0666057, 0.0, 0.997779 +-0.0666057, 0.0, 0.997779 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 +0.0, 1.0, 0.0 + + + + +0.996648, 0.355226 +0.0979369, 0.355226 +0.0979369, 0.0048809 +0.0979369, 0.0048809 +0.996648, 0.00488085 +0.996648, 0.355226 +0.996643, 0.00482193 +0.996644, 0.355167 +0.0979327, 0.355167 +0.0979327, 0.355167 +0.0979326, 0.00482197 +0.996643, 0.00482193 +0.995325, 0.693698 +0.0952358, 0.693696 +0.0952372, 0.358069 +0.0952372, 0.358069 +0.995326, 0.358072 +0.995325, 0.693698 +0.995712, 0.994161 +0.697017, 0.994161 +0.697017, 0.709019 +0.697017, 0.709019 +0.995712, 0.709019 +0.995712, 0.994161 +0.994841, 0.693621 +0.0947512, 0.693619 +0.0947528, 0.357992 +0.0947528, 0.357992 +0.994842, 0.357995 +0.994841, 0.693621 +0.0445547, 0.707523 +0.695375, 0.712237 +0.666895, 0.737505 +0.666895, 0.737505 +0.072667, 0.733201 +0.0445547, 0.707523 +0.0524875, 0.741276 +0.675028, 0.740186 +0.645188, 0.768535 +0.645188, 0.768535 +0.0780106, 0.769529 +0.0524875, 0.741276 +0.0483286, 0.805124 +0.68021, 0.805144 +0.652737, 0.834161 +0.652737, 0.834161 +0.0758014, 0.834144 +0.0483286, 0.805124 +0.673981, 0.802663 +0.0514405, 0.801571 +0.0769636, 0.773319 +0.0769636, 0.773319 +0.644141, 0.774314 +0.673981, 0.802663 +0.0320342, 0.0043303 +0.0352626, 0.0043303 +0.0352626, 0.808058 +0.0352626, 0.808058 +0.0320342, 0.808058 +0.0320342, 0.0043303 +0.0126548, 0.0043303 +0.0158832, 0.0043303 +0.0158832, 0.808058 +0.0158832, 0.808058 +0.0126548, 0.808058 +0.0126548, 0.0043303 +0.0158832, 0.0043303 +0.0191126, 0.0043303 +0.0191126, 0.808058 +0.0191126, 0.808058 +0.0158832, 0.808058 +0.0158832, 0.0043303 +0.0191126, 0.0043303 +0.022343, 0.0043303 +0.022343, 0.808058 +0.022343, 0.808058 +0.0191126, 0.808058 +0.0191126, 0.0043303 +0.022343, 0.0043303 +0.0255743, 0.0043303 +0.0255743, 0.808058 +0.0255743, 0.808058 +0.022343, 0.808058 +0.022343, 0.0043303 +0.0255743, 0.0043303 +0.0288048, 0.0043303 +0.0288048, 0.808058 +0.0288048, 0.808058 +0.0255743, 0.808058 +0.0255743, 0.0043303 +0.0281171, 0.20497 +0.0290044, 0.208058 +0.0279071, 0.211078 +0.0279071, 0.211078 +0.0252445, 0.212876 +0.0220335, 0.212766 +0.0220335, 0.212766 +0.0195005, 0.210789 +0.0186132, 0.207701 +0.0186132, 0.207701 +0.0197105, 0.204681 +0.0223732, 0.202885 +0.0220335, 0.212766 +0.0186132, 0.207701 +0.0223732, 0.202885 +0.0279071, 0.211078 +0.0220335, 0.212766 +0.0223732, 0.202885 +0.0281171, 0.20497 +0.0279071, 0.211078 +0.0223732, 0.202885 +0.0255843, 0.202992 +0.0281171, 0.20497 +0.0223732, 0.202885 +0.0190881, 0.218049 +0.0204065, 0.220979 +0.0197509, 0.224124 +0.0197509, 0.224124 +0.0173717, 0.226283 +0.0141777, 0.226632 +0.0141777, 0.226632 +0.011389, 0.225036 +0.0100705, 0.222106 +0.0100705, 0.222106 +0.0107261, 0.218961 +0.0147068, 0.216693 +0.0141777, 0.226632 +0.0100705, 0.222106 +0.0147068, 0.216693 +0.0197509, 0.224124 +0.0141777, 0.226632 +0.0147068, 0.216693 +0.0190881, 0.218049 +0.0197509, 0.224124 +0.0147068, 0.216693 +0.0146979, 0.216562 +0.0190881, 0.218049 +0.0147068, 0.216693 +0.0328696, 0.0043303 +0.036432, 0.0043303 +0.036432, 0.808058 +0.036432, 0.808058 +0.0328696, 0.808058 +0.0328696, 0.0043303 +0.0114858, 0.0043303 +0.0150483, 0.0043303 +0.0150483, 0.808058 +0.0150483, 0.808058 +0.0114858, 0.808058 +0.0114858, 0.0043303 +0.0150483, 0.0043303 +0.0186118, 0.0043303 +0.0186118, 0.808058 +0.0186118, 0.808058 +0.0150483, 0.808058 +0.0150483, 0.0043303 +0.0186118, 0.0043303 +0.0221764, 0.0043303 +0.0221763, 0.808058 +0.0221763, 0.808058 +0.0186118, 0.808058 +0.0186118, 0.0043303 +0.0221764, 0.0043303 +0.0257418, 0.0043303 +0.0257418, 0.808058 +0.0257418, 0.808058 +0.0221763, 0.808058 +0.0221764, 0.0043303 +0.0257418, 0.0043303 +0.0293064, 0.0043303 +0.0293063, 0.808058 +0.0293063, 0.808058 +0.0257418, 0.808058 +0.0257418, 0.0043303 +0.0285426, 0.20616 +0.0295102, 0.209571 +0.0282882, 0.212899 +0.0282882, 0.212899 +0.0253432, 0.214874 +0.0218002, 0.21474 +0.0218002, 0.21474 +0.0190125, 0.212549 +0.0180449, 0.209138 +0.0180449, 0.209138 +0.0192669, 0.20581 +0.0222121, 0.203838 +0.0218002, 0.21474 +0.0180449, 0.209138 +0.0222121, 0.203838 +0.0282882, 0.212899 +0.0218002, 0.21474 +0.0222121, 0.203838 +0.0285426, 0.20616 +0.0282882, 0.212899 +0.0222121, 0.203838 +0.0257553, 0.203968 +0.0285426, 0.20616 +0.0222121, 0.203838 +0.0200101, 0.220638 +0.0215053, 0.223853 +0.0208253, 0.227333 +0.0208253, 0.227333 +0.0182299, 0.229748 +0.0147104, 0.230177 +0.0147104, 0.230177 +0.0116111, 0.228455 +0.0101159, 0.22524 +0.0101159, 0.22524 +0.0107959, 0.22176 +0.015157, 0.219214 +0.0147104, 0.230177 +0.0101159, 0.22524 +0.015157, 0.219214 +0.0208253, 0.227333 +0.0147104, 0.230177 +0.015157, 0.219214 +0.0200101, 0.220638 +0.0208253, 0.227333 +0.015157, 0.219214 +0.0151446, 0.219047 +0.0200101, 0.220638 +0.015157, 0.219214 +0.0329622, 0.0043303 +0.0365634, 0.0043303 +0.0365634, 0.808058 +0.0365634, 0.808058 +0.0329622, 0.808058 +0.0329622, 0.0043303 +0.0149465, 0.0043303 +0.018549, 0.0043303 +0.018549, 0.808058 +0.018549, 0.808058 +0.0149465, 0.808058 +0.0149465, 0.0043303 +0.018549, 0.0043303 +0.0221527, 0.0043303 +0.0221529, 0.808058 +0.0221529, 0.808058 +0.018549, 0.808058 +0.018549, 0.0043303 +0.0221527, 0.0043303 +0.0257568, 0.0043303 +0.0257571, 0.808058 +0.0257571, 0.808058 +0.0221529, 0.808058 +0.0221527, 0.0043303 +0.0257568, 0.0043303 +0.0293601, 0.0043303 +0.0293601, 0.808058 +0.0293601, 0.808058 +0.0257571, 0.808058 +0.0257568, 0.0043303 +0.0293601, 0.0043303 +0.0329622, 0.0043303 +0.0329622, 0.808058 +0.0329622, 0.808058 +0.0293601, 0.808058 +0.0293601, 0.0043303 +0.00872991, 0.210054 +0.00752289, 0.206679 +0.00853017, 0.203239 +0.00853017, 0.203239 +0.0113624, 0.201022 +0.014946, 0.200969 +0.014946, 0.200969 +0.0179101, 0.202964 +0.0191171, 0.206339 +0.0191171, 0.206339 +0.0181098, 0.209779 +0.015273, 0.21197 +0.014946, 0.200969 +0.0191171, 0.206339 +0.015273, 0.21197 +0.00853017, 0.203239 +0.014946, 0.200969 +0.015273, 0.21197 +0.00872991, 0.210054 +0.00853017, 0.203239 +0.015273, 0.21197 +0.0116902, 0.212075 +0.00872991, 0.210054 +0.015273, 0.21197 +0.0173309, 0.226479 +0.0139519, 0.225284 +0.0119209, 0.22233 +0.0119209, 0.22233 +0.0134691, 0.218018 +0.0127676, 0.216596 +0.0127676, 0.216596 +0.0176317, 0.214884 +0.0210108, 0.21608 +0.0210108, 0.21608 +0.0230417, 0.219033 +0.0229487, 0.222616 +0.0127676, 0.216596 +0.0210108, 0.21608 +0.0229487, 0.222616 +0.0119209, 0.22233 +0.0127676, 0.216596 +0.0229487, 0.222616 +0.0173309, 0.226479 +0.0119209, 0.22233 +0.0229487, 0.222616 +0.0207674, 0.22546 +0.0173309, 0.226479 +0.0229487, 0.222616 +0.0322638, 0.0043303 +0.0355849, 0.0043303 +0.0355849, 0.808058 +0.0355849, 0.808058 +0.0322638, 0.808058 +0.0322638, 0.0043303 +0.0156493, 0.0043303 +0.0189715, 0.0043303 +0.0189716, 0.808058 +0.0189716, 0.808058 +0.0156493, 0.808058 +0.0156493, 0.0043303 +0.0189715, 0.0043303 +0.0222948, 0.0043303 +0.0222948, 0.808058 +0.0222948, 0.808058 +0.0189716, 0.808058 +0.0189715, 0.0043303 +0.0222948, 0.0043303 +0.0256186, 0.0043303 +0.0256186, 0.808058 +0.0256186, 0.808058 +0.0222948, 0.808058 +0.0222948, 0.0043303 +0.0256186, 0.0043303 +0.0289416, 0.0043303 +0.0289416, 0.808058 +0.0289416, 0.808058 +0.0256186, 0.808058 +0.0256186, 0.0043303 +0.0289416, 0.0043303 +0.0322638, 0.0043303 +0.0322638, 0.808058 +0.0322638, 0.808058 +0.0289416, 0.808058 +0.0289416, 0.0043303 +0.00988939, 0.207325 +0.00878603, 0.204209 +0.00972486, 0.20104 +0.00972486, 0.20104 +0.0123434, 0.199006 +0.0156482, 0.198963 +0.0156482, 0.198963 +0.0183755, 0.200813 +0.0194788, 0.203929 +0.0194788, 0.203929 +0.01854, 0.207098 +0.0159177, 0.209111 +0.0156482, 0.198963 +0.0194788, 0.203929 +0.0159177, 0.209111 +0.00972486, 0.20104 +0.0156482, 0.198963 +0.0159177, 0.209111 +0.00988939, 0.207325 +0.00972486, 0.20104 +0.0159177, 0.209111 +0.0126135, 0.209197 +0.00988939, 0.207325 +0.0159177, 0.209111 +0.0171257, 0.22806 +0.014114, 0.226698 +0.0124783, 0.223826 +0.0124783, 0.223826 +0.014237, 0.219918 +0.0136974, 0.218696 +0.0136974, 0.218696 +0.0183066, 0.217429 +0.0213182, 0.218791 +0.0213182, 0.218791 +0.0229539, 0.221664 +0.022589, 0.224949 +0.0136974, 0.218696 +0.0213182, 0.218791 +0.022589, 0.224949 +0.0124783, 0.223826 +0.0136974, 0.218696 +0.022589, 0.224949 +0.0171257, 0.22806 +0.0124783, 0.223826 +0.022589, 0.224949 +0.0203628, 0.227392 +0.0171257, 0.22806 +0.022589, 0.224949 +0.99556, 0.708874 +0.995362, 0.993985 +0.849113, 0.993985 +0.849113, 0.993985 +0.84931, 0.708874 +0.99556, 0.708874 +0.849122, 0.994505 +0.696954, 0.99411 +0.697152, 0.709 +0.697152, 0.709 +0.84932, 0.709394 +0.849122, 0.994505 +0.0320342, 0.0043303 +0.0320342, 0.808058 +0.0320342, 0.808058 +0.0320342, 0.808058 +0.0320342, 0.0043303 +0.0320342, 0.0043303 +0.0146979, 0.216562 +0.0147068, 0.216693 +0.0288048, 0.808058 +0.0288048, 0.808058 +0.0320342, 0.808058 +0.0146979, 0.216562 +0.0288048, 0.808058 +0.0288048, 0.0043303 +0.0288048, 0.0043303 +0.0288048, 0.0043303 +0.0288048, 0.808058 +0.0288048, 0.808058 +0.0255843, 0.202992 +0.0223732, 0.202885 +0.0320342, 0.0043303 +0.0320342, 0.0043303 +0.0288048, 0.0043303 +0.0255843, 0.202992 +0.0320342, 0.0043303 +0.0320342, 0.808058 +0.0304195, 0.808058 +0.0304195, 0.808058 +0.0304195, 0.0043303 +0.0320342, 0.0043303 +0.0320342, 0.808058 +0.0288048, 0.808058 +0.0304195, 0.808058 +0.0288048, 0.808058 +0.0288048, 0.0043303 +0.0304195, 0.0043303 +0.0304195, 0.0043303 +0.0304195, 0.808058 +0.0288048, 0.808058 +0.0288048, 0.0043303 +0.0320342, 0.0043303 +0.0304195, 0.0043303 +0.0328696, 0.0043303 +0.0328696, 0.808058 +0.0328696, 0.808058 +0.0328696, 0.808058 +0.0328696, 0.0043303 +0.0328696, 0.0043303 +0.0151446, 0.219047 +0.015157, 0.219214 +0.0293063, 0.808058 +0.0293063, 0.808058 +0.0328696, 0.808058 +0.0151446, 0.219047 +0.0293063, 0.808058 +0.0293064, 0.0043303 +0.0293064, 0.0043303 +0.0293064, 0.0043303 +0.0293063, 0.808058 +0.0293063, 0.808058 +0.0257553, 0.203968 +0.0222121, 0.203838 +0.0328696, 0.0043303 +0.0328696, 0.0043303 +0.0293064, 0.0043303 +0.0257553, 0.203968 +0.0328696, 0.0043303 +0.0328696, 0.808058 +0.0310879, 0.808058 +0.0310879, 0.808058 +0.031088, 0.0043303 +0.0328696, 0.0043303 +0.0328696, 0.808058 +0.0293063, 0.808058 +0.0310879, 0.808058 +0.0293063, 0.808058 +0.0293064, 0.0043303 +0.031088, 0.0043303 +0.031088, 0.0043303 +0.0310879, 0.808058 +0.0293063, 0.808058 +0.0293064, 0.0043303 +0.0328696, 0.0043303 +0.031088, 0.0043303 +0.011345, 0.808058 +0.011345, 0.0043303 +0.011345, 0.0043303 +0.011345, 0.0043303 +0.011345, 0.808058 +0.011345, 0.808058 +0.014946, 0.200969 +0.0113624, 0.201022 +0.0149465, 0.0043303 +0.0149465, 0.0043303 +0.011345, 0.0043303 +0.014946, 0.200969 +0.0149465, 0.0043303 +0.0149465, 0.808058 +0.0149465, 0.808058 +0.0149465, 0.808058 +0.0149465, 0.0043303 +0.0149465, 0.0043303 +0.0127676, 0.216596 +0.0134691, 0.218018 +0.011345, 0.808058 +0.011345, 0.808058 +0.0149465, 0.808058 +0.0127676, 0.216596 +0.011345, 0.808058 +0.011345, 0.0043303 +0.0131458, 0.0043303 +0.0131458, 0.0043303 +0.0131458, 0.808058 +0.011345, 0.808058 +0.011345, 0.0043303 +0.0149465, 0.0043303 +0.0131458, 0.0043303 +0.0149465, 0.0043303 +0.0149465, 0.808058 +0.0131458, 0.808058 +0.0131458, 0.808058 +0.0131458, 0.0043303 +0.0149465, 0.0043303 +0.0149465, 0.808058 +0.011345, 0.808058 +0.0131458, 0.808058 +0.0123284, 0.808058 +0.0123284, 0.0043303 +0.0123284, 0.0043303 +0.0123284, 0.0043303 +0.0123284, 0.808058 +0.0123284, 0.808058 +0.0156482, 0.198963 +0.0123434, 0.199006 +0.0156493, 0.0043303 +0.0156493, 0.0043303 +0.0123284, 0.0043303 +0.0156482, 0.198963 +0.0156493, 0.0043303 +0.0156493, 0.808058 +0.0156493, 0.808058 +0.0156493, 0.808058 +0.0156493, 0.0043303 +0.0156493, 0.0043303 +0.0136974, 0.218696 +0.014237, 0.219918 +0.0123284, 0.808058 +0.0123284, 0.808058 +0.0156493, 0.808058 +0.0136974, 0.218696 +0.0123284, 0.808058 +0.0123284, 0.0043303 +0.0139889, 0.0043303 +0.0139889, 0.0043303 +0.0139889, 0.808058 +0.0123284, 0.808058 +0.0123284, 0.0043303 +0.0156493, 0.0043303 +0.0139889, 0.0043303 +0.0156493, 0.0043303 +0.0156493, 0.808058 +0.0139889, 0.808058 +0.0139889, 0.808058 +0.0139889, 0.0043303 +0.0156493, 0.0043303 +0.0156493, 0.808058 +0.0123284, 0.808058 +0.0139889, 0.808058 + + + diff --git a/Templates/SalmonWallpaperTemplate/default.properties b/Templates/SalmonWallpaperTemplate/default.properties new file mode 100644 index 0000000..4735723 --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/default.properties @@ -0,0 +1,13 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "build.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-8 +# Indicates whether an apk should be generated for each density. +split.density=false diff --git a/Templates/SalmonWallpaperTemplate/jni/Android.mk b/Templates/SalmonWallpaperTemplate/jni/Android.mk new file mode 100644 index 0000000..c1052c5 --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/jni/Android.mk @@ -0,0 +1,77 @@ +# Copyright (C) 2009 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +LPATH := $(call my-dir) + +ENGINE_PATH = $(SalmonEnginePathCygwin) + +BOOST_PATH = $(LibsPathCygwin)/boost_1_47_0 + +OGG_PATH = $(LibsPathCygwin)/libogg-1.3.0 + +VORBIS_PATH = $(LibsPathCygwin)/libvorbis-1.3.2 + +SQUIRREL_PATH = $(LibsPathCygwin)/sqplus + +LIBPNG_PATH = $(LibsPathCygwin)/libpng_1.4.1_android + +ZIP_PATH = $(LibsPathCygwin)/julienr-libzip-android/jni + +#====== ENGINE AND LIBS ===================== + +include $(ENGINE_PATH)/Android_Salmon_Engine.mk + +#================= THE GAME ======================= + + +LOCAL_PATH:= $(LPATH) + +include $(CLEAR_VARS) + +LOCAL_CFLAGS := -DTARGET_ANDROID -DNOSOUND -DTARGET_SALMON -std=gnu++11 --std=c++11 +LOCAL_STATIC_LIBRARIES := boost +LOCAL_STATIC_LIBRARIES += squirrel +LOCAL_STATIC_LIBRARIES += png_lib +LOCAL_STATIC_LIBRARIES += zip +LOCAL_SHARED_LIBRARIES := SalmonEngine +LOCAL_SHARED_LIBRARIES += gnustl_shared +LOCAL_C_INCLUDES := $(ENGINE_PATH) +LOCAL_C_INCLUDES += $(BOOST_PATH) +LOCAL_C_INCLUDES += $(VORBIS_PATH)/include +LOCAL_C_INCLUDES += $(VORBIS_PATH)/include/vorbis +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/books +LOCAL_C_INCLUDES += $(VORBIS_PATH)/lib/modes +LOCAL_C_INCLUDES += $(OGG_PATH)/include +LOCAL_C_INCLUDES += $(OGG_PATH)/include/ogg +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/include +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/sqplus +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/squirrel +LOCAL_C_INCLUDES += $(SQUIRREL_PATH)/sqstdlib +LOCAL_C_INCLUDES += $(LIBPNG_PATH) +LOCAL_C_INCLUDES += $(ZIP_PATH) +LOCAL_MODULE := SalmonWallpaper +LOCAL_SRC_FILES := main_code.cpp +LOCAL_SRC_FILES += android_api.cpp + +LOCAL_LDLIBS := -lGLESv2 +LOCAL_LDLIBS += -llog -Wl + +#debug +#LOCAL_CFLAGS += -g -ggdb -O0 +#LOCAL_LDLIBS += -g -ggdb + +include $(BUILD_SHARED_LIBRARY) diff --git a/Templates/SalmonWallpaperTemplate/jni/Application.mk b/Templates/SalmonWallpaperTemplate/jni/Application.mk new file mode 100644 index 0000000..b096c4c --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/jni/Application.mk @@ -0,0 +1,3 @@ +APP_STL := gnustl_shared +APP_CPPFLAGS += -fexceptions +APP_CPPFLAGS += -frtti \ No newline at end of file diff --git a/Templates/SalmonWallpaperTemplate/jni/android_api.cpp b/Templates/SalmonWallpaperTemplate/jni/android_api.cpp new file mode 100644 index 0000000..444a4a1 --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/jni/android_api.cpp @@ -0,0 +1,119 @@ +#include "android_api.h" + +#include "main_code.h" +#include "boost\thread.hpp" + +std::shared_ptr App(new TAndroidApplication); + +boost::mutex RenderMutex; + +float lastOffsetX = 0.5f; + +bool OffsetChanged = false; + +bool RedBkgPref = false; + +JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height) +{ + + + RenderMutex.lock(); + + try + { + + if (App->IsInited()) + { + App->OuterDeinit(); //Clean up what is left at previous launch (if applicable) + } + + App->Width = width; + App->Height = height; + + if (width > height) + { + App->OuterInit(width, height, 800.f, 480.f); + } + else + { + App->OuterInit(width, height, 480.f, 800.f); + } + + Renderer->SetAlpha((lastOffsetX) * pi / 180.f); + + App->Inited = true; + } + catch (...) + { + throw; + } + + RenderMutex.unlock(); +} + + + +JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_Update(JNIEnv * env, jobject obj, long dt) +{ + RenderMutex.unlock(); + + try + { + if (App->IsInited()) + { + App->OuterDraw(); + App->OuterUpdate(dt); + + if (OffsetChanged) + { + Renderer->SetAlpha((lastOffsetX) * pi / 180.f); + } + } + } + catch (...) + { + throw; + } + + RenderMutex.unlock(); +} + + +JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, jfloat x, jfloat y) +{ + try + { + if (App->IsInited()) + { + + vec2 offset = vec2(x*Renderer->GetMatrixWidth()/static_cast(App->Width), y*Renderer->GetMatrixHeight()/static_cast(App->Height)); + + App->OuterOnMove(offset); + + } + } + catch (...) + { + throw; + } +} + + +JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetOffset(JNIEnv * env, jobject obj, jfloat offsetX, jfloat offsetY) +{ + + if (Renderer != NULL) + { + OffsetChanged = true; + lastOffsetX = offsetX; + } +} + +JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetOrientation(JNIEnv * env, jobject obj, int isLandscape) +{ +} + +JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetRedBkgPref(JNIEnv * env, jobject obj, jboolean r) +{ + RedBkgPref = r; +} \ No newline at end of file diff --git a/Templates/SalmonWallpaperTemplate/jni/android_api.h b/Templates/SalmonWallpaperTemplate/jni/android_api.h new file mode 100644 index 0000000..b3ca6c5 --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/jni/android_api.h @@ -0,0 +1,31 @@ +#ifndef ANDROID_API_H_INCLUDED +#define ANDROID_API_H_INCLUDED + +#include +#include + +#include +#include +#include + +#include "boost/shared_ptr.hpp" + +#include "main_code.h" + +extern "C" { + + JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_Init(JNIEnv * env, jobject obj, jint width, jint height); + + JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_Update(JNIEnv * env, jobject obj, long dt); + + JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_OnTapMove(JNIEnv * env, jobject obj, jfloat x, jfloat y); + + JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetOffset(JNIEnv * env, jobject obj, jfloat offsetX, jfloat offsetY); + + JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetOrientation(JNIEnv * env, jobject obj, int isLandscape); + + JNIEXPORT void JNICALL Java_fishrungames_wallpapertemplate_JniWrapper_SetRedBkgPref(JNIEnv * env, jobject obj, jboolean r); + }; + + +#endif diff --git a/Templates/SalmonWallpaperTemplate/jni/main_code.cpp b/Templates/SalmonWallpaperTemplate/jni/main_code.cpp new file mode 100644 index 0000000..c90e5ea --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/jni/main_code.cpp @@ -0,0 +1,183 @@ +#include "main_code.h" +#ifdef TARGET_ANDROID +#include "android_api.h" +#endif +#include +#include +#include +#include + +#include "include/Engine.h" + +#include "main_code.h" + +extern float lastOffsetX; + +#ifdef TARGET_WIN32 +bool RedBkgPref = true; + +#else +extern bool RedBkgPref; + +#endif + + + + + +TAndroidApplication::TAndroidApplication() + : TApplication() + , Inited(false) + //, LiteModel(NULL) +{ +} + + +void TAndroidApplication::LoadModels() +{ + + mat3 m(vec4(0,1*sin(pi/8 + pi/2),0,1*cos(pi/8 + pi/2))); + /* + LiteModel = new TLiteModel; + LiteModel->LoadModel("bt_box_yellow.lm1"); + LiteModel->ScaleModel(10.0f); + LiteModel->RotateModel(m); + LiteModel->UpdateVBO();*/ + + FlexModel = ResourceManager->FlexModelManager.InstanciateModel("model.xml"); + + //FlexModel.MoveModel(vec3(1, -4, -4)); + FlexModel.ScaleModel(1.5f); + FlexModel.RotateModel(m); + FlexModel.RefreshBuffer(); +} + + +void TAndroidApplication::DrawAllScene() +{ + glClearColor(0.f, 0.f, 0.f, 1.0f); + + glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); + + Renderer->PushProjectionMatrix(1,1); + Renderer->LoadIdentity(); + + if (RedBkgPref) + { + glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["bkg_red.png"]); + } + else + { + glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["bkg_blue.png"]); + } + + Renderer->DrawRect(vec2(0.0f, 0.f), vec2(1.f, 1.f), vec2(0.f, 0.f), vec2(1.f, 1.f)); + + Renderer->PopProjectionMatrix(); + + glClear(GL_DEPTH_BUFFER_BIT); + + Renderer->SetGLCamView(); + + //LiteModel->DrawVBO(); + FlexModel.Draw(); + +} + +void TAndroidApplication::InnerInit() +{ + RenderMutex.lock(); + + CheckGlError(); + + glEnable(GL_BLEND); + + *Console<<"Inner init go!\n"; + +#ifdef TARGET_ANDROID + ResourceManager->PathToResources = ""; +#endif +#ifdef TARGET_WIN32 + ResourceManager->PathToResources = "../../assets/"; +#endif + ResourceManager->ShaderManager.AddShader("DefaultShader", "gui_transparent.vertex", "gui_transparent.fragment"); + Renderer->PushShader("DefaultShader"); + + ResourceManager->TexList.AddTexture("bkg_red.png"); + ResourceManager->TexList.AddTexture("bkg_blue.png"); + + CheckGlError(); + + Renderer->MovePhi(pi/32); + + //ResourceManager->ModelManager.AddLiteModel("bt_box_yellow.lm1"); + + + ResourceManager->TexList.AddTexture("bt_box_yellow.bmp"); + ResourceManager->FlexModelManager.LoadModelFromXml("model.xml"); + + + LoadModels(); + + if (Width > Height) + { + Renderer->MoveDist(30.f); + } + + else + { + Renderer->MoveDist(45.f); + } + + CheckGlError(); + + Renderer->SetPerspectiveFullScreenViewport(); + + *Console<<"Inner init end!\n"; + + RenderMutex.unlock(); +} + + + +void TAndroidApplication::InnerDeinit() +{ + RenderMutex.lock(); + Inited = false; + /* + if (LiteModel != NULL) + { + LiteModel->FreeModel(); + delete LiteModel; + LiteModel = NULL; + }*/ + + RenderMutex.unlock(); +} + + +void TAndroidApplication::InnerDraw() +{ + RenderMutex.lock(); + + DrawAllScene(); + + RenderMutex.unlock(); + +} + + +void TAndroidApplication::InnerUpdate(cardinal dt) +{ + +} + +void TAndroidApplication::InnerOnMove(vec2 shift) +{ + Renderer->MoveAlpha(-pi*shift.v[0]*0.1f); +} + +void TAndroidApplication::OnMouseDown(TMouseState& mouseState) +{ + +} \ No newline at end of file diff --git a/Templates/SalmonWallpaperTemplate/jni/main_code.h b/Templates/SalmonWallpaperTemplate/jni/main_code.h new file mode 100644 index 0000000..d78d34c --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/jni/main_code.h @@ -0,0 +1,67 @@ +#ifndef GL_CODE_H_INCLUDED +#define GL_CODE_H_INCLUDED + +#ifdef TARGET_ANDROID +//#include "android_api.h" +#endif + +#include +#include +#include + +#ifdef TARGET_ANDROID +#include +#include +#include +#endif + +#include "boost/shared_ptr.hpp" +#include "boost/thread/thread.hpp" +#include "boost/asio.hpp" +#include "boost/signal.hpp" +#include "boost/assign.hpp" +#include "boost/variant.hpp" +#include "boost/function.hpp" +#include "boost/bind.hpp" + +#include "include/Engine.h" + +using namespace SE; + + +class TAndroidApplication : public TApplication +{ +protected: + + void LoadModels(); + +public: + bool Inited; + + boost::mutex RenderMutex; + + //TLiteModel* LiteModel; + TFlexModel FlexModel; + + TAndroidApplication(); + + virtual void InnerInit(); + + virtual void InnerDeinit(); + + virtual void InnerDraw(); + + virtual void InnerUpdate(cardinal dt); + + virtual void InnerOnMove(vec2 shift); + + virtual void OnMouseDown(TMouseState& mouseState); + + bool IsInited() { return Inited; } + + void DrawAllScene(); + +}; + + +#endif diff --git a/Templates/SalmonWallpaperTemplate/res/drawable-hdpi/icon.png b/Templates/SalmonWallpaperTemplate/res/drawable-hdpi/icon.png new file mode 100644 index 0000000..0040da6 Binary files /dev/null and b/Templates/SalmonWallpaperTemplate/res/drawable-hdpi/icon.png differ diff --git a/Templates/SalmonWallpaperTemplate/res/drawable-ldpi/icon.png b/Templates/SalmonWallpaperTemplate/res/drawable-ldpi/icon.png new file mode 100644 index 0000000..629b3f7 Binary files /dev/null and b/Templates/SalmonWallpaperTemplate/res/drawable-ldpi/icon.png differ diff --git a/Templates/SalmonWallpaperTemplate/res/drawable-mdpi/icon.png b/Templates/SalmonWallpaperTemplate/res/drawable-mdpi/icon.png new file mode 100644 index 0000000..7856a23 Binary files /dev/null and b/Templates/SalmonWallpaperTemplate/res/drawable-mdpi/icon.png differ diff --git a/Templates/SalmonWallpaperTemplate/res/drawable/notificon.png b/Templates/SalmonWallpaperTemplate/res/drawable/notificon.png new file mode 100644 index 0000000..c4fe56f Binary files /dev/null and b/Templates/SalmonWallpaperTemplate/res/drawable/notificon.png differ diff --git a/Templates/SalmonWallpaperTemplate/res/drawable/thumb.jpg b/Templates/SalmonWallpaperTemplate/res/drawable/thumb.jpg new file mode 100644 index 0000000..dd5852c Binary files /dev/null and b/Templates/SalmonWallpaperTemplate/res/drawable/thumb.jpg differ diff --git a/Templates/SalmonWallpaperTemplate/res/layout/main.xml b/Templates/SalmonWallpaperTemplate/res/layout/main.xml new file mode 100644 index 0000000..4361cfe --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/res/layout/main.xml @@ -0,0 +1,7 @@ + + + diff --git a/Templates/SalmonWallpaperTemplate/res/layout/prefliste.xml b/Templates/SalmonWallpaperTemplate/res/layout/prefliste.xml new file mode 100644 index 0000000..92fd874 --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/res/layout/prefliste.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/Templates/SalmonWallpaperTemplate/res/values/strings.xml b/Templates/SalmonWallpaperTemplate/res/values/strings.xml new file mode 100644 index 0000000..c9804ef --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/res/values/strings.xml @@ -0,0 +1,27 @@ + + + Salmon Engine Wallpaper Template + Salmon Engine Wallpaper Template + This template made by fishrungames.com + + Background color + Red background + Blue background + + + + + + + + + + + + + + + diff --git a/Templates/SalmonWallpaperTemplate/res/xml/preferences.xml b/Templates/SalmonWallpaperTemplate/res/xml/preferences.xml new file mode 100644 index 0000000..84609c4 --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/res/xml/preferences.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/Templates/SalmonWallpaperTemplate/res/xml/wallpaper.xml b/Templates/SalmonWallpaperTemplate/res/xml/wallpaper.xml new file mode 100644 index 0000000..2d28206 --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/res/xml/wallpaper.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/GLWallpaperService.java b/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/GLWallpaperService.java new file mode 100644 index 0000000..bfd7e0f --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/GLWallpaperService.java @@ -0,0 +1,958 @@ +package fishrungames.wallpapertemplate; + + +import fishrungames.wallpapertemplate.BaseConfigChooser.ComponentSizeChooser; +import fishrungames.wallpapertemplate.BaseConfigChooser.SimpleEGLConfigChooser; + +import java.util.ArrayList; +import java.util.Calendar; + +import javax.microedition.khronos.egl.EGL10; +import javax.microedition.khronos.egl.EGLConfig; +import javax.microedition.khronos.egl.EGLContext; +import javax.microedition.khronos.egl.EGLDisplay; +import javax.microedition.khronos.egl.EGLSurface; + + +import android.service.wallpaper.WallpaperService; +import android.util.Log; +import android.view.SurfaceHolder; + + +public class GLWallpaperService extends WallpaperService { + private static final String TAG = "GLWallpaperService"; + + @Override + public Engine onCreateEngine() { + return new GLEngine(); + } + + public class GLEngine extends Engine { + public final static int RENDERMODE_WHEN_DIRTY = 0; + public final static int RENDERMODE_CONTINUOUSLY = 1; + + private GLThread mGLThread; + private EGLConfigChooser mEGLConfigChooser; + private EGLContextFactory mEGLContextFactory; + private EGLWindowSurfaceFactory mEGLWindowSurfaceFactory; + + private int mDebugFlags; + + public GLEngine() { + super(); + } + + @Override + public void onVisibilityChanged(boolean visible) { + if (visible) { + onResume(); + } else { + onPause(); + } + super.onVisibilityChanged(visible); + } + + @Override + public void onCreate(SurfaceHolder surfaceHolder) { + super.onCreate(surfaceHolder); + // Log.d(TAG, "GLEngine.onCreate()"); + } + + @Override + public void onDestroy() { + super.onDestroy(); + // Log.d(TAG, "GLEngine.onDestroy()"); + mGLThread.requestExitAndWait(); + } + + @Override + public void onSurfaceChanged(SurfaceHolder holder, int format, + int width, int height) { + // Log.d(TAG, "onSurfaceChanged()"); + + + + mGLThread.onWindowResize(width, height); + + super.onSurfaceChanged(holder, format, width, height); + } + + @Override + public void onSurfaceCreated(SurfaceHolder holder) { + Log.d(TAG, "onSurfaceCreated()"); + mGLThread.surfaceCreated(holder); + super.onSurfaceCreated(holder); + } + + @Override + public void onSurfaceDestroyed(SurfaceHolder holder) { + Log.d(TAG, "onSurfaceDestroyed()"); + mGLThread.surfaceDestroyed(); + super.onSurfaceDestroyed(holder); + } + + + public void setDebugFlags(int debugFlags) { + mDebugFlags = debugFlags; + } + + public int getDebugFlags() { + return mDebugFlags; + } + + public void setRenderer() { + checkRenderThreadState(); + if (mEGLConfigChooser == null) { + mEGLConfigChooser = new SimpleEGLConfigChooser(true); + } + if (mEGLContextFactory == null) { + //mEGLContextFactory = new DefaultContextFactory(); + mEGLContextFactory = new ES20ContextFactory(); + } + if (mEGLWindowSurfaceFactory == null) { + mEGLWindowSurfaceFactory = new DefaultWindowSurfaceFactory(); + } + mGLThread = new GLThread(mEGLConfigChooser, + mEGLContextFactory, mEGLWindowSurfaceFactory); + mGLThread.start(); + } + + public void setEGLContextFactory(EGLContextFactory factory) { + checkRenderThreadState(); + mEGLContextFactory = factory; + } + + public void setEGLWindowSurfaceFactory(EGLWindowSurfaceFactory factory) { + checkRenderThreadState(); + mEGLWindowSurfaceFactory = factory; + } + + public void setEGLConfigChooser(EGLConfigChooser configChooser) { + checkRenderThreadState(); + mEGLConfigChooser = configChooser; + } + + public void setEGLConfigChooser(boolean needDepth) { + setEGLConfigChooser(new SimpleEGLConfigChooser(needDepth)); + } + + public void setEGLConfigChooser(int redSize, int greenSize, + int blueSize, int alphaSize, int depthSize, int stencilSize) { + setEGLConfigChooser(new ComponentSizeChooser(redSize, greenSize, + blueSize, alphaSize, depthSize, stencilSize)); + } + + public void setRenderMode(int renderMode) { + mGLThread.setRenderMode(renderMode); + } + + public int getRenderMode() { + return mGLThread.getRenderMode(); + } + + public void requestRender() { + mGLThread.requestRender(); + } + + public void onPause() { + mGLThread.onPause(); + } + + public void onResume() { + mGLThread.onResume(); + } + + public void queueEvent(Runnable r) { + mGLThread.queueEvent(r); + } + + private void checkRenderThreadState() { + if (mGLThread != null) { + throw new IllegalStateException( + "setRenderer has already been called for this instance."); + } + } + } +} + + +// ---------------------------------------------------------------------- + +/** + * An interface for customizing the eglCreateContext and eglDestroyContext + * calls. + * + * + * This interface must be implemented by clients wishing to call + * {@link GLWallpaperService#setEGLContextFactory(EGLContextFactory)} + */ +interface EGLContextFactory { + EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig); + + void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context); +} + +class DefaultContextFactory implements EGLContextFactory { + + public EGLContext createContext(EGL10 egl, EGLDisplay display, + EGLConfig config) { + return egl + .eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT, null); + } + + public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) { + egl.eglDestroyContext(display, context); + } +} + + +class ES20ContextFactory implements EGLContextFactory { + + private static int EGL_CONTEXT_CLIENT_VERSION = 0x3098; + + public EGLContext createContext(EGL10 egl, EGLDisplay display, + EGLConfig config) { + + + int[] attrib_list = + { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE }; + + return egl + .eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT, attrib_list); + } + + public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) { + egl.eglDestroyContext(display, context); + } +} + +/** + * An interface for customizing the eglCreateWindowSurface and eglDestroySurface + * calls. + * + * + * This interface must be implemented by clients wishing to call + * {@link GLWallpaperService#setEGLWindowSurfaceFactory(EGLWindowSurfaceFactory)} + */ +interface EGLWindowSurfaceFactory { + EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display, + EGLConfig config, Object nativeWindow); + + void destroySurface(EGL10 egl, EGLDisplay display, EGLSurface surface); +} + +class DefaultWindowSurfaceFactory implements EGLWindowSurfaceFactory { + + public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display, + EGLConfig config, Object nativeWindow) { + // this is a bit of a hack to work around Droid init problems - if you + // don't have this, it'll get hung up on orientation changes + EGLSurface eglSurface = null; + while (eglSurface == null) { + try { + eglSurface = egl.eglCreateWindowSurface(display, config, + nativeWindow, null); + } catch (Throwable t) { + } finally { + if (eglSurface == null) { + try { + Thread.sleep(10); + } catch (InterruptedException t) { + } + } + } + } + return eglSurface; + } + + public void destroySurface(EGL10 egl, EGLDisplay display, EGLSurface surface) { + egl.eglDestroySurface(display, surface); + } +} + + +class EglHelper { + + private EGL10 mEgl; + private EGLDisplay mEglDisplay; + private EGLSurface mEglSurface; + private EGLContext mEglContext; + EGLConfig mEglConfig; + + private EGLConfigChooser mEGLConfigChooser; + private EGLContextFactory mEGLContextFactory; + private EGLWindowSurfaceFactory mEGLWindowSurfaceFactory; + + + public EglHelper(EGLConfigChooser chooser, + EGLContextFactory contextFactory, + EGLWindowSurfaceFactory surfaceFactory) { + this.mEGLConfigChooser = chooser; + this.mEGLContextFactory = contextFactory; + this.mEGLWindowSurfaceFactory = surfaceFactory; + + } + + /** + * Initialize EGL for a given configuration spec. + * + * @param configSpec + */ + public void start() { + String instanceId = ""; + Log.d("EglHelper" + instanceId, "start()"); + if (mEgl == null) { + Log.d("EglHelper" + instanceId, "getting new EGL"); + /* + * Get an EGL instance + */ + mEgl = (EGL10) EGLContext.getEGL(); + } else { + Log.d("EglHelper" + instanceId, "reusing EGL"); + } + + if (mEglDisplay == null) { + Log.d("EglHelper" + instanceId, "getting new display"); + /* + * Get to the default display. + */ + mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); + } else { + Log.d("EglHelper" + instanceId, "reusing display"); + } + + if (mEglConfig == null) { + Log.d("EglHelper" + instanceId, "getting new config"); + /* + * We can now initialize EGL for that display + */ + int[] version = new int[2]; + mEgl.eglInitialize(mEglDisplay, version); + mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay); + } else { + Log.d("EglHelper" + instanceId, "reusing config"); + } + + if (mEglContext == null) { + Log.d("EglHelper" + instanceId, "creating new context"); + /* + * Create an OpenGL ES context. This must be done only once, an + * OpenGL context is a somewhat heavy object. + */ + mEglContext = mEGLContextFactory.createContext(mEgl, mEglDisplay, + mEglConfig); + if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) { + throw new RuntimeException("createContext failed"); + } + } else { + Log.d("EglHelper" + instanceId, "reusing context"); + } + + mEglSurface = null; + } + + /* + * React to the creation of a new surface by creating and returning an + * OpenGL interface that renders to that surface. + */ + + + public void createSurface(SurfaceHolder holder) { + + if (mEglSurface != null && mEglSurface != EGL10.EGL_NO_SURFACE) { + + + mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE, + EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT); + mEGLWindowSurfaceFactory.destroySurface(mEgl, mEglDisplay, + mEglSurface); + } + + + mEglSurface = mEGLWindowSurfaceFactory.createWindowSurface(mEgl, + mEglDisplay, mEglConfig, holder); + + if (mEglSurface == null || mEglSurface == EGL10.EGL_NO_SURFACE) { + throw new RuntimeException("createWindowSurface failed"); + } + + + if (!mEgl.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, + mEglContext)) { + //throw new RuntimeException("eglMakeCurrent failed."); + } + + + } + + /** + * Display the current render surface. + * + * @return false if the context has been lost. + */ + public boolean swap() { + try { + mEgl.eglSwapBuffers(mEglDisplay, mEglSurface); + } catch (Exception e) { + return false; + } + + return true; + + + /* + * Always check for EGL_CONTEXT_LOST, which means the context and all + * associated data were lost (For instance because the device went to + * sleep). We need to sleep until we get a new surface. + */ + + } + + public void destroySurface() { + if (mEglSurface != null && mEglSurface != EGL10.EGL_NO_SURFACE) { + mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE, + EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT); + mEGLWindowSurfaceFactory.destroySurface(mEgl, mEglDisplay, + mEglSurface); + mEglSurface = null; + } + } + + public void finish() { + if (mEglContext != null) { + mEGLContextFactory.destroyContext(mEgl, mEglDisplay, mEglContext); + mEglContext = null; + } + if (mEglDisplay != null) { + mEgl.eglTerminate(mEglDisplay); + mEglDisplay = null; + } + } +} + +class GLThread extends Thread { + private final static boolean LOG_THREADS = false; + public final static int DEBUG_CHECK_GL_ERROR = 1; + public final static int DEBUG_LOG_GL_CALLS = 2; + + private final GLThreadManager sGLThreadManager = new GLThreadManager(); + private GLThread mEglOwner; + + private EGLConfigChooser mEGLConfigChooser; + private EGLContextFactory mEGLContextFactory; + private EGLWindowSurfaceFactory mEGLWindowSurfaceFactory; + + + public SurfaceHolder mHolder; + private boolean mSizeChanged = true; + + // Once the thread is started, all accesses to the following member + // variables are protected by the sGLThreadManager monitor + public boolean mDone; + private boolean mPaused; + private boolean mHasSurface; + private boolean mWaitingForSurface; + private boolean mHaveEgl; + private int mWidth; + private int mHeight; + private int mRenderMode; + private boolean mRequestRender; + private boolean mEventsWaiting; + // End of member variables protected by the sGLThreadManager monitor. + + //private GLWallpaperService.Renderer mRenderer; + + private ArrayList mEventQueue = new ArrayList(); + private EglHelper mEglHelper; + + + static long lastTimeStamp; + static boolean gameIsInited = false; + + GLThread(EGLConfigChooser chooser, + EGLContextFactory contextFactory, + EGLWindowSurfaceFactory surfaceFactory) { + super(); + mDone = false; + mWidth = 0; + mHeight = 0; + mRequestRender = true; + mRenderMode = GLWallpaperService.GLEngine.RENDERMODE_CONTINUOUSLY; + + this.mEGLConfigChooser = chooser; + this.mEGLContextFactory = contextFactory; + this.mEGLWindowSurfaceFactory = surfaceFactory; + + Calendar c = Calendar.getInstance(); + lastTimeStamp = c.getTimeInMillis(); + gameIsInited = true; + } + + @Override + public void run() { + setName("GLThread " + getId()); + if (LOG_THREADS) { + Log.i("GLThread", "starting tid=" + getId()); + } + + try { + guardedRun(); + } catch (InterruptedException e) { + // fall thru and exit normally + } finally { + sGLThreadManager.threadExiting(this); + } + } + + /* + * This private method should only be called inside a + * synchronized(sGLThreadManager) block. + */ + private void stopEglLocked() { + if (mHaveEgl) { + mHaveEgl = false; + mEglHelper.destroySurface(); + sGLThreadManager.releaseEglSurface(this); + } + } + + private void guardedRun() throws InterruptedException { + mEglHelper = new EglHelper(mEGLConfigChooser, mEGLContextFactory, + mEGLWindowSurfaceFactory/*, mGLWrapper*/); + try { + + boolean tellRendererSurfaceCreated = true; + boolean tellRendererSurfaceChanged = true; + + /* + * This is our main activity thread's loop, we go until asked to + * quit. + */ + while (!isDone()) { + /* + * Update the asynchronous state (window size) + */ + int w = 0; + int h = 0; + boolean changed = false; + boolean needStart = false; + boolean eventsWaiting = false; + + synchronized (sGLThreadManager) { + while (true) { + // Manage acquiring and releasing the SurfaceView + // surface and the EGL surface. + if (mPaused) { + stopEglLocked(); + } + if (!mHasSurface) { + if (!mWaitingForSurface) { + stopEglLocked(); + mWaitingForSurface = true; + sGLThreadManager.notifyAll(); + } + } else { + if (!mHaveEgl) { + if (sGLThreadManager.tryAcquireEglSurface(this)) { + mHaveEgl = true; + mEglHelper.start(); + mRequestRender = true; + needStart = true; + } + } + } + + // Check if we need to wait. If not, update any state + // that needs to be updated, copy any state that + // needs to be copied, and use "break" to exit the + // wait loop. + + if (mDone) { + return; + } + + if (mEventsWaiting) { + eventsWaiting = true; + mEventsWaiting = false; + break; + } + + if ((!mPaused) + && mHasSurface + && mHaveEgl + && (mWidth > 0) + && (mHeight > 0) + && (mRequestRender || (mRenderMode == GLWallpaperService.GLEngine.RENDERMODE_CONTINUOUSLY))) { + changed = mSizeChanged; + w = mWidth; + h = mHeight; + mSizeChanged = false; + mRequestRender = false; + if (mHasSurface && mWaitingForSurface) { + changed = true; + mWaitingForSurface = false; + sGLThreadManager.notifyAll(); + } + break; + } + + + + // By design, this is the only place where we wait(). + + if (LOG_THREADS) { + Log.i("GLThread", "waiting tid=" + getId()); + } + sGLThreadManager.wait(); + } + } // end of synchronized(sGLThreadManager) + + /* + * Handle queued events + */ + if (eventsWaiting) { + Runnable r; + while ((r = getEvent()) != null) { + r.run(); + if (isDone()) { + return; + } + } + // Go back and see if we need to wait to render. + continue; + } + + if (needStart) { + tellRendererSurfaceCreated = true; + changed = true; + } + if (changed) { + mEglHelper.createSurface(mHolder); + tellRendererSurfaceChanged = true; + } + if (tellRendererSurfaceCreated) { + + tellRendererSurfaceCreated = false; + } + + if (tellRendererSurfaceChanged) { + + + //Xperimental -- VLAD KHOREV + JniWrapper.Init(w, h); + + tellRendererSurfaceChanged = false; + } + + + if ((w > 0) && (h > 0)) { + /* draw a frame here */ + + if (gameIsInited) + { + Calendar c = Calendar.getInstance(); + + long currentTimeStamp = c.getTimeInMillis(); + + JniWrapper.Update(currentTimeStamp - lastTimeStamp); + + lastTimeStamp = currentTimeStamp; + + } + + /* + * Once we're done with GL, we need to call swapBuffers() to + * instruct the system to display the rendered frame + */ + mEglHelper.swap(); + } + } + } finally { + /* + * clean-up everything... + */ + synchronized (sGLThreadManager) { + stopEglLocked(); + mEglHelper.finish(); + } + } + } + + private boolean isDone() { + synchronized (sGLThreadManager) { + return mDone; + } + } + + public void setRenderMode(int renderMode) { + if (!((GLWallpaperService.GLEngine.RENDERMODE_WHEN_DIRTY <= renderMode) && (renderMode <= GLWallpaperService.GLEngine.RENDERMODE_CONTINUOUSLY))) { + throw new IllegalArgumentException("renderMode"); + } + synchronized (sGLThreadManager) { + mRenderMode = renderMode; + if (renderMode == GLWallpaperService.GLEngine.RENDERMODE_CONTINUOUSLY) { + sGLThreadManager.notifyAll(); + } + } + } + + public int getRenderMode() { + synchronized (sGLThreadManager) { + return mRenderMode; + } + } + + public void requestRender() { + synchronized (sGLThreadManager) { + mRequestRender = true; + sGLThreadManager.notifyAll(); + } + } + + public void surfaceCreated(SurfaceHolder holder) { + mHolder = holder; + synchronized (sGLThreadManager) { + if (LOG_THREADS) { + Log.i("GLThread", "surfaceCreated tid=" + getId()); + } + mHasSurface = true; + sGLThreadManager.notifyAll(); + } + } + + public void surfaceDestroyed() { + synchronized (sGLThreadManager) { + if (LOG_THREADS) { + Log.i("GLThread", "surfaceDestroyed tid=" + getId()); + } + mHasSurface = false; + sGLThreadManager.notifyAll(); + while (!mWaitingForSurface && isAlive() && !mDone) { + try { + sGLThreadManager.wait(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } + } + } + + public void onPause() { + synchronized (sGLThreadManager) { + mPaused = true; + sGLThreadManager.notifyAll(); + } + } + + public void onResume() { + synchronized (sGLThreadManager) { + mPaused = false; + mRequestRender = true; + sGLThreadManager.notifyAll(); + } + } + + public void onWindowResize(int w, int h) { + synchronized (sGLThreadManager) { + mWidth = w; + mHeight = h; + mSizeChanged = true; + sGLThreadManager.notifyAll(); + } + } + + public void requestExitAndWait() { + // don't call this from GLThread thread or it is a guaranteed + // deadlock! + synchronized (sGLThreadManager) { + mDone = true; + sGLThreadManager.notifyAll(); + } + try { + join(); + } catch (InterruptedException ex) { + Thread.currentThread().interrupt(); + } + } + + /** + * Queue an "event" to be run on the GL rendering thread. + * + * @param r + * the runnable to be run on the GL rendering thread. + */ + public void queueEvent(Runnable r) { + synchronized (this) { + mEventQueue.add(r); + synchronized (sGLThreadManager) { + mEventsWaiting = true; + sGLThreadManager.notifyAll(); + } + } + } + + private Runnable getEvent() { + synchronized (this) { + if (mEventQueue.size() > 0) { + return (Runnable) mEventQueue.remove(0); + } + + } + return null; + } + + private class GLThreadManager { + + public synchronized void threadExiting(GLThread thread) { + if (LOG_THREADS) { + Log.i("GLThread", "exiting tid=" + thread.getId()); + } + thread.mDone = true; + if (mEglOwner == thread) { + mEglOwner = null; + } + notifyAll(); + } + + /* + * Tries once to acquire the right to use an EGL surface. Does not + * block. + * + * @return true if the right to use an EGL surface was acquired. + */ + public synchronized boolean tryAcquireEglSurface(GLThread thread) { + if (mEglOwner == thread || mEglOwner == null) { + mEglOwner = thread; + notifyAll(); + return true; + } + return false; + } + + public synchronized void releaseEglSurface(GLThread thread) { + if (mEglOwner == thread) { + mEglOwner = null; + } + notifyAll(); + } + } +} + +interface EGLConfigChooser { + EGLConfig chooseConfig(EGL10 egl, EGLDisplay display); +} + +abstract class BaseConfigChooser implements EGLConfigChooser { + public BaseConfigChooser(int[] configSpec) { + mConfigSpec = configSpec; + } + + public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { + int[] num_config = new int[1]; + egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config); + + int numConfigs = num_config[0]; + + if (numConfigs <= 0) { + throw new IllegalArgumentException("No configs match configSpec"); + } + + EGLConfig[] configs = new EGLConfig[numConfigs]; + egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs, + num_config); + EGLConfig config = chooseConfig(egl, display, configs); + if (config == null) { + throw new IllegalArgumentException("No config chosen"); + } + return config; + } + + abstract EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, + EGLConfig[] configs); + + protected int[] mConfigSpec; + + public static class ComponentSizeChooser extends BaseConfigChooser { + public ComponentSizeChooser(int redSize, int greenSize, int blueSize, + int alphaSize, int depthSize, int stencilSize) { + super(new int[] { EGL10.EGL_RED_SIZE, redSize, + EGL10.EGL_GREEN_SIZE, greenSize, EGL10.EGL_BLUE_SIZE, + blueSize, EGL10.EGL_ALPHA_SIZE, alphaSize, + EGL10.EGL_DEPTH_SIZE, depthSize, EGL10.EGL_STENCIL_SIZE, + stencilSize, EGL10.EGL_NONE }); + mValue = new int[1]; + mRedSize = redSize; + mGreenSize = greenSize; + mBlueSize = blueSize; + mAlphaSize = alphaSize; + mDepthSize = depthSize; + mStencilSize = stencilSize; + } + + @Override + public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, + EGLConfig[] configs) { + EGLConfig closestConfig = null; + int closestDistance = 1000; + for (EGLConfig config : configs) { + int d = findConfigAttrib(egl, display, config, + EGL10.EGL_DEPTH_SIZE, 0); + int s = findConfigAttrib(egl, display, config, + EGL10.EGL_STENCIL_SIZE, 0); + if (d >= mDepthSize && s >= mStencilSize) { + int r = findConfigAttrib(egl, display, config, + EGL10.EGL_RED_SIZE, 0); + int g = findConfigAttrib(egl, display, config, + EGL10.EGL_GREEN_SIZE, 0); + int b = findConfigAttrib(egl, display, config, + EGL10.EGL_BLUE_SIZE, 0); + int a = findConfigAttrib(egl, display, config, + EGL10.EGL_ALPHA_SIZE, 0); + int distance = Math.abs(r - mRedSize) + + Math.abs(g - mGreenSize) + + Math.abs(b - mBlueSize) + + Math.abs(a - mAlphaSize); + if (distance < closestDistance) { + closestDistance = distance; + closestConfig = config; + } + } + } + return closestConfig; + } + + private int findConfigAttrib(EGL10 egl, EGLDisplay display, + EGLConfig config, int attribute, int defaultValue) { + + if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) { + return mValue[0]; + } + return defaultValue; + } + + private int[] mValue; + // Subclasses can adjust these values: + protected int mRedSize; + protected int mGreenSize; + protected int mBlueSize; + protected int mAlphaSize; + protected int mDepthSize; + protected int mStencilSize; + } + + /** + * This class will choose a supported surface as close to RGB565 as + * possible, with or without a depth buffer. + * + */ + public static class SimpleEGLConfigChooser extends ComponentSizeChooser { + public SimpleEGLConfigChooser(boolean withDepthBuffer) { + super(4, 4, 4, 0, withDepthBuffer ? 16 : 0, 0); + // Adjust target values. This way we'll accept a 4444 or + // 555 buffer if there's no 565 buffer available. + mRedSize = 5; + mGreenSize = 6; + mBlueSize = 5; + } + } +} diff --git a/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/JniWrapper.java b/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/JniWrapper.java new file mode 100644 index 0000000..061f9fa --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/JniWrapper.java @@ -0,0 +1,29 @@ +package fishrungames.wallpapertemplate; + +public class JniWrapper +{ + + static + { + System.loadLibrary("SalmonWallpaper"); + } + + public static void LoadLibrary() + { + //To force loading libraries + } + + public static native void SetRedBkgPref(boolean r); + + + public static native void Init(int width, int height); + + public static native void Update(long dt); + + public static native void OnTapMove(float x, float y); + + public static native void SetOffset(float offsetX, float offsetY); + + public static native void SetOrientation(int isLandscape); + +} diff --git a/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/MainWallpaperService.java b/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/MainWallpaperService.java new file mode 100644 index 0000000..d7f527d --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/MainWallpaperService.java @@ -0,0 +1,227 @@ +package fishrungames.wallpapertemplate; + + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.SharedPreferences.OnSharedPreferenceChangeListener; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; + +import android.net.ConnectivityManager; + +import android.os.Handler; +import android.preference.PreferenceManager; + +import android.view.MotionEvent; +import android.view.SurfaceHolder; + +//import com.seb.SLWP.SLWP.GlEngine.DownloadTask; + +import fishrungames.engine.FileWrapper; + +public class MainWallpaperService extends GLWallpaperService implements + OnSharedPreferenceChangeListener { + /* + * (non-Javadoc) + * + * @see android.app.Service#onLowMemory() + */ + static + { + FileWrapper.LoadSalmonEngineLibrary(); + JniWrapper.LoadLibrary(); + } + + + public static final long SLEEPTIME = 1000 * 60 * 30; // 30 minutes + private GlEngine mGle; + + public static Context mContext; + public static boolean ShowClouds; + public static boolean TouchRot; + + public static int Bg; + public static boolean Usebg; + public static int Tex; + + static long Synctime; + + public boolean Slidedir; + public boolean Slideplanet; + public boolean Syncrot; + public static boolean Randomtex = true; + public static boolean visible = false; + + public static boolean useCropper = true; + public static int Cropaspect; + public static boolean loading = false; + + public static final Handler mHandler = new Handler(); + public static final int RNDMAP = -1; + public static boolean destroyed; + public static String bgfile; + public ConnectivityManager cm; + public boolean needresume; + public boolean fstart; + public static String[] randlist; + public int curtexidx = -99; + + static final String ACTION_FOREGROUND = "fishrungames.wallpapertemplate.FOREGROUND"; + static final String ACTION_BACKGROUND = "fishrungames.wallpapertemplate.BACKGROUND"; + + + + @Override + public void onCreate() { + // TODO Auto-generated method stub + super.onCreate(); + + + PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this); + + FileWrapper.SetActivityInstance(this); + FileWrapper.SetupEnviroment(); + + String apkFilePath = null; + ApplicationInfo appInfo = null; + PackageManager packMgmr = this.getPackageManager(); + try { + appInfo = packMgmr.getApplicationInfo("fishrungames.wallpapertemplate", 0); + } catch (NameNotFoundException e) { + + + + e.printStackTrace(); + throw new RuntimeException("Unable to locate assets, aborting..."); + } + apkFilePath = appInfo.sourceDir; + + FileWrapper.SetupApkFilePath(apkFilePath); + + Init(); + } + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + // handleCommand(intent); + // We want this service to continue running until it is explicitly + // stopped, so return sticky. + return START_STICKY; + } + + private void Init() { + try { + mContext = this; + cm = (ConnectivityManager) mContext + .getSystemService(Context.CONNECTIVITY_SERVICE); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void onDestroy() { + // TODO Auto-generated method stub + super.onDestroy(); + } + + @Override + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, + String key) { + + if (key.compareToIgnoreCase("RedBackground") == 0) { + + JniWrapper.SetRedBkgPref(sharedPreferences.getBoolean("RedBackground", false)); + + } + } + + @Override + public Engine onCreateEngine() { + if (mGle != null) { + mGle = null; + } + try { + + mGle = new GlEngine(); + + } catch (Exception e) { + return null; + } + + return mGle; + } + + class GlEngine extends GLEngine { + + public Handler mHandler = new Handler(); + + long NOW; + + @Override + public void onCreate(SurfaceHolder surfaceHolder) { + super.onCreate(surfaceHolder); + try { + this.setTouchEventsEnabled(true); + fstart = true; + setRenderer(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void onTouchEvent(MotionEvent e) { + + return; + } + + @Override + public void onOffsetsChanged(float xOffset, float yOffset, + float xOffsetStep, float yOffsetStep, int xPixelOffset, + int yPixelOffset) { + + super.onOffsetsChanged(xOffset, yOffset, xOffsetStep, yOffsetStep, + xPixelOffset, yPixelOffset); + + JniWrapper.SetOffset(xPixelOffset*xOffsetStep, yPixelOffset*yOffsetStep); + + } + + @Override + public void onVisibilityChanged(boolean visible) { + // TODO Auto-generated method stub + super.onVisibilityChanged(visible); + MainWallpaperService.visible = visible; + if (visible) { + + } else { + + } + } + + @Override + public void onPause() { + super.onPause(); + } + + @Override + public void onResume() { + + super.onResume(); + } + + @Override + public void onSurfaceChanged(SurfaceHolder holder, int format, + int width, int height) { + // TODO Auto-generated method stub + super.onSurfaceChanged(holder, format, width, height); + fstart = true; + } + + } + +} \ No newline at end of file diff --git a/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/Prefs.java b/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/Prefs.java new file mode 100644 index 0000000..18863b9 --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/src/fishrungames/wallpapertemplate/Prefs.java @@ -0,0 +1,63 @@ +package fishrungames.wallpapertemplate; + +import fishrungames.wallpapertemplate.JniWrapper; +import fishrungames.wallpapertemplate.R; + + +import android.content.Intent; + +import android.net.Uri; +import android.os.Bundle; +import android.preference.CheckBoxPreference; +import android.preference.ListPreference; +import android.preference.Preference; +import android.preference.PreferenceActivity; + +import android.preference.Preference.OnPreferenceChangeListener; + + +public class Prefs extends PreferenceActivity implements + OnPreferenceChangeListener { + + + private CheckBoxPreference redBkgPref; + + + public static Uri currImageURI; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.prefliste); + addPreferencesFromResource(R.xml.preferences); + + redBkgPref = (CheckBoxPreference)this.getPreferenceManager().findPreference("RedBackground"); + + if (redBkgPref.getKey().compareToIgnoreCase("RedBackground") == 0) { + if (!redBkgPref.isChecked()) + { + JniWrapper.SetRedBkgPref(false); + } + else + { + JniWrapper.SetRedBkgPref(true); + } + } + + } + + + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + + return true; + + } + + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + + } + +} diff --git a/Templates/SalmonWallpaperTemplate/windows/Template.sln b/Templates/SalmonWallpaperTemplate/windows/Template.sln new file mode 100644 index 0000000..5b553f6 --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/windows/Template.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Template", "Template\Template.vcxproj", "{0080A3E1-DFBF-4557-B198-E6D5D7724393}" + ProjectSection(ProjectDependencies) = postProject + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20} = {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Salmon Engine", "..\..\..\Engine\Salmon Engine\Salmon Engine.vcxproj", "{48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug_nosound|Win32 = Debug_nosound|Win32 + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug_nosound|Win32.ActiveCfg = Debug|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug_nosound|Win32.Build.0 = Debug|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug|Win32.ActiveCfg = Debug|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Debug|Win32.Build.0 = Debug|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Release|Win32.ActiveCfg = Release|Win32 + {0080A3E1-DFBF-4557-B198-E6D5D7724393}.Release|Win32.Build.0 = Release|Win32 + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Debug_nosound|Win32.ActiveCfg = Debug_nosound|Win32 + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Debug_nosound|Win32.Build.0 = Debug_nosound|Win32 + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Debug|Win32.ActiveCfg = Debug|Win32 + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Debug|Win32.Build.0 = Debug|Win32 + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Release|Win32.ActiveCfg = Release|Win32 + {48ADCE9F-9539-4D3A-BCFA-C2ABABAF0B20}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Templates/SalmonWallpaperTemplate/windows/Template/Template.vcxproj b/Templates/SalmonWallpaperTemplate/windows/Template/Template.vcxproj new file mode 100644 index 0000000..10c6f70 --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/windows/Template/Template.vcxproj @@ -0,0 +1,88 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {0080A3E1-DFBF-4557-B198-E6D5D7724393} + Template + + + + Application + true + NotSet + + + Application + false + true + NotSet + + + + + + + + + + + + + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SalmonEnginePath)include + $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(SalmonEnginePath)$(Configuration) + + + $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;$(SalmonEnginePath)include + $(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib;$(SalmonEnginePath)$(Configuration) + + + + Level3 + Disabled + $(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;$(LibsPath)\DirectXsdk\Include;$(LibsPath)\lpng1510;..\..\jni + TARGET_WIN32;TARGET_SALMON;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501 + + + true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;opengl32.lib;glu32.lib;Salmon Engine.lib;libogg_static.lib;libvorbis_static.lib;libvorbisfile_static.lib;zlib.lib;libpng15.lib;sqplusD.lib;squirrelD.lib;sqdbglibD.lib;sqstdlibD.lib;dsound.lib;dxguid.lib;%(AdditionalDependencies) + $(LibsPath)\boost_1_52_0\boost_windows\libs_engine\$(Configuration);$(LibsPath)\libogg-1.3.0\win32\VS2010\Win32\$(Configuration);$(LibsPath)\libvorbis-1.3.2\win32\VS2010\Win32\$(Configuration);$(LibsPath)\sqplus\lib;$(LibsPath)\DirectXsdk\Lib\x86;$(LibsPath)\lpng1510\projects\vstudio\Debug Library + + + + + Level3 + MaxSpeed + true + true + $(SalmonEnginePath);$(LibsPath)\boost_1_52_0;$(LibsPath)\libogg-1.3.0\include;$(LibsPath)\libvorbis-1.3.2\include;$(LibsPath)\sqplus\sqplus;$(LibsPath)\sqplus\include;$(LibsPath)\DirectXsdk\Include;$(LibsPath)\lpng1510;..\..\jni + TARGET_WIN32;TARGET_SALMON;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0501 + + + true + true + true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;opengl32.lib;glu32.lib;Salmon Engine.lib;libogg_static.lib;libvorbis_static.lib;libvorbisfile_static.lib;zlib.lib;libpng15.lib;sqplus.lib;squirrel.lib;sqdbglib.lib;sqstdlib.lib;dsound.lib;dxguid.lib;%(AdditionalDependencies) + $(LibsPath)\boost_1_52_0\boost_windows\libs_engine\$(Configuration);$(LibsPath)\libogg-1.3.0\win32\VS2010\Win32\$(Configuration);$(LibsPath)\libvorbis-1.3.2\win32\VS2010\Win32\$(Configuration);$(LibsPath)\sqplus\lib;$(LibsPath)\DirectXsdk\Lib\x86;$(LibsPath)\lpng1510\projects\vstudio\Release Library + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Templates/SalmonWallpaperTemplate/windows/Template/main.cpp b/Templates/SalmonWallpaperTemplate/windows/Template/main.cpp new file mode 100644 index 0000000..6fcddd4 --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/windows/Template/main.cpp @@ -0,0 +1,15 @@ +#include "main.h" + + +int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst, + LPSTR lpszCmdLine, int nCmdShow) +{ + //Create application + TAndroidApplication Application; + + Application.Width = 800; + Application.Height = 480; + + //Start application + return MainLoop(Application); +} \ No newline at end of file diff --git a/Templates/SalmonWallpaperTemplate/windows/Template/main.h b/Templates/SalmonWallpaperTemplate/windows/Template/main.h new file mode 100644 index 0000000..ec5d4b8 --- /dev/null +++ b/Templates/SalmonWallpaperTemplate/windows/Template/main.h @@ -0,0 +1,8 @@ +#pragma once + +/* Path to the engine */ +#include "include/Engine.h" + +#include "main_code.h" + +using namespace SE; \ No newline at end of file diff --git a/iOS/Halibut Engine/Halibut Engine.xcodeproj/project.pbxproj b/iOS/Halibut Engine/Halibut Engine.xcodeproj/project.pbxproj new file mode 100644 index 0000000..364d23b --- /dev/null +++ b/iOS/Halibut Engine/Halibut Engine.xcodeproj/project.pbxproj @@ -0,0 +1,832 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 4C77831B15BABFA6003D5142 /* SoundManagerInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C77831A15BABFA6003D5142 /* SoundManagerInterface.h */; }; + 4C77832215BAC035003D5142 /* SoundManagerIos.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4C77832115BAC035003D5142 /* SoundManagerIos.mm */; }; + 4C77832415BAC070003D5142 /* SoundManagerIos.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C77832315BAC070003D5142 /* SoundManagerIos.h */; }; + 4C79A59F15B1895B003F59D1 /* ScriptManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C79A59E15B1895B003F59D1 /* ScriptManager.cpp */; }; + 4C79A5A215B1896F003F59D1 /* ScriptManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C79A5A115B1896F003F59D1 /* ScriptManager.h */; }; + 4C79A5A615B189E0003F59D1 /* ButtonWidget.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C79A5A415B189E0003F59D1 /* ButtonWidget.h */; }; + 4C79A5A715B189E0003F59D1 /* GUIManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C79A5A515B189E0003F59D1 /* GUIManager.h */; }; + 4C79A5AB15B189F4003F59D1 /* ButtonWidget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C79A5A915B189F4003F59D1 /* ButtonWidget.cpp */; }; + 4C79A5AC15B189F4003F59D1 /* GUIManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C79A5AA15B189F4003F59D1 /* GUIManager.cpp */; }; + 4C79A5AF15B18A8B003F59D1 /* FrameManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C79A5AE15B18A8B003F59D1 /* FrameManager.h */; }; + 4C79A5B215B18A97003F59D1 /* FrameManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C79A5B115B18A97003F59D1 /* FrameManager.cpp */; }; + 4C79A5B515B18B0F003F59D1 /* FontManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C79A5B415B18B0F003F59D1 /* FontManager.h */; }; + 4C79A5B815B18B1C003F59D1 /* FontManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C79A5B715B18B1C003F59D1 /* FontManager.cpp */; }; + 4C79A5BB15B18B2B003F59D1 /* HalibutAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C79A5BA15B18B2B003F59D1 /* HalibutAnimation.h */; }; + 4C79A5BE15B18B38003F59D1 /* HalibutAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C79A5BD15B18B38003F59D1 /* HalibutAnimation.cpp */; }; + 4C79A5C015B18B9E003F59D1 /* HalibutRenderInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C79A5BF15B18B9E003F59D1 /* HalibutRenderInterface.h */; }; + 4C79A5C415B18BD4003F59D1 /* HalibutRenderInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C79A5C315B18BD4003F59D1 /* HalibutRenderInterface.cpp */; }; + 4C79A5C815B18D39003F59D1 /* HalibutRenderIos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C79A5C715B18D39003F59D1 /* HalibutRenderIos.cpp */; }; + 4C79A5CA15B18D4B003F59D1 /* HalibutRenderIos.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C79A5C915B18D4B003F59D1 /* HalibutRenderIos.h */; }; + 4C7AD45615B1E3D000A599F6 /* ApplicationInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C7AD45415B1E3D000A599F6 /* ApplicationInterface.cpp */; }; + 4C7AD45715B1E3D000A599F6 /* GlobalConst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C7AD45515B1E3D000A599F6 /* GlobalConst.cpp */; }; + 4C7AD45B15B1E3E300A599F6 /* ApplicationInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C7AD45915B1E3E200A599F6 /* ApplicationInterface.h */; }; + 4C7AD45C15B1E3E300A599F6 /* GlobalConst.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C7AD45A15B1E3E300A599F6 /* GlobalConst.h */; }; + 4C7B4F1E1675101300B5DBA3 /* WidgetTemplatesImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C7B4F1D1675101300B5DBA3 /* WidgetTemplatesImpl.h */; }; + 4C8B986E1660E8E500C3E258 /* WidgetXmlParsers.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8B986D1660E8E500C3E258 /* WidgetXmlParsers.h */; }; + 4C8B98711660E8F900C3E258 /* WidgetXmlParsers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8B98701660E8F900C3E258 /* WidgetXmlParsers.cpp */; }; + 4C8CE90615B0A0F400078175 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C8CE90515B0A0F400078175 /* Foundation.framework */; }; + 4C8CE91715B0A11A00078175 /* DataTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE91515B0A11A00078175 /* DataTypes.h */; }; + 4C8CE91815B0A11A00078175 /* NewDataTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE91615B0A11A00078175 /* NewDataTypes.h */; }; + 4C8CE91C15B0A12800078175 /* DataTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE91A15B0A12800078175 /* DataTypes.cpp */; }; + 4C8CE91D15B0A12800078175 /* NewDataTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE91B15B0A12800078175 /* NewDataTypes.cpp */; }; + 4C8CE93E15B0A56200078175 /* Console.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE93B15B0A56200078175 /* Console.cpp */; }; + 4C8CE93F15B0A56200078175 /* FileUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE93D15B0A56200078175 /* FileUtils.cpp */; }; + 4C8CE94615B0A57F00078175 /* console.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE94115B0A57F00078175 /* console.h */; }; + 4C8CE94715B0A57F00078175 /* ErrorTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE94315B0A57F00078175 /* ErrorTypes.h */; }; + 4C8CE94815B0A57F00078175 /* FileUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE94515B0A57F00078175 /* FileUtils.h */; }; + 4C8CE94A15B0A9DA00078175 /* Engine.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE94915B0A9DA00078175 /* Engine.h */; }; + 4C8CE94C15B0AA8000078175 /* Utils.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE94B15B0AA8000078175 /* Utils.h */; }; + 4C8CE94F15B0AA9600078175 /* SerializeInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE94E15B0AA9600078175 /* SerializeInterface.h */; }; + 4C8CE95215B0AAA900078175 /* SerializeInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE95115B0AAA900078175 /* SerializeInterface.cpp */; }; + 4C8CE95515B0AC2100078175 /* RenderInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE95315B0AC2100078175 /* RenderInterface.cpp */; }; + 4C8CE95615B0AC2100078175 /* RenderMisc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE95415B0AC2100078175 /* RenderMisc.cpp */; }; + 4C8CE95B15B0AC4B00078175 /* RenderInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE95915B0AC4B00078175 /* RenderInterface.h */; }; + 4C8CE95C15B0AC4B00078175 /* RenderMisc.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE95A15B0AC4B00078175 /* RenderMisc.h */; }; + 4C8CE96015B0B0FB00078175 /* HalibutEngineInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE95F15B0B0FB00078175 /* HalibutEngineInterface.h */; }; + 4C8CE96215B0B10B00078175 /* HalibutEngineInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE96115B0B10B00078175 /* HalibutEngineInterface.cpp */; }; + 4C8CE96515B0B1A600078175 /* SalmonTexture.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE96415B0B1A600078175 /* SalmonTexture.h */; }; + 4C8CE96815B0B1B700078175 /* SalmonTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE96715B0B1B700078175 /* SalmonTexture.cpp */; }; + 4C8CE96A15B0B2FD00078175 /* PngHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE96915B0B2FD00078175 /* PngHelper.cpp */; }; + 4C8CE96C15B0B31F00078175 /* PngHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE96B15B0B31F00078175 /* PngHelper.h */; }; + 4C8CE97015B0B44B00078175 /* HalibutEngineIos.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE96F15B0B44A00078175 /* HalibutEngineIos.h */; }; + 4C8CE97215B0B45600078175 /* HalibutEngineIos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE97115B0B45600078175 /* HalibutEngineIos.cpp */; }; + 4C8CE97515B0BB9700078175 /* ShaderManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE97415B0BB9700078175 /* ShaderManager.h */; }; + 4C8CE97815B0BBA800078175 /* ShaderManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE97715B0BBA800078175 /* ShaderManager.cpp */; }; + 4CC1FC3D15B20E440025C6F7 /* IosApi.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CC1FC3C15B20E440025C6F7 /* IosApi.h */; }; + 4CC1FC4015B20E5D0025C6F7 /* IosApi.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4CC1FC3F15B20E5D0025C6F7 /* IosApi.mm */; }; + 4CC857E016938B4B00110F77 /* RenderParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CC857DF16938B4B00110F77 /* RenderParams.h */; }; + 4CC857E316938B6B00110F77 /* RenderParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CC857E216938B6B00110F77 /* RenderParams.cpp */; }; + 4CD18A091672762D00EDC335 /* SmartValueManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CD18A081672762D00EDC335 /* SmartValueManager.h */; }; + 4CD18A0D1672764F00EDC335 /* SmartValueManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CD18A0C1672764F00EDC335 /* SmartValueManager.cpp */; }; + 4CEE2DBA15CDC05E00C4D5F5 /* HalibutRenderGLES20.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CEE2DB915CDC05E00C4D5F5 /* HalibutRenderGLES20.h */; }; + 4CEE2DBD15CDC07800C4D5F5 /* HalibutRenderGLES20.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CEE2DBC15CDC07800C4D5F5 /* HalibutRenderGLES20.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 4C77831A15BABFA6003D5142 /* SoundManagerInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SoundManagerInterface.h; path = ../../../include/SoundManager/SoundManagerInterface.h; sourceTree = ""; }; + 4C77832115BAC035003D5142 /* SoundManagerIos.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SoundManagerIos.mm; path = ../../../src/SoundManager/SoundManagerIos.mm; sourceTree = ""; }; + 4C77832315BAC070003D5142 /* SoundManagerIos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SoundManagerIos.h; path = ../../../include/SoundManager/SoundManagerIos.h; sourceTree = ""; }; + 4C79A59E15B1895B003F59D1 /* ScriptManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptManager.cpp; sourceTree = ""; }; + 4C79A5A115B1896F003F59D1 /* ScriptManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptManager.h; sourceTree = ""; }; + 4C79A5A415B189E0003F59D1 /* ButtonWidget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ButtonWidget.h; sourceTree = ""; }; + 4C79A5A515B189E0003F59D1 /* GUIManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIManager.h; sourceTree = ""; }; + 4C79A5A915B189F4003F59D1 /* ButtonWidget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ButtonWidget.cpp; sourceTree = ""; }; + 4C79A5AA15B189F4003F59D1 /* GUIManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUIManager.cpp; sourceTree = ""; }; + 4C79A5AE15B18A8B003F59D1 /* FrameManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FrameManager.h; sourceTree = ""; }; + 4C79A5B115B18A97003F59D1 /* FrameManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrameManager.cpp; sourceTree = ""; }; + 4C79A5B415B18B0F003F59D1 /* FontManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontManager.h; sourceTree = ""; }; + 4C79A5B715B18B1C003F59D1 /* FontManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontManager.cpp; sourceTree = ""; }; + 4C79A5BA15B18B2B003F59D1 /* HalibutAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HalibutAnimation.h; sourceTree = ""; }; + 4C79A5BD15B18B38003F59D1 /* HalibutAnimation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HalibutAnimation.cpp; sourceTree = ""; }; + 4C79A5BF15B18B9E003F59D1 /* HalibutRenderInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HalibutRenderInterface.h; path = ../../../include/Render/HalibutRender/HalibutRenderInterface.h; sourceTree = ""; }; + 4C79A5C315B18BD4003F59D1 /* HalibutRenderInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HalibutRenderInterface.cpp; path = ../../../src/Render/HalibutRender/HalibutRenderInterface.cpp; sourceTree = ""; }; + 4C79A5C715B18D39003F59D1 /* HalibutRenderIos.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HalibutRenderIos.cpp; path = ../../../src/Render/HalibutRender/HalibutRenderIos.cpp; sourceTree = ""; }; + 4C79A5C915B18D4B003F59D1 /* HalibutRenderIos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HalibutRenderIos.h; path = ../../../include/Render/HalibutRender/HalibutRenderIos.h; sourceTree = ""; }; + 4C7AD45415B1E3D000A599F6 /* ApplicationInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ApplicationInterface.cpp; path = ../../../src/ApplicationInterface.cpp; sourceTree = ""; }; + 4C7AD45515B1E3D000A599F6 /* GlobalConst.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GlobalConst.cpp; path = ../../../src/GlobalConst.cpp; sourceTree = ""; }; + 4C7AD45915B1E3E200A599F6 /* ApplicationInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ApplicationInterface.h; path = ../../../include/ApplicationInterface.h; sourceTree = ""; }; + 4C7AD45A15B1E3E300A599F6 /* GlobalConst.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GlobalConst.h; path = ../../../include/GlobalConst.h; sourceTree = ""; }; + 4C7B4F1D1675101300B5DBA3 /* WidgetTemplatesImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WidgetTemplatesImpl.h; sourceTree = ""; }; + 4C8B986D1660E8E500C3E258 /* WidgetXmlParsers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WidgetXmlParsers.h; sourceTree = ""; }; + 4C8B98701660E8F900C3E258 /* WidgetXmlParsers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WidgetXmlParsers.cpp; sourceTree = ""; }; + 4C8CE90215B0A0F400078175 /* libHalibut Engine.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libHalibut Engine.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 4C8CE90515B0A0F400078175 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 4C8CE90915B0A0F400078175 /* Halibut Engine-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Halibut Engine-Prefix.pch"; sourceTree = ""; }; + 4C8CE91515B0A11A00078175 /* DataTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataTypes.h; sourceTree = ""; }; + 4C8CE91615B0A11A00078175 /* NewDataTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewDataTypes.h; sourceTree = ""; }; + 4C8CE91A15B0A12800078175 /* DataTypes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataTypes.cpp; sourceTree = ""; }; + 4C8CE91B15B0A12800078175 /* NewDataTypes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewDataTypes.cpp; sourceTree = ""; }; + 4C8CE93B15B0A56200078175 /* Console.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Console.cpp; sourceTree = ""; }; + 4C8CE93D15B0A56200078175 /* FileUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileUtils.cpp; sourceTree = ""; }; + 4C8CE94115B0A57F00078175 /* console.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = console.h; sourceTree = ""; }; + 4C8CE94315B0A57F00078175 /* ErrorTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ErrorTypes.h; sourceTree = ""; }; + 4C8CE94515B0A57F00078175 /* FileUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileUtils.h; sourceTree = ""; }; + 4C8CE94915B0A9DA00078175 /* Engine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Engine.h; path = ../../../include/Engine.h; sourceTree = ""; }; + 4C8CE94B15B0AA8000078175 /* Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Utils.h; path = ../../../include/Utils/Utils.h; sourceTree = ""; }; + 4C8CE94E15B0AA9600078175 /* SerializeInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SerializeInterface.h; sourceTree = ""; }; + 4C8CE95115B0AAA900078175 /* SerializeInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SerializeInterface.cpp; sourceTree = ""; }; + 4C8CE95315B0AC2100078175 /* RenderInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderInterface.cpp; path = ../../../src/Render/RenderInterface.cpp; sourceTree = ""; }; + 4C8CE95415B0AC2100078175 /* RenderMisc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderMisc.cpp; path = ../../../src/Render/RenderMisc.cpp; sourceTree = ""; }; + 4C8CE95915B0AC4B00078175 /* RenderInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RenderInterface.h; path = ../../../include/Render/RenderInterface.h; sourceTree = ""; }; + 4C8CE95A15B0AC4B00078175 /* RenderMisc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RenderMisc.h; path = ../../../include/Render/RenderMisc.h; sourceTree = ""; }; + 4C8CE95F15B0B0FB00078175 /* HalibutEngineInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HalibutEngineInterface.h; path = ../../../include/HalibutEngineInterface.h; sourceTree = ""; }; + 4C8CE96115B0B10B00078175 /* HalibutEngineInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HalibutEngineInterface.cpp; path = ../../../src/HalibutEngineInterface.cpp; sourceTree = ""; }; + 4C8CE96415B0B1A600078175 /* SalmonTexture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SalmonTexture.h; sourceTree = ""; }; + 4C8CE96715B0B1B700078175 /* SalmonTexture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SalmonTexture.cpp; sourceTree = ""; }; + 4C8CE96915B0B2FD00078175 /* PngHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PngHelper.cpp; path = ../../../src/Utils/PngHelper.cpp; sourceTree = ""; }; + 4C8CE96B15B0B31F00078175 /* PngHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PngHelper.h; path = ../../../include/Utils/PngHelper.h; sourceTree = ""; }; + 4C8CE96F15B0B44A00078175 /* HalibutEngineIos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HalibutEngineIos.h; path = ../../../include/HalibutEngineIos.h; sourceTree = ""; }; + 4C8CE97115B0B45600078175 /* HalibutEngineIos.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HalibutEngineIos.cpp; path = ../../../src/HalibutEngineIos.cpp; sourceTree = ""; }; + 4C8CE97415B0BB9700078175 /* ShaderManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShaderManager.h; sourceTree = ""; }; + 4C8CE97715B0BBA800078175 /* ShaderManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderManager.cpp; sourceTree = ""; }; + 4CC1FC3C15B20E440025C6F7 /* IosApi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IosApi.h; sourceTree = ""; }; + 4CC1FC3F15B20E5D0025C6F7 /* IosApi.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IosApi.mm; sourceTree = ""; }; + 4CC857DF16938B4B00110F77 /* RenderParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RenderParams.h; path = ../../../include/Render/RenderParams.h; sourceTree = ""; }; + 4CC857E216938B6B00110F77 /* RenderParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderParams.cpp; path = ../../../src/Render/RenderParams.cpp; sourceTree = ""; }; + 4CD18A081672762D00EDC335 /* SmartValueManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SmartValueManager.h; sourceTree = ""; }; + 4CD18A0C1672764F00EDC335 /* SmartValueManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmartValueManager.cpp; sourceTree = ""; }; + 4CEE2DB915CDC05E00C4D5F5 /* HalibutRenderGLES20.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HalibutRenderGLES20.h; path = ../../../include/Render/HalibutRender/HalibutRenderGLES20.h; sourceTree = ""; }; + 4CEE2DBC15CDC07800C4D5F5 /* HalibutRenderGLES20.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HalibutRenderGLES20.cpp; path = ../../../src/Render/HalibutRender/HalibutRenderGLES20.cpp; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 4C8CE8FF15B0A0F400078175 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 4C8CE90615B0A0F400078175 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 4C77831D15BABFAB003D5142 /* SoundManager */ = { + isa = PBXGroup; + children = ( + 4C77831A15BABFA6003D5142 /* SoundManagerInterface.h */, + 4C77832315BAC070003D5142 /* SoundManagerIos.h */, + ); + name = SoundManager; + sourceTree = ""; + }; + 4C77831E15BABFC9003D5142 /* SoundManager */ = { + isa = PBXGroup; + children = ( + 4C77832115BAC035003D5142 /* SoundManagerIos.mm */, + ); + name = SoundManager; + sourceTree = ""; + }; + 4C79A59D15B1895B003F59D1 /* ScriptManager */ = { + isa = PBXGroup; + children = ( + 4C79A59E15B1895B003F59D1 /* ScriptManager.cpp */, + ); + name = ScriptManager; + path = ../../../src/ScriptManager; + sourceTree = ""; + }; + 4C79A5A015B1896F003F59D1 /* ScriptManager */ = { + isa = PBXGroup; + children = ( + 4C79A5A115B1896F003F59D1 /* ScriptManager.h */, + ); + name = ScriptManager; + path = ../../../include/ScriptManager; + sourceTree = ""; + }; + 4C79A5A315B189E0003F59D1 /* GUIManager */ = { + isa = PBXGroup; + children = ( + 4C7B4F1D1675101300B5DBA3 /* WidgetTemplatesImpl.h */, + 4C8B986D1660E8E500C3E258 /* WidgetXmlParsers.h */, + 4C79A5A415B189E0003F59D1 /* ButtonWidget.h */, + 4C79A5A515B189E0003F59D1 /* GUIManager.h */, + ); + name = GUIManager; + path = ../../../include/GUIManager; + sourceTree = ""; + }; + 4C79A5A815B189F4003F59D1 /* GUIManager */ = { + isa = PBXGroup; + children = ( + 4C8B98701660E8F900C3E258 /* WidgetXmlParsers.cpp */, + 4C79A5A915B189F4003F59D1 /* ButtonWidget.cpp */, + 4C79A5AA15B189F4003F59D1 /* GUIManager.cpp */, + ); + name = GUIManager; + path = ../../../src/GUIManager; + sourceTree = ""; + }; + 4C79A5AD15B18A8B003F59D1 /* FrameManager */ = { + isa = PBXGroup; + children = ( + 4C79A5AE15B18A8B003F59D1 /* FrameManager.h */, + ); + name = FrameManager; + path = ../../../include/FrameManager; + sourceTree = ""; + }; + 4C79A5B015B18A97003F59D1 /* FrameManager */ = { + isa = PBXGroup; + children = ( + 4C79A5B115B18A97003F59D1 /* FrameManager.cpp */, + ); + name = FrameManager; + path = ../../../src/FrameManager; + sourceTree = ""; + }; + 4C79A5B315B18B0F003F59D1 /* FontManager */ = { + isa = PBXGroup; + children = ( + 4C79A5B415B18B0F003F59D1 /* FontManager.h */, + ); + name = FontManager; + path = ../../../include/FontManager; + sourceTree = ""; + }; + 4C79A5B615B18B1C003F59D1 /* FontManager */ = { + isa = PBXGroup; + children = ( + 4C79A5B715B18B1C003F59D1 /* FontManager.cpp */, + ); + name = FontManager; + path = ../../../src/FontManager; + sourceTree = ""; + }; + 4C79A5B915B18B2B003F59D1 /* HalibutAnimation */ = { + isa = PBXGroup; + children = ( + 4C79A5BA15B18B2B003F59D1 /* HalibutAnimation.h */, + ); + name = HalibutAnimation; + path = ../../../include/HalibutAnimation; + sourceTree = ""; + }; + 4C79A5BC15B18B38003F59D1 /* HalibutAnimation */ = { + isa = PBXGroup; + children = ( + 4C79A5BD15B18B38003F59D1 /* HalibutAnimation.cpp */, + ); + name = HalibutAnimation; + path = ../../../src/HalibutAnimation; + sourceTree = ""; + }; + 4C79A5C115B18BA3003F59D1 /* HalibutRender */ = { + isa = PBXGroup; + children = ( + 4CEE2DB915CDC05E00C4D5F5 /* HalibutRenderGLES20.h */, + 4C79A5C915B18D4B003F59D1 /* HalibutRenderIos.h */, + 4C79A5BF15B18B9E003F59D1 /* HalibutRenderInterface.h */, + ); + name = HalibutRender; + sourceTree = ""; + }; + 4C79A5C215B18BB8003F59D1 /* HalibutRender */ = { + isa = PBXGroup; + children = ( + 4CEE2DBC15CDC07800C4D5F5 /* HalibutRenderGLES20.cpp */, + 4C79A5C715B18D39003F59D1 /* HalibutRenderIos.cpp */, + 4C79A5C315B18BD4003F59D1 /* HalibutRenderInterface.cpp */, + ); + name = HalibutRender; + sourceTree = ""; + }; + 4C8CE8F715B0A0F400078175 = { + isa = PBXGroup; + children = ( + 4C8CE90715B0A0F400078175 /* Halibut Engine */, + 4C8CE90415B0A0F400078175 /* Frameworks */, + 4C8CE90315B0A0F400078175 /* Products */, + ); + sourceTree = ""; + }; + 4C8CE90315B0A0F400078175 /* Products */ = { + isa = PBXGroup; + children = ( + 4C8CE90215B0A0F400078175 /* libHalibut Engine.a */, + ); + name = Products; + sourceTree = ""; + }; + 4C8CE90415B0A0F400078175 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 4C8CE90515B0A0F400078175 /* Foundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 4C8CE90715B0A0F400078175 /* Halibut Engine */ = { + isa = PBXGroup; + children = ( + 4C8CE91315B0A0FF00078175 /* include */, + 4C8CE91215B0A0FB00078175 /* src */, + 4C8CE90815B0A0F400078175 /* Supporting Files */, + ); + path = "Halibut Engine"; + sourceTree = ""; + }; + 4C8CE90815B0A0F400078175 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 4C8CE90915B0A0F400078175 /* Halibut Engine-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 4C8CE91215B0A0FB00078175 /* src */ = { + isa = PBXGroup; + children = ( + 4CD18A0B1672764F00EDC335 /* SmartValueManager */, + 4C77831E15BABFC9003D5142 /* SoundManager */, + 4C7AD45415B1E3D000A599F6 /* ApplicationInterface.cpp */, + 4C7AD45515B1E3D000A599F6 /* GlobalConst.cpp */, + 4C79A5BC15B18B38003F59D1 /* HalibutAnimation */, + 4C79A5B615B18B1C003F59D1 /* FontManager */, + 4C79A5B015B18A97003F59D1 /* FrameManager */, + 4C79A5A815B189F4003F59D1 /* GUIManager */, + 4C79A59D15B1895B003F59D1 /* ScriptManager */, + 4C8CE97615B0BBA800078175 /* ShaderManager */, + 4C8CE97115B0B45600078175 /* HalibutEngineIos.cpp */, + 4C8CE96615B0B1B700078175 /* TextureManager */, + 4C8CE96115B0B10B00078175 /* HalibutEngineInterface.cpp */, + 4C8CE95715B0AC2700078175 /* Render */, + 4C8CE93915B0A50F00078175 /* Utils */, + ); + name = src; + sourceTree = ""; + }; + 4C8CE91315B0A0FF00078175 /* include */ = { + isa = PBXGroup; + children = ( + 4CD18A071672762D00EDC335 /* SmartValueManager */, + 4C77831D15BABFAB003D5142 /* SoundManager */, + 4C7AD45915B1E3E200A599F6 /* ApplicationInterface.h */, + 4C7AD45A15B1E3E300A599F6 /* GlobalConst.h */, + 4C79A5B915B18B2B003F59D1 /* HalibutAnimation */, + 4C79A5B315B18B0F003F59D1 /* FontManager */, + 4C79A5AD15B18A8B003F59D1 /* FrameManager */, + 4C79A5A315B189E0003F59D1 /* GUIManager */, + 4C79A5A015B1896F003F59D1 /* ScriptManager */, + 4C8CE97315B0BB9700078175 /* ShaderManager */, + 4C8CE96315B0B1A500078175 /* TextureManager */, + 4C8CE95F15B0B0FB00078175 /* HalibutEngineInterface.h */, + 4C8CE95815B0AC3500078175 /* Render */, + 4C8CE94915B0A9DA00078175 /* Engine.h */, + 4C8CE96F15B0B44A00078175 /* HalibutEngineIos.h */, + 4C8CE93715B0A50200078175 /* Utils */, + ); + name = include; + sourceTree = ""; + }; + 4C8CE91415B0A11A00078175 /* DataTypes */ = { + isa = PBXGroup; + children = ( + 4C8CE91515B0A11A00078175 /* DataTypes.h */, + 4C8CE91615B0A11A00078175 /* NewDataTypes.h */, + ); + name = DataTypes; + path = ../../../include/Utils/DataTypes; + sourceTree = ""; + }; + 4C8CE91915B0A12800078175 /* DataTypes */ = { + isa = PBXGroup; + children = ( + 4C8CE91A15B0A12800078175 /* DataTypes.cpp */, + 4C8CE91B15B0A12800078175 /* NewDataTypes.cpp */, + ); + name = DataTypes; + path = ../../../src/Utils/DataTypes; + sourceTree = ""; + }; + 4C8CE93715B0A50200078175 /* Utils */ = { + isa = PBXGroup; + children = ( + 4CC1FC3B15B20E440025C6F7 /* IosApi */, + 4C8CE96B15B0B31F00078175 /* PngHelper.h */, + 4C8CE94B15B0AA8000078175 /* Utils.h */, + 4C8CE94D15B0AA9600078175 /* SerializeInterface */, + 4C8CE94015B0A57F00078175 /* Console */, + 4C8CE94215B0A57F00078175 /* ErrorTypes */, + 4C8CE94415B0A57F00078175 /* FileUtils */, + 4C8CE91415B0A11A00078175 /* DataTypes */, + ); + name = Utils; + sourceTree = ""; + }; + 4C8CE93915B0A50F00078175 /* Utils */ = { + isa = PBXGroup; + children = ( + 4CC1FC3E15B20E5D0025C6F7 /* IosApi */, + 4C8CE96915B0B2FD00078175 /* PngHelper.cpp */, + 4C8CE95015B0AAA900078175 /* SerializeInterface */, + 4C8CE93A15B0A56200078175 /* Console */, + 4C8CE93C15B0A56200078175 /* FileUtils */, + 4C8CE91915B0A12800078175 /* DataTypes */, + ); + name = Utils; + sourceTree = ""; + }; + 4C8CE93A15B0A56200078175 /* Console */ = { + isa = PBXGroup; + children = ( + 4C8CE93B15B0A56200078175 /* Console.cpp */, + ); + name = Console; + path = ../../../src/Utils/Console; + sourceTree = ""; + }; + 4C8CE93C15B0A56200078175 /* FileUtils */ = { + isa = PBXGroup; + children = ( + 4C8CE93D15B0A56200078175 /* FileUtils.cpp */, + ); + name = FileUtils; + path = ../../../src/Utils/FileUtils; + sourceTree = ""; + }; + 4C8CE94015B0A57F00078175 /* Console */ = { + isa = PBXGroup; + children = ( + 4C8CE94115B0A57F00078175 /* console.h */, + ); + name = Console; + path = ../../../include/Utils/Console; + sourceTree = ""; + }; + 4C8CE94215B0A57F00078175 /* ErrorTypes */ = { + isa = PBXGroup; + children = ( + 4C8CE94315B0A57F00078175 /* ErrorTypes.h */, + ); + name = ErrorTypes; + path = ../../../include/Utils/ErrorTypes; + sourceTree = ""; + }; + 4C8CE94415B0A57F00078175 /* FileUtils */ = { + isa = PBXGroup; + children = ( + 4C8CE94515B0A57F00078175 /* FileUtils.h */, + ); + name = FileUtils; + path = ../../../include/Utils/FileUtils; + sourceTree = ""; + }; + 4C8CE94D15B0AA9600078175 /* SerializeInterface */ = { + isa = PBXGroup; + children = ( + 4C8CE94E15B0AA9600078175 /* SerializeInterface.h */, + ); + name = SerializeInterface; + path = ../../../include/Utils/SerializeInterface; + sourceTree = ""; + }; + 4C8CE95015B0AAA900078175 /* SerializeInterface */ = { + isa = PBXGroup; + children = ( + 4C8CE95115B0AAA900078175 /* SerializeInterface.cpp */, + ); + name = SerializeInterface; + path = ../../../src/Utils/SerializeInterface; + sourceTree = ""; + }; + 4C8CE95715B0AC2700078175 /* Render */ = { + isa = PBXGroup; + children = ( + 4C79A5C215B18BB8003F59D1 /* HalibutRender */, + 4C8CE95315B0AC2100078175 /* RenderInterface.cpp */, + 4C8CE95415B0AC2100078175 /* RenderMisc.cpp */, + 4CC857E216938B6B00110F77 /* RenderParams.cpp */, + ); + name = Render; + sourceTree = ""; + }; + 4C8CE95815B0AC3500078175 /* Render */ = { + isa = PBXGroup; + children = ( + 4C79A5C115B18BA3003F59D1 /* HalibutRender */, + 4C8CE95915B0AC4B00078175 /* RenderInterface.h */, + 4C8CE95A15B0AC4B00078175 /* RenderMisc.h */, + 4CC857DF16938B4B00110F77 /* RenderParams.h */, + ); + name = Render; + sourceTree = ""; + }; + 4C8CE96315B0B1A500078175 /* TextureManager */ = { + isa = PBXGroup; + children = ( + 4C8CE96415B0B1A600078175 /* SalmonTexture.h */, + ); + name = TextureManager; + path = ../../../include/TextureManager; + sourceTree = ""; + }; + 4C8CE96615B0B1B700078175 /* TextureManager */ = { + isa = PBXGroup; + children = ( + 4C8CE96715B0B1B700078175 /* SalmonTexture.cpp */, + ); + name = TextureManager; + path = ../../../src/TextureManager; + sourceTree = ""; + }; + 4C8CE97315B0BB9700078175 /* ShaderManager */ = { + isa = PBXGroup; + children = ( + 4C8CE97415B0BB9700078175 /* ShaderManager.h */, + ); + name = ShaderManager; + path = ../../../include/ShaderManager; + sourceTree = ""; + }; + 4C8CE97615B0BBA800078175 /* ShaderManager */ = { + isa = PBXGroup; + children = ( + 4C8CE97715B0BBA800078175 /* ShaderManager.cpp */, + ); + name = ShaderManager; + path = ../../../src/ShaderManager; + sourceTree = ""; + }; + 4CC1FC3B15B20E440025C6F7 /* IosApi */ = { + isa = PBXGroup; + children = ( + 4CC1FC3C15B20E440025C6F7 /* IosApi.h */, + ); + name = IosApi; + path = ../../../include/Utils/IosApi; + sourceTree = ""; + }; + 4CC1FC3E15B20E5D0025C6F7 /* IosApi */ = { + isa = PBXGroup; + children = ( + 4CC1FC3F15B20E5D0025C6F7 /* IosApi.mm */, + ); + name = IosApi; + path = ../../../src/Utils/IosApi; + sourceTree = ""; + }; + 4CD18A071672762D00EDC335 /* SmartValueManager */ = { + isa = PBXGroup; + children = ( + 4CD18A081672762D00EDC335 /* SmartValueManager.h */, + ); + name = SmartValueManager; + path = ../../../include/SmartValueManager; + sourceTree = ""; + }; + 4CD18A0B1672764F00EDC335 /* SmartValueManager */ = { + isa = PBXGroup; + children = ( + 4CD18A0C1672764F00EDC335 /* SmartValueManager.cpp */, + ); + name = SmartValueManager; + path = ../../../src/SmartValueManager; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 4C8CE90015B0A0F400078175 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 4C8CE91715B0A11A00078175 /* DataTypes.h in Headers */, + 4C8CE91815B0A11A00078175 /* NewDataTypes.h in Headers */, + 4C8CE94615B0A57F00078175 /* console.h in Headers */, + 4C8CE94715B0A57F00078175 /* ErrorTypes.h in Headers */, + 4C8CE94815B0A57F00078175 /* FileUtils.h in Headers */, + 4C8CE94A15B0A9DA00078175 /* Engine.h in Headers */, + 4C8CE94C15B0AA8000078175 /* Utils.h in Headers */, + 4C8CE94F15B0AA9600078175 /* SerializeInterface.h in Headers */, + 4C8CE95B15B0AC4B00078175 /* RenderInterface.h in Headers */, + 4C8CE95C15B0AC4B00078175 /* RenderMisc.h in Headers */, + 4C8CE96015B0B0FB00078175 /* HalibutEngineInterface.h in Headers */, + 4C8CE96515B0B1A600078175 /* SalmonTexture.h in Headers */, + 4C8CE96C15B0B31F00078175 /* PngHelper.h in Headers */, + 4C8CE97015B0B44B00078175 /* HalibutEngineIos.h in Headers */, + 4C8CE97515B0BB9700078175 /* ShaderManager.h in Headers */, + 4C79A5A215B1896F003F59D1 /* ScriptManager.h in Headers */, + 4C79A5A615B189E0003F59D1 /* ButtonWidget.h in Headers */, + 4C79A5A715B189E0003F59D1 /* GUIManager.h in Headers */, + 4C79A5AF15B18A8B003F59D1 /* FrameManager.h in Headers */, + 4C79A5B515B18B0F003F59D1 /* FontManager.h in Headers */, + 4C79A5BB15B18B2B003F59D1 /* HalibutAnimation.h in Headers */, + 4C79A5C015B18B9E003F59D1 /* HalibutRenderInterface.h in Headers */, + 4C79A5CA15B18D4B003F59D1 /* HalibutRenderIos.h in Headers */, + 4C7AD45B15B1E3E300A599F6 /* ApplicationInterface.h in Headers */, + 4C7AD45C15B1E3E300A599F6 /* GlobalConst.h in Headers */, + 4CC1FC3D15B20E440025C6F7 /* IosApi.h in Headers */, + 4C77831B15BABFA6003D5142 /* SoundManagerInterface.h in Headers */, + 4C77832415BAC070003D5142 /* SoundManagerIos.h in Headers */, + 4CEE2DBA15CDC05E00C4D5F5 /* HalibutRenderGLES20.h in Headers */, + 4C8B986E1660E8E500C3E258 /* WidgetXmlParsers.h in Headers */, + 4CD18A091672762D00EDC335 /* SmartValueManager.h in Headers */, + 4C7B4F1E1675101300B5DBA3 /* WidgetTemplatesImpl.h in Headers */, + 4CC857E016938B4B00110F77 /* RenderParams.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 4C8CE90115B0A0F400078175 /* Halibut Engine */ = { + isa = PBXNativeTarget; + buildConfigurationList = 4C8CE90F15B0A0F400078175 /* Build configuration list for PBXNativeTarget "Halibut Engine" */; + buildPhases = ( + 4C8CE8FE15B0A0F400078175 /* Sources */, + 4C8CE8FF15B0A0F400078175 /* Frameworks */, + 4C8CE90015B0A0F400078175 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Halibut Engine"; + productName = "Halibut Engine"; + productReference = 4C8CE90215B0A0F400078175 /* libHalibut Engine.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 4C8CE8F915B0A0F400078175 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0430; + }; + buildConfigurationList = 4C8CE8FC15B0A0F400078175 /* Build configuration list for PBXProject "Halibut Engine" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 4C8CE8F715B0A0F400078175; + productRefGroup = 4C8CE90315B0A0F400078175 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 4C8CE90115B0A0F400078175 /* Halibut Engine */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 4C8CE8FE15B0A0F400078175 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4C8CE91C15B0A12800078175 /* DataTypes.cpp in Sources */, + 4C8CE91D15B0A12800078175 /* NewDataTypes.cpp in Sources */, + 4C8CE93E15B0A56200078175 /* Console.cpp in Sources */, + 4C8CE93F15B0A56200078175 /* FileUtils.cpp in Sources */, + 4C8CE95215B0AAA900078175 /* SerializeInterface.cpp in Sources */, + 4C8CE95515B0AC2100078175 /* RenderInterface.cpp in Sources */, + 4C8CE95615B0AC2100078175 /* RenderMisc.cpp in Sources */, + 4C8CE96215B0B10B00078175 /* HalibutEngineInterface.cpp in Sources */, + 4C8CE96815B0B1B700078175 /* SalmonTexture.cpp in Sources */, + 4C8CE96A15B0B2FD00078175 /* PngHelper.cpp in Sources */, + 4C8CE97215B0B45600078175 /* HalibutEngineIos.cpp in Sources */, + 4C8CE97815B0BBA800078175 /* ShaderManager.cpp in Sources */, + 4C79A59F15B1895B003F59D1 /* ScriptManager.cpp in Sources */, + 4C79A5AB15B189F4003F59D1 /* ButtonWidget.cpp in Sources */, + 4C79A5AC15B189F4003F59D1 /* GUIManager.cpp in Sources */, + 4C79A5B215B18A97003F59D1 /* FrameManager.cpp in Sources */, + 4C79A5B815B18B1C003F59D1 /* FontManager.cpp in Sources */, + 4C79A5BE15B18B38003F59D1 /* HalibutAnimation.cpp in Sources */, + 4C79A5C415B18BD4003F59D1 /* HalibutRenderInterface.cpp in Sources */, + 4C79A5C815B18D39003F59D1 /* HalibutRenderIos.cpp in Sources */, + 4C7AD45615B1E3D000A599F6 /* ApplicationInterface.cpp in Sources */, + 4C7AD45715B1E3D000A599F6 /* GlobalConst.cpp in Sources */, + 4CC1FC4015B20E5D0025C6F7 /* IosApi.mm in Sources */, + 4C77832215BAC035003D5142 /* SoundManagerIos.mm in Sources */, + 4CEE2DBD15CDC07800C4D5F5 /* HalibutRenderGLES20.cpp in Sources */, + 4C8B98711660E8F900C3E258 /* WidgetXmlParsers.cpp in Sources */, + 4CD18A0D1672764F00EDC335 /* SmartValueManager.cpp in Sources */, + 4CC857E316938B6B00110F77 /* RenderParams.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 4C8CE90D15B0A0F400078175 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 4C8CE90E15B0A0F400078175 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; + COPY_PHASE_STRIP = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 4C8CE91015B0A0F400078175 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + DSTROOT = /tmp/Halibut_Engine.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Halibut Engine/Halibut Engine-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + TARGET_IOS, + TARGET_HALIBUT, + DEBUG, + BOOST_NO_CXX11_NUMERIC_LIMITS, + ); + HEADER_SEARCH_PATHS = ( + ../../, + "$(LibsPath)/boost_1_52_0", + "$(LibsPath)/lpng1510", + "$(LibsPath)/sqplus/sqplus", + "$(LibsPath)/sqplus/include", + "$(LibsPath)/vorbis-tremor-ios/vorbis", + ); + INSTALL_PATH = ./debug; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + REZ_SEARCH_PATHS = ""; + SKIP_INSTALL = NO; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 4C8CE91115B0A0F400078175 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + DSTROOT = /tmp/Halibut_Engine.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Halibut Engine/Halibut Engine-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + TARGET_IOS, + TARGET_HALIBUT, + BOOST_NO_CXX11_NUMERIC_LIMITS, + ); + HEADER_SEARCH_PATHS = ( + ../../, + "$(LibsPath)/boost_1_52_0", + "$(LibsPath)/lpng1510", + "$(LibsPath)/sqplus/sqplus", + "$(LibsPath)/sqplus/include", + "$(LibsPath)/vorbis-tremor-ios/vorbis", + ); + INSTALL_PATH = ./release; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + REZ_SEARCH_PATHS = ""; + SKIP_INSTALL = NO; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 4C8CE8FC15B0A0F400078175 /* Build configuration list for PBXProject "Halibut Engine" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4C8CE90D15B0A0F400078175 /* Debug */, + 4C8CE90E15B0A0F400078175 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 4C8CE90F15B0A0F400078175 /* Build configuration list for PBXNativeTarget "Halibut Engine" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4C8CE91015B0A0F400078175 /* Debug */, + 4C8CE91115B0A0F400078175 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 4C8CE8F915B0A0F400078175 /* Project object */; +} diff --git a/iOS/Halibut Engine/Halibut Engine/Halibut Engine-Prefix.pch b/iOS/Halibut Engine/Halibut Engine/Halibut Engine-Prefix.pch new file mode 100644 index 0000000..bb827b1 --- /dev/null +++ b/iOS/Halibut Engine/Halibut Engine/Halibut Engine-Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'Halibut Engine' target in the 'Halibut Engine' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/iOS/Salmon Engine/Salmon Engine.xcodeproj/project.pbxproj b/iOS/Salmon Engine/Salmon Engine.xcodeproj/project.pbxproj new file mode 100644 index 0000000..facf408 --- /dev/null +++ b/iOS/Salmon Engine/Salmon Engine.xcodeproj/project.pbxproj @@ -0,0 +1,886 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 4C77831B15BABFA6003D5142 /* SoundManagerInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C77831A15BABFA6003D5142 /* SoundManagerInterface.h */; }; + 4C77832215BAC035003D5142 /* SoundManagerIos.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4C77832115BAC035003D5142 /* SoundManagerIos.mm */; }; + 4C77832415BAC070003D5142 /* SoundManagerIos.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C77832315BAC070003D5142 /* SoundManagerIos.h */; }; + 4C79A59F15B1895B003F59D1 /* ScriptManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C79A59E15B1895B003F59D1 /* ScriptManager.cpp */; }; + 4C79A5A215B1896F003F59D1 /* ScriptManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C79A5A115B1896F003F59D1 /* ScriptManager.h */; }; + 4C79A5AF15B18A8B003F59D1 /* FrameManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C79A5AE15B18A8B003F59D1 /* FrameManager.h */; }; + 4C79A5B215B18A97003F59D1 /* FrameManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C79A5B115B18A97003F59D1 /* FrameManager.cpp */; }; + 4C79A5B515B18B0F003F59D1 /* FontManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C79A5B415B18B0F003F59D1 /* FontManager.h */; }; + 4C79A5B815B18B1C003F59D1 /* FontManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C79A5B715B18B1C003F59D1 /* FontManager.cpp */; }; + 4C7AD45615B1E3D000A599F6 /* ApplicationInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C7AD45415B1E3D000A599F6 /* ApplicationInterface.cpp */; }; + 4C7AD45715B1E3D000A599F6 /* GlobalConst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C7AD45515B1E3D000A599F6 /* GlobalConst.cpp */; }; + 4C7AD45B15B1E3E300A599F6 /* ApplicationInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C7AD45915B1E3E200A599F6 /* ApplicationInterface.h */; }; + 4C7AD45C15B1E3E300A599F6 /* GlobalConst.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C7AD45A15B1E3E300A599F6 /* GlobalConst.h */; }; + 4C8CE90615B0A0F400078175 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C8CE90515B0A0F400078175 /* Foundation.framework */; }; + 4C8CE91715B0A11A00078175 /* DataTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE91515B0A11A00078175 /* DataTypes.h */; }; + 4C8CE91815B0A11A00078175 /* NewDataTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE91615B0A11A00078175 /* NewDataTypes.h */; }; + 4C8CE93E15B0A56200078175 /* Console.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE93B15B0A56200078175 /* Console.cpp */; }; + 4C8CE93F15B0A56200078175 /* FileUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE93D15B0A56200078175 /* FileUtils.cpp */; }; + 4C8CE94615B0A57F00078175 /* console.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE94115B0A57F00078175 /* console.h */; }; + 4C8CE94715B0A57F00078175 /* ErrorTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE94315B0A57F00078175 /* ErrorTypes.h */; }; + 4C8CE94815B0A57F00078175 /* FileUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE94515B0A57F00078175 /* FileUtils.h */; }; + 4C8CE94A15B0A9DA00078175 /* Engine.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE94915B0A9DA00078175 /* Engine.h */; }; + 4C8CE94C15B0AA8000078175 /* Utils.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE94B15B0AA8000078175 /* Utils.h */; }; + 4C8CE94F15B0AA9600078175 /* SerializeInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE94E15B0AA9600078175 /* SerializeInterface.h */; }; + 4C8CE95215B0AAA900078175 /* SerializeInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE95115B0AAA900078175 /* SerializeInterface.cpp */; }; + 4C8CE95515B0AC2100078175 /* RenderInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE95315B0AC2100078175 /* RenderInterface.cpp */; }; + 4C8CE95615B0AC2100078175 /* RenderMisc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE95415B0AC2100078175 /* RenderMisc.cpp */; }; + 4C8CE95B15B0AC4B00078175 /* RenderInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE95915B0AC4B00078175 /* RenderInterface.h */; }; + 4C8CE95C15B0AC4B00078175 /* RenderMisc.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE95A15B0AC4B00078175 /* RenderMisc.h */; }; + 4C8CE96515B0B1A600078175 /* SalmonTexture.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE96415B0B1A600078175 /* SalmonTexture.h */; }; + 4C8CE96815B0B1B700078175 /* SalmonTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE96715B0B1B700078175 /* SalmonTexture.cpp */; }; + 4C8CE96A15B0B2FD00078175 /* PngHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE96915B0B2FD00078175 /* PngHelper.cpp */; }; + 4C8CE96C15B0B31F00078175 /* PngHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE96B15B0B31F00078175 /* PngHelper.h */; }; + 4C8CE97515B0BB9700078175 /* ShaderManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C8CE97415B0BB9700078175 /* ShaderManager.h */; }; + 4C8CE97815B0BBA800078175 /* ShaderManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C8CE97715B0BBA800078175 /* ShaderManager.cpp */; }; + 4C902A2B15C565E900FBC901 /* Salmon Engine-Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = 4C902A2A15C565E900FBC901 /* Salmon Engine-Prefix.pch */; }; + 4C902A2E15C5667800FBC901 /* DataTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C902A2C15C5667800FBC901 /* DataTypes.cpp */; }; + 4C902A2F15C5667800FBC901 /* NewDataTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C902A2D15C5667800FBC901 /* NewDataTypes.cpp */; }; + 4C902A3715C56A4800FBC901 /* BackgroundCubemap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C902A3415C56A4800FBC901 /* BackgroundCubemap.cpp */; }; + 4C902A3815C56A4800FBC901 /* SalmonRenderInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C902A3515C56A4800FBC901 /* SalmonRenderInterface.cpp */; }; + 4C902A3915C56A4800FBC901 /* SalmonRenderIos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C902A3615C56A4800FBC901 /* SalmonRenderIos.cpp */; }; + 4C902A3D15C56A7300FBC901 /* SalmonEngineInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C902A3B15C56A7300FBC901 /* SalmonEngineInterface.cpp */; }; + 4C902A3E15C56A7300FBC901 /* SalmonEngineIos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C902A3C15C56A7300FBC901 /* SalmonEngineIos.cpp */; }; + 4C902A4315C56AEA00FBC901 /* BackgroundCubemap.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C902A4015C56AEA00FBC901 /* BackgroundCubemap.h */; }; + 4C902A4415C56AEA00FBC901 /* SalmonRenderInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C902A4115C56AEA00FBC901 /* SalmonRenderInterface.h */; }; + 4C902A4515C56AEA00FBC901 /* SalmonRenderIos.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C902A4215C56AEA00FBC901 /* SalmonRenderIos.h */; }; + 4C902A4C15C56B3700FBC901 /* SalmonEngineInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C902A4A15C56B3700FBC901 /* SalmonEngineInterface.h */; }; + 4C902A4D15C56B3700FBC901 /* SalmonEngineIos.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C902A4B15C56B3700FBC901 /* SalmonEngineIos.h */; }; + 4C902A5615C56BEE00FBC901 /* SalmonAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C902A4F15C56BEE00FBC901 /* SalmonAnimation.cpp */; }; + 4C902A5715C56BEE00FBC901 /* LightManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C902A5115C56BEE00FBC901 /* LightManager.cpp */; }; + 4C902A5815C56BEE00FBC901 /* ModelManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C902A5315C56BEE00FBC901 /* ModelManager.cpp */; }; + 4C902A5915C56BEE00FBC901 /* SimpleLand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C902A5515C56BEE00FBC901 /* SimpleLand.cpp */; }; + 4C902A6215C56C0900FBC901 /* SalmonAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C902A5B15C56C0900FBC901 /* SalmonAnimation.h */; }; + 4C902A6315C56C0900FBC901 /* LightManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C902A5D15C56C0900FBC901 /* LightManager.h */; }; + 4C902A6415C56C0900FBC901 /* ModelManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C902A5F15C56C0900FBC901 /* ModelManager.h */; }; + 4C902A6515C56C0900FBC901 /* SimpleLand.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C902A6115C56C0900FBC901 /* SimpleLand.h */; }; + 4CC1FC3D15B20E440025C6F7 /* IosApi.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CC1FC3C15B20E440025C6F7 /* IosApi.h */; }; + 4CC1FC4015B20E5D0025C6F7 /* IosApi.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4CC1FC3F15B20E5D0025C6F7 /* IosApi.mm */; }; + 4CC857CD1693865C00110F77 /* NewModelManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CC857CC1693865C00110F77 /* NewModelManager.cpp */; }; + 4CC857D01693867D00110F77 /* RenderParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CC857CF1693867D00110F77 /* RenderParams.cpp */; }; + 4CC857D2169386A300110F77 /* RenderParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CC857D1169386A300110F77 /* RenderParams.h */; }; + 4CC857D4169386BD00110F77 /* NewModelManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CC857D3169386BD00110F77 /* NewModelManager.h */; }; + 4CD18A1A16727C3F00EDC335 /* SmartValueManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CD18A1916727C3F00EDC335 /* SmartValueManager.cpp */; }; + 4CD18A1E16727C4E00EDC335 /* SmartValueManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CD18A1D16727C4E00EDC335 /* SmartValueManager.h */; }; + 4CD18A2016727D4A00EDC335 /* BindableVar.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CD18A1F16727D4A00EDC335 /* BindableVar.h */; }; + 4CEE2DD215CDC55B00C4D5F5 /* SalmonRenderGLES20.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CEE2DD115CDC55B00C4D5F5 /* SalmonRenderGLES20.h */; }; + 4CEE2DD515CDC57200C4D5F5 /* SalmonRenderGLES20.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CEE2DD415CDC57200C4D5F5 /* SalmonRenderGLES20.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 4C77831A15BABFA6003D5142 /* SoundManagerInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SoundManagerInterface.h; path = ../../../include/SoundManager/SoundManagerInterface.h; sourceTree = ""; }; + 4C77832115BAC035003D5142 /* SoundManagerIos.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SoundManagerIos.mm; path = ../../../src/SoundManager/SoundManagerIos.mm; sourceTree = ""; }; + 4C77832315BAC070003D5142 /* SoundManagerIos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SoundManagerIos.h; path = ../../../include/SoundManager/SoundManagerIos.h; sourceTree = ""; }; + 4C79A59E15B1895B003F59D1 /* ScriptManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptManager.cpp; sourceTree = ""; }; + 4C79A5A115B1896F003F59D1 /* ScriptManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptManager.h; sourceTree = ""; }; + 4C79A5AE15B18A8B003F59D1 /* FrameManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FrameManager.h; sourceTree = ""; }; + 4C79A5B115B18A97003F59D1 /* FrameManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrameManager.cpp; sourceTree = ""; }; + 4C79A5B415B18B0F003F59D1 /* FontManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontManager.h; sourceTree = ""; }; + 4C79A5B715B18B1C003F59D1 /* FontManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontManager.cpp; sourceTree = ""; }; + 4C7AD45415B1E3D000A599F6 /* ApplicationInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ApplicationInterface.cpp; path = ../../../src/ApplicationInterface.cpp; sourceTree = ""; }; + 4C7AD45515B1E3D000A599F6 /* GlobalConst.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GlobalConst.cpp; path = ../../../src/GlobalConst.cpp; sourceTree = ""; }; + 4C7AD45915B1E3E200A599F6 /* ApplicationInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ApplicationInterface.h; path = ../../../include/ApplicationInterface.h; sourceTree = ""; }; + 4C7AD45A15B1E3E300A599F6 /* GlobalConst.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GlobalConst.h; path = ../../../include/GlobalConst.h; sourceTree = ""; }; + 4C8CE90215B0A0F400078175 /* libSalmon Engine.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libSalmon Engine.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 4C8CE90515B0A0F400078175 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 4C8CE91515B0A11A00078175 /* DataTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataTypes.h; sourceTree = ""; }; + 4C8CE91615B0A11A00078175 /* NewDataTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewDataTypes.h; sourceTree = ""; }; + 4C8CE93B15B0A56200078175 /* Console.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Console.cpp; sourceTree = ""; }; + 4C8CE93D15B0A56200078175 /* FileUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileUtils.cpp; sourceTree = ""; }; + 4C8CE94115B0A57F00078175 /* console.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = console.h; sourceTree = ""; }; + 4C8CE94315B0A57F00078175 /* ErrorTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ErrorTypes.h; sourceTree = ""; }; + 4C8CE94515B0A57F00078175 /* FileUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileUtils.h; sourceTree = ""; }; + 4C8CE94915B0A9DA00078175 /* Engine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Engine.h; path = ../../../include/Engine.h; sourceTree = ""; }; + 4C8CE94B15B0AA8000078175 /* Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Utils.h; path = ../../../include/Utils/Utils.h; sourceTree = ""; }; + 4C8CE94E15B0AA9600078175 /* SerializeInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SerializeInterface.h; sourceTree = ""; }; + 4C8CE95115B0AAA900078175 /* SerializeInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SerializeInterface.cpp; sourceTree = ""; }; + 4C8CE95315B0AC2100078175 /* RenderInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderInterface.cpp; path = ../../../src/Render/RenderInterface.cpp; sourceTree = ""; }; + 4C8CE95415B0AC2100078175 /* RenderMisc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderMisc.cpp; path = ../../../src/Render/RenderMisc.cpp; sourceTree = ""; }; + 4C8CE95915B0AC4B00078175 /* RenderInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RenderInterface.h; path = ../../../include/Render/RenderInterface.h; sourceTree = ""; }; + 4C8CE95A15B0AC4B00078175 /* RenderMisc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RenderMisc.h; path = ../../../include/Render/RenderMisc.h; sourceTree = ""; }; + 4C8CE96415B0B1A600078175 /* SalmonTexture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SalmonTexture.h; sourceTree = ""; }; + 4C8CE96715B0B1B700078175 /* SalmonTexture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SalmonTexture.cpp; sourceTree = ""; }; + 4C8CE96915B0B2FD00078175 /* PngHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PngHelper.cpp; path = ../../../src/Utils/PngHelper.cpp; sourceTree = ""; }; + 4C8CE96B15B0B31F00078175 /* PngHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PngHelper.h; path = ../../../include/Utils/PngHelper.h; sourceTree = ""; }; + 4C8CE97415B0BB9700078175 /* ShaderManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShaderManager.h; sourceTree = ""; }; + 4C8CE97715B0BBA800078175 /* ShaderManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShaderManager.cpp; sourceTree = ""; }; + 4C902A2A15C565E900FBC901 /* Salmon Engine-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "Salmon Engine-Prefix.pch"; path = "Salmon Engine/Salmon Engine-Prefix.pch"; sourceTree = SOURCE_ROOT; }; + 4C902A2C15C5667800FBC901 /* DataTypes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataTypes.cpp; sourceTree = ""; }; + 4C902A2D15C5667800FBC901 /* NewDataTypes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewDataTypes.cpp; sourceTree = ""; }; + 4C902A3415C56A4800FBC901 /* BackgroundCubemap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BackgroundCubemap.cpp; path = ../../../src/Render/SalmonRender/BackgroundCubemap.cpp; sourceTree = ""; }; + 4C902A3515C56A4800FBC901 /* SalmonRenderInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SalmonRenderInterface.cpp; path = ../../../src/Render/SalmonRender/SalmonRenderInterface.cpp; sourceTree = ""; }; + 4C902A3615C56A4800FBC901 /* SalmonRenderIos.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SalmonRenderIos.cpp; path = ../../../src/Render/SalmonRender/SalmonRenderIos.cpp; sourceTree = ""; }; + 4C902A3B15C56A7300FBC901 /* SalmonEngineInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SalmonEngineInterface.cpp; path = ../../../src/SalmonEngineInterface.cpp; sourceTree = ""; }; + 4C902A3C15C56A7300FBC901 /* SalmonEngineIos.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SalmonEngineIos.cpp; path = ../../../src/SalmonEngineIos.cpp; sourceTree = ""; }; + 4C902A4015C56AEA00FBC901 /* BackgroundCubemap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BackgroundCubemap.h; path = ../../../include/Render/SalmonRender/BackgroundCubemap.h; sourceTree = ""; }; + 4C902A4115C56AEA00FBC901 /* SalmonRenderInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SalmonRenderInterface.h; path = ../../../include/Render/SalmonRender/SalmonRenderInterface.h; sourceTree = ""; }; + 4C902A4215C56AEA00FBC901 /* SalmonRenderIos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SalmonRenderIos.h; path = ../../../include/Render/SalmonRender/SalmonRenderIos.h; sourceTree = ""; }; + 4C902A4A15C56B3700FBC901 /* SalmonEngineInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SalmonEngineInterface.h; path = ../../../include/SalmonEngineInterface.h; sourceTree = ""; }; + 4C902A4B15C56B3700FBC901 /* SalmonEngineIos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SalmonEngineIos.h; path = ../../../include/SalmonEngineIos.h; sourceTree = ""; }; + 4C902A4F15C56BEE00FBC901 /* SalmonAnimation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SalmonAnimation.cpp; sourceTree = ""; }; + 4C902A5115C56BEE00FBC901 /* LightManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LightManager.cpp; sourceTree = ""; }; + 4C902A5315C56BEE00FBC901 /* ModelManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModelManager.cpp; sourceTree = ""; }; + 4C902A5515C56BEE00FBC901 /* SimpleLand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLand.cpp; sourceTree = ""; }; + 4C902A5B15C56C0900FBC901 /* SalmonAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SalmonAnimation.h; sourceTree = ""; }; + 4C902A5D15C56C0900FBC901 /* LightManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LightManager.h; sourceTree = ""; }; + 4C902A5F15C56C0900FBC901 /* ModelManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModelManager.h; sourceTree = ""; }; + 4C902A6115C56C0900FBC901 /* SimpleLand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLand.h; sourceTree = ""; }; + 4CC1FC3C15B20E440025C6F7 /* IosApi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IosApi.h; sourceTree = ""; }; + 4CC1FC3F15B20E5D0025C6F7 /* IosApi.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IosApi.mm; sourceTree = ""; }; + 4CC857CC1693865C00110F77 /* NewModelManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewModelManager.cpp; sourceTree = ""; }; + 4CC857CF1693867D00110F77 /* RenderParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderParams.cpp; path = ../../../src/Render/RenderParams.cpp; sourceTree = ""; }; + 4CC857D1169386A300110F77 /* RenderParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RenderParams.h; path = ../../../include/Render/RenderParams.h; sourceTree = ""; }; + 4CC857D3169386BD00110F77 /* NewModelManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewModelManager.h; sourceTree = ""; }; + 4CD18A1916727C3F00EDC335 /* SmartValueManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmartValueManager.cpp; sourceTree = ""; }; + 4CD18A1D16727C4E00EDC335 /* SmartValueManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SmartValueManager.h; sourceTree = ""; }; + 4CD18A1F16727D4A00EDC335 /* BindableVar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BindableVar.h; path = ../../../include/Utils/BindableVar.h; sourceTree = ""; }; + 4CEE2DD115CDC55B00C4D5F5 /* SalmonRenderGLES20.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SalmonRenderGLES20.h; path = ../../../include/Render/SalmonRender/SalmonRenderGLES20.h; sourceTree = ""; }; + 4CEE2DD415CDC57200C4D5F5 /* SalmonRenderGLES20.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SalmonRenderGLES20.cpp; path = ../../../src/Render/SalmonRender/SalmonRenderGLES20.cpp; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 4C8CE8FF15B0A0F400078175 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 4C8CE90615B0A0F400078175 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 4C77831D15BABFAB003D5142 /* SoundManager */ = { + isa = PBXGroup; + children = ( + 4C77831A15BABFA6003D5142 /* SoundManagerInterface.h */, + 4C77832315BAC070003D5142 /* SoundManagerIos.h */, + ); + name = SoundManager; + sourceTree = ""; + }; + 4C77831E15BABFC9003D5142 /* SoundManager */ = { + isa = PBXGroup; + children = ( + 4C77832115BAC035003D5142 /* SoundManagerIos.mm */, + ); + name = SoundManager; + sourceTree = ""; + }; + 4C79A59D15B1895B003F59D1 /* ScriptManager */ = { + isa = PBXGroup; + children = ( + 4C79A59E15B1895B003F59D1 /* ScriptManager.cpp */, + ); + name = ScriptManager; + path = ../../../src/ScriptManager; + sourceTree = ""; + }; + 4C79A5A015B1896F003F59D1 /* ScriptManager */ = { + isa = PBXGroup; + children = ( + 4C79A5A115B1896F003F59D1 /* ScriptManager.h */, + ); + name = ScriptManager; + path = ../../../include/ScriptManager; + sourceTree = ""; + }; + 4C79A5AD15B18A8B003F59D1 /* FrameManager */ = { + isa = PBXGroup; + children = ( + 4C79A5AE15B18A8B003F59D1 /* FrameManager.h */, + ); + name = FrameManager; + path = ../../../include/FrameManager; + sourceTree = ""; + }; + 4C79A5B015B18A97003F59D1 /* FrameManager */ = { + isa = PBXGroup; + children = ( + 4C79A5B115B18A97003F59D1 /* FrameManager.cpp */, + ); + name = FrameManager; + path = ../../../src/FrameManager; + sourceTree = ""; + }; + 4C79A5B315B18B0F003F59D1 /* FontManager */ = { + isa = PBXGroup; + children = ( + 4C79A5B415B18B0F003F59D1 /* FontManager.h */, + ); + name = FontManager; + path = ../../../include/FontManager; + sourceTree = ""; + }; + 4C79A5B615B18B1C003F59D1 /* FontManager */ = { + isa = PBXGroup; + children = ( + 4C79A5B715B18B1C003F59D1 /* FontManager.cpp */, + ); + name = FontManager; + path = ../../../src/FontManager; + sourceTree = ""; + }; + 4C8CE8F715B0A0F400078175 = { + isa = PBXGroup; + children = ( + 4C8CE90715B0A0F400078175 /* Salmon Engine */, + 4C8CE90415B0A0F400078175 /* Frameworks */, + 4C8CE90315B0A0F400078175 /* Products */, + ); + sourceTree = ""; + }; + 4C8CE90315B0A0F400078175 /* Products */ = { + isa = PBXGroup; + children = ( + 4C8CE90215B0A0F400078175 /* libSalmon Engine.a */, + ); + name = Products; + sourceTree = ""; + }; + 4C8CE90415B0A0F400078175 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 4C8CE90515B0A0F400078175 /* Foundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 4C8CE90715B0A0F400078175 /* Salmon Engine */ = { + isa = PBXGroup; + children = ( + 4C8CE91315B0A0FF00078175 /* include */, + 4C8CE91215B0A0FB00078175 /* src */, + 4C8CE90815B0A0F400078175 /* Supporting Files */, + ); + path = "Salmon Engine"; + sourceTree = ""; + }; + 4C8CE90815B0A0F400078175 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 4C902A2A15C565E900FBC901 /* Salmon Engine-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 4C8CE91215B0A0FB00078175 /* src */ = { + isa = PBXGroup; + children = ( + 4CD18A1816727C3F00EDC335 /* SmartValueManager */, + 4C902A4E15C56BEE00FBC901 /* Animation */, + 4C902A5015C56BEE00FBC901 /* LightManager */, + 4C902A5215C56BEE00FBC901 /* ModelManager */, + 4C902A5415C56BEE00FBC901 /* SimpleLand */, + 4C902A3B15C56A7300FBC901 /* SalmonEngineInterface.cpp */, + 4C902A3C15C56A7300FBC901 /* SalmonEngineIos.cpp */, + 4C77831E15BABFC9003D5142 /* SoundManager */, + 4C7AD45415B1E3D000A599F6 /* ApplicationInterface.cpp */, + 4C7AD45515B1E3D000A599F6 /* GlobalConst.cpp */, + 4C79A5B615B18B1C003F59D1 /* FontManager */, + 4C79A5B015B18A97003F59D1 /* FrameManager */, + 4C79A59D15B1895B003F59D1 /* ScriptManager */, + 4C8CE97615B0BBA800078175 /* ShaderManager */, + 4C8CE96615B0B1B700078175 /* TextureManager */, + 4C8CE95715B0AC2700078175 /* Render */, + 4C8CE93915B0A50F00078175 /* Utils */, + ); + name = src; + sourceTree = ""; + }; + 4C8CE91315B0A0FF00078175 /* include */ = { + isa = PBXGroup; + children = ( + 4CD18A1C16727C4E00EDC335 /* SmartValueManager */, + 4C902A5A15C56C0900FBC901 /* Animation */, + 4C902A5C15C56C0900FBC901 /* LightManager */, + 4C902A5E15C56C0900FBC901 /* ModelManager */, + 4C902A6015C56C0900FBC901 /* SimpleLand */, + 4C902A4A15C56B3700FBC901 /* SalmonEngineInterface.h */, + 4C902A4B15C56B3700FBC901 /* SalmonEngineIos.h */, + 4C77831D15BABFAB003D5142 /* SoundManager */, + 4C7AD45915B1E3E200A599F6 /* ApplicationInterface.h */, + 4C7AD45A15B1E3E300A599F6 /* GlobalConst.h */, + 4C79A5B315B18B0F003F59D1 /* FontManager */, + 4C79A5AD15B18A8B003F59D1 /* FrameManager */, + 4C79A5A015B1896F003F59D1 /* ScriptManager */, + 4C8CE97315B0BB9700078175 /* ShaderManager */, + 4C8CE96315B0B1A500078175 /* TextureManager */, + 4C8CE95815B0AC3500078175 /* Render */, + 4C8CE94915B0A9DA00078175 /* Engine.h */, + 4C8CE93715B0A50200078175 /* Utils */, + ); + name = include; + sourceTree = ""; + }; + 4C8CE91415B0A11A00078175 /* DataTypes */ = { + isa = PBXGroup; + children = ( + 4C8CE91515B0A11A00078175 /* DataTypes.h */, + 4C8CE91615B0A11A00078175 /* NewDataTypes.h */, + ); + name = DataTypes; + path = ../../../include/Utils/DataTypes; + sourceTree = ""; + }; + 4C8CE91915B0A12800078175 /* DataTypes */ = { + isa = PBXGroup; + children = ( + 4C902A2C15C5667800FBC901 /* DataTypes.cpp */, + 4C902A2D15C5667800FBC901 /* NewDataTypes.cpp */, + ); + name = DataTypes; + path = ../../../src/Utils/DataTypes; + sourceTree = ""; + }; + 4C8CE93715B0A50200078175 /* Utils */ = { + isa = PBXGroup; + children = ( + 4CD18A1F16727D4A00EDC335 /* BindableVar.h */, + 4CC1FC3B15B20E440025C6F7 /* IosApi */, + 4C8CE96B15B0B31F00078175 /* PngHelper.h */, + 4C8CE94B15B0AA8000078175 /* Utils.h */, + 4C8CE94D15B0AA9600078175 /* SerializeInterface */, + 4C8CE94015B0A57F00078175 /* Console */, + 4C8CE94215B0A57F00078175 /* ErrorTypes */, + 4C8CE94415B0A57F00078175 /* FileUtils */, + 4C8CE91415B0A11A00078175 /* DataTypes */, + ); + name = Utils; + sourceTree = ""; + }; + 4C8CE93915B0A50F00078175 /* Utils */ = { + isa = PBXGroup; + children = ( + 4CC1FC3E15B20E5D0025C6F7 /* IosApi */, + 4C8CE96915B0B2FD00078175 /* PngHelper.cpp */, + 4C8CE95015B0AAA900078175 /* SerializeInterface */, + 4C8CE93A15B0A56200078175 /* Console */, + 4C8CE93C15B0A56200078175 /* FileUtils */, + 4C8CE91915B0A12800078175 /* DataTypes */, + ); + name = Utils; + sourceTree = ""; + }; + 4C8CE93A15B0A56200078175 /* Console */ = { + isa = PBXGroup; + children = ( + 4C8CE93B15B0A56200078175 /* Console.cpp */, + ); + name = Console; + path = ../../../src/Utils/Console; + sourceTree = ""; + }; + 4C8CE93C15B0A56200078175 /* FileUtils */ = { + isa = PBXGroup; + children = ( + 4C8CE93D15B0A56200078175 /* FileUtils.cpp */, + ); + name = FileUtils; + path = ../../../src/Utils/FileUtils; + sourceTree = ""; + }; + 4C8CE94015B0A57F00078175 /* Console */ = { + isa = PBXGroup; + children = ( + 4C8CE94115B0A57F00078175 /* console.h */, + ); + name = Console; + path = ../../../include/Utils/Console; + sourceTree = ""; + }; + 4C8CE94215B0A57F00078175 /* ErrorTypes */ = { + isa = PBXGroup; + children = ( + 4C8CE94315B0A57F00078175 /* ErrorTypes.h */, + ); + name = ErrorTypes; + path = ../../../include/Utils/ErrorTypes; + sourceTree = ""; + }; + 4C8CE94415B0A57F00078175 /* FileUtils */ = { + isa = PBXGroup; + children = ( + 4C8CE94515B0A57F00078175 /* FileUtils.h */, + ); + name = FileUtils; + path = ../../../include/Utils/FileUtils; + sourceTree = ""; + }; + 4C8CE94D15B0AA9600078175 /* SerializeInterface */ = { + isa = PBXGroup; + children = ( + 4C8CE94E15B0AA9600078175 /* SerializeInterface.h */, + ); + name = SerializeInterface; + path = ../../../include/Utils/SerializeInterface; + sourceTree = ""; + }; + 4C8CE95015B0AAA900078175 /* SerializeInterface */ = { + isa = PBXGroup; + children = ( + 4C8CE95115B0AAA900078175 /* SerializeInterface.cpp */, + ); + name = SerializeInterface; + path = ../../../src/Utils/SerializeInterface; + sourceTree = ""; + }; + 4C8CE95715B0AC2700078175 /* Render */ = { + isa = PBXGroup; + children = ( + 4C902A3A15C56A4D00FBC901 /* Salmon Render */, + 4C8CE95315B0AC2100078175 /* RenderInterface.cpp */, + 4C8CE95415B0AC2100078175 /* RenderMisc.cpp */, + 4CC857CF1693867D00110F77 /* RenderParams.cpp */, + ); + name = Render; + sourceTree = ""; + }; + 4C8CE95815B0AC3500078175 /* Render */ = { + isa = PBXGroup; + children = ( + 4C902A3F15C56AC700FBC901 /* Salmon Render */, + 4C8CE95915B0AC4B00078175 /* RenderInterface.h */, + 4C8CE95A15B0AC4B00078175 /* RenderMisc.h */, + 4CC857D1169386A300110F77 /* RenderParams.h */, + ); + name = Render; + sourceTree = ""; + }; + 4C8CE96315B0B1A500078175 /* TextureManager */ = { + isa = PBXGroup; + children = ( + 4C8CE96415B0B1A600078175 /* SalmonTexture.h */, + ); + name = TextureManager; + path = ../../../include/TextureManager; + sourceTree = ""; + }; + 4C8CE96615B0B1B700078175 /* TextureManager */ = { + isa = PBXGroup; + children = ( + 4C8CE96715B0B1B700078175 /* SalmonTexture.cpp */, + ); + name = TextureManager; + path = ../../../src/TextureManager; + sourceTree = ""; + }; + 4C8CE97315B0BB9700078175 /* ShaderManager */ = { + isa = PBXGroup; + children = ( + 4C8CE97415B0BB9700078175 /* ShaderManager.h */, + ); + name = ShaderManager; + path = ../../../include/ShaderManager; + sourceTree = ""; + }; + 4C8CE97615B0BBA800078175 /* ShaderManager */ = { + isa = PBXGroup; + children = ( + 4C8CE97715B0BBA800078175 /* ShaderManager.cpp */, + ); + name = ShaderManager; + path = ../../../src/ShaderManager; + sourceTree = ""; + }; + 4C902A3A15C56A4D00FBC901 /* Salmon Render */ = { + isa = PBXGroup; + children = ( + 4CEE2DD415CDC57200C4D5F5 /* SalmonRenderGLES20.cpp */, + 4C902A3415C56A4800FBC901 /* BackgroundCubemap.cpp */, + 4C902A3515C56A4800FBC901 /* SalmonRenderInterface.cpp */, + 4C902A3615C56A4800FBC901 /* SalmonRenderIos.cpp */, + ); + name = "Salmon Render"; + sourceTree = ""; + }; + 4C902A3F15C56AC700FBC901 /* Salmon Render */ = { + isa = PBXGroup; + children = ( + 4CEE2DD115CDC55B00C4D5F5 /* SalmonRenderGLES20.h */, + 4C902A4015C56AEA00FBC901 /* BackgroundCubemap.h */, + 4C902A4115C56AEA00FBC901 /* SalmonRenderInterface.h */, + 4C902A4215C56AEA00FBC901 /* SalmonRenderIos.h */, + ); + name = "Salmon Render"; + sourceTree = ""; + }; + 4C902A4E15C56BEE00FBC901 /* Animation */ = { + isa = PBXGroup; + children = ( + 4C902A4F15C56BEE00FBC901 /* SalmonAnimation.cpp */, + ); + name = Animation; + path = ../../../src/Animation; + sourceTree = ""; + }; + 4C902A5015C56BEE00FBC901 /* LightManager */ = { + isa = PBXGroup; + children = ( + 4C902A5115C56BEE00FBC901 /* LightManager.cpp */, + ); + name = LightManager; + path = ../../../src/LightManager; + sourceTree = ""; + }; + 4C902A5215C56BEE00FBC901 /* ModelManager */ = { + isa = PBXGroup; + children = ( + 4CC857CC1693865C00110F77 /* NewModelManager.cpp */, + 4C902A5315C56BEE00FBC901 /* ModelManager.cpp */, + ); + name = ModelManager; + path = ../../../src/ModelManager; + sourceTree = ""; + }; + 4C902A5415C56BEE00FBC901 /* SimpleLand */ = { + isa = PBXGroup; + children = ( + 4C902A5515C56BEE00FBC901 /* SimpleLand.cpp */, + ); + name = SimpleLand; + path = ../../../src/SimpleLand; + sourceTree = ""; + }; + 4C902A5A15C56C0900FBC901 /* Animation */ = { + isa = PBXGroup; + children = ( + 4C902A5B15C56C0900FBC901 /* SalmonAnimation.h */, + ); + name = Animation; + path = ../../../include/Animation; + sourceTree = ""; + }; + 4C902A5C15C56C0900FBC901 /* LightManager */ = { + isa = PBXGroup; + children = ( + 4C902A5D15C56C0900FBC901 /* LightManager.h */, + ); + name = LightManager; + path = ../../../include/LightManager; + sourceTree = ""; + }; + 4C902A5E15C56C0900FBC901 /* ModelManager */ = { + isa = PBXGroup; + children = ( + 4CC857D3169386BD00110F77 /* NewModelManager.h */, + 4C902A5F15C56C0900FBC901 /* ModelManager.h */, + ); + name = ModelManager; + path = ../../../include/ModelManager; + sourceTree = ""; + }; + 4C902A6015C56C0900FBC901 /* SimpleLand */ = { + isa = PBXGroup; + children = ( + 4C902A6115C56C0900FBC901 /* SimpleLand.h */, + ); + name = SimpleLand; + path = ../../../include/SimpleLand; + sourceTree = ""; + }; + 4CC1FC3B15B20E440025C6F7 /* IosApi */ = { + isa = PBXGroup; + children = ( + 4CC1FC3C15B20E440025C6F7 /* IosApi.h */, + ); + name = IosApi; + path = ../../../include/Utils/IosApi; + sourceTree = ""; + }; + 4CC1FC3E15B20E5D0025C6F7 /* IosApi */ = { + isa = PBXGroup; + children = ( + 4CC1FC3F15B20E5D0025C6F7 /* IosApi.mm */, + ); + name = IosApi; + path = ../../../src/Utils/IosApi; + sourceTree = ""; + }; + 4CD18A1816727C3F00EDC335 /* SmartValueManager */ = { + isa = PBXGroup; + children = ( + 4CD18A1916727C3F00EDC335 /* SmartValueManager.cpp */, + ); + name = SmartValueManager; + path = ../../../src/SmartValueManager; + sourceTree = ""; + }; + 4CD18A1C16727C4E00EDC335 /* SmartValueManager */ = { + isa = PBXGroup; + children = ( + 4CD18A1D16727C4E00EDC335 /* SmartValueManager.h */, + ); + name = SmartValueManager; + path = ../../../include/SmartValueManager; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 4C8CE90015B0A0F400078175 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 4C8CE91715B0A11A00078175 /* DataTypes.h in Headers */, + 4C8CE91815B0A11A00078175 /* NewDataTypes.h in Headers */, + 4C8CE94615B0A57F00078175 /* console.h in Headers */, + 4C8CE94715B0A57F00078175 /* ErrorTypes.h in Headers */, + 4C8CE94815B0A57F00078175 /* FileUtils.h in Headers */, + 4C8CE94A15B0A9DA00078175 /* Engine.h in Headers */, + 4C8CE94C15B0AA8000078175 /* Utils.h in Headers */, + 4C8CE94F15B0AA9600078175 /* SerializeInterface.h in Headers */, + 4C8CE95B15B0AC4B00078175 /* RenderInterface.h in Headers */, + 4C8CE95C15B0AC4B00078175 /* RenderMisc.h in Headers */, + 4C8CE96515B0B1A600078175 /* SalmonTexture.h in Headers */, + 4C8CE96C15B0B31F00078175 /* PngHelper.h in Headers */, + 4C8CE97515B0BB9700078175 /* ShaderManager.h in Headers */, + 4C79A5A215B1896F003F59D1 /* ScriptManager.h in Headers */, + 4C79A5AF15B18A8B003F59D1 /* FrameManager.h in Headers */, + 4C79A5B515B18B0F003F59D1 /* FontManager.h in Headers */, + 4C7AD45B15B1E3E300A599F6 /* ApplicationInterface.h in Headers */, + 4C7AD45C15B1E3E300A599F6 /* GlobalConst.h in Headers */, + 4CC1FC3D15B20E440025C6F7 /* IosApi.h in Headers */, + 4C77831B15BABFA6003D5142 /* SoundManagerInterface.h in Headers */, + 4C77832415BAC070003D5142 /* SoundManagerIos.h in Headers */, + 4C902A2B15C565E900FBC901 /* Salmon Engine-Prefix.pch in Headers */, + 4C902A4315C56AEA00FBC901 /* BackgroundCubemap.h in Headers */, + 4C902A4415C56AEA00FBC901 /* SalmonRenderInterface.h in Headers */, + 4C902A4515C56AEA00FBC901 /* SalmonRenderIos.h in Headers */, + 4C902A4C15C56B3700FBC901 /* SalmonEngineInterface.h in Headers */, + 4C902A4D15C56B3700FBC901 /* SalmonEngineIos.h in Headers */, + 4C902A6215C56C0900FBC901 /* SalmonAnimation.h in Headers */, + 4C902A6315C56C0900FBC901 /* LightManager.h in Headers */, + 4C902A6415C56C0900FBC901 /* ModelManager.h in Headers */, + 4C902A6515C56C0900FBC901 /* SimpleLand.h in Headers */, + 4CEE2DD215CDC55B00C4D5F5 /* SalmonRenderGLES20.h in Headers */, + 4CD18A1E16727C4E00EDC335 /* SmartValueManager.h in Headers */, + 4CD18A2016727D4A00EDC335 /* BindableVar.h in Headers */, + 4CC857D2169386A300110F77 /* RenderParams.h in Headers */, + 4CC857D4169386BD00110F77 /* NewModelManager.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 4C8CE90115B0A0F400078175 /* Salmon Engine */ = { + isa = PBXNativeTarget; + buildConfigurationList = 4C8CE90F15B0A0F400078175 /* Build configuration list for PBXNativeTarget "Salmon Engine" */; + buildPhases = ( + 4C8CE8FE15B0A0F400078175 /* Sources */, + 4C8CE8FF15B0A0F400078175 /* Frameworks */, + 4C8CE90015B0A0F400078175 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Salmon Engine"; + productName = "Halibut Engine"; + productReference = 4C8CE90215B0A0F400078175 /* libSalmon Engine.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 4C8CE8F915B0A0F400078175 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0430; + }; + buildConfigurationList = 4C8CE8FC15B0A0F400078175 /* Build configuration list for PBXProject "Salmon Engine" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 4C8CE8F715B0A0F400078175; + productRefGroup = 4C8CE90315B0A0F400078175 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 4C8CE90115B0A0F400078175 /* Salmon Engine */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 4C8CE8FE15B0A0F400078175 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4C8CE93E15B0A56200078175 /* Console.cpp in Sources */, + 4C8CE93F15B0A56200078175 /* FileUtils.cpp in Sources */, + 4C8CE95215B0AAA900078175 /* SerializeInterface.cpp in Sources */, + 4C8CE95515B0AC2100078175 /* RenderInterface.cpp in Sources */, + 4C8CE95615B0AC2100078175 /* RenderMisc.cpp in Sources */, + 4C8CE96815B0B1B700078175 /* SalmonTexture.cpp in Sources */, + 4C8CE96A15B0B2FD00078175 /* PngHelper.cpp in Sources */, + 4C8CE97815B0BBA800078175 /* ShaderManager.cpp in Sources */, + 4C79A59F15B1895B003F59D1 /* ScriptManager.cpp in Sources */, + 4C79A5B215B18A97003F59D1 /* FrameManager.cpp in Sources */, + 4C79A5B815B18B1C003F59D1 /* FontManager.cpp in Sources */, + 4C7AD45615B1E3D000A599F6 /* ApplicationInterface.cpp in Sources */, + 4C7AD45715B1E3D000A599F6 /* GlobalConst.cpp in Sources */, + 4CC1FC4015B20E5D0025C6F7 /* IosApi.mm in Sources */, + 4C77832215BAC035003D5142 /* SoundManagerIos.mm in Sources */, + 4C902A2E15C5667800FBC901 /* DataTypes.cpp in Sources */, + 4C902A2F15C5667800FBC901 /* NewDataTypes.cpp in Sources */, + 4C902A3715C56A4800FBC901 /* BackgroundCubemap.cpp in Sources */, + 4C902A3815C56A4800FBC901 /* SalmonRenderInterface.cpp in Sources */, + 4C902A3915C56A4800FBC901 /* SalmonRenderIos.cpp in Sources */, + 4C902A3D15C56A7300FBC901 /* SalmonEngineInterface.cpp in Sources */, + 4C902A3E15C56A7300FBC901 /* SalmonEngineIos.cpp in Sources */, + 4C902A5615C56BEE00FBC901 /* SalmonAnimation.cpp in Sources */, + 4C902A5715C56BEE00FBC901 /* LightManager.cpp in Sources */, + 4C902A5815C56BEE00FBC901 /* ModelManager.cpp in Sources */, + 4C902A5915C56BEE00FBC901 /* SimpleLand.cpp in Sources */, + 4CEE2DD515CDC57200C4D5F5 /* SalmonRenderGLES20.cpp in Sources */, + 4CD18A1A16727C3F00EDC335 /* SmartValueManager.cpp in Sources */, + 4CC857CD1693865C00110F77 /* NewModelManager.cpp in Sources */, + 4CC857D01693867D00110F77 /* RenderParams.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 4C8CE90D15B0A0F400078175 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 4C8CE90E15B0A0F400078175 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; + COPY_PHASE_STRIP = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 4C8CE91015B0A0F400078175 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + DSTROOT = /tmp/Salmon_Engine.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Salmon Engine/Salmon Engine-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + TARGET_IOS, + TARGET_SALMON, + DEBUG, + BOOST_NO_CXX11_NUMERIC_LIMITS, + ); + HEADER_SEARCH_PATHS = ( + ../../, + "$(LibsPath)/boost_1_52_0", + "$(LibsPath)/lpng1510", + "$(LibsPath)/sqplus/sqplus", + "$(LibsPath)/sqplus/include", + "$(LibsPath)/vorbis-tremor-ios/vorbis", + ); + INSTALL_PATH = ./debug; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + REZ_SEARCH_PATHS = ""; + SKIP_INSTALL = NO; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 4C8CE91115B0A0F400078175 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + DSTROOT = /tmp/Salmon_Engine.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Salmon Engine/Salmon Engine-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + TARGET_IOS, + TARGET_SALMON, + BOOST_NO_CXX11_NUMERIC_LIMITS, + ); + HEADER_SEARCH_PATHS = ( + ../../, + "$(LibsPath)/boost_1_52_0", + "$(LibsPath)/lpng1510", + "$(LibsPath)/sqplus/sqplus", + "$(LibsPath)/sqplus/include", + "$(LibsPath)/vorbis-tremor-ios/vorbis", + ); + INSTALL_PATH = ./release; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + REZ_SEARCH_PATHS = ""; + SKIP_INSTALL = NO; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 4C8CE8FC15B0A0F400078175 /* Build configuration list for PBXProject "Salmon Engine" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4C8CE90D15B0A0F400078175 /* Debug */, + 4C8CE90E15B0A0F400078175 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 4C8CE90F15B0A0F400078175 /* Build configuration list for PBXNativeTarget "Salmon Engine" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4C8CE91015B0A0F400078175 /* Debug */, + 4C8CE91115B0A0F400078175 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 4C8CE8F915B0A0F400078175 /* Project object */; +} diff --git a/iOS/Salmon Engine/Salmon Engine/Salmon Engine-Prefix.pch b/iOS/Salmon Engine/Salmon Engine/Salmon Engine-Prefix.pch new file mode 100644 index 0000000..bb827b1 --- /dev/null +++ b/iOS/Salmon Engine/Salmon Engine/Salmon Engine-Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'Halibut Engine' target in the 'Halibut Engine' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/include/Animation/SalmonAnimation.h b/include/Animation/SalmonAnimation.h new file mode 100644 index 0000000..9765830 --- /dev/null +++ b/include/Animation/SalmonAnimation.h @@ -0,0 +1,178 @@ +#ifndef SALMON_ANIMATION_H_INCLUDED +#define SALMON_ANIMATION_H_INCLUDED +/* +This code contains Model Animation Manager and code to operate Animation +*/ + +#include "include/ModelManager/ModelManager.h" + +namespace SE +{ + +//We have to declare it in advance +class TAnimModel; + +//This struct contains bone information +struct TBoneStruct +{ + vec3 Pos; + vec4 Quat; + float Len; + int Ancient; +}; + +struct TBoneWeightStruct +{ + int BoneNum; + float BoneWeight; +}; + +//This struct contains additional info for every model vertex - weight of 3 bones per vertex +struct TVertexWeightStruct +{ + int WeightCount; + std::vector VertexBoneInfo; +}; + +//One animation sequence (i.e. one move for one model) +class TAnimSequence +{ +protected: + std::vector > BoneInfoMatrix; + int BoneCount; + int FrameCount; +public: + TAnimSequence() : BoneCount(0), FrameCount(0) { } + + //copy constructor + TAnimSequence(const TAnimSequence& animSeq); + + ~TAnimSequence(); + + TAnimSequence& operator=(const TAnimSequence& animSeq); + + bool LoadFromFileAn1(const std::string& fileName); //not safe + + void Clear(); + + + void ScaleAnimSequence(float s); + void MoveAnimSequence(const vec3& v); + void RotateAnimSequence(const mat3& m); + + friend class TAnimModel; +}; + +typedef std::vector TBoneList; +typedef std::vector TVertexWeightList; +typedef std::map > TAnimSequenceMap; + +/* Class for list of animations +List of animations contains bone system + vertex weight table + a list of avaiable animations +*/ +class TAnimList +{ +protected: + TBoneList BoneList; + TBoneList PrevBoneList; + TVertexWeightList VertexWeightList; + TAnimSequenceMap AnimSequenceMap; + + //Means bonelist and vertex weight list are loaded (AnimSequence may remain empty) + bool Ready; +public: + TAnimList() : Ready(false) { } + ~TAnimList() { Clear(); } + + //Load bone system + vertex weight from file + bool LoadBoneSystemFromFileBn1(const std::string& fileName); + bool LoadBoneSystemFromFileBn2(const std::string& fileName); + + //Add one more anim sequence to sequence map + bool LoadAnimSequenceFromFileAn1(const std::string& fileName); + + //Process animations. Must be processed after you process model + void ScaleAnimList(float s); + void MoveAnimList(const vec3& v); + void RotateAnimList(const mat3& m); + + void Clear(); + + void DrawBoneSystem(); + + //this method copies bone system to reserved memory + void SaveBoneSystemToBuf(); + + //this method reloads bone system form reserved memory + void LoadBoneSystemFromBuf(); + + friend class TAnimModel; +}; + +typedef std::map > TAnimListMap; + +//Class that contains list of animations for each model +class TModelAnimManager +{ +protected: + TAnimListMap AnimListMap; + +public: + TModelAnimManager() { }; + ~TModelAnimManager() { Clear(); }; + + TAnimList* operator [] (const std::string& s); + + //NOT SAFE!!! + bool AddAnimationToModel(const std::string& modelName, const std::string& boneListFileName); + + void Clear(); + +}; + + +class TAnimModel +{ +protected: + TLiteModel LiteModel; + + std::vector CopyVertexArr; + + TAnimList* AnimList; + + bool Ready; + + void RecalcVertexPos(); + + //This is used for animation only - to save original t=0 position + void SaveVertexInfoToBuf(); + void LoadVertexInfoFromBuf(); + +public: + TAnimModel() : Ready(false), AnimList(NULL) {} + + ~TAnimModel() { Clear(); } + + bool LoadModel(const std::string& modelName); + + void Clear(); + + void ScaleModel(float s); + void MoveModel(const vec3& v); + void RotateModel(const mat3& r); + + inline void SetShaderTranslateVector(const vec3& v) { LiteModel.SetShaderTranslateVector(v); } + inline void SetShaderRotateMatrix(const mat3& m) { LiteModel.SetShaderRotateMatrix(m); } + + void DrawImmediate(); + void DrawVBO() { LiteModel.DrawVBO(); } + void UpdateVBO() { LiteModel.UpdateVBO(); } + + //n must be in 0..99; ??? + void ApplySequence(const std::string& seq, int n); + +}; + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/ApplicationInterface.h b/include/ApplicationInterface.h new file mode 100644 index 0000000..1e8737d --- /dev/null +++ b/include/ApplicationInterface.h @@ -0,0 +1,43 @@ +#ifndef APPLICATION_INTERFACE_H_INCLUDED +#define APPLICATION_INTERFACE_H_INCLUDED + +#include "include/Utils/Utils.h" + +namespace SE +{ + +class TApplicationInterface +{ +protected: + bool IsConsoleOut; +public: + + + TApplicationInterface(); + + virtual ~TApplicationInterface() { } + + virtual void OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight); + + virtual void InnerInit() { } + //To do on init + + virtual void OuterDeinit(); + + virtual void InnerDeinit() { } + //To do on deinit + + virtual void OuterDraw() { } + + virtual void InnerDraw() { } + //What to draw + + virtual void OuterUpdate(cardinal timer) { } + + virtual void InnerUpdate(cardinal timer) { } +}; + +} //namespace SE + + +#endif \ No newline at end of file diff --git a/include/Engine.h b/include/Engine.h new file mode 100644 index 0000000..4a797fc --- /dev/null +++ b/include/Engine.h @@ -0,0 +1,57 @@ +#ifndef ENGINE_H_INCLUDED +#define ENGINE_H_INCLUDED + + + +#ifdef TARGET_HALIBUT + #ifdef TARGET_WIN32 + #define HALIBUT_WIN32 + #endif + + #ifdef TARGET_ANDROID + #define HALIBUT_ANDROID + #endif + #ifdef TARGET_IOS + #define HALIBUT_IOS + #endif +#endif + +#ifdef TARGET_SALMON + #ifdef TARGET_WIN32 + #define SALMON_WIN32 + #endif + + #ifdef TARGET_ANDROID + #define SALMON_ANDROID + #endif + #ifdef TARGET_IOS + #define SALMON_IOS + #endif +#endif + + +#ifdef SALMON_WIN32 +#include "SalmonEngineWindows.h" +#endif + +#ifdef HALIBUT_WIN32 +#include "HalibutEngineWindows.h" +#endif + + +#ifdef SALMON_ANDROID +#include "SalmonEngineAndroid.h" +#endif +#ifdef HALIBUT_ANDROID +#include "HalibutEngineAndroid.h" +#endif + + +#ifdef SALMON_IOS +#include "include/SalmonEngineIos.h" +#endif +#ifdef HALIBUT_IOS +#include "include/HalibutEngineIos.h" +#endif + +#endif //ENGINE_H_INCLUDED \ No newline at end of file diff --git a/include/FontManager/FontManager.h b/include/FontManager/FontManager.h new file mode 100644 index 0000000..a6986b6 --- /dev/null +++ b/include/FontManager/FontManager.h @@ -0,0 +1,186 @@ +#ifndef FONT_MANAGER_H_INCLUDED +#define FONT_MANAGER_H_INCLUDED + + +#include "include/Utils/Utils.h" + + +namespace SE +{ + +enum TTextHorizontalAlignment +{ + THA_LEFT, + THA_CENTER, + THA_RIGHT +}; + +enum TTextVerticalAlignment +{ + TVA_BOTTOM, + TVA_CENTER, + TVA_TOP +}; + +struct TTextBasicAreaParams : public TSerializeInterface +{ + int Height; + float HorizontalPadding; + float VerticalPadding; + TTextHorizontalAlignment TextHorizontalAlignment; + TTextVerticalAlignment TextVerticalAlignment; + + TTextBasicAreaParams(int height = 12, float horizontalPadding = 2, float verticalPadding = 2, TTextHorizontalAlignment textHorizontalAlignment = THA_LEFT, TTextVerticalAlignment textVerticalAlignment = TVA_BOTTOM) + : Height(height) + , HorizontalPadding(horizontalPadding) + , VerticalPadding(verticalPadding) + , TextHorizontalAlignment(textHorizontalAlignment) + , TextVerticalAlignment(textVerticalAlignment) + { + } + + virtual void Serialize(boost::property_tree::ptree& propertyTree) + { + Height = propertyTree.get(".height"); + HorizontalPadding = propertyTree.get(".horizontalPadding"); + VerticalPadding = propertyTree.get(".verticalPadding"); + + std::string textHorizontalAlignment = propertyTree.get(".textHorizontalAlignment"); + + if (textHorizontalAlignment == "THA_RIGHT") + { + TextHorizontalAlignment = THA_RIGHT; + } + else if (textHorizontalAlignment == "THA_CENTER") + { + TextHorizontalAlignment = THA_CENTER; + } + else + { + TextHorizontalAlignment = THA_LEFT; + } + + std::string textVerticalAlignment = propertyTree.get(".textVerticalAlignment"); + + + if (textVerticalAlignment == "TVA_TOP") + { + TextVerticalAlignment = TVA_TOP; + } + else if (textVerticalAlignment == "TVA_CENTER") + { + TextVerticalAlignment = TVA_CENTER; + } + else + { + TextVerticalAlignment = TVA_BOTTOM; + } + + + } +}; + + + +struct TFontParams +{ + float ShiftX; + float ShiftY; + float InternalShiftX; + float InternalShiftY; + float BitmapHeight; + float BitmapWidth; + float Advance; +}; + +struct TFont +{ + std::string TexName; + cardinal SheetWidth; + cardinal SheetHeight; + std::map CharMap; +}; + +class TTriangleList; //HalibutRender.h + +class TFontManager : public TSerializeInterface +{ +protected: + std::map FontMap; + + std::stack FontStack; + + float DrawChar(vec2 pos, cardinal character); + float DrawCharToVBO(vec2 pos, cardinal character, TTriangleList& triangleList); + + vec2 FitStringToBox(vec2 posFrom, vec2 posTo, TTextBasicAreaParams params, std::string& str); + vec2 FitStringToBoxWithWordWrap(vec2 posFrom, vec2 posTo, TTextBasicAreaParams params, std::string& str); +public: + TFontManager() { } + ~TFontManager(); + + virtual void Serialize(boost::property_tree::ptree& propertyTree); + + void AddFont(const std::string& fontName, const std::string& bitmapFile, const std::string& charmapFile); + + void PushFont(const std::string& fontName); + void PopFont(); + + void DrawString(vec2 pos, TTextBasicAreaParams params, const std::string& str); + + TTriangleList DrawStringToVBO(vec2 pos, TTextBasicAreaParams params, const std::string& str); + + void DrawTextInBox(vec2 posFrom, vec2 posTo, TTextBasicAreaParams params, std::string str, bool wordWrap = true); + + std::string GetCurrentFontName(); + std::string GetCurrentFontTextureName(); + + TTriangleList DrawTextInBoxToVBO(vec2 posFrom, vec2 posTo, TTextBasicAreaParams params, std::string str, bool wordWrap = true); + + + template +float GetCharAdvance(CHARTYPE character) +{ + std::string fontName = GetCurrentFontName(); + + if (FontMap.count(fontName) == 0) + { + throw ErrorToLog("Trying to use unknown font! " + fontName); + } + + TFont& currentFont = FontMap[fontName]; + + static_assert(sizeof(CHARTYPE) <= 4, "LOL, we have to implement more than 4-byte character!"); // LOL, we have to implement more than 4-byte character! + + TFontParams& fontParams = currentFont.CharMap[static_cast(character)]; + + + int scale_x = currentFont.SheetWidth; + + return fontParams.Advance*scale_x; + +} + +template +float GetTextAdvance(STRINGTYPE text) +{ + + boost::erase_all(text, "\n"); //that is easier + + float advance = 0; + + for (size_t i=0; i +#include +#endif +#ifdef TARGET_WIN32 +#include "include/OpenGlExt/OpenGlExt.h" +#endif + +#include "include/Utils/Utils.h" +#include "include/TextureManager/SalmonTexture.h" + +namespace SE +{ + +struct TFrame +{ + cardinal FrameBuffer; + cardinal DepthRenderBuffer; + cardinal TexID; + cardinal Width; + cardinal Height; + std::string TexName; +}; + +typedef std::map TFrameMap; + +class TRendererInterface; +class THalibutRendererInterface; +class THalibutRenderer; +class THalibutRendererAndroid; +class THalibutRendererIos; +class TSalmonRendererInterface; +class TSalmonRenderer; +class TSalmonRendererAndroid; +class TSalmonRendererIos; + +class TFrameManager +{ +protected: + TFrameMap FrameMap; +public: + TFrameManager() {} + + ~TFrameManager(); + + void FreeFrameManager(); + //Clean up frame map + + cardinal AddFrameRenderBuffer(const std::string& frameName, cardinal width, cardinal height); + //Add a new render buffer with name frameName. Width and height must be power of two (512, 1024 etc) + + void DeleteFrameRenderBuffer(const std::string& frameName); + //Delete render / depth buffer with name frameName + + cardinal AddDepthBuffer(const std::string& frameName, cardinal width, cardinal height); + //Add depth buffer with name frameName Width and height must be power of two (512, 1024 etc) + + cardinal AddCubemapBuffer(const std::string& frameName, cardinal width, cardinal height); + //Add cubemap render buffer with name frameName Width and height must be power of two (512, 1024 etc) + + cardinal GetFrameTexture(const std::string& frameName); + //Get texture ID from frame with name frameName + + ivec2 GetFrameWidthHeight(const std::string& frameName); + + TTextureData ReadFromBufferToTexData(const std::string& frameName); + + friend class TRendererInterface; + friend class THalibutRendererInterface; + friend class THalibutRenderer; + friend class THalibutRendererAndroid; + friend class THalibutRendererIos; + friend class TSalmonRendererInterface; + friend class TSalmonRenderer; + friend class TSalmonRendererAndroid; + friend class TSalmonRendererIos; + +}; + +} //namespace SE + +#endif diff --git a/include/GUIManager/ButtonWidget.h b/include/GUIManager/ButtonWidget.h new file mode 100644 index 0000000..75cceff --- /dev/null +++ b/include/GUIManager/ButtonWidget.h @@ -0,0 +1,344 @@ +#ifndef BUTTON_WIDGET_H_INCLUDED +#define BUTTON_WIDGET_H_INCLUDED + + +#include "include/Render/RenderMisc.h" +#include "include/Render/RenderParams.h" +#include "include/Utils/Utils.h" +#include "include/FontManager/FontManager.h" + +namespace SE +{ + +class TInstancingWidgetAncestor +{ +protected: + +public: + TRenderPairList TriangleListVector; + vec2 LeftBottomPos; + + virtual void Update(cardinal dt); + + virtual bool CheckClick(vec2 mousePos); + + virtual void OnTapDown(vec2 pos) { } + virtual void OnTapUp(vec2 pos) { } + virtual void OnMove(vec2 shift) { } + virtual void OnMoveOut() { } + virtual void OnKeyPress(int key) { } + + virtual bool IsTransparentForInput() { return false; } + + virtual ~TInstancingWidgetAncestor(); +}; + + +struct TTextParams : public TSerializeInterface +{ + std::string Text; + std::string FontName; + TTextBasicAreaParams BasicTextAreaParams; + TRenderParams RenderParams; + + TTextParams() + { + } + + TTextParams(const std::string& text) + : Text(text) + { + } + + TTextParams(const std::string& text, const std::string& fontName, int height, float horizontalPadding, float verticalPadding, TTextHorizontalAlignment textHorizontalAlignment, TTextVerticalAlignment textVerticalAlignment) + : Text(text) + , FontName(fontName) + , BasicTextAreaParams(height, horizontalPadding, verticalPadding, textHorizontalAlignment, textVerticalAlignment) + { + } + + virtual void Serialize(boost::property_tree::ptree& propertyTree) + { + Text = propertyTree.get("Text"); + + FontName = propertyTree.get("Font"); + + BasicTextAreaParams.Serialize(propertyTree.find("TextAreaParams")->second); + + if (propertyTree.count("RenderParams") != 0) + { + RenderParams.Serialize(propertyTree.find("RenderParams")->second); + } + } +}; + + +struct TSquareStatic : public TInstancingWidgetAncestor +{ + float Width; + + float Height; + + TSquareStatic() + : Width(0) + , Height(0) + { + } + + virtual bool CheckClick(vec2 mousePos); + + static TSquareStatic* CreateStatic(vec2 posFrom, vec2 posTo); + static TSquareStatic* CreateStaticWithFiller(vec2 posFrom, vec2 posTo, boost::function staticFillerFunc); + static TSquareStatic* CreateStaticWithFillers(vec2 posFrom, vec2 posTo, std::vector> staticFillerFuncArr); + + static void StaticTextureFiller(vec2 posFrom, vec2 posTo, const std::string& texName, TSquareStatic* staticToFill); + static void StaticTextFiller(vec2 posFrom, vec2 posTo, TTextParams buttonTextParams, TSquareStatic* staticToFill); + + static TSquareStatic* CreateStaticTexture(vec2 posFrom, vec2 posTo, const std::string& texName); + static TSquareStatic* CreateStaticText(vec2 posFrom, vec2 posTo, TTextParams buttonTextParams); + +}; + + + +struct TDynamicText : public TInstancingWidgetAncestor +{ +protected: + boost::signals::connection SmartValueConnection; + + TTextParams LastTextParams; + + TRenderPairList::iterator TextRenderPairItr; + +public: + float Width; + + float Height; + + TDynamicText(); + ~TDynamicText(); + + virtual bool CheckClick(vec2 mousePos); + + void UpdateText(std::string text); + + static TDynamicText* CreateDynamicText(vec2 posFrom, vec2 posTo); + static TDynamicText* CreateDynamicTextWithFiller(vec2 posFrom, vec2 posTo, boost::function dynamicTextFillerFunc); + static TDynamicText* CreateDynamicTextWithFillers(vec2 posFrom, vec2 posTo, std::vector> dynamicTextFillerFuncArr); + + static void TextParamsFiller(vec2 posFrom, vec2 posTo, TTextParams textParams, TDynamicText* dynamicTextToFill); + static void SmartValueTextFiller(const std::string& dictionaryName, const std::string& smartValueName, TDynamicText* dynamicTextToFill); + +}; + + +TTriangleList CreateTriangleListForText(vec2 posFrom, vec2 posTo, TTextParams buttonTextParams); + +class TUniversalButton : public TInstancingWidgetAncestor +{ +protected: + + enum + { + BS_NORMAL, + BS_GO_PRESSED, + BS_PRESSED, + BS_GO_NORMAL + } ButtonState; + + float ButtonStateTimer; + +public: + std::vector NormalTextureIteratorArr; + std::vector PressedTextureIteratorArr; + + float Width; + + float Height; + + TUniversalButton(); + + virtual void Update(cardinal dt); + + virtual bool CheckClick(vec2 mousePos); + + virtual void OnTapDown(vec2 pos); + virtual void OnTapUp(vec2 pos); + virtual void OnMoveOut(); + + static TUniversalButton* CreateButton(vec2 posFrom, vec2 posTo); + static TUniversalButton* CreateButtonWithFiller(vec2 posFrom, vec2 posTo, boost::function buttonFillerFunc); + static TUniversalButton* CreateButtonWithFillers(vec2 posFrom, vec2 posTo, std::vector > buttonFillerFuncArr); + + static void SquareButtonFiller(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNamePressed, TUniversalButton* buttonToFill); + static void TextButtonFiller(vec2 posFrom, vec2 posTo, TTextParams buttonTextParamsNormal, TTextParams buttonTextParamsPressed, TUniversalButton* buttonToFill); + + static TUniversalButton* CreateSquareButton(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNamePressed); + static TUniversalButton* CreateTextOnlyButton(vec2 posFrom, vec2 posTo, TTextParams buttonTextParamsNormal, TTextParams buttonTextParamsPressed); + static TUniversalButton* CreateSquareAndTextButton(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNamePressed, TTextParams buttonTextParamsNormal, TTextParams buttonTextParamsPressed); +}; + + +class TEdit : public TInstancingWidgetAncestor +{ +protected: + + float Width; + + float Height; + + TTextParams TextParams; + + void RefreshTextTriangleList(); + + boost::signals::connection InputConnection; + + boost::signals::connection SetTextSlotConnection; + +public: + ~TEdit(); + TRenderPairList::iterator TextIterator; + + + boost::signal OnTextChanged; + + virtual bool CheckClick(vec2 mousePos); + + virtual void OnKeyPress(int key); + virtual void OnTapDown(vec2 pos); + + void SetText(const std::string& newText); + + static TEdit* CreateEdit(vec2 posFrom, vec2 posTo); + static TEdit* CreateEditWithFiller(vec2 posFrom, vec2 posTo, boost::function fillerFunc); + static TEdit* CreateEditWithFillers(vec2 posFrom, vec2 posTo, std::vector > fillerFuncArr); + + static void EditFiller(vec2 posFrom, vec2 posTo, const std::string& texName, TTextParams textParams, TEdit* edit); + static void SmartValueTextFiller(const std::string& dictionaryName, const std::string& smartValueName, TEdit* edit); + + //static TEdit* CreateEdit(vec2 posFrom, vec2 posTo, const std::string& texName, TTextParams textParams); +}; + + +class TCheckBox : public TInstancingWidgetAncestor +{ +protected: + bool IsChecked; //To be set immediately on tap up + + boost::signals::connection SetCheckedSlotConnection; + void RefreshVisibility(); +public: + std::vector StaticTextureIteratorArr; + std::vector CheckedTextureIteratorArr; + + float Width; + + float Height; + + TCheckBox(); + ~TCheckBox(); + + virtual bool CheckClick(vec2 mousePos); + virtual void Update(cardinal dt); + + virtual void OnTapDown(vec2 pos); + virtual void OnTapUp(vec2 pos); + virtual void OnMoveOut(); + + //Logic: + void SetChecked(bool isChecked); + boost::signal OnSetChecked; + + static TCheckBox* CreateCheckBox(vec2 posFrom, vec2 posTo); + static TCheckBox* CreateCheckBoxWithFiller(vec2 posFrom, vec2 posTo, boost::function checkBoxFillerFunc); + static TCheckBox* CreateCheckBoxWithFillers(vec2 posFrom, vec2 posTo, std::vector > checkBoxFillerFuncArr); + + static void TextureFiller(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNameChecked, TCheckBox* checkBoxToFill); + static void TextFiller(vec2 posFrom, vec2 posTo, TTextParams textParams, TCheckBox* checkBoxToFill); + static void CheckedFiller(bool isChecked, TCheckBox* checkBoxToFill); + static void SmartValueFiller(const std::string& dictionaryName, const std::string& smartValueName, TCheckBox* checkBoxToFill); + + static TCheckBox* CreateSimpleCheckBox(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNameChecked); + static TCheckBox* CreateCheckBoxWithText(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNameChecked, vec2 textPosFrom, vec2 textPosTo, TTextParams textParams); +}; + + + +class TRadioButton : public TInstancingWidgetAncestor +{ +protected: + bool IsChecked; //To be set immediately on tap up + + boost::signals::connection SetCheckedSlotConnection; + void RefreshVisibility(); +public: + std::vector StaticTextureIteratorArr; + std::vector CheckedTextureIteratorArr; + + float Width; + + float Height; + + TRadioButton(); + ~TRadioButton(); + + virtual bool CheckClick(vec2 mousePos); + virtual void Update(cardinal dt); + + virtual void OnTapDown(vec2 pos); + virtual void OnTapUp(vec2 pos); + virtual void OnMoveOut(); + + //Logic: + void SetChecked(bool isChecked); + boost::signal OnSetChecked; + + static TRadioButton* CreateRadioButton(vec2 posFrom, vec2 posTo); + static TRadioButton* CreateRadioButtonWithFiller(vec2 posFrom, vec2 posTo, boost::function radioButtonFillerFunc); + static TRadioButton* CreateRadioButtonWithFillers(vec2 posFrom, vec2 posTo, std::vector > radioButtonFillerFuncArr); + + static void TextureFiller(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNameChecked, TRadioButton* radioButtonToFill); + static void TextFiller(vec2 posFrom, vec2 posTo, TTextParams textParams, TRadioButton* radioButtonToFill); + static void CheckedFiller(bool isChecked, TRadioButton* radioButtonToFill); + + template + static void SmartValueFiller(const std::string& dictionaryName, const std::string& smartValueName, TYPENAME value, TRadioButton* radioButtonToFill); + + static TRadioButton* CreateSimpleRadioButton(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNameChecked); + static TRadioButton* CreateRadioButtonWithText(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNameChecked, vec2 textPosFrom, vec2 textPosTo, TTextParams textParams); +}; + + +class TMover : public TInstancingWidgetAncestor +{ +protected: + + float PosCursor; +public: + float Width; + float Height; + float MaxHeight; + + std::string GroupName; + std::string SelfName; //For exclusion + + TMover(); + ~TMover(); + + virtual void Update(cardinal dt); + + virtual bool CheckClick(vec2 mousePos); + + virtual void OnTapDown(vec2 pos); + virtual void OnTapUp(vec2 pos); + virtual void OnMove(vec2 shift); + virtual void OnMoveOut(); + + virtual bool IsTransparentForInput() { return true; } + + static TMover* CreateMover(vec2 posFrom, vec2 posTo, std::string groupName, std::string selfName, float maxHeight); +}; + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/GUIManager/GUIManager.h b/include/GUIManager/GUIManager.h new file mode 100644 index 0000000..48dcddb --- /dev/null +++ b/include/GUIManager/GUIManager.h @@ -0,0 +1,184 @@ +#ifndef GUIMANAGER_H_INCLUDED +#define GUIMANAGER_H_INCLUDED + +#include "include/Render/RenderMisc.h" +#include "include/GUIManager/ButtonWidget.h" +#include "include/GUIManager/WidgetXmlParsers.h" +#include "include/Utils/Utils.h" +#include "include/ScriptManager/ScriptManager.h" + +#include "boost/variant.hpp" +#include "boost/thread.hpp" + +namespace SE +{ + +extern const std::string CONST_HOLD_SIGNAL_NAME; +extern const std::string CONST_CLICK_SIGNAL_NAME; +extern const std::string CONST_DRAG_SIGNAL_NAME; + + +typedef boost::variant TSignalParam; + +struct TWidgetStruct +{ + std::string Name; + std::string GroupName; + int Order; + + bool IsMouseDown; + + std::shared_ptr Widget; + + std::map>> SignalMap; + + TWidgetStruct(const std::string& name, const std::string& groupName, std::shared_ptr widget, int order = 0) + : Name(name) + , GroupName(groupName) + , Order(order) + , IsMouseDown(false) + , Widget(widget) + { + SignalMap[CONST_HOLD_SIGNAL_NAME] = std::shared_ptr>(new boost::signal()); + SignalMap[CONST_CLICK_SIGNAL_NAME] = std::shared_ptr>(new boost::signal()); + SignalMap[CONST_DRAG_SIGNAL_NAME] = std::shared_ptr>(new boost::signal()); + } + + TWidgetStruct(const TWidgetStruct& widgetStruct) + { + Name = widgetStruct.Name; + Widget = widgetStruct.Widget; + GroupName = widgetStruct.GroupName; + IsMouseDown = widgetStruct.IsMouseDown; + Order = widgetStruct.Order; + SignalMap = widgetStruct.SignalMap; + + } + + TWidgetStruct& operator=(const TWidgetStruct& widgetStruct) + { + //Self-assignment is ok + Name = widgetStruct.Name; + Widget = widgetStruct.Widget; + GroupName = widgetStruct.GroupName; + IsMouseDown = widgetStruct.IsMouseDown; + Order = widgetStruct.Order; + SignalMap = widgetStruct.SignalMap; + + return *this; + } + + ~TWidgetStruct() + { + } + + //For sorting + bool operator>(const TWidgetStruct& widget) const + { + return Order > widget.Order; + } + + bool operator<(const TWidgetStruct& widget) const + { + return Order < widget.Order; + } + + bool operator==(const TWidgetStruct& widget) const + { + return Order == widget.Order; + } + + +}; + + +struct TWidgetTransformTask +{ + std::string GroupName; + vec2 PosTo; + int CurrentTime; + int TotalTime; + + enum TMoveStyle + { + MS_LINEAR, + MS_SQR, + MS_SQRT + } MoveStyle; + + TWidgetTransformTask(const std::string& groupName, vec2 posTo, int totalTime, int currentTime, TMoveStyle moveStyle) + : GroupName(groupName) + , PosTo(posTo) + , TotalTime(totalTime) + , CurrentTime(currentTime) + , MoveStyle(moveStyle) + { + } +}; + +typedef std::list TWidgetTrasfromTaskList; + +typedef std::vector TWidgetArr; + +class TGUIManager : public TFunctionBinderInterface +{ +protected: + + TWidgetArr WidgetArr; + + TWidgetTrasfromTaskList WidgetTrasfromTaskList; + + void MoveWidgetByIterator(TWidgetArr::iterator widget, vec2 shift); + + TWidgetArr::iterator FindWidgetInArr(const std::string& widgetName); + + vec2 LastTapPos; + vec2 TotalShift; + + boost::mutex WidgetListMutex; + +public: + + boost::signal KeyPressedSignal; + boost::signal PostUpdateSignal; + + ~TGUIManager(); + + void AddWidget(std::shared_ptr widgetAncestor, const std::string& name, const std::string& groupName, int order = 0); + + void DeleteWidget(std::string name); + void DeleteWidgetGroup(std::string groupName); + + void DeleteWidgetOnUpdate(const std::string& name); + void DeleteWidgetGroupOnUpdate(const std::string& groupName); + + void Update(cardinal dt); + void Draw(); + + void MoveWidget(const std::string& widgetName, vec2 shift); + void MoveWidgetGroup(const std::string& widgetGroupName, const std::string& exceptWidget, vec2 shift); + + void AddWidgetTransformTask(TWidgetTransformTask widgetTransformTask); + + void OnMouseDown(vec2 pos); + + void OnMouseUp(vec2 pos); + + void OnMove(vec2 shift); + + void PrintWidgetList(); + + std::shared_ptr> GetOnClickSignal(const std::string& widgetName); + std::shared_ptr> GetOnHoldSignal(const std::string& widgetName); + std::shared_ptr> GetSignal(const std::string& signalName, const std::string& widgetName); + + //TFunctionBinderInterface implementation: + void SQ_MoveWidget(const SQChar *widgetName, float x, float y); + virtual void BindFunctions(); + +}; + +} //namespace SE + + +#endif \ No newline at end of file diff --git a/include/GUIManager/WidgetTemplatesImpl.h b/include/GUIManager/WidgetTemplatesImpl.h new file mode 100644 index 0000000..65ad389 --- /dev/null +++ b/include/GUIManager/WidgetTemplatesImpl.h @@ -0,0 +1,36 @@ + +// This file contains templates for widgets +// This file must be included somewhere in HalibutEngine.h just after ResourceManager is declared + +namespace SE +{ + +template +void TRadioButton::SmartValueFiller(const std::string& dictionaryName, const std::string& smartValueName, TYPENAME value, TRadioButton* radioButtonToFill) +{ + + radioButtonToFill->SetChecked(ResourceManager->SmartValueManager.GetImmediateValue(dictionaryName, smartValueName) == value); + radioButtonToFill->OnSetChecked.connect + ( + [dictionaryName, smartValueName, value](bool checked) + { + if (checked) + { + if (ResourceManager->SmartValueManager.GetImmediateValue(dictionaryName, smartValueName) != value) + { + ResourceManager->SmartValueManager.SetImmediateValue(dictionaryName, smartValueName, value); + } + } + } + ); + + radioButtonToFill->SetCheckedSlotConnection = ResourceManager->SmartValueManager.GetSignal(dictionaryName, smartValueName).connect + ( + [radioButtonToFill, value](const TYPENAME& newValue) + { + radioButtonToFill->SetChecked(value == newValue); + } + ); +} + +} //namespace SE diff --git a/include/GUIManager/WidgetXmlParsers.h b/include/GUIManager/WidgetXmlParsers.h new file mode 100644 index 0000000..32914de --- /dev/null +++ b/include/GUIManager/WidgetXmlParsers.h @@ -0,0 +1,55 @@ +#ifndef WIDGET_XML_PARSERS_H_INCLUDED +#define WIDGET_XML_PARSERS_H_INCLUDED + +#include "ButtonWidget.h" + +namespace SE +{ + +struct TStaticWidgetParser : public TSerializeInterface +{ + virtual void Serialize(boost::property_tree::ptree& propertyTree); +}; + +struct TDynamicTextWidgetParser : public TSerializeInterface +{ + virtual void Serialize(boost::property_tree::ptree& propertyTree); +}; + + +struct TButtonWidgetParser : public TSerializeInterface +{ + virtual void Serialize(boost::property_tree::ptree& propertyTree); +}; + + +struct TEditWidgetParser : public TSerializeInterface +{ + virtual void Serialize(boost::property_tree::ptree& propertyTree); +}; + +struct TCheckBoxWidgetParser : public TSerializeInterface +{ + virtual void Serialize(boost::property_tree::ptree& propertyTree); +}; + +struct TRadioButtonWidgetParser : public TSerializeInterface +{ + virtual void Serialize(boost::property_tree::ptree& propertyTree); +}; + + +struct TWidgetParser : public TSerializeInterface +{ + virtual void Serialize(boost::property_tree::ptree& propertyTree); +}; + + +struct TWidgetListParser : public TSerializeInterface +{ + virtual void Serialize(boost::property_tree::ptree& propertyTree); +}; + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/GlobalConst.h b/include/GlobalConst.h new file mode 100644 index 0000000..85ceec9 --- /dev/null +++ b/include/GlobalConst.h @@ -0,0 +1,46 @@ +#ifndef GLOBAL_CONST_H_INCLUDED +#define GLOBAL_CONST_H_INCLUDED + +#include "include/Utils/DataTypes/DataTypes.h" + +namespace SE +{ + +/* +This code contains global constant values for engine +*/ + +const float CONST_MAX_CAM_DIST = 20.0f; +//How far camera could be from game field + +//const float CONST_MIN_CAM_DIST = 4.0f; +const float CONST_MIN_CAM_DIST = 0.0f; +//How near camera could be from game field + +const float CONST_MIN_CAM_PHI = pi/48; + +const float CONST_MAX_CAM_PHI = pi/2; + +const int CONST_MAX_SHADER_LIGHTS = 8; +//Max light sources count (for shader) + +//const cardinal CONST_TIMER_INTERVAL = 5; +//Time interval to call Application::Update() + +const float CONST_DEFAULT_FOG_BEGIN_DISTANCE = 14.0f; + +const float CONST_DEFAULT_FOG_END_DISTANCE = 19.0f; + +const vec4 CONST_DEFAULT_FOG_COLOR(0.2f, 0.5f, 1.0f, 1.0f); + +const float CONST_DEFAULT_GLOBAL_SHADOW_AREA_HALFSIZE = 20.0f; + +const int CONST_MAX_STACK_SIZE = 100; + +const float CONST_CAMERA_VERTICAL_SHIFT = 1.5f; + +const float CONST_CAMERA_PHI_ELEVATION_STEP = pi/48; + +} //namespace SE + +#endif diff --git a/include/HalibutAnimation/HalibutAnimation.h b/include/HalibutAnimation/HalibutAnimation.h new file mode 100644 index 0000000..0bd27a4 --- /dev/null +++ b/include/HalibutAnimation/HalibutAnimation.h @@ -0,0 +1,171 @@ +#ifndef HALIBUT_ANIMATION_H_INCLUDED +#define HALIBUT_ANIMATION_H_INCLUDED + +#include "include/Render/RenderMisc.h" +#include "include/Render/RenderParams.h" +#include "include/ScriptManager/ScriptManager.h" +#include +#include + +namespace SE +{ + +struct TAnimShot +{ + vec2 TexCoordFrom; + vec2 TexCoordTo; + cardinal TimePassedFromStart; + TAnimShot(vec2 texCoordFrom, vec2 texCoordTo, cardinal timePassedFromStart) + : TexCoordFrom(texCoordFrom) + , TexCoordTo(texCoordTo) + , TimePassedFromStart(timePassedFromStart) + { + } +}; + + +class THalibutAnimObject : public TSerializeInterface +{ +protected: + std::string TexName; + std::vector AnimShotArr; + + cardinal CurrentAnimTime; + cardinal TotalAnimTime; + + cardinal CurrentAnimFrame; + + void RefreshTriangleListVector(); + +public: + + TRenderPairList TriangleListVector; + + vec2 LeftBottomPos; + + THalibutAnimObject(const std::string& texName, vec2 posFrom, vec2 posTo); + + void AddAnimShot(vec2 texCoordFrom, vec2 texCoordTo, cardinal timePassedFromStart); + + void CalcTotalAnimTime(); + + void Update(cardinal dt); + + void Reset(); + + void Clear(); + + virtual void Serialize(boost::property_tree::ptree& propertyTree); + + +}; + + +class THalibutExternalAnimObject : public TSerializeInterface +{ +protected: + + cardinal CurrentAnimTime; + cardinal TotalAnimTime; + + cardinal CurrentAnimFrame; + + std::vector AnimShotArr; + + TRenderPairList::iterator RenderPairIter; + + cardinal RectCount; + cardinal RectFrom; + + void RefreshTriangleListVector(); + +public: + + THalibutExternalAnimObject() + : RectCount(1) + { + } + + THalibutExternalAnimObject(TRenderPairList::iterator renderPairIter, cardinal rectFrom, cardinal rectCount); + + THalibutExternalAnimObject(const THalibutExternalAnimObject& copyFrom); + + THalibutExternalAnimObject& operator=(const THalibutExternalAnimObject& copyFrom); + + ~THalibutExternalAnimObject(); + + void ReplaceAnimObject(TRenderPairList::iterator renderPairIter, cardinal rectFrom); + + void AddAnimShot(vec2 texCoordFrom, vec2 texCoordTo, cardinal timePassedFromStart); + + void CalcTotalAnimTime(); + + void Update(cardinal dt); + + void Reset(); + + void Clear(); + + virtual void Serialize(boost::property_tree::ptree& propertyTree); +}; + + + +struct THalibutAnimObjectRecord +{ + std::string Name; + + THalibutExternalAnimObject HalibutAnimObject; + + enum TAnimState + { + AS_PLAY, + AS_STOP + } AnimState; + + bool Visible; + + THalibutAnimObjectRecord(const std::string& name, THalibutExternalAnimObject halibutAnimObject, TAnimState animState) + : Name(name) + , HalibutAnimObject(halibutAnimObject) + , AnimState(animState) + , Visible(true) + { + } + +}; + + + +class THalibutAnimationManager : public TFunctionBinderInterface +{ +protected: + std::vector HalibutAnimObjectArr; + std::vector::iterator FindAnimObjectByName(const std::string& name); + +public: + + ~THalibutAnimationManager(); + + void AddAnimationObject(const std::string& animName, THalibutExternalAnimObject halibutExternalAnimObject); + void DeleteAnimationObject(const std::string& animName); + + bool AnimationExists(const std::string& animName); + void ReplaceAnimationObject(const std::string& animName, TRenderPairList::iterator renderPairIter, cardinal rectFrom); + + void Update(cardinal dt); + + void StartAnimation(const std::string& animName); + void StopAnimation(const std::string& animName); + void PauseAnimation(const std::string& animName); + //void HideAnimation(const std::string& animName); + //void ShowAnimation(const std::string& animName); + + void PrintAnimationList(); + virtual void BindFunctions(); + +}; + +} //namespace SE + +#endif diff --git a/include/HalibutEngineAndroid.h b/include/HalibutEngineAndroid.h new file mode 100644 index 0000000..ed48713 --- /dev/null +++ b/include/HalibutEngineAndroid.h @@ -0,0 +1,48 @@ +#ifndef HALIBUT_ENGINE_ANDROID_H_INCLUDED +#define HALIBUT_ENGINE_ANDROID_H_INCLUDED + + +#include "include/Utils/Utils.h" +#include "include/Utils/Console/console.h" + +#include "include/Render/HalibutRender/HalibutRenderAndroid.h" + +#include "include/HalibutEngineInterface.h" +//Android code only + + +namespace SE +{ + +extern TJavaConsole* Console; + +extern THalibutResourceManager* ResourceManager; + +extern THalibutRendererAndroid* Renderer; + +class TApplication : public TApplicationAncestor +{ +protected: +public: + TApplication(); + + virtual ~TApplication(); + + virtual void OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight); + + virtual void OuterDeinit(); + + virtual void OnKeyPress(cardinal key); + +}; + + +} //namespace SE + +//This file includes templates that call any of three singletones: Console, ResourceManager or Renderer + +#include "include/GUIManager/WidgetTemplatesImpl.h" + + + +#endif diff --git a/include/HalibutEngineInterface.h b/include/HalibutEngineInterface.h new file mode 100644 index 0000000..dd0142e --- /dev/null +++ b/include/HalibutEngineInterface.h @@ -0,0 +1,104 @@ +#ifndef HALIBUT_ENGINE_INTERFACE_H_INCLUDED +#define HALIBUT_ENGINE_INTERFACE_H_INCLUDED + +#include "include/ApplicationInterface.h" + +#include "include/TextureManager/SalmonTexture.h" +#include "include/ShaderManager/ShaderManager.h" +#include "include/ScriptManager/ScriptManager.h" +#include "include/GUIManager/GUIManager.h" +#include "include/FrameManager/FrameManager.h" +#include "include/FontManager/FontManager.h" +#include "include/HalibutAnimation/HalibutAnimation.h" +#include "include/SmartValueManager/SmartValueManager.h" + + + +#ifdef TARGET_WIN32 +#include "include/SoundManager/SoundManagerWindows.h" +#endif +#ifdef TARGET_ANDROID +#include "include/SoundManager/SoundManagerAndroid.h" +#endif +#ifdef TARGET_IOS +#include "include/SoundManager/SoundManagerIos.h" +#endif + +namespace SE +{ + +//Windows only +struct TMouseState +{ + int X; + int Y; + bool LeftButtonPressed; + bool MiddleButtonPressed; + bool RightButtonPressed; +}; + + + + +class THalibutResourceManager +{ +public: + std::string PathToResources; + + TTextureListClass TexList; + TShaderManager ShaderManager; + TScriptManager ScriptManager; + TGUIManager GUIManager; + TFrameManager FrameManager; + TFontManager FontManager; + THalibutAnimationManager HalibutAnimationManager; + TSmartValueManager SmartValueManager; + + #ifdef TARGET_WIN32 + TSoundManagerWindows SoundManager; + #endif + #ifdef TARGET_ANDROID + TSoundManagerAndroid SoundManager; + #endif + #ifdef TARGET_IOS + TSoundManagerIos SoundManager; + #endif +}; + + +class TApplicationAncestor : public TApplicationInterface +{ +protected: + +public: + + TApplicationAncestor(); + + //If you override them, call ancestor: + virtual void OuterDraw(); + virtual void OuterUpdate(cardinal dt); + + + virtual void OuterOnTapDown(vec2 p); + virtual void OuterOnTapUp(vec2 p); + virtual void OuterOnMove(vec2 shift); + + virtual void InnerOnTapDown(vec2 p) { } + + virtual void InnerOnTapUp(vec2 p) { } + + virtual void InnerOnMove(vec2 shift) { } + + virtual void OnFling(vec2 v) { } //Android only + + virtual void OnMouseMove(TMouseState& mouseState) { } //Windows only + + virtual void OnMouseWheel(short int delta) { } //Windows only + + virtual void OnKeyPress(cardinal key) { } //Try not to override this. But if you need to override, call ancestor! + +}; + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/HalibutEngineIos.h b/include/HalibutEngineIos.h new file mode 100644 index 0000000..032270a --- /dev/null +++ b/include/HalibutEngineIos.h @@ -0,0 +1,52 @@ +// +// HalibutEngineIos.h +// Halibut Engine +// +// Created by vvv ооо on 13.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#ifndef HALIBUT_ENGINE_IOS_H_INCLUDED +#define HALIBUT_ENGINE_IOS_H_INCLUDED + +#include "include/HalibutEngineInterface.h" + +#include "include/Render/HalibutRender/HalibutRenderIos.h" + +#include "include/Utils/Utils.h" + +namespace SE +{ + +extern TIosConsole* Console; + +extern THalibutResourceManager* ResourceManager; + +extern THalibutRenderIos* Renderer; + +class TApplication : public TApplicationAncestor +{ +public: + TApplication(); + + virtual ~TApplication(); + + virtual void OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight); + + virtual void OuterDeinit(); + + virtual void OnKeyPress(cardinal key); +}; + + + +} //namespace SE + + +//This file includes templates that call any of three singletones: Console, ResourceManager or Renderer + +#include "include/GUIManager/WidgetTemplatesImpl.h" + + + +#endif diff --git a/include/HalibutEngineWindows.h b/include/HalibutEngineWindows.h new file mode 100644 index 0000000..9728bee --- /dev/null +++ b/include/HalibutEngineWindows.h @@ -0,0 +1,63 @@ +#pragma once //Windows ok + + +#include "include/Render/HalibutRender/HalibutRenderWindows.h" + +#include "include/HalibutEngineInterface.h" + +namespace SE +{ + +//============================================================== +//========= GLOBAL VARIABLES - REMEMBER THIS LIST!!! =========== +//============================================================== + +extern HGLRC hRC; //Render context +extern HWND Hwnd; //Main window handle +extern HDC hDC; //Device context + +extern TFileConsole* Console; +//Console and log for output + +extern THalibutRenderer* Renderer; +//OpenGL renderer + +extern THalibutResourceManager* ResourceManager; +//Resource Manager + + + +class TApplication : public TApplicationAncestor +{ +protected: + std::string LogFilename; //Log file name + unsigned char KeyboardBuffer[256]; +public: + int X, Y, Width, Height; //Window position and size + float MatrixWidth, MatrixHeight; + + std::string WindowName; //Window name + + TApplication(); + virtual ~TApplication(); + + const std::string& GetLogFilename(); + + char GetKeyState(cardinal keyNum); + + void SetKeyboardBuffer(const unsigned char* source); + + virtual void OnKeyPress(cardinal key); // If you override this, call ancestor! + + +}; + + +int MainLoop(TApplication& application); + +} //namespace SE + +//This file includes templates that call any of three singletones: Console, ResourceManager or Renderer + +#include "include/GUIManager/WidgetTemplatesImpl.h" + diff --git a/include/LightManager/LightManager.h b/include/LightManager/LightManager.h new file mode 100644 index 0000000..fd1e315 --- /dev/null +++ b/include/LightManager/LightManager.h @@ -0,0 +1,46 @@ +#ifndef LIGHT_MANAGER_H_INCLUDED +#define LIGHT_MANAGER_H_INCLUDED + + +/* +This code contains manager to operate OpenGL lighting + +Use global variable ResourceManager to get access to light manager + +*/ + + +#include "include/Utils/Utils.h" + + +namespace SE +{ + +class TLightManager +{ +protected: + bool LightingEnabled; + + vec3 LightPos; + vec3 LightDirection; + + vec4 LightColor; + +public: + TLightManager(); + + void SetLightPos(vec3 pos); + void SetLightDirection(vec3 dir); + void SetLightColor(vec4 color); + + void SetLightOn(); + void SetLightOff(); + + //To be called from SetUniforms + void SetLightUniforms(); +}; + + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/ModelManager/ModelManager.h b/include/ModelManager/ModelManager.h new file mode 100644 index 0000000..c6ed24f --- /dev/null +++ b/include/ModelManager/ModelManager.h @@ -0,0 +1,130 @@ +#ifndef MODEL_MANAGER_H_INCLUDED +#define MODEL_MANAGER_H_INCLUDED + +/* +This code contains manager to operate static Lite Models + +Use global variable ResourceManager to get access to model manager +*/ + + +#include "include/Utils/Utils.h" + +namespace SE +{ + +class TLiteModel; + +class TAnimModel; + +/* Class to work with Lite Model Resource from model file. +Lite Model Resource can be applied to a number of in-game Lite Models */ +class TLiteModelResource +{ +protected: + + std::vector VertexArr; + std::vector NormalArr; + std::vector TangentArr; + std::vector BinormalArr; + std::vector TexCoordArr; + + int TriangleCount; + std::string Texname; + std::string Normtexname; + std::string PathToResource; +public: + TLiteModelResource() : TriangleCount(0), PathToResource("") { } + ~TLiteModelResource(); + + bool LoadModel(boost::shared_array filePointer, cardinal fileSize); + + void FreeModel(); + + void SetPathToResource(const std::string& pathToResource); + + friend class TLiteModel; +}; + +typedef std::map TLiteModelResourceMap; + +/* Class to work with Lite Model in game. +Lite Model could be translated/scaled/rotated, also Lite Model have its own model matrix */ +class TLiteModel +{ +protected: + std::string Modelname; + + cardinal TriangleCount; + cardinal TexID; + cardinal NormTexID; + + TTriangleList TriangleList; + + mat3 ShaderRotateMatrix; + vec3 ShaderTranslateVector; + bool Loaded; + +public: + TLiteModel() : Modelname(""), TriangleCount(0), TexID(0), NormTexID(0), + Loaded(false), ShaderRotateMatrix(IdentityMatrix), ShaderTranslateVector(ZeroVec3) {} + + ~TLiteModel(); + + bool LoadModel(const std::string& s); + //Load model from Resource Manager with name s + //Model must already be loaded as a Lite Model Resource + + void FreeModel(); + //Clear all data from model + + //Long-term model processing methods + //To rotate/translate model quickly use SetShaderRotateMatrix/SetShaderTranslateVector + //If you use VBO to draw model, you must call UpdateVBO() after you finished model translation/rotation/scaling + void MoveModel(const vec3& v); + void RotateModel(const mat3& r); + void ScaleModel(float s); + void ScaleModel(const vec3& s); + + //Sets translate vector to do fast model translation. No need to call UpdateVBO after + void SetShaderTranslateVector(const vec3& v); + + //Sets rotate matrix to do fast model rotation. No need to call UpdateVBO after + void SetShaderRotateMatrix(const mat3& m); + + //Method to update VBO after translation / rotation / scaling + void UpdateVBO(); + + //Method to draw model in immediate mode. Slow method + void DrawImmediate(); + + //Method to draw model using VBO. Faster than previous but must be called between SalmonRender->BeginDrawVBO() and SalmonRender->EndDrawVBO() + void DrawVBO(); + + friend class TAnimModel; //For animation; +}; + +class TModelManager +{ +protected: + TLiteModelResourceMap LiteModelMap; +public: + TModelManager() {} + ~TModelManager(); + + //Clean up + void Clear(); + + //Get access to Lite Model resource + TLiteModelResource& operator[](const std::string& s); + + //Add lite model resource from file + bool AddLiteModel(const std::string& filename, const std::string& pathToResources = ""); + + //Delete lite model resource + void DeleteLiteModel(const std::string& modelname); +}; + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/ModelManager/NewModelManager.h b/include/ModelManager/NewModelManager.h new file mode 100644 index 0000000..16986aa --- /dev/null +++ b/include/ModelManager/NewModelManager.h @@ -0,0 +1,78 @@ +#ifndef NEW_MODEL_MANAGER_H_INCLUDED +#define NEW_MODEL_MANAGER_H_INCLUDED + +#include "include/Utils/Utils.h" +#include "include/Render/RenderMisc.h" +#include "include/Render/RenderParams.h" + +namespace SE +{ + + +class TFlexModelManager; + +class TFlexModelResource : public TSerializeInterface +{ +protected: + TDataTriangleList DataTriangleList; + + std::map SamplerMap; + + int TriangleCount; +public: + + TFlexModelResource() + : TriangleCount(0) + { + } + + virtual void Serialize(boost::property_tree::ptree& propertyTree); + + friend class TFlexModelManager; +}; + + +class TFlexModel +{ +protected: + TRenderPair RenderPair; + + std::stack DataTriangleListStack; + + bool Loaded; + +public: + + void PushModelDataTriangleList(); + void PopModelDataTriangleList(); + + void MoveModel(const vec3& v); + void RotateModel(const mat3& r); + void ScaleModel(float s); + void ScaleModel(const vec3& s); + + void RefreshBuffer(); + + void Draw(); + + friend class TFlexModelManager; +}; + + +class TFlexModelManager +{ +protected: + + std::map FlexModelResourceMap; + +public: + + void LoadModelFromXml(std::string xmlFileName); + + TFlexModel InstanciateModel(const std::string& modelName); + +}; + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/OpenGLExt/OpenGlExt.h b/include/OpenGLExt/OpenGlExt.h new file mode 100644 index 0000000..3aa30ab --- /dev/null +++ b/include/OpenGLExt/OpenGlExt.h @@ -0,0 +1,120 @@ +#pragma once + +/* +This code contains openGL extensions (for them to be called from everywhere) + +Windows only! +*/ + +#include "include/Utils/WinApi/WinApi.h" + + +namespace SE +{ + +//==================================================== +//===================== GLSL Shaders ================= +//==================================================== + +//Requires GL_VERSION_2_0 +extern PFNGLCREATEPROGRAMPROC glCreateProgram; +extern PFNGLDELETEPROGRAMPROC glDeleteProgram; +extern PFNGLLINKPROGRAMPROC glLinkProgram; +extern PFNGLVALIDATEPROGRAMPROC glValidateProgram; +extern PFNGLUSEPROGRAMPROC glUseProgram; +extern PFNGLGETPROGRAMIVPROC glGetProgramiv; +extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; +extern PFNGLCREATESHADERPROC glCreateShader; +extern PFNGLDELETESHADERPROC glDeleteShader; +extern PFNGLSHADERSOURCEPROC glShaderSource; +extern PFNGLCOMPILESHADERPROC glCompileShader; +extern PFNGLATTACHSHADERPROC glAttachShader; +extern PFNGLDETACHSHADERPROC glDetachShader; +extern PFNGLGETSHADERIVPROC glGetShaderiv; +extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; +extern PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation; +extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; +extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; +extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; +extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; +extern PFNGLUNIFORMMATRIX3FVPROC glUniformMatrix3fv; +extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; +extern PFNGLUNIFORM1IPROC glUniform1i; +extern PFNGLUNIFORM1FVPROC glUniform1fv; +extern PFNGLUNIFORM3FVPROC glUniform2fv; +extern PFNGLUNIFORM3FVPROC glUniform3fv; +extern PFNGLUNIFORM4FVPROC glUniform4fv; +extern PFNGLVERTEXATTRIB1FPROC glVertexAttrib1f; +extern PFNGLVERTEXATTRIB2FPROC glVertexAttrib2f; +extern PFNGLVERTEXATTRIB3FPROC glVertexAttrib3f; +extern PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f; +extern PFNGLVERTEXATTRIB2FVPROC glVertexAttrib2fv; +extern PFNGLVERTEXATTRIB3FVPROC glVertexAttrib3fv; +extern PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv; +extern PFNGLGETACTIVEATTRIBPROC glGetActiveAttrib; +extern PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform; + + +//======================================= +//=========== Multitexture ============== +//======================================= + +//Requires GL version 1.3 +extern PFNGLACTIVETEXTUREPROC glActiveTexture; + +//======================================= +//========== Vertex buffer ============== +//======================================= + +//Requires GL_VERSION_1_5 +extern PFNGLGENBUFFERSPROC glGenBuffers; +extern PFNGLDELETEBUFFERSPROC glDeleteBuffers; +extern PFNGLBINDBUFFERPROC glBindBuffer; +extern PFNGLBUFFERDATAPROC glBufferData; +extern PFNGLBUFFERSUBDATAPROC glBufferSubData; +extern PFNGLMAPBUFFERPROC glMapBuffer; +extern PFNGLUNMAPBUFFERPROC glUnmapBuffer; + +//========================================= +//============ Frame buffer =============== +//========================================= + +//Requires GL_ARB_framebuffer_object +extern PFNGLISRENDERBUFFERPROC glIsRenderbuffer; +extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; +extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; +extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; +extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; +extern PFNGLGETRENDERBUFFERPARAMETERIVPROC glGetRenderbufferParameteriv; +extern PFNGLISFRAMEBUFFERPROC glIsFramebuffer; +extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; +extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; +extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; +extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; +extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D; +extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; +extern PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D; +extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; +extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv; +extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; +extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample; +extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap; +extern PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer; + + + +//=========================================== +//============ Uniform buffer =============== +//=========================================== + +//Requires GL_ARB_uniform_buffer_object +extern PFNGLGETUNIFORMINDICESPROC glGetUniformIndices; +extern PFNGLGETACTIVEUNIFORMSIVPROC glGetActiveUniformsiv; +extern PFNGLGETACTIVEUNIFORMNAMEPROC glGetActiveUniformName; +extern PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex; +extern PFNGLGETACTIVEUNIFORMBLOCKIVPROC glGetActiveUniformBlockiv; +extern PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glGetActiveUniformBlockName; +extern PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding; +extern PFNGLBINDBUFFERBASEPROC glBindBufferBase; + +} //namespace SE diff --git a/include/Render/HalibutRender/HalibutRenderAndroid.h b/include/Render/HalibutRender/HalibutRenderAndroid.h new file mode 100644 index 0000000..c904a8c --- /dev/null +++ b/include/Render/HalibutRender/HalibutRenderAndroid.h @@ -0,0 +1,18 @@ +#ifndef HALIBUT_RENDER_ANDROID_H_INCLUDED +#define HALIBUT_RENDER_ANDROID_H_INCLUDED + + +#include "include/Utils/Utils.h" + +#include "include/Render/HalibutRender/HalibutRenderGLES20.h" + +namespace SE +{ + +class THalibutRendererAndroid : public THalibutRendererGLES20 +{ +}; + +} //namespace SE + +#endif diff --git a/include/Render/HalibutRender/HalibutRenderGLES20.h b/include/Render/HalibutRender/HalibutRenderGLES20.h new file mode 100644 index 0000000..6c3e086 --- /dev/null +++ b/include/Render/HalibutRender/HalibutRenderGLES20.h @@ -0,0 +1,28 @@ +#ifndef HALIBUT_RENDER_GLES20_H_INCLUDED +#define HALIBUT_RENDER_GLES20_H_INCLUDED + +#include "include/Utils/Utils.h" + +#include "include/Render/HalibutRender/HalibutRenderInterface.h" +#include "include/Render/RenderMisc.h" + +namespace SE +{ + +class THalibutRendererGLES20 : public THalibutRendererInterface +{ +protected: + + void DrawQuad(const T2DQuad& quad); + +public: + THalibutRendererGLES20(); + ~THalibutRendererGLES20(); + + virtual void DrawTriangleList(const TTriangleList& triangleList); + +}; + +} //namespace SE + +#endif diff --git a/include/Render/HalibutRender/HalibutRenderInterface.h b/include/Render/HalibutRender/HalibutRenderInterface.h new file mode 100644 index 0000000..80198d9 --- /dev/null +++ b/include/Render/HalibutRender/HalibutRenderInterface.h @@ -0,0 +1,32 @@ +#ifndef HALIBUT_RENDER_INTERFACE_H_INCLUDED +#define HALIBUT_RENDER_INTERFACE_H_INCLUDED + +#include "include/Utils/Utils.h" +#include "include/Render/RenderInterface.h" + +namespace SE +{ + +class THalibutRendererInterface : public TRendererInterface +{ +protected: + + + +public: + + virtual void SetUniforms(); + + virtual void InitOpenGL(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight); + + virtual void SwitchToScreen(); + virtual void SwitchToFrameBuffer(const std::string& frameName); + + virtual void PrintMatrices(); + + +}; + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/Render/HalibutRender/HalibutRenderIos.h b/include/Render/HalibutRender/HalibutRenderIos.h new file mode 100644 index 0000000..52df332 --- /dev/null +++ b/include/Render/HalibutRender/HalibutRenderIos.h @@ -0,0 +1,18 @@ +#ifndef HALIBUT_RENDER_IOS_H_INCLUDED +#define HALIBUT_RENDER_IOS_H_INCLUDED + + +#include "include/Utils/Utils.h" + +#include "include/Render/HalibutRender/HalibutRenderGLES20.h" + +namespace SE +{ + +class THalibutRenderIos : public THalibutRendererGLES20 +{ +}; + +} //namespace SE + +#endif diff --git a/include/Render/HalibutRender/HalibutRenderWindows.h b/include/Render/HalibutRender/HalibutRenderWindows.h new file mode 100644 index 0000000..43c8140 --- /dev/null +++ b/include/Render/HalibutRender/HalibutRenderWindows.h @@ -0,0 +1,30 @@ +#pragma once + +#include "include/Utils/Utils.h" +#include "include/Render/HalibutRender/HalibutRenderInterface.h" +#include "include/Render/RenderMisc.h" + +#include "boost/shared_ptr.hpp" +#include "include/OpenGLExt/OpenGlExt.h" + +namespace SE +{ + +class THalibutRenderer : public THalibutRendererInterface +{ +protected: + + + void DrawTriangleStripImmediate(const TTriangleList& triangleList); + void DrawQuad(const T2DQuad& quad); +public: + THalibutRenderer(); + ~THalibutRenderer(); + + bool BindOpenGLFunctions(); //Must be called once + + virtual void DrawTriangleList(const TTriangleList& triangleList); + +}; + +} //namespace SE \ No newline at end of file diff --git a/include/Render/RenderInterface.h b/include/Render/RenderInterface.h new file mode 100644 index 0000000..2338fef --- /dev/null +++ b/include/Render/RenderInterface.h @@ -0,0 +1,78 @@ +#ifndef RENDER_INTERFACE_H_INCLUDED +#define RENDER_INTERFACE_H_INCLUDED + + +#include "include/Utils/Utils.h" +#include "include/Render/RenderMisc.h" +#include "include/Render/RenderParams.h" + +namespace SE +{ + +class TRendererInterface +{ +protected: + int ScreenWidth; + int ScreenHeight; + + float MatrixWidth; + float MatrixHeight; + + mat4 ProjectionModelviewMatrix; + + std::stack ProjectionMatrixStack; + std::stack ModelviewMatrixStack; + + virtual void TryEnableVertexAttribArrays(); + virtual void TryDisableVertexAttribArrays(); + virtual void DrawQuad(const T2DQuad& quad) = 0; +public: + TRendererInterface(); + virtual ~TRendererInterface() { } + + virtual void InitOpenGL(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight) = 0; + + virtual int GetScreenWidth(); + virtual int GetScreenHeight(); + + virtual float GetMatrixWidth(); + virtual float GetMatrixHeight(); + + virtual void SetScreenWidthHeight(int screenWidth, int screenHeight); + + virtual void SetUniforms() = 0; + + virtual void PushMatrix(); + virtual void LoadIdentity(); + virtual void TranslateMatrix(const vec3& p); + virtual void ScaleMatrix(float scale); + virtual void ScaleMatrix(const vec3& scale); + virtual void RotateMatrix(const vec4& q); + virtual void PushSpecialMatrix(const mat4& m); + virtual void PopMatrix(); + + virtual void SetProjectionMatrix(float width, float height); + virtual void PushProjectionMatrix(float width, float height); + virtual void PopProjectionMatrix(); + + virtual void SetFrameViewport(const std::string& frameName); + virtual void SetFullScreenViewport(); + + virtual void PushShader(const std::string& shaderName); + virtual void PopShader(); + + virtual void DrawRect(const vec2& p1, const vec2& p2); + virtual void DrawRect(const vec2& p1, const vec2& p2, const vec2& t1, const vec2& t2); + virtual void DrawTriangleList(const TTriangleList& triangleList) = 0; + + virtual void SwitchToScreen() = 0; + virtual void SwitchToFrameBuffer(const std::string& frameName) = 0; + + void DrawFrameFullScreen(const std::string& frameName); + void DrawFramePartScreen(const std::string& frameName, vec2 posFrom, vec2 posTo); //To draw water. posFrom and posTo goes from 0 to 1 + +}; + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/Render/RenderMisc.h b/include/Render/RenderMisc.h new file mode 100644 index 0000000..cdecca5 --- /dev/null +++ b/include/Render/RenderMisc.h @@ -0,0 +1,145 @@ +#ifndef RENDER_MISC_H_INCLUDED +#define RENDER_MISC_H_INCLUDED + + +#include "include/Utils/DataTypes/DataTypes.h" +//#include "include/Utils/SerializeInterface/SerializeInterface.h" +#include "boost/shared_ptr.hpp" +#include +#include +#include + + + +#ifdef TARGET_WIN32 + +#include "include/OpenGLExt/OpenGlExt.h" + +#endif + +namespace SE +{ + +struct T2DQuad +{ + vec3 VertexCoord[4]; + vec2 TextureCoord[4]; +}; + +struct TDataTriangleList +{ + mutable std::map> Vec3CoordArr; //mutable because when you call [] on map, it may create a new vector =) + mutable std::map> Vec2CoordArr; //mutable because when you call [] on map, it may create a new vector =) + + TDataTriangleList& operator+=(const TDataTriangleList& dataTriangleList); +}; + +class TTriangleListAncestor +{ +public: + + TDataTriangleList Data; + + bool NeedRefreshBuffer;//Dummy for Android, but you need this for PC + + virtual void RefreshBuffer() { } //Dummy for Android, but you need this for PC + + TTriangleListAncestor(); + + TTriangleListAncestor(const TTriangleListAncestor& c); + + TTriangleListAncestor& operator=(const TTriangleListAncestor& c); + + TTriangleListAncestor(const TDataTriangleList& dataTriangleList); + + TTriangleListAncestor& operator=(const TDataTriangleList& dataTriangleList); + + virtual ~TTriangleListAncestor(); +}; + + +#ifdef TARGET_WIN32 + +class VBOObject //Must stay in shared ptr only! +{ +public: + cardinal Buffer; + + VBOObject(); + + VBOObject(const VBOObject& c); + + VBOObject& operator=(const VBOObject& c); + + ~VBOObject(); +}; + + + +class TTriangleList : public TTriangleListAncestor //Implementation differs for Windows and Android +{ +public: + + mutable std::map > VertBufferArr; + + bool NeedPrepareBufferObjects; + + TTriangleList(); + + ~TTriangleList(); + + virtual void RefreshBuffer(); + +}; + +#endif + +#ifdef TARGET_ANDROID + +class TTriangleList : public TTriangleListAncestor +{ + //No difference +}; + +#endif + + +#ifdef TARGET_IOS + +class TTriangleList : public TTriangleListAncestor +{ + //No difference +}; + +#endif + + +void FillVertexCoordVec(std::vector& coordVec, int pos, vec2 posFrom, vec2 posTo); + +void FillTexCoordVec(std::vector& coordVec, int pos, vec2 texCoordFrom = vec2(0,0), vec2 texCoordTo = vec2(1,1)); + + +std::vector MakeVertexCoordVec(vec2 posFrom, vec2 posTo); + +std::vector MakeTexCoordVec(vec2 texCoordFrom = vec2(0,0), vec2 texCoordTo = vec2(1,1)); + + +TDataTriangleList MakeDataTriangleList(vec2 posFrom, vec2 posTo, vec2 texCoordFrom = vec2(0,0), vec2 texCoordTo = vec2(1,1)); +void MoveDataTriangleList(TDataTriangleList& triangleList, vec3 shift); +void RotateDataTriangleList(TDataTriangleList& triangleList, const mat3& m); +void ScaleDataTriangleList(TDataTriangleList& triangleList, float scale); +void ScaleDataTriangleList(TDataTriangleList& triangleList, vec3 scaleVec); +TDataTriangleList& ClearDataTriangleList(TDataTriangleList& triangleList); +TDataTriangleList& InsertIntoDataTriangleList(TDataTriangleList& triangleList, const std::vector& vertexArr, const std::vector& texCoordArr); + +void Replace6PointsInTriangleList(TDataTriangleList& triangleList, int pos, vec2 posFrom, vec2 posTo, vec2 texCoordFrom = vec2(0,0), vec2 texCoordTo = vec2(1,1)); + + +TTriangleList MakeTriangleList(vec2 posFrom, vec2 posTo, vec2 texCoordFrom = vec2(0,0), vec2 texCoordTo = vec2(1,1)); + +void CheckGlError(const std::string& msg = ""); + + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/Render/RenderParams.h b/include/Render/RenderParams.h new file mode 100644 index 0000000..5f1bbdf --- /dev/null +++ b/include/Render/RenderParams.h @@ -0,0 +1,51 @@ +#ifndef RENDER_PARAMS_H_INCLUDED +#define RENDER_PARAMS_H_INCLUDED + + +#include "include/Utils/DataTypes/DataTypes.h" +#include "include/Utils/SerializeInterface/SerializeInterface.h" +#include "boost/shared_ptr.hpp" +#include +#include +#include + + + +#ifdef TARGET_WIN32 + +#include "include/OpenGLExt/OpenGlExt.h" + +#endif + +namespace SE +{ + +struct TRenderParams : public TSerializeInterface +{ + std::string ShaderName; + + mutable std::map SamplerMap; + mutable std::map FloatMap; + mutable std::map Vec4Map; + + virtual void Serialize(boost::property_tree::ptree& propertyTree); + +}; + +typedef std::pair TRenderPair; + +typedef std::list TRenderPairList; + + +struct TRenderParamsSetter +{ +protected: + const TRenderParams& RenderParams; +public: + TRenderParamsSetter(const TRenderParams& renderParams); + ~TRenderParamsSetter(); +}; + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/Render/SalmonRender/BackgroundCubemap.h b/include/Render/SalmonRender/BackgroundCubemap.h new file mode 100644 index 0000000..f048582 --- /dev/null +++ b/include/Render/SalmonRender/BackgroundCubemap.h @@ -0,0 +1,27 @@ +#ifndef BACKGROUND_CUBEMAP_H_INCLUDED +#define BACKGROUND_CUBEMAP_H_INCLUDED + +#include "include/Render/RenderMisc.h" +#include "include/Utils/Utils.h" + +namespace SE +{ + +class TBackgroundCubemapClass +{ +protected: + TTriangleList TriangleList; + + +public: + cardinal BkgTexId; + + TBackgroundCubemapClass(); + + void Draw(); +}; + +} //namespace SE + + +#endif \ No newline at end of file diff --git a/include/Render/SalmonRender/SalmonRenderAndroid.h b/include/Render/SalmonRender/SalmonRenderAndroid.h new file mode 100644 index 0000000..413f863 --- /dev/null +++ b/include/Render/SalmonRender/SalmonRenderAndroid.h @@ -0,0 +1,17 @@ +#ifndef SALMON_RENDER_ANDROID_H_INCLUDED +#define SALMON_RENDER_ANDROID_H_INCLUDED + +#include "include/Render/SalmonRender/SalmonRenderGLES20.h" + +namespace SE +{ + +class TSalmonRendererAndroid : public TSalmonRendererGLES20 +{ +}; + + +} //namespace SE + + +#endif \ No newline at end of file diff --git a/include/Render/SalmonRender/SalmonRenderGLES20.h b/include/Render/SalmonRender/SalmonRenderGLES20.h new file mode 100644 index 0000000..a662185 --- /dev/null +++ b/include/Render/SalmonRender/SalmonRenderGLES20.h @@ -0,0 +1,29 @@ +#ifndef SALMON_RENDER_GLES20_H_INCLUDED +#define SALMON_RENDER_GLES20_H_INCLUDED + +#include "include/Render/SalmonRender/SalmonRenderInterface.h" + +#ifdef TARGET_ANDROID +#include +#include +#include +#endif + +namespace SE +{ + +class TSalmonRendererGLES20 : public TSalmonRendererInterface +{ +protected: + + virtual void DrawQuad(const T2DQuad& quad); +public: + + void DrawTriangleList(const TTriangleList& triangleList); + + +}; + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/Render/SalmonRender/SalmonRenderInterface.h b/include/Render/SalmonRender/SalmonRenderInterface.h new file mode 100644 index 0000000..9fc7483 --- /dev/null +++ b/include/Render/SalmonRender/SalmonRenderInterface.h @@ -0,0 +1,86 @@ +#ifndef SALMON_RENDER_INTERFACE_H_INCLUDED +#define SALMON_RENDER_INTERFACE_H_INCLUDED + +#include "include/Utils/Utils.h" + +#include "include/SimpleLand/SimpleLand.h" + +#include "include/Render/RenderMisc.h" + +#include "include/Render/SalmonRender/BackgroundCubemap.h" + +#include "include/Render/RenderInterface.h" + +namespace SE +{ + +class TSalmonRendererInterface : public TRendererInterface +{ +protected: + + float CamAlpha; + float CamPhi; + float CamDist; + vec3 CamShift; + vec3 CamPos; //Do not change - call CalcCamPosVec instead + vec3 CamVec; //Do not change - call CalcCamPosVec instead + + mat4 CamModelViewMatrix; + mat4 CamInversedModelViewMatrix; + + float GlobalShadowAreaHalfSize; + + void CalcCamPosVec(); + + virtual void DrawQuad(const T2DQuad& quad) = 0; +public: + + TSalmonRendererInterface(); + + virtual void InitOpenGL(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight); + + virtual void SetUniforms(); + + void SetPerspectiveFullScreenViewport(); + void SetOrthoFullScreenViewport(); + + mat4 GetModelviewMatrix(); + + void SetPerspectiveProjectionMatrix(float angle, float aspect, float zNear, float zFar); + void PushPerspectiveProjectionMatrix(float angle, float aspect, float zNear, float zFar); + + void SetGLCamView(); + void SetGlIdentityView(); + void SetGlPosXView(); + void SetGlNegXView(); + void SetGlPosYView(); + void SetGlNegYView(); + void SetGlPosZView(); + void SetGlNegZView(); + + + void MoveAlpha(float dAlpha); + void MovePhi(float dPhi); + void MoveDist(float dDist); + + void SetAlpha(float alpha); + vec3 GetCamPos(); + + void MoveForward(); + void MoveBackward(); + void MoveLeft(); + void MoveRight(); + + virtual void SwitchToScreen(); + virtual void SwitchToFrameBuffer(const std::string& frameName); + void SwitchToCubemapBuffer(const std::string& frameName,cardinal cubeSide); + + void BeginDrawToDepthBufferGlobal(std::string& globalBufferName); + void BeginDrawToDepthBufferLocal(std::string& localBufferName); + void EndDrawToDepthBuffer(); + +}; + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/Render/SalmonRender/SalmonRenderIos.h b/include/Render/SalmonRender/SalmonRenderIos.h new file mode 100644 index 0000000..30d61e4 --- /dev/null +++ b/include/Render/SalmonRender/SalmonRenderIos.h @@ -0,0 +1,20 @@ +#ifndef SALMON_RENDER_IOS_H_INCLUDED +#define SALMON_RENDER_IOS_H_INCLUDED + +#include "include/Render/SalmonRender/SalmonRenderGLES20.h" + +namespace SE +{ + +class TSalmonRendererIos : public TSalmonRendererGLES20 +{ +protected: + +public: + + +}; + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/Render/SalmonRender/SalmonRenderWindows.h b/include/Render/SalmonRender/SalmonRenderWindows.h new file mode 100644 index 0000000..3da66d3 --- /dev/null +++ b/include/Render/SalmonRender/SalmonRenderWindows.h @@ -0,0 +1,57 @@ +#pragma once + +/* +This code is the heart of engine. Here is the render and resource manager +*/ + + +#include "include/Utils/Utils.h" + +#include "include/SimpleLand/SimpleLand.h" + +#include "include/Render/SalmonRender/SalmonRenderInterface.h" + + +namespace SE +{ + +class TSalmonRenderer : public TSalmonRendererInterface +{ +protected: + + bool IsCameraTransparentToLand; //To make it work you must setup LandToCalcCollision + TSimpleLandClass* LandToCalcCollision; + + float FogBeginDistance; + float FogEndDistance; + vec4 FogColor; + + + //Other data: + + float ShadowClampValue; + + virtual void DrawQuad(const T2DQuad& quad); + +public: + TSalmonRenderer(); + + ~TSalmonRenderer(); + + bool BindOpenGLFunctions(); + + void SetLandToCalcCollision(TSimpleLandClass* landToCalcCollision); + + float GetShadowClampValue(); + void SetShadowClampValue(float shadowClampValue); + + float GetFogBeginDistance(); + float GetFogEndDistance(); + vec4 GetFogColor(); + + void DrawTriangleList(const TTriangleList& triangleList); + + +}; + +} //namespace SE \ No newline at end of file diff --git a/include/SalmonEngineAndroid.h b/include/SalmonEngineAndroid.h new file mode 100644 index 0000000..9c2facb --- /dev/null +++ b/include/SalmonEngineAndroid.h @@ -0,0 +1,63 @@ +#ifndef SALMON_ENGINE_ANDROID_H_INCLUDED +#define SALMON_ENGINE_ANDROID_H_INCLUDED +/* +This code combines all headers for Salmon engine into one header file +*/ + +#include "include/SalmonEngineInterface.h" + +namespace SE +{ + +extern TJavaConsole* Console; +extern TSalmonRendererAndroid* Renderer; +extern TResourceManager* ResourceManager; + +class TApplication : public TApplicationAncestor +{ +protected: +public: + int X, Y, Width, Height; //Window position and size + + TApplication() : X(0), Y(0), Width(4), Height(4) { } + + virtual void OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight); + + virtual void InnerInit() = 0; + //To do on init + + virtual void OuterDeinit(); + + virtual void InnerDeinit() = 0; + //To do on deinit + + virtual void OuterDraw(); + + virtual void InnerDraw() = 0; + //What to draw + + virtual void OuterUpdate(cardinal timer); + + virtual void InnerUpdate(cardinal timer) = 0; + //To do on update + + virtual void UpdateQuick() { }; + //To process input - this method is called more frequently than Update() + + virtual void OnMouseMove(TMouseState& mouseState) { } + //To do on mouse move (with or without pressed buttons) + + virtual void OnMouseDown(TMouseState& mouseState) { } + //To do on mouse up (with or without pressed buttons) + + virtual void OnMouseUp(TMouseState& mouseState) { } + //To do on mouse down (with or without pressed buttons) + //Be careful - even when user "upped" button, in mouseState this button appears as pressed + + virtual void OnMouseWheel(short int delta) { } + //To do on mouse wheel move +}; + +} //namespace SE + +#endif diff --git a/include/SalmonEngineInterface.h b/include/SalmonEngineInterface.h new file mode 100644 index 0000000..218b111 --- /dev/null +++ b/include/SalmonEngineInterface.h @@ -0,0 +1,135 @@ +#ifndef SALMON_ENGINE_INTERFACE_H_INCLUDED +#define SALMON_ENGINE_INTERFACE_H_INCLUDED + +/* +This code combines all headers for Salmon engine into one header file +*/ + + +#include "include/ApplicationInterface.h" + +#include "include/Render/SalmonRender/SalmonRenderInterface.h" + +#ifdef TARGET_ANDROID +#include "include/Render/SalmonRender/SalmonRenderAndroid.h" +#endif +#ifdef TARGET_WIN32 +#include "include/Render/SalmonRender/SalmonRenderWindows.h" +#endif +#ifdef TARGET_IOS +#include "include/Render/SalmonRender/SalmonRenderIos.h" +#endif + + +#include "include/Render/RenderMisc.h" + +#include "include/Animation/SalmonAnimation.h" +#include "include/TextureManager/SalmonTexture.h" +#include "include/ShaderManager/ShaderManager.h" +#include "include/FrameManager/FrameManager.h" +#include "include/LightManager/LightManager.h" +#include "include/ScriptManager/ScriptManager.h" +#ifdef TARGET_ANDROID +#include "include/SoundManager/SoundManagerAndroid.h" +#endif +#ifdef TARGET_WIN32 +#include "include/SoundManager/SoundManagerWindows.h" +#endif +#ifdef TARGET_IOS +#include "include/SoundManager/SoundManagerIos.h" +#endif +#include "include/FontManager/FontManager.h" +#include "include/SimpleLand/SimpleLand.h" +#include "include/SmartValueManager/SmartValueManager.h" + +#include "include/ModelManager/NewModelManager.h" + + +namespace SE +{ + +class TResourceManager +{ +protected: +public: + std::string PathToResources; + + TTextureListClass TexList; + TModelManager ModelManager; + TFlexModelManager FlexModelManager; + TShaderManager ShaderManager; + TFrameManager FrameManager; + TLightManager LightManager; + TModelAnimManager ModelAnimManager; + TScriptManager ScriptManager; + TFontManager FontManager; + TSmartValueManager SmartValueManager; + +#ifdef TARGET_ANDROID + TSoundManagerAndroid SoundManager; +#endif +#ifdef TARGET_WIN32 + TSoundManagerWindows SoundManager; +#endif +#ifdef TARGET_IOS + TSoundManagerIos SoundManager; +#endif + + ~TResourceManager() { } +}; + + +struct TMouseState +{ + int X; + int Y; + bool LeftButtonPressed; + bool MiddleButtonPressed; + bool RightButtonPressed; +}; + + + +class TApplicationAncestor : public TApplicationInterface +{ +protected: + +public: + + TApplicationAncestor(); + + + virtual void OuterDeinit(); + //To do on deinit + + virtual void OuterDraw(); + //What to draw + + virtual void OuterUpdate(cardinal timer); + //To do on update + + virtual void UpdateQuick() { } + //To process input - this method is called more frequently than Update() + + virtual void OuterOnMove(vec2 shift); + virtual void InnerOnMove(vec2 shift) { } + //To do on mouse move (with or without pressed buttons) + + virtual void OnMouseDown(TMouseState& mouseState) { } + //To do on mouse up (with or without pressed buttons) + + virtual void OnMouseUp(TMouseState& mouseState) { } + //To do on mouse down (with or without pressed buttons) + //Be careful - even when user "upped" button, in mouseState this button appears as pressed + + virtual void OnMouseWheel(short int delta) { } + //To do on mouse wheel move + + virtual void OnKeyPress(cardinal key) { } //Try not to override this. But if you need to override, call ancestor! +}; + + +} //namespace SE + +#endif + diff --git a/include/SalmonEngineIos.h b/include/SalmonEngineIos.h new file mode 100644 index 0000000..4b7c97f --- /dev/null +++ b/include/SalmonEngineIos.h @@ -0,0 +1,63 @@ +#ifndef SALMON_ENGINE_ANDROID_H_INCLUDED +#define SALMON_ENGINE_ANDROID_H_INCLUDED +/* +This code combines all headers for Salmon engine into one header file +*/ + +#include "include/SalmonEngineInterface.h" + +namespace SE +{ + +extern TIosConsole* Console; +extern TSalmonRendererIos* Renderer; +extern TResourceManager* ResourceManager; + +class TApplication : public TApplicationAncestor +{ +protected: +public: + int X, Y, Width, Height; //Window position and size + + TApplication() : X(0), Y(0), Width(4), Height(4) { } + + virtual void OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight); + + virtual void InnerInit() = 0; + //To do on init + + virtual void OuterDeinit(); + + virtual void InnerDeinit() = 0; + //To do on deinit + + virtual void OuterDraw(); + + virtual void InnerDraw() = 0; + //What to draw + + virtual void OuterUpdate(cardinal timer); + + virtual void InnerUpdate(cardinal timer) = 0; + //To do on update + + virtual void UpdateQuick() { }; + //To process input - this method is called more frequently than Update() + + virtual void OnMouseMove(TMouseState& mouseState) { } + //To do on mouse move (with or without pressed buttons) + + virtual void OnMouseDown(TMouseState& mouseState) { } + //To do on mouse up (with or without pressed buttons) + + virtual void OnMouseUp(TMouseState& mouseState) { } + //To do on mouse down (with or without pressed buttons) + //Be careful - even when user "upped" button, in mouseState this button appears as pressed + + virtual void OnMouseWheel(short int delta) { } + //To do on mouse wheel move +}; + +} //namespace SE + +#endif diff --git a/include/SalmonEngineWindows.h b/include/SalmonEngineWindows.h new file mode 100644 index 0000000..a231836 --- /dev/null +++ b/include/SalmonEngineWindows.h @@ -0,0 +1,72 @@ +#pragma once + +/* +This code combines all headers for Salmon engine into one header file +*/ + +#include "include/SalmonEngineInterface.h" + +namespace SE +{ + +//============================================================== +//========= GLOBAL VARIABLES - REMEMBER THIS LIST!!! =========== +//============================================================== + +extern TFileConsole* Console; +extern TSalmonRenderer* Renderer; +extern TResourceManager* ResourceManager; + + +extern HGLRC hRC; //Render context +extern HWND Hwnd; //Main window handle +extern HDC hDC; //Device context + + +class TApplication : public TApplicationAncestor +{ +protected: + std::string LogFilename; //Log file name +public: + int X, Y, Width, Height; //Window position and size + + std::string WindowName; //Window name + + TApplication() : X(0), Y(0), Width(800), Height(600), WindowName("Salmon Engine"), LogFilename("log.txt") { } + + const std::string& GetLogFilename() { return LogFilename; } + + virtual void InnerInit() = 0; + //To do on init + + virtual void InnerDeinit() = 0; + //To do on deinit + + virtual void InnerDraw() = 0; + //What to draw + + virtual void InnerUpdate(cardinal timer) = 0; + //To do on update + + virtual void UpdateQuick() { }; + //To process input - this method is called more frequently than Update() + + virtual void OnMouseMove(TMouseState& mouseState) { } + //To do on mouse move (with or without pressed buttons) + + virtual void OnMouseDown(TMouseState& mouseState) { } + //To do on mouse up (with or without pressed buttons) + + virtual void OnMouseUp(TMouseState& mouseState) { } + //To do on mouse down (with or without pressed buttons) + //Be careful - even when user "upped" button, in mouseState this button appears as pressed + + virtual void OnMouseWheel(short int delta) { } + //To do on mouse wheel move + + virtual void OnKeyPress(cardinal key); //Try not to override this. But if you need to override, call ancestor! +}; + +int MainLoop(TApplication& application); + +} //namespace SE \ No newline at end of file diff --git a/include/ScriptManager/ScriptManager.h b/include/ScriptManager/ScriptManager.h new file mode 100644 index 0000000..ac6e19b --- /dev/null +++ b/include/ScriptManager/ScriptManager.h @@ -0,0 +1,117 @@ +#ifndef SCRIPT_MANAGER_H_INCLUDED +#define SCRIPT_MANAGER_H_INCLUDED + +#include "sqplus.h" +#include +#include + +namespace SE +{ + +struct TScriptInfo +{ + std::string LongName; + std::string ShortDescription; + std::string Description; + bool Registered; + + TScriptInfo() + : Registered(false) + { + } + + TScriptInfo(const std::string& longName, const std::string& shortDescription = "", const std::string& description = "") + : LongName(longName) + , ShortDescription(shortDescription) + , Description(description) + , Registered(false) + { + } +}; + + +class TFunctionBinderInterface +{ +public: + static std::vector BinderList; + + TFunctionBinderInterface() + { + BinderList.push_back(this); + } + + virtual void BindFunctions() = 0; +}; + + +class TScriptManager : public TSerializeInterface +{ +protected: + HSQUIRRELVM virtualMachine; + std::map FuncInfoMap; + + template + void RegisterFunc(T1& object, T2 method, const std::string& funcName) + { + SqPlus::RegisterGlobal(virtualMachine, object, method, _SC(funcName.c_str())); + } + + template + void RegisterFunc(T globalFunc, const std::string& funcName) + { + SqPlus::RegisterGlobal(virtualMachine, globalFunc, _SC(funcName.c_str())); + } + +public: + TScriptManager(); + ~TScriptManager(); + + void AddFuncDescription(const std::string& shortName, TScriptInfo scriptInfo); + + void RunScript(const std::string& scriptCode); + + void BindBasicFunctions(); + + template + void AddFunction(const std::string& shortName, TScriptInfo scriptInfo, T1& object, T2 method) + { + AddFuncDescription(shortName, scriptInfo); + RegisterFunc(object, method, shortName); + RegisterFunc(object, method, scriptInfo.LongName); + FuncInfoMap[shortName].Registered = true; + } + + + template + void AddFunction(const std::string& shortName, TScriptInfo scriptInfo, T globalFunc) + { + AddFuncDescription(shortName, scriptInfo); + RegisterFunc(globalFunc, shortName); + RegisterFunc(globalFunc, scriptInfo.LongName); + FuncInfoMap[shortName].Registered = true; + } + + void BindFunctionsFromObject(TFunctionBinderInterface* binderObject); + + void PrintRegisteredFunctionList(); + + void PrintFunctionInfo(const std::string& funcName); + + virtual void Serialize(boost::property_tree::ptree& propertyTree); + +}; + + + +void SQ_Print(const SQChar *inString); +void SQ_PrintWidgetList(); +void SQ_MoveWidget(const SQChar *widgetName, float x, float y); +//void SQ_PrintTextureList(); +//void SQ_PrintAnimationList(); + +//void SQ_MoveWidgetTransformTaskTest(const SQChar *groupName, float x, float y, cardinal totalTime); + + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/ShaderManager/ShaderManager.h b/include/ShaderManager/ShaderManager.h new file mode 100644 index 0000000..b151d74 --- /dev/null +++ b/include/ShaderManager/ShaderManager.h @@ -0,0 +1,160 @@ +#ifndef SHADER_MANAGER_H_INCLUDED +#define SHADER_MANAGER_H_INCLUDED + +/* +This code contains shader manager +*/ + +#include + +#ifdef TARGET_WIN32 +#include "../OpenGlExt/OpenGlExt.h" +#endif + +#include "include/Utils/Utils.h" + +namespace SE +{ + +//============================================== +//=============== CONST AREA =================== +//============================================== + + +//Global uniforms (must remain same from shader to shader) +//If you add a new one - put it to SetCurrentShader() too +const std::string CONST_STRING_TEXTURE_UNIFORM = "Texture"; +const std::string CONST_STRING_NORMALMAP_UNIFORM = "NormalMap"; +const std::string CONST_STRING_SHADOWMAPGLOBAL_UNIFORM = "ShadowMapGlobal"; +const std::string CONST_STRING_SHADOWMAPLOCAL_UNIFORM = "ShadowMapLocal"; +const std::string CONST_STRING_ENV_UNIFORM = "Env"; +const std::string CONST_STRING_NORMALMAPEXISTS_UNIFORM = "NormalMapExists"; + +const std::string CONST_STRING_LIGHT_POS_UNIFORM = "LightPos"; +const std::string CONST_STRING_LIGHT_DIRECTION_UNIFORM = "LightDirection"; +const std::string CONST_STRING_LIGHT_COLOR_UNIFORM = "LightColor"; + +const std::string CONST_STRING_CAMPOS_UNIFORM = "CamPos"; +const std::string CONST_STRING_SHADOWCLAMPVALUE_UNIFORM = "ShadowClampValue"; + +const std::string CONST_STRING_FOG_BEGIN_DISTANCE_UNIFORM = "FogBeginDistance"; +const std::string CONST_STRING_FOG_END_DISTANCE_UNIFORM = "FogEndDistance"; +const std::string CONST_STRING_FOG_COLOR_UNIFORM = "FogColor"; + +const std::string CONST_STRING_MATERIAL_COLOR_UNIFORM = "MaterialColor"; +const std::string CONST_STRING_TRANSPARENCY_UNIFORM = "Transparency"; + +//For Halibut Render +const std::string CONST_STRING_HALIBUT_PROJECTION_MATRIX_UNIFORM = "ProjectionMatrix"; + +//Local uniforms (need to be setup before each draw) +const std::string CONST_STRING_MODELROTATEMATRIX_UNIFORM = "ModelRotateMatrix"; +const std::string CONST_STRING_MODELTRANSLATEVECTOR_UNIFORM = "ModelTranslateVector"; + + +//Attributes +const std::string CONST_STRING_POSITION_ATTRIB = "vPosition"; +const std::string CONST_STRING_TEXCOORD_ATTRIB = "vTexCoord"; + +const std::string CONST_STRING_NORMAL_ATTRIB = "Normal"; +const std::string CONST_STRING_TANGENT_ATTRIB = "Tangent"; +const std::string CONST_STRING_BINORMAL_ATTRIB = "Binormal"; + +//====================================== + +class TShaderManager; //see below + + + +class TShaderResource +{ +protected: + cardinal ShaderProgram; + + std::map > UniformList; + std::map > AttribList; + +public: + TShaderResource(); + ~TShaderResource(); + + bool CompileShader(boost::shared_array vertexCode, boost::shared_array fragmentCode); + void FreeShader(); + + int GetAttribIndex(const std::string& attribName); + int GetUniformIndex(const std::string& uniformName); + + friend void RenderUniform1f(const std::string& uniformName, const float value); + friend void RenderUniform3fv(const std::string& uniformName, const float* value); + friend void RenderUniform4fv(const std::string& uniformName, const float* value); + friend void RenderUniformMatrix3fv(const std::string& uniformName, bool transpose, const float* value); + friend void RenderUniformMatrix4fv(const std::string& uniformName, bool transpose, const float* value); + friend void RenderUniform1i(const std::string& uniformName, const int value); + + friend void VertexAttrib2fv(const std::string& attribName, const float* value); + friend void VertexAttrib3fv(const std::string& attribName, const float* value); + friend void VertexAttribPointer2fv(const std::string& attribName,int stride, const char* pointer); + friend void VertexAttribPointer3fv(const std::string& attribName,int stride, const char* pointer); + + friend void EnableVertexAttribArray(const std::string& attribName); + friend void DisableVertexAttribArray(const std::string& attribName); + + + #ifdef TARGET_WIN32 + friend void RefreshAttribBuffer2fv(const std::string& attribName, std::map >& vec2CoordArr); + friend void RefreshAttribBuffer3fv(const std::string& attribName, std::map >& vec3CoordArr); + #endif + + friend class TShaderManager; + +}; + +class TShaderManager : public TSerializeInterface +{ +protected: + std::map, std::less > ShaderList; + + std::stack ShaderNameStack; + + //To be called only by SalmonRander/HalibutRender!!! + void PushShader(const std::string& shaderName); + void PopShader(); +public: + TShaderManager() {} + ~TShaderManager(); + std::shared_ptr GetCurrentShader(); + + virtual void Serialize(boost::property_tree::ptree& propertyTree); + + bool AddShader(const std::string& shaderName, const std::string& vertexFileName, const std::string& fragmentFileName); + + void Clear(); + + friend class TRendererInterface; + +}; + +//Dont forget to make them friend to TShaderResource +void RenderUniform1f(const std::string& uniformName, const float value); +void RenderUniform3fv(const std::string& uniformName, const float* value); +void RenderUniform4fv(const std::string& uniformName, const float* value); +void RenderUniformMatrix3fv(const std::string& uniformName, bool transpose, const float* value); +void RenderUniformMatrix4fv(const std::string& uniformName, bool transpose, const float* value); +void RenderUniform1i(const std::string& uniformName, const int value); + +void VertexAttrib2fv(const std::string& attribName, const float* value); +void VertexAttrib3fv(const std::string& attribName, const float* value); +void VertexAttribPointer2fv(const std::string& attribName, int stride, const char* pointer); +void VertexAttribPointer3fv(const std::string& attribName, int stride, const char* pointer); + +void EnableVertexAttribArray(const std::string& attribName); +void DisableVertexAttribArray(const std::string& attribName); + +#ifdef TARGET_WIN32 +void RefreshAttribBuffer2fv(const std::string& attribName, std::map >& vec2CoordArr); +void RefreshAttribBuffer3fv(const std::string& attribName, std::map >& vec3CoordArr); +#endif + +} //namespace SE + +#endif diff --git a/include/SimpleLand/SimpleLand.h b/include/SimpleLand/SimpleLand.h new file mode 100644 index 0000000..5510c0d --- /dev/null +++ b/include/SimpleLand/SimpleLand.h @@ -0,0 +1,142 @@ +#ifndef SIMPLE_LAND_H_INCLUDED +#define SIMPLE_LAND_H_INCLUDED + +#include "include/Utils/Utils.h" + +namespace SE +{ + +const int CONST_DEFAULT_LAND_WIDTH = 16; +const int CONST_DEFAULT_LAND_HEIGHT = 16; +const float CONST_DEFAULT_LAND_CELL_INVERVAL = 2.0f; + +const float CONST_LAND_MOVE_STEP = 0.3f; + + +//Struct for one land vertex +struct TSimpleLandVertex +{ + vec3 pos; //Vertex position (x,y,z) + vec3 norm; //Vertex normal vector + vec3 tangent; //Vertex tangent vector + vec3 binorm; //Vertex binormal vector + int landtype; //Vertex type - not in use right now +}; + +struct TVBOLandVertex +{ + std::vector pos; //Vertex position (x,y,z) + std::vector norm; //Vertex normal vector + std::vector tangent; //Vertex tangent vector + std::vector binorm; //Vertex binormal vector + std::vector texCoord; //Vertex texture coords +}; + +//Land triangle +struct TLandSimpleTriangle +{ + vec3 PointList[3]; //3 vertices + vec3 NormVec; //Normal vector (not for draw, but for physics/collision) +}; + +//Land class +class TSimpleLandClass +{ +private: + + int Width; //Number of vertices along X + int Height; //Number of vertices along -Z + float CellInterval; //Distance between vertices + + std::vector VertexMatrix; + std::vector TriangleMatrix; + + //Textures: + cardinal TexID; + cardinal NormTexID; + + //For VBO: + std::vector IndexArr; + TVBOLandVertex VBOLandVertexArr; + + cardinal IndexBuffer; + cardinal VertexBuffer; + cardinal NormBuffer; + cardinal TangentBuffer; + cardinal BinormBuffer; + cardinal TexcoordBuffer; + + void CreateVBO(); + void FreeVBO(); + + void UpdateVBO(); + void UpdateTriangleMatrix(); + + + vec3 CalcCrossingForPoint(const vec3& lineFrom, const vec3& lineTo, int i, int j); + vec3 CalcCrossingForPoint(const vec3& pos, int i, int j); +public: + + TSimpleLandClass(); + + ~TSimpleLandClass(); + + bool LoadFromFile(const std::string& filename); + //Load land struct from ls1 file + + void SaveToFile(char* filename); //Xperimental. Not in use right now + + void SetTexture(const std::string& texFilename); + //Set land texture name + + void SetNormTexture(const std::string& normTexFilename); + //Set land texture name + + void DrawImmediate(); //Very sloooow. Need to speed up! + //Draw land immediate + + void DrawVBO(); + + vec3 CalcCrossing(vec3 LineFrom, vec3 LineTo); + //Calculate intersection (segment LiteFrom -> LineTo and the land) + + vec3 CalcVerticalCrossing(const vec3& pos); + //Calculate land height on (pos.x, pos.y) + + float CalcVerticalCrossingFast(const vec3& pos); + //Calculate approximate land height on (pos.x, pos.y) + + bool IsOnTheLand(const vec3& pos); + + void RecalcNormalVectors(); + //Recalc normal vectors - must be called after land is modified + + void MoveLandUp(vec3 CursorPos, float R);//NIU + //Move land up under cursor + + void MoveLandDown(vec3 CursorPos, float R);//NIU + //Move land down under cursor + + void SmoothLand(vec3 CursorPos, float R);//NIU + //Smooth land up under cursor + + void TextureLand(vec3 CursorPos, float R, int ltype);//NIU + //Set land type under cursor + + void Scale(float s); + + void Scale(vec3 s); + + void Move(const vec3& v); + + int GetWidth(); + + int GetHeight(); + + float* GetTriangleMatrix(); + //Use it for physics only! +}; + +} //namespace SE + +#endif diff --git a/include/SmartValueManager/SmartValueManager.h b/include/SmartValueManager/SmartValueManager.h new file mode 100644 index 0000000..fc8baf8 --- /dev/null +++ b/include/SmartValueManager/SmartValueManager.h @@ -0,0 +1,56 @@ +#ifndef SMART_VALUE_MANAGER_H_INCLUDED +#define SMART_VALUE_MANAGER_H_INCLUDED + +#include "include/Utils/Utils.h" + +#pragma warning(disable: 4503) //ololo, DisctionariesMap expands into looong boolshit + +namespace SE +{ + +typedef boost::variant< + std::shared_ptr>, + std::shared_ptr>, + std::shared_ptr>, + std::shared_ptr>, + std::shared_ptr>, + std::shared_ptr>, + std::shared_ptr>> TSmartValue; + + +class TSmartValueManager : public TSerializeInterface +{ +protected: + + std::map> DisctionariesMap; + +public: + + TSmartValue& GetSmartValue(const std::string& dictName, const std::string& valueName); + + template + TYPENAME GetImmediateValue(const std::string& dictName, const std::string& valueName) + { + return (*boost::get>>(GetSmartValue(dictName, valueName)))(); + } + + template + void SetImmediateValue(const std::string& dictName, const std::string& valueName, TYPENAME value) + { + *boost::get>>(GetSmartValue(dictName, valueName)) = value; + } + + template + boost::signal& GetSignal(const std::string& dictName, const std::string& valueName) + { + return boost::get>>(GetSmartValue(dictName, valueName))->OnVarChanged; + } + + virtual void Serialize(boost::property_tree::ptree& propertyTree); + +}; + + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/SoundManager/SoundManagerAndroid.h b/include/SoundManager/SoundManagerAndroid.h new file mode 100644 index 0000000..4102d05 --- /dev/null +++ b/include/SoundManager/SoundManagerAndroid.h @@ -0,0 +1,33 @@ +#ifndef SOUND_MANAGER_ANDROID_INCLUDED +#define SOUND_MANAGER_ANDROID_INCLUDED + +#include "include/Utils/DataTypes/DataTypes.h" +#include "include/SoundManager/SoundManagerInterface.h" + +namespace SE +{ + +class TSoundManagerAndroid : public TSoundManagerInterface +{ +public: + TSoundManagerAndroid(); + ~TSoundManagerAndroid(); + + + virtual void LoadSound(const std::string& soundFileName); + virtual void PlaySound(const std::string& soundName); + + virtual void LoadMusic(const std::string& musicFileName); + virtual void PlayMusic(const std::string& musicName); + virtual void PlayMusicLooped(const std::string& musicName); + virtual void StopMusic(const std::string& musicName); + + +protected: + +}; + + +#endif + +} //namespace SE \ No newline at end of file diff --git a/include/SoundManager/SoundManagerDataTypes.h b/include/SoundManager/SoundManagerDataTypes.h new file mode 100644 index 0000000..ae300df --- /dev/null +++ b/include/SoundManager/SoundManagerDataTypes.h @@ -0,0 +1,105 @@ +#ifndef SOUND_MANAGER_DATA_TYPES_H_INCLUDED +#define SOUND_MANAGER_DATA_TYPES_H_INCLUDED + +#ifndef NOSOUND + + +#ifdef TARGET_ANDROID +#include +#include +#endif + +#include "boost/thread.hpp" +#include "boost/smart_ptr.hpp" +#include "boost/bind.hpp" + +#include + +#include + + +#include "vorbis/codec.h" +#include "vorbis/vorbisfile.h" + + +namespace SE +{ + +typedef boost::shared_array TByteArrPtr; + + + +struct TBasicWAVEHeader +{ + char Riff[4];//'RIFF' + unsigned int RiffSize; + char Wave[4];//'WAVE' + char Fmt[4];//'fmt ' + unsigned int FmtSize; + unsigned short Format; + unsigned short Channels; + unsigned int SamplesPerSec; + unsigned int BytesPerSec; + unsigned short BlockAlign; + unsigned short BitsPerSample; + char Data[4];//'data' + unsigned int DataSize; +}; + + + + +struct TOggCallbackFileBuffer +{ + size_t FileSize; + size_t FilePos; + TByteArrPtr FileData; + + TOggCallbackFileBuffer(const TByteArrPtr& fileData, size_t fileSize) + : FileData(fileData) + , FileSize(fileSize) + , FilePos(0) + { + } + + TOggCallbackFileBuffer() + : FileData(NULL) //dummy + , FileSize(0) + , FilePos(0) + { + } + + TOggCallbackFileBuffer(const TOggCallbackFileBuffer& copyFrom) + { + FileSize = copyFrom.FileSize; + FilePos = copyFrom.FilePos; + FileData = copyFrom.FileData; + } + + TOggCallbackFileBuffer& operator=(const TOggCallbackFileBuffer& copyFrom) + { + if (©From == this) + { + return *this; + } + + FileSize = copyFrom.FileSize; + FilePos = copyFrom.FilePos; + FileData = copyFrom.FileData; + + return *this; + } + +}; + + + + +extern ov_callbacks OggCallbacks; + +} //namespace SE + +#endif + + +#endif diff --git a/include/SoundManager/SoundManagerInterface.h b/include/SoundManager/SoundManagerInterface.h new file mode 100644 index 0000000..d76a62c --- /dev/null +++ b/include/SoundManager/SoundManagerInterface.h @@ -0,0 +1,34 @@ +#ifndef SOUND_MANAGER_INTERFACE_H_INCLUDED +#define SOUND_MANAGER_INTERFACE_H_INCLUDED +#include "include/Utils/DataTypes/DataTypes.h" + +namespace SE +{ + +class TSoundManagerInterface +{ +public: + + virtual void LoadSound(const std::string& soundFileName) = 0; + virtual void PlaySound(const std::string& soundName) = 0; + + virtual void LoadMusic(const std::string& musicFileName) = 0; + virtual void PlayMusic(const std::string& musicName) = 0; + virtual void PlayMusicLooped(const std::string& musicName) = 0; + virtual void StopMusic(const std::string& musicName) = 0; + + virtual void StopAllMusic() { } + + virtual void TryStopAndPlayMusicLooped(const std::string& musicName) { } + + virtual void Update(cardinal dt) { }; + + +protected: + +}; + +} //namespace SE + + +#endif \ No newline at end of file diff --git a/include/SoundManager/SoundManagerIos.h b/include/SoundManager/SoundManagerIos.h new file mode 100644 index 0000000..4f86361 --- /dev/null +++ b/include/SoundManager/SoundManagerIos.h @@ -0,0 +1,39 @@ +// +// SoundManagerIos.h +// Halibut Engine +// +// Created by vvv ооо on 21.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#ifndef SOUND_MANAGER_IOS_H_INCLUDED +#define SOUND_MANAGER_IOS_H_INCLUDED + +#include "include/SoundManager/SoundManagerInterface.h" + +namespace SE +{ + +class TSoundManagerIos : public TSoundManagerInterface +{ +public: + + TSoundManagerIos(); + ~TSoundManagerIos(); + + virtual void LoadSound(const std::string& soundFileName); + virtual void PlaySound(const std::string& soundName); + + void LoadMusicLooped(const std::string& musicFileName); + virtual void LoadMusic(const std::string& musicFileName); + virtual void PlayMusic(const std::string& musicName); + virtual void PlayMusicLooped(const std::string& musicName); + virtual void StopMusic(const std::string& musicName); + +}; + + +} //namespace SE + + +#endif diff --git a/include/SoundManager/SoundManagerWindows.h b/include/SoundManager/SoundManagerWindows.h new file mode 100644 index 0000000..3396e35 --- /dev/null +++ b/include/SoundManager/SoundManagerWindows.h @@ -0,0 +1,248 @@ +#ifndef SOUND_MANAGER_WINDOWS_H_INCLUDED +#define SOUND_MANAGER_WINDOWS_H_INCLUDED + +#include "include/SoundManager/SoundManagerDataTypes.h" +#include "include/SoundManager/SoundManagerInterface.h" +#include "include/Utils/Utils.h" + + +#ifndef NOSOUND +#include "audiodefs.h" +#include "dsound.h" + +namespace SE +{ + + +const cardinal CONST_DIRECTSOUND_BUFFER_SIZE = 4096*16; + +const cardinal CONST_BPS = 2; + +struct TDirectSoundStruct +{ + IDirectSoundBuffer8* soundBuffer; + + TDirectSoundStruct() : soundBuffer(NULL) { } + + ~TDirectSoundStruct() + { + if (soundBuffer != NULL) + { + soundBuffer->Release(); + soundBuffer = NULL; + } + } +}; + + +struct TWaveFile +{ + TBasicWAVEHeader WaveHeader; + TByteArrPtr WaveData; + cardinal WaveDataCursor; +}; + + +TWaveFile OggSoundFromFile(const std::string& fileName); +TWaveFile LoadWaveFile(const std::string& fileName); + +DSBUFFERDESC FillPrimaryWaveBufferDescription(); + +WAVEFORMATEX FillPrimaryWaveFormat(cardinal samplesPerSec); + +DSBUFFERDESC FillSecondaryWaveBufferDescription(cardinal bufferSize, WAVEFORMATEX* pWaveFormat); + +WAVEFORMATEX FillSecondaryWaveFormat(cardinal bufferSize); + + +class TMusicDataAccessInterface +{ +public: + + TMusicDataAccessInterface() : goneOverEnd(false) { } + +protected: + + bool goneOverEnd; + + void ResetDataCursor(); + + virtual int InnerReadDataToBuffer(char* buffer, int size, int& bytesRead) = 0; + + virtual void InnerResetDataCursor() = 0; + + virtual void LoadSoundData(const std::string& fileName) = 0; + + virtual void ClearSoundData() = 0; + + virtual bool CheckIfSoundIsOver() = 0; + + virtual cardinal GetSamplesPerSec() = 0; + + void ReadDataToBuffer_Looped(char* buffer, int size); + + int ReadDataToBuffer(char* buffer, int size); + +}; + + +class TMusicStreamAncestor : public TMusicDataAccessInterface +{ +public: + + TMusicStreamAncestor(); + ~TMusicStreamAncestor(); + + void Load(const std::string& musicFileName); + void Clear(); + + void Update(); + + void Play(); + void PlayLooped(); + + void Stop(); + +protected: + void InnerPlay(); + void InitialFillBuffer(); + + + bool IsPlaying; + bool Looped; + bool IsLoaded; + + TDirectSoundStruct DirectSoundBuffer; + + cardinal BufferCursorPos; + cardinal PlayCursorPos; + + cardinal TotalPlayCursorPos; + +}; + + + +class TWaveStream : public TMusicStreamAncestor +{ +public: + + TWaveStream(); + ~TWaveStream(); + +protected: + + virtual int InnerReadDataToBuffer(char* buffer, int size, int& bytesRead); + virtual void InnerResetDataCursor(); + virtual void ClearSoundData(); + virtual void LoadSoundData(const std::string& fileName); + virtual bool CheckIfSoundIsOver(); + + virtual cardinal GetSamplesPerSec(); + + TWaveFile MusicFile; + +}; + + +class TOggMusicStream : public TMusicStreamAncestor +{ +public: + + TOggMusicStream(); + ~TOggMusicStream(); + +protected: + + bool IsInited; + + virtual int InnerReadDataToBuffer(char* buffer, int size, int& bytesRead); + virtual void InnerResetDataCursor(); + virtual void ClearSoundData(); + virtual void LoadSoundData(const std::string& fileName); + virtual bool CheckIfSoundIsOver(); + virtual cardinal GetSamplesPerSec(); + + TOggCallbackFileBuffer FileBuffer; + OggVorbis_File OggFileData; + vorbis_info* VorbisInfo; + +}; + + + + + +DWORD GetMaxWriteSize(cardinal m_cbBufOffset, cardinal m_cbBufSize, TDirectSoundStruct& soundStruct); + +void FillMemoryWithZero(char* bufferPtr, cardinal bufferSize); + + +class TSoundManagerWindows : public TSoundManagerInterface +{ +private: + + std::map SoundMap; + std::map > StreamMap; + + void InitDirectSound(); + void ShutdownDirectSound(); + + + +public: + TSoundManagerWindows(); + ~TSoundManagerWindows(); + + virtual void LoadSound(const std::string& soundFileName); + virtual void PlaySound(const std::string& soundName); + + virtual void LoadMusic(const std::string& musicFileName); + virtual void PlayMusic(const std::string& musicName); + virtual void PlayMusicLooped(const std::string& musicName); + virtual void StopMusic(const std::string& musicName); + + virtual void StopAllMusic(); + virtual void TryStopAndPlayMusicLooped(const std::string& musicName); + + virtual void Update(cardinal dt); + + IDirectSoundBuffer8* CreateDirectSound8InterfaceBuffer(cardinal dataSize, cardinal samplesPerSec); + + IDirectSound8* DirectSound; + IDirectSoundBuffer* PrimaryBuffer; + +}; + +} //namespace SE + +#else + +namespace SE +{ + + +//NOSOUND version - just dummy +class TSoundManagerWindows : public TSoundManagerInterface +{ +private: + +public: + + virtual void LoadSound(const std::string& soundFileName) { } + virtual void PlaySound(const std::string& soundName) { } + + virtual void LoadMusic(const std::string& musicFileName) { } + virtual void PlayMusic(const std::string& musicName) { } + virtual void PlayMusicLooped(const std::string& musicName) { } + virtual void StopMusic(const std::string& musicName) { } + +}; + + +} //namespace SE + + +#endif + +#endif \ No newline at end of file diff --git a/include/TextureManager/SalmonTexture.h b/include/TextureManager/SalmonTexture.h new file mode 100644 index 0000000..ff519a5 --- /dev/null +++ b/include/TextureManager/SalmonTexture.h @@ -0,0 +1,106 @@ +#pragma once + +/* +This code contains texture manager +*/ + +#ifdef TARGET_WIN32 + #include "include/OpenGlExt/OpenGlExt.h" +#endif + +#ifdef TARGET_ANDROID + #include + #include +#endif + + +#include "include/Utils/Utils.h" +#include "include/Utils/PngHelper.h" +#include "include/ScriptManager/ScriptManager.h" + +namespace SE +{ + + +struct TTextureInfo +{ + cardinal Width; + cardinal Height; + cardinal TexID; + cardinal RefCount; +}; + + +struct TTextureData +{ + cardinal Width; + cardinal Height; + char Format[8]; + cardinal DataSize; + boost::shared_array Data; +}; + +typedef std::map > TTextureMap; + + +class TTextureListClass : public TSerializeInterface, public TFunctionBinderInterface +{ +protected: + + TTextureMap TexMap; + + std::map> CreateFunctionMap; + std::map> AddFunctionMap; + + void NormalizeTexData(TTextureData& texData); + + bool CreateTexDataFromBmp24(const std::string& filename, TTextureData& texData); + bool CreateTexDataFromBmp32(const std::string& filename, TTextureData& texData); + bool CreateTexDataFromTga(const std::string& filename, TTextureData& texData); + bool CreateTexDataFromPng(const std::string& filename, TTextureData& texData); + cardinal AddTextureBmp24Data(const TTextureData& texData); + cardinal AddTextureBmp32Data(const TTextureData& texData); + + cardinal AddCubemapTextureBmp24Data(TTextureData* texData); + //cardinal AddCubemapTextureBmp32Data(TTextureData* texData); Not implemented yet + +public: + TTextureListClass(); + ~TTextureListClass(); + + void Clear(); + + virtual void Serialize(boost::property_tree::ptree& propertyTree); + + cardinal operator[](const std::string& s) + { + if (TexMap.count(s) != 0) + return TexMap[s].TexID; + else + return 0; + } + + cardinal GetTextureHeight(const std::string& texName); + cardinal GetTextureWidth(const std::string& texName); + + cardinal AddTextureDirectly(const std::string& filename, std::string texName = ""); //Loads texture directly from this file or fails + cardinal AddTexture(const std::string& fileName, std::string texName = ""); //Adds path to resources to the filename then call previous one + cardinal AddTextureFromUserdata(const std::string& fileName, std::string texName = ""); //Same as above but checks if file is created in user data + + cardinal AddCubemapTexture(std::string filename[6]); // "posx.bmp","negx.bmp","posy.bmp","negy.bmp","posz.bmp","negz.bmp" + + + cardinal AddEmptyTexture(const std::string& texName, cardinal width, cardinal height); + cardinal AddEmptyCubemapTexture(const std::string& texName, cardinal width, cardinal height); + cardinal AddDepthTexture(const std::string& texName, cardinal width, cardinal height); + void DeleteTexture(const std::string& texName); + void DeleteTexture(cardinal texID); + + void PrintTextureList(); + + virtual void BindFunctions(); + + void SaveTexDataToPlainBmpToUserData(const std::string& fileName, TTextureData texData); +}; + +} //namespace SE diff --git a/include/Utils/BindableVar.h b/include/Utils/BindableVar.h new file mode 100644 index 0000000..c7c6213 --- /dev/null +++ b/include/Utils/BindableVar.h @@ -0,0 +1,53 @@ +#ifndef BINDABLE_VAR_H_INCLUDED +#define BINDABLE_VAR_H_INCLUDED + +#include "boost/signal.hpp" +#include "boost/variant.hpp" + +namespace SE +{ + +//Must be stored in shared_ptr: + +template +class TBindableVar +{ +protected: + TYPENAME Variable; + +public: + + boost::signal OnVarChanged; + + TBindableVar() + { + } + + TBindableVar(const TYPENAME&& var) + : Variable(var) + { + } + + operator TYPENAME() + { + return Variable; + } + + TYPENAME operator()() + { + return Variable; + } + + TBindableVar& operator=(const TYPENAME& var) + { + Variable = var; + OnVarChanged(Variable); + return *this; + } + +}; + + +} //namespace SE + +#endif diff --git a/include/Utils/Console/console.h b/include/Utils/Console/console.h new file mode 100644 index 0000000..af4c035 --- /dev/null +++ b/include/Utils/Console/console.h @@ -0,0 +1,132 @@ +#ifndef CONSOLE_H_INCLUDED +#define CONSOLE_H_INCLUDED + +/* +This code contains console/log to work with + +Use global variable Console like that: + +*Console<<"something"< +#include + +#ifdef TARGET_WIN32 +#include +#endif +#ifdef TARGET_ANDROID +#include +#include + +#include "boost/thread.hpp" +#endif + + +#include "include/Render/RenderMisc.h" + + +namespace SE +{ + +extern const std::string CONST_CONSOLE_TEX_NAME; + + + +class TSimpleConsole +{ +protected: + std::string History; + + std::string TextSavedInTriangleList; + + std::shared_ptr HistoryTriangeList; + + + +public: + std::string ConsoleInput; + cardinal ConsoleCursor; + std::vector InputHistory; + cardinal InputHistoryCursor; + + TSimpleConsole() : History(""), TextSavedInTriangleList(""), ConsoleCursor(0), InputHistoryCursor(0) { } + + virtual ~TSimpleConsole() { } + + void Clear() { History = ""; } + + void CutHistory(); + + virtual std::string GetHistory(); + + virtual void Draw(); +}; + + +#ifdef TARGET_WIN32 + +class TFileConsole : public TSimpleConsole +{ +protected: + std::string filename; + std::ofstream f; +public: + TFileConsole(); + + TFileConsole(const std::string& Afilename); + + ~TFileConsole(); + + TFileConsole& operator<<(const std::string& s); + + void PrintImmediate(const std::string& s); +}; + +#endif + + +#ifdef TARGET_ANDROID + +class TJavaConsole : public TSimpleConsole +{ +protected: + boost::mutex ConsoleMutex; + std::string AppDir; + std::string LogFilename; +public: + + TJavaConsole(); + + TJavaConsole& operator<<(const std::string& s); + + void PrintImmediate(const std::string& s); +}; + +#endif + + +#ifdef TARGET_IOS + +class TIosConsole : public TSimpleConsole +{ +protected: +public: + TIosConsole(); + + //TFileConsole(const std::string& Afilename); + + ~TIosConsole(); + + TIosConsole& operator<<(const std::string& s); + + void PrintImmediate(const std::string& s); +}; + + +#endif + +} //namespace SE + +#endif + diff --git a/include/Utils/DataTypes/DataTypes.h b/include/Utils/DataTypes/DataTypes.h new file mode 100644 index 0000000..dbd3c55 --- /dev/null +++ b/include/Utils/DataTypes/DataTypes.h @@ -0,0 +1,201 @@ +#ifndef DATA_TYPES_H_INCLUDED +#define DATA_TYPES_H_INCLUDED + +/* +This code contains additional data types and some const values to use +*/ + +#include +#include +#include +#include +#include "boost/lexical_cast.hpp" + +#include "NewDataTypes.h" + +namespace SE +{ + +typedef unsigned int cardinal; +typedef unsigned short int word; +typedef unsigned char byte; + +typedef cardinal* pcardinal; + +//Use mat4 to store projection/modelview matrices (i.e. for shadow mapping) +struct mat4 +{ + float m[16]; +}; + +struct TSmpTriangle +{ + vec3 p[3]; + vec3 v; + vec3 w; + vec3 n; +}; + + +const float pi = 3.14159265359f; + +const float CONST_EPSILON = 0.00001f; + +const float WhiteColor[4] = {1.0f, 1.0f, 1.0f, 1.0f}; +const float RedColor[4] = {1.0f, 0.0f, 0.0f, 1.0f}; +const float NoColor[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + +const mat3 IdentityMatrix(vec3(1.0f, 0.0f, 0.0f), vec3(0.0f, 1.0f, 0.0f), vec3(0.0f, 0.0f, 1.0f)); + +const mat4 IdentityMatrix4 = + { 1.f, 0.f, 0.f, 0.f, + 0.f, 1.f, 0.f, 0.f, + 0.f, 0.f, 1.f, 0.f, + 0.f, 0.f, 0.f, 1.f }; + + +const vec3 ZeroVec3(0.0f, 0.0f, 0.0f); + +const vec4 ZeroQuat(0.0f, 0.0f, 0.0f, 1.0f); + +const std::string fendl="\x0D\x0A"; //Windows-style, for files +const std::string endl="\n"; + +vec4 InverseQuat(const vec4& q); + +//For shadow mapping or for OpenGL ES 2.0 +mat4 InverseModelViewMatrix(const mat4& m); +mat4 SetToNormalMatrix(const mat4& m); +mat4 MakeOrthoMatrix(float width, float height); +mat4 MakeFrustumMatrix(float left, float right, float bottom, float top, float nearVal, float farVal); +mat4 MakePerspectiveMatrix(float angle, float aspect, float zNear, float zFar); + +mat4 MultMatrixMatrix(const mat4& m1, const mat4& m2); + +bool IsFloatEqual(float a, float b); + +int LineCrossTriangle(const vec3& a, const vec3& b, const TSmpTriangle& tr); + +int LineCrossTriangle(const vec3& a, const vec3& b, const TSmpTriangle& tr, vec3& CrossPoint); + +int PointInTriangle(const vec3& q, const TSmpTriangle& tr); + + +template +inline std::string tostr(T i) +{ + return boost::lexical_cast(i); +} + +inline int toint(const char* str) +{ + return boost::lexical_cast(str); +} + +inline int toint(const std::string& str) +{ + return boost::lexical_cast(str); +} +//#ifndef TARGET_WIN32 //Already defined in windows.h + +template +inline T min(T a, T b) +{ + return a < b ? a : b; +} + +template +inline T max(T a, T b) +{ + return a > b ? a : b; +} + +//#endif + +template +inline T clamp(T a, T c_from, T c_to) +{ + if (a < c_from) + { + return c_from; + } + + if (a > c_to) + { + return c_to; + } + + return a; +} + +template +inline T sign(T a) +{ + if (a == 0) + { + return 0; + } + + if (a < 0) + { + return -1; + } + + + return 1; +} + + +float roundf(float r); + +template +T InterpolateLinear(T a, T b, float t) +{ + return a + (b-a)*t; +} + +template +T InterpolateSqr(T a, T b, float t) +{ + return a + (b-a)*t*t; +} + + +template +T InterpolateSqrt(T a, T b, float t) +{ + return a + (b-a)*sqrtf(t); +} + +template +bool IsPower2(T x) +{ + return ( (x > 0) && ((x & (x - 1)) == 0) ); +} + +cardinal GetGreaterPower2(cardinal x); + +vec2 StringToVec2(std::string str); +vec3 StringToVec3(std::string str); +vec4 StringToVec4(std::string str); + +// ================================================ +// ========== wide strings and UTF8 strings ======= +// ================================================ + + +void utf8toWStr(std::wstring& dest, const std::string& src); + +void wstrToUtf8(std::string& dest, const std::wstring& src); + +std::string wstrToUtf8(const std::wstring& str); + +std::wstring utf8toWStr(const std::string& str); + +std::ostream& operator<<(std::ostream& f, const std::wstring& s); + +std::istream& operator>>(std::istream& f, std::wstring& s); + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/Utils/DataTypes/NewDataTypes.h b/include/Utils/DataTypes/NewDataTypes.h new file mode 100644 index 0000000..0e60046 --- /dev/null +++ b/include/Utils/DataTypes/NewDataTypes.h @@ -0,0 +1,1023 @@ +#ifndef NEW_DATA_TYPES_H_INCLUDED +#define NEW_DATA_TYPES_H_INCLUDED + +#include + +namespace SE +{ + +//Find this in DataTypes.h +bool IsFloatEqual(float a, float b); + + +template +class tvec4; + + +template +class tmat3; + +template +class tvec2 +{ +public: + TYPENAME v[2]; + tvec2() { v[0] = 0; v[1] = 0; } + + template + tvec2(TYPENAME1 x, TYPENAME2 y) { v[0] = static_cast(x); v[1] = static_cast(y); } + + tvec2& operator=(const tvec2& vc); + bool operator==(const tvec2& vc) const; + bool operator!=(const tvec2& vc) const; + tvec2& operator+=(const tvec2& vc); + tvec2 operator+(const tvec2& a) const; + tvec2& operator-=(const tvec2& vc); + tvec2 operator-(const tvec2& a) const; + tvec2& operator-(); + tvec2& operator*=(TYPENAME c); +}; + +typedef tvec2 vec2; +typedef tvec2 ivec2; + + +vec2 Normalize(const vec2& a); + + +float Length(const vec2& a); + + +float DotProduct(const vec2& a,const vec2& b); + + +template +class tvec3 +{ +public: + TYPENAME1 v[3]; + + tvec3(); + tvec3(TYPENAME1 x, TYPENAME1 y, TYPENAME1 z); + tvec3(const tvec2& vc, TYPENAME1 z); + tvec3(const tvec3& vc); + tvec3(const tvec4& vc); + + bool operator==(const tvec3& vc) const; + bool operator!=(const tvec3& vc) const; + tvec3& operator=(const tvec3& vc); + tvec3& operator+=(const tvec3& vc); + tvec3& operator-=(const tvec3& vc); + tvec3 operator+(const tvec3& a) const; + tvec3 operator-(const tvec3& a) const; + tvec3& operator-(); + tvec3& operator*=(TYPENAME1 c); + tvec3 operator*(const tmat3& mt) const; //MultRowMatrix() +}; + +typedef tvec3 vec3; + + +float DotProduct(const vec3& a,const vec3& b); +vec3 CrossProduct(const vec3& a,const vec3& b); +vec3 Normalize(const vec3& a); +float Length(const vec3& a); + +template +class tvec4 +{ +public: + TYPENAME1 v[4]; + + tvec4(); + tvec4(TYPENAME1 x, TYPENAME1 y, TYPENAME1 z, TYPENAME1 w); + tvec4(const tvec3& vc); + tvec4(const tvec4& vc); + tvec4(const tmat3& m); + + bool operator==(const tvec4& vc) const; + bool operator!=(const tvec4& vc) const; + tvec4& operator=(const tvec4& vc); + tvec4& operator+=(const tvec4& vc); + tvec4& operator-=(const tvec4& vc); + const tvec4 operator+(const tvec4& a) const; + const tvec4 operator-(const tvec4& a) const; + //vec4& operator-(); not so obvious for quaternion :( + tvec4& operator*=(TYPENAME1 c); + + tvec4& operator*=(const tvec4& q); + tvec4 operator*(const tvec4& q) const; +}; + + +typedef tvec4 vec4; + + +vec4 InverseQuat(const vec4& q); + + +template +class tmat2 +{ +public: + TYPENAME1 m[4]; + + tmat2(); + tmat2(TYPENAME1 alpha); + tmat2(const tmat2& mt); + + bool operator==(const tmat2& mt) const; + bool operator!=(const tmat2& mt) const; + tmat2& operator=(const tmat2& mt); + tmat2& operator*=(const tmat2& mt); + tmat2 operator*(const tmat2& mt); + tvec2 operator*(const tvec2& vc) const; //MultMatrixCol() + +}; + +typedef tmat2 mat2; + + + +template +class tmat3 +{ +public: + TYPENAME1 m[9]; + + tmat3(); + tmat3(const tvec3& col1, const tvec3& col2, const tvec3& col3); + tmat3(const tmat3& mt); + tmat3(const tvec4& q); + + bool operator==(const tmat3& mt) const; + bool operator!=(const tmat3& mt) const; + tmat3& operator=(const tmat3& mt); + tmat3& operator*=(const tmat3& mt); + tmat3 operator*(const tmat3& mt); + tvec3 operator*(const tvec3& vc) const; //MultMatrixCol() + +}; + +typedef tmat3 mat3; + + + + +mat3 TransposeMatrix(const mat3& m); +mat3 InverseMatrix(const mat3& m); + +//Outside: +inline vec2 operator*(const vec2& a, float c) +{ + vec2 r; + r.v[0] = a.v[0]*c; + r.v[1] = a.v[1]*c; + return r; +} + +inline vec2 operator*(float c, const vec2& a) +{ + return a*c; +} + +inline vec3 operator*(const vec3& a, float c) +{ + vec3 r; + r.v[0] = a.v[0]*c; + r.v[1] = a.v[1]*c; + r.v[2] = a.v[2]*c; + return r; +} + +inline vec3 operator*(float c, const vec3& a) +{ + return a*c; +} + +inline vec4 operator*(const vec4& a, float c) +{ + vec4 r; + r.v[0] = a.v[0]*c; + r.v[1] = a.v[1]*c; + r.v[2] = a.v[2]*c; + r.v[3] = a.v[3]*c; + return r; +} + +inline vec4 operator*(float c,const vec4& a) +{ + return a*c; +} + + + + + +//============= vec2 ================ + +template +inline tvec2& tvec2::operator=(const tvec2& vc) +{ + //Self-assignment is ok here + v[0] = vc.v[0]; + v[1] = vc.v[1]; + + return *this; +} + +template +inline bool tvec2::operator==(const tvec2& vc) const +{ + if (IsFloatEqual(static_cast(v[0]), static_cast(vc.v[0])) && + IsFloatEqual(static_cast(v[1]), static_cast(vc.v[1]))) + { + return true; + } + + return false; +} + +template +inline bool tvec2::operator!=(const tvec2& vc) const +{ + return !(*this == vc); +} + +template +inline tvec2& tvec2::operator+=(const tvec2& vc) +{ + v[0] += vc.v[0]; + v[1] += vc.v[1]; + + return *this; +} + +template +inline tvec2 tvec2::operator+(const tvec2& a) const +{ + tvec2 r = *this; + r += a; + return r; +} + +template +inline tvec2& tvec2::operator-=(const tvec2& vc) +{ + v[0] -= vc.v[0]; + v[1] -= vc.v[1]; + + return *this; +} + +template +inline tvec2 tvec2::operator-(const tvec2& a) const +{ + tvec2 r = *this; + r -= a; + return r; +} + +template +inline tvec2& tvec2::operator-() +{ + v[0] = -v[0]; + v[1] = -v[1]; + + return *this; +} + +template +inline tvec2& tvec2::operator*=(TYPENAME c) +{ + v[0] *= c; + v[1] *= c; + + return *this; +} + + +inline vec2 Normalize(const vec2& a) +{ + vec2 r; + float d = a.v[0]*a.v[0]+a.v[1]*a.v[1]; + if (IsFloatEqual(d, 0.0f)) + { + r.v[0] = 0.0f; + r.v[1] = 0.0f; + + return r; + } + else + { + d = sqrtf(d); + + r.v[0] = a.v[0]/d; + r.v[1] = a.v[1]/d; + + return r; + } +} + +inline float Length(const vec2& a) +{ + return sqrtf(a.v[0]*a.v[0] + a.v[1]*a.v[1]); +} + +inline float DotProduct(const vec2& a,const vec2& b) +{ + return a.v[0]*b.v[0] + a.v[1]*b.v[1]; +} + +//============= vec3 ================ + + +template +inline tvec3::tvec3() +{ + v[0] = 0; + v[1] = 0; + v[2] = 0; +} + +template +inline tvec3::tvec3(TYPENAME1 x, TYPENAME1 y, TYPENAME1 z) +{ + v[0] = x; + v[1] = y; + v[2] = z; +} + +template +inline tvec3::tvec3(const tvec2& vc, TYPENAME1 z) +{ + v[0] = vc.v[0]; + v[1] = vc.v[1]; + v[2] = z; +} + +template +inline tvec3::tvec3(const tvec3& vc) +{ + v[0] = vc.v[0]; + v[1] = vc.v[1]; + v[2] = vc.v[2]; +} + +template +inline tvec3::tvec3(const tvec4& vc) +{ + v[0] = vc.v[0]; + v[1] = vc.v[1]; + v[2] = vc.v[2]; +} + +template +inline bool tvec3::operator==(const tvec3& vc) const +{ + if (IsFloatEqual(static_cast(v[0]), static_cast(vc.v[0])) && + IsFloatEqual(static_cast(v[1]), static_cast(vc.v[1])) && + IsFloatEqual(static_cast(v[2]), static_cast(vc.v[2]))) + { + return true; + } + + return false; +} + +template +inline bool tvec3::operator!=(const tvec3& vc) const +{ + return !(*this == vc); +} + + +template +inline tvec3& tvec3::operator=(const tvec3& vc) +{ + //Self-assignment is ok here + v[0] = vc.v[0]; + v[1] = vc.v[1]; + v[2] = vc.v[2]; + + return *this; +} + +template +inline tvec3& tvec3::operator+=(const tvec3& vc) +{ + v[0] += vc.v[0]; + v[1] += vc.v[1]; + v[2] += vc.v[2]; + + return *this; +} + +template +inline tvec3& tvec3::operator-=(const tvec3& vc) +{ + v[0] -= vc.v[0]; + v[1] -= vc.v[1]; + v[2] -= vc.v[2]; + + return *this; +} + +template +inline tvec3 tvec3::operator+(const tvec3& a) const +{ + tvec3 r = *this; + r += a; + return r; +} + +template +inline tvec3 tvec3::operator-(const tvec3& a) const +{ + tvec3 r = *this; + r -= a; + return r; +} + +template +inline tvec3& tvec3::operator-() +{ + v[0] = -v[0]; + v[1] = -v[1]; + v[2] = -v[2]; + + return *this; +} + +template +inline tvec3& tvec3::operator*=(TYPENAME1 c) +{ + v[0] *= c; + v[1] *= c; + v[2] *= c; + + return *this; +} + +template +inline tvec3 tvec3::operator*(const tmat3& mt) const +{ + tvec3 r = *this; + + r.v[0] = v[0]*mt.m[0] + v[1]*mt.m[1] + v[2]*mt.m[2]; + r.v[1] = v[0]*mt.m[3] + v[1]*mt.m[4] + v[2]*mt.m[5]; + r.v[2] = v[0]*mt.m[6] + v[1]*mt.m[7] + v[2]*mt.m[8]; + + return r; +} + +inline float DotProduct(const vec3& a,const vec3& b) +{ + return a.v[0]*b.v[0]+a.v[1]*b.v[1]+a.v[2]*b.v[2]; +} + +inline vec3 CrossProduct(const vec3& a,const vec3& b) +{ + vec3 r; + r.v[0] = a.v[1]*b.v[2] - a.v[2]*b.v[1]; + r.v[1] = a.v[2]*b.v[0] - a.v[0]*b.v[2]; + r.v[2] = a.v[0]*b.v[1] - a.v[1]*b.v[0]; + return r; +} + +inline vec3 Normalize(const vec3& a) +{ + vec3 r; + float d = a.v[0]*a.v[0]+a.v[1]*a.v[1]+a.v[2]*a.v[2]; + if (IsFloatEqual(d,0.0f)) + { + r.v[0] = 0.0f; + r.v[1] = 0.0f; + r.v[2] = 0.0f; + return r; + } + else + { + d = sqrtf(d); + + r.v[0] = a.v[0]/d; + r.v[1] = a.v[1]/d; + r.v[2] = a.v[2]/d; + + return r; + } +} + +inline float Length(const vec3& a) +{ + return sqrtf(a.v[0]*a.v[0] + a.v[1]*a.v[1] + a.v[2]*a.v[2]); +} + + +//============= vec4 ================ + + +template +inline tvec4::tvec4() +{ + v[0] = 0; + v[1] = 0; + v[2] = 0; + v[3] = 1; +} + +template +inline tvec4::tvec4(TYPENAME1 x, TYPENAME1 y, TYPENAME1 z, TYPENAME1 w) +{ + v[0] = x; + v[1] = y; + v[2] = z; + v[3] = w; +} + +template +inline tvec4::tvec4(const tvec4& vc) +{ + v[0] = vc.v[0]; + v[1] = vc.v[1]; + v[2] = vc.v[2]; + v[3] = vc.v[3]; +} + +template +inline tvec4::tvec4(const tvec3& vc) +{ + v[0] = vc.v[0]; + v[1] = vc.v[1]; + v[2] = vc.v[2]; + v[3] = 0.0f; +} + +template +inline tvec4::tvec4(const tmat3& m) +{ + + TYPENAME1 f; + + if (m.m[0] >= m.m[4] && m.m[0] >= m.m[8]) + { + f = sqrtf(1.0f + m.m[0] - m.m[4] - m.m[8]); + if (f != 0) + { + v[3] = (m.m[5] - m.m[7]) / (f + f); + v[0] = f/2; + v[1] = (m.m[3] + m.m[1]) / (f + f); + v[2] = (m.m[6] + m.m[2]) / (f + f); + } + else + { + v[3] = 1; + v[2] = 0; + v[1] = 0; + v[0] = 0; + } + } + + if (m.m[4] >= m.m[0] && m.m[4] >= m.m[8]) + { + f = sqrtf(1.0f + m.m[4] - m.m[0] - m.m[8]); + if (f != 0) + { + v[3] = (m.m[6] - m.m[2]) / (f + f); + v[1] = f/2; + v[0] = (m.m[1] + m.m[3]) / (f + f); + v[2] = (m.m[7] + m.m[5]) / (f + f); + } + else + { + v[3] = 1; + v[2] = 0; + v[1] = 0; + v[0] = 0; + } + } + + if (m.m[8] >= m.m[4] && m.m[8] >= m.m[0]) + { + f = sqrtf(1.0f + m.m[8] - m.m[2]); + if (f != 0) + { + v[3] = (m.m[1] - m.m[3]) / (f + f); + v[2] = f/2; + v[1] = (m.m[5] + m.m[7]) / (f + f); + v[0] = (m.m[6] + m.m[2]) / (f + f); + } + else + { + v[3] = 1; + v[2] = 0; + v[1] = 0; + v[0] = 0; + } + } + +} + +template +inline bool tvec4::operator==(const tvec4& vc) const +{ + if (IsFloatEqual(static_cast(v[0]), static_cast(vc.v[0])) && + IsFloatEqual(static_cast(v[1]), static_cast(vc.v[1])) && + IsFloatEqual(static_cast(v[2]), static_cast(vc.v[2])) && + IsFloatEqual(static_cast(v[3]), static_cast(vc.v[3]))) + { + return true; + } + + return false; +} + +template +inline bool tvec4::operator!=(const tvec4& vc) const +{ + return !(*this == vc); +} + +template +inline tvec4& tvec4::operator=(const tvec4& vc) +{ + //Self-assignment is not actual here... + v[0] = vc.v[0]; + v[1] = vc.v[1]; + v[2] = vc.v[2]; + v[3] = vc.v[3]; + + return *this; +} + +template +inline tvec4& tvec4::operator+=(const tvec4& vc) +{ + v[0] += vc.v[0]; + v[1] += vc.v[1]; + v[2] += vc.v[2]; + v[3] += vc.v[3]; + + return *this; +} + +template +inline tvec4& tvec4::operator-=(const tvec4& vc) +{ + v[0] -= vc.v[0]; + v[1] -= vc.v[1]; + v[2] -= vc.v[2]; + v[3] -= vc.v[3]; + return *this; +} + +template +inline const tvec4 tvec4::operator+(const tvec4& a) const +{ + tvec4 r = *this; + r += a; + return r; +} + +template +inline const tvec4 tvec4::operator-(const tvec4& a) const +{ + tvec4 r = *this; + r -= a; + return r; +} + + +template +inline tvec4& tvec4::operator*=(TYPENAME1 c) +{ + v[0] *= c; + v[1] *= c; + v[2] *= c; + v[3] *= c; + + return *this; +} + +template +inline tvec4& tvec4::operator*=(const tvec4& q) +{ + TYPENAME1 A = (v[3] + v[0]) * (q.v[3] + q.v[0]); + TYPENAME1 B = (v[2] - v[1]) * (q.v[1] - q.v[2]); + TYPENAME1 C = (v[0] - v[3]) * (q.v[1] + q.v[2]); + TYPENAME1 D = (v[1] + v[2]) * (q.v[0] - q.v[3]); + TYPENAME1 E = (v[0] + v[2]) * (q.v[0] + q.v[1]); + TYPENAME1 F = (v[0] - v[2]) * (q.v[0] - q.v[1]); + TYPENAME1 G = (v[3] + v[1]) * (q.v[3] - q.v[2]); + TYPENAME1 H = (v[3] - v[1]) * (q.v[3] + q.v[2]); + + v[0] = A - ( E + F + G + H) * 0.5f; + v[1] =-C + ( E - F + G - H) * 0.5f; + v[2] =-D + ( E - F - G + H) * 0.5f; + v[3] = B + (-E - F + G + H) * 0.5f; + + return *this; +} + +template +inline tvec4 tvec4::operator*(const tvec4& q) const +{ + tvec4 r = *this; + r *= q; + return r; +} + + +inline vec4 InverseQuat(const vec4& q) +{ + float n; + vec4 r; + n = (q.v[0]*q.v[0]+q.v[1]*q.v[1]+q.v[2]*q.v[2]); + + if (n!=0.0f) + { + r.v[0] = -q.v[0] / n; + r.v[1] = -q.v[1] / n; + r.v[2] = -q.v[2] / n; + r.v[3] = q.v[3]; + } + else + { + r.v[0] = 0.0f; + r.v[1] = 0.0f; + r.v[2] = 0.0f; + r.v[3] = 1.0f; + }; + + return r; + +} +//========== mat2 =========== + + +template +inline tmat2::tmat2() +{ + m[0] = 1; + m[1] = 0; + + + m[2] = 0; + m[3] = 1; + +} + +template +inline tmat2::tmat2(TYPENAME1 alpha) +{ + m[0] = cosf(alpha); + m[1] = sinf(alpha); + + m[2] = -sinf(alpha); + m[3] = cosf(alpha); + +} + +template +inline tmat2::tmat2(const tmat2& mt) +{ + m[0] = mt.m[0]; + m[1] = mt.m[1]; + + m[2] = mt.m[2]; + m[3] = mt.m[3]; + +} + +template +inline bool tmat2::operator==(const tmat2& mt) const +{ + if (IsFloatEqual(static_cast(m[0]), static_cast(mt.m[0])) && + IsFloatEqual(static_cast(m[1]), static_cast(mt.m[1])) && + IsFloatEqual(static_cast(m[2]), static_cast(mt.m[2])) && + IsFloatEqual(static_cast(m[3]), static_cast(mt.m[3]))) + { + return true; + } + + return false; +} + +template +inline bool tmat2::operator!=(const tmat2& mt) const +{ + return !(*this == mt); +} + +template +inline tmat2& tmat2::operator=(const tmat2& mt) +{ + //Self-assignment is not actual here.... + m[0] = mt.m[0]; + m[1] = mt.m[1]; + m[2] = mt.m[2]; + m[3] = mt.m[3]; + return *this; +} + +template +inline tmat2& tmat2::operator*=(const tmat2& mt) +{ + tmat2 a(*this); + + m[0] = a.m[0]*mt.m[0] + a.m[2]*mt.m[1]; + m[1] = a.m[1]*mt.m[0] + a.m[3]*mt.m[1]; + m[2] = a.m[0]*mt.m[2] + a.m[2]*mt.m[3]; + m[3] = a.m[1]*mt.m[2] + a.m[3]*mt.m[3]; + + return *this; +} + +template +inline tmat2 tmat2::operator*(const tmat2& mt) +{ + tmat2 r = *this; + r *= mt; + return r; +} + +template +inline tvec2 tmat2::operator*(const tvec2& vc) const +{ + tvec2 r; + r.v[0] = m[0]*vc.v[0] + m[2]*vc.v[1]; + r.v[1] = m[1]*vc.v[0] + m[3]*vc.v[1]; + return r; +} + +//========== mat3 =========== + + +template +inline tmat3::tmat3() +{ + m[0] = 1; + m[1] = 0; + m[2] = 0; + + m[3] = 0; + m[4] = 1; + m[5] = 0; + + m[6] = 0; + m[7] = 0; + m[8] = 1; +} + +template +inline tmat3::tmat3(const tvec3& col1, const tvec3& col2, const tvec3& col3) +{ + m[0] = col1.v[0]; + m[1] = col1.v[1]; + m[2] = col1.v[2]; + + m[3] = col2.v[0]; + m[4] = col2.v[1]; + m[5] = col2.v[2]; + + m[6] = col3.v[0]; + m[7] = col3.v[1]; + m[8] = col3.v[2]; +} + +template +inline tmat3::tmat3(const tmat3& mt) +{ + m[0] = mt.m[0]; + m[1] = mt.m[1]; + m[2] = mt.m[2]; + + m[3] = mt.m[3]; + m[4] = mt.m[4]; + m[5] = mt.m[5]; + + m[6] = mt.m[6]; + m[7] = mt.m[7]; + m[8] = mt.m[8]; +} + +template +inline tmat3::tmat3(const tvec4& q) +{ + TYPENAME1 wx, wy, wz, xx, yy, yz, xy, xz, zz,s,x2,y2,z2; + + s=2.0f/(q.v[0]*q.v[0]+q.v[1]*q.v[1]+q.v[2]*q.v[2]+q.v[3]*q.v[3]); + + + x2=q.v[0]*s; + y2=q.v[1]*s; + z2=q.v[2]*s; + + wx=q.v[3]*x2; wy=q.v[3]*y2; wz=q.v[3]*z2; + xx=q.v[0]*x2; xy=q.v[1]*x2; xz=q.v[2]*x2; + yy=q.v[1]*y2; yz=q.v[2]*y2; + zz=q.v[2]*z2; + + m[0] = 1.0f - (yy + zz); + m[1] = xy + wz; + m[2] = xz - wy; + + m[3] = xy - wz; + m[4] = 1.0f - (xx + zz); + m[5] = yz + wx; + + m[6] = xz + wy; + m[7] = yz - wx; + m[8] = 1.0f - (xx + yy); + +} + +template +inline bool tmat3::operator==(const tmat3& mt) const +{ + if (IsFloatEqual(m[0], mt.m[0]) && + IsFloatEqual(m[1], mt.m[1]) && + IsFloatEqual(m[2], mt.m[2]) && + IsFloatEqual(m[3], mt.m[3]) && + IsFloatEqual(m[4], mt.m[4]) && + IsFloatEqual(m[5], mt.m[5]) && + IsFloatEqual(m[6], mt.m[6]) && + IsFloatEqual(m[7], mt.m[7]) && + IsFloatEqual(m[8], mt.m[8])) + { + return true; + } + + return false; +} + +template +inline bool tmat3::operator!=(const tmat3& mt) const +{ + return !(*this == mt); +} + +template +inline tmat3& tmat3::operator=(const tmat3& mt) +{ + //Self-assignment is not actual here.... + m[0] = mt.m[0]; + m[1] = mt.m[1]; + m[2] = mt.m[2]; + + m[3] = mt.m[3]; + m[4] = mt.m[4]; + m[5] = mt.m[5]; + + m[6] = mt.m[6]; + m[7] = mt.m[7]; + m[8] = mt.m[8]; + + return *this; +} + +template +inline tmat3& tmat3::operator*=(const tmat3& mt) +{ + tmat3 a(*this); + + m[0] = a.m[0]*mt.m[0] + a.m[1]*mt.m[3] + a.m[2]*mt.m[6]; + m[1] = a.m[0]*mt.m[1] + a.m[1]*mt.m[4] + a.m[2]*mt.m[7]; + m[2] = a.m[0]*mt.m[2] + a.m[1]*mt.m[5] + a.m[2]*mt.m[8]; + + m[3] = a.m[3]*mt.m[0] + a.m[4]*mt.m[3] + a.m[5]*mt.m[6]; + m[4] = a.m[3]*mt.m[1] + a.m[4]*mt.m[4] + a.m[5]*mt.m[7]; + m[5] = a.m[3]*mt.m[2] + a.m[4]*mt.m[5] + a.m[5]*mt.m[8]; + + m[6] = a.m[6]*mt.m[0] + a.m[7]*mt.m[3] + a.m[8]*mt.m[6]; + m[7] = a.m[6]*mt.m[1] + a.m[7]*mt.m[4] + a.m[8]*mt.m[7]; + m[8] = a.m[6]*mt.m[2] + a.m[7]*mt.m[5] + a.m[8]*mt.m[8]; + + return *this; +} + +template +inline tmat3 tmat3::operator*(const tmat3& mt) +{ + tmat3 r = *this; + r *= mt; + return r; +} + +template +inline tvec3 tmat3::operator*(const tvec3& vc) const +{ + tvec3 r; + r.v[0] = m[0]*vc.v[0] + m[3]*vc.v[1] + m[6]*vc.v[2]; + r.v[1] = m[1]*vc.v[0] + m[4]*vc.v[1] + m[7]*vc.v[2]; + r.v[2] = m[2]*vc.v[0] + m[5]*vc.v[1] + m[8]*vc.v[2]; + return r; +} + +mat3 TransposeMatrix(const mat3& m); + +mat3 InverseMatrix(const mat3& m); + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/Utils/ErrorTypes/ErrorTypes.h b/include/Utils/ErrorTypes/ErrorTypes.h new file mode 100644 index 0000000..fe898e0 --- /dev/null +++ b/include/Utils/ErrorTypes/ErrorTypes.h @@ -0,0 +1,93 @@ +#ifndef ERROR_TYPES_H_INCLUDED +#define ERROR_TYPES_H_INCLUDED + +/* +This code contains exception types for asserting and log watch +*/ + +#include "include/Utils/Console/Console.h" +#include "include/Utils/DataTypes/DataTypes.h" + +namespace SE +{ + +#ifdef TARGET_WIN32 +extern TFileConsole* Console; +#endif + +#ifdef TARGET_ANDROID +extern TJavaConsole* Console; +#endif + + +#ifdef TARGET_IOS +extern TIosConsole* Console; +#endif + +class ErrorCommon +{ +public: + ErrorCommon() {/* *Console<<"Common error!";*/ } + virtual ~ErrorCommon() { } +}; + +class ErrorToLog : public ErrorCommon +{ +public: + ErrorToLog(const std::string& message) { *Console< +boost::shared_array CreateMemFromFile(const std::string& fileName, cardinal& intCount) +{ + cardinal SIZEOF_TYPENAME = sizeof(TYPENAME); + + FILE * pFile; + + long fSize; + + size_t result; + + TYPENAME* fileData; + + std::string realFileName = fileName; + + + if (fopen_s(&pFile, realFileName.c_str(), "rb" ) != 0) + { + throw ErrorToLog("File not loaded: " + fileName); + } + + // obtain file size: + fseek (pFile , 0 , SEEK_END); + fSize = ftell (pFile); + rewind (pFile); + + fileData = new TYPENAME [fSize % SIZEOF_TYPENAME == 0 ? fSize/SIZEOF_TYPENAME : fSize/SIZEOF_TYPENAME + 1]; + + result = fread (&fileData[0], 1, fSize, pFile); + + if (result != fSize) + { + throw ErrorToLog("File not loaded: " + fileName); + } + + // terminate + fclose (pFile); + + intCount = fSize; + + return boost::shared_array(fileData); + +} +#endif + +#ifdef TARGET_ANDROID + +template +boost::shared_array CreateMemFromFile(const std::string& fileName, cardinal& intCount) +{ + if (std::string(fileName.begin(), fileName.begin() + 5) == "/data") + { + *Console<<"File is in userdata - "+fileName; + + cardinal SIZEOF_TYPENAME = sizeof(TYPENAME); + + FILE * pFile; + + long fSize; + + size_t result; + + TYPENAME* fileData; + + std::string realFileName = fileName; + + pFile = fopen ( realFileName.c_str(), "rb" ); + if (pFile == NULL) + { + throw ErrorToLog("File not loaded: " + fileName); + } + + // obtain file size: + fseek (pFile , 0 , SEEK_END); + fSize = ftell (pFile); + rewind (pFile); + + fileData = new TYPENAME [fSize % SIZEOF_TYPENAME == 0 ? fSize/SIZEOF_TYPENAME : fSize/SIZEOF_TYPENAME + 1]; + + result = fread (&fileData[0], 1, fSize, pFile); + + if (result != fSize) + { + throw ErrorToLog("File not loaded: " + fileName); + } + + // terminate + fclose (pFile); + + intCount = fSize; + + return boost::shared_array(fileData); + } + + *Console<<"File is in resources - "+fileName; + + return JniCreateMemFromFile(fileName, intCount); +} + + +#endif + +#ifdef TARGET_IOS + +template +boost::shared_array CreateMemFromFile(const std::string& fileName, cardinal& intCount) +{ + cardinal SIZEOF_TYPENAME = sizeof(TYPENAME); + + FILE * pFile; + + long fSize; + + size_t result; + + TYPENAME* fileData; + + std::string realFileName = IosGetFileReadPath(fileName); + + pFile = fopen ( realFileName.c_str(), "rb" ); + if (pFile == NULL) + { + throw ErrorToLog("File not loaded: " + fileName); + } + + // obtain file size: + fseek (pFile , 0 , SEEK_END); + fSize = ftell (pFile); + rewind (pFile); + + fileData = new TYPENAME [fSize % SIZEOF_TYPENAME == 0 ? fSize/SIZEOF_TYPENAME : fSize/SIZEOF_TYPENAME + 1]; + + result = fread (&fileData[0], 1, fSize, pFile); + + if (result != fSize) + { + throw ErrorToLog("File not loaded: " + fileName); + } + + // terminate + fclose (pFile); + + intCount = fSize; + + return boost::shared_array(fileData); + +} + + +#endif + +//utitily to process texture uploading +inline char* GetFileName(const char* filename) +{ + char* fname = (char*)filename + strlen(filename); + + while ((*fname != '\\')&&(*fname != '/')&&(fname >= filename )) + --fname; + + ++fname; + + return fname; +} + +inline std::string GetFileName(const std::string& filename) +{ + std::string::const_iterator i = filename.end() - 1; + + while ((i > filename.begin() )&&(*i != '\\')&&(*i != '/')) + --i; + + if (*i == '\\' || *i == '/') + { + i++; + } + + return std::string(i, filename.end()); +} + +//utitily to process texture uploading +inline char* GetFileExt(const char* filename) +{ + char* fext = (char*)filename + strlen(filename); + + while (*fext != '.') + --fext; + + return fext; +} + +inline std::string GetFileExt(const std::string& filename) +{ + std::string::const_iterator i = filename.end() - 1; + + while (*i != '.') + --i; + + return std::string(i, filename.end()); + +} + +std::string GetFilePath(const std::string& filename); + +#ifdef TARGET_IOS + +//Special for IOS, because Foundation.h conflicts with sq_plus.h + +// Obviously, this returns ResourceManager->PathToResources + +std::string GetPathToResources(); +#endif + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/Utils/IosApi/IosApi.h b/include/Utils/IosApi/IosApi.h new file mode 100644 index 0000000..77e1d92 --- /dev/null +++ b/include/Utils/IosApi/IosApi.h @@ -0,0 +1,24 @@ +// +// Halibut_Engine.h +// Halibut Engine +// +// Created by vvv ооо on 13.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#include + +#include +#include + +#include "include/Utils/ErrorTypes/ErrorTypes.h" + +namespace SE +{ + +std::string IosGetFileReadPath(const std::string& filename); + +std::string IosGetFilePathUserData(const std::string& filename); + + +} //namespace SE diff --git a/include/Utils/JniApi/JniApi.h b/include/Utils/JniApi/JniApi.h new file mode 100644 index 0000000..2191b14 --- /dev/null +++ b/include/Utils/JniApi/JniApi.h @@ -0,0 +1,140 @@ +#ifndef JNI_API_H_INCLUDED +#define JNI_API_H_INCLUDED + +#include +#include +#include "include/Utils/DataTypes/DataTypes.h" +#include "include/Utils/ErrorTypes/ErrorTypes.h" +#include "boost/shared_array.hpp" + +#include "zip.h" +#include "zipint.h" +#include +#include + +namespace SE +{ + +/* + +This code mostly hard to explain +You may treat this like a factory-class + +But you cannot put JNI functions inside a class, that's why it is not a real class + +The only thing you need from here - functions JniCreateDataFromFile and JniCreateDataFromAlignedFile for FileUtils.h/cpp + +See doc for details + +*/ + +extern const std::string CONST_JAVA_FILESYSTEM_CLASS_NAME; + +//All 3 deprecated +extern cardinal* FileArr; +extern int FileSize; +extern std::string ApkFilePath; + +extern "C" { + JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_SetupEnviroment(JNIEnv* env, jobject thiz); + JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_SetupApkFilePath(JNIEnv* env, jobject thiz, jstring s); + JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_ConsoleOut(JNIEnv* env, jobject thiz, jstring s); + + //All 2 deprecated + JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_CreateFile(JNIEnv* env, jobject thiz, int fileSize); + JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_WriteToFile(JNIEnv* env, jobject thiz, jbyteArray buffer, int bufferSize); + + +}; + +//Deprecated +void JniCallOpenFile(const std::string& fileName); + + +//Deprecated +template +boost::shared_array JniCreateMemFromFileOld(const std::string& fileName, cardinal& blockCount) +{ + + //if size is too large - need to do some work + cardinal SIZEOF_TYPENAME = sizeof(TYPENAME); + if (SIZEOF_TYPENAME > 4) + { + throw ErrorToLog("ERROR! Size of type too large - file is not properly aligned. Need work!"); + } + + if (FileArr != NULL) + throw ErrorToLog("ERROR: Trying to reach two files at same time!!!!"); + + JniCallOpenFile(fileName); + + // ... + //Wait until Java pass all file data to FileArr through WriteToFile() + // ... + + //Give pointer away + boost::shared_array r(reinterpret_cast(FileArr)); + blockCount = FileSize % SIZEOF_TYPENAME == 0 ? FileSize / SIZEOF_TYPENAME: FileSize / SIZEOF_TYPENAME + 1; + FileArr = NULL; + FileSize = 0; + return r; +} + + +std::string JniGetApplicationDir(); + +void JniLoadSound(const std::string& fileName); +void JniPlaySound(const std::string& soundName); + +void JniPlayMusic(const std::string& fileName); +void JniPlayMusicLooped(const std::string& fileName); +void JniStopMusic(); + +void JniReleaseAllSoundsAndMusic(); +void JniPauseAllSoundsAndMusic();//NIU right now +void JniResumeAllSoundsAndMusic(); //NIU right now + +void LoadApk(const std::string& fileName, std::vector& returnData); + +void PrintApkContent(); + + +template +boost::shared_array JniCreateMemFromFile(const std::string& fileName, cardinal& blockCount) +{ + + try + { + + //if size is too large - need to do some work + cardinal SIZEOF_TYPENAME = sizeof(TYPENAME); + if (SIZEOF_TYPENAME > 4) + { + throw ErrorToLog("ERROR! Size of type too large - file is not properly aligned. Need work!"); + } + + std::vector fileData; + + LoadApk(fileName, fileData); + + cardinal fileSize = fileData.size(); + + blockCount = fileSize % SIZEOF_TYPENAME == 0 ? fileSize / SIZEOF_TYPENAME: fileSize / SIZEOF_TYPENAME + 1; + + boost::shared_array result(new TYPENAME[blockCount]); + + memcpy(&result[0], &fileData[0], fileSize); + + return result; + + } + catch(ErrorCommon e) + { + throw; + } +} + +} //namespace SE + + +#endif \ No newline at end of file diff --git a/include/Utils/PngHelper.h b/include/Utils/PngHelper.h new file mode 100644 index 0000000..84d129c --- /dev/null +++ b/include/Utils/PngHelper.h @@ -0,0 +1,37 @@ +#ifndef PNG_HELPER_H_INCLUDED +#define PNG_HELPER_H_INCLUDED + +extern "C" +{ +#define PNG_DEBUG 3 +#include "png.h" +} + +#include "boost/shared_array.hpp" +#include "include/Utils/DataTypes/DataTypes.h" + +namespace SE +{ + +struct TPngDataStruct +{ + int Width; + int Height; + png_byte ColorType; + png_byte BitDepth; + + png_structp PngPtr; + png_infop InfoPtr; + int NumberOfPasses; + png_bytep* RowPointers; +}; + + + +TPngDataStruct read_png_file(const boost::shared_array& fileArr, cardinal fileSize); + + +} //namespace SE + + +#endif \ No newline at end of file diff --git a/include/Utils/SerializeInterface/SerializeInterface.h b/include/Utils/SerializeInterface/SerializeInterface.h new file mode 100644 index 0000000..493232b --- /dev/null +++ b/include/Utils/SerializeInterface/SerializeInterface.h @@ -0,0 +1,62 @@ +#ifndef SERIALIZE_INTERFACE_H_INCLUDED +#define SERIALIZE_INTERFACE_H_INCLUDED + +#include "include/Utils/DataTypes/DataTypes.h" +#include "include/Utils/ErrorTypes/ErrorTypes.h" +#include "boost/property_tree/ptree.hpp" +#include "boost/property_tree/xml_parser.hpp" +#include "boost/shared_array.hpp" + +#include "boost/foreach.hpp" +#include + +namespace SE +{ + +std::shared_ptr StringToPropertyTree(std::string xmlCode, std::map replaceMap = std::map()); + +std::shared_ptr FileToPropertyTree(boost::shared_array xmlFileArr, cardinal xmlFileSize, std::map replaceMap = std::map()); + +std::shared_ptr FileToPropertyTree(const std::string& fileName, std::map replaceMap = std::map()); + + +class TSerializeInterface +{ +public: + virtual void Serialize(boost::property_tree::ptree& propertyTree) + { + } + +}; + + +template +class TMapParser : public TSerializeInterface +{ +public: + std::map Map; + + virtual void Serialize(boost::property_tree::ptree& propertyTree) + { + + BOOST_FOREACH(boost::property_tree::ptree::value_type& subTree, propertyTree) + { + TKEY key = subTree.second.get(".key"); + TVALUE value = subTree.second.get(".value"); + + Map[key] = value; + } + } +}; + +template +std::map SerializeToMap(boost::property_tree::ptree& propertyTree) +{ + TMapParser mapParser; + mapParser.Serialize(propertyTree); + return mapParser.Map; +} + +} //namespace SE + +#endif \ No newline at end of file diff --git a/include/Utils/SimpleTimer.h b/include/Utils/SimpleTimer.h new file mode 100644 index 0000000..1c9d5e4 --- /dev/null +++ b/include/Utils/SimpleTimer.h @@ -0,0 +1,30 @@ +#ifndef SIMPLE_TIMER_H_INCLUDED +#define SIMPLE_TIMER_H_INCLUDED + +#include "include/Utils/DataTypes/DataTypes.h" + +#include "boost/date_time/posix_time/posix_time.hpp" + +namespace SE +{ + +class TSimpleTimer +{ +protected: + int Timer; +public: + + TSimpleTimer(); + + void SetTimer(int timer); + void Update(cardinal dt); + bool IsOver(); + + boost::posix_time::time_duration GetPosixTime(); + +}; + +} //namespace SE + + +#endif \ No newline at end of file diff --git a/include/Utils/Utils.h b/include/Utils/Utils.h new file mode 100644 index 0000000..c50964c --- /dev/null +++ b/include/Utils/Utils.h @@ -0,0 +1,42 @@ +#ifndef UTILS_H_INCLUDED +#define UTILS_H_INCLUDED +/* +This code combines additional routines (such as console/log, exceptions, math utils, file utils) for engine to use +*/ + +#include +#include +#include +#include +#include "boost/shared_array.hpp" +#include "boost/property_tree/ptree.hpp" +#include "boost/foreach.hpp" + +#include "boost/asio.hpp" +#include "boost/date_time/posix_time/posix_time.hpp" +#include "boost/signal.hpp" + + +#include "include/Utils/Console/Console.h" +#include "include/Utils/ErrorTypes/ErrorTypes.h" +#include "../GlobalConst.h" +#include "include/Utils/FileUtils/FileUtils.h" +#include "include/Utils/SerializeInterface/SerializeInterface.h" + +#include "include/Utils/BindableVar.h" +#include "include/Utils/SimpleTimer.h" + +#ifdef TARGET_WIN32 +#include "WinApi/WinApi.h" +#endif + +#ifdef TARGET_ANDROID +#include "JniApi/JniApi.h" +#endif + +#ifdef TARGET_IOS +#include "IosApi/IosApi.h" +#endif + + +#endif \ No newline at end of file diff --git a/include/Utils/WinApi/WinApi.h b/include/Utils/WinApi/WinApi.h new file mode 100644 index 0000000..0f81a7a --- /dev/null +++ b/include/Utils/WinApi/WinApi.h @@ -0,0 +1,24 @@ +#pragma once + +#define NOMINMAX 1 +#include "windows.h" +#undef NOMINMAX +#include "gl/gl.h" +#include "gl/glu.h" +#include "gl/glext.h" + +namespace SE +{ + +/* +Here goes all functions that are platform-specific +When I make iOS/Mac/Linux port, I will make same API pair h/cpp + */ + +void GetWindowWidthHeight(int& width, int& height); + +int GetWindowWidth(); + +int GetWindowHeight(); + +} //namespace SE \ No newline at end of file diff --git a/src/Animation/SalmonAnimation.cpp b/src/Animation/SalmonAnimation.cpp new file mode 100644 index 0000000..92129a2 --- /dev/null +++ b/src/Animation/SalmonAnimation.cpp @@ -0,0 +1,670 @@ +#include "include/Animation/SalmonAnimation.h" + +#include "include/Utils/Utils.h" +#include "include/Engine.h" + +namespace SE +{ + +TAnimSequence::TAnimSequence(const TAnimSequence& animSeq) +{ + + BoneCount = animSeq.BoneCount; + FrameCount = animSeq.FrameCount; + + BoneInfoMatrix = animSeq.BoneInfoMatrix; +} + +TAnimSequence::~TAnimSequence() +{ + Clear(); +} + +TAnimSequence& TAnimSequence::operator=(const TAnimSequence& animSeq) +{ + if (this == &animSeq) + return *this; + + Clear(); + + BoneCount = animSeq.BoneCount; + FrameCount = animSeq.FrameCount; + BoneInfoMatrix = animSeq.BoneInfoMatrix; + + + + return *this; + +} + +void TAnimSequence::Clear() +{ + + BoneInfoMatrix.clear(); + FrameCount = 0; + BoneCount = 0; + + +} + + +bool TAnimSequence::LoadFromFileAn1(const std::string& fileName) +{ + Clear(); + + int i,j; + + cardinal fSize; + + boost::shared_array fileData = CreateMemFromFile(fileName, fSize); + + + if ((((char*)&fileData[0])[0] != 'A')|| + (((char*)&fileData[0])[1] != 'N')|| + (((char*)&fileData[0])[2] != 0)|| + (((char*)&fileData[0])[3] != 1)) + throw ErrorFileNotCorrect(fileName); + + + if (fSize < 3) + throw ErrorFileNotCorrect(fileName); + + BoneCount = fileData[1]; + FrameCount = fileData[2]; + + + BoneInfoMatrix.resize(FrameCount); + + for (i = 0; i < FrameCount; i++) + BoneInfoMatrix[i].resize(BoneCount); + + //Shift from file pointer + cardinal filePointer = 3; + + for (i=0; ifSize) + { + throw ErrorFileTooShort(fileName); + } + + BoneInfoMatrix[i][j].Pos.v[0] = ((float*)&fileData[0])[filePointer++]; + BoneInfoMatrix[i][j].Pos.v[1] = ((float*)&fileData[0])[filePointer++]; + BoneInfoMatrix[i][j].Pos.v[2] = ((float*)&fileData[0])[filePointer++]; + + BoneInfoMatrix[i][j].Quat.v[0] = ((float*)&fileData[0])[filePointer++]; + BoneInfoMatrix[i][j].Quat.v[1] = ((float*)&fileData[0])[filePointer++]; + BoneInfoMatrix[i][j].Quat.v[2] = ((float*)&fileData[0])[filePointer++]; + BoneInfoMatrix[i][j].Quat.v[3] = ((float*)&fileData[0])[filePointer++]; + + BoneInfoMatrix[i][j].Len = ((float*)&fileData[0])[filePointer++]; + + BoneInfoMatrix[i][j].Ancient = 0; //dummy + } + + + return true; +} + +void TAnimSequence::ScaleAnimSequence(float s) +{ + + + for (int i=0; i fileData = CreateMemFromFile(ResourceManager->PathToResources+fileName,fSize); + + + + if (fileData == NULL) + throw ErrorFileNotLoaded(fileName); + + if ((((char*)&fileData[0])[0]!='B')|| + (((char*)&fileData[0])[1]!='N')|| + (((char*)&fileData[0])[2]!=0)|| + (((char*)&fileData[0])[3]!=1)) + throw ErrorFileNotCorrect(fileName); + + if (fSize < 3) + throw ErrorFileNotCorrect(fileName); + + int boneCount = fileData[1]; + int vertexCount = fileData[2]; + + + //Shift from file pointer + cardinal filePointer = 3; + + //temporary data storage + TBoneStruct boneStruct; + TVertexWeightStruct vertexWeightStruct; + + + for (i=0; i fSize) + throw ErrorFileTooShort(fileName); + + boneStruct.Pos.v[0] = ((float*)fileData[0])[filePointer++]; + boneStruct.Pos.v[1] = ((float*)&fileData[0])[filePointer++]; + boneStruct.Pos.v[2] = ((float*)&fileData[0])[filePointer++]; + + boneStruct.Quat.v[0] = ((float*)&fileData[0])[filePointer++]; + boneStruct.Quat.v[1] = ((float*)&fileData[0])[filePointer++]; + boneStruct.Quat.v[2] = ((float*)&fileData[0])[filePointer++]; + boneStruct.Quat.v[3] = ((float*)&fileData[0])[filePointer++]; + + boneStruct.Len = ((float*)&fileData[0])[filePointer++]; + + boneStruct.Ancient = fileData[filePointer++]; + + BoneList.push_back(boneStruct); + } + + for (i=0; i fSize) + throw ErrorFileTooShort(fileName); + + vertexWeightStruct.WeightCount = fileData[filePointer++]; + + vertexWeightStruct.VertexBoneInfo.resize(3); + + vertexWeightStruct.VertexBoneInfo[0].BoneNum = fileData[filePointer++]; + vertexWeightStruct.VertexBoneInfo[0].BoneWeight = ((float*)&fileData[0])[filePointer++]; + vertexWeightStruct.VertexBoneInfo[1].BoneNum = fileData[filePointer++]; + vertexWeightStruct.VertexBoneInfo[1].BoneWeight = ((float*)&fileData[0])[filePointer++]; + vertexWeightStruct.VertexBoneInfo[2].BoneNum = fileData[filePointer++]; + vertexWeightStruct.VertexBoneInfo[2].BoneWeight = ((float*)&fileData[0])[filePointer++]; + + VertexWeightList.push_back(vertexWeightStruct); + } + + + Ready = true; + + + return true; +} + + +bool TAnimList::LoadBoneSystemFromFileBn2(const std::string& fileName) +{ + Clear(); + + int i; + + cardinal fSize; + boost::shared_array fileData = CreateMemFromFile(ResourceManager->PathToResources+fileName,fSize); + + if (fileData == NULL) + throw ErrorFileNotLoaded(fileName); + + if (((reinterpret_cast(&fileData[0]))[0]!='B')|| + ((reinterpret_cast(&fileData[0]))[1]!='N')|| + ((reinterpret_cast(&fileData[0]))[2]!=0)|| + ((reinterpret_cast(&fileData[0]))[3]!=2)) + throw ErrorFileNotCorrect(fileName); + + if (fSize < 3) + throw ErrorFileNotCorrect(fileName); + + int boneCount = fileData[1]; + int vertexCount = fileData[2]; + + + //Shift from file pointer + cardinal filePointer = 3; + + //temporary data storage + TBoneStruct boneStruct; + TVertexWeightStruct vertexWeightStruct; + + + for (i=0; i fSize) + throw ErrorFileTooShort(fileName); + + boneStruct.Pos.v[0] = (reinterpret_cast(&fileData[0]))[filePointer++]; + boneStruct.Pos.v[1] = (reinterpret_cast(&fileData[0]))[filePointer++]; + boneStruct.Pos.v[2] = (reinterpret_cast(&fileData[0]))[filePointer++]; + + boneStruct.Quat.v[0] = (reinterpret_cast(&fileData[0]))[filePointer++]; + boneStruct.Quat.v[1] = (reinterpret_cast(&fileData[0]))[filePointer++]; + boneStruct.Quat.v[2] = (reinterpret_cast(&fileData[0]))[filePointer++]; + boneStruct.Quat.v[3] = (reinterpret_cast(&fileData[0]))[filePointer++]; + + boneStruct.Len = (reinterpret_cast(&fileData[0]))[filePointer++]; + + boneStruct.Ancient = (reinterpret_cast(&fileData[0]))[filePointer++]; + + BoneList.push_back(boneStruct); + } + + for (i=0; i fSize) + throw ErrorFileTooShort(fileName); + + vertexWeightStruct.WeightCount = fileData[filePointer++]; + + vertexWeightStruct.VertexBoneInfo.resize(vertexWeightStruct.WeightCount); + + TBoneWeightStruct boneWeightStructZero; + boneWeightStructZero.BoneNum = -1; + boneWeightStructZero.BoneWeight = -1; + + for (cardinal j=0; j(&fileData[0]))[filePointer++]; + vertexWeightStruct.VertexBoneInfo[j] = boneWeightStruct; + } + + VertexWeightList.push_back(vertexWeightStruct); + } + + + Ready = true; + + //delete [] fileData; + + return true; +} + +bool TAnimList::LoadAnimSequenceFromFileAn1(const std::string& fileName) +{ + std::string shortFileName(GetFileName((char*)fileName.c_str())); + + if (AnimSequenceMap.count(shortFileName) == 0) + { + TAnimSequence animSeqience; + if (animSeqience.LoadFromFileAn1(ResourceManager->PathToResources+fileName)) + { + AnimSequenceMap[shortFileName] = animSeqience; + return true; + } + else + return false; + } + + return false; +} + +void TAnimList::Clear() +{ + BoneList.clear(); + VertexWeightList.clear(); + AnimSequenceMap.clear(); + Ready = false; +} + +void TAnimList::ScaleAnimList(float s) +{ + for (TBoneList::iterator i = BoneList.begin(); i != BoneList.end(); ++i) + { + i->Pos *= s; + i->Len *= s; + } + + for (TAnimSequenceMap::iterator j = AnimSequenceMap.begin(); j != AnimSequenceMap.end(); ++j) + { + j->second.ScaleAnimSequence(s); + } +} + +void TAnimList::MoveAnimList(const vec3& v) +{ + for (TBoneList::iterator i = BoneList.begin(); i != BoneList.end(); ++i) + { + i->Pos += v; + } + + for (TAnimSequenceMap::iterator j = AnimSequenceMap.begin(); j != AnimSequenceMap.end(); ++j) + { + j->second.MoveAnimSequence(v); + } +} + +void TAnimList::RotateAnimList(const mat3& m) +{ + vec4 q(m); + + for (TBoneList::iterator i = BoneList.begin(); i != BoneList.end(); ++i) + { + i->Pos = m * i->Pos; + i->Quat = i->Quat * q; + } + + for (TAnimSequenceMap::iterator j = AnimSequenceMap.begin(); j != AnimSequenceMap.end(); ++j) + { + j->second.RotateAnimSequence(m); + } +} + + +void TAnimList::DrawBoneSystem() +{ +#ifdef TARGET_WIN32 + vec3 startpos, endpos; + vec4 vx, q, inv_q; + + TBoneList::iterator i; + + for (TBoneList::iterator i = BoneList.begin(); i != BoneList.end(); ++i) + { + + startpos = i->Pos; + q = i->Quat; + + vx = vec4(i->Len, 0.0f, 0.0f, 0.0f); + + inv_q.v[0] = - q.v[0]; + inv_q.v[1] = - q.v[1]; + inv_q.v[2] = - q.v[2]; + inv_q.v[3] = q.v[3]; + + vx = q * vx * inv_q; + + endpos = startpos + vec3(vx); + + glBegin(GL_LINES); + glNormal3f(0.0f, 1.0f, 0.0f); + glVertex3fv(startpos.v); + glVertex3fv(endpos.v); + glEnd(); + } +#endif +} + +void TAnimList::SaveBoneSystemToBuf() +{ + PrevBoneList.assign(BoneList.begin(),BoneList.end()); +} + +void TAnimList::LoadBoneSystemFromBuf() +{ + BoneList.assign(PrevBoneList.begin(),PrevBoneList.end()); +} + +//===================================================== +//=========== TModelAnimManager ======================= +//===================================================== + +TAnimList* TModelAnimManager::operator [] (const std::string& s) +{ + if (AnimListMap.count(s) > 0) + { + return &AnimListMap[s]; + } + + return NULL; +} + +//NOT SAFE!!! Need to check if model exists in Lite Model Manager and need to check if bone list belongs to this model +bool TModelAnimManager::AddAnimationToModel(const std::string& modelName, const std::string& boneListFileName) +{ + if (AnimListMap.count(modelName) == 0) + { + //TODO: Make switch + //if (!AnimListMap[modelName].LoadBoneSystemFromFileBn1(boneListFileName)) + if (!AnimListMap[modelName].LoadBoneSystemFromFileBn2(boneListFileName)) + { + AnimListMap.erase(modelName); + return false; + } + + return true; + } + return false; +} + +void TModelAnimManager::Clear() +{ + + AnimListMap.clear(); +} + + +//================================================== +//=============== ANIM MODEL ======================= +//================================================== + + + + +void TAnimModel::RecalcVertexPos() +{ + + int i,j,nBone; + mat3 R, R0, dR; + vec4 dq,inv_q; + vec4 q0; + vec4 q; + vec4 inv_q0; + vec4 inv_dq; + //vec3 endbone0; + vec3 endbone; + vec3 p[20];//TODO: MAKE THIS DYNAMIC!!!! + vec3 PrevPos,dbp,px; + + //float n; + + int VertexCount = LiteModel.TriangleCount * 3; + + + + for (i=0; iVertexWeightList[i].WeightCount; + + for (j=0; jVertexWeightList[i].VertexBoneInfo[j].BoneNum; + + q0 = AnimList->PrevBoneList[nBone].Quat; + + inv_q0 = q0; + + inv_q0.v[0] = - inv_q0.v[0]; + inv_q0.v[1] = - inv_q0.v[1]; + inv_q0.v[2] = - inv_q0.v[2]; + inv_q0.v[3] = inv_q0.v[3]; + + q = AnimList->BoneList[nBone].Quat; + + inv_q = q; + + inv_q.v[0] = - inv_q.v[0]; + inv_q.v[1] = - inv_q.v[1]; + inv_q.v[2] = - inv_q.v[2]; + inv_q.v[3] = inv_q.v[3]; + + vec3 prevBonePos = AnimList->PrevBoneList[nBone].Pos; + + px = PrevPos - prevBonePos; + + px = inv_q * (q0 * vec4(px) * inv_q0) * q; + + vec3 bonePos = AnimList->BoneList[nBone].Pos; + + p[j] = bonePos + px; + + } + + px = vec3(0.0f, 0.0f, 0.0f); + + for (j=0; jVertexWeightList[i].VertexBoneInfo[j].BoneWeight; + } + + //LiteModel.VertexArr[i] = px; + LiteModel.TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB][i] = px; + + /* + //Normal + px = ((vec3*)(LiteModel.TrianglePointer))[i+VertexCount]; + px = dR * px; + ((vec3*)(LiteModel.TrianglePointer))[i+VertexCount] = px; + + //Tangent + px = ((vec3*)(LiteModel.TrianglePointer))[i+VertexCount+VertexCount]; + px = dR * px; + ((vec3*)(LiteModel.TrianglePointer))[i+VertexCount+VertexCount] = px; + + //Binormal + px = ((vec3*)(LiteModel.TrianglePointer))[i+VertexCount+VertexCount+VertexCount]; + px = dR * px; + ((vec3*)(LiteModel.TrianglePointer))[i+VertexCount+VertexCount+VertexCount] = px;*/ + } + +} + +void TAnimModel::SaveVertexInfoToBuf() +{ + + CopyVertexArr = LiteModel.TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB]; + + AnimList->SaveBoneSystemToBuf(); +} +void TAnimModel::LoadVertexInfoFromBuf() +{ + + LiteModel.TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB] = CopyVertexArr; + + AnimList->LoadBoneSystemFromBuf(); +} + + +bool TAnimModel::LoadModel(const std::string& modelName) +{ + if (!LiteModel.LoadModel(modelName)) + return false; + + + CopyVertexArr.resize(LiteModel.TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].size()); + CopyVertexArr = LiteModel.TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB]; + + AnimList = ResourceManager->ModelAnimManager[modelName]; + + if (AnimList == NULL) + return false; + + Ready = true; + + SaveVertexInfoToBuf(); + + return true; +} + +void TAnimModel::Clear() +{ + + CopyVertexArr.clear(); + + LiteModel.FreeModel(); + AnimList = NULL; + + Ready = false; +} + +void TAnimModel::ScaleModel(float s) +{ + LiteModel.ScaleModel(s); + AnimList->ScaleAnimList(s); + + SaveVertexInfoToBuf(); +} + +void TAnimModel::MoveModel(const vec3& v) +{ + LiteModel.MoveModel(v); + AnimList->MoveAnimList(v); + + SaveVertexInfoToBuf(); +} + +void TAnimModel::RotateModel(const mat3& r) +{ + LiteModel.RotateModel(r); + AnimList->RotateAnimList(r); + + SaveVertexInfoToBuf(); +} + +void TAnimModel::DrawImmediate() +{ + LiteModel.DrawImmediate(); +} + +void TAnimModel::ApplySequence(const std::string& seq, int n) +{ + + int boneCount = AnimList->BoneList.size(); + + for (int i=0; iBoneList[i].Pos = AnimList->AnimSequenceMap[seq].BoneInfoMatrix[n][i].Pos; + AnimList->BoneList[i].Quat = AnimList->AnimSequenceMap[seq].BoneInfoMatrix[n][i].Quat; + AnimList->BoneList[i].Len = AnimList->AnimSequenceMap[seq].BoneInfoMatrix[n][i].Len; + } + + RecalcVertexPos(); +} + +} //namespace SE \ No newline at end of file diff --git a/src/ApplicationInterface.cpp b/src/ApplicationInterface.cpp new file mode 100644 index 0000000..99d1a32 --- /dev/null +++ b/src/ApplicationInterface.cpp @@ -0,0 +1,35 @@ +#include "include/Engine.h" + + +namespace SE +{ + +TApplicationInterface::TApplicationInterface() + : IsConsoleOut(false) +{ +} + +void TApplicationInterface::OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight) +{ + ResourceManager->ScriptManager.BindBasicFunctions(); + InnerInit(); +#ifdef TARGET_HALIBUT + Renderer->InitOpenGL(screenWidth, screenHeight, matrixWidth, matrixHeight); +#endif +#ifdef TARGET_SALMON + Renderer->InitOpenGL(screenWidth, screenHeight, matrixWidth, matrixHeight); +#endif + + CheckGlError(); + + srand(static_cast(time(0))); +} + +void TApplicationInterface::OuterDeinit() +{ + CheckGlError("OuterDeinit"); + InnerDeinit(); +} + + +} //namespace SE \ No newline at end of file diff --git a/src/FontManager/FontManager.cpp b/src/FontManager/FontManager.cpp new file mode 100644 index 0000000..96f0205 --- /dev/null +++ b/src/FontManager/FontManager.cpp @@ -0,0 +1,479 @@ +#include "include/FontManager/FontManager.h" +#include "include/Engine.h" + +#include + +namespace SE +{ + +const float CONST_HEIGHT_COEF = 1.0f; + +const int CONST_MAX_FONT_STACK_SIZE = 10; + + + +TFontManager::~TFontManager() +{ + *Console<<"TFontManager deleting..."; +} + +void TFontManager::Serialize(boost::property_tree::ptree& propertyTree) +{ + BOOST_FOREACH(boost::property_tree::ptree::value_type &v, propertyTree.get_child("Fonts")) + { + + std::string fontName = v.second.get("FontName"); + std::string bitmapFileName = v.second.get("BitmapFileName"); + std::string charmapFileName = v.second.get("CharmapFileName"); + + AddFont(fontName, bitmapFileName, charmapFileName); + + } + +} + +void TFontManager::AddFont(const std::string& fontName, const std::string& bitmapFile, const std::string& charmapFile) +{ + if (FontMap.count(fontName) > 0) + { + throw ErrorToLog("Trying to add font twice or some font files not found!" + fontName); + } + + TFont& currentFont = FontMap[fontName]; + + std::string texName = GetFileName(bitmapFile); + + currentFont.TexName = texName; + + ResourceManager->TexList.AddTexture(bitmapFile); + + currentFont.SheetWidth = ResourceManager->TexList.GetTextureWidth(texName); + currentFont.SheetHeight = ResourceManager->TexList.GetTextureHeight(texName); + + cardinal byteCount; + + boost::shared_array charmapFileArr = boost::shared_array(CreateMemFromFile(ResourceManager->PathToResources+charmapFile, byteCount)); + + //Need to rewrite this code :( + + TFontParams fontParams; + cardinal character; + + std::stringstream charmapFileStream; + charmapFileStream.write(&charmapFileArr[0], byteCount); + + while(!charmapFileStream.eof()) + { + + charmapFileStream>>character; + charmapFileStream>>fontParams.ShiftX; + charmapFileStream>>fontParams.ShiftY; + charmapFileStream>>fontParams.InternalShiftX; + charmapFileStream>>fontParams.InternalShiftY; + charmapFileStream>>fontParams.BitmapWidth; + charmapFileStream>>fontParams.BitmapHeight; + charmapFileStream>>fontParams.Advance; + + currentFont.CharMap[character] = fontParams; + } + + + +} + + + +void TFontManager::PushFont(const std::string& fontName) +{ + if (FontStack.size() >= CONST_MAX_FONT_STACK_SIZE) + { + throw ErrorToLog("Error: font stack overflow!"); + } + FontStack.push(fontName); +} + +void TFontManager::PopFont() +{ + if (FontStack.size() == 0) + { + throw ErrorToLog("Error: font stack underflow!"); + } + + FontStack.pop(); +} + +std::string TFontManager::GetCurrentFontName() +{ + if (FontStack.size() == 0) + { + throw ErrorToLog("Error: font stack underflow!"); + } + + return FontStack.top(); +} + +std::string TFontManager::GetCurrentFontTextureName() +{ + return FontMap[GetCurrentFontName()].TexName; +} + + +float TFontManager::DrawChar(vec2 pos, cardinal character) +{ + //Also see DrawCharToVBO + + std::string fontName = GetCurrentFontName(); + + if (FontMap.count(fontName) == 0) + { + throw ErrorToLog("Trying to use unknown font! " + fontName); + } + + TFont& currentFont = FontMap[fontName]; + + TFontParams& fontParams = currentFont.CharMap[character]; + + int scale_y = currentFont.SheetHeight; + int scale_x = currentFont.SheetWidth; + + float height = scale_y*fontParams.BitmapHeight; + + float width = scale_x*fontParams.BitmapWidth; + + vec2 p1 = pos + vec2(+ scale_x*fontParams.InternalShiftX, -height- scale_y*fontParams.InternalShiftY); + vec2 p2 = pos + vec2(width + scale_x*fontParams.InternalShiftX, - scale_y* fontParams.InternalShiftY); + + vec2 t1 = vec2(fontParams.ShiftX, + 1 - fontParams.ShiftY - fontParams.BitmapHeight - fontParams.InternalShiftY); + vec2 t2 = vec2(fontParams.ShiftX + fontParams.BitmapWidth, + 1 - fontParams.ShiftY - fontParams.InternalShiftY); + + Renderer->DrawRect(p1, p2, t1, t2); + + return fontParams.Advance*scale_x; +} + +float TFontManager::DrawCharToVBO(vec2 pos, cardinal character, TTriangleList& triangleList) +{ + //Also see DrawChar + + std::string fontName = GetCurrentFontName(); + + if (FontMap.count(fontName) == 0) + { + throw ErrorToLog("Trying to use unknown font! " + fontName); + } + + TFont& currentFont = FontMap[fontName]; + + TFontParams& fontParams = currentFont.CharMap[character]; + + int scale_y = currentFont.SheetHeight; + int scale_x = currentFont.SheetWidth; + + float height = scale_y*fontParams.BitmapHeight; + + float width = scale_x*fontParams.BitmapWidth; + + vec2 p1 = pos + vec2(+ scale_x*fontParams.InternalShiftX, -height - scale_y*fontParams.InternalShiftY); + vec2 p2 = pos + vec2(width + scale_x*fontParams.InternalShiftX, - scale_y* fontParams.InternalShiftY); + + + vec2 t1 = vec2(fontParams.ShiftX, + 1 - fontParams.ShiftY - fontParams.BitmapHeight - fontParams.InternalShiftY); + vec2 t2 = vec2(fontParams.ShiftX + fontParams.BitmapWidth, + 1 - fontParams.ShiftY - fontParams.InternalShiftY); + + /* + vec2 p12 = vec2(p1.v[0], p2.v[1]); + vec2 p21 = vec2(p2.v[0], p1.v[1]); + + vec2 t12 = vec2(t1.v[0], t2.v[1]); + vec2 t21 = vec2(t2.v[0], t1.v[1]); + + + triangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(vec3(p1, 0)); + triangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(vec3(p12, 0)); + triangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(vec3(p2, 0)); + + triangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(vec3(p2, 0)); + triangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(vec3(p21, 0)); + triangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(vec3(p1, 0)); + + triangleList.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].push_back(t1); + triangleList.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].push_back(t12); + triangleList.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].push_back(t2); + + triangleList.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].push_back(t2); + triangleList.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].push_back(t21); + triangleList.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].push_back(t1); + */ + triangleList.Data += MakeDataTriangleList(p1, p2, t1, t2); + + return fontParams.Advance*scale_x; +} + +vec2 TFontManager::FitStringToBox(vec2 posFrom, vec2 posTo, TTextBasicAreaParams params, std::string& str) +{ + //Need to make this deprecated! + + throw ErrorToLog("Call to deprecated TFontManager::FitStringToBox"); + + std::string fontName = GetCurrentFontName(); + + float intervalY = CONST_HEIGHT_COEF * params.Height; + + size_t rows = 1; + + float maxWidth = posTo.v[0] - posFrom.v[0]; + + cardinal p = 0; + vec2 cursor; + + while (p maxWidth) + { + str.insert(p, 1, '\n'); + cursor.v[0] = 0; + } + + p++; + } + + size_t found = str.find_first_of('\n'); + + while (found != std::string::npos) + { + rows++; + found = str.find_first_of('\n', found + 1); + } + + return vec2(posFrom.v[0], posFrom.v[1] + intervalY*rows); + +} + + +vec2 TFontManager::FitStringToBoxWithWordWrap(vec2 posFrom, vec2 posTo, TTextBasicAreaParams params, std::string& str) +{ + + std::string fontName = GetCurrentFontName(); + + float intervalY = CONST_HEIGHT_COEF * params.Height; + + size_t rows = 1; + + //Apply padding: + + posFrom.v[0] += params.HorizontalPadding; + posTo.v[0] -= params.HorizontalPadding; + posFrom.v[1] += params.VerticalPadding; + posTo.v[1] -= params.VerticalPadding; + + + float maxWidth = posTo.v[0] - posFrom.v[0]; + + + //cardinal p = 0; + vec2 cursor; + + + std::vector explodedByParagraph; + + boost::split(explodedByParagraph, str, boost::is_any_of("\n"), boost::token_compress_on); + + std::string result; + + + for (size_t i=0; i explodedByWord; + + boost::split(explodedByWord, explodedByParagraph[i], boost::is_space(), boost::token_compress_on); + + for (size_t j=0; j< explodedByWord.size(); j++) + { + std::string s = explodedByWord[j]; + + float adv = GetTextAdvance(s); + + if (adv + cursor.v[0] < maxWidth) + { + result += s + " "; + cursor.v[0] += adv + GetCharAdvance(' '); + } + else + { + if (adv < maxWidth) + { + result += "\n" + s + " "; + cursor.v[0] = adv + GetCharAdvance(' '); + } + else + { + for (int k=0; k maxWidth) + { + cursor.v[0] = 0; + result += "\n"; + } + } + } + } + } + + result += "\n"; + cursor.v[0] = 0; + + } + + //Erase last symbol \n + result.erase(result.end()-1, result.end()); + + + str = result; + + size_t found = str.find_first_of('\n'); + + while (found != std::string::npos) + { + rows++; + found = str.find_first_of('\n', found + 1); + } + + vec2 result_vec = vec2(posFrom.v[0], posFrom.v[1] + intervalY*rows); + + if (params.TextHorizontalAlignment == THA_RIGHT) + { + result_vec.v[0] = posTo.v[0]; + } + else if (params.TextHorizontalAlignment == THA_CENTER) + { + result_vec.v[0] = (posTo.v[0] + posFrom.v[0])*0.5f; + } + + if (params.TextVerticalAlignment == TVA_TOP) + { + result_vec.v[1] = posTo.v[1]; + } + else if (params.TextVerticalAlignment == TVA_CENTER) + { + result_vec.v[1] = (posTo.v[1] + posFrom.v[1])*0.5f; + } + + return result_vec; + +} + +TTriangleList TFontManager::DrawStringToVBO(vec2 pos, TTextBasicAreaParams params, const std::string& str) +{ + + std::wstring ws; + utf8toWStr(ws, str); + + std::string fontName = GetCurrentFontName(); + + float width; + + TTriangleList triangleList; + + std::vector rowArr; + + boost::split(rowArr, ws, boost::algorithm::is_any_of("\n")); + + vec2 startPos = pos; + + float rowsHeight = rowArr.size() * CONST_HEIGHT_COEF*params.Height; + + + BOOST_FOREACH(auto& rowStr, rowArr) + { + + float rowWidth = GetTextAdvance(rowStr); + + for (cardinal i=0; iDrawTriangleList(triangleList); + +} + +void TFontManager::DrawTextInBox(vec2 posFrom, vec2 posTo, TTextBasicAreaParams params, std::string str, bool wordWrap) +{ + vec2 realPosFrom; + if (wordWrap) + { + realPosFrom = FitStringToBoxWithWordWrap(posFrom, posTo, params, str); + } + else + { + realPosFrom = FitStringToBox(posFrom, posTo, params, str); + } + + DrawString(realPosFrom, params, str); +} + +TTriangleList TFontManager::DrawTextInBoxToVBO(vec2 posFrom, vec2 posTo, TTextBasicAreaParams params, std::string str, bool wordWrap) +{ + + vec2 realPosFrom; + if (wordWrap) + { + realPosFrom = FitStringToBoxWithWordWrap(posFrom, posTo, params, str); + } + else + { + realPosFrom = FitStringToBox(posFrom, posTo, params, str); + } + return DrawStringToVBO(realPosFrom, params, str); +} + +} //namespace SE \ No newline at end of file diff --git a/src/FrameManager/FrameManager.cpp b/src/FrameManager/FrameManager.cpp new file mode 100644 index 0000000..af029e2 --- /dev/null +++ b/src/FrameManager/FrameManager.cpp @@ -0,0 +1,341 @@ +#include "include/FrameManager/FrameManager.h" + +#include "include/Utils/Utils.h" +#include "include/Engine.h" + +namespace SE +{ + +//=================================================== +//================ FRAME MANAGER ==================== +//=================================================== + + +TFrameManager::~TFrameManager() +{ + FreeFrameManager(); + *Console<<"ResourceManager::FrameManager deleting"; +} + +void TFrameManager::FreeFrameManager() +{ + BOOST_FOREACH(auto& i, FrameMap) + { + ResourceManager->TexList.DeleteTexture(i.second.TexName); + glDeleteRenderbuffers(1, &(i.second.DepthRenderBuffer)); + glBindFramebuffer(GL_FRAMEBUFFER, 0); + glDeleteFramebuffers(1, &(i.second.FrameBuffer)); + } + + FrameMap.clear(); + +} + +cardinal TFrameManager::AddFrameRenderBuffer(const std::string& frameName,cardinal width,cardinal height) +{ + #ifdef TARGET_ANDROID + #define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE + #endif + #ifdef TARGET_IOS + #define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE + #endif + + if (FrameMap.count(frameName) == 0) + { + + + + std::string texName = frameName + "Texture"; + cardinal texID = ResourceManager->TexList.AddEmptyTexture(texName,width,height); + + + cardinal frameBuffer; + cardinal depthRenderBuffer; + cardinal status; + + + glGenFramebuffers(1,&frameBuffer); + glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer); + + + glGenRenderbuffers(1, &depthRenderBuffer); + glBindRenderbuffer(GL_RENDERBUFFER, depthRenderBuffer); + + #ifdef TARGET_WIN32 + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height); + #endif + #ifdef TARGET_ANDROID + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height); + #endif + #ifdef TARGET_IOS + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height); + #endif + + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderBuffer); + + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texID, 0); + + status = glCheckFramebufferStatus(GL_FRAMEBUFFER); + + switch(status) + { + case GL_FRAMEBUFFER_COMPLETE_EXT: + *Console<<"FrameManager:: frame buffer added: "+frameName; + FrameMap[frameName].FrameBuffer = frameBuffer; + FrameMap[frameName].DepthRenderBuffer = depthRenderBuffer; + FrameMap[frameName].TexID = texID; + FrameMap[frameName].Width = width; + FrameMap[frameName].Height = height; + FrameMap[frameName].TexName = texName; + + return FrameMap[frameName].FrameBuffer; + + break; + default: + *Console<<"FrameManager::ERROR - frame buffer can not be added correctly: "+frameName+", with error: "+tostr(status); + ResourceManager->TexList.DeleteTexture(texName); + glDeleteRenderbuffers(1, &depthRenderBuffer); + glBindFramebuffer(GL_FRAMEBUFFER, 0); + glDeleteFramebuffers(1, &frameBuffer); + + return 0; + } + + } + else + return FrameMap[frameName].FrameBuffer; + + #ifdef TARGET_ANDROID + #undef GL_FRAMEBUFFER_COMPLETE_EXT + #endif + #ifdef TARGET_IOS + #undef GL_FRAMEBUFFER_COMPLETE_EXT + #endif + +} + +cardinal TFrameManager::AddCubemapBuffer(const std::string& frameName,cardinal width,cardinal height) +{ + + #ifdef TARGET_ANDROID + #define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE + #endif + #ifdef TARGET_IOS + #define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE + #endif + + if (FrameMap.count(frameName) == 0) + { + + std::string texName = frameName + "Texture"; + cardinal texID = ResourceManager->TexList.AddEmptyCubemapTexture(texName,width,height); + + cardinal frameBuffer; + cardinal depthRenderBuffer; + cardinal status; + + + glGenFramebuffers(1,&frameBuffer); + glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer); + + glGenRenderbuffers(1, &depthRenderBuffer); + glBindRenderbuffer(GL_RENDERBUFFER, depthRenderBuffer); + + #ifdef TARGET_WIN32 + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height); + #endif + #ifdef TARGET_ANDROID + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height); + #endif + #ifdef TARGET_IOS + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height); + #endif + + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderBuffer); + + + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, texID, 0); + + //?? is it needed? + + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X+1, texID, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X+2, texID, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X+3, texID, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X+4, texID, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X+5, texID, 0); + + + + + status = glCheckFramebufferStatus(GL_FRAMEBUFFER); + + switch(status) + { + case GL_FRAMEBUFFER_COMPLETE_EXT: + *Console<<"FrameManager:: frame buffer added: "+frameName; + FrameMap[frameName].FrameBuffer = frameBuffer; + FrameMap[frameName].DepthRenderBuffer = depthRenderBuffer; + FrameMap[frameName].TexID = texID; + FrameMap[frameName].Width = width; + FrameMap[frameName].Height = height; + FrameMap[frameName].TexName = texName; + + //return FrameMap[frameName].TexID; //That is easier + return FrameMap[frameName].FrameBuffer; + + break; + default: + *Console<<"ERROR number : "+tostr(status)+endl; + *Console<<"FrameManager::ERROR - frame buffer can not be added correctly: "+frameName; + ResourceManager->TexList.DeleteTexture(texName); + glDeleteRenderbuffers(1, &depthRenderBuffer); + glBindFramebuffer(GL_FRAMEBUFFER, 0); + glDeleteFramebuffers(1, &frameBuffer); + + return 0; + } + + + } + else + return FrameMap[frameName].FrameBuffer; + + #ifdef TARGET_ANDROID + #undef GL_FRAMEBUFFER_COMPLETE_EXT + #endif + #ifdef TARGET_IOS + #undef GL_FRAMEBUFFER_COMPLETE_EXT + #endif + +} + +void TFrameManager::DeleteFrameRenderBuffer(const std::string& frameName) +{ + if (FrameMap.count(frameName) > 0) + { + ResourceManager->TexList.DeleteTexture(FrameMap[frameName].TexName); + glDeleteRenderbuffers(1, &(FrameMap[frameName].DepthRenderBuffer)); + glBindFramebuffer(GL_FRAMEBUFFER, 0); + glDeleteFramebuffers(1, &(FrameMap[frameName].FrameBuffer)); + + FrameMap.erase(frameName); + } +} + +cardinal TFrameManager::AddDepthBuffer(const std::string& frameName, cardinal width, cardinal height) +{ + + #ifdef TARGET_ANDROID + #define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE + #endif + + if (FrameMap.count(frameName) == 0) + { + + std::string texName = frameName + "Texture"; + cardinal depthTexID = ResourceManager->TexList.AddDepthTexture(texName,width,height); + + cardinal frameBuffer; + cardinal status; + + + glGenFramebuffers(1,&frameBuffer); + glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer); + + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexID, 0); + + #ifdef TARGET_WIN32 + glDrawBuffer(GL_NONE); + glReadBuffer(GL_NONE); + #endif + + status = glCheckFramebufferStatus(GL_FRAMEBUFFER); + + switch(status) + { + case GL_FRAMEBUFFER_COMPLETE: + *Console<<"FrameManager:: frame buffer added: "+frameName; + FrameMap[frameName].FrameBuffer = frameBuffer; + FrameMap[frameName].DepthRenderBuffer = 0; + FrameMap[frameName].TexID = depthTexID; + FrameMap[frameName].Width = width; + FrameMap[frameName].Height = height; + FrameMap[frameName].TexName = texName; + + return FrameMap[frameName].FrameBuffer; + break; + default: + *Console<<"FrameManager::ERROR - frame buffer can not be added correctly: "+frameName; + ResourceManager->TexList.DeleteTexture(texName); + glBindFramebuffer(GL_FRAMEBUFFER, 0); + glDeleteFramebuffers(1, &frameBuffer); + + return 0; + } + + + } + else + return FrameMap[frameName].FrameBuffer; + + #ifdef TARGET_ANDROID + #undef GL_FRAMEBUFFER_COMPLETE_EXT + #endif +} + + + +cardinal TFrameManager::GetFrameTexture(const std::string& frameName) +{ + if (FrameMap.count(frameName) > 0) + { + return FrameMap[frameName].TexID; + } + else + return 0; +} + + +ivec2 TFrameManager::GetFrameWidthHeight(const std::string& frameName) +{ + if (FrameMap.count(frameName) == 0) + { + throw ErrorToLog("Frame "+frameName+" not found!"); + } + + return ivec2(FrameMap[frameName].Width, FrameMap[frameName].Height); +} + + +TTextureData TFrameManager::ReadFromBufferToTexData(const std::string& frameName) +{ + TTextureData texData; + texData.Width = FrameMap[frameName].Width; + texData.Height = FrameMap[frameName].Height; + texData.DataSize = texData.Width * texData.Height * 3; + + texData.Data = boost::shared_array(new char[texData.DataSize]); + + boost::shared_array data(new char[texData.Width * texData.Height * 4]); + + glReadPixels(0, 0, FrameMap[frameName].Width, FrameMap[frameName].Height, GL_RGBA, GL_UNSIGNED_BYTE, &data[0]); + + for (cardinal i=0; i < texData.Width; i++) + { + for (cardinal j=0; j < texData.Height; j++) + { + int x = (i * texData.Height + j) + (i * texData.Height + j) + (i * texData.Height + j); + + int y = 4 * (i * texData.Height + j); + + texData.Data[x + 2] = data[y + 2]; + texData.Data[x + 1] = data[y + 1]; + texData.Data[x + 0] = data[y + 0]; + } + } + + return texData; + +} + +} //namespace SE \ No newline at end of file diff --git a/src/GUIManager/ButtonWidget.cpp b/src/GUIManager/ButtonWidget.cpp new file mode 100644 index 0000000..dae5c85 --- /dev/null +++ b/src/GUIManager/ButtonWidget.cpp @@ -0,0 +1,1170 @@ +#include "include/Engine.h" + +namespace SE +{ + +const cardinal CONST_BUTTON_HIGHLIGHT_TIME = 100; + +TInstancingWidgetAncestor::~TInstancingWidgetAncestor() +{ +} + + +void TInstancingWidgetAncestor::Update(cardinal dt) +{ +} + +bool TInstancingWidgetAncestor::CheckClick(vec2 mousePos) +{ + return false; +} + + +bool TSquareStatic::CheckClick(vec2 mousePos) +{ + if (mousePos.v[0] >= LeftBottomPos.v[0] && + mousePos.v[0] <= LeftBottomPos.v[0] + Width && + mousePos.v[1] >= LeftBottomPos.v[1] && + mousePos.v[1] <= LeftBottomPos.v[1] + Height) + { + return true; + } + else + { + return false; + } +} + +TSquareStatic* TSquareStatic::CreateStatic(vec2 posFrom, vec2 posTo) +{ + TSquareStatic* staticWidget = new TSquareStatic(); + + staticWidget->LeftBottomPos = posFrom; + staticWidget->Width = posTo.v[0] - posFrom.v[0]; + staticWidget->Height = posTo.v[1] - posFrom.v[1]; + + return staticWidget; + +} + + +TSquareStatic* TSquareStatic::CreateStaticWithFiller(vec2 posFrom, vec2 posTo, boost::function staticFillerFunc) +{ + TSquareStatic* staticWidget = TSquareStatic::CreateStatic(posFrom, posTo); + + staticFillerFunc(staticWidget); + + return staticWidget; +} + + +TSquareStatic* TSquareStatic::CreateStaticWithFillers(vec2 posFrom, vec2 posTo, std::vector> staticFillerFuncArr) +{ + TSquareStatic* staticWidget = TSquareStatic::CreateStatic(posFrom, posTo); + + BOOST_FOREACH(auto& func, staticFillerFuncArr) + { + func(staticWidget); + } + + return staticWidget; +} + + +void TSquareStatic::StaticTextureFiller(vec2 posFrom, vec2 posTo, const std::string& texName, TSquareStatic* staticToFill) +{ + + TRenderParams renderParams; + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = texName; + renderParams.FloatMap[CONST_STRING_TRANSPARENCY_UNIFORM] = 1.f; + + TTriangleList triangleList = MakeTriangleList(posFrom, posTo); + + triangleList.RefreshBuffer(); + + staticToFill->TriangleListVector.insert(staticToFill->TriangleListVector.end(), TRenderPair(renderParams, triangleList)); +} + +void TSquareStatic::StaticTextFiller(vec2 posFrom, vec2 posTo, TTextParams buttonTextParams, TSquareStatic* staticToFill) +{ + + TRenderParams renderParams = buttonTextParams.RenderParams; + + TTriangleList triangleList; + + if (buttonTextParams.FontName == "") + { + buttonTextParams.FontName = ResourceManager->FontManager.GetCurrentFontName(); + } + + ResourceManager->FontManager.PushFont(buttonTextParams.FontName); + + triangleList = CreateTriangleListForText(posFrom, posTo, buttonTextParams); + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = ResourceManager->FontManager.GetCurrentFontTextureName(); + + staticToFill->TriangleListVector.insert(staticToFill->TriangleListVector.end(),TRenderPair(renderParams, triangleList)); + triangleList.RefreshBuffer(); + + ResourceManager->FontManager.PopFont(); + +} + +TSquareStatic* TSquareStatic::CreateStaticTexture(vec2 posFrom, vec2 posTo, const std::string& texName) +{ + return CreateStaticWithFiller(posFrom, posTo, boost::bind(TSquareStatic::StaticTextureFiller, posFrom, posTo, texName, _1)); + +} + +TSquareStatic* TSquareStatic::CreateStaticText(vec2 posFrom, vec2 posTo, TTextParams buttonTextParams) +{ + return CreateStaticWithFiller(posFrom, posTo, boost::bind(TSquareStatic::StaticTextFiller, posFrom, posTo, buttonTextParams, _1)); +} + + + + +TTriangleList CreateTriangleListForText(vec2 posFrom, vec2 posTo, TTextParams buttonTextParams) +{ + TTriangleList triangleList; + + triangleList = ResourceManager->FontManager.DrawTextInBoxToVBO(posFrom, posTo, buttonTextParams.BasicTextAreaParams, buttonTextParams.Text); + + return triangleList; +} + +//==================================================== + + +TDynamicText::TDynamicText() + : Width(0) + , Height(0) +{ +} + +TDynamicText::~TDynamicText() +{ + if (SmartValueConnection.connected()) + { + SmartValueConnection.disconnect(); + } +} + +bool TDynamicText::CheckClick(vec2 mousePos) +{ + if (mousePos.v[0] >= LeftBottomPos.v[0] && + mousePos.v[0] <= LeftBottomPos.v[0] + Width && + mousePos.v[1] >= LeftBottomPos.v[1] && + mousePos.v[1] <= LeftBottomPos.v[1] + Height) + { + return true; + } + else + { + return false; + } +} + +void TDynamicText::UpdateText(std::string text) +{ + if (LastTextParams.Text != text) + { + LastTextParams.Text = text; + + vec2 posFrom = LeftBottomPos; + vec2 posTo = LeftBottomPos + vec2(Width, Height); + + TextRenderPairItr->second = CreateTriangleListForText(posFrom, posTo, LastTextParams); + } +} + +TDynamicText* TDynamicText::CreateDynamicText(vec2 posFrom, vec2 posTo) +{ + TDynamicText* dynamicText = new TDynamicText(); + + dynamicText->LeftBottomPos = posFrom; + dynamicText->Width = posTo.v[0] - posFrom.v[0]; + dynamicText->Height = posTo.v[1] - posFrom.v[1]; + + return dynamicText; +} + +TDynamicText* TDynamicText::CreateDynamicTextWithFiller(vec2 posFrom, vec2 posTo, boost::function dynamicTextFillerFunc) +{ + TDynamicText* dynamicText = TDynamicText::CreateDynamicText(posFrom, posTo); + + dynamicTextFillerFunc(dynamicText); + + return dynamicText; +} + +TDynamicText* TDynamicText::CreateDynamicTextWithFillers(vec2 posFrom, vec2 posTo, std::vector> dynamicTextFillerFuncArr) +{ + TDynamicText* dynamicText = TDynamicText::CreateDynamicText(posFrom, posTo); + + BOOST_FOREACH(auto& func, dynamicTextFillerFuncArr) + { + func(dynamicText); + } + + return dynamicText; +} + +void TDynamicText::TextParamsFiller(vec2 posFrom, vec2 posTo, TTextParams textParams, TDynamicText* dynamicTextToFill) +{ + TRenderParams renderParams = textParams.RenderParams; + + TTriangleList triangleList; + + if (textParams.FontName == "") + { + textParams.FontName = ResourceManager->FontManager.GetCurrentFontName(); + } + + ResourceManager->FontManager.PushFont(textParams.FontName); + + triangleList = CreateTriangleListForText(posFrom, posTo, textParams); + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = ResourceManager->FontManager.GetCurrentFontTextureName(); + + dynamicTextToFill->TextRenderPairItr = dynamicTextToFill->TriangleListVector.insert(dynamicTextToFill->TriangleListVector.end(),TRenderPair(renderParams, triangleList)); + triangleList.RefreshBuffer(); + + ResourceManager->FontManager.PopFont(); + + + dynamicTextToFill->LastTextParams = textParams; +} + +void TDynamicText::SmartValueTextFiller(const std::string& dictionaryName, const std::string& smartValueName, TDynamicText* dynamicTextToFill) +{ + + dynamicTextToFill->UpdateText(ResourceManager->SmartValueManager.GetImmediateValue(dictionaryName, smartValueName)); + + dynamicTextToFill->SmartValueConnection = ResourceManager->SmartValueManager.GetSignal(dictionaryName, smartValueName).connect(boost::bind(&TDynamicText::UpdateText, dynamicTextToFill, _1)); + +} + + + + + + +//======================================================= + + +TUniversalButton::TUniversalButton() + : ButtonState(BS_NORMAL) + , ButtonStateTimer(0.f) +{ +} + + + +void TUniversalButton::Update(cardinal dt) +{ + if (ButtonState == BS_GO_PRESSED) + { + ButtonStateTimer += dt; + if (ButtonStateTimer >= CONST_BUTTON_HIGHLIGHT_TIME) + { + ButtonStateTimer = CONST_BUTTON_HIGHLIGHT_TIME; + ButtonState = BS_PRESSED; + } + } + else if (ButtonState == BS_GO_NORMAL) + { + ButtonStateTimer -= dt; + if (ButtonStateTimer <= 0) + { + ButtonStateTimer = 0; + ButtonState = BS_NORMAL; + } + } + + for (std::vector::iterator i = PressedTextureIteratorArr.begin(); i != PressedTextureIteratorArr.end(); ++i) + { + (*i)->first.FloatMap[CONST_STRING_TRANSPARENCY_UNIFORM] = (ButtonStateTimer+0.f) / CONST_BUTTON_HIGHLIGHT_TIME; + } + + +} + + +bool TUniversalButton::CheckClick(vec2 mousePos) +{ + if (mousePos.v[0] >= LeftBottomPos.v[0] && + mousePos.v[0] <= LeftBottomPos.v[0] + Width && + mousePos.v[1] >= LeftBottomPos.v[1] && + mousePos.v[1] <= LeftBottomPos.v[1] + Height) + { + return true; + } + else + { + return false; + } +} + +void TUniversalButton::OnTapDown(vec2 pos) +{ + if (ButtonState == BS_NORMAL || ButtonState == BS_GO_NORMAL) + { + ButtonState = BS_GO_PRESSED; + } + +} + +void TUniversalButton::OnTapUp(vec2 pos) +{ + if (ButtonState == BS_PRESSED || ButtonState == BS_GO_PRESSED) + { + ButtonState = BS_GO_NORMAL; + } + +} + +void TUniversalButton::OnMoveOut() +{ + if (ButtonState == BS_PRESSED || ButtonState == BS_GO_PRESSED) + { + + ButtonState = BS_GO_NORMAL; + } +} + +TUniversalButton* TUniversalButton::CreateButton(vec2 posFrom, vec2 posTo) +{ + TUniversalButton* button = new TUniversalButton(); + + button->LeftBottomPos = posFrom; + + button->Width = posTo.v[0] - posFrom.v[0]; + + button->Height = posTo.v[1] - posFrom.v[1]; + + return button; +} + +TUniversalButton* TUniversalButton::CreateButtonWithFiller(vec2 posFrom, vec2 posTo, boost::function buttonFillerFunc) +{ + + TUniversalButton* button = TUniversalButton::CreateButton(posFrom, posTo); + + buttonFillerFunc(button); + + return button; +} + +TUniversalButton* TUniversalButton::CreateButtonWithFillers(vec2 posFrom, vec2 posTo, std::vector > buttonFillerFuncArr) +{ + TUniversalButton* button = TUniversalButton::CreateButton(posFrom, posTo); + + for (std::vector >::iterator funcItr = buttonFillerFuncArr.begin(); funcItr != buttonFillerFuncArr.end(); ++funcItr) + { + (*funcItr)(button); + } + + return button; +} + +void TUniversalButton::SquareButtonFiller(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNamePressed, TUniversalButton* buttonToFill) +{ + + TRenderParams renderParams; + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = texName; + renderParams.FloatMap[CONST_STRING_TRANSPARENCY_UNIFORM] = 1.f; + + TTriangleList triangleList = MakeTriangleList(posFrom, posTo); + + triangleList.RefreshBuffer(); + + buttonToFill->NormalTextureIteratorArr.push_back(buttonToFill->TriangleListVector.insert(buttonToFill->TriangleListVector.end(), TRenderPair(renderParams, triangleList))); + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = texNamePressed; + renderParams.FloatMap[CONST_STRING_TRANSPARENCY_UNIFORM] = 0.f; + + buttonToFill->PressedTextureIteratorArr.push_back(buttonToFill->TriangleListVector.insert(buttonToFill->TriangleListVector.end(),TRenderPair(renderParams, triangleList))); + +} + + +void TUniversalButton::TextButtonFiller(vec2 posFrom, vec2 posTo, TTextParams buttonTextParamsNormal, TTextParams buttonTextParamsPressed, TUniversalButton* buttonToFill) +{ + + + + TTriangleList triangleList; + + if (buttonTextParamsNormal.FontName == "") + { + buttonTextParamsNormal.FontName = ResourceManager->FontManager.GetCurrentFontName(); + } + + if (buttonTextParamsPressed.FontName == "") + { + buttonTextParamsPressed.FontName = ResourceManager->FontManager.GetCurrentFontName(); + } + + + + TRenderParams renderParams = buttonTextParamsNormal.RenderParams; + + ResourceManager->FontManager.PushFont(buttonTextParamsNormal.FontName); + + triangleList = CreateTriangleListForText(posFrom, posTo, buttonTextParamsNormal); + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = ResourceManager->FontManager.GetCurrentFontTextureName(); + renderParams.FloatMap[CONST_STRING_TRANSPARENCY_UNIFORM] = 1.f; + + + buttonToFill->NormalTextureIteratorArr.push_back(buttonToFill->TriangleListVector.insert(buttonToFill->TriangleListVector.end(),TRenderPair(renderParams, triangleList))); + triangleList.RefreshBuffer(); + ResourceManager->FontManager.PopFont(); + + + renderParams = buttonTextParamsPressed.RenderParams; + + ResourceManager->FontManager.PushFont(buttonTextParamsPressed.FontName); + + triangleList = CreateTriangleListForText(posFrom, posTo, buttonTextParamsPressed); + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = ResourceManager->FontManager.GetCurrentFontTextureName(); + renderParams.FloatMap[CONST_STRING_TRANSPARENCY_UNIFORM] = 0.f; + + + buttonToFill->PressedTextureIteratorArr.push_back(buttonToFill->TriangleListVector.insert(buttonToFill->TriangleListVector.end(),TRenderPair(renderParams, triangleList))); + triangleList.RefreshBuffer(); + ResourceManager->FontManager.PopFont(); + +} + +TUniversalButton* TUniversalButton::CreateSquareButton(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNamePressed) +{ + return CreateButtonWithFiller(posFrom, posTo, boost::bind(TUniversalButton::SquareButtonFiller, posFrom, posTo, texName, texNamePressed, _1)); +} + +TUniversalButton* TUniversalButton::CreateTextOnlyButton(vec2 posFrom, vec2 posTo, TTextParams buttonTextParamsNormal, TTextParams buttonTextParamsPressed) +{ + return CreateButtonWithFiller(posFrom, posTo, boost::bind(TUniversalButton::TextButtonFiller, posFrom, posTo, buttonTextParamsNormal, buttonTextParamsPressed, _1)); +} + +TUniversalButton* TUniversalButton::CreateSquareAndTextButton(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNamePressed, TTextParams buttonTextParamsNormal, TTextParams buttonTextParamsPressed) +{ + + std::vector > funcIter; + + funcIter.push_back(boost::bind(TUniversalButton::SquareButtonFiller, posFrom, posTo, texName, texNamePressed, _1)); + funcIter.push_back(boost::bind(TUniversalButton::TextButtonFiller, posFrom, posTo, buttonTextParamsNormal, buttonTextParamsPressed, _1)); + + TUniversalButton* universalButton = CreateButtonWithFillers(posFrom, posTo, funcIter); + + return universalButton; +} + + +TEdit* TEdit::CreateEdit(vec2 posFrom, vec2 posTo) +{ + TEdit* edit = new TEdit(); + + edit->LeftBottomPos = posFrom; + + edit->Width = posTo.v[0] - posFrom.v[0]; + + edit->Height = posTo.v[1] - posFrom.v[1]; + + return edit; +} + +TEdit* TEdit::CreateEditWithFiller(vec2 posFrom, vec2 posTo, boost::function fillerFunc) +{ + TEdit* edit = CreateEdit(posFrom, posTo); + + fillerFunc(edit); + + return edit; +} + +TEdit* TEdit::CreateEditWithFillers(vec2 posFrom, vec2 posTo, std::vector > fillerFuncArr) +{ + TEdit* edit = CreateEdit(posFrom, posTo); + + BOOST_FOREACH(auto& f, fillerFuncArr) + { + f(edit); + } + + return edit; +} + +void TEdit::EditFiller(vec2 posFrom, vec2 posTo, const std::string& texName, TTextParams textParams, TEdit* edit) +{ + TRenderParams renderParams = textParams.RenderParams; + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = texName; + + TTriangleList triangleList = MakeTriangleList(posFrom, posTo); + + triangleList.RefreshBuffer(); + + edit->TriangleListVector.insert(edit->TriangleListVector.end(), TRenderPair(renderParams, triangleList)); + + + if (textParams.FontName == "") + { + textParams.FontName = ResourceManager->FontManager.GetCurrentFontName(); + } + + ResourceManager->FontManager.PushFont(textParams.FontName); + + triangleList = CreateTriangleListForText(posFrom, posTo, textParams); + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = ResourceManager->FontManager.GetCurrentFontTextureName(); + + edit->TextIterator = (edit->TriangleListVector.insert(edit->TriangleListVector.end(),TRenderPair(renderParams, triangleList))); + triangleList.RefreshBuffer(); + ResourceManager->FontManager.PopFont(); + + + edit->TextParams = textParams; + +} + +void TEdit::SmartValueTextFiller(const std::string& dictionaryName, const std::string& smartValueName, TEdit* edit) +{ + edit->SetText(ResourceManager->SmartValueManager.GetImmediateValue(dictionaryName, smartValueName)); + + edit->SetTextSlotConnection = ResourceManager->SmartValueManager.GetSignal(dictionaryName, smartValueName).connect(boost::bind(&TEdit::SetText, edit, _1)); + + edit->OnTextChanged.connect + ( + [dictionaryName, smartValueName](std::string text) + { + if (ResourceManager->SmartValueManager.GetImmediateValue(dictionaryName, smartValueName) != text) + { + ResourceManager->SmartValueManager.SetImmediateValue(dictionaryName, smartValueName, text); + } + } + ); +} + +/* +TEdit* TEdit::CreateEdit(vec2 posFrom, vec2 posTo, const std::string& texName, TTextParams textParams) +{ + + + //Filler: + + TRenderParams renderParams = textParams.RenderParams; + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = texName; + + TTriangleList triangleList = MakeTriangleList(posFrom, posTo); + + triangleList.RefreshBuffer(); + + edit->TriangleListVector.insert(edit->TriangleListVector.end(), TRenderPair(renderParams, triangleList)); + + + if (textParams.FontName == "") + { + textParams.FontName = ResourceManager->FontManager.GetCurrentFontName(); + } + + ResourceManager->FontManager.PushFont(textParams.FontName); + + triangleList = CreateTriangleListForText(posFrom, posTo, textParams); + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = ResourceManager->FontManager.GetCurrentFontTextureName(); + + edit->TextIterator = (edit->TriangleListVector.insert(edit->TriangleListVector.end(),TRenderPair(renderParams, triangleList))); + triangleList.RefreshBuffer(); + ResourceManager->FontManager.PopFont(); + + return edit; +}*/ + +TEdit::~TEdit() +{ + if (InputConnection.connected()) + { + InputConnection.disconnect(); + } + + if (SetTextSlotConnection.connected()) + { + SetTextSlotConnection.disconnect(); + } +} + +void TEdit::RefreshTextTriangleList() +{ + TTriangleList triangleList = CreateTriangleListForText(LeftBottomPos, LeftBottomPos + vec2(Width, Height), TextParams); + + TextIterator->second = triangleList; + +} + +bool TEdit::CheckClick(vec2 mousePos) +{ + if (mousePos.v[0] >= LeftBottomPos.v[0] && + mousePos.v[0] <= LeftBottomPos.v[0] + Width && + mousePos.v[1] >= LeftBottomPos.v[1] && + mousePos.v[1] <= LeftBottomPos.v[1] + Height) + { + return true; + } + else + { + return false; + } +} + +void TEdit::OnTapDown(vec2 pos) +{ + if (!InputConnection.connected()) + { + ResourceManager->GUIManager.KeyPressedSignal.disconnect_all_slots(); + InputConnection = ResourceManager->GUIManager.KeyPressedSignal.connect(boost::bind(&TEdit::OnKeyPress, this, _1)); + } +} + +void TEdit::OnKeyPress(int key) +{ + if (key == 8) //Backspace + { + if (TextParams.Text.size() > 0) + { + TextParams.Text.erase(TextParams.Text.end()-1); + } + } + else if (key >= 32 && key <= 255) //ASCII + { + TextParams.Text += static_cast(key); + } + + OnTextChanged(TextParams.Text); + + RefreshTextTriangleList(); +} + +void TEdit::SetText(const std::string& newText) +{ + if (newText != TextParams.Text) + { + TextParams.Text = newText; + + OnTextChanged(TextParams.Text); + + RefreshTextTriangleList(); + } +} + + +//============================ Check Box ============================ + + +TCheckBox::TCheckBox() + : IsChecked(false) + , Width(0.f) + , Height(0.f) +{ +} + +TCheckBox::~TCheckBox() +{ + + if (SetCheckedSlotConnection.connected()) + { + SetCheckedSlotConnection.disconnect(); + } +} + +void TCheckBox::SetChecked(bool isChecked) +{ + + if (isChecked == IsChecked) + { + return; //This prevent recursion + } + + + if (!IsChecked) + { + IsChecked = true; + + OnSetChecked(IsChecked); + + RefreshVisibility(); + } + else + { + IsChecked = false; + + OnSetChecked(IsChecked); + + RefreshVisibility(); + } +} + +void TCheckBox::RefreshVisibility() +{ + + //IsChecked + if (IsChecked) + { + for (std::vector::iterator i = CheckedTextureIteratorArr.begin(); i != CheckedTextureIteratorArr.end(); ++i) + { + (*i)->first.FloatMap[CONST_STRING_TRANSPARENCY_UNIFORM] = 1.f; + } + } + else + { + for (std::vector::iterator i = CheckedTextureIteratorArr.begin(); i != CheckedTextureIteratorArr.end(); ++i) + { + (*i)->first.FloatMap[CONST_STRING_TRANSPARENCY_UNIFORM] = 0.f; + } + } +} + +bool TCheckBox::CheckClick(vec2 mousePos) +{ + if (mousePos.v[0] >= LeftBottomPos.v[0] && + mousePos.v[0] <= LeftBottomPos.v[0] + Width && + mousePos.v[1] >= LeftBottomPos.v[1] && + mousePos.v[1] <= LeftBottomPos.v[1] + Height) + { + return true; + } + else + { + return false; + } +} + +void TCheckBox::Update(cardinal dt) +{ +} + +void TCheckBox::OnTapDown(vec2 pos) +{ +} + +void TCheckBox::OnTapUp(vec2 pos) +{ + SetChecked(!IsChecked); +} + +void TCheckBox::OnMoveOut() +{ +} + + +TCheckBox* TCheckBox::CreateCheckBox(vec2 posFrom, vec2 posTo) +{ + TCheckBox* checkBox = new TCheckBox(); + + checkBox->LeftBottomPos = posFrom; + + checkBox->Width = posTo.v[0] - posFrom.v[0]; + + checkBox->Height = posTo.v[1] - posFrom.v[1]; + + return checkBox; +} + +TCheckBox* TCheckBox::CreateCheckBoxWithFiller(vec2 posFrom, vec2 posTo, boost::function checkBoxFillerFunc) +{ + TCheckBox* checkBox = TCheckBox::CreateCheckBox(posFrom, posTo); + + checkBoxFillerFunc(checkBox); + + return checkBox; +} + +TCheckBox* TCheckBox::CreateCheckBoxWithFillers(vec2 posFrom, vec2 posTo, std::vector > checkBoxFillerFuncArr) +{ + TCheckBox* checkBox = TCheckBox::CreateCheckBox(posFrom, posTo); + + BOOST_FOREACH(boost::function& fillerFunc, checkBoxFillerFuncArr) + { + fillerFunc(checkBox); + } + + return checkBox; +} + +void TCheckBox::TextureFiller(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNameChecked, TCheckBox* checkBoxToFill) +{ + + TRenderParams renderParams; + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = texName; + renderParams.FloatMap[CONST_STRING_TRANSPARENCY_UNIFORM] = 1.f; + + TTriangleList triangleList = MakeTriangleList(posFrom, posTo); + + triangleList.RefreshBuffer(); + + + checkBoxToFill->StaticTextureIteratorArr.push_back(checkBoxToFill->TriangleListVector.insert(checkBoxToFill->TriangleListVector.end(), TRenderPair(renderParams, triangleList))); + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = texNameChecked; + renderParams.FloatMap[CONST_STRING_TRANSPARENCY_UNIFORM] = 0.f; + + checkBoxToFill->CheckedTextureIteratorArr.push_back(checkBoxToFill->TriangleListVector.insert(checkBoxToFill->TriangleListVector.end(),TRenderPair(renderParams, triangleList))); + +} + +void TCheckBox::TextFiller(vec2 posFrom, vec2 posTo, TTextParams textParams, TCheckBox* checkBoxToFill) +{ + + TRenderParams renderParams = textParams.RenderParams; + + TTriangleList triangleList; + + if (textParams.FontName == "") + { + textParams.FontName = ResourceManager->FontManager.GetCurrentFontName(); + } + + ResourceManager->FontManager.PushFont(textParams.FontName); + + triangleList = CreateTriangleListForText(posFrom, posTo, textParams); + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = ResourceManager->FontManager.GetCurrentFontTextureName(); + + checkBoxToFill->StaticTextureIteratorArr.push_back(checkBoxToFill->TriangleListVector.insert(checkBoxToFill->TriangleListVector.end(),TRenderPair(renderParams, triangleList))); + triangleList.RefreshBuffer(); + ResourceManager->FontManager.PopFont(); + +} + +void TCheckBox::CheckedFiller(bool isChecked, TCheckBox* checkBoxToFill) +{ + checkBoxToFill->SetChecked(isChecked); +} + +void TCheckBox::SmartValueFiller(const std::string& dictionaryName, const std::string& smartValueName, TCheckBox* checkBoxToFill) +{ + + checkBoxToFill->SetChecked(ResourceManager->SmartValueManager.GetImmediateValue(dictionaryName, smartValueName)); + + checkBoxToFill->SetCheckedSlotConnection = ResourceManager->SmartValueManager.GetSignal(dictionaryName, smartValueName).connect(boost::bind(&TCheckBox::SetChecked, checkBoxToFill, _1)); + + checkBoxToFill->OnSetChecked.connect + ( + [dictionaryName, smartValueName](bool checked) + { + if (ResourceManager->SmartValueManager.GetImmediateValue(dictionaryName, smartValueName) != checked) + { + ResourceManager->SmartValueManager.SetImmediateValue(dictionaryName, smartValueName, checked); + } + } + ); +} + + +TCheckBox* TCheckBox::CreateSimpleCheckBox(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNameChecked) +{ + return CreateCheckBoxWithFiller(posFrom, posTo, boost::bind(&TCheckBox::TextureFiller, posFrom, posTo, texName, texNameChecked, _1)); +} + +TCheckBox* TCheckBox::CreateCheckBoxWithText(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNameChecked, vec2 textPosFrom, vec2 textPosTo, TTextParams textParams) +{ + TCheckBox* checkBox = CreateCheckBox(posFrom, posTo); + + TCheckBox::TextureFiller(posFrom, posTo, texName, texNameChecked, checkBox); + TCheckBox::TextFiller(textPosFrom, textPosTo, textParams, checkBox); + + return checkBox; +} + + +//============================ Radio Button ============================ + + +TRadioButton::TRadioButton() + : IsChecked(false) + , Width(0.f) + , Height(0.f) +{ +} + +TRadioButton::~TRadioButton() +{ + + if (SetCheckedSlotConnection.connected()) + { + SetCheckedSlotConnection.disconnect(); + } +} + +void TRadioButton::SetChecked(bool isChecked) +{ + + if (isChecked == IsChecked) + { + return; //This prevent recursion + } + + IsChecked = isChecked; + + OnSetChecked(IsChecked); + + RefreshVisibility(); +} + +void TRadioButton::RefreshVisibility() +{ + + //IsChecked + if (IsChecked) + { + for (std::vector::iterator i = CheckedTextureIteratorArr.begin(); i != CheckedTextureIteratorArr.end(); ++i) + { + (*i)->first.FloatMap[CONST_STRING_TRANSPARENCY_UNIFORM] = 1.f; + } + } + else + { + for (std::vector::iterator i = CheckedTextureIteratorArr.begin(); i != CheckedTextureIteratorArr.end(); ++i) + { + (*i)->first.FloatMap[CONST_STRING_TRANSPARENCY_UNIFORM] = 0.f; + } + } +} + +bool TRadioButton::CheckClick(vec2 mousePos) +{ + if (mousePos.v[0] >= LeftBottomPos.v[0] && + mousePos.v[0] <= LeftBottomPos.v[0] + Width && + mousePos.v[1] >= LeftBottomPos.v[1] && + mousePos.v[1] <= LeftBottomPos.v[1] + Height) + { + return true; + } + else + { + return false; + } +} + +void TRadioButton::Update(cardinal dt) +{ +} + +void TRadioButton::OnTapDown(vec2 pos) +{ +} + +void TRadioButton::OnTapUp(vec2 pos) +{ + SetChecked(true); +} + +void TRadioButton::OnMoveOut() +{ +} + + +TRadioButton* TRadioButton::CreateRadioButton(vec2 posFrom, vec2 posTo) +{ + TRadioButton* radioButton = new TRadioButton(); + + radioButton->LeftBottomPos = posFrom; + + radioButton->Width = posTo.v[0] - posFrom.v[0]; + + radioButton->Height = posTo.v[1] - posFrom.v[1]; + + return radioButton; +} + +TRadioButton* TRadioButton::CreateRadioButtonWithFiller(vec2 posFrom, vec2 posTo, boost::function radioButtonFillerFunc) +{ + TRadioButton* radioButton = TRadioButton::CreateRadioButton(posFrom, posTo); + + radioButtonFillerFunc(radioButton); + + return radioButton; +} + +TRadioButton* TRadioButton::CreateRadioButtonWithFillers(vec2 posFrom, vec2 posTo, std::vector > radioButtonFillerFuncArr) +{ + TRadioButton* radioButton = TRadioButton::CreateRadioButton(posFrom, posTo); + + BOOST_FOREACH(boost::function& fillerFunc, radioButtonFillerFuncArr) + { + fillerFunc(radioButton); + } + + return radioButton; +} + +void TRadioButton::TextureFiller(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNameChecked, TRadioButton* radioButtonToFill) +{ + + TRenderParams renderParams; + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = texName; + renderParams.FloatMap[CONST_STRING_TRANSPARENCY_UNIFORM] = 1.f; + + TTriangleList triangleList = MakeTriangleList(posFrom, posTo); + + triangleList.RefreshBuffer(); + + + radioButtonToFill->StaticTextureIteratorArr.push_back(radioButtonToFill->TriangleListVector.insert(radioButtonToFill->TriangleListVector.end(), TRenderPair(renderParams, triangleList))); + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = texNameChecked; + renderParams.FloatMap[CONST_STRING_TRANSPARENCY_UNIFORM] = 0.f; + + radioButtonToFill->CheckedTextureIteratorArr.push_back(radioButtonToFill->TriangleListVector.insert(radioButtonToFill->TriangleListVector.end(),TRenderPair(renderParams, triangleList))); + +} + +void TRadioButton::TextFiller(vec2 posFrom, vec2 posTo, TTextParams textParams, TRadioButton* radioButtonToFill) +{ + + TRenderParams renderParams = textParams.RenderParams; + + TTriangleList triangleList; + + if (textParams.FontName == "") + { + textParams.FontName = ResourceManager->FontManager.GetCurrentFontName(); + } + + ResourceManager->FontManager.PushFont(textParams.FontName); + + triangleList = CreateTriangleListForText(posFrom, posTo, textParams); + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = ResourceManager->FontManager.GetCurrentFontTextureName(); + renderParams.FloatMap[CONST_STRING_TRANSPARENCY_UNIFORM] = 1.f; + + + radioButtonToFill->StaticTextureIteratorArr.push_back(radioButtonToFill->TriangleListVector.insert(radioButtonToFill->TriangleListVector.end(),TRenderPair(renderParams, triangleList))); + triangleList.RefreshBuffer(); + ResourceManager->FontManager.PopFont(); + +} + +void TRadioButton::CheckedFiller(bool isChecked, TRadioButton* radioButtonToFill) +{ + radioButtonToFill->SetChecked(isChecked); +} + +TRadioButton* TRadioButton::CreateSimpleRadioButton(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNameChecked) +{ + return CreateRadioButtonWithFiller(posFrom, posTo, boost::bind(&TRadioButton::TextureFiller, posFrom, posTo, texName, texNameChecked, _1)); +} + +TRadioButton* TRadioButton::CreateRadioButtonWithText(vec2 posFrom, vec2 posTo, const std::string& texName, const std::string& texNameChecked, vec2 textPosFrom, vec2 textPosTo, TTextParams textParams) +{ + TRadioButton* radioButton = CreateRadioButton(posFrom, posTo); + + TRadioButton::TextureFiller(posFrom, posTo, texName, texNameChecked, radioButton); + TRadioButton::TextFiller(textPosFrom, textPosTo, textParams, radioButton); + + return radioButton; +} + + + + +//====================== Mover ===================== + + + + + +TMover::TMover() + : Width(0) + , Height(0) + , PosCursor(0) +{ +} + + +TMover::~TMover() +{ +} + +void TMover::Update(cardinal dt) +{ +} + +bool TMover::CheckClick(vec2 mousePos) +{ + if (mousePos.v[0] >= LeftBottomPos.v[0] && + mousePos.v[0] <= LeftBottomPos.v[0] + Width && + mousePos.v[1] >= LeftBottomPos.v[1] && + mousePos.v[1] <= LeftBottomPos.v[1] + Height) + { + return true; + } + else + { + return false; + } +} + +void TMover::OnTapDown(vec2 pos) +{ +} + +void TMover::OnTapUp(vec2 pos) +{ +} + +void TMover::OnMove(vec2 shift) +{ + float oldPosCursor = PosCursor; + PosCursor -= shift.v[1]; + + if (PosCursor < 0) + { + PosCursor = 0; + } + + if (PosCursor > MaxHeight - Height) + { + PosCursor = MaxHeight - Height; + } + + float shift_y = PosCursor - oldPosCursor; + + if (shift_y != 0) + { + ResourceManager->GUIManager.MoveWidgetGroup(GroupName, SelfName, vec2(0, shift_y)); + } +} + +void TMover::OnMoveOut() +{ +} + + +TMover* TMover::CreateMover(vec2 posFrom, vec2 posTo, std::string groupName, std::string selfName, float maxHeight) +{ + TMover* mover = new TMover(); + + mover->LeftBottomPos = posFrom; + + mover->Width = posTo.v[0] - posFrom.v[0]; + + mover->Height = posTo.v[1] - posFrom.v[1]; + + mover->GroupName = groupName; + + mover->SelfName = selfName; + + mover->MaxHeight = maxHeight; + + return mover; +} + +} //namespace SE \ No newline at end of file diff --git a/src/GUIManager/GUIManager.cpp b/src/GUIManager/GUIManager.cpp new file mode 100644 index 0000000..06e94c8 --- /dev/null +++ b/src/GUIManager/GUIManager.cpp @@ -0,0 +1,415 @@ +#include "include/Engine.h" + +namespace SE +{ + +const std::string CONST_HOLD_SIGNAL_NAME = "OnHold"; +const std::string CONST_CLICK_SIGNAL_NAME = "OnClick"; +const std::string CONST_DRAG_SIGNAL_NAME = "OnDrag"; + + +TGUIManager::~TGUIManager() +{ + + WidgetTrasfromTaskList.clear(); + + WidgetArr.clear(); + + *Console<<"GUI Manager deleting..."; +} + + +void TGUIManager::AddWidget(std::shared_ptr widgetAncestor, const std::string& name, const std::string& groupName, int order) +{ + for (TWidgetArr::iterator i = WidgetArr.begin(); i != WidgetArr.end(); i++) + { + if (i->Name == name) + { + return; + } + } + WidgetArr.push_back(TWidgetStruct(name, groupName, widgetAncestor, order)); + std::stable_sort(WidgetArr.begin(), WidgetArr.end()); +} + +void TGUIManager::DeleteWidget(std::string name) +{ + for (TWidgetArr::iterator i = WidgetArr.begin(); i != WidgetArr.end(); i++) + { + if (i->Name == name) + { + WidgetArr.erase(i); + return; + } + } +} + +void TGUIManager::DeleteWidgetGroup(std::string groupName) +{ + bool widgetErased; + for (TWidgetArr::iterator i = WidgetArr.begin(); i != WidgetArr.end();) + { + widgetErased = false; + if (i->GroupName == groupName) + { + i = WidgetArr.erase(i); + widgetErased = true; + } + + if (i != WidgetArr.end() & !widgetErased) + { + ++i; + } + } +} + +void TGUIManager::DeleteWidgetOnUpdate(const std::string& name) +{ + PostUpdateSignal.connect(boost::bind(&TGUIManager::DeleteWidget, this, name)); +} + +void TGUIManager::DeleteWidgetGroupOnUpdate(const std::string& groupName) +{ + PostUpdateSignal.connect(boost::bind(&TGUIManager::DeleteWidgetGroup, this, groupName)); +} + + + +void TGUIManager::AddWidgetTransformTask(TWidgetTransformTask widgetTransformTask) +{ + WidgetTrasfromTaskList.push_back(widgetTransformTask); +} + +void TGUIManager::Update(cardinal dt) +{ + + WidgetListMutex.lock(); + + for (TWidgetArr::iterator i = WidgetArr.begin(); i != WidgetArr.end(); ++i) + { + i->Widget->Update(dt); + + if (i->IsMouseDown) + { + (*(i->SignalMap[CONST_HOLD_SIGNAL_NAME]))(TSignalParam(dt)); + + } + + for (TRenderPairList::iterator itr = i->Widget->TriangleListVector.begin(); itr != i->Widget->TriangleListVector.end(); ++itr) + { + if (itr->second.NeedRefreshBuffer) + { + itr->second.RefreshBuffer(); + itr->second.NeedRefreshBuffer = false; + } + } + } + + for (TWidgetTrasfromTaskList::iterator i = WidgetTrasfromTaskList.begin(); i != WidgetTrasfromTaskList.end(); ) + { + int prevCurrentTime = i->CurrentTime; + + i->CurrentTime += dt; + + if (i->CurrentTime >= i->TotalTime) + { + i->CurrentTime = i->TotalTime; + } + + vec2 oldPos; + vec2 newPos; + + float t0 = clamp((prevCurrentTime + 0.f)/i->TotalTime, 0, 1); + float t = clamp((i->CurrentTime + 0.f)/i->TotalTime, 0, 1); + + if (i->MoveStyle == TWidgetTransformTask::MS_LINEAR) + { + oldPos = InterpolateLinear(vec2(0,0), i->PosTo, t0); + newPos = InterpolateLinear(vec2(0,0), i->PosTo, t); + } + if (i->MoveStyle == TWidgetTransformTask::MS_SQR) + { + oldPos = InterpolateSqr(vec2(0,0), i->PosTo, t0); + newPos = InterpolateSqr(vec2(0,0), i->PosTo, t); + } + if (i->MoveStyle == TWidgetTransformTask::MS_SQRT) + { + oldPos = InterpolateSqrt(vec2(0,0), i->PosTo, t0); + newPos = InterpolateSqrt(vec2(0,0), i->PosTo, t); + } + + vec2 moveDistance = newPos - oldPos; + + for (TWidgetArr::iterator j = WidgetArr.begin(); j != WidgetArr.end(); ++j) + { + if (j->GroupName == i->GroupName) + { + MoveWidgetByIterator(j, moveDistance); + } + } + + + if (i->CurrentTime == i->TotalTime) + { + i = WidgetTrasfromTaskList.erase(i); + } + else + { + ++i; + } + } + + WidgetListMutex.unlock(); + + PostUpdateSignal(); + + PostUpdateSignal.disconnect_all_slots(); +} + +void TGUIManager::Draw() +{ + + TWidgetArr::iterator i; + for (i = WidgetArr.begin(); i != WidgetArr.end(); ++i) + { + + TRenderPairList::iterator j; + + for (j = i->Widget->TriangleListVector.begin(); j != i->Widget->TriangleListVector.end(); ++j) + { + + TRenderParamsSetter paramSetter(j->first); + + Renderer->DrawTriangleList(j->second); + + CheckGlError("TGUIManager::Draw()"); + + } + } +} + +TWidgetArr::iterator TGUIManager::FindWidgetInArr(const std::string& widgetName) +{ + TWidgetArr::iterator i; + + for (i = WidgetArr.begin(); i != WidgetArr.end(); ++i) + { + if (i->Name == widgetName) + { + break; + } + } + + if (i == WidgetArr.end()) + { + throw ErrorToLog("ERROR: widget not found: "+widgetName); + } + + return i; +} + +void TGUIManager::MoveWidgetByIterator(TWidgetArr::iterator widget, vec2 shift) +{ + widget->Widget->LeftBottomPos += shift; + + std::vector::iterator i; + + TRenderPairList::iterator itr; + + for (itr = widget->Widget->TriangleListVector.begin(); itr != widget->Widget->TriangleListVector.end(); ++itr) + { + std::vector& vertexCoordVec = itr->second.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB]; + + for (i = vertexCoordVec.begin(); i != vertexCoordVec.end(); ++i) + { + *i += vec3(shift, 0); + } + + itr->second.NeedRefreshBuffer = true; + } +} + +void TGUIManager::MoveWidget(const std::string& widgetName, vec2 shift) +{ + + TWidgetArr::iterator widget = FindWidgetInArr(widgetName); + MoveWidgetByIterator(widget, shift); +} + +void TGUIManager::MoveWidgetGroup(const std::string& widgetGroupName, const std::string& exceptWidget, vec2 shift) +{ + for (TWidgetArr::iterator i = WidgetArr.begin(); i != WidgetArr.end(); ++i) + { + if (i->GroupName == widgetGroupName && i->Name != exceptWidget) + { + MoveWidgetByIterator(i, shift); + } + } +} + +void TGUIManager::OnMouseDown(vec2 pos) +{ + //Xperimental - need to call widget methods and signals NOT IN "FOR" LOOP + + WidgetListMutex.lock(); + + TWidgetArr::reverse_iterator i; + + LastTapPos = pos; + TotalShift = vec2(0,0); + + for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i) + { + if (i->Widget->CheckClick(pos)) + { + bool isTransparentForInput = i->Widget->IsTransparentForInput(); + + i->Widget->OnTapDown(pos); + i->IsMouseDown = true; + + if (! isTransparentForInput) + { + WidgetListMutex.unlock(); + return; + } + } + } + + WidgetListMutex.unlock(); +} + +void TGUIManager::OnMouseUp(vec2 pos) +{ + //Xperimental - need to call widget methods and signals NOT IN "FOR" LOOP + + WidgetListMutex.lock(); + + TWidgetArr::reverse_iterator i; + + for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i) + { + if (i->Widget->CheckClick(pos)) + { + bool isTransparentForInput = i->Widget->IsTransparentForInput(); + i->Widget->OnTapUp(pos); + i->IsMouseDown = false; + (*(i->SignalMap[CONST_CLICK_SIGNAL_NAME]))(TSignalParam(pos)); + + if (! isTransparentForInput) + { + WidgetListMutex.unlock(); + return; + } + } + } + + WidgetListMutex.unlock(); +} + +void TGUIManager::OnMove(vec2 shift) +{ + //Xperimental - need to call widget methods and signals NOT IN "FOR" LOOP + + + TWidgetArr::reverse_iterator i; + + bool moveIsProcessed = false; + bool moveOutIsProcessed = false; + + TotalShift += shift; + + for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i) + { + if (!moveIsProcessed && i->Widget->CheckClick(LastTapPos-TotalShift)) + { + bool isTransparentForInput = i->Widget->IsTransparentForInput(); + + i->Widget->OnMove(shift); + (*(i->SignalMap[CONST_DRAG_SIGNAL_NAME]))(TSignalParam(shift)); + + if (! isTransparentForInput) + { + moveIsProcessed = true; + } + } + } + + for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i) + { + if (!moveOutIsProcessed && i->Widget->CheckClick(LastTapPos) && !i->Widget->CheckClick(LastTapPos-TotalShift)) + { + bool isTransparentForInput = i->Widget->IsTransparentForInput(); + + i->Widget->OnMoveOut(); + i->IsMouseDown = false; + if (! isTransparentForInput) + { + moveOutIsProcessed = true; + } + } + } +} + +void TGUIManager::PrintWidgetList() +{ + TWidgetArr::iterator i; + + for (i = WidgetArr.begin(); i != WidgetArr.end(); ++i) + { + std::string widgetRow = i->Name + " (" + tostr(i->Widget->LeftBottomPos.v[0]) + ", " + tostr(i->Widget->LeftBottomPos.v[1]) + ")"; + Console->PrintImmediate(widgetRow); + } +} + + +std::shared_ptr> TGUIManager::GetOnClickSignal(const std::string& widgetName) +{ + + TWidgetArr::iterator i = FindWidgetInArr(widgetName); + + return i->SignalMap[CONST_CLICK_SIGNAL_NAME]; + +} + +std::shared_ptr> TGUIManager::GetOnHoldSignal(const std::string& widgetName) +{ + + TWidgetArr::iterator i = FindWidgetInArr(widgetName); + + return i->SignalMap[CONST_HOLD_SIGNAL_NAME]; + +} + +std::shared_ptr> TGUIManager::GetSignal(const std::string& signalName, const std::string& widgetName) +{ + + TWidgetArr::iterator i = FindWidgetInArr(widgetName); + + if (i->SignalMap.count(signalName) == 0) + { + throw ErrorToLog("Illegal signal: "+signalName); + } + + return i->SignalMap[signalName]; +} + +void TGUIManager::SQ_MoveWidget(const SQChar *widgetName, float x, float y) +{ + MoveWidget(std::string(widgetName), vec2(x,y)); +} + + +void TGUIManager::BindFunctions() +{ + ResourceManager->ScriptManager.AddFunction("pwl", + TScriptInfo("PrintWidgetList"), + ResourceManager->GUIManager, + &TGUIManager::PrintWidgetList); + + ResourceManager->ScriptManager.AddFunction("mw", + TScriptInfo("MoveWidget"), + ResourceManager->GUIManager, + &TGUIManager::SQ_MoveWidget); +} + +} //namespace SE \ No newline at end of file diff --git a/src/GUIManager/WidgetXmlParsers.cpp b/src/GUIManager/WidgetXmlParsers.cpp new file mode 100644 index 0000000..1eb9964 --- /dev/null +++ b/src/GUIManager/WidgetXmlParsers.cpp @@ -0,0 +1,514 @@ +#include "include/Engine.h" + + +namespace SE +{ + +void TStaticWidgetParser::Serialize(boost::property_tree::ptree& propertyTree) +{ + std::string widgetType = propertyTree.get(".type"); + std::string name = propertyTree.get(".name"); + std::string group = propertyTree.get(".group"); + + float xCenter = propertyTree.get(".xCenter"); + float yCenter = propertyTree.get(".yCenter"); + float width = propertyTree.get(".width"); + float height = propertyTree.get(".height"); + int order = propertyTree.get(".order", 0); + + vec2 posFrom(xCenter - width*0.5f, yCenter - height*0.5f); + vec2 posTo(xCenter + width*0.5f, yCenter + height*0.5f); + + //boost::property_tree::ptree& fillerTree = propertyTree.find("Filler")->second; + + std::vector> fillerFuncArr; + + + BOOST_FOREACH(boost::property_tree::ptree::value_type &v, propertyTree) + { + if (v.first == "Filler") + { + boost::property_tree::ptree& fillerTree = v.second; + + if (fillerTree.get(".type") == "StaticTextureFiller") + { + std::string normTexName = fillerTree.get(".texName"); + + fillerFuncArr.push_back(boost::bind(TSquareStatic::StaticTextureFiller, posFrom, posTo, normTexName, _1)); + + } + else if (fillerTree.get(".type") == "StaticTextFiller") + { + TTextParams textParamsNormal; + + boost::property_tree::ptree& textParamsNormalTree = fillerTree.find("TextParams")->second; + + textParamsNormal.Serialize(textParamsNormalTree); + + fillerFuncArr.push_back(boost::bind(TSquareStatic::StaticTextFiller, posFrom, posTo, textParamsNormal, _1)); + } + } + } + + ResourceManager->GUIManager.AddWidget( + std::shared_ptr(TSquareStatic::CreateStaticWithFillers(posFrom, posTo, fillerFuncArr)), + name, + group, + order); + +} + + +void TDynamicTextWidgetParser::Serialize(boost::property_tree::ptree& propertyTree) +{ + std::string widgetType = propertyTree.get(".type"); + std::string name = propertyTree.get(".name"); + std::string group = propertyTree.get(".group"); + + float xCenter = propertyTree.get(".xCenter"); + float yCenter = propertyTree.get(".yCenter"); + float width = propertyTree.get(".width"); + float height = propertyTree.get(".height"); + int order = propertyTree.get(".order", 0); + + vec2 posFrom(xCenter - width*0.5f, yCenter - height*0.5f); + vec2 posTo(xCenter + width*0.5f, yCenter + height*0.5f); + + //boost::property_tree::ptree& fillerTree = propertyTree.find("Filler")->second; + + std::vector> fillerFuncArr; + + + BOOST_FOREACH(boost::property_tree::ptree::value_type &v, propertyTree) + { + if (v.first == "Filler") + { + boost::property_tree::ptree& fillerTree = v.second; + + if (fillerTree.get(".type") == "TextParamsFiller") + { + TTextParams textParamsNormal; + + boost::property_tree::ptree& textParamsNormalTree = fillerTree.find("TextParams")->second; + + textParamsNormal.Serialize(textParamsNormalTree); + + fillerFuncArr.push_back(boost::bind(TDynamicText::TextParamsFiller, posFrom, posTo, textParamsNormal, _1)); + } + else if (fillerTree.get(".type") == "SmartValueTextFiller") + { + std::string dictionaryName = fillerTree.get(".dictionaryName"); + std::string smartValueName = fillerTree.get(".smartValueName"); + fillerFuncArr.push_back(boost::bind(TDynamicText::SmartValueTextFiller, dictionaryName, smartValueName, _1)); + } + } + } + + ResourceManager->GUIManager.AddWidget( + std::shared_ptr(TDynamicText::CreateDynamicTextWithFillers(posFrom, posTo, fillerFuncArr)), + name, + group, + order); + +} + + + +void TButtonWidgetParser::Serialize(boost::property_tree::ptree& propertyTree) +{ + + std::string widgetType = propertyTree.get(".type"); + std::string name = propertyTree.get(".name"); + std::string group = propertyTree.get(".group"); + + float xCenter = propertyTree.get(".xCenter"); + float yCenter = propertyTree.get(".yCenter"); + float width = propertyTree.get(".width"); + float height = propertyTree.get(".height"); + int order = propertyTree.get(".order", 0); + + vec2 posFrom(xCenter - width*0.5f, yCenter - height*0.5f); + vec2 posTo(xCenter + width*0.5f, yCenter + height*0.5f); + + std::vector > fillerFuncArr; + + BOOST_FOREACH(boost::property_tree::ptree::value_type &v, propertyTree) + { + if (v.first == "Filler") + { + + boost::property_tree::ptree& fillerTree = v.second; + + if (fillerTree.get(".type") == "SquareButtonFiller") + { + std::string normTexName = fillerTree.get(".normTexName"); + std::string pressedTexName = fillerTree.get(".pressedTexName"); + + + fillerFuncArr.push_back(boost::bind(TUniversalButton::SquareButtonFiller, posFrom, posTo, normTexName, pressedTexName, _1)); + + } + else if (fillerTree.get(".type") == "TextButtonFiller") + { + TTextParams textParamsNormal; + TTextParams textParamsPressed; + + boost::property_tree::ptree& textParamsNormalTree = fillerTree.find("TextParamsNormal")->second; + + textParamsNormal.Serialize(textParamsNormalTree); + + boost::property_tree::ptree& textParamsPressedTree = fillerTree.find("TextParamsPressed")->second; + + textParamsPressed.Serialize(textParamsPressedTree); + + fillerFuncArr.push_back(boost::bind(TUniversalButton::TextButtonFiller, posFrom, posTo, textParamsNormal, textParamsPressed, _1)); + + } + } + + } + + ResourceManager->GUIManager.AddWidget( + std::shared_ptr( + TUniversalButton::CreateButtonWithFillers(posFrom, posTo, fillerFuncArr) + ), + name, + group, + order); + +} + + + + +void TEditWidgetParser::Serialize(boost::property_tree::ptree& propertyTree) +{ + std::string widgetType = propertyTree.get(".type"); + std::string name = propertyTree.get(".name"); + std::string group = propertyTree.get(".group"); + + float xCenter = propertyTree.get(".xCenter"); + float yCenter = propertyTree.get(".yCenter"); + float width = propertyTree.get(".width"); + float height = propertyTree.get(".height"); + int order = propertyTree.get(".order", 0); + + vec2 posFrom(xCenter - width*0.5f, yCenter - height*0.5f); + vec2 posTo(xCenter + width*0.5f, yCenter + height*0.5f); + /* + //The only one filler + std::string texName = propertyTree.get("Filler..texName"); + + TTextParams textParams; + + boost::property_tree::ptree& textParamsTree = propertyTree.find("Filler")->second.find("TextParams")->second; + + textParams.Serialize(textParamsTree); + + ResourceManager->GUIManager.AddWidget( + std::shared_ptr(TEdit::CreateEdit(posFrom, posTo, texName, textParams)), + name, + group, + order);*/ + + std::vector> fillerFuncArr; + + BOOST_FOREACH(boost::property_tree::ptree::value_type &v, propertyTree) + { + if (v.first == "Filler") + { + + boost::property_tree::ptree& fillerTree = v.second; + + if (fillerTree.get(".type") == "EditFiller") + { + + std::string texName = fillerTree.get(".texName"); + + TTextParams textParams; + + boost::property_tree::ptree& textParamsTree = fillerTree.find("TextParams")->second; + + textParams.Serialize(textParamsTree); + + fillerFuncArr.push_back(boost::bind(TEdit::EditFiller, posFrom, posTo, texName, textParams, _1)); + + + } + else if (fillerTree.get(".type") == "SmartValueTextFiller") + { + + std::string dictionaryName = fillerTree.get(".dictionaryName"); + std::string smartValueName = fillerTree.get(".smartValueName"); + fillerFuncArr.push_back(boost::bind(TEdit::SmartValueTextFiller, dictionaryName, smartValueName, _1)); + + } + } + + } + + ResourceManager->GUIManager.AddWidget( + std::shared_ptr( + TEdit::CreateEditWithFillers(posFrom, posTo, fillerFuncArr) + ), + name, + group, + order); +} + + + + + +void TCheckBoxWidgetParser::Serialize(boost::property_tree::ptree& propertyTree) +{ + std::string widgetType = propertyTree.get(".type"); + std::string name = propertyTree.get(".name"); + std::string group = propertyTree.get(".group"); + + float xCenter = propertyTree.get(".xCenter"); + float yCenter = propertyTree.get(".yCenter"); + float width = propertyTree.get(".width"); + float height = propertyTree.get(".height"); + int order = propertyTree.get(".order", 0); + + vec2 posFrom(xCenter - width*0.5f, yCenter - height*0.5f); + vec2 posTo(xCenter + width*0.5f, yCenter + height*0.5f); + + std::vector > fillerFuncArr; + + BOOST_FOREACH(boost::property_tree::ptree::value_type &v, propertyTree) + { + if (v.first == "Filler") + { + + boost::property_tree::ptree& fillerTree = v.second; + + if (fillerTree.get(".type") == "TextureFiller") + { + std::string texName = fillerTree.get(".texName"); + std::string checkedTexName = fillerTree.get(".checkedTexName"); + + fillerFuncArr.push_back(boost::bind(TCheckBox::TextureFiller, posFrom, posTo, texName, checkedTexName, _1)); + + } + else if (fillerTree.get(".type") == "TextFiller") + { + TTextParams textParams; + + boost::property_tree::ptree& textParamsTree = fillerTree.find("TextParams")->second; + + textParams.Serialize(textParamsTree); + + float textXCenter = fillerTree.get(".xCenter"); + float textYCenter = fillerTree.get(".yCenter"); + float textWidth = fillerTree.get(".width"); + float textHeight = fillerTree.get(".height"); + + vec2 textPosFrom(textXCenter - textWidth*0.5f, textYCenter - textHeight*0.5f); + vec2 textPosTo(textXCenter + textWidth*0.5f, textYCenter + textHeight*0.5f); + + fillerFuncArr.push_back(boost::bind(TCheckBox::TextFiller, textPosFrom, textPosTo, textParams, _1)); + + } + else if (fillerTree.get(".type") == "RadioButtonGroupFiller") + { + //std::string radioGroupName = fillerTree.get(""); + //fillerFuncArr.push_back(boost::bind(TCheckBox::RadioButtonGroupFiller, radioGroupName, _1)); + throw ErrorToLog("RadioButtonGroupFiller is not allowed for checkboxes!"); + } + else if (fillerTree.get(".type") == "SmartValueFiller") + { + std::string dictionaryName = fillerTree.get(".dictionaryName"); + std::string smartValueName = fillerTree.get(".smartValueName"); + fillerFuncArr.push_back(boost::bind(TCheckBox::SmartValueFiller, dictionaryName, smartValueName, _1)); + } + } + + } + + + ResourceManager->GUIManager.AddWidget( + std::shared_ptr( + TCheckBox::CreateCheckBoxWithFillers(posFrom, posTo, fillerFuncArr) + ), + name, + group, + order); + +} + + + +void TRadioButtonWidgetParser::Serialize(boost::property_tree::ptree& propertyTree) +{ + std::string widgetType = propertyTree.get(".type"); + std::string name = propertyTree.get(".name"); + std::string group = propertyTree.get(".group"); + + float xCenter = propertyTree.get(".xCenter"); + float yCenter = propertyTree.get(".yCenter"); + float width = propertyTree.get(".width"); + float height = propertyTree.get(".height"); + int order = propertyTree.get(".order", 0); + + vec2 posFrom(xCenter - width*0.5f, yCenter - height*0.5f); + vec2 posTo(xCenter + width*0.5f, yCenter + height*0.5f); + + std::vector > fillerFuncArr; + + BOOST_FOREACH(boost::property_tree::ptree::value_type &v, propertyTree) + { + if (v.first == "Filler") + { + + boost::property_tree::ptree& fillerTree = v.second; + + if (fillerTree.get(".type") == "TextureFiller") + { + std::string texName = fillerTree.get(".texName"); + std::string checkedTexName = fillerTree.get(".checkedTexName"); + + fillerFuncArr.push_back(boost::bind(TRadioButton::TextureFiller, posFrom, posTo, texName, checkedTexName, _1)); + + } + else if (fillerTree.get(".type") == "TextFiller") + { + TTextParams textParams; + + boost::property_tree::ptree& textParamsTree = fillerTree.find("TextParams")->second; + + textParams.Serialize(textParamsTree); + + float textXCenter = fillerTree.get(".xCenter"); + float textYCenter = fillerTree.get(".yCenter"); + float textWidth = fillerTree.get(".width"); + float textHeight = fillerTree.get(".height"); + + vec2 textPosFrom(textXCenter - textWidth*0.5f, textYCenter - textHeight*0.5f); + vec2 textPosTo(textXCenter + textWidth*0.5f, textYCenter + textHeight*0.5f); + + fillerFuncArr.push_back(boost::bind(TRadioButton::TextFiller, textPosFrom, textPosTo, textParams, _1)); + + } + else if (fillerTree.get(".type") == "SmartValueFiller") + { + std::string dictionaryName = fillerTree.get(".dictionaryName"); + std::string smartValueName = fillerTree.get(".smartValueName"); + + std::string smartValueType = fillerTree.get("type"); + + if (smartValueType == "int") + { + int value = fillerTree.get("value"); + fillerFuncArr.push_back(boost::bind(TRadioButton::SmartValueFiller, dictionaryName, smartValueName, value, _1)); + } + else if (smartValueType == "float") + { + float value = fillerTree.get("value"); + fillerFuncArr.push_back(boost::bind(TRadioButton::SmartValueFiller, dictionaryName, smartValueName, value, _1)); + } + else if (smartValueType == "bool") + { + bool value = fillerTree.get("value"); + fillerFuncArr.push_back(boost::bind(TRadioButton::SmartValueFiller, dictionaryName, smartValueName, value, _1)); + } + else if (smartValueType == "string") + { + std::string value = fillerTree.get("value"); + fillerFuncArr.push_back(boost::bind(TRadioButton::SmartValueFiller, dictionaryName, smartValueName, value, _1)); + } + else + { + throw ErrorToLog("Unknown type: "+smartValueType); + } + + } + } + + } + + + ResourceManager->GUIManager.AddWidget( + std::shared_ptr( + TRadioButton::CreateRadioButtonWithFillers(posFrom, posTo, fillerFuncArr) + ), + name, + group, + order); +} + + + +/* +void TWidgetParser::Serialize(boost::property_tree::ptree& propertyTree) +{ + + BOOST_FOREACH(boost::property_tree::ptree::value_type &v, propertyTree.begin()->second) + { + std::string widgetType = v.second.get(".type"); + + + if (widgetType == "Button") + { + TButtonWidgetParser().Serialize(v.second); + } + if (widgetType == "Static") + { + TStaticWidgetParser().Serialize(v.second); + } + if (widgetType == "Edit") + { + TEditWidgetParser().Serialize(v.second); + } + if (widgetType == "CheckBox") + { + TCheckBoxWidgetParser().Serialize(v.second); + } + } +} +*/ + +void TWidgetParser::Serialize(boost::property_tree::ptree& propertyTree) +{ + + BOOST_FOREACH(boost::property_tree::ptree::value_type &v, propertyTree) + { + std::string widgetType = v.second.get(".type"); + + + if (widgetType == "Button") + { + TButtonWidgetParser().Serialize(v.second); + } + if (widgetType == "Static") + { + TStaticWidgetParser().Serialize(v.second); + } + if (widgetType == "DynamicText") + { + TDynamicTextWidgetParser().Serialize(v.second); + } + if (widgetType == "Edit") + { + TEditWidgetParser().Serialize(v.second); + } + if (widgetType == "CheckBox") + { + TCheckBoxWidgetParser().Serialize(v.second); + } + if (widgetType == "RadioButton") + { + TRadioButtonWidgetParser().Serialize(v.second); + } + } +} + + +void TWidgetListParser::Serialize(boost::property_tree::ptree& propertyTree) +{ + TWidgetParser().Serialize(propertyTree.begin()->second); +} + + +} //namespace SE \ No newline at end of file diff --git a/src/GlobalConst.cpp b/src/GlobalConst.cpp new file mode 100644 index 0000000..a41fb3f --- /dev/null +++ b/src/GlobalConst.cpp @@ -0,0 +1,7 @@ +#include "include/GlobalConst.h" + +namespace SE +{ + + +} //namespace SE \ No newline at end of file diff --git a/src/HalibutAnimation/HalibutAnimation.cpp b/src/HalibutAnimation/HalibutAnimation.cpp new file mode 100644 index 0000000..b29cef4 --- /dev/null +++ b/src/HalibutAnimation/HalibutAnimation.cpp @@ -0,0 +1,501 @@ +#include "include/Engine.h" + +#include "boost/assign.hpp" + +namespace SE +{ + +THalibutAnimObject::THalibutAnimObject(const std::string& texName, vec2 posFrom, vec2 posTo) + : TexName(texName) + , TotalAnimTime(0) + , CurrentAnimTime(0) + , CurrentAnimFrame(0) +{ + TRenderParams renderParams; + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = texName; + renderParams.FloatMap[CONST_STRING_TRANSPARENCY_UNIFORM] = 1.f; + + TriangleListVector.push_back(std::pair(renderParams, MakeTriangleList(posFrom, posTo))); + + LeftBottomPos = posFrom; +} + + +void THalibutAnimObject::RefreshTriangleListVector() +{ + vec2 tex1 = AnimShotArr[CurrentAnimFrame].TexCoordFrom; + vec2 tex2 = vec2(AnimShotArr[CurrentAnimFrame].TexCoordFrom.v[0], AnimShotArr[CurrentAnimFrame].TexCoordTo.v[1]); + vec2 tex3 = AnimShotArr[CurrentAnimFrame].TexCoordTo; + vec2 tex4 = vec2(AnimShotArr[CurrentAnimFrame].TexCoordTo.v[0], AnimShotArr[CurrentAnimFrame].TexCoordFrom.v[1]); + + TTriangleList& triangleList = TriangleListVector.begin()->second; + + triangleList.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB][0] = tex1; + triangleList.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB][1] = tex2; + triangleList.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB][2] = tex3; + + triangleList.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB][3] = tex3; + triangleList.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB][4] = tex4; + triangleList.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB][5] = tex1; + + triangleList.RefreshBuffer(); +} + +void THalibutAnimObject::AddAnimShot(vec2 texCoordFrom, vec2 texCoordTo, cardinal timePassedFromStart) +{ + AnimShotArr.push_back(TAnimShot(texCoordFrom, texCoordTo, timePassedFromStart)); + + CalcTotalAnimTime(); //Not rational but prevents a lot of stupid mistakes :( +} + +void THalibutAnimObject::CalcTotalAnimTime() +{ + if (AnimShotArr.size() == 0) + { + TotalAnimTime = 0; + } + else + { + std::vector::iterator i = AnimShotArr.end(); + + i--; + + TotalAnimTime = i->TimePassedFromStart; + } + +} + +void THalibutAnimObject::Update(cardinal dt) +{ + if (AnimShotArr.size() == 0) + { + return; + } + + //cardinal prevCurrentAnimTime = CurrentAnimTime; + + CurrentAnimTime += dt; + + cardinal prevCurrentAnimFrame = CurrentAnimFrame; + + while (CurrentAnimTime > AnimShotArr[CurrentAnimFrame].TimePassedFromStart) + { + CurrentAnimFrame++; + + if (CurrentAnimFrame == AnimShotArr.size()) + { + CurrentAnimFrame = 0; + CurrentAnimTime -= TotalAnimTime; + } + } + + if (prevCurrentAnimFrame != CurrentAnimFrame) + { + RefreshTriangleListVector(); + } +} + +void THalibutAnimObject::Reset() +{ + CurrentAnimFrame = 0; + CurrentAnimTime = 0; + RefreshTriangleListVector(); +} + + +void THalibutAnimObject::Serialize(boost::property_tree::ptree& propertyTree) +{ + Clear(); + + TexName = propertyTree.get("Animation.TexName"); + + vec2 posFrom, posTo; + + posFrom.v[0] = propertyTree.get("Animation.PosFrom..x"); + posFrom.v[1] = propertyTree.get("Animation.PosFrom..y"); + posTo.v[0] = propertyTree.get("Animation.PosTo..x"); + posTo.v[1] = propertyTree.get("Animation.PosTo..y"); + + TRenderParams renderParams; + + renderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM] = TexName; + renderParams.FloatMap[CONST_STRING_TRANSPARENCY_UNIFORM] = 1.f; + + + TriangleListVector.push_back(std::pair(renderParams, MakeTriangleList(posFrom, posTo))); + + BOOST_FOREACH(boost::property_tree::ptree::value_type &v, propertyTree.get_child("Animation.Frames")) + { + vec2 texCoordFrom, texCoordTo; + + texCoordFrom.v[0] = v.second.get("TexCoordFrom..x"); + texCoordFrom.v[1] = v.second.get("TexCoordFrom..y"); + texCoordTo.v[0] = v.second.get("TexCoordTo..x"); + texCoordTo.v[1] = v.second.get("TexCoordTo..y"); + + cardinal timePassedFromStart = v.second.get("TimePassed"); + + AddAnimShot(texCoordFrom, texCoordTo, timePassedFromStart); + + } + +} + + +void THalibutAnimObject::Clear() +{ + AnimShotArr.clear(); + + TriangleListVector.clear(); + + TotalAnimTime = 0; + CurrentAnimTime = 0; + CurrentAnimFrame = 0; +} + + + +//================================================== + + + +THalibutExternalAnimObject::THalibutExternalAnimObject(TRenderPairList::iterator renderPairIter, cardinal rectFrom, cardinal rectCount) + : RectCount(rectCount) + , RectFrom(rectFrom) + , TotalAnimTime(0) + , CurrentAnimTime(0) + , CurrentAnimFrame(0) + , RenderPairIter(renderPairIter) +{ +} + +THalibutExternalAnimObject::THalibutExternalAnimObject(const THalibutExternalAnimObject& copyFrom) + : CurrentAnimTime(copyFrom.CurrentAnimTime) + , TotalAnimTime(copyFrom.TotalAnimTime) + , CurrentAnimFrame(copyFrom.CurrentAnimFrame) + , AnimShotArr(copyFrom.AnimShotArr) + , RenderPairIter(copyFrom.RenderPairIter) + , RectCount(copyFrom.RectCount) + , RectFrom(copyFrom.RectFrom) +{ + +} + +THalibutExternalAnimObject& THalibutExternalAnimObject::operator=(const THalibutExternalAnimObject& copyFrom) +{ + //Self-assignment is ok + + CurrentAnimTime = copyFrom.CurrentAnimTime; + TotalAnimTime = copyFrom.TotalAnimTime; + + CurrentAnimFrame = copyFrom.CurrentAnimFrame; + + AnimShotArr = copyFrom.AnimShotArr; + + RenderPairIter = copyFrom.RenderPairIter; + + RectCount = copyFrom.RectCount; + RectFrom = copyFrom.RectFrom; + + return *this; + +} + +THalibutExternalAnimObject::~THalibutExternalAnimObject() +{ + +} + +void THalibutExternalAnimObject::ReplaceAnimObject(TRenderPairList::iterator renderPairIter, cardinal rectFrom) +{ + + RectFrom = rectFrom; + RenderPairIter = renderPairIter; +} + +void THalibutExternalAnimObject::RefreshTriangleListVector() +{ + + vec2 tex1 = AnimShotArr[CurrentAnimFrame].TexCoordFrom; + vec2 tex2 = vec2(AnimShotArr[CurrentAnimFrame].TexCoordFrom.v[0], AnimShotArr[CurrentAnimFrame].TexCoordTo.v[1]); + vec2 tex3 = AnimShotArr[CurrentAnimFrame].TexCoordTo; + vec2 tex4 = vec2(AnimShotArr[CurrentAnimFrame].TexCoordTo.v[0], AnimShotArr[CurrentAnimFrame].TexCoordFrom.v[1]); + + + + for (cardinal i = RectFrom; isecond.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB][i*6+0] = tex1; + RenderPairIter->second.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB][i*6+1] = tex2; + RenderPairIter->second.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB][i*6+2] = tex3; + + RenderPairIter->second.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB][i*6+3] = tex3; + RenderPairIter->second.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB][i*6+4] = tex4; + RenderPairIter->second.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB][i*6+5] = tex1; + } + + RenderPairIter->second.NeedRefreshBuffer = true; + +} + +void THalibutExternalAnimObject::AddAnimShot(vec2 texCoordFrom, vec2 texCoordTo, cardinal timePassedFromStart) +{ + + AnimShotArr.push_back(TAnimShot(texCoordFrom, texCoordTo, timePassedFromStart)); + + CalcTotalAnimTime(); //Not rational but prevents a lot of stupid mistakes :( +} + +void THalibutExternalAnimObject::CalcTotalAnimTime() +{ + + if (AnimShotArr.size() == 0) + { + TotalAnimTime = 0; + } + else + { + std::vector::iterator i = AnimShotArr.end(); + + i--; + + TotalAnimTime = i->TimePassedFromStart; + } + +} + +void THalibutExternalAnimObject::Update(cardinal dt) +{ + + if (AnimShotArr.size() == 0) + { + return; + } + + //cardinal prevCurrentAnimTime = CurrentAnimTime; + + CurrentAnimTime += dt; + + cardinal prevCurrentAnimFrame = CurrentAnimFrame; + + while (CurrentAnimTime > AnimShotArr[CurrentAnimFrame].TimePassedFromStart) + { + CurrentAnimFrame++; + + if (CurrentAnimFrame == AnimShotArr.size()) + { + CurrentAnimFrame = 0; + CurrentAnimTime -= TotalAnimTime; + } + } + + if (prevCurrentAnimFrame != CurrentAnimFrame) + { + RefreshTriangleListVector(); + } +} + +void THalibutExternalAnimObject::Reset() +{ + + CurrentAnimFrame = 0; + CurrentAnimTime = 0; + RefreshTriangleListVector(); +} + + +void THalibutExternalAnimObject::Serialize(boost::property_tree::ptree& propertyTree) +{ + + //*Console<<"Halibut external anim object serialize\n"; + Clear(); + + BOOST_FOREACH(boost::property_tree::ptree::value_type &v, propertyTree.get_child("Animation.Frames")) + { + vec2 texCoordFrom, texCoordTo; + + texCoordFrom.v[0] = v.second.get("TexCoordFrom..x"); + texCoordFrom.v[1] = v.second.get("TexCoordFrom..y"); + texCoordTo.v[0] = v.second.get("TexCoordTo..x"); + texCoordTo.v[1] = v.second.get("TexCoordTo..y"); + + cardinal timePassedFromStart = v.second.get("TimePassed"); + + AddAnimShot(texCoordFrom, texCoordTo, timePassedFromStart); + + } + +} + + +void THalibutExternalAnimObject::Clear() +{ + + //*Console<<"Halibut external anim object clear\n"; + + AnimShotArr.clear(); + + TotalAnimTime = 0; + CurrentAnimTime = 0; + CurrentAnimFrame = 0; +} + + +//================================================== + + +THalibutAnimationManager::~THalibutAnimationManager() +{ + *Console<<"HalibutAnimationManager deleting..."; +} + +std::vector::iterator THalibutAnimationManager::FindAnimObjectByName(const std::string& name) +{ + std::vector::iterator i; + + for (i = HalibutAnimObjectArr.begin(); i != HalibutAnimObjectArr.end(); ++i) + { + if (i->Name == name) + { + return i; + } + } + + //throw ErrorToLog("ERROR: Animation not found: " + name + "\n"); + + return HalibutAnimObjectArr.end(); +} + + +void THalibutAnimationManager::ReplaceAnimationObject(const std::string& animName, TRenderPairList::iterator renderPairIter, cardinal rectFrom) +{ + + std::vector::iterator i = FindAnimObjectByName(animName); + + if (i == HalibutAnimObjectArr.end()) + { + throw ErrorToLog("ERROR: Animation not found: " + animName); + } + + i->HalibutAnimObject.ReplaceAnimObject(renderPairIter, rectFrom); +} + +void THalibutAnimationManager::AddAnimationObject(const std::string& animName, THalibutExternalAnimObject halibutExternalAnimObject) +{ + + if (FindAnimObjectByName(animName) == HalibutAnimObjectArr.end()) + { + HalibutAnimObjectArr.push_back(THalibutAnimObjectRecord(animName, halibutExternalAnimObject, THalibutAnimObjectRecord::AS_STOP)); + } +} + + +void THalibutAnimationManager::DeleteAnimationObject(const std::string& animName) +{ + + std::vector::iterator i = FindAnimObjectByName(animName); + if (i != HalibutAnimObjectArr.end()) + { + HalibutAnimObjectArr.erase(i); + } + +} + + +bool THalibutAnimationManager::AnimationExists(const std::string& animName) +{ + return FindAnimObjectByName(animName) != HalibutAnimObjectArr.end(); +} + +void THalibutAnimationManager::Update(cardinal dt) +{ + + std::vector::iterator i; + + for (i = HalibutAnimObjectArr.begin(); i != HalibutAnimObjectArr.end(); ++i) + { + if (i->AnimState == THalibutAnimObjectRecord::AS_PLAY) + { + i->HalibutAnimObject.Update(dt); + } + } +} + + + +void THalibutAnimationManager::StartAnimation(const std::string& animName) +{ + + std::vector::iterator i = FindAnimObjectByName(animName); + + if (FindAnimObjectByName(animName) == HalibutAnimObjectArr.end()) + { + return; + } + + i->AnimState = THalibutAnimObjectRecord::AS_PLAY; +} + +void THalibutAnimationManager::StopAnimation(const std::string& animName) +{ + + std::vector::iterator i = FindAnimObjectByName(animName); + + if (FindAnimObjectByName(animName) == HalibutAnimObjectArr.end()) + { + return; + } + + i->AnimState = THalibutAnimObjectRecord::AS_STOP; + + i->HalibutAnimObject.Reset(); +} + +void THalibutAnimationManager::PauseAnimation(const std::string& animName) +{ + + std::vector::iterator i = FindAnimObjectByName(animName); + + i->AnimState = THalibutAnimObjectRecord::AS_STOP; +} + +/* +void THalibutAnimationManager::HideAnimation(const std::string& animName) +{ + std::vector::iterator i = FindAnimObjectByName(animName); + + i->Visible = false; +} + + +void THalibutAnimationManager::ShowAnimation(const std::string& animName) +{ + std::vector::iterator i = FindAnimObjectByName(animName); + + i->Visible = true; +}*/ + +void THalibutAnimationManager::PrintAnimationList() +{ + + static std::map mapAnimState = boost::assign::map_list_of(THalibutAnimObjectRecord::AS_PLAY, "AS_PLAY")(THalibutAnimObjectRecord::AS_STOP, "AS_STOP"); + + std::vector::iterator i; + + Console->PrintImmediate("==========> ANIMATION LIST <=========="); + + for (i = HalibutAnimObjectArr.begin(); i != HalibutAnimObjectArr.end(); ++i) + { + Console->PrintImmediate(i->Name + " " + mapAnimState[i->AnimState]); + } +} + + +void THalibutAnimationManager::BindFunctions() +{ + //*Console<<"Bind functions in THalibutAnimationManager\n"; + ResourceManager->ScriptManager.AddFunction("pal", TScriptInfo("PrintAnimationList"), *this, &THalibutAnimationManager::PrintAnimationList); +} + +} //namespace SE \ No newline at end of file diff --git a/src/HalibutEngineAndroid.cpp b/src/HalibutEngineAndroid.cpp new file mode 100644 index 0000000..9048779 --- /dev/null +++ b/src/HalibutEngineAndroid.cpp @@ -0,0 +1,175 @@ +#include "include/HalibutEngineAndroid.h" + + +namespace SE +{ + +TJavaConsole* Console = NULL; + +THalibutResourceManager* ResourceManager = NULL; + +THalibutRendererAndroid* Renderer = NULL; + + +TApplication::TApplication() +{ +} + +void TApplication::OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight) +{ + + OuterDeinit(); + + Console = new TJavaConsole; + + *Console<ScriptManager.BindBasicFunctions(); + + InnerInit(); + + Renderer->InitOpenGL(screenWidth, screenHeight, matrixWidth, matrixHeight); + + +} + +void TApplication::OuterDeinit() +{ + if (Console != NULL) + { + *Console<<"OuterDeinit"; + } + InnerDeinit(); + + + if (ResourceManager != NULL) + { + delete ResourceManager; + ResourceManager = NULL; + } + + if (Renderer != NULL) + { + delete Renderer; + Renderer = NULL; + } + + + + if (Console != NULL) + { + delete Console; + Console = NULL; + } + +} + +TApplication::~TApplication() +{ + OuterDeinit(); +} + + +void TApplication::OnKeyPress(cardinal key) +{ + //For Android + //7-16 => "0".."9" + //29-54 => "a".."z" + // + + if (IsConsoleOut) + { + + if (key == 96 || key == 126) //` or ~ + { + + IsConsoleOut = false; + } + else if (key == 8) //Backspace + { + if (Console->ConsoleInput.size() > 0 && Console->ConsoleCursor > 0) + { + //Console->ConsoleInput.erase(Console->ConsoleInput.end()-1); + Console->ConsoleInput.erase(Console->ConsoleInput.begin() + Console->ConsoleCursor-1); + Console->ConsoleCursor--; + } + } + else if (key == 13 || key == 10) //Enter + { + ResourceManager->ScriptManager.RunScript(Console->ConsoleInput); + *Console<<"===>"+Console->ConsoleInput+"<==="; + + Console->InputHistory.push_back(Console->ConsoleInput); + + Console->InputHistoryCursor = Console->InputHistory.size(); + + Console->ConsoleInput = ""; + Console->ConsoleCursor = 0; + } + else if (key >= 32 && key <= 255) //ASCII + { + //Console->ConsoleInput += static_cast(key); + Console->ConsoleInput.insert(Console->ConsoleInput.begin()+Console->ConsoleCursor, static_cast(key)); + Console->ConsoleCursor++; + } + else if (key > 0x100) //VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT + { + /* + cardinal realKey = key - 0x100; + + if (realKey == VK_UP) + { + if (Console->InputHistoryCursor > 0) + { + Console->InputHistoryCursor--; + Console->ConsoleInput = Console->InputHistory[Console->InputHistoryCursor]; + Console->ConsoleCursor = Console->ConsoleInput.size(); + } + } + if (realKey == VK_DOWN) + { + if ( Console->InputHistoryCursor+1 < Console->InputHistory.size()) + { + Console->InputHistoryCursor++; + Console->ConsoleInput = Console->InputHistory[Console->InputHistoryCursor]; + Console->ConsoleCursor = Console->ConsoleInput.size(); + } + } + if (realKey == VK_LEFT) + { + if (Console->ConsoleCursor > 0) + { + Console->ConsoleCursor--; + } + } + if (realKey == VK_RIGHT) + { + if (Console->ConsoleCursor < Console->ConsoleInput.size()) + { + Console->ConsoleCursor++; + } + }*/ + } + else + { + *Console<ConsoleInput = ""; + Console->ConsoleCursor = Console->ConsoleInput.size(); + } + } +} + + +} //namespace SE \ No newline at end of file diff --git a/src/HalibutEngineInterface.cpp b/src/HalibutEngineInterface.cpp new file mode 100644 index 0000000..83e172a --- /dev/null +++ b/src/HalibutEngineInterface.cpp @@ -0,0 +1,76 @@ +#include "include/HalibutEngineInterface.h" +#include "include/Engine.h" + + +namespace SE +{ + +TApplicationAncestor::TApplicationAncestor() +{ +} + + +void TApplicationAncestor::OuterDraw() +{ + + CheckGlError("THalibutApplicationInterface::OuterDraw 1"); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); + + glActiveTexture(GL_TEXTURE0); + RenderUniform1i("Texture", 0); + RenderUniform1f("Transparency", 1.f); + + InnerDraw(); + + CheckGlError("THalibutApplicationInterface::OuterDraw 1.5"); + + ResourceManager->GUIManager.Draw(); + + if (IsConsoleOut) + { + Console->Draw(); + } + CheckGlError("THalibutApplicationInterface::OuterDraw 2"); + +} + + + +void TApplicationAncestor::OuterUpdate(cardinal dt) +{ + CheckGlError(); + ResourceManager->GUIManager.Update(dt); + ResourceManager->HalibutAnimationManager.Update(dt); + + +#ifndef TARGET_IOS + ResourceManager->SoundManager.Update(dt); +#endif + CheckGlError(); + InnerUpdate(dt); + + CheckGlError(); +} + + +void TApplicationAncestor::OuterOnTapDown(vec2 p) +{ + ResourceManager->GUIManager.OnMouseDown(p); + InnerOnTapDown(p); +} + +void TApplicationAncestor::OuterOnTapUp(vec2 p) +{ + ResourceManager->GUIManager.OnMouseUp(p); + InnerOnTapUp(p); +} + +void TApplicationAncestor::OuterOnMove(vec2 shift) +{ + ResourceManager->GUIManager.OnMove(shift); + InnerOnMove(shift); +} + + +} //namespace SE \ No newline at end of file diff --git a/src/HalibutEngineIos.cpp b/src/HalibutEngineIos.cpp new file mode 100644 index 0000000..9cd7896 --- /dev/null +++ b/src/HalibutEngineIos.cpp @@ -0,0 +1,187 @@ +// +// HalibutEngineIos.cpp +// Halibut Engine +// +// Created by vvv ооо on 13.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#include + +#include "include/Engine.h" + +#include "include/HalibutEngineIos.h" + +namespace SE +{ + +TIosConsole* Console = NULL; + +THalibutResourceManager* ResourceManager = NULL; + +THalibutRenderIos* Renderer = NULL; + + +TApplication::TApplication() +{ +} + +void TApplication::OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight) +{ + + OuterDeinit(); + + Console = new TIosConsole; + + *Console<ScriptManager.BindBasicFunctions(); + + InnerInit(); + + Renderer->InitOpenGL(screenWidth, screenHeight, matrixWidth, matrixHeight); + + +} + +void TApplication::OuterDeinit() +{ + if (Console != NULL) + { + *Console<<"OuterDeinit"; + } + InnerDeinit(); + + + if (ResourceManager != NULL) + { + delete ResourceManager; + ResourceManager = NULL; + } + + if (Renderer != NULL) + { + delete Renderer; + Renderer = NULL; + } + + + + if (Console != NULL) + { + delete Console; + Console = NULL; + } + +} + +TApplication::~TApplication() +{ + OuterDeinit(); +} + + +void TApplication::OnKeyPress(cardinal key) +{ + //For Android + //7-16 => "0".."9" + //29-54 => "a".."z" + // + + if (IsConsoleOut) + { + + if (key == 96 || key == 126) //` or ~ + { + + IsConsoleOut = false; + } + else if (key == 8) //Backspace + { + if (Console->ConsoleInput.size() > 0 && Console->ConsoleCursor > 0) + { + //Console->ConsoleInput.erase(Console->ConsoleInput.end()-1); + Console->ConsoleInput.erase(Console->ConsoleInput.begin() + Console->ConsoleCursor-1); + Console->ConsoleCursor--; + } + } + else if (key == 13 || key == 10) //Enter + { + ResourceManager->ScriptManager.RunScript(Console->ConsoleInput); + *Console<<"===>"+Console->ConsoleInput+"<==="; + + Console->InputHistory.push_back(Console->ConsoleInput); + + Console->InputHistoryCursor = Console->InputHistory.size(); + + Console->ConsoleInput = ""; + Console->ConsoleCursor = 0; + } + else if (key >= 32 && key <= 255) //ASCII + { + //Console->ConsoleInput += static_cast(key); + Console->ConsoleInput.insert(Console->ConsoleInput.begin()+Console->ConsoleCursor, static_cast(key)); + Console->ConsoleCursor++; + } + else if (key > 0x100) //VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT + { + /* + cardinal realKey = key - 0x100; + + if (realKey == VK_UP) + { + if (Console->InputHistoryCursor > 0) + { + Console->InputHistoryCursor--; + Console->ConsoleInput = Console->InputHistory[Console->InputHistoryCursor]; + Console->ConsoleCursor = Console->ConsoleInput.size(); + } + } + if (realKey == VK_DOWN) + { + if ( Console->InputHistoryCursor+1 < Console->InputHistory.size()) + { + Console->InputHistoryCursor++; + Console->ConsoleInput = Console->InputHistory[Console->InputHistoryCursor]; + Console->ConsoleCursor = Console->ConsoleInput.size(); + } + } + if (realKey == VK_LEFT) + { + if (Console->ConsoleCursor > 0) + { + Console->ConsoleCursor--; + } + } + if (realKey == VK_RIGHT) + { + if (Console->ConsoleCursor < Console->ConsoleInput.size()) + { + Console->ConsoleCursor++; + } + }*/ + } + else + { + *Console<ConsoleInput = ""; + Console->ConsoleCursor = Console->ConsoleInput.size(); + } + } +} + + + +} //namespace SE diff --git a/src/HalibutEngineWindows.cpp b/src/HalibutEngineWindows.cpp new file mode 100644 index 0000000..cc3e8db --- /dev/null +++ b/src/HalibutEngineWindows.cpp @@ -0,0 +1,510 @@ +#include "include/Utils/Utils.h" +#include "include/HalibutEngineWindows.h" + +namespace SE +{ + +//============================================================== +//========= GLOBAL VARIABLES - REMEMBER THIS LIST!!! =========== +//============================================================== + +HGLRC hRC; //Render context +HWND Hwnd; //Main window handle +HDC hDC; //Device context + +TFileConsole* Console = NULL; + +THalibutRenderer* Renderer = NULL; + +THalibutResourceManager* ResourceManager = NULL; + + +//============================================================== +//=============== GLOBAL VARS ENDS ============================= +//============================================================== + +const int CONST_DEFAULT_SCREEN_WIDTH = 800; +const int CONST_DEFAULT_SCREEN_HEIGHT = 600; + +const cardinal CONST_TIMER_INTERVAL = 10; + +//There might be anything +const char CONST_WINDOW_CLASS_NAME[] = "TSalmonEngineForm"; + +//To calculate when to call Update +cardinal NewTickCount; +cardinal LastTickCount; + +vec2 MouseButtonPos; +vec2 MouseTotalShift; +bool MouseButtonPressed = false; +bool MouseMoved = false; + +//User application +TApplication* App = NULL; + + +TApplication::TApplication() + : X(0) + , Y(0) + , Width(800) + , Height(600) + , MatrixWidth(0.f) + , MatrixHeight(0.f) + , WindowName("Halibut Engine") + , LogFilename("log.txt") +{ + for(int i=0; i<256; i++) + { + KeyboardBuffer[i] = 0; + } +} + +TApplication::~TApplication() +{ +} + +const std::string& TApplication::GetLogFilename() +{ + return LogFilename; +} + +char TApplication::GetKeyState(cardinal keyNum) +{ + if (keyNum > 255) + throw ErrorToLog("GetKeyState - invalid key number!"); + + return KeyboardBuffer[keyNum]; +} + + +void TApplication::SetKeyboardBuffer(const unsigned char* source) +{ + memcpy((unsigned char*)KeyboardBuffer, source, 256); +} + +void TApplication::OnKeyPress(cardinal key) +{ + + if (IsConsoleOut) + { + + if (key == 96 || key == 126) //~ + { + IsConsoleOut = false; + } + else if (key == 8) //Backspace + { + if (Console->ConsoleInput.size() > 0 && Console->ConsoleCursor > 0) + { + Console->ConsoleInput.erase(Console->ConsoleInput.begin() + Console->ConsoleCursor-1); + Console->ConsoleCursor--; + } + } + else if (key == 13|| key == 10) //Enter + { + ResourceManager->ScriptManager.RunScript(Console->ConsoleInput); + + Console->InputHistory.push_back(Console->ConsoleInput); + + Console->InputHistoryCursor = Console->InputHistory.size(); + + Console->ConsoleInput = ""; + Console->ConsoleCursor = 0; + } + else if (key >= 32 && key <= 255) //ASCII + { + Console->ConsoleInput.insert(Console->ConsoleInput.begin()+Console->ConsoleCursor, static_cast(key)); + Console->ConsoleCursor++; + } + else if (key > 0x100) //VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT + { + cardinal realKey = key - 0x100; + + if (realKey == VK_UP) + { + if (Console->InputHistoryCursor > 0) + { + Console->InputHistoryCursor--; + Console->ConsoleInput = Console->InputHistory[Console->InputHistoryCursor]; + Console->ConsoleCursor = Console->ConsoleInput.size(); + } + } + if (realKey == VK_DOWN) + { + if ( Console->InputHistoryCursor+1 < Console->InputHistory.size()) + { + Console->InputHistoryCursor++; + Console->ConsoleInput = Console->InputHistory[Console->InputHistoryCursor]; + Console->ConsoleCursor = Console->ConsoleInput.size(); + } + } + if (realKey == VK_LEFT) + { + if (Console->ConsoleCursor > 0) + { + Console->ConsoleCursor--; + } + } + if (realKey == VK_RIGHT) + { + if (Console->ConsoleCursor < Console->ConsoleInput.size()) + { + Console->ConsoleCursor++; + } + } + + } + else + { + *Console<<"Key is "+tostr(key)+endl; + } + + } + else + { + ResourceManager->GUIManager.KeyPressedSignal(key); + + if (key == 96 || key == 126) //~ + { + IsConsoleOut = true; + Console->ConsoleInput = ""; + Console->ConsoleCursor = Console->ConsoleInput.size(); + } + } +} + + +void DrawScene() +{ + App->OuterDraw(); + SwapBuffers(hDC); +} + +void ProcessTickCount() +{ + //unsigned char keyboardStateArr[256]; + + NewTickCount = GetTickCount(); + if (NewTickCount - LastTickCount > CONST_TIMER_INTERVAL) + { + /* + GetKeyboardState((unsigned char*)keyboardStateArr); + App->SetKeyboardBuffer((unsigned char*)keyboardStateArr); + */ + + App->OuterUpdate(NewTickCount - LastTickCount); + LastTickCount = NewTickCount; + } + +} + +LONG WINAPI WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + static PAINTSTRUCT ps; + + TMouseState mouseState; + + switch(uMsg) + { + case WM_CLOSE: + Hwnd = 0; //HACK to force window to close + PostQuitMessage(0); + //Xperimental + return DefWindowProc(hWnd, uMsg, wParam, lParam); + + break; + case WM_PAINT: + DrawScene(); + + BeginPaint(hWnd, &ps); + EndPaint(hWnd, &ps); + + ProcessTickCount(); + break; + case WM_SIZE: + + PostMessage(hWnd, WM_PAINT, 0, 0); + break; + case WM_CHAR: + App->OnKeyPress(wParam); + /* + switch (wParam) + { + case 27: + PostQuitMessage(0); + Hwnd = 0; + + //Xperimental + return DefWindowProc(hWnd, uMsg, wParam, lParam); + + break; + //... Will add more code later + } + */ + break; + case WM_KEYDOWN: + //Special for arrow keys + + if (wParam == VK_UP || wParam == VK_DOWN || wParam == VK_LEFT || wParam == VK_RIGHT) + { + App->OnKeyPress(0x100 + wParam); + } + + break; + case WM_MOUSEMOVE: + mouseState.X = (lParam << 16) >> 16; + mouseState.Y = lParam >> 16; + mouseState.LeftButtonPressed = (wParam & MK_LBUTTON); + mouseState.MiddleButtonPressed = (wParam & MK_MBUTTON); + mouseState.RightButtonPressed = (wParam & MK_RBUTTON); + + App->OnMouseMove(mouseState); + + if (MouseButtonPressed) + { + vec2 currentMousePos(static_cast(mouseState.X), static_cast(App->Height - mouseState.Y)); + vec2 shift = (MouseButtonPos - currentMousePos); + //shift.v[1] = - shift.v[1]; + App->OuterOnMove(shift); + //App->OuterOnMove(currentMousePos - MouseButtonPos); + MouseButtonPos = currentMousePos; + + MouseTotalShift += shift; + + if (fabs(MouseTotalShift.v[0]) > 10.f || fabs(MouseTotalShift.v[1]) > 10.f) + { + MouseMoved = true; + } + } + + break; + + case WM_LBUTTONDOWN: + case WM_RBUTTONDOWN: + mouseState.X = (lParam << 16) >> 16; + mouseState.Y = lParam >> 16; + mouseState.LeftButtonPressed = (wParam & MK_LBUTTON); + mouseState.MiddleButtonPressed = (wParam & MK_MBUTTON); + mouseState.RightButtonPressed = (wParam & MK_RBUTTON); + + MouseButtonPos = vec2(static_cast(mouseState.X), static_cast(App->Height - mouseState.Y)); + + if (mouseState.LeftButtonPressed) + { + App->OuterOnTapDown(MouseButtonPos); + + } + + MouseButtonPressed = true; + + MouseMoved = false; + + MouseTotalShift = vec2(0,0); + + + + break; + case WM_LBUTTONUP: + case WM_RBUTTONUP: + mouseState.X = (lParam << 16) >> 16; + mouseState.Y = lParam >> 16; + mouseState.LeftButtonPressed = (wParam & MK_LBUTTON); + mouseState.MiddleButtonPressed = (wParam & MK_MBUTTON); + mouseState.MiddleButtonPressed = (wParam & MK_RBUTTON); + + if (!MouseMoved) + { + App->OuterOnTapUp(vec2(static_cast(mouseState.X), static_cast(App->Height - mouseState.Y))); + } + + MouseButtonPressed = false; + + break; + + case WM_MOUSEWHEEL: + App->OnMouseWheel(wParam >> 16); + break; + } + + return DefWindowProc(hWnd, uMsg, wParam, lParam); +} + +bool CreateOpenGLWindow(const char* title, int x, int y, int width, int height,HWND& hWnd, HDC& hDC, HGLRC& hRC) +{ + int pf; + WNDCLASS wc; + PIXELFORMATDESCRIPTOR pfd; + static HINSTANCE hInstance = 0; + + if (!hInstance) + { + hInstance = GetModuleHandle(NULL); + wc.style = CS_OWNDC; + wc.lpfnWndProc = (WNDPROC)WindowProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.lpszClassName = CONST_WINDOW_CLASS_NAME; + + if (!RegisterClass(&wc)) + { + return NULL; + } + } + + RECT r; + r.left = x; + r.right = x + width; + r.top = y; + r.bottom = y + height; + + DWORD windowStyle = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + AdjustWindowRect(&r, windowStyle, false); + + hWnd = CreateWindow(CONST_WINDOW_CLASS_NAME, title, windowStyle, 0, 0, r.right-r.left, r.bottom-r.top, NULL, NULL, hInstance, NULL); + + if (hWnd == NULL) + { + return false; + } + + hDC = GetDC(hWnd); + + memset(&pfd, 0, sizeof(pfd)); + pfd.nSize = sizeof(pfd); + pfd.nVersion = 1; + pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; + pfd.iPixelType = PFD_TYPE_RGBA; + pfd.cColorBits = 32; + + pf = ChoosePixelFormat(hDC, &pfd); + if (pf == 0) + { + return false; + } + + if (SetPixelFormat(hDC, pf, &pfd) == FALSE) + { + return false; + } + + hRC = wglCreateContext( hDC ); + wglMakeCurrent( hDC, hRC ); + + return true; +} + +int MainLoop(TApplication& application) +{ + MSG msg; + + //Here console log is not created so we can not use ErrorCommon + try + { + Console = new TFileConsole(application.GetLogFilename()); + } + catch(...) + { + exit(1); + } + + //Here console log is already created + try + { + + *Console<<"Log started"; + + if (!CreateOpenGLWindow(application.WindowName.c_str(), application.X, application.Y, application.Width, application.Height,Hwnd,hDC,hRC)) + { + *Console<<"Unable to create OpenGL Window!"; + exit(1); + } + + *Console<<"OpenGL Window created"; + + + if (App != NULL) + throw ErrorCommon(); + + App = &application; + + Renderer = new THalibutRenderer; + ResourceManager = new THalibutResourceManager; + + if (Renderer->BindOpenGLFunctions()) + { + if (App->MatrixWidth == 0) + { + App->MatrixWidth = static_cast(App->Width); + } + + if (App->MatrixHeight == 0) + { + App->MatrixHeight = static_cast(App->Height); + } + + App->OuterInit(App->Width, App->Height, App->MatrixWidth, App->MatrixHeight); + + ShowWindow(Hwnd, SW_SHOW); + UpdateWindow(Hwnd); + + NewTickCount = GetTickCount(); + LastTickCount = NewTickCount; + + bool StayIn = true; + + while (StayIn) + { + while(PeekMessage(&msg, Hwnd, 0, 0, PM_NOREMOVE)) + { + if(GetMessage(&msg, Hwnd, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + else + { + StayIn = false; + } + } + DrawScene(); + + ProcessTickCount(); + } + + } + + *Console<<"Program prepares to quit"; + + App->OuterDeinit(); + + delete ResourceManager; + delete Renderer; + + + wglMakeCurrent(NULL, NULL); + ReleaseDC(Hwnd,hDC); + wglDeleteContext(hRC); + DestroyWindow(Hwnd); + + } + catch(ErrorCommon) + { + //... let the ErrorTypes.h do the buisness + } + + + delete Console; + + + return 0; +} + + +} //namespace SE diff --git a/src/LightManager/LightManager.cpp b/src/LightManager/LightManager.cpp new file mode 100644 index 0000000..361c8ba --- /dev/null +++ b/src/LightManager/LightManager.cpp @@ -0,0 +1,53 @@ +#include "include/LightManager/LightManager.h" + +#include "include/Utils/Utils.h" +#include "include/Engine.h" + + +namespace SE +{ + +//=================================================== +//================ LIGHT MANAGER ==================== +//=================================================== + +TLightManager::TLightManager() + : LightingEnabled(false) +{ +} + +void TLightManager::SetLightPos(vec3 pos) +{ + LightPos = pos; +} + +void TLightManager::SetLightDirection(vec3 dir) +{ + LightDirection = Normalize(dir); +} + +void TLightManager::SetLightColor(vec4 color) +{ + LightColor = color; +} + + +void TLightManager::SetLightOn() +{ + LightingEnabled = true; +} + +void TLightManager::SetLightOff() +{ + LightingEnabled = false; +} + +void TLightManager::SetLightUniforms() +{ + + RenderUniform3fv(CONST_STRING_LIGHT_POS_UNIFORM, LightPos.v); + RenderUniform3fv(CONST_STRING_LIGHT_DIRECTION_UNIFORM, LightDirection.v); + RenderUniform4fv(CONST_STRING_LIGHT_COLOR_UNIFORM, LightColor.v); +} + +} //namespace SE \ No newline at end of file diff --git a/src/ModelManager/ModelManager.cpp b/src/ModelManager/ModelManager.cpp new file mode 100644 index 0000000..6510a52 --- /dev/null +++ b/src/ModelManager/ModelManager.cpp @@ -0,0 +1,361 @@ +#include "include/ModelManager/ModelManager.h" + +#include "include/Utils/Utils.h" +#include "include/Engine.h" + +namespace SE +{ + +//=================================================== +//=========== LITE MODEL RESOURCE =================== +//=================================================== + +TLiteModelResource::~TLiteModelResource() +{ + FreeModel(); + *Console<<"ResourceManager::ModelManager::LiteModelResource deleting"; +} + +bool TLiteModelResource::LoadModel(boost::shared_array filePointer, cardinal fileSize) +{ + + FreeModel(); + + cardinal triangleShift = *reinterpret_cast(&filePointer[4]); + + TriangleCount = *reinterpret_cast(&filePointer[0] + triangleShift - 4); + + int texnamelen = *reinterpret_cast(&filePointer[0] + 76); + + Texname = std::string(reinterpret_cast(&filePointer[78]), reinterpret_cast(&filePointer[78]) + texnamelen); + + int normtexnamelen = *reinterpret_cast(&filePointer[78]+texnamelen); + + Normtexname = std::string(reinterpret_cast(&filePointer[80]+texnamelen), reinterpret_cast(&filePointer[80]+texnamelen) + normtexnamelen); + + ResourceManager->TexList.AddTextureDirectly((PathToResource + std::string(Texname))); + if (Normtexname != "") + { + ResourceManager->TexList.AddTextureDirectly((PathToResource + std::string(Normtexname))); + } + + VertexArr.resize(TriangleCount * 3); + NormalArr.resize(TriangleCount * 3); + TangentArr.resize(TriangleCount * 3); + BinormalArr.resize(TriangleCount * 3); + TexCoordArr.resize(TriangleCount * 3); + + memcpy(&VertexArr[0], &filePointer[0] + triangleShift, TriangleCount * 36); + memcpy(&NormalArr[0], &filePointer[0] + triangleShift + TriangleCount * 36, TriangleCount * 36); + memcpy(&TangentArr[0], &filePointer[0] + triangleShift + TriangleCount * 72, TriangleCount * 36); + memcpy(&BinormalArr[0], &filePointer[0] + triangleShift + TriangleCount * 108, TriangleCount * 36); + memcpy(&TexCoordArr[0], &filePointer[0] + triangleShift + TriangleCount * 144, TriangleCount * 24); + + return true; + +} + +void TLiteModelResource::FreeModel() +{ + + if (Texname != "") + { + ResourceManager->TexList.DeleteTexture(GetFileName(Texname)); + Texname = ""; + } + + if (Normtexname != "") + { + ResourceManager->TexList.DeleteTexture(GetFileName(Normtexname)); + Normtexname = ""; + } + + VertexArr.clear(); + NormalArr.clear(); + TangentArr.clear(); + BinormalArr.clear(); + TexCoordArr.clear(); + +} + +void TLiteModelResource::SetPathToResource(const std::string& pathToResource) +{ + PathToResource = pathToResource; +} + + + +//=================================================== +//============= LITE MODEL REF ====================== +//=================================================== +TLiteModel::~TLiteModel() +{ + FreeModel(); + *Console<<"Render::LiteModel model deleting: " + Modelname; +} + +bool TLiteModel::LoadModel(const std::string& s) +{ + + TLiteModelResource& res = ResourceManager->ModelManager[s]; + + FreeModel(); + + Modelname = s; + + TriangleCount = res.TriangleCount; + + if (res.Texname != "") + TexID = ResourceManager->TexList[res.Texname]; + else + TexID = 0; + + if (res.Normtexname != "") + NormTexID = ResourceManager->TexList[res.Normtexname]; + else + NormTexID = 0; + + + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB] = res.VertexArr; + TriangleList.Data.Vec3CoordArr[CONST_STRING_NORMAL_ATTRIB] = res.NormalArr; + TriangleList.Data.Vec3CoordArr[CONST_STRING_TANGENT_ATTRIB] = res.TangentArr; + TriangleList.Data.Vec3CoordArr[CONST_STRING_BINORMAL_ATTRIB] = res.BinormalArr; + TriangleList.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB] = res.TexCoordArr; + + Loaded = true; + + return true; +} + +void TLiteModel::FreeModel() +{ + Loaded = false; + + TriangleList.Data.Vec3CoordArr.clear(); + TriangleList.Data.Vec2CoordArr.clear(); +#ifdef TARGET_WIN32 + TriangleList.VertBufferArr.clear(); +#endif + TriangleCount = 0; + TexID = 0; + NormTexID = 0; + + Modelname = ""; +} + + +void TLiteModel::UpdateVBO() +{ + + CheckGlError(); + + TriangleList.RefreshBuffer(); + + CheckGlError(); + +} + +void TLiteModel::DrawImmediate() +{ + +#ifdef TARGET_WIN32 + + if (Loaded) + { + + int triangleCount = TriangleCount; + + if (NormTexID == 0) + { + RenderUniform1i(CONST_STRING_NORMALMAPEXISTS_UNIFORM, 0); + } + + RenderUniformMatrix3fv(CONST_STRING_MODELROTATEMATRIX_UNIFORM, false, ShaderRotateMatrix.m); + RenderUniform3fv(CONST_STRING_MODELTRANSLATEVECTOR_UNIFORM, ShaderTranslateVector.v); + + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, NormTexID); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, TexID); + + for (int i=0; iDrawTriangleList(TriangleList); + + RenderUniform1i(CONST_STRING_NORMALMAPEXISTS_UNIFORM, 1); + + CheckGlError(); +} + + + + +void TLiteModel::MoveModel(const vec3& v) +{ + for (cardinal i = 0; i < TriangleCount * 3; i++) + { + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB][i] += v; + } +} + +void TLiteModel::RotateModel(const mat3& r) +{ + + for (cardinal i = 0; i < TriangleCount * 3; i++) + { + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB][i] = r * TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB][i]; + TriangleList.Data.Vec3CoordArr[CONST_STRING_NORMAL_ATTRIB][i] = r * TriangleList.Data.Vec3CoordArr[CONST_STRING_NORMAL_ATTRIB][i]; + TriangleList.Data.Vec3CoordArr[CONST_STRING_TANGENT_ATTRIB][i] = r * TriangleList.Data.Vec3CoordArr[CONST_STRING_TANGENT_ATTRIB][i]; + TriangleList.Data.Vec3CoordArr[CONST_STRING_BINORMAL_ATTRIB][i] = r * TriangleList.Data.Vec3CoordArr[CONST_STRING_BINORMAL_ATTRIB][i]; + } +} + +void TLiteModel::ScaleModel(float s) +{ + + for (cardinal i = 0; i < TriangleCount * 3; i++) + { + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB][i] *= s; + } + +} + + +void TLiteModel::ScaleModel(const vec3& s) +{ + + for (cardinal i = 0; i < TriangleCount * 3; i++) + { + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB][i].v[0] *= s.v[0]; + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB][i].v[1] *= s.v[1]; + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB][i].v[2] *= s.v[2]; + } + +} + +void TLiteModel::SetShaderTranslateVector(const vec3& v) +{ + ShaderTranslateVector = v; +} + +void TLiteModel::SetShaderRotateMatrix(const mat3& m) +{ + ShaderRotateMatrix = m; +} + + +//=================================================== +//=============== MODEL MANAGER ===================== +//=================================================== + +TModelManager::~TModelManager() +{ + + Clear(); + + *Console<<"ResourceManager::ModelManager deleting"; +} + +void TModelManager::Clear() +{ + if (LiteModelMap.size() != 0) + { + LiteModelMap.clear(); + *Console<<"ResourceManager::ModelManager cleared"; + } +} + +TLiteModelResource& TModelManager::operator[](const std::string& s) +{ + if (LiteModelMap.count(s) == 0) + { + throw ErrorToLog("Lite model with name " + s + " not loaded!"); + } + + return LiteModelMap[s]; +} + +bool TModelManager::AddLiteModel(const std::string& filename, const std::string& pathToResources) +{ + cardinal fileSize; + + std::string modelName = GetFileName(filename); + + //If model already exists + if (LiteModelMap.count(modelName) != 0) + return true; + + boost::shared_array fileArr = CreateMemFromFile((ResourceManager->PathToResources + filename), fileSize); + + if (!(fileArr[0] == 'L' && fileArr[1] == 'M' && fileArr[2] == 0 && fileArr[3] == 1)) + throw ErrorFileNotCorrect(filename); + + + LiteModelMap[modelName].SetPathToResource(GetFilePath(ResourceManager->PathToResources + filename)); + + bool result = LiteModelMap[modelName].LoadModel(fileArr, fileSize); + + if (!result) + throw ErrorFileNotLoaded(filename); + + *Console<<"Lite model added successfully: "+filename; + + return true; +} + +void TModelManager::DeleteLiteModel(const std::string& modelname) +{ + LiteModelMap.erase(modelname); + *Console<<"ResourceManager::ModelManager model deleted: "+modelname; +} + + +} //namespace SE \ No newline at end of file diff --git a/src/ModelManager/NewModelManager.cpp b/src/ModelManager/NewModelManager.cpp new file mode 100644 index 0000000..b0be1e0 --- /dev/null +++ b/src/ModelManager/NewModelManager.cpp @@ -0,0 +1,145 @@ +#include "include/ModelManager/NewModelManager.h" + +#include "include/Utils/Utils.h" +#include "include/Engine.h" + +namespace SE +{ + +const int CONST_DATA_STACK_SIZE = 20; + +void TFlexModelResource::Serialize(boost::property_tree::ptree& propertyTree) +{ + + BOOST_FOREACH(auto& ptree, propertyTree.get_child("Model.Vec3ArrMap")) + { + + std::string name = ptree.second.get(".name"); + + + BOOST_FOREACH(auto& vec3tree, ptree.second.get_child("")) + { + if (vec3tree.first == "Vec3") + { + DataTriangleList.Vec3CoordArr[name].push_back(StringToVec3(vec3tree.second.get(""))); + } + } + } + + BOOST_FOREACH(auto& ptree, propertyTree.get_child("Model.Vec2ArrMap")) + { + std::string name = ptree.second.get(".name"); + + BOOST_FOREACH(auto& vec2tree, ptree.second.get_child("")) + { + if (vec2tree.first == "Vec2") + { + DataTriangleList.Vec2CoordArr[name].push_back(StringToVec2(vec2tree.second.get(""))); + } + } + } + + BOOST_FOREACH(auto& ptree, propertyTree.get_child("Model.SamplerMap")) + { + if (ptree.first == "Sampler") + { + std::string name = ptree.second.get(".name"); + std::string value = ptree.second.get(".value"); + + SamplerMap[name] = value; + + } + } + +} + + + +void TFlexModel::PushModelDataTriangleList() +{ + if (DataTriangleListStack.size() == CONST_DATA_STACK_SIZE) + { + throw ErrorToLog("Error in TFlexModel::PushModelDataTriangleList - stack overflow!"); + } + + DataTriangleListStack.push(RenderPair.second.Data); +} + +void TFlexModel::PopModelDataTriangleList() +{ + if (DataTriangleListStack.size() == 0) + { + throw ErrorToLog("Error in TFlexModel::PushModelDataTriangleList - stack underflow!"); + } + + RenderPair.second.Data = DataTriangleListStack.top(); + + DataTriangleListStack.pop(); +} + +void TFlexModel::MoveModel(const vec3& v) +{ + MoveDataTriangleList(RenderPair.second.Data, v); +} + +void TFlexModel::RotateModel(const mat3& r) +{ + RotateDataTriangleList(RenderPair.second.Data, r); +} + +void TFlexModel::ScaleModel(float s) +{ + ScaleDataTriangleList(RenderPair.second.Data, s); +} + +void TFlexModel::ScaleModel(const vec3& s) +{ + ScaleDataTriangleList(RenderPair.second.Data, s); +} + +void TFlexModel::RefreshBuffer() +{ + RenderPair.second.RefreshBuffer(); +} + +void TFlexModel::Draw() +{ + TRenderParamsSetter setter(RenderPair.first); + + Renderer->DrawTriangleList(RenderPair.second); +} + + +void TFlexModelManager::LoadModelFromXml(std::string xmlFileName) +{ + TFlexModelResource model; + + std::string modelName = GetFileName(xmlFileName); + std::string modelPath = GetFilePath(xmlFileName); + + model.Serialize(*FileToPropertyTree(xmlFileName)); + + FlexModelResourceMap[modelName] = model; +} + +TFlexModel TFlexModelManager::InstanciateModel(const std::string& modelName) +{ + if (FlexModelResourceMap.count(modelName) == 0) + { + throw ErrorToLog("Model not loaded: " + modelName); + } + + TFlexModel model; + + model.RenderPair.second.Data = FlexModelResourceMap[modelName].DataTriangleList; + + model.RenderPair.second.RefreshBuffer(); + + model.RenderPair.first.SamplerMap = FlexModelResourceMap[modelName].SamplerMap; + + return model; +} + + + +} //namespace SE \ No newline at end of file diff --git a/src/OpenGLExt/OpenGlExt.cpp b/src/OpenGLExt/OpenGlExt.cpp new file mode 100644 index 0000000..77869f6 --- /dev/null +++ b/src/OpenGLExt/OpenGlExt.cpp @@ -0,0 +1,111 @@ +#include "include/OpenGlExt/OpenGlExt.h" + +namespace SE +{ + +//==================================================== +//===================== GLSL Shaders ================= +//==================================================== + +//Requires GL_VERSION_2_0 +PFNGLCREATEPROGRAMPROC glCreateProgram = NULL; +PFNGLDELETEPROGRAMPROC glDeleteProgram = NULL; +PFNGLLINKPROGRAMPROC glLinkProgram = NULL; +PFNGLVALIDATEPROGRAMPROC glValidateProgram = NULL; +PFNGLUSEPROGRAMPROC glUseProgram = NULL; +PFNGLGETPROGRAMIVPROC glGetProgramiv = NULL; +PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog = NULL; +PFNGLCREATESHADERPROC glCreateShader = NULL; +PFNGLDELETESHADERPROC glDeleteShader = NULL; +PFNGLSHADERSOURCEPROC glShaderSource = NULL; +PFNGLCOMPILESHADERPROC glCompileShader = NULL; +PFNGLATTACHSHADERPROC glAttachShader = NULL; +PFNGLDETACHSHADERPROC glDetachShader = NULL; +PFNGLGETSHADERIVPROC glGetShaderiv = NULL; +PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog = NULL; +PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation = NULL; +PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer = NULL; +PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray = NULL; +PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray = NULL; +PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation = NULL; +PFNGLUNIFORMMATRIX3FVPROC glUniformMatrix3fv = NULL; +PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv = NULL; +PFNGLUNIFORM1IPROC glUniform1i = NULL; +PFNGLUNIFORM1FVPROC glUniform1fv = NULL; +PFNGLUNIFORM3FVPROC glUniform2fv = NULL; +PFNGLUNIFORM3FVPROC glUniform3fv = NULL; +PFNGLUNIFORM4FVPROC glUniform4fv = NULL; +PFNGLVERTEXATTRIB1FPROC glVertexAttrib1f = NULL; +PFNGLVERTEXATTRIB2FPROC glVertexAttrib2f = NULL; +PFNGLVERTEXATTRIB3FPROC glVertexAttrib3f = NULL; +PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f = NULL; +PFNGLVERTEXATTRIB2FVPROC glVertexAttrib2fv = NULL; +PFNGLVERTEXATTRIB3FVPROC glVertexAttrib3fv = NULL; +PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv = NULL; +PFNGLGETACTIVEATTRIBPROC glGetActiveAttrib = NULL; +PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform = NULL; + + +//======================================= +//=========== Multitexture ============== +//======================================= + +//Requires GL version 1.3 +PFNGLACTIVETEXTUREPROC glActiveTexture = NULL; + +//======================================= +//========== Vertex buffer ============== +//======================================= + +//Requires GL_VERSION_1_5 +PFNGLGENBUFFERSPROC glGenBuffers = NULL; +PFNGLDELETEBUFFERSPROC glDeleteBuffers = NULL; +PFNGLBINDBUFFERPROC glBindBuffer = NULL; +PFNGLBUFFERDATAPROC glBufferData = NULL; +PFNGLBUFFERSUBDATAPROC glBufferSubData = NULL; +PFNGLMAPBUFFERPROC glMapBuffer = NULL; +PFNGLUNMAPBUFFERPROC glUnmapBuffer = NULL; + +//========================================= +//============ Frame buffer =============== +//========================================= + +//Requires GL_ARB_framebuffer_object +PFNGLISRENDERBUFFERPROC glIsRenderbuffer = NULL; +PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer = NULL; +PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers = NULL; +PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers = NULL; +PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage = NULL; +PFNGLGETRENDERBUFFERPARAMETERIVPROC glGetRenderbufferParameteriv = NULL; +PFNGLISFRAMEBUFFERPROC glIsFramebuffer = NULL; +PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer = NULL; +PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers = NULL; +PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers = NULL; +PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus = NULL; +PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D = NULL; +PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D = NULL; +PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D = NULL; +PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer = NULL; +PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv = NULL; +PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer = NULL; +PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample = NULL; +PFNGLGENERATEMIPMAPPROC glGenerateMipmap = NULL; +PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer = NULL; + + + +//=========================================== +//============ Uniform buffer =============== +//=========================================== + +//Requires GL_ARB_uniform_buffer_object +PFNGLGETUNIFORMINDICESPROC glGetUniformIndices = NULL; +PFNGLGETACTIVEUNIFORMSIVPROC glGetActiveUniformsiv = NULL; +PFNGLGETACTIVEUNIFORMNAMEPROC glGetActiveUniformName = NULL; +PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex = NULL; +PFNGLGETACTIVEUNIFORMBLOCKIVPROC glGetActiveUniformBlockiv = NULL; +PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glGetActiveUniformBlockName = NULL; +PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding = NULL; +PFNGLBINDBUFFERBASEPROC glBindBufferBase = NULL; + +} //namespace SE \ No newline at end of file diff --git a/src/Render/HalibutRender/HalibutRenderAndroid.cpp b/src/Render/HalibutRender/HalibutRenderAndroid.cpp new file mode 100644 index 0000000..1b7d530 --- /dev/null +++ b/src/Render/HalibutRender/HalibutRenderAndroid.cpp @@ -0,0 +1,7 @@ +#include "include/Engine.h" +#include "include/Render/HalibutRender/HalibutRenderAndroid.h" + +namespace SE +{ + +} //namespace SE \ No newline at end of file diff --git a/src/Render/HalibutRender/HalibutRenderGLES20.cpp b/src/Render/HalibutRender/HalibutRenderGLES20.cpp new file mode 100644 index 0000000..f9288f8 --- /dev/null +++ b/src/Render/HalibutRender/HalibutRenderGLES20.cpp @@ -0,0 +1,50 @@ +#include "include/Engine.h" +#include "include/Render/HalibutRender/HalibutRenderGLES20.h" + +namespace SE +{ + +THalibutRendererGLES20::THalibutRendererGLES20() +{ + ProjectionMatrixStack.push(IdentityMatrix4); + ModelviewMatrixStack.push(IdentityMatrix4); + *Console<<"Halibut Render created\n"; +} + +THalibutRendererGLES20::~THalibutRendererGLES20() +{ + *Console<<"Halibut Render destroying\n"; +} + +void THalibutRendererGLES20::DrawQuad(const T2DQuad& quad) +{ + + VertexAttribPointer3fv(CONST_STRING_POSITION_ATTRIB, 0, reinterpret_cast(quad.VertexCoord)); + VertexAttribPointer2fv(CONST_STRING_TEXCOORD_ATTRIB, 0, reinterpret_cast(quad.TextureCoord)); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + +} + +void THalibutRendererGLES20::DrawTriangleList(const TTriangleList& triangleList) +{ + + for (std::map >::iterator i = triangleList.Data.Vec2CoordArr.begin(); i != triangleList.Data.Vec2CoordArr.end(); ++i ) + { + VertexAttribPointer2fv(i->first, 0, reinterpret_cast(&triangleList.Data.Vec2CoordArr[i->first][0])); + } + + for (std::map >::iterator i = triangleList.Data.Vec3CoordArr.begin(); i != triangleList.Data.Vec3CoordArr.end(); ++i ) + { + VertexAttribPointer3fv(i->first, 0, reinterpret_cast(&triangleList.Data.Vec3CoordArr[i->first][0])); + } + + if (!triangleList.Data.Vec3CoordArr.empty()) + { + glDrawArrays(GL_TRIANGLES,0,triangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].size()); + } + +} + + +} //namespace SE \ No newline at end of file diff --git a/src/Render/HalibutRender/HalibutRenderInterface.cpp b/src/Render/HalibutRender/HalibutRenderInterface.cpp new file mode 100644 index 0000000..2e4bda1 --- /dev/null +++ b/src/Render/HalibutRender/HalibutRenderInterface.cpp @@ -0,0 +1,141 @@ +#include "include/Engine.h" + +namespace SE +{ + +void THalibutRendererInterface::SetUniforms() +{ + + if (ProjectionMatrixStack.size() <=0) + { + throw ErrorToLog("Projection matrix stack out!"); + } + + if (ModelviewMatrixStack.size() <=0) + { + throw ErrorToLog("Modelview matrix stack out!"); + } + + ProjectionModelviewMatrix = MultMatrixMatrix(ProjectionMatrixStack.top(), ModelviewMatrixStack.top()); + RenderUniformMatrix4fv(CONST_STRING_HALIBUT_PROJECTION_MATRIX_UNIFORM, false, ProjectionModelviewMatrix.m); + + //Refactoring! + + RenderUniform1i(CONST_STRING_TEXTURE_UNIFORM, 0); + RenderUniform1i(CONST_STRING_NORMALMAP_UNIFORM, 1); + + RenderUniform1f(CONST_STRING_TRANSPARENCY_UNIFORM, 1.f); + + RenderUniform4fv(CONST_STRING_MATERIAL_COLOR_UNIFORM, WhiteColor); + + + /* + RenderUniform1i(CONST_STRING_SHADOWMAPGLOBAL_UNIFORM,2); + RenderUniform1i(CONST_STRING_SHADOWMAPLOCAL_UNIFORM,3); + + RenderUniform1i(CONST_STRING_NORMALMAPEXISTS_UNIFORM,1); + RenderUniform1i(CONST_STRING_ENV_UNIFORM,0);*/ +} + +void THalibutRendererInterface::InitOpenGL(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight) +{ + + *Console<<"Halibut Render OpenGL init\n"; + + #ifdef TARGET_WIN32 + glEnable(GL_NORMALIZE); + glEnable(GL_TEXTURE_2D); + #endif + + glDisable(GL_DEPTH_TEST); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + ScreenWidth = screenWidth; + ScreenHeight = screenHeight; + + MatrixWidth = matrixWidth; + MatrixHeight = matrixHeight; + + while (!ProjectionMatrixStack.empty()) + { + ProjectionMatrixStack.pop(); + } + ProjectionMatrixStack.push(MakeOrthoMatrix(matrixWidth, matrixHeight)); + + while (!ModelviewMatrixStack.empty()) + { + ModelviewMatrixStack.pop(); + } + ModelviewMatrixStack.push(IdentityMatrix4); + + glViewport(0, 0, ScreenWidth, ScreenHeight); + + SetUniforms(); + #ifndef TARGET_IOS + SwitchToScreen(); + #endif + + CheckGlError(); + +} + +void THalibutRendererInterface::SwitchToScreen() +{ + //TODO: fix this stupid bug +#ifdef TARGET_IOS + glBindFramebuffer(GL_FRAMEBUFFER, 2); +#else + glBindFramebuffer(GL_FRAMEBUFFER, 0); +#endif + glViewport(0, 0, ScreenWidth, ScreenHeight); + SetProjectionMatrix(MatrixWidth, MatrixHeight); + SetUniforms(); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +} + +void THalibutRendererInterface::SwitchToFrameBuffer(const std::string& frameName) +{ + if (ResourceManager->FrameManager.FrameMap.count(frameName) > 0) + { + TFrame& Frame = ResourceManager->FrameManager.FrameMap[frameName]; + + glBindFramebuffer(GL_FRAMEBUFFER, Frame.FrameBuffer); + glViewport(0, 0, Frame.Width, Frame.Height); + SetProjectionMatrix(static_cast(Frame.Width), static_cast(Frame.Height)); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + } +} + +void THalibutRendererInterface::PrintMatrices() +{ + mat4 proj = ProjectionMatrixStack.top(); + mat4 modv = ModelviewMatrixStack.top(); + *Console<<"Projection:\n "; + for (int i=0; i<16; i++) + { + *Console<::const_iterator vertexIterator = triangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].begin(); + std::vector::const_iterator texcoordIterator = triangleList.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].begin(); + + for (int i=0; iv); + VertexAttrib3fv(CONST_STRING_POSITION_ATTRIB, (vertexIterator++)->v); + VertexAttrib2fv(CONST_STRING_TEXCOORD_ATTRIB, (texcoordIterator++)->v); + VertexAttrib3fv(CONST_STRING_POSITION_ATTRIB, (vertexIterator++)->v); + VertexAttrib2fv(CONST_STRING_TEXCOORD_ATTRIB, (texcoordIterator++)->v); + VertexAttrib3fv(CONST_STRING_POSITION_ATTRIB, (vertexIterator++)->v); + glEnd(); + } +} + + + +void THalibutRenderer::DrawTriangleList(const TTriangleList& triangleList) +{ + + //for (std::map >::iterator i = triangleList.Vec2CoordArr.begin(); i != triangleList.Vec2CoordArr.end(); ++i ) + BOOST_FOREACH(auto& i, triangleList.Data.Vec2CoordArr) + { + glBindBuffer(GL_ARRAY_BUFFER, triangleList.VertBufferArr[i.first]->Buffer); + VertexAttribPointer2fv(i.first, 0, NULL); + } + + //for (std::map >::iterator i = triangleList.Vec3CoordArr.begin(); i != triangleList.Vec3CoordArr.end(); ++i ) + BOOST_FOREACH(auto& i, triangleList.Data.Vec3CoordArr) + { + glBindBuffer(GL_ARRAY_BUFFER, triangleList.VertBufferArr[i.first]->Buffer); + VertexAttribPointer3fv(i.first, 0, NULL); + } + + if (!triangleList.Data.Vec3CoordArr.empty()) + { + glDrawArrays(GL_TRIANGLES,0,triangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].size()); + } + +} + +} //namespace SE + \ No newline at end of file diff --git a/src/Render/RenderInterface.cpp b/src/Render/RenderInterface.cpp new file mode 100644 index 0000000..b8f9ff2 --- /dev/null +++ b/src/Render/RenderInterface.cpp @@ -0,0 +1,324 @@ +#include "include/Render/RenderInterface.h" +#include "include/Engine.h" + +namespace SE +{ + +TRendererInterface::TRendererInterface() + : ScreenWidth(0) + , ScreenHeight(0) +{ +} + +void TRendererInterface::TryEnableVertexAttribArrays() +{ + EnableVertexAttribArray(CONST_STRING_POSITION_ATTRIB); + EnableVertexAttribArray(CONST_STRING_NORMAL_ATTRIB); + EnableVertexAttribArray(CONST_STRING_TEXCOORD_ATTRIB); + EnableVertexAttribArray(CONST_STRING_TANGENT_ATTRIB); + EnableVertexAttribArray(CONST_STRING_BINORMAL_ATTRIB); +} + +void TRendererInterface::TryDisableVertexAttribArrays() +{ + DisableVertexAttribArray(CONST_STRING_BINORMAL_ATTRIB); + DisableVertexAttribArray(CONST_STRING_TANGENT_ATTRIB); + DisableVertexAttribArray(CONST_STRING_TEXCOORD_ATTRIB); + DisableVertexAttribArray(CONST_STRING_NORMAL_ATTRIB); + DisableVertexAttribArray(CONST_STRING_POSITION_ATTRIB); +} + + +int TRendererInterface::GetScreenWidth() +{ + return ScreenWidth; +} + +int TRendererInterface::GetScreenHeight() +{ + return ScreenHeight; +} + +float TRendererInterface::GetMatrixWidth() +{ + return MatrixWidth; +} + + +float TRendererInterface::GetMatrixHeight() +{ + return MatrixHeight; +} + + + + +void TRendererInterface::SetScreenWidthHeight(int screenWidth, int screenHeight) +{ + ScreenWidth = screenWidth; + ScreenHeight = screenHeight; +} + +void TRendererInterface::PushMatrix() +{ + if (ModelviewMatrixStack.size() == 0) + { + throw ErrorToLog("Modelview matrix stack underflow!!!!"); + } + + ModelviewMatrixStack.push(ModelviewMatrixStack.top()); + + if (ModelviewMatrixStack.size() > 64) + { + throw ErrorToLog("Modelview matrix stack overflow!!!!"); + } +} + +void TRendererInterface::LoadIdentity() +{ + if (ModelviewMatrixStack.size() == 0) + { + throw ErrorToLog("Modelview matrix stack underflow!!!!"); + } + + ModelviewMatrixStack.pop(); + ModelviewMatrixStack.push(IdentityMatrix4); + + SetUniforms(); +} + +void TRendererInterface::TranslateMatrix(const vec3& p) +{ + mat4 m = IdentityMatrix4; + m.m[12] = p.v[0]; + m.m[13] = p.v[1]; + m.m[14] = p.v[2]; + m = MultMatrixMatrix(ModelviewMatrixStack.top(), m); + + if (ModelviewMatrixStack.size() == 0) + { + throw ErrorToLog("Modelview matrix stack underflow!!!!"); + } + + ModelviewMatrixStack.pop(); + ModelviewMatrixStack.push(m); + + SetUniforms(); +} + +void TRendererInterface::ScaleMatrix(float scale) +{ + mat4 m = IdentityMatrix4; + m.m[0] = scale; + m.m[5] = scale; + m.m[10] = scale; + m = MultMatrixMatrix(ModelviewMatrixStack.top(), m); + + if (ModelviewMatrixStack.size() == 0) + { + throw ErrorToLog("Modelview matrix stack underflow!!!!"); + } + + ModelviewMatrixStack.pop(); + ModelviewMatrixStack.push(m); + + SetUniforms(); +} + +void TRendererInterface::ScaleMatrix(const vec3& scale) +{ + mat4 m = IdentityMatrix4; + m.m[0] = scale.v[0]; + m.m[5] = scale.v[1]; + m.m[10] = scale.v[2]; + m = MultMatrixMatrix(ModelviewMatrixStack.top(), m); + + if (ModelviewMatrixStack.size() == 0) + { + throw ErrorToLog("Modelview matrix stack underflow!!!!"); + } + + ModelviewMatrixStack.pop(); + ModelviewMatrixStack.push(m); + + SetUniforms(); +} + +void TRendererInterface::RotateMatrix(const vec4& q) +{ + mat3 m3(q); + mat4 m = IdentityMatrix4; + m.m[0] = m3.m[0]; + m.m[1] = m3.m[1]; + m.m[2] = m3.m[2]; + + m.m[4] = m3.m[3]; + m.m[5] = m3.m[4]; + m.m[6] = m3.m[5]; + + m.m[8] = m3.m[6]; + m.m[9] = m3.m[7]; + m.m[10] = m3.m[8]; + + m = MultMatrixMatrix(ModelviewMatrixStack.top(), m); + + if (ModelviewMatrixStack.size() == 0) + { + throw ErrorToLog("Modelview matrix stack underflow!!!!"); + } + + ModelviewMatrixStack.pop(); + ModelviewMatrixStack.push(m); + + SetUniforms(); +} + +void TRendererInterface::PushSpecialMatrix(const mat4& m) +{ + if (ModelviewMatrixStack.size() > 64) + { + throw ErrorToLog("Modelview matrix stack overflow!!!!"); + } + ModelviewMatrixStack.push(m); + SetUniforms(); +} + + +void TRendererInterface::PopMatrix() +{ + if (ModelviewMatrixStack.size() == 0) + { + throw ErrorToLog("Modelview matrix stack underflow!!!!"); + } + ModelviewMatrixStack.pop(); + + SetUniforms(); +} + +void TRendererInterface::PushProjectionMatrix(float width, float height) +{ + mat4 m = MakeOrthoMatrix(width, height); + ProjectionMatrixStack.push(m); + SetUniforms(); + + if (ProjectionMatrixStack.size() > 64) + { + throw ErrorToLog("Projection matrix stack overflow!!!!"); + } +} + +void TRendererInterface::PopProjectionMatrix() +{ + if (ProjectionMatrixStack.size() == 0) + { + throw ErrorToLog("Projection matrix stack underflow!!!!"); + } + ProjectionMatrixStack.pop(); + SetUniforms(); +} + +void TRendererInterface::SetProjectionMatrix(float width, float height) +{ + mat4 m = MakeOrthoMatrix(width, height); + if (ProjectionMatrixStack.size() == 0) + { + throw ErrorToLog("Projection matrix stack underflow!!!!"); + } + ProjectionMatrixStack.pop(); + ProjectionMatrixStack.push(m); + SetUniforms(); + +} + +void TRendererInterface::SetFrameViewport(const std::string& frameName) +{ + ivec2 frameWidthHeight = ResourceManager->FrameManager.GetFrameWidthHeight(frameName); + glViewport(0, 0, frameWidthHeight.v[0], frameWidthHeight.v[1]); +} + +void TRendererInterface::SetFullScreenViewport() +{ + glViewport(0, 0, ScreenWidth, ScreenHeight); +} + +void TRendererInterface::PushShader(const std::string& shaderName) +{ + + ResourceManager->ShaderManager.PushShader(shaderName); + SetUniforms(); + TryEnableVertexAttribArrays(); +} + +void TRendererInterface::PopShader() +{ + + ResourceManager->ShaderManager.PopShader(); + SetUniforms(); + TryEnableVertexAttribArrays(); + +} + + +void TRendererInterface::DrawRect(const vec2& p1, const vec2& p2) +{ + T2DQuad quad; + + quad.VertexCoord[0] = vec3(p1.v[0], p1.v[1], 0.0f); + quad.VertexCoord[1] = vec3(p1.v[0], p2.v[1], 0.0f); + quad.VertexCoord[2] = vec3(p2.v[0], p1.v[1], 0.0f); + quad.VertexCoord[3] = vec3(p2.v[0], p2.v[1], 0.0f); + + quad.TextureCoord[0] = vec2(0.01f, 0.01f); + quad.TextureCoord[1] = vec2(0.01f, 0.99f); + quad.TextureCoord[2] = vec2(0.99f, 0.01f); + quad.TextureCoord[3] = vec2(0.99f, 0.99f); + + DrawQuad(quad); +} + +void TRendererInterface::DrawRect(const vec2& p1, const vec2& p2, const vec2& t1, const vec2& t2) +{ + T2DQuad quad; + + quad.VertexCoord[0] = vec3(p1.v[0], p1.v[1], 0.0f); + quad.VertexCoord[1] = vec3(p1.v[0], p2.v[1], 0.0f); + quad.VertexCoord[2] = vec3(p2.v[0], p1.v[1], 0.0f); + quad.VertexCoord[3] = vec3(p2.v[0], p2.v[1], 0.0f); + + quad.TextureCoord[0] = vec2(t1.v[0], t1.v[1]); + quad.TextureCoord[1] = vec2(t1.v[0], t2.v[1]); + quad.TextureCoord[2] = vec2(t2.v[0], t1.v[1]); + quad.TextureCoord[3] = vec2(t2.v[0], t2.v[1]); + + DrawQuad(quad); +} + + +void TRendererInterface::DrawFrameFullScreen(const std::string& frameName) +{ + + DrawFramePartScreen(frameName, vec2(0, 0), vec2(1, 1)); +} + +void TRendererInterface::DrawFramePartScreen(const std::string& frameName, vec2 posFrom, vec2 posTo) +{ + + cardinal texID = ResourceManager->FrameManager.GetFrameTexture(frameName.c_str()); + + if (texID != 0) + { + PushProjectionMatrix(1,1); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + LoadIdentity(); + glBindTexture(GL_TEXTURE_2D,texID); + + DrawRect(posFrom, posTo, posFrom, posTo); + + PopProjectionMatrix(); + + } + +} + +} //namespace SE \ No newline at end of file diff --git a/src/Render/RenderMisc.cpp b/src/Render/RenderMisc.cpp new file mode 100644 index 0000000..89e8f96 --- /dev/null +++ b/src/Render/RenderMisc.cpp @@ -0,0 +1,368 @@ +#include "include/Engine.h" + +namespace SE +{ + +#ifdef TARGET_WIN32 + +VBOObject::VBOObject() +{ + glGenBuffers(1, &Buffer); +} + +VBOObject::VBOObject(const VBOObject& c) +{ + throw ErrorToLog("Copy constructor for VBOObject called\n"); +} + + VBOObject& VBOObject::operator=(const VBOObject& c) +{ + throw ErrorToLog("operator= for VBOObject called\n"); + return *this; +} + + VBOObject::~VBOObject() +{ + glDeleteBuffers(1, &Buffer); +} + + +#endif + +TDataTriangleList& TDataTriangleList::operator+=(const TDataTriangleList& dataTriangleList) +{ + BOOST_FOREACH(auto& i, dataTriangleList.Vec3CoordArr) + { + if (Vec3CoordArr.count(i.first) == 0) + { + Vec3CoordArr[i.first] = i.second; + } + else + { + Vec3CoordArr[i.first].insert(Vec3CoordArr[i.first].end(), i.second.begin(), i.second.end()); + } + } + + BOOST_FOREACH(auto& i, dataTriangleList.Vec2CoordArr) + { + if (Vec2CoordArr.count(i.first) == 0) + { + Vec2CoordArr[i.first] = i.second; + } + else + { + Vec2CoordArr[i.first].insert(Vec2CoordArr[i.first].end(), i.second.begin(), i.second.end()); + } + } + + return *this; +} + + +TTriangleListAncestor::TTriangleListAncestor() + : NeedRefreshBuffer(false) +{ +} + +TTriangleListAncestor::TTriangleListAncestor(const TTriangleListAncestor& c) + : NeedRefreshBuffer(false) +{ + Data = c.Data; +} + +TTriangleListAncestor& TTriangleListAncestor::operator=(const TTriangleListAncestor& c) +{ + Data = c.Data; + NeedRefreshBuffer = c.NeedRefreshBuffer; + + return *this; +} + +TTriangleListAncestor::TTriangleListAncestor(const TDataTriangleList& dataTriangleList) + : NeedRefreshBuffer(false) +{ + Data = dataTriangleList; +} + +TTriangleListAncestor& TTriangleListAncestor::operator=(const TDataTriangleList& dataTriangleList) +{ + Data = dataTriangleList; + NeedRefreshBuffer = true; + + return *this; +} + +TTriangleListAncestor::~TTriangleListAncestor() +{ +} + + +#ifdef TARGET_WIN32 + +TTriangleList::TTriangleList() + : TTriangleListAncestor() + , NeedPrepareBufferObjects(true) +{ +} + +TTriangleList::~TTriangleList() +{ +} + +void TTriangleList::RefreshBuffer() +{ + //VertBuffer + + + if (NeedPrepareBufferObjects && Data.Vec2CoordArr.size() > 0 && Data.Vec3CoordArr.size() > 0) + { + + NeedPrepareBufferObjects = false; + + BOOST_FOREACH(auto& i, Data.Vec2CoordArr) + { + if (VertBufferArr[i.first] == std::shared_ptr()) + { + VertBufferArr[i.first] = std::shared_ptr(new VBOObject); + glBindBuffer(GL_ARRAY_BUFFER, VertBufferArr[i.first]->Buffer); + + //What to do if buffer becomes empty? + if (i.second.size() > 0) + { + glBufferData(GL_ARRAY_BUFFER, i.second.size() * 8, &i.second[0], GL_STATIC_DRAW); + } + else + { + glBufferData(GL_ARRAY_BUFFER, 0, NULL, GL_STATIC_DRAW); + } + } + + } + + BOOST_FOREACH(auto& i, Data.Vec3CoordArr) + //for (std::map >::iterator i = Data.Vec3CoordArr.begin(); i != Data.Vec3CoordArr.end(); ++i ) + { + if (VertBufferArr[i.first] == std::shared_ptr()) + { + VertBufferArr[i.first] = std::shared_ptr(new VBOObject); + glBindBuffer(GL_ARRAY_BUFFER, VertBufferArr[i.first]->Buffer); + + //What to do if buffer becomes empty? + if (i.second.size() > 0) + { + glBufferData(GL_ARRAY_BUFFER, i.second.size() * 12, &i.second[0], GL_STATIC_DRAW); + } + else + { + glBufferData(GL_ARRAY_BUFFER, 0, NULL, GL_STATIC_DRAW); + } + } + + + } + + } + + + BOOST_FOREACH(auto& i, Data.Vec2CoordArr) + { + glBindBuffer(GL_ARRAY_BUFFER, VertBufferArr[i.first]->Buffer); + RefreshAttribBuffer2fv(i.first, Data.Vec2CoordArr); + } + + BOOST_FOREACH(auto& i, Data.Vec3CoordArr) + { + glBindBuffer(GL_ARRAY_BUFFER, VertBufferArr[i.first]->Buffer); + RefreshAttribBuffer3fv(i.first, Data.Vec3CoordArr); + } + + +} + +#endif + +void FillVertexCoordVec(std::vector& coordVec, int pos, vec2 posFrom, vec2 posTo) +{ + vec2 pos1 = posFrom; + vec2 pos2 = vec2(posFrom.v[0], posTo.v[1]); + vec2 pos3 = posTo; + vec2 pos4 = vec2(posTo.v[0], posFrom.v[1]); + + coordVec[pos] = vec3(pos1, 0); + coordVec[pos+1] = vec3(pos2, 0); + coordVec[pos+2] = vec3(pos3, 0); + coordVec[pos+3] = vec3(pos3, 0); + coordVec[pos+4] = vec3(pos4, 0); + coordVec[pos+5] = vec3(pos1, 0); + +} + +void FillTexCoordVec(std::vector& coordVec, int pos, vec2 texCoordFrom, vec2 texCoordTo) +{ + vec2 tex1 = texCoordFrom; + vec2 tex2 = vec2(texCoordFrom.v[0], texCoordTo.v[1]); + vec2 tex3 = texCoordTo; + vec2 tex4 = vec2(texCoordTo.v[0], texCoordFrom.v[1]); + + + coordVec[pos] = tex1; + coordVec[pos+1] = tex2; + coordVec[pos+2] = tex3; + coordVec[pos+3] = tex3; + coordVec[pos+4] = tex4; + coordVec[pos+5] = tex1; + +} + + +std::vector MakeVertexCoordVec(vec2 posFrom, vec2 posTo) +{ + std::vector r; + r.resize(6); + + FillVertexCoordVec(r, 0, posFrom, posTo); + + return r; +} + +std::vector MakeTexCoordVec(vec2 texCoordFrom, vec2 texCoordTo) +{ + std::vector r; + r.resize(6); + FillTexCoordVec(r, 0, texCoordFrom, texCoordTo); + + return r; +} + + +TDataTriangleList MakeDataTriangleList(vec2 posFrom, vec2 posTo, vec2 texCoordFrom, vec2 texCoordTo) +{ + TDataTriangleList triangleList; + + triangleList.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB] = MakeVertexCoordVec(posFrom, posTo); + triangleList.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB] = MakeTexCoordVec(texCoordFrom, texCoordTo); + + return triangleList; +} + +void MoveDataTriangleList(TDataTriangleList& triangleList, vec3 shift) +{ + if (triangleList.Vec3CoordArr.count(CONST_STRING_POSITION_ATTRIB) == 0) + { + return; + } + + BOOST_FOREACH(auto& i, triangleList.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB]) + { + i += shift; + } +} + +void RotateDataTriangleList(TDataTriangleList& triangleList, const mat3& m) +{ + if (triangleList.Vec3CoordArr.count(CONST_STRING_POSITION_ATTRIB) == 0) + { + return; + } + + BOOST_FOREACH(vec3& i, triangleList.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB]) + { + i = i * m; + } +} + +void ScaleDataTriangleList(TDataTriangleList& triangleList, float scale) +{ + if (triangleList.Vec3CoordArr.count(CONST_STRING_POSITION_ATTRIB) == 0) + { + return; + } + + BOOST_FOREACH(vec3& i, triangleList.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB]) + { + i.v[0] *= scale; + i.v[1] *= scale; + i.v[2] *= scale; + } +} + +void ScaleDataTriangleList(TDataTriangleList& triangleList, vec3 scaleVec) +{ + if (triangleList.Vec3CoordArr.count(CONST_STRING_POSITION_ATTRIB) == 0) + { + return; + } + + BOOST_FOREACH(vec3& i, triangleList.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB]) + { + i.v[0] *= scaleVec.v[0]; + i.v[1] *= scaleVec.v[1]; + i.v[2] *= scaleVec.v[2]; + } +} + +TDataTriangleList& ClearDataTriangleList(TDataTriangleList& triangleList) +{ + //throw ErrorToLog("Seems that here are some problems with this func. Do not use it!"); + + BOOST_FOREACH(auto& i, triangleList.Vec2CoordArr) + { + i.second.clear(); + } + + BOOST_FOREACH(auto& i, triangleList.Vec3CoordArr) + { + i.second.clear(); + } + + return triangleList; +} + +TDataTriangleList& InsertIntoDataTriangleList(TDataTriangleList& triangleList, const std::vector& vertexArr, const std::vector& texCoordArr) +{ + triangleList.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].insert(triangleList.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].end(), vertexArr.begin(), vertexArr.end()); + triangleList.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].insert(triangleList.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].end(), texCoordArr.begin(), texCoordArr.end()); + + return triangleList; +} + + +TTriangleList MakeTriangleList(vec2 posFrom, vec2 posTo, vec2 texCoordFrom, vec2 texCoordTo) +{ + TTriangleList triangleList; + + triangleList.Data = MakeDataTriangleList(posFrom, posTo, texCoordFrom, texCoordTo); + + triangleList.RefreshBuffer(); + + return triangleList; + +} + +void Replace6PointsInTriangleList(TDataTriangleList& triangleList, int pos, vec2 posFrom, vec2 posTo, vec2 texCoordFrom, vec2 texCoordTo) +{ + FillVertexCoordVec(triangleList.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB], pos, posFrom, posTo); + FillTexCoordVec(triangleList.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB], pos, texCoordFrom, texCoordTo); +} + + + +void CheckGlError(const std::string& msg) +{ + cardinal error = glGetError(); + + if (error != GL_NO_ERROR) + { + if (msg == "") + { + throw ErrorToLog("Gl error = "+tostr(error)); + } + else + { + throw ErrorToLog("Gl error = "+tostr(error) + "; with message = " + msg); + } + } +} + + +} //namespace SE \ No newline at end of file diff --git a/src/Render/RenderParams.cpp b/src/Render/RenderParams.cpp new file mode 100644 index 0000000..26a3148 --- /dev/null +++ b/src/Render/RenderParams.cpp @@ -0,0 +1,114 @@ +#include "include/Engine.h" +#include "boost/lexical_cast.hpp" + +namespace SE +{ + +TRenderParamsSetter::TRenderParamsSetter(const TRenderParams& renderParams) + : RenderParams(renderParams) +{ + if (RenderParams.ShaderName != "") + { + Renderer->PushShader(RenderParams.ShaderName); + + } + else + { + Renderer->SetUniforms(); + } + + //Xperimental -- NEED TO DO SOMETHING WITH THIS, later! + glActiveTexture(GL_TEXTURE1); + + if (RenderParams.SamplerMap.count(CONST_STRING_NORMALMAP_UNIFORM)) + { + glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList[RenderParams.SamplerMap[CONST_STRING_NORMALMAP_UNIFORM]]); + } + else + { + glBindTexture(GL_TEXTURE_2D, 0); + } + + glActiveTexture(GL_TEXTURE0); + + if (RenderParams.SamplerMap.count(CONST_STRING_TEXTURE_UNIFORM)) + { + glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList[RenderParams.SamplerMap[CONST_STRING_TEXTURE_UNIFORM]]); + } + else + { + glBindTexture(GL_TEXTURE_2D, 0); + } + + for (std::map::iterator i = RenderParams.FloatMap.begin(); i != RenderParams.FloatMap.end(); ++i) + { + RenderUniform1f(i->first, i->second); + } + + for (std::map::iterator i = RenderParams.Vec4Map.begin(); i != RenderParams.Vec4Map.end(); ++i) + { + RenderUniform4fv(i->first, i->second.v); + } +} + +TRenderParamsSetter::~TRenderParamsSetter() +{ + if (RenderParams.ShaderName != "") + { + Renderer->PopShader(); + } +} + +/* + std::string ShaderName; + + mutable std::map SamplerMap; + mutable std::map FloatMap; + mutable std::map Vec4Map; + */ +void TRenderParams::Serialize(boost::property_tree::ptree& propertyTree) +{ + if (propertyTree.count("Shader") != 0) + { + ShaderName = propertyTree.get("Shader"); + } + + if (propertyTree.count("SamplerMap") != 0) + { + SamplerMap.clear(); + + TMapParser mapParser; + + mapParser.Serialize(propertyTree.get_child("SamplerMap")); + + SamplerMap = mapParser.Map; + } + + if (propertyTree.count("FloatMap") != 0) + { + SamplerMap.clear(); + + TMapParser mapParser; + + mapParser.Serialize(propertyTree.get_child("FloatMap")); + + FloatMap = mapParser.Map; + } + + if (propertyTree.count("Vec4Map") != 0) + { + SamplerMap.clear(); + + TMapParser mapParser; + + mapParser.Serialize(propertyTree.get_child("Vec4Map")); + + for (std::map::iterator i = mapParser.Map.begin(); i != mapParser.Map.end(); ++i) + { + Vec4Map[i->first] = StringToVec4(i->second); + } + + } +} + +} //namespace SE \ No newline at end of file diff --git a/src/Render/SalmonRender/BackgroundCubemap.cpp b/src/Render/SalmonRender/BackgroundCubemap.cpp new file mode 100644 index 0000000..df38b60 --- /dev/null +++ b/src/Render/SalmonRender/BackgroundCubemap.cpp @@ -0,0 +1,118 @@ +#include "include/Engine.h" + +namespace SE +{ + +const float CONST_CUBEMAP_SIDE = 50.0f; + +TBackgroundCubemapClass::TBackgroundCubemapClass() +{ + + + vec3 pos1 = vec3(-CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE); + vec3 pos2 = vec3(-CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE); + vec3 pos3 = vec3(-CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE); + vec3 pos4 = vec3(-CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE); + + + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos1); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos2); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos3); + + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos3); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos4); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos1); + + pos1 = vec3(CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE); + pos2 = vec3(CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE); + pos3 = vec3(CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE); + pos4 = vec3(CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE); + + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos1); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos2); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos3); + + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos3); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos4); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos1); + + pos1 = vec3(-CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE); + pos2 = vec3(CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE); + pos3 = vec3(CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE); + pos4 = vec3(-CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE); + + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos1); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos2); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos3); + + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos3); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos4); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos1); + + pos1 = vec3(-CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE); + pos2 = vec3(CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE); + pos3 = vec3(CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE); + pos4 = vec3(-CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE); + + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos1); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos2); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos3); + + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos3); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos4); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos1); + + pos1 = vec3(-CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE); + pos2 = vec3(CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE); + pos3 = vec3(CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE); + pos4 = vec3(-CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE); + + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos1); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos2); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos3); + + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos3); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos4); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos1); + + pos1 = vec3(-CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE); + pos2 = vec3(CONST_CUBEMAP_SIDE, -CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE); + pos3 = vec3(CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE); + pos4 = vec3(-CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE, CONST_CUBEMAP_SIDE); + + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos1); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos2); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos3); + + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos3); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos4); + TriangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].push_back(pos1); + + TriangleList.Data.Vec2CoordArr[CONST_STRING_TEXCOORD_ATTRIB].resize(36); //Texture coords actually not in use + + + TriangleList.RefreshBuffer(); +} + + +void TBackgroundCubemapClass::Draw() +{ + + mat4 m = Renderer->GetModelviewMatrix(); + + m.m[12] = 0.f; + m.m[13] = 0.f; + m.m[14] = 0.f; + + Renderer->PushSpecialMatrix(m); + + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_CUBE_MAP, BkgTexId); + + Renderer->DrawTriangleList(TriangleList); + Renderer->PopMatrix(); + +} + +} //namespace SE \ No newline at end of file diff --git a/src/Render/SalmonRender/SalmonRenderAndroid.cpp b/src/Render/SalmonRender/SalmonRenderAndroid.cpp new file mode 100644 index 0000000..4ce1dac --- /dev/null +++ b/src/Render/SalmonRender/SalmonRenderAndroid.cpp @@ -0,0 +1,9 @@ +#include "include/Render/SalmonRender/SalmonRenderAndroid.h" + +#include "include/Utils/Utils.h" +#include "include/Engine.h" + +namespace SE +{ + +} //namespace SE \ No newline at end of file diff --git a/src/Render/SalmonRender/SalmonRenderGLES20.cpp b/src/Render/SalmonRender/SalmonRenderGLES20.cpp new file mode 100644 index 0000000..95ac42d --- /dev/null +++ b/src/Render/SalmonRender/SalmonRenderGLES20.cpp @@ -0,0 +1,44 @@ +#include "include/Render/SalmonRender/SalmonRenderAndroid.h" + +#include "include/Utils/Utils.h" +#include "include/Engine.h" + +namespace SE +{ + +void TSalmonRendererGLES20::DrawQuad(const T2DQuad& quad) +{ + //EnableVertexAttribArray("vPosition"); + //EnableVertexAttribArray("vTexCoord"); + + VertexAttribPointer3fv("vPosition", 0, reinterpret_cast(quad.VertexCoord)); + VertexAttribPointer2fv("vTexCoord", 0, reinterpret_cast(quad.TextureCoord)); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + //DisableVertexAttribArray("vPosition"); + //DisableVertexAttribArray("vTexCoord"); +} + + + +void TSalmonRendererGLES20::DrawTriangleList(const TTriangleList& triangleList) +{ + for (std::map >::iterator i = triangleList.Data.Vec2CoordArr.begin(); i != triangleList.Data.Vec2CoordArr.end(); ++i ) + { + VertexAttribPointer2fv(i->first, 0, reinterpret_cast(&triangleList.Data.Vec2CoordArr[i->first][0])); + } + + for (std::map >::iterator i = triangleList.Data.Vec3CoordArr.begin(); i != triangleList.Data.Vec3CoordArr.end(); ++i ) + { + VertexAttribPointer3fv(i->first, 0, reinterpret_cast(&triangleList.Data.Vec3CoordArr[i->first][0])); + } + + if (!triangleList.Data.Vec3CoordArr.empty()) + { + glDrawArrays(GL_TRIANGLES,0,triangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].size()); + } + +} + +} //namespace SE diff --git a/src/Render/SalmonRender/SalmonRenderInterface.cpp b/src/Render/SalmonRender/SalmonRenderInterface.cpp new file mode 100644 index 0000000..5a069ed --- /dev/null +++ b/src/Render/SalmonRender/SalmonRenderInterface.cpp @@ -0,0 +1,810 @@ +#include "include/Render/SalmonRender/SalmonRenderInterface.h" + +#include "include/Utils/Utils.h" +#include "include/Engine.h" + +namespace SE +{ + + +TSalmonRendererInterface::TSalmonRendererInterface() + : CamAlpha(0.0f) + , CamPhi(0.0f) + , CamDist(0.0f) + , CamShift(ZeroVec3) + , GlobalShadowAreaHalfSize(CONST_DEFAULT_GLOBAL_SHADOW_AREA_HALFSIZE) +{ + ProjectionMatrixStack.push(IdentityMatrix4); + + ModelviewMatrixStack.push(IdentityMatrix4); + +} + + +void TSalmonRendererInterface::SetUniforms() +{ + + //Refactoring! + + + if (ProjectionMatrixStack.size() <=0) + { + throw ErrorToLog("Projection matrix stack out!"); + } + + if (ModelviewMatrixStack.size() <=0) + { + throw ErrorToLog("Modelview matrix stack out!"); + } + + ProjectionModelviewMatrix = MultMatrixMatrix(ProjectionMatrixStack.top(), ModelviewMatrixStack.top()); + RenderUniformMatrix4fv(CONST_STRING_HALIBUT_PROJECTION_MATRIX_UNIFORM, false, ProjectionModelviewMatrix.m); + + //TODO: Make a new name =( + RenderUniformMatrix4fv("ProjectionMatrix1", false, ProjectionMatrixStack.top().m); + + RenderUniform1i(CONST_STRING_TEXTURE_UNIFORM,0); + RenderUniform1i(CONST_STRING_NORMALMAP_UNIFORM,1); + RenderUniform1i(CONST_STRING_SHADOWMAPGLOBAL_UNIFORM,2); + RenderUniform1i(CONST_STRING_SHADOWMAPLOCAL_UNIFORM,3); + + RenderUniform1i(CONST_STRING_NORMALMAPEXISTS_UNIFORM,1); + RenderUniform1i(CONST_STRING_ENV_UNIFORM,0); + + //RenderUniform1f(CONST_STRING_SHADOWCLAMPVALUE_UNIFORM, GetShadowClampValue()); + //RenderUniform1i(CONST_STRING_ACTIVELIGHTCOUNT_UNIFORM, ResourceManager->LightManager.GetActiveLightCount()); + + //RenderUniform1f(CONST_STRING_FOG_BEGIN_DISTANCE_UNIFORM, GetFogBeginDistance()); + //RenderUniform1f(CONST_STRING_FOG_END_DISTANCE_UNIFORM, GetFogEndDistance()); + //RenderUniform4fv(CONST_STRING_FOG_COLOR_UNIFORM, GetFogColor().v); + + RenderUniform3fv(CONST_STRING_CAMPOS_UNIFORM, GetCamPos().v); + + ResourceManager->LightManager.SetLightUniforms(); +} + + +void TSalmonRendererInterface::InitOpenGL(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight) +{ + + ModelviewMatrixStack.push(IdentityMatrix4); + ProjectionMatrixStack.push(IdentityMatrix4); + + ScreenWidth = screenWidth; + ScreenHeight = screenHeight; + + MatrixWidth = matrixWidth; + MatrixHeight = matrixHeight; + + SetPerspectiveProjectionMatrix(pi / 6.f, 1.0, 1.0f, 100.0f); //Baad =( + + SetPerspectiveFullScreenViewport(); + + glEnable(GL_DEPTH_TEST); + #ifdef TARGET_WIN32 + glEnable(GL_LIGHTING); + glEnable(GL_NORMALIZE); + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glMaterialfv(GL_FRONT, GL_DIFFUSE, WhiteColor); + + glPolygonMode(GL_FRONT_AND_BACK , GL_FILL); + #endif + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + CheckGlError(); + +} + + +void TSalmonRendererInterface::CalcCamPosVec() +{ + + float sina = sinf(CamAlpha); + float cosa = cosf(CamAlpha); + float sinp = sinf(CamPhi); + float cosp = cosf(CamPhi); + + CamVec.v[0] = CamDist * cosp * sina; + CamVec.v[1] = - CamDist * sinp; + CamVec.v[2] = - CamDist * cosp * cosa; + + CamPos = CamShift - CamVec; + + RenderUniform3fv(CONST_STRING_CAMPOS_UNIFORM,(float*)&CamPos); +} + +void TSalmonRendererInterface::SetPerspectiveFullScreenViewport() +{ + + glViewport(0, 0, ScreenWidth, ScreenHeight); + + SetPerspectiveProjectionMatrix(pi / 6.f, float(MatrixWidth) / float(MatrixHeight), 1.0f, 100.0f); +} + +void TSalmonRendererInterface::SetOrthoFullScreenViewport() +{ + + glViewport(0, 0, ScreenWidth, ScreenHeight); + + SetProjectionMatrix(static_cast(MatrixWidth), static_cast(MatrixHeight)); +} + + +mat4 TSalmonRendererInterface::GetModelviewMatrix() +{ + if (ModelviewMatrixStack.size() == 0) + { + throw ErrorToLog("Modelview matrix stack underflow!!!!"); + } + return ModelviewMatrixStack.top(); +} + + +void TSalmonRendererInterface::SetPerspectiveProjectionMatrix(float angle, float aspect, float zNear, float zFar) +{ + mat4 m = MakePerspectiveMatrix(angle, aspect, zNear, zFar); + + if (ProjectionMatrixStack.size() == 0) + { + throw ErrorToLog("Projection matrix stack underflow!!!!"); + } + ProjectionMatrixStack.pop(); + ProjectionMatrixStack.push(m); + SetUniforms(); +} + +void TSalmonRendererInterface::PushPerspectiveProjectionMatrix(float angle, float aspect, float zNear, float zFar) +{ + mat4 m = MakePerspectiveMatrix(angle, aspect, zNear, zFar); + + ProjectionMatrixStack.push(m); + + if (ProjectionMatrixStack.size() > 64) + { + throw ErrorToLog("Projection matrix stack overflow!!!!"); + } + + SetUniforms(); +} + + + + + +void TSalmonRendererInterface::SetGLCamView() +{ + /* + glLoadIdentity(); + glTranslatef(0.0f, 0.0f, -CamDist); + glRotatef(CamPhi*180.0f/pi, 1.0f, 0.0f, 0.0f); + glRotatef(CamAlpha*180.0f/pi, 0.0f, 1.0f, 0.0f); + + //TODO + glTranslatef(-CamShift.v[0], -CamShift.v[1], -CamShift.v[2]); + + glGetFloatv(GL_MODELVIEW_MATRIX,CamModelViewMatrix.m); + + CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix); + + RenderUniform3fv(CONST_STRING_CAMPOS_UNIFORM,CamPos.v);*/ + + LoadIdentity(); + TranslateMatrix(vec3(0.0f, 0.0f, -CamDist)); + RotateMatrix(vec4(1.f * sin(CamPhi/2.f), 0.f, 0.f, 1.f * cos(CamPhi/2.f))); + RotateMatrix(vec4(0.f, 1.f * sin(CamAlpha/2.f), 0.f, 1.f * cos(CamAlpha/2.f))); + TranslateMatrix(-CamShift); + + CamModelViewMatrix = ModelviewMatrixStack.top(); + CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix); + + SetUniforms(); +} + +void TSalmonRendererInterface::SetGlIdentityView() +{ + /* + glLoadIdentity(); + + glGetFloatv(GL_MODELVIEW_MATRIX,CamModelViewMatrix.m); + + CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix); + + RenderUniform3fv(CONST_STRING_CAMPOS_UNIFORM, (float*)ZeroVec3.v);*/ + + LoadIdentity(); + + CamModelViewMatrix = ModelviewMatrixStack.top(); + CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix); + + SetUniforms(); +} + +void TSalmonRendererInterface::SetGlPosXView() +{ + /* + glLoadIdentity(); + glRotatef ( 90.0, 0.0, 1.0, 0.0 ); + glRotatef ( 180.0, 1.0, 0.0, 0.0 ); + glTranslatef(-CamPos.v[0], -CamPos.v[1], -CamPos.v[2]); + + glGetFloatv(GL_MODELVIEW_MATRIX,CamModelViewMatrix.m); + + CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix);*/ + + LoadIdentity(); + + RotateMatrix(vec4(0.f, 1.f * sin(pi / 4.f), 0.f, 1.f * cos(pi / 4.f))); + RotateMatrix(vec4(1.f * sin(pi / 2.f), 0.f, 0.f, 1.f * cos(pi / 2.f))); + + TranslateMatrix(-CamShift); + + CamModelViewMatrix = ModelviewMatrixStack.top(); + CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix); + + SetUniforms(); + +} + +void TSalmonRendererInterface::SetGlNegXView() +{ + /* + glLoadIdentity(); + glRotatef ( -90.0, 0.0, 1.0, 0.0 ); + glRotatef ( 180.0, 1.0, 0.0, 0.0 ); + glTranslatef(-CamPos.v[0], -CamPos.v[1], -CamPos.v[2]); + + glGetFloatv(GL_MODELVIEW_MATRIX,CamModelViewMatrix.m); + + CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix);*/ + + LoadIdentity(); + + RotateMatrix(vec4(0.f, -1.f * sin(pi / 4.f), 0.f, 1.f * cos(pi / 4.f))); + RotateMatrix(vec4(1.f * sin(pi / 2.f), 0.f, 0.f, 1.f * cos(pi / 2.f))); + + TranslateMatrix(-CamShift); + + CamModelViewMatrix = ModelviewMatrixStack.top(); + CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix); + + SetUniforms(); +} + +void TSalmonRendererInterface::SetGlPosYView() +{ + /* + glLoadIdentity(); + glRotatef ( -90.0, 1.0, 0.0, 0.0 ); + glTranslatef(-CamPos.v[0], -CamPos.v[1], -CamPos.v[2]); + + glGetFloatv(GL_MODELVIEW_MATRIX,CamModelViewMatrix.m); + + CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix);*/ + + LoadIdentity(); + RotateMatrix(vec4(-1.f * sin(pi / 4.f), 0.f, 0.f, 1.f * cos(pi / 4.f))); + + TranslateMatrix(-CamShift); + + CamModelViewMatrix = ModelviewMatrixStack.top(); + CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix); + + SetUniforms(); + +} + +void TSalmonRendererInterface::SetGlNegYView() +{ + /* + glLoadIdentity(); + glRotatef ( 90.0, 1.0, 0.0, 0.0 ); + glTranslatef(-CamPos.v[0], -CamPos.v[1], -CamPos.v[2]); + + glGetFloatv(GL_MODELVIEW_MATRIX,CamModelViewMatrix.m); + + CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix);*/ + + LoadIdentity(); + RotateMatrix(vec4(1.f * sin(pi / 4.f), 0.f, 0.f, 1.f * cos(pi / 4.f))); + + TranslateMatrix(-CamShift); + + CamModelViewMatrix = ModelviewMatrixStack.top(); + CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix); + + SetUniforms(); +} + +void TSalmonRendererInterface::SetGlPosZView() +{ + /* + glLoadIdentity(); + glRotatef ( 180.0, 0.0, 1.0, 0.0 ); + glRotatef ( 180.0, 0.0, 0.0, 1.0 ); + glTranslatef(-CamPos.v[0], -CamPos.v[1], -CamPos.v[2]); + + glGetFloatv(GL_MODELVIEW_MATRIX,CamModelViewMatrix.m); + + CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix); + */ + + LoadIdentity(); + + RotateMatrix(vec4(0.f, 1.f * sin(pi / 2.f), 0.f, 1.f * cos(pi / 2.f))); + RotateMatrix(vec4(0.f, 0.f, 1.f * sin(pi / 2.f), 1.f * cos(pi / 2.f))); + + TranslateMatrix(-CamShift); + + CamModelViewMatrix = ModelviewMatrixStack.top(); + CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix); + + SetUniforms(); +} + +void TSalmonRendererInterface::SetGlNegZView() +{ + /* + glLoadIdentity(); + glRotatef ( 180.0, 0.0, 0.0, 1.0 ); + glTranslatef(-CamPos.v[0], -CamPos.v[1], -CamPos.v[2]); + + glGetFloatv(GL_MODELVIEW_MATRIX,CamModelViewMatrix.m); + + CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix);*/ + + LoadIdentity(); + + RotateMatrix(vec4(0.f, 0.f, 1.f * sin(pi / 2.f), 1.f * cos(pi / 2.f))); + + TranslateMatrix(-CamShift); + + CamModelViewMatrix = ModelviewMatrixStack.top(); + CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix); + + SetUniforms(); + +} + + +vec3 TSalmonRendererInterface::GetCamPos() +{ + return CamPos; +} + + +void TSalmonRendererInterface::MoveAlpha(float dAlpha) +{ + if (dAlpha == 0.0f) + return; + + CamAlpha += dAlpha; + + while (CamAlpha >= 2*pi) + { + CamAlpha -= 2*pi; + } + + while (CamAlpha<0.0f) + { + CamAlpha += 2*pi; + } + + //Possibly refactor??? + CalcCamPosVec(); + /* + if (!IsCameraTransparentToLand && LandToCalcCollision->IsOnTheLand(CamPos)) + { + CamPhi -= CONST_CAMERA_PHI_ELEVATION_STEP; + + CalcCamPosVec(); + + float h = LandToCalcCollision->CalcVerticalCrossingFast(CamPos); + + if (h + CONST_CAMERA_VERTICAL_SHIFT > CamPos.v[1]) + { + CamPhi = CONST_MIN_CAM_PHI; + + CalcCamPosVec(); + + h = LandToCalcCollision->CalcVerticalCrossingFast(CamPos); + + while (h + CONST_CAMERA_VERTICAL_SHIFT > CamPos.v[1]) + { + CamPhi += CONST_CAMERA_PHI_ELEVATION_STEP; + CalcCamPosVec(); + } + } + else + { + CamPhi += CONST_CAMERA_PHI_ELEVATION_STEP; + CalcCamPosVec(); + } + } + */ +} + +void TSalmonRendererInterface::MovePhi(float dPhi) +{ + if (dPhi == 0.0f) + return; + + //float oldCamPhi = CamPhi; + CamPhi += dPhi; + + if (CamPhi > CONST_MAX_CAM_PHI) + { + CamPhi = CONST_MAX_CAM_PHI; + } + + if (CamPhi < CONST_MIN_CAM_PHI) + { + CamPhi = CONST_MIN_CAM_PHI; + } + + //Possibly refactor??? + CalcCamPosVec(); + /* + if (!IsCameraTransparentToLand && LandToCalcCollision->IsOnTheLand(CamPos)) + { + CamPhi -= CONST_CAMERA_PHI_ELEVATION_STEP; + + CalcCamPosVec(); + + float h = LandToCalcCollision->CalcVerticalCrossingFast(CamPos); + + if (h + CONST_CAMERA_VERTICAL_SHIFT > CamPos.v[1]) + { + CamPhi = CONST_MIN_CAM_PHI; + + CalcCamPosVec(); + + h = LandToCalcCollision->CalcVerticalCrossingFast(CamPos); + + while (h + CONST_CAMERA_VERTICAL_SHIFT > CamPos.v[1]) + { + CamPhi += CONST_CAMERA_PHI_ELEVATION_STEP; + CalcCamPosVec(); + } + } + else + { + CamPhi += CONST_CAMERA_PHI_ELEVATION_STEP; + CalcCamPosVec(); + } + }*/ + +} + +void TSalmonRendererInterface::MoveDist(float dDist) +{ + CamDist += dDist; /* + if (CamDist>CONST_MAX_CAM_DIST) + { + CamDist = CONST_MAX_CAM_DIST; + }*/ + + if (CamDistIsOnTheLand(CamPos)) + { + CamPhi -= CONST_CAMERA_PHI_ELEVATION_STEP; + + CalcCamPosVec(); + + float h = LandToCalcCollision->CalcVerticalCrossingFast(CamPos); + + if (h + CONST_CAMERA_VERTICAL_SHIFT > CamPos.v[1]) + { + CamPhi = CONST_MIN_CAM_PHI; + + CalcCamPosVec(); + + h = LandToCalcCollision->CalcVerticalCrossingFast(CamPos); + + while (h + CONST_CAMERA_VERTICAL_SHIFT > CamPos.v[1]) + { + CamPhi += CONST_CAMERA_PHI_ELEVATION_STEP; + CalcCamPosVec(); + } + } + else + { + CamPhi += CONST_CAMERA_PHI_ELEVATION_STEP; + CalcCamPosVec(); + } + }*/ + +} + + +void TSalmonRendererInterface::SetAlpha(float alpha) +{ + if (alpha == CamAlpha) + return; + + CamAlpha = alpha; + + while (CamAlpha >= 2*pi) + { + CamAlpha -= 2*pi; + } + + while (CamAlpha<0.0f) + { + CamAlpha += 2*pi; + } + + //Possibly refactor??? + CalcCamPosVec(); +} + +void TSalmonRendererInterface::MoveForward() +{ + vec3 mov; + + float sina = sinf(CamAlpha); + float cosa = cosf(CamAlpha); + + mov.v[0] = sina; + mov.v[1] = 0; + mov.v[2] = - cosa; + + CamShift = CamShift + mov; + + //Possibly refactor??? + CalcCamPosVec(); + /* + if (!IsCameraTransparentToLand && LandToCalcCollision->IsOnTheLand(CamPos)) + { + CamPhi -= CONST_CAMERA_PHI_ELEVATION_STEP; + + CalcCamPosVec(); + + float h = LandToCalcCollision->CalcVerticalCrossingFast(CamPos); + + if (h + CONST_CAMERA_VERTICAL_SHIFT > CamPos.v[1]) + { + CamPhi = CONST_MIN_CAM_PHI; + + CalcCamPosVec(); + + h = LandToCalcCollision->CalcVerticalCrossingFast(CamPos); + + while (h + CONST_CAMERA_VERTICAL_SHIFT > CamPos.v[1]) + { + CamPhi += CONST_CAMERA_PHI_ELEVATION_STEP; + CalcCamPosVec(); + } + } + else + { + CamPhi += CONST_CAMERA_PHI_ELEVATION_STEP; + CalcCamPosVec(); + } + }*/ + +} + +void TSalmonRendererInterface::MoveBackward() +{ + vec3 mov; + + float sina = sinf(CamAlpha); + float cosa = cosf(CamAlpha); + + mov.v[0] = - sina; + mov.v[1] = 0; + mov.v[2] = cosa; + + CamShift = CamShift + mov; + //Possibly refactor??? + CalcCamPosVec(); + /* + if (!IsCameraTransparentToLand && LandToCalcCollision->IsOnTheLand(CamPos)) + { + CamPhi -= CONST_CAMERA_PHI_ELEVATION_STEP; + + CalcCamPosVec(); + + float h = LandToCalcCollision->CalcVerticalCrossingFast(CamPos); + + if (h + CONST_CAMERA_VERTICAL_SHIFT > CamPos.v[1]) + { + CamPhi = CONST_MIN_CAM_PHI; + + CalcCamPosVec(); + + h = LandToCalcCollision->CalcVerticalCrossingFast(CamPos); + + while (h + CONST_CAMERA_VERTICAL_SHIFT > CamPos.v[1]) + { + CamPhi += CONST_CAMERA_PHI_ELEVATION_STEP; + CalcCamPosVec(); + } + } + else + { + CamPhi += CONST_CAMERA_PHI_ELEVATION_STEP; + CalcCamPosVec(); + } + }*/ + +} + +void TSalmonRendererInterface::MoveLeft() +{ + vec3 mov; + + float sina = sinf(CamAlpha); + float cosa = cosf(CamAlpha); + + mov.v[0] = - cosa; + mov.v[1] = 0; + mov.v[2] = - sina; + + CamShift = CamShift + mov; + + //Possibly refactor??? + CalcCamPosVec(); + /* + if (!IsCameraTransparentToLand && LandToCalcCollision->IsOnTheLand(CamPos)) + { + CamPhi -= CONST_CAMERA_PHI_ELEVATION_STEP; + + CalcCamPosVec(); + + float h = LandToCalcCollision->CalcVerticalCrossingFast(CamPos); + + if (h + CONST_CAMERA_VERTICAL_SHIFT > CamPos.v[1]) + { + CamPhi = CONST_MIN_CAM_PHI; + + CalcCamPosVec(); + + h = LandToCalcCollision->CalcVerticalCrossingFast(CamPos); + + while (h + CONST_CAMERA_VERTICAL_SHIFT > CamPos.v[1]) + { + CamPhi += CONST_CAMERA_PHI_ELEVATION_STEP; + CalcCamPosVec(); + } + } + else + { + CamPhi += CONST_CAMERA_PHI_ELEVATION_STEP; + CalcCamPosVec(); + } + } + */ +} + +void TSalmonRendererInterface::MoveRight() +{ + vec3 mov; + + float sina = sinf(CamAlpha); + float cosa = cosf(CamAlpha); + + mov.v[0] = cosa; + mov.v[1] = 0; + mov.v[2] = sina; + + CamShift = CamShift + mov; + + //Possibly refactor??? + CalcCamPosVec(); + /* + if (!IsCameraTransparentToLand && LandToCalcCollision->IsOnTheLand(CamPos)) + { + CamPhi -= CONST_CAMERA_PHI_ELEVATION_STEP; + + CalcCamPosVec(); + + float h = LandToCalcCollision->CalcVerticalCrossingFast(CamPos); + + if (h + CONST_CAMERA_VERTICAL_SHIFT > CamPos.v[1]) + { + CamPhi = CONST_MIN_CAM_PHI; + + CalcCamPosVec(); + + h = LandToCalcCollision->CalcVerticalCrossingFast(CamPos); + + while (h + CONST_CAMERA_VERTICAL_SHIFT > CamPos.v[1]) + { + CamPhi += CONST_CAMERA_PHI_ELEVATION_STEP; + CalcCamPosVec(); + } + } + else + { + CamPhi += CONST_CAMERA_PHI_ELEVATION_STEP; + CalcCamPosVec(); + } + }*/ + +} + + + +void TSalmonRendererInterface::SwitchToScreen() +{ + glBindFramebuffer(GL_FRAMEBUFFER, 0); + SetPerspectiveFullScreenViewport(); + SetGLCamView(); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +} + +void TSalmonRendererInterface::SwitchToFrameBuffer(const std::string& frameName) +{ + + if (ResourceManager->FrameManager.FrameMap.count(frameName) > 0) + { + TFrame Frame = ResourceManager->FrameManager.FrameMap[frameName]; + + glBindFramebuffer(GL_FRAMEBUFFER, Frame.FrameBuffer); + + SetFrameViewport(frameName); + + SetGLCamView(); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + } +} + +void TSalmonRendererInterface::SwitchToCubemapBuffer(const std::string& frameName,cardinal cubeSide) +{ + + + if (ResourceManager->FrameManager.FrameMap.count(frameName) > 0) + { + TFrame Frame = ResourceManager->FrameManager.FrameMap[frameName]; + + glBindFramebuffer(GL_FRAMEBUFFER, Frame.FrameBuffer); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + cubeSide, Frame.TexID, 0); + /* + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(90, 1, 1, 100); + glViewport(0, 0, Frame.Width, Frame.Height); + glMatrixMode(GL_MODELVIEW);*/ + + SetPerspectiveProjectionMatrix(90, 1, 1, 100); + + SetFrameViewport(frameName); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //IS A MUST!!! + } +} + + + +void TSalmonRendererInterface::BeginDrawToDepthBufferGlobal(std::string& globalBufferName) +{ + SwitchToFrameBuffer(globalBufferName); + //SetGLLightProjectionAndView(ZeroVec3, GlobalShadowAreaHalfSize, 0); +} + + +void TSalmonRendererInterface::BeginDrawToDepthBufferLocal(std::string& localBufferName) +{ + SwitchToFrameBuffer(localBufferName); + //SetGLLightProjectionAndView(CamShift, GlobalShadowAreaHalfSize/3.0f, 1); +} + +void TSalmonRendererInterface::EndDrawToDepthBuffer() +{ + SetPerspectiveFullScreenViewport(); +} + + +} //namespace SE + diff --git a/src/Render/SalmonRender/SalmonRenderIos.cpp b/src/Render/SalmonRender/SalmonRenderIos.cpp new file mode 100644 index 0000000..a81ec5a --- /dev/null +++ b/src/Render/SalmonRender/SalmonRenderIos.cpp @@ -0,0 +1,9 @@ +#include "include/Render/SalmonRender/SalmonRenderIos.h" + +#include "include/Utils/Utils.h" +#include "include/Engine.h" + +namespace SE +{ + +} //namespace SE \ No newline at end of file diff --git a/src/Render/SalmonRender/SalmonRenderWindows.cpp b/src/Render/SalmonRender/SalmonRenderWindows.cpp new file mode 100644 index 0000000..038d110 --- /dev/null +++ b/src/Render/SalmonRender/SalmonRenderWindows.cpp @@ -0,0 +1,335 @@ +#include "include/Render/SalmonRender/SalmonRenderWindows.h" + +#include "include/OpenGLExt/OpenGlExt.h" +#include "include/Utils/Utils.h" +#include "include/Engine.h" + +namespace SE +{ + +//=================================================== +//================ RENDER =========================== +//=================================================== + +TSalmonRenderer::TSalmonRenderer() : + ShadowClampValue(0.0f), + FogBeginDistance(CONST_DEFAULT_FOG_BEGIN_DISTANCE), + FogEndDistance(CONST_DEFAULT_FOG_END_DISTANCE), + FogColor(CONST_DEFAULT_FOG_COLOR), + LandToCalcCollision(NULL), + IsCameraTransparentToLand(true) +{ + +} + +TSalmonRenderer::~TSalmonRenderer() +{ +} + + + +bool TSalmonRenderer::BindOpenGLFunctions() +{ + char* extensionList = (char*)glGetString(GL_EXTENSIONS); + char* glVersion = (char*)glGetString(GL_VERSION); + bool ok = true; + + *Console< 1.0f) + ShadowClampValue = 1.0f; + + RenderUniform1f(CONST_STRING_SHADOWCLAMPVALUE_UNIFORM, ShadowClampValue); +} + + +float TSalmonRenderer::GetFogBeginDistance() +{ + return FogBeginDistance; +} + +float TSalmonRenderer::GetFogEndDistance() +{ + return FogEndDistance; +} + +vec4 TSalmonRenderer::GetFogColor() +{ + return FogColor; +} + + + + +void TSalmonRenderer::DrawTriangleList(const TTriangleList& triangleList) +{ + BOOST_FOREACH(auto& i, triangleList.Data.Vec2CoordArr) + { + glBindBuffer(GL_ARRAY_BUFFER, triangleList.VertBufferArr[i.first]->Buffer); + VertexAttribPointer2fv(i.first, 0, NULL); + } + + BOOST_FOREACH(auto& i, triangleList.Data.Vec3CoordArr) + { + glBindBuffer(GL_ARRAY_BUFFER, triangleList.VertBufferArr[i.first]->Buffer); + VertexAttribPointer3fv(i.first, 0, NULL); + } + + if (!triangleList.Data.Vec3CoordArr.empty()) + { + glDrawArrays(GL_TRIANGLES,0,triangleList.Data.Vec3CoordArr[CONST_STRING_POSITION_ATTRIB].size()); + } + +} + +} //namespace SE diff --git a/src/SalmonEngineAndroid.cpp b/src/SalmonEngineAndroid.cpp new file mode 100644 index 0000000..a95a542 --- /dev/null +++ b/src/SalmonEngineAndroid.cpp @@ -0,0 +1,82 @@ +#include "include/SalmonEngineAndroid.h" + +#include "include/Utils/Utils.h" + +namespace SE +{ + +void TApplication::OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight) +{ + OuterDeinit(); + + Console = new TJavaConsole; + + *Console<ScriptManager.BindBasicFunctions(); + + InnerInit(); + + Renderer->InitOpenGL(screenWidth, screenHeight, matrixWidth, matrixHeight); + CheckGlError(); +} + + +void TApplication::OuterDeinit() +{ + + if (Console != NULL) + { + *Console<<"OuterDeinit"; + } + + InnerDeinit(); + + if (ResourceManager != NULL) + { + delete ResourceManager; + ResourceManager = NULL; + } + + if (Console != NULL) + { + *Console<<"Resource manager deleted, deleting salmon render"; + } + + if (Renderer != NULL) + { + delete Renderer; + Renderer = NULL; + } + if (Console != NULL) + { + *Console<<"salmon render deleted"; + } + + + + if (Console != NULL) + { + delete Console; + Console = NULL; + } + +} + + +void TApplication::OuterDraw() +{ + InnerDraw(); +} + +void TApplication::OuterUpdate(cardinal timer) +{ + InnerUpdate(timer); +} + + +} //namespace SE \ No newline at end of file diff --git a/src/SalmonEngineInterface.cpp b/src/SalmonEngineInterface.cpp new file mode 100644 index 0000000..c7a66e9 --- /dev/null +++ b/src/SalmonEngineInterface.cpp @@ -0,0 +1,73 @@ +#include "include/SalmonEngineInterface.h" +namespace SE +{ + +#ifdef TARGET_ANDROID +TJavaConsole* Console; +TSalmonRendererAndroid* Renderer; +#endif + + +#ifdef TARGET_WIN32 +TFileConsole* Console; +TSalmonRenderer* Renderer; +#endif + +#ifdef TARGET_IOS +TIosConsole* Console; +TSalmonRendererIos* Renderer; +#endif + +TResourceManager* ResourceManager; + + +TApplicationAncestor::TApplicationAncestor() +{ + +} + +void TApplicationAncestor::OuterDeinit() +{ + InnerDeinit(); +} + + +void TApplicationAncestor::OuterDraw() +{ + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); + + glActiveTexture(GL_TEXTURE0); + RenderUniform1i("Texture", 0); + RenderUniform1f("Transparency", 1.f); + + InnerDraw(); + + glDisable(GL_DEPTH_TEST); + Renderer->PushShader("DefaultShader"); + + if (IsConsoleOut) + { + Console->Draw(); + } + + Renderer->PopShader(); + glEnable(GL_DEPTH_TEST); +} + +void TApplicationAncestor::OuterUpdate(cardinal timer) +{ + ResourceManager->SoundManager.Update(timer); + + InnerUpdate(timer); + + CheckGlError(); +} + +void TApplicationAncestor::OuterOnMove(vec2 shift) +{ + InnerOnMove(shift); +} + + +} //namespace SE \ No newline at end of file diff --git a/src/SalmonEngineIos.cpp b/src/SalmonEngineIos.cpp new file mode 100644 index 0000000..e6f3629 --- /dev/null +++ b/src/SalmonEngineIos.cpp @@ -0,0 +1,83 @@ +#include "include/SalmonEngineIos.h" + +#include "include/Utils/Utils.h" + + +namespace SE +{ + +void TApplication::OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight) +{ + OuterDeinit(); + + Console = new TIosConsole; + + *Console<ScriptManager.BindBasicFunctions(); + + InnerInit(); + + Renderer->InitOpenGL(screenWidth, screenHeight, matrixWidth, matrixHeight); + CheckGlError(); +} + + +void TApplication::OuterDeinit() +{ + + if (Console != NULL) + { + *Console<<"OuterDeinit"; + } + + InnerDeinit(); + + if (ResourceManager != NULL) + { + delete ResourceManager; + ResourceManager = NULL; + } + + if (Console != NULL) + { + *Console<<"Resource manager deleted, deleting salmon render"; + } + + if (Renderer != NULL) + { + delete Renderer; + Renderer = NULL; + } + if (Console != NULL) + { + *Console<<"salmon render deleted"; + } + + + + if (Console != NULL) + { + delete Console; + Console = NULL; + } + +} + + +void TApplication::OuterDraw() +{ + InnerDraw(); +} + +void TApplication::OuterUpdate(cardinal timer) +{ + InnerUpdate(timer); +} + + +} //namespace SE \ No newline at end of file diff --git a/src/SalmonEngineWindows.cpp b/src/SalmonEngineWindows.cpp new file mode 100644 index 0000000..35c6389 --- /dev/null +++ b/src/SalmonEngineWindows.cpp @@ -0,0 +1,401 @@ + +#include "include/Utils/Utils.h" +#include "include/SalmonEngineWindows.h" + + +namespace SE +{ + +//============================================================== +//========= GLOBAL VARIABLES - REMEMBER THIS LIST!!! =========== +//============================================================== + +HGLRC hRC; //Render context +HWND Hwnd; //Main window handle +HDC hDC; //Device context + +//============================================================== +//=============== GLOBAL VARS ENDS ============================= +//============================================================== + +//There might be anything +const char CONST_WINDOW_CLASS_NAME[] = "TSalmonEngineForm"; + +const cardinal CONST_TIMER_INTERVAL = 10; + +//To calculate when to call Update +cardinal NewTickCount; +cardinal LastTickCount; + +//User application +TApplication* App = NULL; + + + +void TApplication::OnKeyPress(cardinal key) +{ + if (IsConsoleOut) + { + + if (key == 96 || key == 126 /*|| key == 184 || key == 168*/) //~, 184 and 168 is russian e + { + IsConsoleOut = false; + } + else if (key == 8) //Backspace + { + if (Console->ConsoleInput.size() > 0 && Console->ConsoleCursor > 0) + { + Console->ConsoleInput.erase(Console->ConsoleInput.begin() + Console->ConsoleCursor-1); + Console->ConsoleCursor--; + } + } + else if (key == 13|| key == 10) //Enter + { + ResourceManager->ScriptManager.RunScript(Console->ConsoleInput); + + Console->InputHistory.push_back(Console->ConsoleInput); + + Console->InputHistoryCursor = Console->InputHistory.size(); + + Console->ConsoleInput = ""; + Console->ConsoleCursor = 0; + } + else if (key >= 32 && key <= 255) //ASCII + { + Console->ConsoleInput.insert(Console->ConsoleInput.begin()+Console->ConsoleCursor, static_cast(key)); + Console->ConsoleCursor++; + } + else if (key > 0x100) //VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT + { + cardinal realKey = key - 0x100; + + if (realKey == VK_UP) + { + if (Console->InputHistoryCursor > 0) + { + Console->InputHistoryCursor--; + Console->ConsoleInput = Console->InputHistory[Console->InputHistoryCursor]; + Console->ConsoleCursor = Console->ConsoleInput.size(); + } + } + if (realKey == VK_DOWN) + { + if ( Console->InputHistoryCursor+1 < Console->InputHistory.size()) + { + Console->InputHistoryCursor++; + Console->ConsoleInput = Console->InputHistory[Console->InputHistoryCursor]; + Console->ConsoleCursor = Console->ConsoleInput.size(); + } + } + if (realKey == VK_LEFT) + { + if (Console->ConsoleCursor > 0) + { + Console->ConsoleCursor--; + } + } + if (realKey == VK_RIGHT) + { + if (Console->ConsoleCursor < Console->ConsoleInput.size()) + { + Console->ConsoleCursor++; + } + } + + } + else + { + *Console<<"Key is "+tostr(key)+endl; + } + + } + else + { + if (key == 96 || key == 126 /*|| key == 184 || key == 168*/) //~, 184 and 168 is russian e + { + IsConsoleOut = true; + Console->ConsoleInput = ""; + Console->ConsoleCursor = Console->ConsoleInput.size(); + } + } +} + + +void DrawScene() +{ + App->OuterDraw(); + SwapBuffers(hDC); +} + +void ProcessTickCount() +{ + + App->UpdateQuick(); + NewTickCount = GetTickCount(); + if (NewTickCount - LastTickCount > CONST_TIMER_INTERVAL) + { + LastTickCount = NewTickCount; + App->OuterUpdate(CONST_TIMER_INTERVAL); + } + +} + +LONG WINAPI WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + static PAINTSTRUCT ps; + + TMouseState mouseState; + + switch(uMsg) + { + case WM_CLOSE: + Hwnd = 0; //HACK to force window to close + PostQuitMessage(0); + //Xperimental + return DefWindowProc(hWnd, uMsg, wParam, lParam); + + break; + case WM_PAINT: + DrawScene(); + BeginPaint(hWnd, &ps); + EndPaint(hWnd, &ps); + + ProcessTickCount(); + break; + case WM_SIZE: + + PostMessage(hWnd, WM_PAINT, 0, 0); + break; + case WM_CHAR: + App->OnKeyPress(wParam); + /* + switch (wParam) + { + case 27: + PostQuitMessage(0); + Hwnd = 0; + + //Xperimental + return DefWindowProc(hWnd, uMsg, wParam, lParam); + + break; + //... Will add more code later + }*/ + break; + + case WM_MOUSEMOVE: + mouseState.X = (lParam << 16) >> 16; + mouseState.Y = lParam >> 16; + mouseState.LeftButtonPressed = (wParam & MK_LBUTTON); + mouseState.MiddleButtonPressed = (wParam & MK_MBUTTON); + mouseState.RightButtonPressed = (wParam & MK_RBUTTON); + + App->OnMouseMove(mouseState); + break; + + case WM_LBUTTONDOWN: + case WM_RBUTTONDOWN: + mouseState.X = (lParam << 16) >> 16; + mouseState.Y = lParam >> 16; + mouseState.LeftButtonPressed = (wParam & MK_LBUTTON); + mouseState.MiddleButtonPressed = (wParam & MK_MBUTTON); + mouseState.RightButtonPressed = (wParam & MK_RBUTTON); + + App->OnMouseDown(mouseState); + break; + case WM_LBUTTONUP: + case WM_RBUTTONUP: + mouseState.X = (lParam << 16) >> 16; + mouseState.Y = lParam >> 16; + mouseState.LeftButtonPressed = (wParam & MK_LBUTTON); + mouseState.MiddleButtonPressed = (wParam & MK_MBUTTON); + mouseState.MiddleButtonPressed = (wParam & MK_RBUTTON); + + App->OnMouseUp(mouseState); + break; + + case WM_MOUSEWHEEL: + App->OnMouseWheel(wParam >> 16); + break; + } + + return DefWindowProc(hWnd, uMsg, wParam, lParam); +} + +bool CreateOpenGLWindow(const char* title, int x, int y, int width, int height,HWND& hWnd, HDC& hDC, HGLRC& hRC) +{ + int pf; + WNDCLASS wc; + PIXELFORMATDESCRIPTOR pfd; + static HINSTANCE hInstance = 0; + + if (!hInstance) + { + hInstance = GetModuleHandle(NULL); + wc.style = CS_OWNDC; + wc.lpfnWndProc = (WNDPROC)WindowProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.lpszClassName = CONST_WINDOW_CLASS_NAME; + + if (!RegisterClass(&wc)) + { + return NULL; + } + } + + RECT r; + r.left = x; + r.right = x + width; + r.top = y; + r.bottom = y + height; + + DWORD windowStyle = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; + + AdjustWindowRect(&r, windowStyle, false); + + hWnd = CreateWindow(CONST_WINDOW_CLASS_NAME, title, windowStyle, 0, 0, r.right-r.left, r.bottom-r.top, NULL, NULL, hInstance, NULL); + + if (hWnd == NULL) + { + return false; + } + + hDC = GetDC(hWnd); + + memset(&pfd, 0, sizeof(pfd)); + pfd.nSize = sizeof(pfd); + pfd.nVersion = 1; + pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; + pfd.iPixelType = PFD_TYPE_RGBA; + pfd.cColorBits = 32; + + pf = ChoosePixelFormat(hDC, &pfd); + if (pf == 0) + { + return false; + } + + if (SetPixelFormat(hDC, pf, &pfd) == FALSE) + { + return false; + } + + hRC = wglCreateContext( hDC ); + wglMakeCurrent( hDC, hRC ); + + return true; +} + +int MainLoop(TApplication& application) +{ + MSG msg; + + //Here console log is not created so we can not use ErrorCommon + try + { + Console = new TFileConsole(application.GetLogFilename()); + } + catch(...) + { + exit(1); + } + + //Here console log is already created + try + { + + *Console<<"Log started"; + + if (!CreateOpenGLWindow(application.WindowName.c_str(), application.X, application.Y, application.Width, application.Height,Hwnd,hDC,hRC)) + { + *Console<<"Unable to create OpenGL Window!"; + exit(1); + } + + *Console<<"OpenGL Window created"; + + + if (App != NULL) + throw ErrorCommon(); + + App = &application; + + Renderer = new TSalmonRenderer; + ResourceManager = new TResourceManager; + + int width; + int height; + + GetWindowWidthHeight(width, height); + + + if (Renderer->BindOpenGLFunctions()) + { + + App->OuterInit(width, height, static_cast(width), static_cast(height)); + + ShowWindow(Hwnd, SW_SHOW); + UpdateWindow(Hwnd); + + NewTickCount = GetTickCount(); + LastTickCount = NewTickCount; + + bool StayIn = true; + + while (StayIn) + { + while(PeekMessage(&msg, Hwnd, 0, 0, PM_NOREMOVE)) + { + if(GetMessage(&msg, Hwnd, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + else + { + StayIn = false; + } + } + DrawScene(); + + ProcessTickCount(); + } + + } + + *Console<<"Program prepares to quit"; + + App->OuterDeinit(); + + delete ResourceManager; + delete Renderer; + + + wglMakeCurrent(NULL, NULL); + ReleaseDC(Hwnd,hDC); + wglDeleteContext(hRC); + DestroyWindow(Hwnd); + + } + catch(...) + { + //... let the ErrorTypes.h do the buisness + } + + + delete Console; + + + return 0; +} + + + +} //namespace SE + diff --git a/src/ScriptManager/ScriptManager.cpp b/src/ScriptManager/ScriptManager.cpp new file mode 100644 index 0000000..e4079d5 --- /dev/null +++ b/src/ScriptManager/ScriptManager.cpp @@ -0,0 +1,206 @@ +#include "include/Engine.h" +#include "include/ScriptManager/ScriptManager.h" + + +namespace SE +{ + +std::vector TFunctionBinderInterface::BinderList; + + +TScriptManager::TScriptManager() +{ + SquirrelVM::Init(); + + virtualMachine = SquirrelVM::GetVMPtr(); + + //SqPlus::RegisterGlobal(virtualMachine, SQ_Print, _SC("Print")); + //SqPlus::RegisterGlobal(virtualMachine, SQ_Print, _SC("p")); + + //boost::function f = xxx; + + /* + SqPlus::RegisterGlobal(virtualMachine, ResourceManager->GUIManager, &TGUIManager::PrintWidgetList, _SC("PrintWidgetList")); + //SqPlus::RegisterGlobal(virtualMachine, SQ_PrintWidgetList, _SC("pwl")); + //SqPlus::RegisterGlobal(virtualMachine, Tm >(f), &Tm >::operator(), _SC("pwl")); + RegisterFunc(ResourceManager->GUIManager, &TGUIManager::PrintWidgetList, ""); + */ + + /* + AddFunction("pwl", + TScriptInfo("PrintWidgetList", "Print out list of widgets registered in system", "Print out list of widgets registered in system"), + ResourceManager->GUIManager, + &TGUIManager::PrintWidgetList);*/ + + /* + AddFuncDescription("pwl", TScriptInfo("PrintWidgetList", "Print out list of widgets registered in system", "Print out list of widgets registered in system")); + SqPlus::RegisterGlobal(virtualMachine, ResourceManager->GUIManager, &TGUIManager::PrintWidgetList, _SC("PrintWidgetList")); + SqPlus::RegisterGlobal(virtualMachine, ResourceManager->GUIManager, &TGUIManager::PrintWidgetList, _SC("pwl")); + + SqPlus::RegisterGlobal(virtualMachine, SQ_MoveWidget, _SC("MoveWidget")); + SqPlus::RegisterGlobal(virtualMachine, SQ_MoveWidget, _SC("mw")); + + SqPlus::RegisterGlobal(virtualMachine, SQ_MoveWidgetTransformTaskTest, _SC("MoveWidgetTransformTaskTest")); + SqPlus::RegisterGlobal(virtualMachine, SQ_MoveWidgetTransformTaskTest, _SC("mwttt")); + + SqPlus::RegisterGlobal(virtualMachine, SQ_PrintTextureList, _SC("PrintTextureList")); + SqPlus::RegisterGlobal(virtualMachine, SQ_PrintTextureList, _SC("ptl")); + + SqPlus::RegisterGlobal(virtualMachine, SQ_PrintAnimationList, _SC("PrintAnimationList")); + SqPlus::RegisterGlobal(virtualMachine, SQ_PrintAnimationList, _SC("pal")); + */ + + + *Console<<"Script manager ready"; +} + + +TScriptManager::~TScriptManager() +{ + *Console<<"Script manager shutdown"; + SquirrelVM::Shutdown(); +} + +void TScriptManager::RunScript(const std::string& scriptCode) +{ + try + { + SquirrelObject m = SquirrelVM::CompileBuffer(_T(scriptCode.c_str())); + + SquirrelVM::RunScript(m); + } + catch (SquirrelError) + { + *Console<<"Script failed to run"; + } + +} + + +void TScriptManager::BindBasicFunctions() +{ + //Hack =D + static bool alreadyBind = false; + + if (!alreadyBind) + { + *Console<<"Bind basic functions"; + + AddFunction("p", TScriptInfo("Print"), SQ_Print); + + AddFunction("help", TScriptInfo("Help"), *this, &TScriptManager::PrintRegisteredFunctionList); + + AddFunction("man", TScriptInfo("Manual"), *this, &TScriptManager::PrintFunctionInfo); + + std::vector::iterator i; + + for (i = TFunctionBinderInterface::BinderList.begin(); i != TFunctionBinderInterface::BinderList.end(); ++i) + { + + (*i)->BindFunctions(); + } + + alreadyBind = true; + } + + + + +} + + +void TScriptManager::AddFuncDescription(const std::string& shortName, TScriptInfo scriptInfo) +{ + if (FuncInfoMap.count(shortName) > 0) + { + //If this description is already exists + scriptInfo.Registered = FuncInfoMap[shortName].Registered; + } + + FuncInfoMap[shortName] = scriptInfo; + + +} + + +void TScriptManager::BindFunctionsFromObject(TFunctionBinderInterface* binderObject) +{ + binderObject->BindFunctions(); +} + + +void TScriptManager::PrintRegisteredFunctionList() +{ + std::map::iterator i; + + Console->PrintImmediate("========== Console function list ==========="); + + for (i = FuncInfoMap.begin(); i != FuncInfoMap.end(); ++i) + { + if (i->second.Registered) + { + Console->PrintImmediate(i->first + " | " + i->second.ShortDescription); + } + } +} + +void TScriptManager::PrintFunctionInfo(const std::string& funcName) +{ + if (FuncInfoMap.count(funcName) > 0 && FuncInfoMap[funcName].Registered) + { + Console->PrintImmediate( funcName + " | " + FuncInfoMap[funcName].LongName + " | " + FuncInfoMap[funcName].Description); + } +} + +void TScriptManager::Serialize(boost::property_tree::ptree& propertyTree) +{ + + BOOST_FOREACH(boost::property_tree::ptree::value_type &v, propertyTree.get_child("FunctionInfoList")) + { + std::string shortName = v.second.get("ShortName"); + std::string longName = v.second.get("LongName"); + std::string shortDescription = v.second.get("ShortDescription"); + std::string description = v.second.get("Description"); + + AddFuncDescription(shortName, TScriptInfo(longName, shortDescription, description)); + } +} + + +//============================================= +//============= Typical commands ============== +//============================================= + +void SQ_Print(const SQChar *inString) +{ + Console->PrintImmediate(std::string(inString)); +} + +/* +void SQ_PrintWidgetList() +{ + ResourceManager->GUIManager.PrintWidgetList(); +} + +void SQ_MoveWidget(const SQChar *widgetName, float x, float y) +{ + ResourceManager->GUIManager.MoveWidget(std::string(widgetName), vec2(x,y)); +} + +void SQ_MoveWidgetTransformTaskTest(const SQChar *groupName, float x, float y, cardinal totalTime) +{ + ResourceManager->GUIManager.AddWidgetTransformTask(TWidgetTransformTask(std::string(groupName), vec2(x,y), totalTime, 0, TWidgetTransformTask::MS_SQRT)); +} + + +void SQ_PrintTextureList() +{ + ResourceManager->TexList.PrintTextureList(); +} + +void SQ_PrintAnimationList() +{ + ResourceManager->HalibutAnimationManager.PrintAnimationList(); +}*/ + +} //namespace SE \ No newline at end of file diff --git a/src/ShaderManager/ShaderManager.cpp b/src/ShaderManager/ShaderManager.cpp new file mode 100644 index 0000000..96ce1c2 --- /dev/null +++ b/src/ShaderManager/ShaderManager.cpp @@ -0,0 +1,405 @@ +#include "include/ShaderManager/ShaderManager.h" + +#include "include/Utils/Utils.h" +#include "include/Engine.h" + +namespace SE +{ + +//=================================================== +//============== SHADER RESOURCE ==================== +//=================================================== + + + +TShaderResource::TShaderResource() + : ShaderProgram(0) +{ +} + +TShaderResource::~TShaderResource() +{ + + *Console<<"ResourceManager::ShaderManager::Shader deleting"; + FreeShader(); + +} + +bool TShaderResource::CompileShader(boost::shared_array vertexCode, boost::shared_array fragmentCode) +{ + + FreeShader(); + + const int CONST_INFOLOG_LENGTH = 256; + + char infoLog[CONST_INFOLOG_LENGTH]; + int infoLogLength; + + int vertexShaderCompiled; + int fragmentShaderCompiled; + int programLinked; + + cardinal vertexShader; + cardinal fragmentShader; + + int vertexCodeLength = strlen(vertexCode.get()); + int fragmentCodeLength = strlen(fragmentCode.get()); + + const char* vc = &vertexCode[0]; + const char* fc = &fragmentCode[0]; + + vertexShader = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vertexShader, 1, &(vc), &vertexCodeLength); + + fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fragmentShader, 1, &(fc), &fragmentCodeLength); + + glCompileShader(vertexShader); + glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &vertexShaderCompiled); + glGetShaderInfoLog(vertexShader, CONST_INFOLOG_LENGTH, &infoLogLength, infoLog); + *Console<<"ResourceManager::ShaderManager::Shader "+std::string(infoLog); + + glCompileShader(fragmentShader); + glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &fragmentShaderCompiled); + glGetShaderInfoLog(fragmentShader, CONST_INFOLOG_LENGTH, &infoLogLength, infoLog); + *Console<<"ResourceManager::ShaderManager::Shader " + std::string(infoLog); + + if (!vertexShaderCompiled || !fragmentShaderCompiled) + return false; + + ShaderProgram = glCreateProgram(); + *Console<<"Shader program is - " + tostr(ShaderProgram); + glAttachShader(ShaderProgram, vertexShader); + glAttachShader(ShaderProgram, fragmentShader); + + glLinkProgram(ShaderProgram); + + glDeleteShader(vertexShader); + glDeleteShader(fragmentShader); + + glGetProgramiv(ShaderProgram, GL_LINK_STATUS, &programLinked); + glGetProgramInfoLog(ShaderProgram, CONST_INFOLOG_LENGTH, &infoLogLength, infoLog); + + *Console<<"ResourceManager::ShaderManager::Shader "+std::string(infoLog); + + if (!programLinked) + { + ShaderProgram = 0; + return false; + } + + + int dummySize; //Dummy + int dummyLen; //Dummy + cardinal dummyType; //Dummy + + //================= Parsing all uniforms ================ + + int activeUniforms; + + const int CONST_UNIFORM_NAME_LENGTH = 256; + char uniformName[CONST_UNIFORM_NAME_LENGTH]; + + glGetProgramiv(ShaderProgram, GL_ACTIVE_UNIFORMS, &activeUniforms); + + for (int i = 0; i < activeUniforms; i++) + { + glGetActiveUniform(ShaderProgram, i, CONST_UNIFORM_NAME_LENGTH, &dummyLen, &dummySize, &dummyType, uniformName); + UniformList[uniformName] = glGetUniformLocation(ShaderProgram, uniformName); + } + + //================= Parsing all attributes ================ + int activeAttribs; + + const int CONST_ATTRIB_NAME_LENGTH = 256; + char attribName[CONST_ATTRIB_NAME_LENGTH]; + + glGetProgramiv(ShaderProgram, GL_ACTIVE_ATTRIBUTES, &activeAttribs); + + for (int i = 0; i < activeAttribs; i++) + { + glGetActiveAttrib(ShaderProgram, i, CONST_ATTRIB_NAME_LENGTH, &dummyLen, &dummySize, &dummyType, attribName); + AttribList[attribName] = glGetAttribLocation(ShaderProgram, attribName); + } + + return true; +} + +void TShaderResource::FreeShader() +{ + + if (ShaderProgram != 0) + { +#ifdef TARGET_ANDROID + if (glIsProgram(ShaderProgram)) + { + glDeleteProgram(ShaderProgram); + } +#else + glDeleteProgram(ShaderProgram); +#endif + ShaderProgram = 0; + } + + UniformList.clear(); + AttribList.clear(); +} + +int TShaderResource::GetAttribIndex(const std::string& attribName) +{ + if (AttribList.count(attribName) > 0) + return AttribList[attribName]; + else + return -1; +} + +int TShaderResource::GetUniformIndex(const std::string& uniformName) +{ + if (UniformList.count(uniformName) > 0) + return UniformList[uniformName]; + else + return -1; +} + + + + +//=================================================== +//=============== SHADER MANAGER ==================== +//=================================================== + + +TShaderManager::~TShaderManager() +{ + Clear(); + *Console<<"ResourceManager::ShaderManager deleting"; +} + +std::shared_ptr TShaderManager::GetCurrentShader() +{ + if (ShaderNameStack.size() == 0) + { + throw ErrorToLog("GetCurrentShader: Shader is not selected!"); + } + + return ShaderList[ShaderNameStack.top()]; +} + +void TShaderManager::Serialize(boost::property_tree::ptree& propertyTree) +{ + + BOOST_FOREACH(boost::property_tree::ptree::value_type &v, propertyTree.get_child("Shaders")) + { + std::string shaderName = v.second.get("Name"); + std::string vertexFileName = v.second.get("VertexFileName"); + std::string fragmentFileName = v.second.get("FragmentFileName"); + + AddShader(shaderName, vertexFileName, fragmentFileName); + + } +} + +bool TShaderManager::AddShader(const std::string& shaderName, const std::string& vertexFileName, const std::string& fragmentFileName) +{ + + std::string pathToResources = ResourceManager->PathToResources; + + if (ShaderList.count(shaderName) > 0) + { + *Console<<"ResourceManager::ShaderManager ERROR shader already exists: "+shaderName; + return false; + } + + *Console<<"Prepare to add shader "+shaderName; + cardinal fSize; + boost::shared_array fPointer; + boost::shared_array vertexCode; + boost::shared_array fragmentCode; + + fPointer = CreateMemFromFile(pathToResources + vertexFileName, fSize); + + vertexCode = boost::shared_array(new char [fSize + 1]); + + memcpy(vertexCode.get(), fPointer.get(), fSize); + + vertexCode[fSize] = 0; + + fPointer = CreateMemFromFile(pathToResources + fragmentFileName, fSize); + + fragmentCode = boost::shared_array(new char [fSize + 1]); + + memcpy(fragmentCode.get(), fPointer.get(), fSize); + + fragmentCode[fSize] = 0; + + std::shared_ptr shaderResource(new TShaderResource); + + ShaderList[shaderName] = shaderResource; + + if (!ShaderList[shaderName]->CompileShader(vertexCode, fragmentCode)) + { + *Console<<"ResourceManager::ShaderManager ERROR shader could not be compiled or linked: "+shaderName; + return false; + } + + *Console<<"ResourceManager::ShaderManager shader loaded: "+shaderName; + + return true; +} + +void TShaderManager::Clear() +{ + glUseProgram(0); + ShaderList.clear(); + *Console<<"ResourceManager::ShaderManager cleared"; +} + + +void TShaderManager::PushShader(const std::string& shaderName) +{ + + if (ShaderList.count(shaderName) == 0) + throw ErrorShaderNotExists(shaderName); + + if (ShaderNameStack.size() >= CONST_MAX_STACK_SIZE) + throw ErrorShaderStackOverflow(); + + + if (ShaderNameStack.size() == 0 || ShaderNameStack.top() != shaderName) + { + glUseProgram(ShaderList[shaderName]->ShaderProgram); + } + + ShaderNameStack.push(shaderName); +} + + +void TShaderManager::PopShader() +{ + if (ShaderNameStack.size() <= 1) + { + throw ErrorToLog("Shader stack underflow!!"); + } + std::string oldShaderName = ShaderNameStack.top(); + + ShaderNameStack.pop(); + std::string shaderName = ShaderNameStack.top(); + if (oldShaderName != shaderName) + { + glUseProgram(ShaderList[shaderName]->ShaderProgram); + } +} + +//======================================================== +//======================== Utilities ===================== +//======================================================== + +void RenderUniform1f(const std::string& uniformName, const float value) +{ + if (ResourceManager != NULL) + if (ResourceManager->ShaderManager.GetCurrentShader()->UniformList.count(uniformName) > 0) + glUniform1fv(ResourceManager->ShaderManager.GetCurrentShader()->UniformList[uniformName],1,&value); +} + +void RenderUniform3fv(const std::string& uniformName, const float* value) +{ + if (ResourceManager != NULL) + if (ResourceManager->ShaderManager.GetCurrentShader()->UniformList.count(uniformName) > 0) + glUniform3fv(ResourceManager->ShaderManager.GetCurrentShader()->UniformList[uniformName],1,value); +} + +void RenderUniform4fv(const std::string& uniformName, const float* value) +{ + if (ResourceManager != NULL) + if (ResourceManager->ShaderManager.GetCurrentShader()->UniformList.count(uniformName) > 0) + glUniform4fv(ResourceManager->ShaderManager.GetCurrentShader()->UniformList[uniformName],1,value); +} + + +void RenderUniformMatrix3fv(const std::string& uniformName,bool transpose, const float* value) +{ + if (ResourceManager != NULL) + if (ResourceManager->ShaderManager.GetCurrentShader()->UniformList.count(uniformName) > 0) + glUniformMatrix3fv(ResourceManager->ShaderManager.GetCurrentShader()->UniformList[uniformName],1,transpose,value); + +} + +void RenderUniformMatrix4fv(const std::string& uniformName,bool transpose, const float* value) +{ + if (ResourceManager != NULL) + if (ResourceManager->ShaderManager.GetCurrentShader()->UniformList.count(uniformName) > 0) + glUniformMatrix4fv(ResourceManager->ShaderManager.GetCurrentShader()->UniformList[uniformName],1,transpose,value); + +} + + +void RenderUniform1i(const std::string& uniformName, const int value) +{ + if (ResourceManager != NULL) + if (ResourceManager->ShaderManager.GetCurrentShader()->UniformList.count(uniformName) > 0) + glUniform1i(ResourceManager->ShaderManager.GetCurrentShader()->UniformList[uniformName],value); +} + +void VertexAttrib2fv(const std::string& attribName, const float* value) +{ + if (ResourceManager != NULL) + if (ResourceManager->ShaderManager.GetCurrentShader()->AttribList.count(attribName) > 0) + glVertexAttrib2fv(ResourceManager->ShaderManager.GetCurrentShader()->AttribList[attribName], value); +} + +void VertexAttrib3fv(const std::string& attribName, const float* value) +{ + if (ResourceManager != NULL) + if (ResourceManager->ShaderManager.GetCurrentShader()->AttribList.count(attribName) > 0) + glVertexAttrib3fv(ResourceManager->ShaderManager.GetCurrentShader()->AttribList[attribName], value); +} + +void VertexAttribPointer2fv(const std::string& attribName,int stride, const char* pointer) +{ + if (ResourceManager != NULL) + if (ResourceManager->ShaderManager.GetCurrentShader()->AttribList.count(attribName) > 0) + glVertexAttribPointer(ResourceManager->ShaderManager.GetCurrentShader()->AttribList[attribName], 2, GL_FLOAT, GL_FALSE, stride, pointer); +} + +void VertexAttribPointer3fv(const std::string& attribName,int stride, const char* pointer) +{ + if (ResourceManager != NULL) + if (ResourceManager->ShaderManager.GetCurrentShader()->AttribList.count(attribName) > 0) + glVertexAttribPointer(ResourceManager->ShaderManager.GetCurrentShader()->AttribList[attribName], 3, GL_FLOAT, GL_FALSE, stride, pointer); +} + +void EnableVertexAttribArray(const std::string& attribName) +{ + if (ResourceManager != NULL) + if (ResourceManager->ShaderManager.GetCurrentShader()->AttribList.count(attribName) > 0) + glEnableVertexAttribArray(ResourceManager->ShaderManager.GetCurrentShader()->AttribList[attribName]); +} + +void DisableVertexAttribArray(const std::string& attribName) +{ + if (ResourceManager != NULL) + if (ResourceManager->ShaderManager.GetCurrentShader()->AttribList.count(attribName) > 0) + glDisableVertexAttribArray(ResourceManager->ShaderManager.GetCurrentShader()->AttribList[attribName]); +} + + +#ifdef TARGET_WIN32 +void RefreshAttribBuffer2fv(const std::string& attribName, std::map >& vec2CoordArr) +{ + if (ResourceManager != NULL) + if (ResourceManager->ShaderManager.GetCurrentShader()->AttribList.count(attribName) > 0) + if (vec2CoordArr[attribName].size() > 0) + glBufferData(GL_ARRAY_BUFFER, vec2CoordArr[attribName].size()*8, &(*vec2CoordArr[attribName].begin()), GL_STATIC_DRAW); + +} + +void RefreshAttribBuffer3fv(const std::string& attribName, std::map >& vec3CoordArr) +{ + if (ResourceManager != NULL) + if (ResourceManager->ShaderManager.GetCurrentShader()->AttribList.count(attribName) > 0) + if (vec3CoordArr[attribName].size() > 0) + glBufferData(GL_ARRAY_BUFFER, vec3CoordArr[attribName].size()*12, &(*vec3CoordArr[attribName].begin()), GL_STATIC_DRAW); +} +#endif + +} //namespace SE \ No newline at end of file diff --git a/src/SimpleLand/SimpleLand.cpp b/src/SimpleLand/SimpleLand.cpp new file mode 100644 index 0000000..214aaa7 --- /dev/null +++ b/src/SimpleLand/SimpleLand.cpp @@ -0,0 +1,826 @@ +#include "include/Engine.h" + +namespace SE +{ + +const float CONST_LAND_Y_LIMIT = 15.0f; +//Limit for y pos of land (edge or trench/dip) + +const float CONST_MIN_COS_BETWEEN_CURSOR_AND_VERTEX = 0.99f; +//See CalcCrossing() for explanation + + +TSimpleLandClass::TSimpleLandClass() + : Width(CONST_DEFAULT_LAND_WIDTH), + Height(CONST_DEFAULT_LAND_HEIGHT), + CellInterval(CONST_DEFAULT_LAND_CELL_INVERVAL), + TexID(0), + NormTexID(0) +{ + int k; + + VertexMatrix.resize(Width*Height); + + for (int i=0; iTexList.DeleteTexture(TexID); + TexID = 0; + } + + if (NormTexID != 0) + { + ResourceManager->TexList.DeleteTexture(NormTexID); + NormTexID = 0; + } + +} + +void TSimpleLandClass::CreateVBO() +{ + IndexArr.resize(6*(Width-1)*(Height-1)); + + //VBOLandVertexArr.resize(Width*Height); + VBOLandVertexArr.pos.resize(Width * Height); + VBOLandVertexArr.norm.resize(Width * Height); + VBOLandVertexArr.tangent.resize(Width * Height); + VBOLandVertexArr.binorm.resize(Width * Height); + VBOLandVertexArr.texCoord.resize(Width * Height); + + for (int i = 0; i < Height-1; i++) + for (int j = 0; j < Width-1; j++) + { + + IndexArr[6*(j + i*(Width-1))] = j + i*(Width); + IndexArr[6*(j + i*(Width-1)) + 1] = j + 1 + i*(Width); + IndexArr[6*(j + i*(Width-1)) + 2] = Width + j + i*(Width); + + IndexArr[6*(j + i*(Width-1)) + 3] = j + 1 + i*(Width); + IndexArr[6*(j + i*(Width-1)) + 4] = Width + 1 + j + i*(Width); + IndexArr[6*(j + i*(Width-1)) + 5] = Width + j + i*(Width); + + } + + for (int i = 0; i < Height-1; i++) + for (int j = 0; j < Width-1; j++) + { + VBOLandVertexArr.pos[j + i*Width] = VertexMatrix[j + i*Width].pos; + VBOLandVertexArr.norm[j + i*Width] = VertexMatrix[j + i*Width].norm; + VBOLandVertexArr.tangent[j + i*Width] = VertexMatrix[j + i*Width].tangent; + VBOLandVertexArr.binorm[j + i*Width] = VertexMatrix[j + i*Width].binorm; + VBOLandVertexArr.texCoord[j + i*Width].v[0] = float(j) / Width; + VBOLandVertexArr.texCoord[j + i*Width].v[1] = float(i) / Height; + } + +#ifdef TARGET_WIN32 + glGenBuffers(1, &IndexBuffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IndexBuffer); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, 6*(Width-1)*(Height-1)*4, &IndexArr[0], GL_STATIC_DRAW); + + glGenBuffers(1, &VertexBuffer); + glBindBuffer(GL_ARRAY_BUFFER, VertexBuffer); + glBufferData(GL_ARRAY_BUFFER, Width * Height * sizeof(vec3), &(VBOLandVertexArr.pos[0]), GL_STATIC_DRAW); + + glGenBuffers(1, &NormBuffer); + glBindBuffer(GL_ARRAY_BUFFER, NormBuffer); + glBufferData(GL_ARRAY_BUFFER, Width * Height * sizeof(vec3), &(VBOLandVertexArr.norm[0]), GL_STATIC_DRAW); + + glGenBuffers(1, &TangentBuffer); + glBindBuffer(GL_ARRAY_BUFFER, TangentBuffer); + glBufferData(GL_ARRAY_BUFFER, Width * Height * sizeof(vec3), &(VBOLandVertexArr.tangent[0]), GL_STATIC_DRAW); + + glGenBuffers(1, &BinormBuffer); + glBindBuffer(GL_ARRAY_BUFFER, BinormBuffer); + glBufferData(GL_ARRAY_BUFFER, Width * Height * sizeof(vec3), &(VBOLandVertexArr.binorm[0]), GL_STATIC_DRAW); + + glGenBuffers(1, &TexcoordBuffer); + glBindBuffer(GL_ARRAY_BUFFER, TexcoordBuffer); + glBufferData(GL_ARRAY_BUFFER, Width * Height * sizeof(vec2), &(VBOLandVertexArr.texCoord[0]), GL_STATIC_DRAW); +#endif + +} + +void TSimpleLandClass::FreeVBO() +{ +#ifdef TARGET_WIN32 + glDeleteBuffers(1, &VertexBuffer); + glDeleteBuffers(1, &NormBuffer); + glDeleteBuffers(1, &TangentBuffer); + glDeleteBuffers(1, &BinormBuffer); + glDeleteBuffers(1, &TexcoordBuffer); + glDeleteBuffers(1, &IndexBuffer); +#endif + + VBOLandVertexArr.pos.clear(); + VBOLandVertexArr.norm.clear(); + VBOLandVertexArr.tangent.clear(); + VBOLandVertexArr.binorm.clear(); + VBOLandVertexArr.texCoord.clear(); + IndexArr.clear(); +} + +void TSimpleLandClass::UpdateVBO() +{ + //Index array remains the same - only vertex array is to be changed + + for (int i = 0; i < Height; i++) + { + for (int j = 0; j < Width; j++) + { + VBOLandVertexArr.pos[j + i*Width] = VertexMatrix[j + i*Width].pos; + VBOLandVertexArr.norm[j + i*Width] = VertexMatrix[j + i*Width].norm; + VBOLandVertexArr.tangent[j + i*Width] = VertexMatrix[j + i*Width].tangent; + VBOLandVertexArr.binorm[j + i*Width] = VertexMatrix[j + i*Width].binorm; + VBOLandVertexArr.texCoord[j + i*Width].v[0] = float(j) / Width; + VBOLandVertexArr.texCoord[j + i*Width].v[1] = float(i) / Height; + } + } + +#ifdef TARGET_WIN32 + + glBindBuffer(GL_ARRAY_BUFFER, VertexBuffer); + glBufferSubData(GL_ARRAY_BUFFER, 0, Width * Height * sizeof(vec3), &(VBOLandVertexArr.pos[0])); + + glBindBuffer(GL_ARRAY_BUFFER, NormBuffer); + glBufferSubData(GL_ARRAY_BUFFER, 0, Width * Height * sizeof(vec3), &(VBOLandVertexArr.norm[0])); + + glBindBuffer(GL_ARRAY_BUFFER, TangentBuffer); + glBufferSubData(GL_ARRAY_BUFFER, 0, Width * Height * sizeof(vec3), &(VBOLandVertexArr.tangent[0])); + + glBindBuffer(GL_ARRAY_BUFFER, BinormBuffer); + glBufferSubData(GL_ARRAY_BUFFER, 0, Width * Height * sizeof(vec3), &(VBOLandVertexArr.binorm[0])); + + glBindBuffer(GL_ARRAY_BUFFER, TexcoordBuffer); + glBufferSubData(GL_ARRAY_BUFFER, 0, Width * Height * sizeof(vec2), &(VBOLandVertexArr.texCoord[0])); +#endif +} + +vec3 TSimpleLandClass::CalcCrossingForPoint(const vec3& pos, int i, int j) +{ + vec3 lineFrom = pos; + vec3 lineTo = pos; + + lineFrom.v[1] = CONST_LAND_Y_LIMIT; + lineTo.v[1] = -CONST_LAND_Y_LIMIT; + + vec3 r = CalcCrossingForPoint(lineFrom, lineTo, i, j); + + if (r == lineFrom) + return pos; + + return r; +} + +vec3 TSimpleLandClass::CalcCrossingForPoint(const vec3& lineFrom,const vec3& lineTo, int i, int j) +{ + if (i >= Height-1 || i < 0 || j >= Width-1 || j < 0) + return lineFrom; + + TSmpTriangle tr; + vec3 r; + + + tr.p[0] = VertexMatrix[j + i*Width].pos; + tr.p[1] = VertexMatrix[(j+1) + i*Width].pos; + tr.p[2] = VertexMatrix[(j+1) + (i+1)*Width].pos; + + tr.v = tr.p[1] - tr.p[0]; + tr.w = tr.p[2] - tr.p[1]; + tr.n = CrossProduct(tr.v, tr.w); + + if (LineCrossTriangle(lineFrom, lineTo, tr, r) == 1) + return r; + + tr.p[0] = VertexMatrix[j + i*Width].pos; + tr.p[1] = VertexMatrix[j + (i+1)*Width].pos; + tr.p[2] = VertexMatrix[(j+1) + (i+1)*Width].pos; + + tr.v = tr.p[1] - tr.p[0]; + tr.w = tr.p[2] - tr.p[1]; + tr.n = CrossProduct(tr.v, tr.w); + + if (LineCrossTriangle(lineFrom, lineTo, tr, r) == 1) + return r; + + return lineFrom; +} + +bool TSimpleLandClass::LoadFromFile(const std::string& filename) +{ + + cardinal dwordCount; + boost::shared_array fileArr = CreateMemFromFile((ResourceManager->PathToResources + filename).c_str(), dwordCount); + + if ((((char*)&fileArr[0])[0]!='L')|| + (((char*)&fileArr[0])[1]!='S')|| + (((char*)&fileArr[0])[2]!=0)|| + (((char*)&fileArr[0])[3]!=1)) + throw ErrorFileNotCorrect(filename); + + Width = fileArr[1]; + Height = fileArr[2]; + CellInterval = ((float*)&fileArr[0])[3]; + + std::vector tempVertexMatrix; + tempVertexMatrix.resize(Width*Height); + + + for (int i = 0; i < Height; i++) + for (int j = 0; j < Width; j++) + { + int k = j + i * Width; + tempVertexMatrix[k] = ((TSimpleLandVertex*)(&fileArr[0] + 4))[k]; + } + + //Replace old matrices with new + + TriangleMatrix.resize(2*(Width-1)*(Height-1)); + VertexMatrix = tempVertexMatrix; + + UpdateTriangleMatrix(); + + RecalcNormalVectors(); + + FreeVBO(); + CreateVBO(); + + return true; +} + + + +void TSimpleLandClass::SaveToFile(char* filename) +{ + //NIU + + //Need to clean up +#ifdef TARGET_WIN32 + + OFSTRUCT ofstruct; + DWORD FSize; + DWORD BytesWriten; + char* FileArr; + + //Îòêðûâàåì ôàéë + HANDLE h=(HANDLE)OpenFile(filename,&ofstruct,OF_CREATE); + + FSize = 16 + Width*Height*sizeof(TSimpleLandVertex); + + FileArr = new char [FSize]; + + FileArr[0] = 'L'; + FileArr[1] = 'S'; + FileArr[2] = 0; + FileArr[3] = 1; + + ((int*)FileArr)[1] = Width; + ((int*)FileArr)[2] = Height; + ((float*)FileArr)[3] = CellInterval; + + int k; + + for (int i=0;iTexList.DeleteTexture(TexID); + } + TexID = ResourceManager->TexList.AddTexture(texFilename); +} + +void TSimpleLandClass::SetNormTexture(const std::string& normTexFilename) +{ + if (NormTexID != 0) + { + ResourceManager->TexList.DeleteTexture(NormTexID); + } + NormTexID = ResourceManager->TexList.AddTexture(normTexFilename); +} + + + + +void TSimpleLandClass::DrawImmediate() +{ + //Need to speed up! + +#ifdef TARGET_WIN32 + + int i, j, k, k_up, k_right, k_right_up; + + if (NormTexID == 0) + { + RenderUniform1i(CONST_STRING_NORMALMAPEXISTS_UNIFORM, 0); + } + + glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,WhiteColor); + + RenderUniformMatrix3fv(CONST_STRING_MODELROTATEMATRIX_UNIFORM, false, (float*)IdentityMatrix.m); + RenderUniform3fv(CONST_STRING_MODELTRANSLATEVECTOR_UNIFORM, (float*)ZeroVec3.v); + + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, NormTexID); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, TexID); + + for (i = 0; i < Height-1; i++) + for (j = 0; j < Width-1; j++) + { + k = j + i*Width; + k_right = (j+1) + i*Width; + k_up = j + (i+1)*Width; + k_right_up = (j+1) + (i+1)*Width; + + float tx0 = float(j)/(Width-1); + float ty0 = float(i)/(Height-1); + + float tx1 = float(j+1)/(Width-1); + float ty1 = float(i+1)/(Height-1); + + glBegin(GL_TRIANGLES); + glNormal3fv(VertexMatrix[k].norm.v); + VertexAttrib3fv(CONST_STRING_TANGENT_ATTRIB, VertexMatrix[k].tangent.v); + VertexAttrib3fv(CONST_STRING_BINORMAL_ATTRIB, VertexMatrix[k].binorm.v); + glTexCoord2f(tx0,ty0); + glVertex3fv(VertexMatrix[k].pos.v); + + glNormal3fv(VertexMatrix[k_right].norm.v); + VertexAttrib3fv(CONST_STRING_TANGENT_ATTRIB, VertexMatrix[k_right].tangent.v); + VertexAttrib3fv(CONST_STRING_BINORMAL_ATTRIB, VertexMatrix[k_right].binorm.v); + glTexCoord2f(tx1,ty0); + glVertex3fv(VertexMatrix[k_right].pos.v); + + glNormal3fv(VertexMatrix[k_up].norm.v); + VertexAttrib3fv(CONST_STRING_TANGENT_ATTRIB, VertexMatrix[k_up].tangent.v); + VertexAttrib3fv(CONST_STRING_BINORMAL_ATTRIB, VertexMatrix[k_up].binorm.v); + glTexCoord2f(tx0,ty1); + glVertex3fv(VertexMatrix[k_up].pos.v); + glEnd(); + + glBegin(GL_TRIANGLES); + glNormal3fv(VertexMatrix[k_right_up].norm.v); + VertexAttrib3fv(CONST_STRING_TANGENT_ATTRIB, VertexMatrix[k_right_up].tangent.v); + VertexAttrib3fv(CONST_STRING_BINORMAL_ATTRIB, VertexMatrix[k_right_up].binorm.v); + glTexCoord2f(tx1,ty1); + glVertex3fv(VertexMatrix[k_right_up].pos.v); + + glNormal3fv(VertexMatrix[k_up].norm.v); + VertexAttrib3fv(CONST_STRING_TANGENT_ATTRIB, VertexMatrix[k_up].tangent.v); + VertexAttrib3fv(CONST_STRING_BINORMAL_ATTRIB, VertexMatrix[k_up].binorm.v); + glTexCoord2f(tx0,ty1); + glVertex3fv(VertexMatrix[k_up].pos.v); + + glNormal3fv(VertexMatrix[k_right].norm.v); + VertexAttrib3fv(CONST_STRING_TANGENT_ATTRIB, VertexMatrix[k_right].tangent.v); + VertexAttrib3fv(CONST_STRING_BINORMAL_ATTRIB, VertexMatrix[k_right].binorm.v); + glTexCoord2f(tx1,ty0); + glVertex3fv(VertexMatrix[k_right].pos.v); + glEnd(); + + } + + RenderUniform1i(CONST_STRING_NORMALMAPEXISTS_UNIFORM, 1); + +#endif +} + +void TSimpleLandClass::DrawVBO() +{ + + + //RenderUniform1i(CONST_STRING_NORMALMAPEXISTS_UNIFORM, min(NormTexID, 1)); + + //RenderUniformMatrix3fv(CONST_STRING_MODELROTATEMATRIX_UNIFORM, false, (float*)IdentityMatrix.m); + //RenderUniform3fv(CONST_STRING_MODELTRANSLATEVECTOR_UNIFORM, (float*)ZeroVec3.v); + + if (NormTexID != 0) + { + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D,NormTexID); + } + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D,TexID); + + +#ifdef TARGET_WIN32 + + + glBindBuffer(GL_ARRAY_BUFFER, NormBuffer); + VertexAttribPointer3fv(CONST_STRING_NORMAL_ATTRIB, 0, (char*)NULL); + + glBindBuffer(GL_ARRAY_BUFFER, TangentBuffer); + VertexAttribPointer3fv(CONST_STRING_TANGENT_ATTRIB, 0, (char*)NULL); + + glBindBuffer(GL_ARRAY_BUFFER, BinormBuffer); + VertexAttribPointer3fv(CONST_STRING_BINORMAL_ATTRIB, 0, (char*)NULL); + + glBindBuffer(GL_ARRAY_BUFFER, TexcoordBuffer); + VertexAttribPointer2fv(CONST_STRING_TEXCOORD_ATTRIB, 0, (char*)NULL); + + glBindBuffer(GL_ARRAY_BUFFER, VertexBuffer); + VertexAttribPointer3fv(CONST_STRING_POSITION_ATTRIB, 0, (char*)NULL); + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IndexBuffer); + + glDrawElements(GL_TRIANGLES, 6*(Width-1)*(Height-1), GL_UNSIGNED_INT, NULL); + + +#endif +#ifdef TARGET_ANDROID + + + VertexAttribPointer3fv(CONST_STRING_NORMAL_ATTRIB, 0, reinterpret_cast(&(VBOLandVertexArr.norm[0]))); + + VertexAttribPointer3fv(CONST_STRING_TANGENT_ATTRIB, 0, reinterpret_cast(&(VBOLandVertexArr.tangent[0]))); + + VertexAttribPointer3fv(CONST_STRING_BINORMAL_ATTRIB, 0, reinterpret_cast(&(VBOLandVertexArr.binorm[0]))); + + VertexAttribPointer2fv(CONST_STRING_TEXCOORD_ATTRIB, 0, reinterpret_cast(&(VBOLandVertexArr.texCoord[0]))); + + VertexAttribPointer3fv(CONST_STRING_POSITION_ATTRIB, 0, reinterpret_cast(&(VBOLandVertexArr.pos[0]))); + + glDrawElements(GL_TRIANGLES, 6*(Width-1)*(Height-1), GL_UNSIGNED_SHORT, &IndexArr[0]); + +#endif + + RenderUniform1i(CONST_STRING_NORMALMAPEXISTS_UNIFORM,1); + +} + +vec3 TSimpleLandClass::CalcCrossing(vec3 LineFrom,vec3 LineTo) +{ + int i, j; + vec3 CursorVec = Normalize(LineTo - LineFrom); + vec3 CamPos = Renderer->GetCamPos(); + + for (i = 0; i < Height-1; i++) + for (j = 0; j < Width-1; j++) + { + vec3 CamToVertex = Normalize(VertexMatrix[j + i*Width].pos - CamPos); + float cosA = DotProduct(CamToVertex, CursorVec); + + if (cosA > CONST_MIN_COS_BETWEEN_CURSOR_AND_VERTEX) + { + vec3 r = CalcCrossingForPoint(LineFrom, LineTo, i, j); + + if (!(r == LineFrom)) + return r; + } + } + + return LineFrom; +} + +vec3 TSimpleLandClass::CalcVerticalCrossing(const vec3& pos) +{ + int ir = -1; + int jr = -1; + + float xMin = VertexMatrix[0].pos.v[0]; + float xMax = VertexMatrix[Width-1].pos.v[0]; + + float yMin = VertexMatrix[Height*Width-1].pos.v[2]; + float yMax = VertexMatrix[0].pos.v[2]; + + jr = static_cast(floor((Width-1)*(pos.v[0]-xMin)/(xMax - xMin))); + ir = static_cast(floor((Height-1)*(pos.v[2]-yMax)/(yMin - yMax))); //Must be reversed + + + if (ir < 0 || ir >= Height-1 || jr < 0 || jr >= Width-1) + { + return pos; + } + else + { + vec3 r; + r = CalcCrossingForPoint(pos, ir, jr); + //r = CalcCrossingForPoint(r, ir+1, jr); + //r = CalcCrossingForPoint(r, ir+2, jr); + //r = CalcCrossingForPoint(r, ir-1, jr); + //r = CalcCrossingForPoint(r, ir-2, jr); + return r; + } + +} + +float TSimpleLandClass::CalcVerticalCrossingFast(const vec3& pos) +{ + int ir = -1; + int jr = -1; + + float xMin = VertexMatrix[0].pos.v[0]; + float xMax = VertexMatrix[Width-1].pos.v[0]; + + float zMin = VertexMatrix[Height*Width-1].pos.v[2]; + float zMax = VertexMatrix[0].pos.v[2]; + + float w = (xMax - xMin) / (Width-1); + float h = (zMax - zMin) / (Height-1); + + jr = int((pos.v[0] - xMin)/w); + ir = (Height-1) - int(ceilf((pos.v[2] - zMin)/h)); + + if (ir < 0 || ir >= Height-1 || jr < 0 || jr >= Width-1) + { + return pos.v[1]; + } + else + { + return max(VertexMatrix[jr + ir*Width].pos.v[1], + max(VertexMatrix[(jr+1) + ir*Width].pos.v[1], + max(VertexMatrix[jr + (ir+1)*Width].pos.v[1], + VertexMatrix[(jr+1) + (ir+1)*Width].pos.v[1]))); + } + + +} + +bool TSimpleLandClass::IsOnTheLand(const vec3& pos) +{ + + float xMin = VertexMatrix[0].pos.v[0]; + float xMax = VertexMatrix[Width-1].pos.v[0]; + + float yMin = VertexMatrix[Height*Width-1].pos.v[2]; + float yMax = VertexMatrix[0].pos.v[2]; + + return (pos.v[0] >= xMin) && (pos.v[0] <= xMax) && (pos.v[2] >= yMin) && (pos.v[2] <= yMax); + +} + +void TSimpleLandClass::MoveLandUp(vec3 CursorPos,float R) +{ + //NIU + int i,j; + vec3 pointpos; + float r,k; + + for (i=0;i0) ? VertexMatrix[j+(i-1)*Width].pos.v[1] : pointpos.v[1]; + h2 = (j>0) ? VertexMatrix[j-1+i*Width].pos.v[1] : pointpos.v[1]; + + h3 = (isecond) + { + std::string dictName = subTree.second.get(".name"); + + BOOST_FOREACH(auto& subSubTree, subTree.second) + { + if (subSubTree.first == "Record") + { + std::string key = subSubTree.second.get(".key"); + + std::string type = subSubTree.second.get(".type", ""); + + if (type == "int") + { + DisctionariesMap[dictName][key] = std::shared_ptr>(new TBindableVar(subSubTree.second.get(".value"))); + } + else if (type == "bool") + { + DisctionariesMap[dictName][key] = std::shared_ptr>(new TBindableVar(subSubTree.second.get(".value"))); + } + else if (type == "float") + { + DisctionariesMap[dictName][key] = std::shared_ptr>(new TBindableVar(subSubTree.second.get(".value"))); + } + else if (type == "vec2") + { + DisctionariesMap[dictName][key] = std::shared_ptr>(new TBindableVar(StringToVec2(subSubTree.second.get(".value")))); + } + else if (type == "vec3") + { + DisctionariesMap[dictName][key] = std::shared_ptr>(new TBindableVar(StringToVec3(subSubTree.second.get(".value")))); + } + else if (type == "vec4") + { + DisctionariesMap[dictName][key] = std::shared_ptr>(new TBindableVar(StringToVec4(subSubTree.second.get(".value")))); + } + else + { + DisctionariesMap[dictName][key] = std::shared_ptr>(new TBindableVar(subSubTree.second.get(".value"))); + } + } + } + } +} + +} //namespace SE \ No newline at end of file diff --git a/src/SoundManager/SoundManagerAndroid.cpp b/src/SoundManager/SoundManagerAndroid.cpp new file mode 100644 index 0000000..3311bdf --- /dev/null +++ b/src/SoundManager/SoundManagerAndroid.cpp @@ -0,0 +1,48 @@ +#include "include/Engine.h" + +namespace SE +{ + +TSoundManagerAndroid::TSoundManagerAndroid() +{ +} + +TSoundManagerAndroid::~TSoundManagerAndroid() +{ + JniReleaseAllSoundsAndMusic(); +} + + +void TSoundManagerAndroid::LoadSound(const std::string& soundFileName) +{ + JniLoadSound(soundFileName); +} + +void TSoundManagerAndroid::PlaySound(const std::string& soundName) +{ + JniPlaySound(soundName); +} + + +void TSoundManagerAndroid::LoadMusic(const std::string& musicFileName) +{ + //dummy. Not needed +} + +void TSoundManagerAndroid::PlayMusic(const std::string& musicName) +{ + JniPlayMusic(musicName); +} + +void TSoundManagerAndroid::PlayMusicLooped(const std::string& musicName) +{ + JniPlayMusicLooped(musicName); +} + +void TSoundManagerAndroid::StopMusic(const std::string& musicName) +{ + JniStopMusic(); +} + + +} //namespace SE \ No newline at end of file diff --git a/src/SoundManager/SoundManagerDataTypes.cpp b/src/SoundManager/SoundManagerDataTypes.cpp new file mode 100644 index 0000000..35ce4c2 --- /dev/null +++ b/src/SoundManager/SoundManagerDataTypes.cpp @@ -0,0 +1,92 @@ +#ifndef NOSOUND + +#include "include/SoundManager/SoundManagerDataTypes.h" + + +namespace SE +{ + + +extern "C" +{ +size_t OggFileRead(void* toBuf, size_t varsize, size_t varcount, void* fromBuf); + +int OggFileSeek(void *fromBuf, ogg_int64_t offset, int whence); + +long OggFileTell(void *fromBuf); +} + +size_t OggFileRead(void* toBuf, size_t varsize, size_t varcount, void* fromBuf) +{ + TOggCallbackFileBuffer& callbackFileBuffer = *(reinterpret_cast(fromBuf)); + + if (callbackFileBuffer.FilePos+varsize*varcount > callbackFileBuffer.FileSize) + { + size_t dataLeft = callbackFileBuffer.FileSize - callbackFileBuffer.FilePos; + + if (dataLeft != 0) + { + memcpy(toBuf, &callbackFileBuffer.FileData[callbackFileBuffer.FilePos], dataLeft); + } + + callbackFileBuffer.FilePos += dataLeft; + + return dataLeft; + } + else + { + memcpy(toBuf, &callbackFileBuffer.FileData[callbackFileBuffer.FilePos], varsize*varcount); + callbackFileBuffer.FilePos += varsize*varcount; + + return varsize*varcount; + } +} + + + +int OggFileSeek(void *fromBuf, ogg_int64_t offset, int whence) +{ + TOggCallbackFileBuffer& callbackFileBuffer = *(reinterpret_cast(fromBuf)); + + size_t newPos; + + switch(whence) + { +case SEEK_SET: + newPos = static_cast(offset); + break; +case SEEK_CUR: + newPos = static_cast(callbackFileBuffer.FilePos + offset); + break; +case SEEK_END: + newPos = static_cast(callbackFileBuffer.FileSize - 1 - offset); + break; + }; + + callbackFileBuffer.FilePos = newPos; + + return 0; + +} + +long OggFileTell(void *fromBuf) +{ + TOggCallbackFileBuffer& callbackFileBuffer = *(reinterpret_cast(fromBuf)); + + return callbackFileBuffer.FilePos; +} + + + +ov_callbacks OggCallbacks = { + (size_t (*)(void *, size_t, size_t, void *)) OggFileRead, + (int (*)(void *, ogg_int64_t, int)) OggFileSeek, + (int (*)(void *)) NULL, + (long (*)(void *)) OggFileTell +}; + + +#endif //NOSOUND + + +} //namespace SE \ No newline at end of file diff --git a/src/SoundManager/SoundManagerIos.mm b/src/SoundManager/SoundManagerIos.mm new file mode 100644 index 0000000..1d283da --- /dev/null +++ b/src/SoundManager/SoundManagerIos.mm @@ -0,0 +1,132 @@ +// +// SoundManagerIos.mm +// Halibut Engine +// +// Created by vvv ооо on 21.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#include +#include +#include + +#import +#import "PASoundMgr.h" +#import "PASoundListener.h" +#import "PASoundSource.h" + +#include "include/Utils/Utils.h" + +#include "include/SoundManager/SoundManagerIos.h" + +namespace SE +{ + +std::map AudioSourceMap; + +TSoundManagerIos::TSoundManagerIos() +{ + [PASoundMgr sharedSoundManager]; + [[[PASoundMgr sharedSoundManager] listener] setPosition:CGPointMake(0, 0)]; +} + +TSoundManagerIos::~TSoundManagerIos() +{ + for (std::map::iterator i = AudioSourceMap.begin(); i != AudioSourceMap.end(); ++i) + { + //[i->second release]; + } + AudioSourceMap.clear(); +} + +void TSoundManagerIos::LoadSound(const std::string& soundFileName) +{ + LoadMusic(soundFileName); +} + + +void TSoundManagerIos::PlaySound(const std::string& soundName) +{ + PlayMusic(soundName); +} + +void TSoundManagerIos::LoadMusicLooped(const std::string& musicFileName) +{ + //Hack for ios, see below + std::string musicName = GetFileName(musicFileName); + + std::string fullFileName = GetPathToResources() + musicFileName; + + NSString* nsFileName = [NSString stringWithCString:fullFileName.c_str() encoding:NSUTF8StringEncoding]; + + NSString* nsFileNameWithoutExt = [nsFileName stringByDeletingPathExtension]; + + NSString* nsFileExt = [nsFileName pathExtension]; + + if (AudioSourceMap.count(musicName) > 0) + { + //[AudioSourceMap[musicName] release]; + } + + /*AudioSourceMap[musicFileName] = [[[PASoundMgr sharedSoundManager] addSound:@"trance-loop" withExtension:@"ogg" position:CGPointMake(0, 0) looped:NO] retain];*/ + AudioSourceMap[musicName] = [[PASoundMgr sharedSoundManager] addSound:nsFileNameWithoutExt withExtension:nsFileExt position:CGPointMake(0, 0) looped:YES]; +} + +void TSoundManagerIos::LoadMusic(const std::string& musicFileName) +{ + std::string musicName = GetFileName(musicFileName); + + std::string fullFileName = GetPathToResources() + musicFileName; + + NSString* nsFileName = [NSString stringWithCString:fullFileName.c_str() encoding:NSUTF8StringEncoding]; + + NSString* nsFileNameWithoutExt = [nsFileName stringByDeletingPathExtension]; + + NSString* nsFileExt = [nsFileName pathExtension]; + + if (AudioSourceMap.count(musicName) > 0) + { + //[AudioSourceMap[musicName] release]; + } + + /*AudioSourceMap[musicFileName] = [[[PASoundMgr sharedSoundManager] addSound:@"trance-loop" withExtension:@"ogg" position:CGPointMake(0, 0) looped:NO] retain];*/ + AudioSourceMap[musicName] = [[PASoundMgr sharedSoundManager] addSound:nsFileNameWithoutExt withExtension:nsFileExt position:CGPointMake(0, 0) looped:NO]; +} + + +void TSoundManagerIos::PlayMusic(const std::string& musicName) +{ + if (AudioSourceMap.count(musicName) == 0) + { + throw ErrorToLog("Sound or music not exists: "+musicName); + } + + AudioSourceMap[musicName].looped = false; + + [AudioSourceMap[musicName] playAtListenerPosition]; +} + +void TSoundManagerIos::PlayMusicLooped(const std::string& musicName) +{ + if (AudioSourceMap.count(musicName) == 0) + { + throw ErrorToLog("Sound or music not exists: "+musicName); + } + + AudioSourceMap[musicName].looped = true; + + [AudioSourceMap[musicName] playAtListenerPosition]; +} + +void TSoundManagerIos::StopMusic(const std::string& musicName) +{ + if (AudioSourceMap.count(musicName) == 0) + { + throw ErrorToLog("Sound or music not exists: "+musicName); + } + + [AudioSourceMap[musicName] stop]; +} + + +} //namespace SE \ No newline at end of file diff --git a/src/SoundManager/SoundManagerWindows.cpp b/src/SoundManager/SoundManagerWindows.cpp new file mode 100644 index 0000000..dd45704 --- /dev/null +++ b/src/SoundManager/SoundManagerWindows.cpp @@ -0,0 +1,1022 @@ +#ifndef NOSOUND +#include "include/SoundManager/SoundManagerWindows.h" + +#include "include/Engine.h" + +namespace SE +{ + +TWaveFile OggSoundFromFile(const std::string& fileName) +{ + + + cardinal fileSize; + TByteArrPtr fileData = CreateMemFromFile(fileName, fileSize); + + OggVorbis_File testOggFile; + + TOggCallbackFileBuffer oggBuffer(fileData, fileSize); + + if(ov_open_callbacks(&oggBuffer, &testOggFile, NULL, 0, OggCallbacks) < 0) + throw ErrorToLog("Error! Input does not appear to be an Ogg bitstream: "+fileName+"\n"); + + vorbis_info *pInfo; + + pInfo = ov_info(&testOggFile, -1); + + int channels = 0; + + + channels = pInfo->channels; + + long freq; + freq = pInfo->rate; + + std::vector bufferData; + + const int BUFFER_SIZE = 32768; + int endian = 0; // 0 for Little-Endian, 1 for Big-Endian + int bitStream; + long bytes; + char array[BUFFER_SIZE]; + + do + { + bytes = ov_read(&testOggFile, array, BUFFER_SIZE, endian, 2, 1, &bitStream); + bufferData.insert(bufferData.end(), array, array + bytes); + } while (bytes > 0); + + //delete [] fileData; + + TBasicWAVEHeader soundHeader; + + soundHeader.SamplesPerSec = freq; + soundHeader.DataSize = static_cast(bufferData.size()); + soundHeader.BitsPerSample = 16; + soundHeader.Channels = channels; + + //Just in case... + //soundHeader. + + ov_clear(&testOggFile); + + char* rawBufferData = new char[bufferData.size()]; + memcpy(rawBufferData, &bufferData[0], bufferData.size()); + + TWaveFile result; + + result.WaveHeader = soundHeader; + result.WaveData = TByteArrPtr(rawBufferData); + result.WaveDataCursor = 0; + + + return result; + +} + + +TWaveFile LoadWaveFile(const std::string& fileName) +{ + TWaveFile waveFile; + + cardinal byteCount; + + boost::shared_array filePtr = CreateMemFromFile(fileName.c_str(), byteCount); + + if (byteCount <= sizeof(TBasicWAVEHeader)) + throw ErrorToLog("Invalid wave file: "+fileName+"!!"); + + //Possibly not aligned??? + waveFile.WaveHeader = *(reinterpret_cast(&filePtr[0])); + + if (byteCount < sizeof(TBasicWAVEHeader) + waveFile.WaveHeader.DataSize) + throw ErrorToLog("Wave file too short: "+fileName+"!!"); + + + waveFile.WaveData = TByteArrPtr(new char [waveFile.WaveHeader.DataSize]); + + memcpy(&(waveFile.WaveData[0]), &filePtr[0] + sizeof(TBasicWAVEHeader), waveFile.WaveHeader.DataSize); + + waveFile.WaveDataCursor = 0; + + return waveFile; +} + + +DSBUFFERDESC FillPrimaryWaveBufferDescription() +{ + DSBUFFERDESC bufferDesc; + + // Setup the primary buffer description. + bufferDesc.dwSize = sizeof(DSBUFFERDESC); + bufferDesc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRLVOLUME; + bufferDesc.dwBufferBytes = 0; + bufferDesc.dwReserved = 0; + bufferDesc.lpwfxFormat = NULL; + bufferDesc.guid3DAlgorithm = GUID_NULL; + + return bufferDesc; +} + +WAVEFORMATEX FillPrimaryWaveFormat() +{ + + WAVEFORMATEX waveFormat; + + // Setup the format of the primary sound buffer. + // In this case it is a .WAV file recorded at 44,100 samples per second in 16-bit stereo (cd audio format). + waveFormat.wFormatTag = WAVE_FORMAT_PCM; + waveFormat.nSamplesPerSec = 44100; + waveFormat.wBitsPerSample = 16; + waveFormat.nChannels = 2; + waveFormat.nBlockAlign = (waveFormat.wBitsPerSample / 8) * waveFormat.nChannels; + waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAlign; + waveFormat.cbSize = 0; + + return waveFormat; +} + +DSBUFFERDESC FillSecondaryWaveBufferDescription(cardinal bufferSize, WAVEFORMATEX* pWaveFormat) +{ + DSBUFFERDESC bufferDesc; + + bufferDesc.dwSize = sizeof(DSBUFFERDESC); + bufferDesc.dwFlags = DSBCAPS_CTRLVOLUME; + bufferDesc.dwBufferBytes = bufferSize; + bufferDesc.dwReserved = 0; + bufferDesc.lpwfxFormat = pWaveFormat; + bufferDesc.guid3DAlgorithm = GUID_NULL; + + return bufferDesc; +} + +WAVEFORMATEX FillSecondaryWaveFormat(cardinal samplesPerSec) +{ + WAVEFORMATEX waveFormat; + + waveFormat.wFormatTag = WAVE_FORMAT_PCM; + + waveFormat.nSamplesPerSec = samplesPerSec; + + waveFormat.wBitsPerSample = 16; + + waveFormat.nChannels = 2; + waveFormat.nBlockAlign = (waveFormat.wBitsPerSample / 8) * waveFormat.nChannels; + waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAlign; + waveFormat.cbSize = 0; + + return waveFormat; +} + + +//============================================ +//============================================ +//============================================ + + + +void TMusicDataAccessInterface::ResetDataCursor() +{ + goneOverEnd = false; + InnerResetDataCursor(); +} + +void TMusicDataAccessInterface::ReadDataToBuffer_Looped(char* buffer, int size) +{ + int totalbytesRead = 0; + int bytesRead; + int sizeLeft = size; + + while(totalbytesRead < size) + { + InnerReadDataToBuffer(&buffer[totalbytesRead], sizeLeft, bytesRead); + totalbytesRead += bytesRead; + sizeLeft -= bytesRead; + } + +} + + +int TMusicDataAccessInterface::ReadDataToBuffer(char* buffer, int size) +{ + int result; + int totalbytesRead = 0; + int bytesRead; + int sizeLeft = size; + + while(totalbytesRead < size && (!goneOverEnd)) + { + result = InnerReadDataToBuffer(&buffer[totalbytesRead], sizeLeft, bytesRead); + + goneOverEnd = (result == -1); + + totalbytesRead += bytesRead; + sizeLeft -= bytesRead; + } + + if (goneOverEnd) + { + for (int i = totalbytesRead; i < size; i++) + { + buffer[i] = 0x00; + } + } + + if (goneOverEnd) + { + return -1; + } + else + { + return 1; + } + +} + +//============================================ +//============================================ +//============================================ + + + +TMusicStreamAncestor::TMusicStreamAncestor() + : IsPlaying(false) + , Looped(false) + , BufferCursorPos(0) + , PlayCursorPos(0) + , TotalPlayCursorPos(0) + , IsLoaded(false) +{ +} + + +TMusicStreamAncestor::~TMusicStreamAncestor() +{ +} + + +void TMusicStreamAncestor::Load(const std::string& musicFileName) +{ + + std::string fileName = musicFileName; + + //MusicFile = LoadWaveFile(fileName); + LoadSoundData(fileName); + + DirectSoundBuffer.soundBuffer = ResourceManager->SoundManager.CreateDirectSound8InterfaceBuffer(CONST_DIRECTSOUND_BUFFER_SIZE, GetSamplesPerSec()); + + InitialFillBuffer(); + + BufferCursorPos = 0; + PlayCursorPos = 0; + TotalPlayCursorPos = 0; + + IsLoaded = true; +} + +void TMusicStreamAncestor::Clear() +{ + if (IsLoaded) + { + ClearSoundData(); + + DirectSoundBuffer.soundBuffer->Release(); + DirectSoundBuffer.soundBuffer = NULL; + + BufferCursorPos = 0; + PlayCursorPos = 0; + TotalPlayCursorPos = 0; + + IsLoaded = false; + } +} + + + +void TMusicStreamAncestor::Update() +{ + + if (!IsPlaying) + { + return; + } + + cardinal readPosition; + HRESULT r; + + r = DirectSoundBuffer.soundBuffer->GetCurrentPosition(reinterpret_cast(&readPosition), NULL); + + if (r != DS_OK) + { + throw ErrorToLog("Error in TWaveMusicStruct::Update"); + } + + + if (readPosition >= PlayCursorPos) + { + TotalPlayCursorPos += (readPosition - PlayCursorPos); + } + else + { + TotalPlayCursorPos += (CONST_DIRECTSOUND_BUFFER_SIZE - PlayCursorPos) + readPosition; + } + + PlayCursorPos = readPosition; + + if (CheckIfSoundIsOver() && !Looped) + { + Stop(); + return; + } + + + char* bufferPtr1; + char* bufferPtr2; + cardinal bufferSize1, bufferSize2; + + cardinal size = GetMaxWriteSize(BufferCursorPos, CONST_DIRECTSOUND_BUFFER_SIZE, DirectSoundBuffer); + + if (size == 0) + { + return; + } + + r = DirectSoundBuffer.soundBuffer->Lock(BufferCursorPos, size, reinterpret_cast(&bufferPtr1), reinterpret_cast(&bufferSize1), reinterpret_cast(&bufferPtr2), reinterpret_cast(&bufferSize2), 0); + + if (r != DS_OK) + { + throw ErrorToLog("Error in UpdateBufferWithWaveFile"); + } + + if (Looped) + { + ReadDataToBuffer_Looped(bufferPtr1, bufferSize1); + } + else + { + ReadDataToBuffer(bufferPtr1, bufferSize1); + } + + if (bufferPtr2 != NULL) + { + if (Looped) + { + ReadDataToBuffer_Looped(bufferPtr2, bufferSize2); + } + else + { + ReadDataToBuffer(bufferPtr2, bufferSize2); + } + } + + BufferCursorPos = (BufferCursorPos + bufferSize1 + bufferSize2) % CONST_DIRECTSOUND_BUFFER_SIZE; + + r = DirectSoundBuffer.soundBuffer->Unlock(reinterpret_cast(bufferPtr1), (bufferSize1), reinterpret_cast(bufferPtr2), (bufferSize2)); + + if(FAILED(r)) + { + throw ErrorToLog("Error in UpdateBufferWithWaveFile"); + } +} + + +void TMusicStreamAncestor::Play() +{ + if (!IsLoaded) + { + return; + } + Looped = false; + InnerPlay(); +} + +void TMusicStreamAncestor::PlayLooped() +{ + if (!IsLoaded) + { + return; + } + Looped = true; + InnerPlay(); +} + +void TMusicStreamAncestor::Stop() +{ + if (!IsLoaded) + { + return; + } + + HRESULT r; + + IsPlaying = false; + + ResetDataCursor(); + + BufferCursorPos = 0; + PlayCursorPos = 0; + TotalPlayCursorPos = 0; + + r = DirectSoundBuffer.soundBuffer->Stop(); + + r = DirectSoundBuffer.soundBuffer->SetCurrentPosition(0); + + if (r != DS_OK) + { + throw ErrorToLog("Error in TWaveMusicStruct::Stop"); + } + + + if (r != DS_OK) + { + throw ErrorToLog("Error in TWaveMusicStruct::Stop"); + } + + InitialFillBuffer(); + +} + + + +void TMusicStreamAncestor::InnerPlay() +{ + if (IsPlaying) + { + return; + } + + HRESULT result; + + // Set position at the beginning of the sound buffer. + result = DirectSoundBuffer.soundBuffer->SetCurrentPosition(0); + if(FAILED(result)) + { + throw ErrorToLog("Error in LoadAndPlaySound"); + } + + // Set volume of the buffer to 100%. + result = DirectSoundBuffer.soundBuffer->SetVolume(DSBVOLUME_MAX); + if(FAILED(result)) + { + throw ErrorToLog("Error in LoadAndPlaySound"); + } + + // Play the contents of the secondary sound buffer. + result = DirectSoundBuffer.soundBuffer->Play(0, 0, DSBPLAY_LOOPING); + if(FAILED(result)) + { + throw ErrorToLog("Error in LoadAndPlaySound"); + } + + + IsPlaying = true; +} + +void TMusicStreamAncestor::InitialFillBuffer() +{ + HRESULT r; + + cardinal bufferSize; + + char *bufferPtr; + + r = DirectSoundBuffer.soundBuffer->Lock(0, CONST_DIRECTSOUND_BUFFER_SIZE, reinterpret_cast(&bufferPtr), reinterpret_cast(&bufferSize), NULL, 0, 0); + + if(FAILED(r)) + { + throw ErrorToLog("Error in LoadAndPlaySound"); + } + + if (ReadDataToBuffer(bufferPtr, CONST_DIRECTSOUND_BUFFER_SIZE) != 1) + { + throw ErrorToLog("Assert on LoadAndPlaySound"); + } + + // Unlock the secondary buffer after the data has been written to it. + r = DirectSoundBuffer.soundBuffer->Unlock(reinterpret_cast(bufferPtr), bufferSize, NULL, 0); + + if(FAILED(r)) + { + throw ErrorToLog("Error in LoadAndPlaySound"); + } + +} + + +//=============================================== +//=============================================== +//=============================================== + + +TSoundManagerWindows::TSoundManagerWindows() +{ + InitDirectSound(); +} + + +TSoundManagerWindows::~TSoundManagerWindows() +{ + SoundMap.clear(); + ShutdownDirectSound(); +} + +void TSoundManagerWindows::InitDirectSound() +{ + HRESULT result; + DSBUFFERDESC bufferDesc; + WAVEFORMATEX waveFormat; + + // Initialize the direct sound interface pointer for the default sound device. + result = DirectSoundCreate8(NULL, &DirectSound, NULL); + if(FAILED(result)) + { + throw ErrorToLog("Error in InitDirectSound"); + } + + // Set the cooperative level to priority so the format of the primary sound buffer can be modified. + result = DirectSound->SetCooperativeLevel(Hwnd, DSSCL_PRIORITY); //Hwnd is global variable defined in HalibutEngineWindows + if(FAILED(result)) + { + throw ErrorToLog("Error in InitDirectSound"); + } + + // Setup the primary buffer description. + bufferDesc = FillPrimaryWaveBufferDescription(); + + // Get control of the primary sound buffer on the default sound device. + result = DirectSound->CreateSoundBuffer(&bufferDesc, &PrimaryBuffer, NULL); + if(FAILED(result)) + { + throw ErrorToLog("Error in InitDirectSound"); + } + + waveFormat = FillPrimaryWaveFormat(); + + // Set the primary buffer to be the wave format specified. + result = PrimaryBuffer->SetFormat(&waveFormat); + if(FAILED(result)) + { + throw ErrorToLog("Error in InitDirectSound"); + } + +} + +void TSoundManagerWindows::ShutdownDirectSound() +{ + // Release the primary sound buffer pointer. + if(PrimaryBuffer) + { + PrimaryBuffer->Release(); + PrimaryBuffer = 0; + } + + // Release the direct sound interface pointer. + if(PrimaryBuffer) + { + PrimaryBuffer->Release(); + PrimaryBuffer = 0; + } + +} + + + +IDirectSoundBuffer8* TSoundManagerWindows::CreateDirectSound8InterfaceBuffer(cardinal dataSize, cardinal samplesPerSec) +{ + WAVEFORMATEX waveFormat; + DSBUFFERDESC bufferDesc; + HRESULT result; + IDirectSoundBuffer* tempBuffer; + + IDirectSoundBuffer8* soundBuffer; + + + // Set the wave format of secondary buffer that this wave file will be loaded onto. + waveFormat = FillSecondaryWaveFormat(samplesPerSec); + + // Set the buffer description of the secondary sound buffer that the wave file will be loaded onto. + bufferDesc = FillSecondaryWaveBufferDescription(dataSize, &waveFormat); + + // Create a temporary sound buffer with the specific buffer settings. + result = DirectSound->CreateSoundBuffer(&bufferDesc, &tempBuffer, NULL); + if(FAILED(result)) + { + throw ErrorToLog("Error in CreateDirectSound8InterfaceBuffer"); + } + + // Test the buffer format against the direct sound 8 interface and create the secondary buffer. + result = tempBuffer->QueryInterface(IID_IDirectSoundBuffer8, reinterpret_cast(&soundBuffer)); + + + if(FAILED(result)) + { + throw ErrorToLog("Error in CreateDirectSound8InterfaceBuffer"); + } + + // Release the temporary buffer. + tempBuffer->Release(); + tempBuffer = 0; + + return soundBuffer; +} + + + +void TSoundManagerWindows::LoadSound(const std::string& soundFileName) +{ + std::string soundName = std::string(GetFileName(soundFileName.c_str())); + + if (SoundMap.count(soundName) != 0) + { + return; + } + + HRESULT result; + + std::string fileName = ResourceManager->PathToResources + soundFileName; + + + TWaveFile waveFile; + + if (GetFileExt(fileName) == ".ogg") + { + waveFile = OggSoundFromFile(fileName); + } + else if (GetFileExt(fileName) == ".wav") + { + waveFile = LoadWaveFile(fileName); + } + else + { + throw ErrorToLog("Unknown extension for sound for file: "+tostr(fileName)); + } + + + SoundMap[soundName].soundBuffer = CreateDirectSound8InterfaceBuffer(waveFile.WaveHeader.DataSize, waveFile.WaveHeader.SamplesPerSec); + + cardinal bufferSize; + + unsigned char *bufferPtr; + + result = SoundMap[soundName].soundBuffer->Lock(0, waveFile.WaveHeader.DataSize, reinterpret_cast(&bufferPtr), reinterpret_cast(&bufferSize), NULL, 0, 0); + + if(FAILED(result)) + { + throw ErrorToLog("Error in LoadAndPlaySound"); + } + + // Copy the wave data into the buffer. + memcpy(bufferPtr, &(waveFile.WaveData[0]), waveFile.WaveHeader.DataSize); + + // Unlock the secondary buffer after the data has been written to it. + result = SoundMap[soundName].soundBuffer->Unlock(reinterpret_cast(bufferPtr), bufferSize, NULL, 0); + if(FAILED(result)) + { + throw ErrorToLog("Error in LoadAndPlaySound"); + } + +} + + +void TSoundManagerWindows::PlaySound(const std::string& soundName) +{ + + if (SoundMap.count(soundName) == 0) + { + return; + } + + HRESULT result; + + + // Set position at the beginning of the sound buffer. + result = SoundMap[soundName].soundBuffer->SetCurrentPosition(0); + if(FAILED(result)) + { + throw ErrorToLog("Error in LoadAndPlaySound"); + } + + // Set volume of the buffer to 100%. + result = SoundMap[soundName].soundBuffer->SetVolume(DSBVOLUME_MAX); + if(FAILED(result)) + { + throw ErrorToLog("Error in LoadAndPlaySound"); + } + + // Play the contents of the secondary sound buffer. + result = SoundMap[soundName].soundBuffer->Play(0, 0, 0); + if(FAILED(result)) + { + throw ErrorToLog("Error in LoadAndPlaySound"); + } +} + + +void TSoundManagerWindows::PlayMusic(const std::string& musicName) +{ + if (StreamMap.count(musicName) != 0) + { + StreamMap[musicName]->Play(); + } +} + +void TSoundManagerWindows::PlayMusicLooped(const std::string& musicName) +{ + if (StreamMap.count(musicName) != 0) + { + StreamMap[musicName]->PlayLooped(); + } +} + +void TSoundManagerWindows::LoadMusic(const std::string& musicFileName) +{ + std::string musicName = std::string(GetFileName(musicFileName.c_str())); + + if (StreamMap.count(musicName) == 0) + { + + boost::shared_ptr ptr; + + if (std::string(GetFileExt(musicName.c_str())) == ".wav") + { + ptr = boost::shared_ptr(new TWaveStream); + } + else if (std::string(GetFileExt(musicName.c_str())) == ".ogg") + { + ptr = boost::shared_ptr(new TOggMusicStream); + } + + StreamMap[musicName] = ptr; + + StreamMap[musicName]->Load(ResourceManager->PathToResources + musicFileName); + } +} + +void TSoundManagerWindows::StopMusic(const std::string& musicName) +{ + if (StreamMap.count(musicName) != 0) + { + StreamMap[musicName]->Stop(); + } +} + +void TSoundManagerWindows::StopAllMusic() +{ + for (std::map >::iterator i = StreamMap.begin(); i != StreamMap.end(); ++i) + { + i->second->Stop(); + } +} + +void TSoundManagerWindows::TryStopAndPlayMusicLooped(const std::string& musicName) +{ + for (std::map >::iterator i = StreamMap.begin(); i != StreamMap.end(); ++i) + { + if (i->first != musicName) + { + i->second->Stop(); + } + } + + if (StreamMap.count(musicName) != 0) + { + StreamMap[musicName]->PlayLooped(); + } + + + +} + +DWORD GetMaxWriteSize(cardinal m_cbBufOffset, cardinal m_cbBufSize, TDirectSoundStruct& soundStruct) +{ + DWORD dwWriteCursor, dwPlayCursor, dwMaxSize; + + // Get current play position + if (soundStruct.soundBuffer->GetCurrentPosition (&dwPlayCursor, &dwWriteCursor) == DS_OK) + { + if (m_cbBufOffset <= dwPlayCursor) + { + // Our write position trails play cursor + dwMaxSize = dwPlayCursor - m_cbBufOffset; + } + + else // (m_cbBufOffset > dwPlayCursor) + { + // Play cursor has wrapped + dwMaxSize = m_cbBufSize - m_cbBufOffset + dwPlayCursor; + } + } + else + { + throw ErrorToLog("Error in GetMaxWriteSize"); + dwMaxSize = 0; + } + return dwMaxSize; +} + +void FillMemoryWithZero(char* bufferPtr, cardinal bufferSize) +{ + for (cardinal i=0; i >::iterator i; + + for (i = StreamMap.begin(); i != StreamMap.end(); ++i) + { + i->second->Update(); + } +} + + +//================================================================ +//================================================================ +//================================================================ + +TWaveStream::TWaveStream() +{ + ResetDataCursor(); +} + + +TWaveStream::~TWaveStream() +{ + Clear(); +} + +int TWaveStream::InnerReadDataToBuffer(char* buffer, int size, int& bytesRead) +{ + int result = 1; + + if (size + MusicFile.WaveDataCursor > MusicFile.WaveHeader.DataSize) + { + bytesRead = MusicFile.WaveHeader.DataSize - MusicFile.WaveDataCursor; + } + else + { + bytesRead = size; + } + + memcpy(buffer, &(MusicFile.WaveData[MusicFile.WaveDataCursor]), bytesRead); + + MusicFile.WaveDataCursor += size; + + while (MusicFile.WaveDataCursor >= MusicFile.WaveHeader.DataSize) + { + MusicFile.WaveDataCursor -= MusicFile.WaveHeader.DataSize; + result = -1; + } + + return result; + + +} + +void TWaveStream::InnerResetDataCursor() +{ + MusicFile.WaveDataCursor = 0; +} + +void TWaveStream::ClearSoundData() +{ + MusicFile.WaveData = TByteArrPtr(NULL); + MusicFile.WaveHeader.DataSize = 0; + MusicFile.WaveDataCursor = 0; +} + +void TWaveStream::LoadSoundData(const std::string& fileName) +{ + MusicFile = LoadWaveFile(fileName); +} + +bool TWaveStream::CheckIfSoundIsOver() +{ + return (TotalPlayCursorPos >= MusicFile.WaveHeader.DataSize); +} + +cardinal TWaveStream::GetSamplesPerSec() +{ + return MusicFile.WaveHeader.SamplesPerSec; +} + + +//============================================= +//============================================= +//============================================= + + +TOggMusicStream::TOggMusicStream() +{ + IsInited = false; + ResetDataCursor(); +} + + +TOggMusicStream::~TOggMusicStream() +{ + Clear(); +} + +int TOggMusicStream::InnerReadDataToBuffer(char* buffer, int size, int& bytesRead) +{ + int result; + int section; + + bytesRead = ov_read(&OggFileData, buffer, size, 0, CONST_BPS, 1, §ion); + + if (bytesRead == -1) + { + throw ErrorToLog("Error!"); + } + else if (bytesRead == 0) + { + + if (ov_raw_seek(&(OggFileData), 0)) + { + throw ErrorToLog("Error on call ov_raw_seek!"); + } + + result = -1; + } + else + { + result = 1; + } + + + return result; + +} + +void TOggMusicStream::InnerResetDataCursor() +{ + if (!IsInited) + { + return; + } + + if (ov_raw_seek(&(OggFileData), 0)) + { + throw ErrorToLog("Error on call ov_raw_seek!"); + } + +} + +void TOggMusicStream::ClearSoundData() +{ + + FileBuffer = TOggCallbackFileBuffer(); + + ov_clear(&OggFileData); + + + VorbisInfo = NULL; + + IsInited = false; + +} + +void TOggMusicStream::LoadSoundData(const std::string& fileName) +{ + cardinal fileSize; + + TByteArrPtr fileArr = CreateMemFromFile(fileName, fileSize); + + FileBuffer = TOggCallbackFileBuffer(fileArr, fileSize); + + if(ov_open_callbacks(&FileBuffer, &OggFileData, NULL, 0, OggCallbacks) < 0) + throw ErrorToLog("Error! Input does not appear to be an Ogg bitstream: "+fileName); + + VorbisInfo = ov_info(&OggFileData, -1); + + IsInited = true; +} + +bool TOggMusicStream::CheckIfSoundIsOver() +{ + cardinal r = static_cast(2 * CONST_BPS * ov_pcm_total(&OggFileData, -1)); + if (OV_EINVAL == r) + { + throw ErrorToLog("Ogg error!"); + } + + + return (TotalPlayCursorPos >= r); +} + + +cardinal TOggMusicStream::GetSamplesPerSec() +{ + return VorbisInfo->rate; +} + + +#endif //NOSOUND + + +} //namespace SE \ No newline at end of file diff --git a/src/TextureManager/SalmonTexture.cpp b/src/TextureManager/SalmonTexture.cpp new file mode 100644 index 0000000..803e95c --- /dev/null +++ b/src/TextureManager/SalmonTexture.cpp @@ -0,0 +1,899 @@ +#include "include/TextureManager/SalmonTexture.h" + +#include "include/Utils/Utils.h" +#include "include/Engine.h" + +#include "boost/gil/gil_all.hpp" +#include "boost/gil/extension/numeric/sampler.hpp" +#include "boost/gil/extension/numeric/resample.hpp" + +#include "boost/assign.hpp" + +namespace SE +{ + +TTextureListClass::TTextureListClass() +{ + using namespace boost::assign; + + using namespace std; + + CreateFunctionMap[".bmp"] = boost::bind(&TTextureListClass::CreateTexDataFromBmp24, this, _1, _2); + CreateFunctionMap[".bmp32"] = boost::bind(&TTextureListClass::CreateTexDataFromBmp32, this, _1, _2); + CreateFunctionMap[".png"] = boost::bind(&TTextureListClass::CreateTexDataFromPng, this, _1, _2); + CreateFunctionMap[".tga"] = boost::bind(&TTextureListClass::CreateTexDataFromTga, this, _1, _2); + + AddFunctionMap["bmp24"] = boost::bind(&TTextureListClass::AddTextureBmp24Data, this, _1); + AddFunctionMap["bmp32"] = boost::bind(&TTextureListClass::AddTextureBmp32Data, this, _1); + +} + +TTextureListClass::~TTextureListClass() +{ + Clear(); + + *Console<<"ResourceManager::TexList deleting"; +} + +void TTextureListClass::Clear() +{ + + if (TexMap.size() != 0) + { + + BOOST_FOREACH(auto& i, TexMap) + { + glDeleteTextures(1,&(i.second.TexID)); + } + + TexMap.clear(); + + *Console<<"ResourceManager::TexList cleared"; + } + +} + +void TTextureListClass::Serialize(boost::property_tree::ptree& propertyTree) +{ + + BOOST_FOREACH(boost::property_tree::ptree::value_type &v, propertyTree.get_child("Textures")) + { + + std::string fileName = v.second.get("FileName"); + std::string texName = v.second.get("TexName", ""); + + AddTexture(fileName, texName); + + } +} + +void TTextureListClass::NormalizeTexData(TTextureData& texData) +{ + + using namespace boost::gil; + + if (IsPower2(texData.Width) && IsPower2(texData.Height)) + { + return; + } + + cardinal newWidth = GetGreaterPower2(texData.Width); + cardinal newHeight = GetGreaterPower2(texData.Height); + + if (!strcmp(texData.Format, "bmp32")) + { + + boost::shared_array newData(new char [newWidth * newHeight * 4]); + + rgba8_view_t oldView = interleaved_view(texData.Width, texData.Height, reinterpret_cast(texData.Data.get()), texData.DataSize / texData.Height); + + rgba8_image_t newImage(newWidth, newHeight); + + resize_view(oldView, view(newImage), bilinear_sampler()); + + texData.Data = newData; + texData.Width = newWidth; + texData.Height = newHeight; + texData.DataSize = newWidth * newHeight * 4; + + oldView = interleaved_view(texData.Width, texData.Height, reinterpret_cast(texData.Data.get()), texData.DataSize / texData.Height); + + copy_pixels(view(newImage), oldView); + + } + else if (!strcmp(texData.Format, "bmp24")) + { + boost::shared_array newData(new char [newWidth * newHeight * 3]); + + rgb8_view_t oldView = interleaved_view(texData.Width, texData.Height, reinterpret_cast(texData.Data.get()), texData.DataSize / texData.Height); + + rgb8_image_t newImage(newWidth, newHeight); + + resize_view(oldView, view(newImage), bilinear_sampler()); + + texData.Data = newData; + texData.Width = newWidth; + texData.Height = newHeight; + texData.DataSize = newWidth * newHeight * 3; + + oldView = interleaved_view(texData.Width, texData.Height, reinterpret_cast(texData.Data.get()), texData.DataSize / texData.Height); + + copy_pixels(view(newImage), oldView); + } + else + { + throw ErrorToLog("TTextureListClass::NormalizeTexData Format unsupported: "+std::string(texData.Format)); + } +} + + +bool TTextureListClass::CreateTexDataFromBmp24(const std::string& filename, TTextureData& texData) +{ + + cardinal fileSize; + boost::shared_array fileArr = CreateMemFromFile(filename, fileSize); + + if (fileSize<22) + throw ErrorFileNotCorrect(filename); + + //This refers to BITMAPV5HEADER + + strcpy(texData.Format, "bmp24"); + texData.Width = *reinterpret_cast(&fileArr[18]); + texData.Height = *reinterpret_cast(&fileArr[22]); + + texData.DataSize = texData.Height * texData.Width * 3; + + texData.Data = boost::shared_array(new char [texData.DataSize]); + + cardinal pos = *reinterpret_cast(&fileArr[10]); + cardinal x = 0; + + for (cardinal i=0; ifileSize) + throw ErrorFileTooShort(filename); + + x = (i * texData.Height + j) + (i * texData.Height + j) + (i * texData.Height + j); + + texData.Data[x + 2] = fileArr[pos++]; + texData.Data[x + 1] = fileArr[pos++]; + texData.Data[x + 0] = fileArr[pos++]; + + } + + return true; +} + + +bool TTextureListClass::CreateTexDataFromBmp32(const std::string& filename, TTextureData& texData) +{ + cardinal fileSize; + + boost::shared_array fileArr = CreateMemFromFile(filename, fileSize); + + if (fileSize<22) + throw ErrorFileNotCorrect(filename); + + //Meaning BITMAPV5HEADER + + strcpy(texData.Format, "bmp32"); + texData.Width = *reinterpret_cast(&fileArr[18]); + texData.Height = *reinterpret_cast(&fileArr[22]); + + texData.DataSize = texData.Height * texData.Width * 4; + + texData.Data = boost::shared_array(new char [texData.DataSize]); + + cardinal pos = *reinterpret_cast(&fileArr[10]); + cardinal x = 0; + + for (cardinal i=0; ifileSize) + throw ErrorFileTooShort(filename); + + x = (i * texData.Height + j) * 4; + texData.Data[x + 2] = fileArr[pos++]; + texData.Data[x + 1] = fileArr[pos++]; + texData.Data[x + 0] = fileArr[pos++]; + texData.Data[x + 3] = fileArr[pos++]; + } + + //delete [] fileArr; + + return true; +} + +bool TTextureListClass::CreateTexDataFromTga(const std::string& filename, TTextureData& texData) +{ + + cardinal fileSize; + boost::shared_array fileArr = CreateMemFromFile(filename, fileSize); + + if (fileSize < 22) + throw ErrorFileNotCorrect(filename); + + texData.Width = *reinterpret_cast(&fileArr[12]); + texData.Height = *reinterpret_cast(&fileArr[14]); + + char textLength = fileArr[0]; + + char dataType = fileArr[2]; + + char bitsPerPixel = fileArr[16]; + + + if (bitsPerPixel == 24) + { + texData.DataSize = texData.Height * texData.Width * 3; + texData.Data = boost::shared_array(new char [texData.DataSize]); + strcpy(texData.Format, "bmp24"); + } + else + if (bitsPerPixel == 32) + { + texData.DataSize = texData.Height * texData.Width * 4; + texData.Data = boost::shared_array(new char [texData.DataSize]); + strcpy(texData.Format, "bmp32"); + } + else + throw ErrorFileNotCorrect(filename); + + int bytesPerPixel = bitsPerPixel / 8; + + unsigned char blockInfo; + char whatItIs; + unsigned int numPixels; + + cardinal n = 0; + int filePos = textLength + 18; + + if (dataType == 2) + { + + for(cardinal n = 0; n < texData.Height * texData.Width; n++) + { + texData.Data[n*bytesPerPixel + 2] = fileArr[filePos++]; + texData.Data[n*bytesPerPixel + 1] = fileArr[filePos++]; + texData.Data[n*bytesPerPixel + 0] = fileArr[filePos++]; + if (bitsPerPixel == 32) + { + texData.Data[n*bytesPerPixel + 3] = fileArr[filePos++]; + } + } + + } + else if (dataType == 10) + { + throw ErrorToLog("RLE-compressed TGA is not supported yet: "+filename); + + while (n < texData.Height * texData.Width) + { + blockInfo = fileArr[filePos++]; + whatItIs = blockInfo & 128; + numPixels = blockInfo & 127; + + if (whatItIs) + { + + for (cardinal i=0; i fileArr = CreateMemFromFile(filename, fileSize); + + if (fileSize < 22) + throw ErrorFileNotCorrect(filename); + + TPngDataStruct s = read_png_file(fileArr, fileSize); + + texData.Width = s.Width; + texData.Height = s.Height; + + cardinal bytesPerPixel; + + if (s.ColorType == PNG_COLOR_TYPE_RGB) + { + strcpy(texData.Format, "bmp24"); + + bytesPerPixel = 3; + } + else if (s.ColorType == PNG_COLOR_TYPE_RGBA) + { + strcpy(texData.Format, "bmp32"); + + bytesPerPixel = 4; + } + + texData.DataSize = texData.Height * texData.Width * bytesPerPixel; + texData.Data = boost::shared_array(new char [texData.DataSize]); + + + cardinal x; + + for (cardinal i=0; iPathToResources + fileName; + return AddTextureDirectly(fullFileName, texName); + +} + + +cardinal TTextureListClass::AddTextureFromUserdata(const std::string& fileName, std::string texName) +{ + + + if (!IsFileExistsInUserData(fileName)) + { + throw ErrorToLog("File not found in userdata: "+fileName); + } + + std::string fullFileName = GetFilePathUserData(fileName); + + return AddTextureDirectly(fullFileName.c_str(), texName); +} + + +cardinal TTextureListClass::AddCubemapTexture(std::string filename[6]) +{ + + + filename[0] = ResourceManager->PathToResources + filename[0]; + filename[1] = ResourceManager->PathToResources + filename[1]; + filename[2] = ResourceManager->PathToResources + filename[2]; + filename[3] = ResourceManager->PathToResources + filename[3]; + filename[4] = ResourceManager->PathToResources + filename[4]; + filename[5] = ResourceManager->PathToResources + filename[5]; + + std::string texname = GetFileName(filename[0]); + std::string texext; + cardinal TexID; + int i; + + if (TexMap.count(texname) == 0) + { + TTextureData texData[6]; + + for (i = 0; i < 6; i++) + { + texext = GetFileExt(filename[i]); + *Console<<"Going to add texture: "+filename[i]; + if (texext == ".bmp") + { + if (!CreateTexDataFromBmp24(filename[i],texData[i])) + { + *Console<<"ResourceManager::TexList ERROR - TEXTURE LOAD FAILED: "+texname; + return 0; + } + + } + else + { + + *Console<<"ResourceManager::TexList ERROR - FORMAT NOT SUPPORTED: "+texext; + return 0; + } + + } + + //All textures have been inserted into texData[6], lets add them + + TexID = AddCubemapTextureBmp24Data(texData); + + //for (int j = 0; j < 6; j++) delete [] texData[j].Data; + + if (TexID != 0) + { + TexMap[texname].RefCount = 1; + TexMap[texname].TexID = TexID; + *Console<<"ResourceManager::TexList texture added succesfuly: "+texname; + return TexID; + } + else + { + *Console<<"ResourceManager::TexList ERROR - TEXTURE ADD TO OPENGL FAILED: "+texname; + return 0; + } + + + } + else + { + ++TexMap[texname].RefCount; + *Console<<"ResourceManager::TexList Texture reference added: "+texname; + return TexMap[texname].TexID; + } + +} + +cardinal TTextureListClass::AddEmptyTexture(const std::string& texName,cardinal width,cardinal height) +{ + cardinal texID; + + if (TexMap.count(texName) == 0) + { + + glGenTextures(1, &texID); + glBindTexture(GL_TEXTURE_2D, texID); + + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + #ifdef TARGET_WIN32 + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); + #endif + + #ifndef TARGET_WIN32 //TARGET_ANDROID or TARGET_IOS + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + #endif + + + } + else + { + TexMap[texName].RefCount++; + texID = TexMap[texName].TexID; + } + + return texID; + +} + + +cardinal TTextureListClass::AddEmptyCubemapTexture(const std::string& texName,cardinal width,cardinal height) +{ + cardinal texID; + + if (TexMap.count(texName) == 0) + { + + glGenTextures(1, &texID); + glBindTexture(GL_TEXTURE_CUBE_MAP, texID); + + #ifdef TARGET_WIN32 + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+0, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+1, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+2, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+3, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+4, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+5, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); + #endif + + #ifndef TARGET_WIN32 //TARGET_IOS or TARGET_ANDROID + + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+0, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+1, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+2, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+3, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+4, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+5, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + + #endif + } + else + { + TexMap[texName].RefCount++; + texID = TexMap[texName].TexID; + } + + return texID; +} + + +cardinal TTextureListClass::AddDepthTexture(const std::string& texName,cardinal width,cardinal height) +{ + #ifdef TARGET_WIN32 + cardinal texID; + + if (TexMap.count(texName) == 0) + { + + glGenTextures(1, &texID); + glBindTexture(GL_TEXTURE_2D, texID); + + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); + + } + else + { + TexMap[texName].RefCount++; + texID = TexMap[texName].TexID; + } + + return texID; + #endif + + #ifdef TARGET_ANDROID + + throw ErrorToLog("Trying to create depth texture on Android!!!"); + + return 0; + + #endif +#ifdef TARGET_IOS + + throw ErrorToLog("Trying to create depth texture on iOS!!!"); + + return 0; + +#endif + +} + +void TTextureListClass::DeleteTexture(const std::string& texName) +{ + if (TexMap.count(texName) != 0) + { + --TexMap[texName].RefCount; + + if (TexMap[texName].RefCount == 0) + { + glDeleteTextures(1,&(TexMap[texName].TexID)); + TexMap.erase(texName); + *Console<<"ResourceManager::TexList texture "+texName+" deleted"; + } + else + *Console<<"ResourceManager::TexList texture "+texName+" reference deleted"; + } +} + + +void TTextureListClass::DeleteTexture(cardinal texID) +{ + TTextureMap::iterator i = TexMap.begin(); + + while (i != TexMap.end()) + { + if (i->second.TexID == texID) + { + (i->second.RefCount)--; + + if (i->second.RefCount == 0) + { + glDeleteTextures(1,&(i->second.TexID)); + + *Console << "ResourceManager::TexList texture " + (i->first) + " deleted"; + + TexMap.erase(i); + } + else + *Console<<"ResourceManager::TexList texture "+(i->first)+" reference deleted"; + + i = TexMap.end(); //to go out of loop + + } + else + { + ++i; + } + + } + +} + + +void TTextureListClass::PrintTextureList() +{ + TTextureMap::iterator i; + + Console->PrintImmediate("======= Texture List =========="); + + for (i = TexMap.begin(); i != TexMap.end(); ++i) + { + Console->PrintImmediate("ID="+tostr(i->second.TexID) + " " + i->first +" Ref="+tostr(i->second.RefCount)); + } +} + + +void TTextureListClass::BindFunctions() +{ + //*Console<<"Bind functions in TTextureListClass\n"; + ResourceManager->ScriptManager.AddFunction("ptl", TScriptInfo("PrintTextureList"), *this, &TTextureListClass::PrintTextureList); +} + +void TTextureListClass::SaveTexDataToPlainBmpToUserData(const std::string& fileName, TTextureData texData) +{ + + std::string fullFileName = GetFilePathUserData(fileName); + FILE * pFile; + pFile = fopen (fullFileName.c_str(), "wb"); + + if (pFile == NULL) + { + throw ErrorToLog("pFile == NULL in TTextureListClass::SaveTexDataToPlainBmp"); + } + + char DummyBuffer[10]; + + fwrite (DummyBuffer, 1, 10, pFile); //0 -> 10 + + int rgbDataOffset = 26; + + fwrite (&rgbDataOffset, 4, 1, pFile); //10 -> 14 + + fwrite (DummyBuffer, 1, 4, pFile); //14 -> 18 + + fwrite (&(texData.Width), 4, 1, pFile); //18 -> 22 + fwrite (&(texData.Height), 4, 1, pFile); //22 -> 26 + + cardinal x = 0; + + for (cardinal i = 0; i < texData.Width; i++) + { + for(cardinal j = 0; j < texData.Height; j++) + { + x = (i * texData.Height + j) + (i * texData.Height + j) + (i * texData.Height + j); + + fwrite (&(texData.Data[x + 2]), 1, 1, pFile); + fwrite (&(texData.Data[x + 1]), 1, 1, pFile); + fwrite (&(texData.Data[x + 0]), 1, 1, pFile); + } + } + + fclose (pFile); + +} + + +} //namespace SE \ No newline at end of file diff --git a/src/Utils/Console/Console.cpp b/src/Utils/Console/Console.cpp new file mode 100644 index 0000000..17753f2 --- /dev/null +++ b/src/Utils/Console/Console.cpp @@ -0,0 +1,243 @@ +#include "include/Engine.h" +#include "boost/date_time.hpp" + +namespace SE +{ + +const cardinal CONST_MAX_ROWS_IN_HISTORY = 20; + +const float CONST_CONSOLE_PART_OF_SCREEN = 0.35f; + +const int CONST_ROW_WIDTH = 14; + +const std::string CONST_CONSOLE_TEX_NAME = "console_bkg.bmp"; + +void TSimpleConsole::Draw() +{ + + + RenderUniform1f("Transparency", 1.f); + + if (HistoryTriangeList.get() == 0) + { + HistoryTriangeList = std::shared_ptr(new TTriangleList); + } + + float screenWidth = Renderer->GetMatrixWidth(); + float screenHeight = Renderer->GetMatrixHeight(); + glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList[CONST_CONSOLE_TEX_NAME]); + + Renderer->PushProjectionMatrix(static_cast(screenWidth), static_cast(screenHeight)); + Renderer->PushMatrix(); + Renderer->LoadIdentity(); + + Renderer->DrawRect(vec2(0.f, screenHeight*(1.f - CONST_CONSOLE_PART_OF_SCREEN)), vec2(screenWidth, screenHeight)); + + if (TextSavedInTriangleList != History) + { + TextSavedInTriangleList = History; + *HistoryTriangeList = ResourceManager->FontManager.DrawTextInBoxToVBO(vec2(0.f, screenHeight * (1.f - CONST_CONSOLE_PART_OF_SCREEN)), vec2(static_cast(screenWidth), static_cast(screenHeight)), CONST_ROW_WIDTH, TextSavedInTriangleList); + } + + TTriangleList consoleInputTriangleList = ResourceManager->FontManager.DrawTextInBoxToVBO(vec2(0.f, screenHeight * (1.f - CONST_CONSOLE_PART_OF_SCREEN)), vec2(static_cast(screenWidth), static_cast(screenHeight)), CONST_ROW_WIDTH, ">"+ConsoleInput); + + glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList[ResourceManager->FontManager.GetCurrentFontTextureName()]); + + Renderer->DrawTriangleList(*HistoryTriangeList); + Renderer->DrawTriangleList(consoleInputTriangleList); + + std::string ConsoleInputAtCursor = std::string((">"+ConsoleInput), 0, ConsoleCursor+1); + + float advance = ResourceManager->FontManager.GetTextAdvance(ConsoleInputAtCursor); + + TTriangleList consoleCursorTriangleList = ResourceManager->FontManager.DrawTextInBoxToVBO(vec2(advance, screenHeight*(1.f - CONST_CONSOLE_PART_OF_SCREEN)), vec2(static_cast(screenWidth), static_cast(screenHeight)), 14, "|"); + + Renderer->DrawTriangleList(consoleCursorTriangleList); + + Renderer->PopMatrix(); + Renderer->PopProjectionMatrix(); + +} + + +void TSimpleConsole::CutHistory() +{ + cardinal i = 0; + + cardinal pos = std::string::npos; + + do + { + if (pos != std::string::npos && pos > 0) + { + pos--; + } + + pos = History.find_last_of('\n', pos); + i++; + } + while (pos != std::string::npos && i != CONST_MAX_ROWS_IN_HISTORY); + + if (pos != std::string::npos) + { + History = History.substr(pos); + } +} + +std::string TSimpleConsole::GetHistory() +{ + return History; +} + + +#ifdef TARGET_WIN32 + +TFileConsole::TFileConsole() + : filename("conlog.txt") + , f("conlog.txt") +{ +} + +TFileConsole::TFileConsole(const std::string& Afilename) + : filename(Afilename) + , f(Afilename) +{ +} + +TFileConsole::~TFileConsole() +{ + f.close(); +} + +TFileConsole& TFileConsole::operator<<(const std::string& s) +{ + boost::posix_time::ptime t = boost::posix_time::second_clock::local_time(); + + std::string string_with_time_mark; + + string_with_time_mark = to_simple_string(t)+": "+s; + + PrintImmediate(string_with_time_mark); + + History += string_with_time_mark+endl; + CutHistory(); + + return *this; +} + + +void TFileConsole::PrintImmediate(const std::string& s) +{ + + f<1)) + { + return 0; + } + + q = a + h * t.v[0]; + + CrossPoint = q; + + return PointInTriangle(q, tr); + + +} + +int PointInTriangle(const vec3& q, const TSmpTriangle& tr) +{ + vec3 v,h; + float nf2[3]; + vec4 quat, inv_quat, p; + + TSmpTriangle trx; + + float sina,cosa,cos2a; + + int i; + + h = vec3(0.0f, 1.0f, 0.0f); + + + if (IsFloatEqual(tr.n.v[0],0.0f) && (!IsFloatEqual(tr.n.v[1],0.0f)) && IsFloatEqual(tr.n.v[2],0.0f)) + { + quat = vec4(1.0f, 0.0f, 0.0f, 0.0f); + } + else + { + v = CrossProduct(tr.n,h); + + cos2a = DotProduct(Normalize(tr.n), h); + + cos2a *= 0.5f; + cosa = sqrtf(0.5f + cos2a); + sina = sqrtf(0.5f - cos2a); + + v = Normalize(v); + + quat.v[0] = v.v[0]*sina; + quat.v[1] = v.v[1]*sina; + quat.v[2] = v.v[2]*sina; + quat.v[3] = cosa; + + } + + inv_quat.v[0] = - quat.v[0]; + inv_quat.v[1] = - quat.v[1]; + inv_quat.v[2] = - quat.v[2]; + inv_quat.v[3] = quat.v[3]; + + for (i=0; i<3; i++) + { + p = vec4(tr.p[i]); + + p = quat * p * inv_quat; + + trx.p[i] = vec3(p); + + }; + + p.v[0] = q.v[0]; + p.v[1] = q.v[1]; + p.v[2] = q.v[2]; + p.v[3] = 0.0f; + + p = quat * p * inv_quat; + + + for (i=0;i<2;i++) + nf2[i] = (p.v[0]-trx.p[i].v[0])*(trx.p[i+1].v[2]-trx.p[i].v[2])-(p.v[2]-trx.p[i].v[2])*(trx.p[i+1].v[0]-trx.p[i].v[0]); + + //Not to go over array: + nf2[2] = (p.v[0]-trx.p[2].v[0])*(trx.p[0].v[2]-trx.p[2].v[2])-(p.v[2]-trx.p[2].v[2])*(trx.p[0].v[0]-trx.p[2].v[0]); + + if (((nf2[0]>=0.0f) && (nf2[1]>=0.0f) && (nf2[2]>=0.0f)) + || ((nf2[0]<=0.0f) && (nf2[1]<=0.0f) && (nf2[2]<=0.0f))) + { + return 1; + } + else + { + return 0; + } + +} + + +float roundf(float r) +{ + return (r > 0.0f) ? floorf(r + 0.5f) : ceilf(r - 0.5f); +} + +cardinal GetGreaterPower2(cardinal x) +{ + if (x > 65536) + { + throw ErrorToLog("GetGreaterPower2: x("+tostr(x)+") is bigger than 65536"); + } + + cardinal result = 1; + + while (x > result) + { + result *= 2; + } + + return result; +} + +vec2 StringToVec2(std::string str) +{ + boost::erase_all(str, " "); + + std::vector splitVec; + + boost::split( splitVec, str, boost::is_any_of(",;"), boost::token_compress_on ); + + if (splitVec.size() < 2) + { + throw ErrorToLog("StringToVec2 - vector is too short: "+str); + } + + vec2 result; + + result.v[0] = boost::lexical_cast(splitVec[0]); + result.v[1] = boost::lexical_cast(splitVec[1]); + + return result; +} + +vec3 StringToVec3(std::string str) +{ + boost::erase_all(str, " "); + + std::vector splitVec; + + boost::split( splitVec, str, boost::is_any_of(",;"), boost::token_compress_on ); + + if (splitVec.size() < 3) + { + throw ErrorToLog("StringToVec3 - vector is too short: "+str); + } + + vec3 result; + + result.v[0] = boost::lexical_cast(splitVec[0]); + result.v[1] = boost::lexical_cast(splitVec[1]); + result.v[2] = boost::lexical_cast(splitVec[2]); + + return result; +} + +vec4 StringToVec4(std::string str) +{ + boost::erase_all(str, " "); + + std::vector splitVec; + + boost::split( splitVec, str, boost::is_any_of(",;"), boost::token_compress_on ); + + if (splitVec.size() < 4) + { + throw ErrorToLog("StringToVec4 - vector is too short: "+str); + } + + vec4 result; + + result.v[0] = boost::lexical_cast(splitVec[0]); + result.v[1] = boost::lexical_cast(splitVec[1]); + result.v[2] = boost::lexical_cast(splitVec[2]); + result.v[3] = boost::lexical_cast(splitVec[3]); + + return result; +} + + +// ================================================ +// ========== wide strings and UTF8 strings ======= +// ================================================ + + +void utf8toWStr(std::wstring& dest, const std::string& src){ + dest.clear(); + wchar_t w = 0; + int bytes = 0; + wchar_t err = 0xFFFD; + for (size_t i = 0; i < src.size(); i++){ + unsigned char c = (unsigned char)src[i]; + if (c <= 0x7f){//first byte + if (bytes){ + dest.push_back(err); + bytes = 0; + } + dest.push_back((wchar_t)c); + } + else if (c <= 0xbf){//second/third/etc byte + if (bytes){ + w = ((w << 6)|(c & 0x3f)); + bytes--; + if (bytes == 0) + dest.push_back(w); + } + else + dest.push_back(err); + } + else if (c <= 0xdf){//2byte sequence start + bytes = 1; + w = c & 0x1f; + } + else if (c <= 0xef){//3byte sequence start + bytes = 2; + w = c & 0x0f; + } + else if (c <= 0xf7){//3byte sequence start + bytes = 3; + w = c & 0x07; + } + else{ + dest.push_back(err); + bytes = 0; + } + } + if (bytes) + dest.push_back(err); +} + +void wstrToUtf8(std::string& dest, const std::wstring& src){ + dest.clear(); + for (size_t i = 0; i < src.size(); i++){ + wchar_t w = src[i]; + if (w <= 0x7f) + dest.push_back((char)w); + else if (w <= 0x7ff){ + dest.push_back(0xc0 | ((w >> 6)& 0x1f)); + dest.push_back(0x80| (w & 0x3f)); + } + else if (w <= 0xffff){ + dest.push_back(0xe0 | ((w >> 12)& 0x0f)); + dest.push_back(0x80| ((w >> 6) & 0x3f)); + dest.push_back(0x80| (w & 0x3f)); + } + else if (w <= 0x10ffff){ + dest.push_back(0xf0 | ((w >> 18)& 0x07)); + dest.push_back(0x80| ((w >> 12) & 0x3f)); + dest.push_back(0x80| ((w >> 6) & 0x3f)); + dest.push_back(0x80| (w & 0x3f)); + } + else + dest.push_back('?'); + } +} + +std::string wstrToUtf8(const std::wstring& str){ + std::string result; + wstrToUtf8(result, str); + return result; +} + +std::wstring utf8toWStr(const std::string& str){ + std::wstring result; + utf8toWStr(result, str); + return result; +} + +std::ostream& operator<<(std::ostream& f, const std::wstring& s){ + std::string s1; + wstrToUtf8(s1, s); + f << s1; + return f; +} + +std::istream& operator>>(std::istream& f, std::wstring& s){ + std::string s1; + f >> s1; + utf8toWStr(s, s1); + return f; +} + + +} //namespace SE \ No newline at end of file diff --git a/src/Utils/DataTypes/NewDataTypes.cpp b/src/Utils/DataTypes/NewDataTypes.cpp new file mode 100644 index 0000000..cb8b73d --- /dev/null +++ b/src/Utils/DataTypes/NewDataTypes.cpp @@ -0,0 +1,57 @@ +#include "include/Utils/DataTypes/NewDataTypes.h" +#include "include/Utils/DataTypes/DataTypes.h" +#include "include/Utils/ErrorTypes/ErrorTypes.h" + +namespace SE +{ + +mat3 TransposeMatrix(const mat3& m) +{ + mat3 r; + r.m[0] = m.m[0]; + r.m[1] = m.m[3]; + r.m[2] = m.m[6]; + r.m[3] = m.m[1]; + r.m[4] = m.m[4]; + r.m[5] = m.m[7]; + r.m[6] = m.m[2]; + r.m[7] = m.m[5]; + r.m[8] = m.m[8]; + return r; +} + +mat3 InverseMatrix(const mat3& m) +{ + float d; + mat3 r; + + d = m.m[0]*(m.m[4]*m.m[8] - m.m[5]*m.m[7]); + d -= m.m[1]*(m.m[3]*m.m[8] - m.m[6]*m.m[5]); + d += m.m[2]*(m.m[3]*m.m[7] - m.m[6]*m.m[4]); + + if (IsFloatEqual(d,0.0f)) + { + throw ErrorToLog("Error: matrix cannot be inversed!"); + + } + else + { + + r.m[0] = (m.m[4]*m.m[8] - m.m[5]*m.m[7])/d; + r.m[1] = - (m.m[1]*m.m[8] - m.m[2]*m.m[7])/d; + r.m[2] = (m.m[1]*m.m[5] - m.m[2]*m.m[4])/d; + + r.m[3] = - (m.m[3]*m.m[8] - m.m[5]*m.m[6])/d; + r.m[4] = (m.m[0]*m.m[8] - m.m[2]*m.m[6])/d; + r.m[5] = - (m.m[0]*m.m[5] - m.m[2]*m.m[3])/d; + + r.m[6] = (m.m[3]*m.m[7] - m.m[6]*m.m[4])/d; + r.m[7] = - (m.m[0]*m.m[7] - m.m[6]*m.m[1])/d; + r.m[8] = (m.m[0]*m.m[4] - m.m[1]*m.m[3])/d; + + }; + return r; +} + + +} //namespace SE \ No newline at end of file diff --git a/src/Utils/FileUtils/FileUtils.cpp b/src/Utils/FileUtils/FileUtils.cpp new file mode 100644 index 0000000..485ddbd --- /dev/null +++ b/src/Utils/FileUtils/FileUtils.cpp @@ -0,0 +1,91 @@ +#include "include/Utils/FileUtils/FileUtils.h" + +#include "include/Utils/Utils.h" + +#include "include/Engine.h" + +#include + +namespace SE +{ + +bool findString(char* in, char* list) +{ + int thisLength = strlen(in); + while (*list != 0) + { + int length = strcspn(list," "); + + if( thisLength == length ) + if (!strncmp(in,list,length)) + return true; + + list += length + 1; + } + return false; +} + +std::string GetFilePath(const std::string& filename) +{ + //any symbol - "/" or "\" + + int i = filename.find_last_of("/\\"); + + if (i==filename.npos) + { + return ""; + } + + std::string r = filename.substr(0, i+1); + + return r; +} + + +bool IsFileExistsInUserData(const std::string& filename) +{ + + std::string realFileName = GetFilePathUserData(filename); + + FILE* f; + + f = fopen(realFileName.c_str(), "r"); + + if (f == NULL) + { + return false; + } + + fclose(f); + + return true; +} + + + +std::string GetFilePathUserData(const std::string& filename) +{ +#ifdef TARGET_WIN32 + std::string realFileName = filename; +#endif +#ifdef TARGET_ANDROID + std::string realFileName = JniGetApplicationDir()+"/" + filename; +#endif +#ifdef TARGET_IOS + std::string realFileName = IosGetFilePathUserData(filename); +#endif + + return realFileName; +} + +#ifdef TARGET_IOS +//Special for IOS -> Foundation.h conflicts with sq_plus.h +std::string GetPathToResources() +{ + return ResourceManager->PathToResources; +} +#endif + + + +} //namespace SE diff --git a/src/Utils/IosApi/IosApi.mm b/src/Utils/IosApi/IosApi.mm new file mode 100644 index 0000000..d6f96c1 --- /dev/null +++ b/src/Utils/IosApi/IosApi.mm @@ -0,0 +1,51 @@ +// +// Halibut_Engine.m +// Halibut Engine +// +// Created by vvv ооо on 13.07.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import + +#include "include/Utils/Utils.h" + + +namespace SE +{ + +std::string IosGetFileReadPath(const std::string& filename) +{ + + NSString* nsFullFileName = [NSString stringWithCString:filename.c_str() encoding:NSUTF8StringEncoding]; + + NSString* nsFileShortName = [nsFullFileName lastPathComponent]; + + NSString* nsFileShortNameWithoutExt = [nsFileShortName stringByDeletingPathExtension]; + + NSString* nsFileExt = [nsFullFileName pathExtension]; + + NSString* nsFilePath = [nsFullFileName stringByDeletingLastPathComponent]; + + NSString *filePath = [[NSBundle mainBundle] pathForResource:nsFileShortNameWithoutExt ofType:nsFileExt inDirectory:nsFilePath]; + + return std::string([filePath UTF8String]); +} + + +std::string IosGetFilePathUserData(const std::string& filename) +{ + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, + NSUserDomainMask, YES); + + + NSString* docDir = [paths objectAtIndex:0]; + docDir = [docDir stringByAppendingString:@"/"]; + + NSString* file = [docDir stringByAppendingString:[NSString stringWithCString:filename.c_str() encoding:NSUTF8StringEncoding]]; + + return std::string([[NSFileManager defaultManager] fileSystemRepresentationWithPath:file]); +} + +} //namespace SE + diff --git a/src/Utils/JniApi/JniApi.cpp b/src/Utils/JniApi/JniApi.cpp new file mode 100644 index 0000000..a6fb4aa --- /dev/null +++ b/src/Utils/JniApi/JniApi.cpp @@ -0,0 +1,389 @@ +#include "include/Utils/JniApi/JniApi.h" + +#include "include/Utils/Utils.h" + +namespace SE +{ + +JavaVM* JavaVirtualMachine = 0; + +const std::string CONST_JAVA_FILESYSTEM_CLASS_NAME = "fishrungames/engine/FileWrapper"; + +//Private data + +//All 3 deprecated +cardinal* FileArr = NULL; +int FileSize = 0; +int filePointer; + +std::string ApkFilePath; + +//Private methods +jclass JniTryFindClass(const std::string& className); +jmethodID JniTryFindStaticMethod(jclass clazz, const std::string& methodId, const std::string methodSignature); +void CheckCommonExceptionWithMessage(const std::string& message); + +//Deprecated +void JniCallOpenFile(const std::string& fileName); + + +//================================================== +//=============== IMPLEMENTATION =================== +//================================================== + + +JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_SetupEnviroment(JNIEnv* env, jobject thiz) +{ + int JVMResult; + JVMResult = env->GetJavaVM(&JavaVirtualMachine); + + //TODO: Check if jmvresult != 0 +} + +JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_SetupApkFilePath(JNIEnv* env, jobject thiz, jstring s) +{ + + const char *nativeString = env->GetStringUTFChars(s, 0); + + ApkFilePath = std::string(nativeString); + + env->ReleaseStringUTFChars(s, nativeString); + +} + +JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_ConsoleOut(JNIEnv* env, jobject thiz, jstring s) +{ + const char *nativeString = env->GetStringUTFChars(s, 0); + + *Console<ReleaseStringUTFChars(s, nativeString); + +} + + +//Deprecated +JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_CreateFile(JNIEnv* env, jobject thiz, int fileSize) +{ + FileSize = fileSize; + FileArr = new cardinal [fileSize % 4 == 0 ? fileSize/4 : fileSize/4 + 1]; + filePointer = 0; +} + + +//Deprecated +JNIEXPORT void JNICALL Java_fishrungames_engine_FileWrapper_WriteToFile(JNIEnv* env, jobject thiz, jbyteArray buffer, int bufferSize) +{ + JNIEnv* jenv; + JavaVirtualMachine->GetEnv((void**)&jenv, JNI_VERSION_1_4); + jenv->GetByteArrayRegion(buffer, 0, bufferSize, (jbyte*)((char*)FileArr + filePointer)); + filePointer += bufferSize; + +} + +//=================================================== +//============== Private methods ==================== +//=================================================== + +jclass JniTryFindClass(const std::string& className) +{ + + JNIEnv* jenv; + JavaVirtualMachine->GetEnv((void**)&jenv, JNI_VERSION_1_4); + + jclass clazz = jenv->FindClass(className.c_str()); + + + if (jenv->ExceptionOccurred() != 0) + { + jenv->ExceptionClear(); + throw ErrorToLog("JNI: failed to find class: "+className); + } + + return clazz; +} + +jmethodID JniTryFindStaticMethod(jclass clazz, const std::string& methodId, const std::string methodSignature) +{ + JNIEnv* jenv; + JavaVirtualMachine->GetEnv((void**)&jenv, JNI_VERSION_1_4); + + jmethodID mid = jenv->GetStaticMethodID(clazz, methodId.c_str(), methodSignature.c_str()); + + if (jenv->ExceptionOccurred() != 0) + { + jenv->ExceptionClear(); + throw ErrorToLog("JNI: failed to find static method: "+methodId+" with signature: "+methodSignature); + } + + return mid; +} + +void CheckCommonExceptionWithMessage(const std::string& message) +{ + JNIEnv* jenv; + JavaVirtualMachine->GetEnv((void**)&jenv, JNI_VERSION_1_4); + + if (jenv->ExceptionOccurred() != 0) + { + jenv->ExceptionClear(); + throw ErrorToLog(message); + } +} + + +//Deprecated +void JniCallOpenFile(const std::string& fileName) +{ + JNIEnv* jenv; + JavaVirtualMachine->GetEnv((void**)&jenv, JNI_VERSION_1_4); + + jclass clazz = JniTryFindClass(CONST_JAVA_FILESYSTEM_CLASS_NAME); + + jmethodID mid = JniTryFindStaticMethod(clazz, "OpenFile", "(Ljava/lang/String;)I"); + + jstring jstr = jenv->NewStringUTF(fileName.c_str()); + + + CheckCommonExceptionWithMessage("Fail in JniCallOpenFile\n"); + + //Any problem? - see console log + if (jenv->CallStaticIntMethod(clazz, mid, jstr) != 1) + throw ErrorToLog("ERROR: Could not open file: " + fileName); +} + + +std::string JniGetApplicationDir() +{ + JNIEnv* jenv; + JavaVirtualMachine->GetEnv((void**)&jenv, JNI_VERSION_1_4); + + jclass clazz = JniTryFindClass(CONST_JAVA_FILESYSTEM_CLASS_NAME); + + jmethodID mid = JniTryFindStaticMethod(clazz, "GetApplicationDir", "()Ljava/lang/String;"); + + jstring jstr = (jstring)jenv->CallStaticObjectMethod(clazz, mid); + + const char *nativeString = jenv->GetStringUTFChars(jstr, 0); + + std::string s(nativeString); + + jenv->ReleaseStringUTFChars(jstr, nativeString); + + return s; + +} + + +void JniLoadSound(const std::string& fileName) +{ + + JNIEnv* jenv; + JavaVirtualMachine->GetEnv((void**)&jenv, JNI_VERSION_1_4); + + jclass clazz = JniTryFindClass(CONST_JAVA_FILESYSTEM_CLASS_NAME); + + jmethodID mid = JniTryFindStaticMethod(clazz, "LoadSound", "(Ljava/lang/String;)V"); + + jstring jstr = jenv->NewStringUTF(fileName.c_str()); + + CheckCommonExceptionWithMessage("Fail in JniLoadSound"); + + //Any problem? - see console log + jenv->CallStaticVoidMethod(clazz, mid, jstr); + +} + +void JniPlaySound(const std::string& soundName) +{ + + JNIEnv* jenv; + JavaVirtualMachine->GetEnv((void**)&jenv, JNI_VERSION_1_4); + + jclass clazz = JniTryFindClass(CONST_JAVA_FILESYSTEM_CLASS_NAME); + + jmethodID mid = JniTryFindStaticMethod(clazz, "PlaySound", "(Ljava/lang/String;)V"); + + jstring jstr = jenv->NewStringUTF(soundName.c_str()); + + CheckCommonExceptionWithMessage("Fail in JniPlaySound"); + + //Any problem? - see console log + jenv->CallStaticVoidMethod(clazz, mid, jstr); +} + +void JniPlayMusic(const std::string& fileName) +{ + *Console<<"In play music\n"; + JNIEnv* jenv; + JavaVirtualMachine->GetEnv((void**)&jenv, JNI_VERSION_1_4); + + jclass clazz = JniTryFindClass(CONST_JAVA_FILESYSTEM_CLASS_NAME); + + jmethodID mid = JniTryFindStaticMethod(clazz, "PlayMusic", "(Ljava/lang/String;)V"); + + jstring jstr = jenv->NewStringUTF(fileName.c_str()); + + CheckCommonExceptionWithMessage("Fail in JniPlayMusic"); + + //Any problem? - see console log + jenv->CallStaticVoidMethod(clazz, mid, jstr); +} + + +void JniPlayMusicLooped(const std::string& fileName) +{ + JNIEnv* jenv; + JavaVirtualMachine->GetEnv((void**)&jenv, JNI_VERSION_1_4); + + jclass clazz = JniTryFindClass(CONST_JAVA_FILESYSTEM_CLASS_NAME); + + jmethodID mid = JniTryFindStaticMethod(clazz, "PlayMusicLooped", "(Ljava/lang/String;)V"); + + jstring jstr = jenv->NewStringUTF(fileName.c_str()); + + CheckCommonExceptionWithMessage("Fail in JniPlayMusicLooped"); + + //Any problem? - see console log + jenv->CallStaticVoidMethod(clazz, mid, jstr); +} + + +void JniStopMusic() +{ + JNIEnv* jenv; + + JavaVirtualMachine->GetEnv((void**)&jenv, JNI_VERSION_1_4); + + jclass clazz = JniTryFindClass(CONST_JAVA_FILESYSTEM_CLASS_NAME); + + jmethodID mid = JniTryFindStaticMethod(clazz, "StopMusic", "()V"); + + CheckCommonExceptionWithMessage("Fail in JniPlayMusicLooped"); + + //Any problem? - see console log + jenv->CallStaticVoidMethod(clazz, mid); +} + +void JniReleaseAllSoundsAndMusic() +{ + JNIEnv* jenv; + JavaVirtualMachine->GetEnv((void**)&jenv, JNI_VERSION_1_4); + + jclass clazz = JniTryFindClass(CONST_JAVA_FILESYSTEM_CLASS_NAME); + + jmethodID mid = JniTryFindStaticMethod(clazz, "ReleaseAllSoundsAndMusic", "()V"); + + CheckCommonExceptionWithMessage("Fail in JniReleaseAllSoundsAndMusic"); + + //Any problem? - see console log + jenv->CallStaticVoidMethod(clazz, mid); +} + +void JniPauseAllSoundsAndMusic() +{ + JNIEnv* jenv; + + JavaVirtualMachine->GetEnv((void**)&jenv, JNI_VERSION_1_4); + + jclass clazz = JniTryFindClass(CONST_JAVA_FILESYSTEM_CLASS_NAME); + + jmethodID mid = JniTryFindStaticMethod(clazz, "PauseAllSoundsAndMusic", "()V"); + + CheckCommonExceptionWithMessage("Fail in JniPauseAllSoundsAndMusic"); + + //Any problem? - see console log + jenv->CallStaticVoidMethod(clazz, mid); +} + +void JniResumeAllSoundsAndMusic() +{ + JNIEnv* jenv; + + JavaVirtualMachine->GetEnv((void**)&jenv, JNI_VERSION_1_4); + + jclass clazz = JniTryFindClass(CONST_JAVA_FILESYSTEM_CLASS_NAME); + + jmethodID mid = JniTryFindStaticMethod(clazz, "ResumeAllSoundsAndMusic", "()V"); + + CheckCommonExceptionWithMessage("Fail in JniResumeAllSoundsAndMusic"); + + //Any problem? - see console log + jenv->CallStaticVoidMethod(clazz, mid); +} + + + +void PrintApkContent() +{ + zip* APKArchive = zip_open(ApkFilePath.c_str(), 0, NULL); + if (APKArchive == NULL) + { + throw ErrorToLog("Error in loadAPK"); + } + + //Just for debug, print APK contents + int numFiles = zip_get_num_files(APKArchive); + + for (int i=0; i& returnData) +{ + + //PrintApkContent(); + + if (ApkFilePath == "") + { + throw ErrorToLog("Apk file path is not set!"); + } + + //*Console<<"ApkFilePath = "+ApkFilePath+"\n"; + + zip* APKArchive = zip_open(ApkFilePath.c_str(), 0, NULL); + + if (APKArchive == NULL) + { + throw ErrorToLog("Error in loadAPK, apk archive is not valid"); + } + + zip_file *zfile = zip_fopen(APKArchive, ("assets/" + fileName).c_str(), 0); + + char buf[4096]; + + if (zfile != NULL) + { + size_t bytesRead; + do + { + bytesRead = zip_fread(zfile, &buf[0], 4096); + returnData.insert(returnData.end(), buf, buf + bytesRead); + } + while (bytesRead == 4096); + zip_fclose(zfile); + } + else + { + throw ErrorToLog("Error in loadAPK, data in apk archive is broken: "+fileName); + } + + zip_close(APKArchive); + +} + + +} //namespace SE \ No newline at end of file diff --git a/src/Utils/PngHelper.cpp b/src/Utils/PngHelper.cpp new file mode 100644 index 0000000..5e3635f --- /dev/null +++ b/src/Utils/PngHelper.cpp @@ -0,0 +1,133 @@ +#include "include/Utils/PngHelper.h" +#include "include/Utils/Utils.h" + +namespace SE +{ + +#ifdef TARGET_ANDROID +typedef PNG_CONST png_byte FAR * png_const_bytep; +#endif + +struct TPngReadStruct +{ + const boost::shared_array& FileArr; + cardinal FileSize; + int CurrentPointer; + TPngReadStruct(const boost::shared_array& fileArr, cardinal fileSize) + : FileArr(fileArr) + , FileSize(fileSize) + , CurrentPointer(8) + { + } + +}; + + +void user_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + + + png_voidp a = png_get_io_ptr(png_ptr); + + TPngReadStruct* pngReadStruct = reinterpret_cast(a); + + + if (pngReadStruct->CurrentPointer + length >= pngReadStruct->FileSize) + { + throw ErrorToLog("PNG pointer gone too far!"); + } + + for (cardinal i = 0; i < length; i++) + { + data[i] = pngReadStruct->FileArr[pngReadStruct->CurrentPointer + i]; + } + + pngReadStruct->CurrentPointer += length; + +} + + +TPngDataStruct read_png_file(const boost::shared_array& fileArr, cardinal fileSize) +{ + + TPngDataStruct result; + + TPngReadStruct readStruct(fileArr, fileSize); + + + char header[8]; // 8 is the maximum size that can be checked + + for (cardinal i=0; i<8; i++) + { + header[i] = fileArr[i]; + } + + + if (png_sig_cmp(reinterpret_cast(header), 0, 8)) + { + throw ErrorToLog("Incorrect PNG file (1)!"); + } + + /* initialize stuff */ + result.PngPtr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + + if (!result.PngPtr) + { + throw ErrorToLog("Incorrect PNG file (2)!"); + } + + result.InfoPtr = png_create_info_struct(result.PngPtr); + + if (!result.InfoPtr) + { + throw ErrorToLog("Incorrect PNG file (3)!"); + } + + if (setjmp(png_jmpbuf(result.PngPtr))) + { + throw ErrorToLog("Incorrect PNG file (4)!"); + } + + png_set_read_fn(result.PngPtr, (png_voidp)&readStruct, user_read_data); + + png_set_sig_bytes(result.PngPtr, 8); + + png_read_info(result.PngPtr, result.InfoPtr); + + result.Width = png_get_image_width(result.PngPtr, result.InfoPtr); + result.Height = png_get_image_height(result.PngPtr, result.InfoPtr); + result.ColorType = png_get_color_type(result.PngPtr, result.InfoPtr); + result.BitDepth = png_get_bit_depth(result.PngPtr, result.InfoPtr); + + if (result.BitDepth != 8) + { + throw ErrorToLog("Incorrect bit depth in png file!"); + } + + if (result.ColorType != PNG_COLOR_TYPE_RGB && result.ColorType != PNG_COLOR_TYPE_RGBA) + { + throw ErrorToLog("Incorrect color type in png file!"); + } + + result.NumberOfPasses = png_set_interlace_handling(result.PngPtr); + png_read_update_info(result.PngPtr, result.InfoPtr); + + + if (setjmp(png_jmpbuf(result.PngPtr))) + { + throw ErrorToLog("Incorrect PNG file (5)!"); + } + + + result.RowPointers = (png_bytep*) malloc(sizeof(png_bytep) * result.Height); + for (int y=0; y + + +namespace SE +{ + +void ReplaceText(boost::property_tree::ptree& propertyTree, std::map& replaceMap) +{ + for (boost::property_tree::ptree::iterator i = propertyTree.begin(); i != propertyTree.end(); ) + { + BOOST_FOREACH(auto& itr, replaceMap) + { + std::string param = i->second.get(""); + if (param != "") + { + boost::algorithm::replace_all(param, itr.first, itr.second); + i->second.put("", param); + } + } + + + if (i != propertyTree.end()) + { + i++; + } + } +} + +boost::property_tree::ptree::iterator ReplaceIncludeFile(boost::property_tree::ptree& propertyTree, boost::property_tree::ptree::iterator propertyTreeItr, std::map replaceMap) +{ + boost::shared_array xmlFileArr; + cardinal xmlFileSize; + + std::string fileName = propertyTreeItr->second.get(".file"); + + for (boost::property_tree::ptree::iterator i = propertyTreeItr->second.begin(); i != propertyTreeItr->second.end(); ++i) + { + if (i->first == "Param") + { + std::string paramName = i->second.get(".name"); + std::string paramValue = i->second.get(".value"); + + //If value already consist template that can be expanded: + while (replaceMap.count(paramValue) != 0) + { + paramValue = replaceMap[paramValue]; + } + + replaceMap[paramName] = paramValue; + } + } + + xmlFileArr = CreateMemFromFile(ResourceManager->PathToResources + fileName, xmlFileSize); + + std::string xmlString = std::string(&xmlFileArr[0], &xmlFileArr[xmlFileSize]); + + std::shared_ptr includeFileTree = StringToPropertyTree(xmlString, replaceMap); + + boost::property_tree::ptree::iterator newItr = propertyTree.erase(propertyTreeItr); + + propertyTree.insert(newItr, includeFileTree->begin(), includeFileTree->end()); + + if (newItr == propertyTree.begin()) + { + throw ErrorToLog("Property tree logic error - don't know how to handle :("); + } + + newItr--; + + return newItr; +} + +void GetReplaceMapRecoursively(boost::property_tree::ptree& propertyTree, std::map replaceMap) +{ + ReplaceText(propertyTree, replaceMap); + + for (boost::property_tree::ptree::iterator i = propertyTree.begin(); i != propertyTree.end(); ) + { + std::map localMap = replaceMap; + + if (i->first == "Include") + { + i = ReplaceIncludeFile(propertyTree, i, localMap); + } + else + { + GetReplaceMapRecoursively(i->second, localMap); + } + + BOOST_FOREACH(auto& itr, localMap) + { + if (localMap.count(itr.second) != 0) + { + localMap[itr.first] = localMap[itr.second]; + } + } + + if (i != propertyTree.end()) + { + i++; + } + } + + +} + + +std::shared_ptr StringToPropertyTree(std::string xmlCode, std::map replaceMap) +{ + std::shared_ptr propertyTree(new boost::property_tree::ptree); + + std::stringstream stream(xmlCode); + + try + { + boost::property_tree::read_xml(stream, *propertyTree); + + //Parsing tag + GetReplaceMapRecoursively(*propertyTree, replaceMap); + + + } + catch(boost::property_tree::xml_parser_error) + { + throw ErrorToLog("ERROR: xml parse error"); + } + + return propertyTree; + +} + +std::shared_ptr FileToPropertyTree(boost::shared_array xmlFileArr, cardinal xmlFileSize, std::map replaceMap) +{ + std::string xmlCode = std::string(&xmlFileArr[0], &xmlFileArr[xmlFileSize]); + + return StringToPropertyTree(xmlCode, replaceMap); +} + +std::shared_ptr FileToPropertyTree(const std::string& fileName, std::map replaceMap) +{ + cardinal byteCount; + + boost::shared_array file = CreateMemFromFile(ResourceManager->PathToResources + fileName, byteCount); + + return FileToPropertyTree(file, byteCount, replaceMap); +} + + + +} //namespace SE diff --git a/src/Utils/SimpleTimer.cpp b/src/Utils/SimpleTimer.cpp new file mode 100644 index 0000000..99e11ce --- /dev/null +++ b/src/Utils/SimpleTimer.cpp @@ -0,0 +1,37 @@ +#include "include/Utils/SimpleTimer.h" + + +namespace SE +{ + +TSimpleTimer::TSimpleTimer() + : Timer(0) +{ +} + + +void TSimpleTimer::SetTimer(int timer) +{ + Timer = timer; +} + +void TSimpleTimer::Update(cardinal dt) +{ + if (Timer > 0) + { + Timer = max(Timer - static_cast(dt), 0); + } +} + +bool TSimpleTimer::IsOver() +{ + return Timer == 0; +} + +boost::posix_time::time_duration TSimpleTimer::GetPosixTime() +{ + return boost::posix_time::seconds(Timer / 1000); +} + + +} //namespace SE \ No newline at end of file diff --git a/src/Utils/WinApi/WinApi.cpp b/src/Utils/WinApi/WinApi.cpp new file mode 100644 index 0000000..1fd6029 --- /dev/null +++ b/src/Utils/WinApi/WinApi.cpp @@ -0,0 +1,36 @@ +#include "include/Engine.h" + +namespace SE +{ + +/* +Here goes all functions that are platform-specific +When I make iOS/Mac/Linux port, I will make same API pair h/cpp + */ + +void GetWindowWidthHeight(int& width, int& height) +{ + RECT rc; + GetClientRect(Hwnd, &rc); + + width = rc.right; + height = rc.bottom; +} + +int GetWindowWidth() +{ + RECT rc; + GetClientRect(Hwnd, &rc); + + return rc.right; +} + +int GetWindowHeight() +{ + RECT rc; + GetClientRect(Hwnd, &rc); + + return rc.bottom; +} + +} //namespace SE \ No newline at end of file