Selaa lähdekoodia

Merge branch 'master' of https://github.com/taylor001/crown

Daniele Bartolini 12 vuotta sitten
vanhempi
sitoutus
669ab50852

+ 21 - 5
BUILD.txt

@@ -40,23 +40,39 @@ engine on the currently supported platforms.
 
 		1. $ mkdir build
 		2. $ cd build
-		3. $ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/your/install/dir -DCROWN_ARCH=<arch>
-		   (read below for valid architecture strings)
+		3. $ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/your/install/dir -DCROWN_BUILD=<build>
+		   (read below for valid build strings)
 		4. $ make
 		5. $ make install
 
-		'CROWN_ARCH' valid values right now are:
+		'CROWN_BUILD' valid values right now are:
+
+ 			* linux-debug-32
+ 			* linux-development-32
+ 			* linux-release-32
+ 			* linux-debug-64
+ 			* linux-development-64
+ 			* linux-release-64
 
-	 		* Linux: "x86" or "x86_64"
 
 	- Windows
 
 		1. Create a folder named 'build'
 		2. Open a terminal and:
 		3. cd build
-		4. cmake.exe .. -DCMAKE_INSTALL_PREFIX=C:/your/install/dir -DCROWN_ARCH=win64
+		4. cmake.exe .. -DCMAKE_INSTALL_PREFIX=C:/your/install/dir -DCROWN_BUILD=<build>
 		5. Open the generated Visual Studio solution and build/install from there
 
+		'CROWN_BUILD' valid values right now are:
+
+ 			* windows-debug-32
+ 			* windows-development-32
+ 			* windows-release-32
+ 			* windows-debug-64
+ 			* windows-development-64
+ 			* windows-release-64
+
+
 	- Android
 
 		1. $ cd utils

+ 4 - 3
engine/CMakeLists.txt

@@ -58,7 +58,8 @@ set (CROWN_INCLUDES
 	${CMAKE_SOURCE_DIR}/engine/lua
 	${CMAKE_SOURCE_DIR}/engine/compilers
 	${CMAKE_SOURCE_DIR}/engine/compilers/lua
-	${CMAKE_SOURCE_DIR}/engine/compilers/tga
+	${CMAKE_SOURCE_DIR}/engine/compilers/texture
+	${CMAKE_SOURCE_DIR}/engine/compilers/mesh
 )
 
 set (SRC
@@ -334,14 +335,14 @@ set (COMPILER_SRC
 	compilers/Compiler.cpp
 	compilers/BundleCompiler.cpp
 	compilers/lua/LuaCompiler.cpp
-	compilers/tga/TGACompiler.cpp
+	compilers/texture/TextureCompiler.cpp
 )
 
 set (COMPILER_HEADER
 	compilers/Compiler.h
 	compilers/BundleCompiler.h
 	compilers/lua/LuaCompiler.h
-	compilers/tga/TGACompiler.h
+	compilers/texture/TextureCompiler.h
 )
 
 set (CROWN_LIBRARIES)

+ 1 - 1
engine/compilers/BundleCompiler.cpp

@@ -75,7 +75,7 @@ bool BundleCompiler::compile(const char* bundle_dir, const char* source_dir)
 		bool result = false;
 		if (resource_type_hash == TEXTURE_TYPE)
 		{
-			result = m_tga.compile(source_dir, bundle_dir, filename, out_name);
+			result = m_texture.compile(source_dir, bundle_dir, filename, out_name);
 		}
 		else if (resource_type_hash == LUA_TYPE)
 		{

+ 3 - 3
engine/compilers/BundleCompiler.h

@@ -26,7 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include "TGACompiler.h"
+#include "TextureCompiler.h"
 #include "LuaCompiler.h"
 #include "DynamicString.h"
 #include "Vector.h"
@@ -49,8 +49,8 @@ private:
 
 private:
 
-	TGACompiler	m_tga;
-	LuaCompiler m_lua;
+	TextureCompiler	m_texture;
+	LuaCompiler 	m_lua;
 };
 
 } // namespace crown

+ 8 - 8
engine/compilers/tga/TGACompiler.cpp → engine/compilers/texture/TextureCompiler.cpp

@@ -24,7 +24,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "TGACompiler.h"
+#include "TextureCompiler.h"
 #include "PixelFormat.h"
 #include "Allocator.h"
 #include "Filesystem.h"
@@ -33,19 +33,19 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-TGACompiler::TGACompiler() :
+TextureCompiler::TextureCompiler() :
 	m_texture_data_size(0),
 	m_texture_data(NULL)
 {
 }
 
 //-----------------------------------------------------------------------------
-TGACompiler::~TGACompiler()
+TextureCompiler::~TextureCompiler()
 {
 }
 
 //-----------------------------------------------------------------------------
-size_t TGACompiler::compile_impl(Filesystem& fs, const char* resource_path)
+size_t TextureCompiler::compile_impl(Filesystem& fs, const char* resource_path)
 {
 	File* in_file = fs.open(resource_path, FOM_READ);
 
@@ -133,7 +133,7 @@ size_t TGACompiler::compile_impl(Filesystem& fs, const char* resource_path)
 }
 
 //-----------------------------------------------------------------------------
-void TGACompiler::write_impl(File* out_file)
+void TextureCompiler::write_impl(File* out_file)
 {
 	out_file->write((char*)&m_texture_header, sizeof(TextureHeader));
 	out_file->write((char*)m_texture_data, m_texture_data_size);
@@ -147,7 +147,7 @@ void TGACompiler::write_impl(File* out_file)
 }
 
 //-----------------------------------------------------------------------------
-void TGACompiler::load_uncompressed(File* in_file)
+void TextureCompiler::load_uncompressed(File* in_file)
 {
 	uint64_t size = m_tga_header.width * m_tga_header.height;
 
@@ -177,7 +177,7 @@ void TGACompiler::load_uncompressed(File* in_file)
 }
 
 //-----------------------------------------------------------------------------
-void TGACompiler::load_compressed(File* in_file)
+void TextureCompiler::load_compressed(File* in_file)
 {
 	uint8_t rle_id = 0;
 	uint32_t i = 0;
@@ -240,7 +240,7 @@ void TGACompiler::load_compressed(File* in_file)
 }
 
 //-----------------------------------------------------------------------------
-void TGACompiler::swap_red_blue()
+void TextureCompiler::swap_red_blue()
 {
 	for (uint64_t i = 0; i < m_tga_size * m_tga_channels; i += m_tga_channels)
 	{

+ 3 - 3
engine/compilers/tga/TGACompiler.h → engine/compilers/texture/TextureCompiler.h

@@ -47,12 +47,12 @@ struct TGAHeader
 	char		image_descriptor;	// 11h  Image descriptor byte
 };
 
-class TGACompiler : public Compiler
+class TextureCompiler : public Compiler
 {
 public:
 
-					TGACompiler();
-					~TGACompiler();
+					TextureCompiler();
+					~TextureCompiler();
 
 	size_t			compile_impl(Filesystem& fs, const char* resource_path);
 	void			write_impl(File* out_file);

+ 8 - 8
engine/resource/Resource.h

@@ -34,19 +34,19 @@ namespace crown
 {
 
 /// Hashed values for supported resource types
-const char* const TEXTURE_EXTENSION			= "tga";
-const char* const MESH_EXTENSION			= "dae";
+const char* const TEXTURE_EXTENSION			= "texture";
+const char* const MESH_EXTENSION			= "mesh";
 const char* const LUA_EXTENSION				= "lua";
-const char* const TEXT_EXTENSION			= "txt";
+const char* const TEXT_EXTENSION			= "text";
 const char* const MATERIAL_EXTENSION		= "material";
-const char* const SOUND_EXTENSION			= "wav";
+const char* const SOUND_EXTENSION			= "sound";
 
-const uint32_t TEXTURE_TYPE					= 0x1410A16A;
-const uint32_t MESH_TYPE					= 0xE8239EEC;
+const uint32_t TEXTURE_TYPE					= 0xDEED4F7;
+const uint32_t MESH_TYPE					= 0xA6E48B29;
 const uint32_t LUA_TYPE						= 0xD96E7C37;
-const uint32_t TEXT_TYPE					= 0x9000BF0B;
+const uint32_t TEXT_TYPE					= 0x45CC650;
 const uint32_t MATERIAL_TYPE				= 0x46807A92;
-const uint32_t SOUND_TYPE					= 0x8E128AA1;
+const uint32_t SOUND_TYPE					= 0xD196AB6E;
 
 /// ResourceId uniquely identifies a resource by its name and type.
 /// In order to speed up the lookup by the manager, it also keeps

+ 23 - 3
utils/crown-android.rb

@@ -1,4 +1,26 @@
-#!/usr/bin/ruby
+# Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+# Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+# 
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation
+# files (the "Software"), to deal in the Software without
+# restriction, including without limitation the rights to use,
+# copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following
+# conditions:
+# 
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
 
 require 'optparse'
 require 'ostruct'
@@ -139,10 +161,8 @@ end
 def build_android_project(path)
 	# Move to root directory of Android project
 	Dir.chdir(path)
-
 	# Build libraries
 	system("ndk-build")
-
 	# Build apk
 	system("ant debug")
 end

+ 80 - 0
utils/murmur2-32-hash.rb

@@ -0,0 +1,80 @@
+# Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+# Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+# 
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation
+# files (the "Software"), to deal in the Software without
+# restriction, including without limitation the rights to use,
+# copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following
+# conditions:
+# 
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+
+# MurmurHash2, by Austin Appleby
+def murmur2_32(string, seed)
+
+    m = 0x5bd1e995
+    r = 24
+    len = string.length
+
+    h = seed ^ len
+
+    data = string.bytes.to_a
+
+    while len >= 4
+      	k = data[0]
+      	k |= data[1] << 8
+      	k |= data[2] << 16
+      	k |= data[3] << 24
+
+      	k = ( k * m ) % 0x100000000
+      	k ^= k >> r
+      	k = ( k * m ) % 0x100000000
+
+      	h = ( h * m ) % 0x100000000
+      	h ^= k
+
+      	len -= 4
+    end
+
+    if len == 3 then
+      h ^= data[-1] << 16
+      h ^= data[-2] << 8
+      h ^= data[-3]
+    end
+    if len == 2 then
+      h ^= data[-1] << 8
+      h ^= data[-2]
+    end
+    if len == 1 then
+      h ^= data[-1]
+    end
+
+    h = ( h * m ) % 0x100000000
+    h ^= h >> 13
+    h = ( h * m ) % 0x100000000
+    h ^= h >> 15
+
+    return h
+end
+
+if ARGV.length != 2
+	print "Usage: ruby murmur2-hash.rb <string> <seed>\n"
+	exit
+end
+
+result = murmur2_32(ARGV[0], ARGV[1].to_i)
+
+print result.to_s(16) + "\n";