Compare commits
21 Commits
ios-suppor
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8e7c0f80f | ||
|
|
9ba3fabfb6 | ||
|
|
1effcd1e6d | ||
| bc82f5c091 | |||
| 8d7a1973e7 | |||
| 3a0f4c3647 | |||
|
|
d6a3e477c1 | ||
|
|
4d68c4dff8 | ||
|
|
e1c2210621 | ||
|
|
c188fa0ce2 | ||
|
|
9db9f469cc | ||
|
|
db7a889962 | ||
|
|
95a193323c | ||
|
|
f19c2d24a3 | ||
|
|
e1b81a7cc3 | ||
|
|
baeefae94d | ||
|
|
aa9fa659df | ||
| 6049239303 | |||
|
|
55d06f0590 | ||
|
|
58b7724ba2 | ||
| 6ae787b90d |
31
.github/workflows/build.yml
vendored
31
.github/workflows/build.yml
vendored
@@ -216,16 +216,6 @@ jobs:
|
||||
distribution: temurin
|
||||
java-version: 25
|
||||
|
||||
- name: Validate environment
|
||||
run: |
|
||||
echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT"
|
||||
echo "ANDROID_NDK_PATH=$ANDROID_NDK_PATH"
|
||||
echo "JAVA_HOME=$JAVA_HOME"
|
||||
echo "MATRIX_ABI=$MATRIX_ABI"
|
||||
$ANDROID_SDK_ROOT/platform-tools/adb version || true
|
||||
java -version
|
||||
javac -version
|
||||
|
||||
- name: Run Android build script
|
||||
run: |
|
||||
chmod +x ./build.sh
|
||||
@@ -322,17 +312,10 @@ jobs:
|
||||
files: mcpe-linux/MinecraftPE-server
|
||||
dest: minecraftpe-server-${{ steps.ref.outputs.hash }}.zip
|
||||
|
||||
- name: Zip Android arm64-v8a Artifact
|
||||
uses: vimtor/action-zip@v1.2
|
||||
with:
|
||||
files: minecraftpe-apk-arm64-v8a/minecraftpe-v8a-debug.apk
|
||||
dest: minecraftpe-${{ steps.ref.outputs.hash }}-android-arm64-v8a.zip
|
||||
|
||||
- name: Zip Android armeabi-v7a Artifact
|
||||
uses: vimtor/action-zip@v1.2
|
||||
with:
|
||||
files: minecraftpe-apk-armeabi-v7a/minecraftpe-v7a-debug.apk
|
||||
dest: minecraftpe-${{ steps.ref.outputs.hash }}-android-armeabi-v7a.zip
|
||||
- name: Rename Android Artifacts
|
||||
run: |
|
||||
mv minecraftpe-apk-arm64-v8a/minecraftpe-v8a-debug.apk minecraftpe-${{ steps.ref.outputs.hash }}-android-arm64-v8a.apk
|
||||
mv minecraftpe-apk-armeabi-v7a/minecraftpe-v7a-debug.apk minecraftpe-${{ steps.ref.outputs.hash }}-android-armeabi-v7a.apk
|
||||
|
||||
- name: Zip Web Artifact
|
||||
uses: vimtor/action-zip@v1.2
|
||||
@@ -358,9 +341,9 @@ jobs:
|
||||
MinecraftPE development release for commit ${{ github.sha }}.
|
||||
files: |
|
||||
./data.zip
|
||||
./minecraftpe-server-${{ steps.ref.outputs.hash }}.zip
|
||||
./minecraftpe-${{ steps.ref.outputs.hash }}-windows.zip
|
||||
./minecraftpe-${{ steps.ref.outputs.hash }}-linux.zip
|
||||
./minecraftpe-server-${{ steps.ref.outputs.hash }}.zip
|
||||
./minecraftpe-${{ steps.ref.outputs.hash }}-android-arm64-v8a.zip
|
||||
./minecraftpe-${{ steps.ref.outputs.hash }}-android-armeabi-v7a.zip
|
||||
./minecraftpe-${{ steps.ref.outputs.hash }}-android-arm64-v8a.apk
|
||||
./minecraftpe-${{ steps.ref.outputs.hash }}-android-armeabi-v7a.apk
|
||||
./minecraftpe-${{ steps.ref.outputs.hash }}-web.zip
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@ out/
|
||||
bin/
|
||||
lib/
|
||||
build-apk/
|
||||
build-haiku/
|
||||
cmake-build-*/
|
||||
CMakeFiles/
|
||||
CMakeCache.txt
|
||||
|
||||
157
CMakeLists.txt
157
CMakeLists.txt
@@ -1,6 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
project(MinecraftPE)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Haiku")
|
||||
set(HAIKU, 1)
|
||||
endif()
|
||||
|
||||
include(cmake/CPM.cmake)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
@@ -26,6 +30,10 @@ if (${PLATFORM} STREQUAL "Desktop")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc")
|
||||
endif()
|
||||
|
||||
if(HAIKU)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc -static")
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++11-narrowing -Wno-narrowing -Wno-invalid-source-encoding -Wno-reserved-user-defined-literal")
|
||||
endif()
|
||||
@@ -34,6 +42,10 @@ if (${PLATFORM} STREQUAL "Desktop")
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
include_directories(misc/windows)
|
||||
set(EXTRA_LIBS ws2_32 winhttp)
|
||||
elseif(HAIKU)
|
||||
find_library(pthread NAMES pthread)
|
||||
find_library(network NAMES network)
|
||||
set(EXTRA_LIBS pthread m network)
|
||||
elseif(UNIX)
|
||||
find_library(pthread NAMES pthread)
|
||||
set(EXTRA_LIBS pthread m)
|
||||
@@ -44,73 +56,88 @@ elseif (${PLATFORM} STREQUAL "Web")
|
||||
set(EXTRA_LIBS "idbfs.js")
|
||||
endif()
|
||||
|
||||
# I totally shocked
|
||||
if(${PLATFORM} MATCHES "Web")
|
||||
set(PNG_LIB png)
|
||||
set(AL_LIBTYPE "STATIC")
|
||||
if(!HAIKU)
|
||||
if(${PLATFORM} MATCHES "Web")
|
||||
set(PNG_LIB png)
|
||||
set(ZLIB_LIB zlib)
|
||||
set(AL_LIBTYPE "STATIC")
|
||||
|
||||
add_library(zlib INTERFACE IMPORTED)
|
||||
set_target_properties(zlib PROPERTIES
|
||||
INTERFACE_LINK_OPTIONS "-sUSE_ZLIB=1"
|
||||
)
|
||||
add_library(zlib INTERFACE IMPORTED)
|
||||
set_target_properties(zlib PROPERTIES
|
||||
INTERFACE_LINK_OPTIONS "-sUSE_ZLIB=1"
|
||||
)
|
||||
|
||||
add_library(png INTERFACE IMPORTED)
|
||||
set_target_properties(png PROPERTIES
|
||||
INTERFACE_COMPILE_OPTIONS "-sUSE_LIBPNG=1"
|
||||
INTERFACE_LINK_OPTIONS "-sUSE_LIBPNG=1"
|
||||
)
|
||||
add_library(png INTERFACE IMPORTED)
|
||||
set_target_properties(png PROPERTIES
|
||||
INTERFACE_COMPILE_OPTIONS "-sUSE_LIBPNG=1"
|
||||
INTERFACE_LINK_OPTIONS "-sUSE_LIBPNG=1"
|
||||
)
|
||||
|
||||
add_library(glfw INTERFACE IMPORTED)
|
||||
set_target_properties(glfw PROPERTIES
|
||||
INTERFACE_LINK_OPTIONS "-sUSE_GLFW=3"
|
||||
add_library(glfw INTERFACE IMPORTED)
|
||||
set_target_properties(glfw PROPERTIES
|
||||
INTERFACE_LINK_OPTIONS "-sUSE_GLFW=3"
|
||||
)
|
||||
|
||||
else()
|
||||
set(PNG_LIB png_shared)
|
||||
set(ZLIB_LIB zlib)
|
||||
set(AL_LIB "OpenAL::OpenAL")
|
||||
set(AL_LIBTYPE "SHARED")
|
||||
|
||||
CPMAddPackage(
|
||||
NAME "zlib"
|
||||
GIT_REPOSITORY "https://github.com/madler/zlib"
|
||||
GIT_TAG "v1.3.2"
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME "libpng"
|
||||
GIT_REPOSITORY "https://github.com/pnggroup/libpng.git"
|
||||
GIT_TAG "v1.6.55"
|
||||
OPTIONS
|
||||
"ZLIB_ROOT ${zlib_SOURCE_DIR}"
|
||||
"ZLIB_INCLUDE_DIRS ${zlib_SOURCE_DIR}"
|
||||
"PNG_TOOLS OFF"
|
||||
"PNG_TESTS OFF"
|
||||
)
|
||||
CPMAddPackage(
|
||||
NAME "glfw"
|
||||
GIT_REPOSITORY "https://github.com/glfw/glfw.git"
|
||||
GIT_TAG "3.4"
|
||||
EXCLUDE_FROM_ALL TRUE
|
||||
OPTIONS
|
||||
"GLFW_BUILD_EXAMPLES OFF"
|
||||
"GLFW_BUILD_TESTS OFF"
|
||||
"GLFW_BUILD_DOCS OFF"
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
CPMAddPackage(
|
||||
NAME "openal"
|
||||
GIT_REPOSITORY "https://github.com/kcat/openal-soft.git"
|
||||
GIT_TAG "1.25.1"
|
||||
OPTIONS
|
||||
"ALSOFT_EXAMPLES OFF"
|
||||
"ALSOFT_TESTS OFF"
|
||||
"ALSOFT_UTILS OFF"
|
||||
"LIBTYPE ${AL_LIBTYPE}"
|
||||
"ALSOFT_ENABLE_MODULES OFF"
|
||||
"ALSOFT_STATIC_STDCXX ON"
|
||||
"ALSOFT_STATIC_LIBGCC ON"
|
||||
)
|
||||
else()
|
||||
set(PNG_LIB png_shared)
|
||||
set(AL_LIBTYPE "SHARED")
|
||||
# alot of these have haikuports specific versions,
|
||||
find_library(glfw NAMES glfw)
|
||||
find_library(openal NAMES openal)
|
||||
find_library(png NAMES png)
|
||||
find_library(zlib NAMES zlib)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME "zlib"
|
||||
GIT_REPOSITORY "https://github.com/madler/zlib"
|
||||
GIT_TAG "v1.3.2"
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME "libpng"
|
||||
GIT_REPOSITORY "https://github.com/pnggroup/libpng.git"
|
||||
GIT_TAG "v1.6.55"
|
||||
OPTIONS
|
||||
"ZLIB_ROOT ${zlib_SOURCE_DIR}"
|
||||
"ZLIB_INCLUDE_DIRS ${zlib_SOURCE_DIR}"
|
||||
"PNG_TOOLS OFF"
|
||||
"PNG_TESTS OFF"
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME "glfw"
|
||||
GIT_REPOSITORY "https://github.com/glfw/glfw.git"
|
||||
GIT_TAG "3.4"
|
||||
EXCLUDE_FROM_ALL TRUE
|
||||
OPTIONS
|
||||
"GLFW_BUILD_EXAMPLES OFF"
|
||||
"GLFW_BUILD_TESTS OFF"
|
||||
"GLFW_BUILD_DOCS OFF"
|
||||
)
|
||||
set(PNG_LIB png)
|
||||
set(ZLIB_LIB z)
|
||||
set(AL_LIB openal)
|
||||
endif()
|
||||
|
||||
CPMAddPackage(
|
||||
NAME "openal"
|
||||
GIT_REPOSITORY "https://github.com/kcat/openal-soft.git"
|
||||
GIT_TAG "1.25.1"
|
||||
OPTIONS
|
||||
"ALSOFT_EXAMPLES OFF"
|
||||
"ALSOFT_TESTS OFF"
|
||||
"ALSOFT_UTILS OFF"
|
||||
"LIBTYPE ${AL_LIBTYPE}"
|
||||
"ALSOFT_ENABLE_MODULES OFF"
|
||||
"ALSOFT_STATIC_STDCXX ON"
|
||||
"ALSOFT_STATIC_LIBGCC ON"
|
||||
)
|
||||
|
||||
# TODO: Clear this paths with *
|
||||
file(GLOB SERVER_SOURCES
|
||||
"project/lib_projects/raknet/jni/RaknetSources/*.cpp"
|
||||
@@ -316,7 +343,8 @@ if(UNIX)
|
||||
"project/lib_projects/raknet/jni/RaknetSources"
|
||||
)
|
||||
|
||||
target_link_libraries("${PROJECT_NAME}-server" ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries("${PROJECT_NAME}-server" ${EXTRA_LIBS})
|
||||
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT_NAME} ${CLIENT_SOURCES})
|
||||
@@ -372,11 +400,16 @@ if(${PLATFORM} MATCHES "Web")
|
||||
endif()
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "__EMSCRIPTEN__" "NO_SOUND" "NO_NETWORK")
|
||||
else()
|
||||
target_compile_options(${PROJECT_NAME} PUBLIC
|
||||
"-O3"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Client
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "OPENGL_ES" "NO_EGL" ${PLATFORM})
|
||||
target_link_libraries(${PROJECT_NAME} zlib ${PNG_LIB} OpenAL::OpenAL glfw ${EXTRA_LIBS})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} ${ZLIB_LIB} ${PNG_LIB} ${AL_LIB} glfw ${EXTRA_LIBS})
|
||||
|
||||
if (OpenSSL_FOUND)
|
||||
target_link_libraries(${PROJECT_NAME} OpenSSL::SSL OpenSSL::Crypto)
|
||||
@@ -407,4 +440,4 @@ else()
|
||||
endif()
|
||||
|
||||
message(STATUS "Compiling with the flags:")
|
||||
message(STATUS " PLATFORM=" ${PLATFORM_CPP})
|
||||
message(STATUS " PLATFORM=" ${PLATFORM_CPP})
|
||||
|
||||
@@ -153,7 +153,20 @@ options.group.tweaks=Tweaks
|
||||
options.allowSprint=Allow sprint
|
||||
options.barOnTop=HUD above inventory
|
||||
options.rpiCursor=Show Raspberry PI cursor
|
||||
options.foliageTint=Tint Grass and Leaves
|
||||
options.foliagetint=Foliage Tinting
|
||||
options.javaHud=Beta Java hotbar tweaks
|
||||
options.blockOutline=Block Outline Selection
|
||||
options.fogType=Fog/Sky Color
|
||||
options.fogType.vanilla=Vanilla
|
||||
options.fogType.java=Beta Java
|
||||
options.fogType.unused=Unused
|
||||
|
||||
options.restoredAnims=Restored Animations
|
||||
|
||||
options.normalLighting=Java Beta/Normals Shading
|
||||
|
||||
options.isJoyTouchArea=Use Split Controls
|
||||
|
||||
options.autoJump=Auto Jump
|
||||
options.thirdperson=Third Person
|
||||
options.servervisible=Server Visible
|
||||
|
||||
@@ -98,6 +98,7 @@ LOCAL_SRC_FILES := ../../../src/main.cpp \
|
||||
../../../src/client/player/RemotePlayer.cpp \
|
||||
../../../src/client/player/input/KeyboardInput.cpp \
|
||||
../../../src/client/player/input/touchscreen/TouchscreenInput.cpp \
|
||||
../../../src/client/renderer/Lighting.cpp \
|
||||
../../../src/client/renderer/Chunk.cpp \
|
||||
../../../src/client/renderer/EntityTileRenderer.cpp \
|
||||
../../../src/client/renderer/GameRenderer.cpp \
|
||||
|
||||
@@ -75,6 +75,7 @@ LOCAL_SRC_FILES := ../../../src/main.cpp \
|
||||
../../../src/client/player/RemotePlayer.cpp \
|
||||
../../../src/client/player/input/KeyboardInput.cpp \
|
||||
../../../src/client/player/input/touchscreen/TouchscreenInput.cpp \
|
||||
../../../src/client/renderer/Lighting.cpp \
|
||||
../../../src/client/renderer/Chunk.cpp \
|
||||
../../../src/client/renderer/EntityTileRenderer.cpp \
|
||||
../../../src/client/renderer/GameRenderer.cpp \
|
||||
|
||||
26
project/haiku/createpkg.sh
Executable file
26
project/haiku/createpkg.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
mkdir build-haiku
|
||||
cd build-haiku
|
||||
cmake ..
|
||||
make -j10
|
||||
|
||||
rm -rf pkg
|
||||
|
||||
mkdir pkg
|
||||
mkdir -p ./pkg/apps/
|
||||
mkdir -p ./pkg/data/minecraftpe
|
||||
mkdir -p ./pkg/settings/minecraftpe
|
||||
mkdir -p ./pkg/data/deskbar/menu/Applications/
|
||||
mkdir -p ./pkg/data/deskbar/menu/Games/
|
||||
|
||||
cp -rv ../project/haiku/pkg ./
|
||||
cp -v MinecraftPE ./pkg/apps/minecraftpe
|
||||
cp -v MinecraftPE-server ./pkg/apps/minecraftpe-server
|
||||
cp -rv data ./pkg/data/minecraftpe
|
||||
|
||||
ln -s ../../../../apps/minecraftpe ./pkg/data/deskbar/menu/Applications/minecraftpe
|
||||
ln -s ../../../../apps/minecraftpe ./pkg/data/deskbar/menu/Games/minecraftpe
|
||||
|
||||
|
||||
package create -C pkg minecraftpe-0.6.1-x86_64.hpkg
|
||||
27
project/haiku/pkg/.PackageInfo
Normal file
27
project/haiku/pkg/.PackageInfo
Normal file
@@ -0,0 +1,27 @@
|
||||
name minecraftpe
|
||||
version 0.6.1-1
|
||||
architecture x86_64
|
||||
summary "Minecraft Pocket Edition"
|
||||
description "A port of minecraft pocket edition to Haiku"
|
||||
packager "Li <li@silica.codes>"
|
||||
vendor "Mojang"
|
||||
copyrights {
|
||||
"Copyright (C) 2026 by Mojang"
|
||||
}
|
||||
licenses {
|
||||
"MIT"
|
||||
}
|
||||
provides {
|
||||
minecraftpe = 0.6.1-1
|
||||
app:minecraftpe = 0.6.1-1
|
||||
}
|
||||
requires {
|
||||
glfw >= 3.3.7-1
|
||||
openal >= 1.21.1-5
|
||||
}
|
||||
global-writable-files {
|
||||
"settings/minecraftpe" directory keep-old
|
||||
}
|
||||
urls {
|
||||
"https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1/"
|
||||
}
|
||||
@@ -1179,6 +1179,8 @@
|
||||
F99F0FAD2F8436CE00F2B29A /* FoliageColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99F0FAB2F8436CE00F2B29A /* FoliageColor.cpp */; };
|
||||
F99F0FAF2F8436EB00F2B29A /* Color.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99F0FAE2F8436EB00F2B29A /* Color.cpp */; };
|
||||
F99F0FB02F8436EB00F2B29A /* Color.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99F0FAE2F8436EB00F2B29A /* Color.cpp */; };
|
||||
BEEF202614CFF670005F0002 /* Lighting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEEF202614CFF670005F0001 /* Lighting.cpp */; };
|
||||
BEEF202614CFF670005F0003 /* Lighting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEEF202614CFF670005F0001 /* Lighting.cpp */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@@ -2466,6 +2468,7 @@
|
||||
F99F0FA82F84369F00F2B29A /* GrassColor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GrassColor.cpp; sourceTree = "<group>"; };
|
||||
F99F0FAB2F8436CE00F2B29A /* FoliageColor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FoliageColor.cpp; sourceTree = "<group>"; };
|
||||
F99F0FAE2F8436EB00F2B29A /* Color.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Color.cpp; sourceTree = "<group>"; };
|
||||
BEEF202614CFF670005F0001 /* Lighting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Lighting.cpp; path = Lighting.cpp; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -3533,6 +3536,7 @@
|
||||
D5B50CF114CFF66F005F7284 /* TileRenderer.cpp */,
|
||||
D5B50CF214CFF66F005F7284 /* TileRenderer.h */,
|
||||
D5B50CF314CFF66F005F7284 /* VertecDecl.h */,
|
||||
BEEF202614CFF670005F0001 /* Lighting.cpp */,
|
||||
);
|
||||
path = renderer;
|
||||
sourceTree = "<group>";
|
||||
@@ -5439,6 +5443,7 @@
|
||||
D5D8C4C41639341100FD35F0 /* Motive.cpp in Sources */,
|
||||
D5D8C4C8163934BB00FD35F0 /* HangingEntityItem.cpp in Sources */,
|
||||
D5D8C4CC1639362F00FD35F0 /* NetherReactorPattern.cpp in Sources */,
|
||||
BEEF202614CFF670005F0002 /* Lighting.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -5821,6 +5826,7 @@
|
||||
042A91AF16B17517007ABBC6 /* NinePatch.cpp in Sources */,
|
||||
042A91B016B17517007ABBC6 /* OptionsGroup.cpp in Sources */,
|
||||
042A91B216B17517007ABBC6 /* TextBox.cpp in Sources */,
|
||||
BEEF202614CFF670005F0003 /* Lighting.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -351,7 +351,8 @@ StartupResult RakPeer::Startup( unsigned short maxConnections, SocketDescriptor
|
||||
#if defined(_WIN32)
|
||||
threadPriority=0;
|
||||
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
threadPriority=40;
|
||||
#else
|
||||
threadPriority=1000;
|
||||
#endif
|
||||
|
||||
@@ -17,8 +17,8 @@ using namespace RakNet;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
#include <kernel/OS.h>
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
@@ -93,9 +93,10 @@ int RakThread::Create( void* start_address( void* ), void *arglist, int priority
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
thread_id threadHandle = spawn_thread((thread_func)start_address, "RakThread", priority, arglist);
|
||||
int res = resume_thread(threadHandle);
|
||||
return res == B_OK ? 0 : 1;
|
||||
#else
|
||||
pthread_t threadHandle;
|
||||
// Create thread linux
|
||||
|
||||
@@ -42,10 +42,10 @@ SocketLayerOverride *SocketLayer::slo=0;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined(__HAIKU__)
|
||||
#include <sys/types.h>
|
||||
#include <ifaddrs.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1436,8 +1436,25 @@ RakNet::RakString SocketLayer::GetSubNetForSocketAndIp(SOCKET inSock, RakNet::Ra
|
||||
}
|
||||
}
|
||||
return "";
|
||||
#else
|
||||
#elif defined(__HAIKU__)
|
||||
struct ifaddrs *ifap, *ifa;
|
||||
getifaddrs (&ifap);
|
||||
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
|
||||
if (ifa->ifa_addr && ifa->ifa_addr->sa_family==AF_INET) {
|
||||
sockaddr_in* sa = (sockaddr_in*)ifa->ifa_addr;
|
||||
char* ip_addr = inet_ntoa(sa->sin_addr);
|
||||
if (inIpString == ip_addr) {
|
||||
sockaddr_in* sa = (sockaddr_in*)ifa->ifa_netmask;
|
||||
char* netmask = inet_ntoa(sa->sin_addr);
|
||||
|
||||
freeifaddrs(ifap);
|
||||
return netmask;
|
||||
}
|
||||
}
|
||||
}
|
||||
freeifaddrs(ifap);
|
||||
return "";
|
||||
#else
|
||||
int fd,fd2;
|
||||
fd2 = socket__(AF_INET, SOCK_DGRAM, 0);
|
||||
|
||||
@@ -1648,7 +1665,7 @@ void GetMyIP_Win32( SystemAddress addresses[MAXIMUM_NUMBER_OF_INTERNAL_IDS] )
|
||||
}
|
||||
}
|
||||
// #else
|
||||
/*
|
||||
|
||||
void GetMyIP_Linux( SystemAddress addresses[MAXIMUM_NUMBER_OF_INTERNAL_IDS] )
|
||||
{
|
||||
struct ifaddrs *ifaddr, *ifa;
|
||||
@@ -1699,7 +1716,7 @@ void GetMyIP_Linux( SystemAddress addresses[MAXIMUM_NUMBER_OF_INTERNAL_IDS] )
|
||||
|
||||
freeifaddrs(ifaddr);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1707,10 +1724,10 @@ void SocketLayer::GetMyIP( SystemAddress addresses[MAXIMUM_NUMBER_OF_INTERNAL_ID
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined(_WIN32)
|
||||
GetMyIP_Win32(addresses);
|
||||
#elif defined(__HAIKU__)
|
||||
GetMyIP_Linux(addresses);
|
||||
#else
|
||||
// GetMyIP_Linux(addresses);
|
||||
GetMyIP_Win32(addresses);
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#include "UDPForwarder.h"
|
||||
|
||||
#if defined(__HAIKU__)
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#if _RAKNET_SUPPORT_UDPForwarder==1
|
||||
|
||||
#include "GetTime.h"
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <shellapi.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/html5.h>
|
||||
#endif
|
||||
@@ -31,12 +32,19 @@ static void png_funcReadFile(png_structp pngPtr, png_bytep data, png_size_t leng
|
||||
class AppPlatform_glfw: public AppPlatform
|
||||
{
|
||||
public:
|
||||
AppPlatform_glfw()
|
||||
|
||||
#ifdef __HAIKU__
|
||||
std::string game_directory = "/system/data/minecraftpe/";
|
||||
#else
|
||||
std::string game_directory = "";
|
||||
#endif
|
||||
|
||||
AppPlatform_glfw()
|
||||
{
|
||||
}
|
||||
|
||||
BinaryBlob readAssetFile(const std::string& filename) override {
|
||||
FILE* fp = fopen(("data/" + filename).c_str(), "r");
|
||||
FILE* fp = fopen((game_directory + "data/" + filename).c_str(), "r");
|
||||
if (!fp)
|
||||
return BinaryBlob();
|
||||
|
||||
@@ -73,7 +81,7 @@ public:
|
||||
|
||||
TextureData out;
|
||||
|
||||
std::string filename = textureFolder? "data/images/" + filename_
|
||||
std::string filename = textureFolder? (game_directory + "data/images/") + filename_
|
||||
: filename_;
|
||||
std::ifstream source(filename.c_str(), std::ios::binary);
|
||||
|
||||
|
||||
@@ -745,6 +745,7 @@ void Minecraft::tickInput() {
|
||||
int dst = options.getIntValue(OPTIONS_VIEW_DISTANCE);
|
||||
options.set(OPTIONS_VIEW_DISTANCE, (dst + 1) % 4);
|
||||
}
|
||||
|
||||
#ifdef CHEATS
|
||||
if (key == Keyboard::KEY_U) {
|
||||
onGraphicsReset();
|
||||
@@ -1128,6 +1129,8 @@ void Minecraft::init()
|
||||
textures = new Textures(&options, platform());
|
||||
textures->addDynamicTexture(new WaterTexture());
|
||||
textures->addDynamicTexture(new WaterSideTexture());
|
||||
textures->addDynamicTexture(new LavaTexture());
|
||||
textures->addDynamicTexture(new LavaSideTexture());
|
||||
textures->addDynamicTexture(new FireTexture());
|
||||
gui.texturesLoaded(textures);
|
||||
|
||||
|
||||
@@ -54,18 +54,24 @@ OptionBool limitFramerate("limitFramerate", false);
|
||||
OptionBool vsync("vsync", true);
|
||||
OptionBool fancyGraphics("fancyGraphics", true);
|
||||
OptionBool viewBobbing("viewBobbing", true);
|
||||
OptionBool ambientOcclusion("ao", false);
|
||||
OptionBool ambientOcclusion("ao", true);
|
||||
|
||||
OptionBool useNormalLighting("normalLighting", true);
|
||||
|
||||
OptionBool useTouchscreen("useTouchscreen", true);
|
||||
|
||||
OptionBool serverVisible("servervisible", true);
|
||||
|
||||
OptionBool foliageTint("foliagetint", false);
|
||||
OptionBool foliageTint("foliagetint", true);
|
||||
|
||||
OptionInt fogType("fogType", 0, 0, 2);
|
||||
|
||||
OptionBool javaHud("javaHud", false);
|
||||
|
||||
OptionBool blockOutline("blockOutline", false);
|
||||
|
||||
OptionBool restoredAnims("restoredAnims", true);
|
||||
|
||||
OptionInt keyForward("key.forward", Keyboard::KEY_W);
|
||||
OptionInt keyLeft("key.left", Keyboard::KEY_A);
|
||||
OptionInt keyBack("key.back", Keyboard::KEY_S);
|
||||
@@ -142,7 +148,11 @@ void Options::initTable() {
|
||||
|
||||
m_options[OPTIONS_USE_TOUCHSCREEN] = &useTouchscreen;
|
||||
|
||||
m_options[OPTIONS_BLOCK_OUTLINE] = &blockOutline;
|
||||
|
||||
m_options[OPTIONS_NORMAL_LIGHTING] = &useNormalLighting;
|
||||
|
||||
m_options[OPTIONS_RESTORED_ANIMS] = &restoredAnims;
|
||||
|
||||
m_options[OPTIONS_SERVER_VISIBLE] = &serverVisible;
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ enum OptionId {
|
||||
OPTIONS_LIMIT_FRAMERATE,
|
||||
OPTIONS_VSYNC,
|
||||
OPTIONS_FANCY_GRAPHICS,
|
||||
OPTIONS_NORMAL_LIGHTING,
|
||||
|
||||
// Cheats / debug
|
||||
OPTIONS_FLY_SPEED,
|
||||
@@ -56,6 +57,7 @@ enum OptionId {
|
||||
OPTIONS_IS_FLYING,
|
||||
|
||||
// Control
|
||||
OPTIONS_BLOCK_OUTLINE,
|
||||
OPTIONS_USE_MOUSE_FOR_DIGGING,
|
||||
OPTIONS_IS_LEFT_HANDED,
|
||||
OPTIONS_IS_JOY_TOUCH_AREA,
|
||||
@@ -87,6 +89,7 @@ enum OptionId {
|
||||
OPTIONS_FOLIAGE_TINT,
|
||||
OPTIONS_FOG_TYPE,
|
||||
OPTIONS_JAVA_HUD,
|
||||
OPTIONS_RESTORED_ANIMS,
|
||||
// Should be last!
|
||||
OPTIONS_COUNT
|
||||
};
|
||||
|
||||
@@ -18,6 +18,8 @@ OptionsFile::OptionsFile() {
|
||||
settingsPath = "options.txt";
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
settingsPath = "/games/com.mojang/options.txt";
|
||||
#elif defined(__HAIKU__)
|
||||
settingsPath = "/system/settings/minecraftpe/options.txt";
|
||||
#else
|
||||
settingsPath = "options.txt";
|
||||
#endif
|
||||
|
||||
@@ -596,7 +596,8 @@ void Gui::renderProgressIndicator( const bool isTouchInterface, const int screen
|
||||
bool bowEquipped = currentItem != NULL ? currentItem->getItem() == Item::bow : false;
|
||||
bool itemInUse = currentItem != NULL ? currentItem->getItem() == minecraft->player->getUseItem()->getItem() : false;
|
||||
if ((!isTouchInterface || minecraft->options.getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA)
|
||||
|| (bowEquipped && itemInUse)) && !minecraft->options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||
|| (bowEquipped && itemInUse)) && !minecraft->options.getBooleanValue(OPTIONS_HIDEGUI))
|
||||
{
|
||||
minecraft->textures->loadAndBindTexture("gui/icons.png");
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc2(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);
|
||||
@@ -620,7 +621,7 @@ void Gui::renderProgressIndicator( const bool isTouchInterface, const int screen
|
||||
const float x = InvGuiScale * minecraft->inputHolder->mousex;
|
||||
const float y = InvGuiScale * minecraft->inputHolder->mousey;
|
||||
glTranslatef2(x, y, 0);
|
||||
drawArrayVT(rcFeedbackOuter.vboId, rcFeedbackOuter.vertexCount, 24);
|
||||
drawArrayVT(rcFeedbackOuter.vboId, rcFeedbackOuter.vertexCount, 36);
|
||||
glTranslatef2(-x, -y, 0);
|
||||
|
||||
glEnable2(GL_TEXTURE_2D);
|
||||
@@ -641,12 +642,12 @@ void Gui::renderProgressIndicator( const bool isTouchInterface, const int screen
|
||||
const float y = InvGuiScale * minecraft->inputHolder->mousey;
|
||||
glPushMatrix2();
|
||||
glTranslatef2(x, y, 0);
|
||||
drawArrayVT(rcFeedbackOuter.vboId, rcFeedbackOuter.vertexCount, 24);
|
||||
drawArrayVT(rcFeedbackOuter.vboId, rcFeedbackOuter.vertexCount, 36);
|
||||
glScalef2(0.5f + progress, 0.5f + progress, 1);
|
||||
//glDisable2(GL_CULL_FACE);
|
||||
glColor4f2(1, 1, 1, 1);
|
||||
glBlendFunc2(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);
|
||||
drawArrayVT(rcFeedbackInner.vboId, rcFeedbackInner.vertexCount, 24, GL_TRIANGLE_FAN);
|
||||
drawArrayVT(rcFeedbackInner.vboId, rcFeedbackInner.vertexCount, 36, GL_TRIANGLE_FAN);
|
||||
glPopMatrix2();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
@@ -1035,7 +1036,10 @@ void Gui::renderChatMessages( const int screenHeight, unsigned int max, bool isC
|
||||
}
|
||||
|
||||
void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
|
||||
glColor4f2(1, 1, 1, .5);
|
||||
glColor4f2(1, 1, 1, 1);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
minecraft->textures->loadAndBindTexture("gui/gui.png");
|
||||
|
||||
Inventory* inventory = minecraft->player->inventory;
|
||||
|
||||
@@ -36,6 +36,16 @@ void OptionsItem::render( Minecraft* minecraft, int xm, int ym ) {
|
||||
}
|
||||
text += ": " + scaleText;
|
||||
}
|
||||
if (m_optionId == OPTIONS_FOG_TYPE) {
|
||||
int value = minecraft->options.getIntValue(OPTIONS_FOG_TYPE);
|
||||
std::string scaleText;
|
||||
switch (value) {
|
||||
case 0: scaleText = I18n::get("options.fogType.vanilla"); break;
|
||||
case 1: scaleText = I18n::get("options.fogType.java"); break;
|
||||
case 2: scaleText = I18n::get("options.fogType.unused"); break;
|
||||
}
|
||||
text += ": " + scaleText;
|
||||
}
|
||||
|
||||
minecraft->font->draw(text, (float)x, (float)y + yOffset, 0x909090, false);
|
||||
super::render(minecraft, xm, ym);
|
||||
|
||||
@@ -41,6 +41,7 @@ void CreditsScreen::init() {
|
||||
_lines.push_back("karson");
|
||||
_lines.push_back("deepfriedwaffles");
|
||||
_lines.push_back("EpikIzCool");
|
||||
_lines.push_back("fileshredder");
|
||||
_lines.push_back("");
|
||||
// avoid color tags around the URL so it isn't mangled by the parser please
|
||||
_lines.push_back("Join our Discord server: https://discord.gg/c58YesBxve");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "IngameBlockSelectionScreen.h"
|
||||
#include "../../renderer/TileRenderer.h"
|
||||
#include "../../renderer/Lighting.h"
|
||||
#include "../../player/LocalPlayer.h"
|
||||
#include "../../renderer/gles.h"
|
||||
#include "../../Minecraft.h"
|
||||
@@ -80,10 +81,10 @@ void IngameBlockSelectionScreen::renderSlots()
|
||||
|
||||
blitOffset = -90;
|
||||
|
||||
//glEnable2(GL_RESCALE_NORMAL);
|
||||
glEnable2(GL_RESCALE_NORMAL);
|
||||
//glPushMatrix2();
|
||||
//glRotatef2(180, 1, 0, 0);
|
||||
//Lighting::turnOn();
|
||||
Lighting::turnOn(minecraft);
|
||||
//glPopMatrix2();
|
||||
|
||||
minecraft->textures->loadAndBindTexture("gui/gui.png");
|
||||
@@ -122,8 +123,8 @@ void IngameBlockSelectionScreen::renderSlots()
|
||||
//w.stop();
|
||||
//w.printEvery(1000, "render-blocksel");
|
||||
|
||||
//glDisable2(GL_RESCALE_NORMAL);
|
||||
//Lighting::turnOn();
|
||||
glDisable2(GL_RESCALE_NORMAL);
|
||||
Lighting::turnOn(minecraft);
|
||||
}
|
||||
|
||||
int IngameBlockSelectionScreen::getSlotPosX(int slotX) {
|
||||
|
||||
@@ -208,7 +208,9 @@ void OptionsScreen::generateOptionScreens() {
|
||||
// // Controls Pane
|
||||
optionPanes[2]->addOptionItem(OPTIONS_INVERT_Y_MOUSE, minecraft)
|
||||
.addOptionItem(OPTIONS_USE_TOUCHSCREEN, minecraft)
|
||||
.addOptionItem(OPTIONS_AUTOJUMP, minecraft);
|
||||
.addOptionItem(OPTIONS_AUTOJUMP, minecraft)
|
||||
.addOptionItem(OPTIONS_BLOCK_OUTLINE, minecraft)
|
||||
.addOptionItem(OPTIONS_IS_JOY_TOUCH_AREA, minecraft);
|
||||
|
||||
for (int i = OPTIONS_KEY_FORWARD; i <= OPTIONS_KEY_USE; i++) {
|
||||
optionPanes[2]->addOptionItem((OptionId)i, minecraft);
|
||||
@@ -224,14 +226,16 @@ void OptionsScreen::generateOptionScreens() {
|
||||
.addOptionItem(OPTIONS_RENDER_DEBUG, minecraft)
|
||||
.addOptionItem(OPTIONS_ANAGLYPH_3D, minecraft)
|
||||
.addOptionItem(OPTIONS_VIEW_BOBBING, minecraft)
|
||||
.addOptionItem(OPTIONS_AMBIENT_OCCLUSION, minecraft);
|
||||
.addOptionItem(OPTIONS_AMBIENT_OCCLUSION, minecraft)
|
||||
.addOptionItem(OPTIONS_NORMAL_LIGHTING, minecraft);
|
||||
|
||||
optionPanes[4]->addOptionItem(OPTIONS_ALLOW_SPRINT, minecraft)
|
||||
.addOptionItem(OPTIONS_BAR_ON_TOP, minecraft)
|
||||
.addOptionItem(OPTIONS_RPI_CURSOR, minecraft)
|
||||
.addOptionItem(OPTIONS_FOLIAGE_TINT, minecraft)
|
||||
.addOptionItem(OPTIONS_JAVA_HUD, minecraft)
|
||||
.addOptionItem(OPTIONS_FOG_TYPE, minecraft);
|
||||
.addOptionItem(OPTIONS_FOG_TYPE, minecraft)
|
||||
.addOptionItem(OPTIONS_RESTORED_ANIMS, minecraft);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ void ModelPart::compile( float scale )
|
||||
void ModelPart::draw()
|
||||
{
|
||||
#ifdef OPENGL_ES
|
||||
drawArrayVT_NoState(vboId, cubes.size() * 2 * 3 * 6, 24);
|
||||
drawArrayVTN_NoState(vboId, cubes.size() * 2 * 3 * 6, 36);
|
||||
#else
|
||||
glCallList(list);
|
||||
#endif
|
||||
|
||||
@@ -43,6 +43,18 @@ void PolygonQuad::mirror() {
|
||||
}
|
||||
|
||||
void PolygonQuad::render(Tesselator& t, float scale, int vboId /* = -1 */) {
|
||||
Vec3 v0 = vertices[0].pos - vertices[1].pos;
|
||||
Vec3 v1 = vertices[2].pos - vertices[1].pos;
|
||||
Vec3 n = v1.cross(v0).normalized();
|
||||
if (_flipNormal == true)
|
||||
{
|
||||
t.normal(-n.x , -n.y , -n.z );
|
||||
}
|
||||
else
|
||||
{
|
||||
t.normal(n.x , n.y , n.z );
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
VertexPT& v = vertices[i];
|
||||
t.vertexUV(v.pos.x * scale, v.pos.y * scale, v.pos.z * scale, v.u, v.v);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,11 +21,12 @@
|
||||
#include "../../world/item/BowItem.h"
|
||||
#include "../../world/level/tile/LeafTile.h"
|
||||
#include "entity/HumanoidMobRenderer.h"
|
||||
#include "Lighting.h"
|
||||
|
||||
//static StopwatchHandler handler;
|
||||
|
||||
ItemInHandRenderer::ItemInHandRenderer( Minecraft* mc )
|
||||
: mc(mc),
|
||||
: mc(mc),
|
||||
lastSlot(-1),
|
||||
height(0),
|
||||
oHeight(0),
|
||||
@@ -49,21 +50,47 @@ ItemInHandRenderer::ItemInHandRenderer( Minecraft* mc )
|
||||
void ItemInHandRenderer::tick()
|
||||
{
|
||||
oHeight = height;
|
||||
item.id = 0;
|
||||
//item.id = 0;
|
||||
|
||||
ItemInstance* itemInHand = mc->player->inventory->getSelected();
|
||||
if (itemInHand && itemInHand->count > 0) {
|
||||
item.id = itemInHand->id;
|
||||
item.setAuxValue(itemInHand->getAuxValue());
|
||||
bool sameItem = (itemInHand && item.id == itemInHand->id && item.getAuxValue() == itemInHand->getAuxValue());
|
||||
|
||||
|
||||
|
||||
if (mc->options.getBooleanValue(OPTIONS_RESTORED_ANIMS)) // if enabled, restores and fixes item switching animation
|
||||
{
|
||||
if (!itemInHand && item.id == 0) sameItem = true;
|
||||
float max = 0.4f;
|
||||
float tHeight = sameItem ? 1 : 0;
|
||||
float dd = tHeight - height;
|
||||
if (dd < -max) dd = -max;
|
||||
if (dd > max) dd = max;
|
||||
|
||||
height += dd;
|
||||
|
||||
if (height < 0.1){
|
||||
if (itemInHand && itemInHand->count > 0) {
|
||||
item.id = itemInHand->id;
|
||||
item.setAuxValue(itemInHand->getAuxValue());
|
||||
} else {
|
||||
item.id = 0;
|
||||
}
|
||||
}
|
||||
} else // otherwise use vanilla broken behaviour where it instantly switches items/blocks
|
||||
{
|
||||
if (itemInHand && itemInHand->count > 0) {
|
||||
item.id = itemInHand->id;
|
||||
item.setAuxValue(itemInHand->getAuxValue());
|
||||
}
|
||||
|
||||
float max = 0.4f;
|
||||
float tHeight = 1;//matches ? 1 : 0;
|
||||
float dd = tHeight - height;
|
||||
if (dd < -max) dd = -max;
|
||||
if (dd > max) dd = max;
|
||||
|
||||
height += dd;
|
||||
}
|
||||
|
||||
float max = 0.4f;
|
||||
float tHeight = 1;//matches ? 1 : 0;
|
||||
float dd = tHeight - height;
|
||||
if (dd < -max) dd = -max;
|
||||
if (dd > max) dd = max;
|
||||
|
||||
height += dd;
|
||||
}
|
||||
|
||||
void ItemInHandRenderer::renderItem(Mob* mob, ItemInstance* item )
|
||||
@@ -92,7 +119,7 @@ void ItemInHandRenderer::renderItem(Mob* mob, ItemInstance* item )
|
||||
if(mob != NULL) {
|
||||
itemIcon = mob->getItemInHandIcon(item, 0);
|
||||
}
|
||||
|
||||
|
||||
bool reTesselate(false);
|
||||
if(itemIcon != lastIconRendered && lastItemRendered == itemId)
|
||||
reTesselate = true;
|
||||
@@ -139,9 +166,9 @@ void ItemInHandRenderer::renderItem(Mob* mob, ItemInstance* item )
|
||||
float v1 = (vp * 16 + 15.99f) / 256.0f;
|
||||
|
||||
float r = 1.0f;
|
||||
// float xo = 0.0f;
|
||||
// float yo = 0.3f;
|
||||
/*
|
||||
// float xo = 0.0f;
|
||||
// float yo = 0.3f;
|
||||
/*
|
||||
//glEnable2(GL_RESCALE_NORMAL);
|
||||
glTranslatef2(-xo, -yo, 0);
|
||||
float s = 1.5f;
|
||||
@@ -150,19 +177,28 @@ void ItemInHandRenderer::renderItem(Mob* mob, ItemInstance* item )
|
||||
glRotatef2(50, 0, 1, 0);
|
||||
glRotatef2(45 + 290, 0, 0, 1);
|
||||
glTranslatef2(-15 / 16.0f, -1 / 16.0f, 0);
|
||||
*/
|
||||
*/
|
||||
float dd = 1 / 16.0f;
|
||||
float col = 1.0f;
|
||||
float br = mc->player->getBrightness(0);
|
||||
|
||||
|
||||
t.color(col*br,col*br,col*br,1.0f);
|
||||
t.normal(0.0f, 0.0f, 1.0f);
|
||||
t.vertexUV(0, 0, 0, u0, v1);
|
||||
t.vertexUV(r, 0, 0, u1, v1);
|
||||
t.vertexUV(r, 1, 0, u1, v0);
|
||||
t.vertexUV(0, 1, 0, u0, v0);
|
||||
|
||||
t.normal(0.0f, 0.0f, -1.0f);
|
||||
t.vertexUV(0, 1, 0 - dd, u0, v0);
|
||||
t.vertexUV(r, 1, 0 - dd, u1, v0);
|
||||
t.vertexUV(r, 0, 0 - dd, u1, v1);
|
||||
t.vertexUV(0, 0, 0 - dd, u0, v1);
|
||||
|
||||
col = 0.8f;
|
||||
t.color(col*br,col*br,col*br,1.0f);
|
||||
t.normal(-1.0f, 0.0f, 0.0f);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
float p = i / 16.0f;
|
||||
float uu = u0 + (u1 - u0) * p - 0.5f / 256.0f;
|
||||
@@ -172,6 +208,7 @@ void ItemInHandRenderer::renderItem(Mob* mob, ItemInstance* item )
|
||||
t.vertexUV(xx, 1, 0, uu, v0);
|
||||
t.vertexUV(xx, 1, 0 - dd, uu, v0);
|
||||
}
|
||||
t.normal(1.0f, 0.0f, 0.0f);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
float p = i / 16.0f;
|
||||
float uu = u0 + (u1 - u0) * p - 0.5f / 256.0f;
|
||||
@@ -181,6 +218,10 @@ void ItemInHandRenderer::renderItem(Mob* mob, ItemInstance* item )
|
||||
t.vertexUV(xx, 0, 0, uu, v1);
|
||||
t.vertexUV(xx, 0, 0 - dd, uu, v1);
|
||||
}
|
||||
|
||||
col = 0.6f;
|
||||
t.color(col*br,col*br,col*br,1.0f);
|
||||
t.normal(0.0f, 1.0f, 0.0f);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
float p = i / 16.0f;
|
||||
float vv = v1 + (v0 - v1) * p - 0.5f / 256.0f;
|
||||
@@ -190,6 +231,7 @@ void ItemInHandRenderer::renderItem(Mob* mob, ItemInstance* item )
|
||||
t.vertexUV(r, yy, 0 - dd, u1, vv);
|
||||
t.vertexUV(0, yy, 0 - dd, u0, vv);
|
||||
}
|
||||
t.normal(0.0f, -1.0f, 0.0f);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
float p = i / 16.0f;
|
||||
float vv = v1 + (v0 - v1) * p - 0.5f / 256.0f;
|
||||
@@ -219,7 +261,7 @@ void ItemInHandRenderer::renderItem(Mob* mob, ItemInstance* item )
|
||||
}
|
||||
mc->textures->loadAndBindTexture(renderObject.texture);
|
||||
|
||||
drawArrayVT_NoState(renderObject.chunk.vboId, renderObject.chunk.vertexCount);
|
||||
drawArrayVTN_NoState(renderObject.chunk.vboId, renderObject.chunk.vertexCount);
|
||||
if (renderObject.isFlat)
|
||||
glPopMatrix2();
|
||||
}
|
||||
@@ -227,6 +269,7 @@ void ItemInHandRenderer::renderItem(Mob* mob, ItemInstance* item )
|
||||
//handler.printEvery(100);
|
||||
}
|
||||
|
||||
|
||||
void ItemInHandRenderer::render( float a )
|
||||
{
|
||||
//return;
|
||||
@@ -241,6 +284,8 @@ void ItemInHandRenderer::render( float a )
|
||||
glPushMatrix2();
|
||||
glRotatef2(player->xRotO + (player->xRot - player->xRotO) * a, 1, 0, 0);
|
||||
glRotatef2(player->yRotO + (player->yRot - player->yRotO) * a, 0, 1, 0);
|
||||
glEnable(GL_RESCALE_NORMAL);
|
||||
Lighting::turnOn(mc);
|
||||
glPopMatrix2();
|
||||
|
||||
float br = mc->level->getBrightness(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
|
||||
@@ -293,7 +338,7 @@ void ItemInHandRenderer::render( float a )
|
||||
glTranslatef2(0.7f * d, -0.65f * d - (1 - h) * 0.6f, -0.9f * d);
|
||||
|
||||
glRotatef2(45, 0, 1, 0);
|
||||
//glEnable2(GL_RESCALE_NORMAL);
|
||||
glEnable2(GL_RESCALE_NORMAL);
|
||||
glRotatef2(-swing3 * 20, 0, 1, 0);
|
||||
glRotatef2(-swing2 * 20, 0, 0, 1);
|
||||
glRotatef2(-swing2 * 80, 1, 0, 0);
|
||||
@@ -330,7 +375,9 @@ void ItemInHandRenderer::render( float a )
|
||||
}
|
||||
glEnableClientState2(GL_VERTEX_ARRAY);
|
||||
glEnableClientState2(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableClientState2(GL_NORMAL_ARRAY);
|
||||
renderItem(player, item);
|
||||
glDisableClientState2(GL_NORMAL_ARRAY);
|
||||
glDisableClientState2(GL_VERTEX_ARRAY);
|
||||
glDisableClientState2(GL_TEXTURE_COORD_ARRAY);
|
||||
glPopMatrix2();
|
||||
@@ -349,14 +396,15 @@ void ItemInHandRenderer::render( float a )
|
||||
glTranslatef2(0.8f * d, -0.75f * d - (1 - h) * 0.6f, -0.9f * d);
|
||||
|
||||
glRotatef2(45, 0, 1, 0);
|
||||
//glEnable2(GL_RESCALE_NORMAL);
|
||||
// glEnable2(GL_RESCALE_NORMAL);
|
||||
glEnable(GL_NORMALIZE);
|
||||
glRotatef2(swing2 * 70, 0, 1, 0);
|
||||
glRotatef2(-swing3 * 20, 0, 0, 1);
|
||||
// glRotatef2(-swing2 * 80, 1, 0, 0);
|
||||
|
||||
mc->textures->loadAndBindTexture(player->getTexture());
|
||||
glTranslatef2(-1.0f, +3.6f, +3.5f);
|
||||
glRotatef2(120, 0, 0, 1);
|
||||
glRotatef2(120, 0, 0, 1);
|
||||
glRotatef2(180 + 20, 1, 0, 0);
|
||||
glRotatef2(-90 - 45, 0, 1, 0);
|
||||
glScalef2(1.5f / 24.0f * 16, 1.5f / 24.0f * 16, 1.5f / 24.0f * 16);
|
||||
@@ -369,8 +417,8 @@ void ItemInHandRenderer::render( float a )
|
||||
playerRenderer->renderHand();
|
||||
glPopMatrix2();
|
||||
}
|
||||
//glDisable2(GL_RESCALE_NORMAL);
|
||||
//Lighting.turnOff();
|
||||
glDisable2(GL_RESCALE_NORMAL);
|
||||
Lighting::turnOff();
|
||||
//w.stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -513,14 +513,14 @@ void LevelRenderer::render(const AABB& b) const
|
||||
{
|
||||
Tesselator& t = Tesselator::instance;
|
||||
|
||||
glColor4f2(1, 1, 1, 1);
|
||||
// glColor4f2(1, 1, 1, 1);
|
||||
|
||||
textures->loadAndBindTexture("terrain.png");
|
||||
// textures->loadAndBindTexture("terrain.png"); // uh need to check java - shredder
|
||||
|
||||
//t.begin();
|
||||
t.color(255, 255, 255, 255);
|
||||
// t.color(255, 255, 255, 255); // again not needed, for some reason the vanilla source code tints it... white? maybe this was used for something else in MCPE's dev at one point? - shredder
|
||||
|
||||
t.offset(((Mob*)mc->player)->getPos(0).negated());
|
||||
// t.offset(((Mob*)mc->player)->getPos(0).negated()); // why does this even exist normally, it just makes the thing... not render
|
||||
|
||||
t.begin(GL_LINE_STRIP);
|
||||
t.vertex(b.x0, b.y0, b.z0);
|
||||
|
||||
49
src/client/renderer/Lighting.cpp
Normal file
49
src/client/renderer/Lighting.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include "Lighting.h"
|
||||
#include "gles.h"
|
||||
#include "../Minecraft.h"
|
||||
|
||||
void Lighting::turnOff() {
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_LIGHT0);
|
||||
glDisable(GL_LIGHT1);
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
}
|
||||
|
||||
void Lighting::turnOn(Minecraft* minecraft) {
|
||||
if (!minecraft->options.getBooleanValue(OPTIONS_NORMAL_LIGHTING)){ // if normal lighting is false, then just dont use the lighting system at all like in vanilla - shredder
|
||||
turnOff();
|
||||
return;
|
||||
}
|
||||
glEnable(GL_NORMALIZE);
|
||||
// if normal lighting is true then enable GLES/OpenGL states to setup lighting
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_LIGHT1);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
// glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
|
||||
|
||||
constexpr float a = 0.4f;
|
||||
constexpr float d = 0.6f;
|
||||
constexpr float s = 0.0f;
|
||||
|
||||
|
||||
//Vec3 l = world::phys::Vec3{0.2, 1.0, -0.7}.normalize();
|
||||
constexpr float lightmodel_ambient[] = {a, a, a, 1.0f};
|
||||
constexpr float diffuse[] = {d, d, d, 1.0f};
|
||||
constexpr float ambient[] = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
constexpr float specular[] = {s, s, s, 1.0f};
|
||||
|
||||
constexpr float pos0[] = {(float)(0.16169041989141428), (float)(0.8084520874101966), (float)(-0.5659164515496377), 0.0f};
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, pos0);
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
|
||||
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
|
||||
glLightfv(GL_LIGHT0, GL_SPECULAR, specular);
|
||||
|
||||
constexpr float pos1[] = {(float)(-0.16169041989141428), (float)(0.8084520874101966), (float)(0.5659164515496377), 0.0f};
|
||||
glLightfv(GL_LIGHT1, GL_POSITION, pos1);
|
||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);
|
||||
glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);
|
||||
glLightfv(GL_LIGHT1, GL_SPECULAR, specular);
|
||||
glShadeModel(GL_FLAT);
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lightmodel_ambient);
|
||||
}
|
||||
12
src/client/renderer/Lighting.h
Normal file
12
src/client/renderer/Lighting.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef NET_MINECRAFT_CLIENT_RENDERER__Lighting_H__
|
||||
#define NET_MINECRAFT_CLIENT_RENDERER__Lighting_H__
|
||||
|
||||
class Minecraft;
|
||||
class Lighting
|
||||
{
|
||||
public:
|
||||
static void turnOff();
|
||||
static void turnOn(Minecraft* minecraft);
|
||||
|
||||
};
|
||||
#endif /*NET_MINECRAFT_CLIENT_RENDERER__Lighting_H__*/
|
||||
@@ -8,7 +8,7 @@ Tesselator Tesselator::instance(sizeof(GLfloat) * MAX_FLOATS); // max size in by
|
||||
const int VertexSizeBytes = sizeof(VERTEX);
|
||||
|
||||
Tesselator::Tesselator( int size )
|
||||
: size(size),
|
||||
: size(size),
|
||||
vertices(0),
|
||||
u(0), v(0),
|
||||
_color(0),
|
||||
@@ -20,7 +20,7 @@ Tesselator::Tesselator( int size )
|
||||
_noColor(false),
|
||||
mode(0),
|
||||
xo(0), yo(0), zo(0),
|
||||
_normal(0),
|
||||
_nx(0), _ny(0), _nz(0),
|
||||
_sx(1), _sy(1),
|
||||
|
||||
tesselating(false),
|
||||
@@ -97,9 +97,9 @@ RenderChunk Tesselator::end( bool useMine, int bufferId )
|
||||
int access = GL_STATIC_DRAW;//(accessMode==ACCESS_DYNAMIC) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW;
|
||||
glBindBuffer2(GL_ARRAY_BUFFER, bufferId);
|
||||
glBufferData2(GL_ARRAY_BUFFER, bytes, _varray, access); // GL_STREAM_DRAW
|
||||
|
||||
|
||||
totalSize += bytes;
|
||||
|
||||
|
||||
#ifndef USE_VBO
|
||||
// 0 1 2 3 4 5 6 7
|
||||
// x y z u v c
|
||||
@@ -112,7 +112,7 @@ RenderChunk Tesselator::end( bool useMine, int bufferId )
|
||||
glEnableClientState2(GL_COLOR_ARRAY);
|
||||
}
|
||||
if (hasNormal) {
|
||||
glNormalPointer(GL_BYTE, VertexSizeBytes, (GLvoid*) (6 * 4));
|
||||
glNormalPointer(GL_FLOAT, VertexSizeBytes, (GLvoid*) (6 * 4));
|
||||
glEnableClientState2(GL_NORMAL_ARRAY);
|
||||
}
|
||||
glVertexPointer2(3, GL_FLOAT, VertexSizeBytes, 0);
|
||||
@@ -278,9 +278,11 @@ void Tesselator::vertex( float x, float y, float z )
|
||||
if (hasColor) {
|
||||
dst.color = src.color;
|
||||
}
|
||||
//if (hasNormal) {
|
||||
// dst.normal = src.normal;
|
||||
//}
|
||||
if (hasNormal) {
|
||||
dst.nx = src.nx;
|
||||
dst.ny = src.ny;
|
||||
dst.nz = src.nz;
|
||||
}
|
||||
|
||||
dst.x = src.x;
|
||||
dst.y = src.y;
|
||||
@@ -301,9 +303,11 @@ void Tesselator::vertex( float x, float y, float z )
|
||||
if (hasColor) {
|
||||
vertex.color = _color;
|
||||
}
|
||||
//if (hasNormal) {
|
||||
// vertex.normal = _normal;
|
||||
//}
|
||||
if (hasNormal) {
|
||||
vertex.nx = _nx;
|
||||
vertex.ny = _ny;
|
||||
vertex.nz = _nz;
|
||||
}
|
||||
|
||||
vertex.x = _sx * (x + xo);
|
||||
vertex.y = _sy * (y + yo);
|
||||
@@ -332,18 +336,22 @@ void Tesselator::setAccessMode(int mode)
|
||||
|
||||
void Tesselator::normal( float x, float y, float z )
|
||||
{
|
||||
static int _warn_t = 0;
|
||||
if ((++_warn_t & 32767) == 1)
|
||||
LOGI("WARNING: Can't use normals (Tesselator::normal)\n");
|
||||
return;
|
||||
//static int _warn_t = 0;
|
||||
//if ((++_warn_t & 32767) == 1)
|
||||
// LOGI("WARNING: Can't use normals (Tesselator::normal)\n");
|
||||
//return;
|
||||
|
||||
if (!tesselating) printf("But..");
|
||||
hasNormal = true;
|
||||
char xx = (char) (x * 128);
|
||||
char yy = (char) (y * 127);
|
||||
char zz = (char) (z * 127);
|
||||
//char xx = (char) (x * 128);
|
||||
//char yy = (char) (y * 127);
|
||||
//char zz = (char) (z * 127);
|
||||
|
||||
_normal = xx | (yy << 8) | (zz << 16);
|
||||
//_normal = xx | (yy << 8) | (zz << 16);
|
||||
// trying a new thing hopefully works
|
||||
this->_nx = x;
|
||||
this->_ny = y;
|
||||
this->_nz = z;
|
||||
}
|
||||
|
||||
void Tesselator::offset( float xo, float yo, float zo ) {
|
||||
@@ -389,7 +397,7 @@ void Tesselator::draw()
|
||||
vboId = 0;
|
||||
|
||||
int bufferId = vboIds[vboId];
|
||||
|
||||
|
||||
int access = GL_DYNAMIC_DRAW;//(accessMode==ACCESS_DYNAMIC) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW;
|
||||
glBindBuffer2(GL_ARRAY_BUFFER, bufferId);
|
||||
glBufferData2(GL_ARRAY_BUFFER, bytes, _varray, access); // GL_STREAM_DRAW
|
||||
@@ -404,10 +412,10 @@ void Tesselator::draw()
|
||||
//glColorPointer2(4, GL_UNSIGNED_BYTE, VertexSizeBytes, (GLvoid*) &_varray->color);
|
||||
glEnableClientState2(GL_COLOR_ARRAY);
|
||||
}
|
||||
//if (hasNormal) {
|
||||
// glNormalPointer(GL_BYTE, VertexSizeBytes, (GLvoid*) (6 * 4));
|
||||
// glEnableClientState2(GL_NORMAL_ARRAY);
|
||||
//}
|
||||
if (hasNormal) {
|
||||
glNormalPointer(GL_FLOAT, VertexSizeBytes, (GLvoid*) (6 * 4));
|
||||
glEnableClientState2(GL_NORMAL_ARRAY);
|
||||
}
|
||||
//glVertexPointer2(3, GL_FLOAT, VertexSizeBytes, (GLvoid*)&_varray);
|
||||
glVertexPointer2(3, GL_FLOAT, VertexSizeBytes, 0);
|
||||
glEnableClientState2(GL_VERTEX_ARRAY);
|
||||
@@ -421,7 +429,7 @@ void Tesselator::draw()
|
||||
glDisableClientState2(GL_VERTEX_ARRAY);
|
||||
if (hasTexture) glDisableClientState2(GL_TEXTURE_COORD_ARRAY);
|
||||
if (hasColor) glDisableClientState2(GL_COLOR_ARRAY);
|
||||
//if (hasNormal) glDisableClientState2(GL_NORMAL_ARRAY);
|
||||
if (hasNormal) glDisableClientState2(GL_NORMAL_ARRAY);
|
||||
}
|
||||
|
||||
clear();
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
extern const int VertexSizeBytes;
|
||||
|
||||
typedef VertexDeclPTC VERTEX;
|
||||
typedef VertexDeclPTCN VERTEX;
|
||||
typedef std::map<GLuint, GLsizei> IntGLMap;
|
||||
|
||||
|
||||
@@ -98,7 +98,9 @@ private:
|
||||
float xo, yo, zo;
|
||||
float u, v;
|
||||
unsigned int _color;
|
||||
int _normal;
|
||||
// int _normal; // trying a new thing
|
||||
float _nx, _ny, _nz;
|
||||
|
||||
float _sx, _sy;
|
||||
|
||||
bool hasColor;
|
||||
|
||||
@@ -225,7 +225,7 @@ bool TileRenderer::tesselateTorchInWorld( Tile* tt, int x, int y, int z )
|
||||
|
||||
bool TileRenderer::tesselateFireInWorld( Tile* tt, int x, int y, int z )
|
||||
{
|
||||
// @todo: fire alpha transparency seems to be scuffed, also it seems i might have messed up the second layer while porting from lce/java , need to look into it - shredder
|
||||
// fire transparency has been fixed - shredder
|
||||
|
||||
Tesselator& t = Tesselator::instance;
|
||||
|
||||
@@ -2308,30 +2308,54 @@ void TileRenderer::renderEast( Tile* tt, float x, float y, float z, int tex )
|
||||
void TileRenderer::renderTile( Tile* tile, int data )
|
||||
{
|
||||
Tesselator& t = Tesselator::instance;
|
||||
|
||||
t.color(0xff, 0xff, 0xff);
|
||||
|
||||
t.color(0xff, 0xff, 0xff); // i disabled this, this is normally enabled in normal mcpe see if this fits OPTION_NORMAL_LIGHTING - shredder
|
||||
int shape = tile->getRenderShape();
|
||||
|
||||
if (shape == Tile::SHAPE_BLOCK) {
|
||||
tile->updateDefaultShape();
|
||||
t.addOffset(-0.5f, -0.5f, -0.5f);
|
||||
t.begin();
|
||||
|
||||
t.normal(0.0f, -1.0f, 0.0f);// most normal calls in this file has been added me since they existed in java - shredder
|
||||
|
||||
renderFaceDown(tile, 0, 0, 0, tile->getTexture(0, data));
|
||||
|
||||
t.normal(0.0f, 1.0f, 0.0f);
|
||||
|
||||
renderFaceUp(tile, 0, 0, 0, tile->getTexture(1, data));
|
||||
|
||||
t.normal(0.0f, 0.0f, -1.0f);
|
||||
|
||||
renderNorth(tile, 0, 0, 0, tile->getTexture(2, data));
|
||||
|
||||
t.normal(0.0f, 0.0f, 1.0f);
|
||||
|
||||
renderSouth(tile, 0, 0, 0, tile->getTexture(3, data));
|
||||
|
||||
t.normal(-1.0f, 0.0f, 0.0f);
|
||||
|
||||
renderWest(tile, 0, 0, 0, tile->getTexture(4, data));
|
||||
|
||||
t.normal(1.0f, 0.0f, 0.0f);
|
||||
|
||||
renderEast(tile, 0, 0, 0, tile->getTexture(5, data));
|
||||
t.draw();
|
||||
|
||||
t.addOffset(0.5f, 0.5f, 0.5f);
|
||||
|
||||
} else if (shape == Tile::SHAPE_CROSS_TEXTURE) {
|
||||
} else if (shape == Tile::SHAPE_CROSS_TEXTURE) { // uhh java has this but is this even ever used??? - shredder
|
||||
t.begin();
|
||||
|
||||
t.normal(0.0f, -1.0f, 0.0f);
|
||||
|
||||
tesselateCrossTexture(tile, data, -0.5f, -0.5f, -0.5f);
|
||||
t.draw();
|
||||
} else if(shape == Tile::SHAPE_STEM) {
|
||||
t.begin();
|
||||
|
||||
t.normal(0.0f, -1.0f, 0.0f);
|
||||
|
||||
tile->updateDefaultShape();
|
||||
tesselateStemTexture(tile, data, tile->yy1, -0.5f, -0.5f, -0.5f);
|
||||
t.draw();
|
||||
@@ -2340,16 +2364,39 @@ void TileRenderer::renderTile( Tile* tile, int data )
|
||||
t.offset(-0.5f, -0.5f, -0.5f);
|
||||
float s = 1 / 16.0f;
|
||||
t.begin();
|
||||
|
||||
t.normal(0.0f, -1.0f, 0.0f);
|
||||
|
||||
renderFaceDown(tile, 0, 0, 0, tile->getTexture(0));
|
||||
|
||||
t.normal(0.0f, 1.0f, 0.0f);
|
||||
|
||||
renderFaceUp(tile, 0, 0, 0, tile->getTexture(1));
|
||||
|
||||
t.normal(0.0f, 0.0f, -1.0f);
|
||||
|
||||
t.addOffset(0, 0, s);
|
||||
|
||||
|
||||
renderNorth(tile, 0, 0, 0, tile->getTexture(2));
|
||||
|
||||
t.normal(0.0f, 0.0f, 1.0f);
|
||||
|
||||
t.addOffset(0, 0, -s);
|
||||
t.addOffset(0, 0, -s);
|
||||
|
||||
|
||||
|
||||
renderSouth(tile, 0, 0, 0, tile->getTexture(3));
|
||||
|
||||
t.normal(-1.0f, 0.0f, 0.0f);
|
||||
|
||||
t.addOffset(0, 0, s);
|
||||
t.addOffset(s, 0, 0);
|
||||
renderWest(tile, 0, 0, 0, tile->getTexture(4));
|
||||
|
||||
t.normal(1.0f, 0.0f, 0.0f);
|
||||
|
||||
t.addOffset(-s, 0, 0);
|
||||
t.addOffset(-s, 0, 0);
|
||||
renderEast(tile, 0, 0, 0, tile->getTexture(5));
|
||||
@@ -2363,7 +2410,7 @@ void TileRenderer::renderTile( Tile* tile, int data )
|
||||
//} else if (shape == Tile::SHAPE_TORCH) {
|
||||
//// t.begin();
|
||||
//// t.normal(0, -1, 0);
|
||||
//// tesselateTorch(tile, -0.5f, -0.5f, -0.5f, 0, 0);
|
||||
/// tesselateTorch(tile, -0.5f, -0.5f, -0.5f, 0, 0);
|
||||
//// t.end();
|
||||
} else if (shape == Tile::SHAPE_ENTITYTILE_ANIMATED) {
|
||||
EntityTileRenderer::instance->render(tile, data, 1.0f);
|
||||
@@ -2375,11 +2422,23 @@ void TileRenderer::renderTile( Tile* tile, int data )
|
||||
if (i == 0) tile->setShape(0, 0, 0, 1, 1, 0.5f);
|
||||
if (i == 1) tile->setShape(0, 0, 0.5f, 1, 0.5f, 1);
|
||||
|
||||
|
||||
t.normal(0.0f, -1.0f, 0.0f);
|
||||
renderFaceDown(tile, 0, 0, 0, tile->getTexture(0));
|
||||
|
||||
t.normal(0.0f, 1.0f, 0.0f);
|
||||
renderFaceUp(tile, 0, 0, 0, tile->getTexture(1));
|
||||
|
||||
t.normal(0.0f, 0.0f, -1.0f);
|
||||
renderNorth(tile, 0, 0, 0, tile->getTexture(2));
|
||||
|
||||
t.normal(0.0f, 0.0f, 1.0f);
|
||||
renderSouth(tile, 0, 0, 0, tile->getTexture(3));
|
||||
|
||||
t.normal(-1.0f, 0.0f, 0.0f);
|
||||
renderWest(tile, 0, 0, 0, tile->getTexture(4));
|
||||
|
||||
t.normal(1.0f, 0.0f, 0.0f);
|
||||
renderEast(tile, 0, 0, 0, tile->getTexture(5));
|
||||
}
|
||||
t.draw();
|
||||
@@ -2396,12 +2455,23 @@ void TileRenderer::renderTile( Tile* tile, int data )
|
||||
if (i == 2) tile->setShape(0.5f - w, 1 - w * 3, -w * 2, 0.5f + w, 1 - w, 1 + w * 2);
|
||||
if (i == 3) tile->setShape(0.5f - w, 0.5f - w * 3, -w * 2, 0.5f + w, 0.5f - w, 1 + w * 2);
|
||||
|
||||
renderFaceDown(tile, 0, 0, 0, tile->getTexture(0));
|
||||
renderFaceUp(tile, 0, 0, 0, tile->getTexture(1));
|
||||
renderNorth(tile, 0, 0, 0, tile->getTexture(2));
|
||||
renderSouth(tile, 0, 0, 0, tile->getTexture(3));
|
||||
renderWest(tile, 0, 0, 0, tile->getTexture(4));
|
||||
renderEast(tile, 0, 0, 0, tile->getTexture(5));
|
||||
t.normal(0.0f, -1.0f, 0.0f);
|
||||
renderFaceDown(tile, 0, 0, 0, tile->getTexture(0));
|
||||
|
||||
t.normal(0.0f, 1.0f, 0.0f);
|
||||
renderFaceUp(tile, 0, 0, 0, tile->getTexture(1));
|
||||
|
||||
t.normal(0.0f, 0.0f, -1.0f);
|
||||
renderNorth(tile, 0, 0, 0, tile->getTexture(2));
|
||||
|
||||
t.normal(0.0f, 0.0f, 1.0f);
|
||||
renderSouth(tile, 0, 0, 0, tile->getTexture(3));
|
||||
|
||||
t.normal(-1.0f, 0.0f, 0.0f);
|
||||
renderWest(tile, 0, 0, 0, tile->getTexture(4));
|
||||
|
||||
t.normal(1.0f, 0.0f, 0.0f);
|
||||
renderEast(tile, 0, 0, 0, tile->getTexture(5));
|
||||
}
|
||||
t.draw();
|
||||
t.addOffset(0.5f, 0.5f, 0.5f);
|
||||
@@ -2415,12 +2485,23 @@ void TileRenderer::renderTile( Tile* tile, int data )
|
||||
if (i == 1) tile->setShape(0.5f - w, .3f, 1 - w * 2, 0.5f + w, 1, 1);
|
||||
if (i == 2) tile->setShape(0.5f - w, .5f, w * 2, 0.5f + w, 1 - w, 1 - w * 2);
|
||||
|
||||
renderFaceUp(tile, 0, 0, 0, tile->getTexture(0));
|
||||
renderFaceDown(tile, 0, 0, 0, tile->getTexture(1));
|
||||
renderNorth(tile, 0, 0, 0, tile->getTexture(2));
|
||||
renderSouth(tile, 0, 0, 0, tile->getTexture(3));
|
||||
renderWest(tile, 0, 0, 0, tile->getTexture(4));
|
||||
renderEast(tile, 0, 0, 0, tile->getTexture(5));
|
||||
t.normal(0.0f, -1.0f, 0.0f);
|
||||
renderFaceDown(tile, 0, 0, 0, tile->getTexture(0));
|
||||
|
||||
t.normal(0.0f, 1.0f, 0.0f);
|
||||
renderFaceUp(tile, 0, 0, 0, tile->getTexture(1));
|
||||
|
||||
t.normal(0.0f, 0.0f, -1.0f);
|
||||
renderNorth(tile, 0, 0, 0, tile->getTexture(2));
|
||||
|
||||
t.normal(0.0f, 0.0f, 1.0f);
|
||||
renderSouth(tile, 0, 0, 0, tile->getTexture(3));
|
||||
|
||||
t.normal(-1.0f, 0.0f, 0.0f);
|
||||
renderWest(tile, 0, 0, 0, tile->getTexture(4));
|
||||
|
||||
t.normal(1.0f, 0.0f, 0.0f);
|
||||
renderEast(tile, 0, 0, 0, tile->getTexture(5));
|
||||
}
|
||||
t.draw();
|
||||
t.addOffset(0.5f, 0.5f, 0.5f);
|
||||
@@ -2469,7 +2550,7 @@ void TileRenderer::renderGuiTile( Tile* tile, int data )
|
||||
|
||||
} else if (shape == Tile::SHAPE_CROSS_TEXTURE) {
|
||||
t.begin();
|
||||
//t.normal(0, -1, 0);
|
||||
t.normal(0, -1, 0);
|
||||
tesselateCrossTexture(tile, data, -0.5f, -0.5f, -0.5f);
|
||||
//t.end();
|
||||
t.draw();
|
||||
|
||||
@@ -14,7 +14,8 @@ typedef struct VertexDeclPTCN
|
||||
GLfloat x, y, z;
|
||||
GLfloat u, v;
|
||||
GLuint color;
|
||||
GLuint normal;
|
||||
// GLuint normal; // trying a new thing
|
||||
GLfloat nx, ny, nz;
|
||||
|
||||
} VertexDeclPTCN;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "../../Minecraft.h"
|
||||
#include "../../Option.h"
|
||||
|
||||
#include "../Lighting.h"
|
||||
EntityRenderDispatcher* EntityRenderer::entityRenderDispatcher = NULL;
|
||||
|
||||
EntityRenderer::EntityRenderer()
|
||||
@@ -134,7 +135,7 @@ void EntityRenderer::postRender(Entity* entity, float x, float y, float z, float
|
||||
}
|
||||
}
|
||||
void EntityRenderer::renderFlame(Entity* e, float x, float y, float z, float a) {
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
int tex = ((Tile*)Tile::fire)->tex;
|
||||
|
||||
int xt = (tex & 0xf) << 4;
|
||||
@@ -176,7 +177,7 @@ void EntityRenderer::renderFlame(Entity* e, float x, float y, float z, float a)
|
||||
}
|
||||
t.draw();
|
||||
glPopMatrix2();
|
||||
// glEnable2(GL_LIGHTING);
|
||||
glEnable2(GL_LIGHTING);
|
||||
}
|
||||
|
||||
void EntityRenderer::renderShadow(Entity* e, float x, float y, float z, float pow, float a) { //
|
||||
@@ -186,10 +187,9 @@ void EntityRenderer::renderShadow(Entity* e, float x, float y, float z, float po
|
||||
//Textures* textures = entityRenderDispatcher->textures;
|
||||
//textures->bind(textures->loadTexture("%clamp%/environment/shadow.png"));
|
||||
Textures* textures = entityRenderDispatcher->textures;
|
||||
textures->bind(textures->loadTexture("/misc/shadow.png"));
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
|
||||
|
||||
Level* level = getLevel();
|
||||
|
||||
@@ -221,6 +221,9 @@ void EntityRenderer::renderShadow(Entity* e, float x, float y, float z, float po
|
||||
renderTileShadow(Tile::tiles[t], x, y + e->getShadowHeightOffs(), z, xt, yt, zt, pow, r, xo, yo + e->getShadowHeightOffs(), zo);
|
||||
}
|
||||
}
|
||||
textures->loadAndBindTexture(("/misc/shadow.png"));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
tt.draw();
|
||||
|
||||
glColor4f2(1, 1, 1, 1);
|
||||
|
||||
@@ -45,7 +45,7 @@ void ItemRenderer::render(Entity* itemEntity_, float x, float y, float z, float
|
||||
else if (item->count > 1) count = 2;
|
||||
|
||||
glTranslatef2((float) x, (float) y + bob, (float) z);
|
||||
//glEnable2(GL_RESCALE_NORMAL);
|
||||
glEnable2(GL_RESCALE_NORMAL);
|
||||
if (item->id < 256 && TileRenderer::canRender(Tile::tiles[item->id]->getRenderShape())) {
|
||||
glRotatef2(spin, 0, 1, 0);
|
||||
|
||||
@@ -107,7 +107,7 @@ void ItemRenderer::render(Entity* itemEntity_, float x, float y, float z, float
|
||||
}
|
||||
glRotatef2(180 - entityRenderDispatcher->playerRotY, 0, 1, 0);
|
||||
t.begin();
|
||||
//t.normal(0, 1, 0);
|
||||
t.normal(0, 1, 0);
|
||||
t.vertexUV(0 - xo, 0 - yo, 0, u0, v1);
|
||||
t.vertexUV(r - xo, 0 - yo, 0, u1, v1);
|
||||
t.vertexUV(r - xo, 1 - yo, 0, u1, v0);
|
||||
@@ -118,7 +118,7 @@ void ItemRenderer::render(Entity* itemEntity_, float x, float y, float z, float
|
||||
glPopMatrix2();
|
||||
}
|
||||
}
|
||||
//glDisable2(GL_RESCALE_NORMAL);
|
||||
glDisable2(GL_RESCALE_NORMAL);
|
||||
glPopMatrix2();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ void PaintingRenderer::render( Entity* entity, float x, float y, float z, float
|
||||
glPushMatrix();
|
||||
glTranslatef(float(x), float(y), float(z));
|
||||
glRotatef(rot, 0, 1.0f, 0);
|
||||
//glEnable(GL_RESCALE_NORMAL);
|
||||
glEnable(GL_RESCALE_NORMAL);
|
||||
bindTexture("art/kz.png");
|
||||
Painting* painting = (Painting*)entity;
|
||||
const Motive* motive = painting->motive;
|
||||
@@ -17,7 +17,7 @@ void PaintingRenderer::render( Entity* entity, float x, float y, float z, float
|
||||
float s = 1.0f / 16.0f;
|
||||
glScalef(s, s, s);
|
||||
renderPainting(painting, motive->w, motive->h, motive->uo, motive->vo, a);
|
||||
//glDisable(GL_RESCALE_NORMAL);
|
||||
glDisable(GL_RESCALE_NORMAL);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
@@ -77,10 +77,10 @@ void PlayerRenderer::render(Entity* mob_, float x, float y, float z, float rot,
|
||||
model = desired;
|
||||
humanoidModel = desired;
|
||||
}
|
||||
LOGI("[PlayerRenderer] %s: skin=%s, modelTex=%dx%d, desired=%s\n",
|
||||
((Player*)mob)->name.c_str(), mob->getTexture().c_str(),
|
||||
humanoidModel->texWidth, humanoidModel->texHeight,
|
||||
(desired == playerModel64 ? "64" : "32"));
|
||||
// LOGI("[PlayerRenderer] %s: skin=%s, modelTex=%dx%d, desired=%s\n", // don't log it always, only for debug - shredder
|
||||
// ((Player*)mob)->name.c_str(), mob->getTexture().c_str(),
|
||||
// humanoidModel->texWidth, humanoidModel->texHeight,
|
||||
// (desired == playerModel64 ? "64" : "32"));
|
||||
HumanoidMobRenderer::render(mob_, x, y, z, rot, a);
|
||||
}
|
||||
|
||||
|
||||
@@ -115,6 +115,41 @@ void drawArrayVTC_NoState(int bufferId, int vertices, int vertexSize /* = 24 */)
|
||||
}
|
||||
#endif
|
||||
|
||||
void drawArrayVTN(int bufferId, int vertices, int vertexSize /* = 24 */) {
|
||||
//if (Options::debugGl) LOGI("drawArray\n");
|
||||
//LOGI("draw-vtc: %d, %d, %d\n", bufferId, vertices, vertexSize);
|
||||
glEnableClientState2(GL_VERTEX_ARRAY);
|
||||
glEnableClientState2(GL_TEXTURE_COORD_ARRAY);
|
||||
//glEnableClientState2(GL_COLOR_ARRAY);
|
||||
glEnableClientState2(GL_NORMAL_ARRAY);
|
||||
|
||||
glBindBuffer2(GL_ARRAY_BUFFER, bufferId);
|
||||
|
||||
glVertexPointer2( 3, GL_FLOAT, vertexSize, 0);
|
||||
glTexCoordPointer2(2, GL_FLOAT, vertexSize, (GLvoid*) (3 * 4));
|
||||
//glColorPointer2(4, GL_UNSIGNED_BYTE, vertexSize, (GLvoid*) (5*4));
|
||||
glNormalPointer(GL_FLOAT, vertexSize, (GLvoid*) (6 * 4));
|
||||
|
||||
glDrawArrays2(GL_TRIANGLES, 0, vertices);
|
||||
|
||||
glDisableClientState2(GL_VERTEX_ARRAY);
|
||||
glDisableClientState2(GL_TEXTURE_COORD_ARRAY);
|
||||
//glDisableClientState2(GL_COLOR_ARRAY);
|
||||
glDisableClientState2(GL_NORMAL_ARRAY);
|
||||
}
|
||||
|
||||
#ifndef drawArrayVTN_NoState
|
||||
void drawArrayVTCN_NoState(int bufferId, int vertices, int vertexSize /* = 24 */) {
|
||||
glBindBuffer2(GL_ARRAY_BUFFER, bufferId);
|
||||
|
||||
glVertexPointer2( 3, GL_FLOAT, vertexSize, 0);
|
||||
glTexCoordPointer2(2, GL_FLOAT, vertexSize, (GLvoid*) (3 * 4));
|
||||
//glColorPointer2(4, GL_UNSIGNED_BYTE, vertexSize, (GLvoid*) (5*4));
|
||||
glNormalPointer(GL_FLOAT, vertexSize, (GLvoid*) (6 * 4));
|
||||
|
||||
glDrawArrays2(GL_TRIANGLES, 0, vertices);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -4,11 +4,15 @@
|
||||
#include "../../platform/log.h"
|
||||
#include "../Options.h"
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#define GLES_SILENCE_DEPRECATION
|
||||
#endif
|
||||
|
||||
// Android should always run OPENGL_ES
|
||||
#if defined(ANDROID) || defined(__APPLE__) || defined(RPI)
|
||||
#define OPENGL_ES
|
||||
#endif
|
||||
|
||||
#define GLES_SILENCE_DEPRECATION
|
||||
// Other systems might run it, if they #define OPENGL_ES
|
||||
// #if defined(OPENGL_ES) // || defined(ANDROID)
|
||||
#define USE_VBO
|
||||
@@ -55,13 +59,18 @@ void anGenBuffers(GLsizei n, GLuint* buffer);
|
||||
#ifdef USE_VBO
|
||||
#define drawArrayVT_NoState drawArrayVT
|
||||
#define drawArrayVTC_NoState drawArrayVTC
|
||||
void drawArrayVT(int bufferId, int vertices, int vertexSize = 24, unsigned int mode = GL_TRIANGLES);
|
||||
#define drawArrayVTN_NoState drawArrayVTN
|
||||
void drawArrayVT(int bufferId, int vertices, int vertexSize = 36, unsigned int mode = GL_TRIANGLES);
|
||||
#ifndef drawArrayVT_NoState
|
||||
//void drawArrayVT_NoState(int bufferId, int vertices, int vertexSize = 24);
|
||||
//void drawArrayVT_NoState(int bufferId, int vertices, int vertexSize = 36);
|
||||
#endif
|
||||
void drawArrayVTC(int bufferId, int vertices, int vertexSize = 24);
|
||||
void drawArrayVTC(int bufferId, int vertices, int vertexSize = 36);
|
||||
#ifndef drawArrayVTC_NoState
|
||||
void drawArrayVTC_NoState(int bufferId, int vertices, int vertexSize = 24);
|
||||
void drawArrayVTC_NoState(int bufferId, int vertices, int vertexSize = 36);
|
||||
#endif
|
||||
void drawArrayVTN(int bufferId, int vertices, int vertexSize = 36);
|
||||
#ifndef drawArrayVTN_NoState
|
||||
void drawArrayVTCN_NoState(int bufferId, int vertices, int vertexSize = 36);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -114,6 +123,7 @@ int glhUnProjectf( float winx, float winy, float winz,
|
||||
#define glVertexPointer2 glVertexPointer
|
||||
#define glColorPointer2 glColorPointer
|
||||
#define glTexCoordPointer2 glTexCoordPointer
|
||||
#define glNormalPointer2 glNormalPointer
|
||||
#define glEnableClientState2 glEnableClientState
|
||||
#define glDisableClientState2 glDisableClientState
|
||||
#define glDrawArrays2 glDrawArrays
|
||||
@@ -137,7 +147,7 @@ int glhUnProjectf( float winx, float winy, float winz,
|
||||
//
|
||||
// Extensions
|
||||
//
|
||||
#ifdef WIN32
|
||||
#ifdef WIN32
|
||||
#define glGetProcAddress(a) wglGetProcAddress(a)
|
||||
#else
|
||||
#define glGetProcAddress(a) (void*(0))
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// DynamicTexture
|
||||
//
|
||||
DynamicTexture::DynamicTexture(int tex_)
|
||||
: tex(tex_),
|
||||
: tex(tex_),
|
||||
replicate(1)
|
||||
{
|
||||
memset(pixels, 0, 16*16*4);
|
||||
@@ -29,8 +29,8 @@ void DynamicTexture::bindTexture(Textures* tex) {
|
||||
/*
|
||||
WaterTexture::WaterTexture()
|
||||
: super(Tile::water->tex),
|
||||
_tick(0),
|
||||
_frame(0)
|
||||
_tick(0),
|
||||
_frame(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ void WaterTexture::tick() {
|
||||
*/
|
||||
|
||||
WaterTexture::WaterTexture()
|
||||
: super(Tile::water->tex),
|
||||
: super(Tile::water->tex),
|
||||
_tick(0),
|
||||
_frame(0)
|
||||
{
|
||||
@@ -76,55 +76,55 @@ void WaterTexture::tick()
|
||||
next[x + y * 16] = pow / 3.3f + heat[x + y * 16] * 0.8f;
|
||||
}
|
||||
|
||||
for (int x = 0; x < 16; x++)
|
||||
for (int y = 0; y < 16; y++) {
|
||||
heat[x + y * 16] += heata[x + y * 16] * 0.05f;
|
||||
for (int x = 0; x < 16; x++)
|
||||
for (int y = 0; y < 16; y++) {
|
||||
heat[x + y * 16] += heata[x + y * 16] * 0.05f;
|
||||
|
||||
if (heat[x + y * 16] < 0) heat[x + y * 16] = 0;
|
||||
heata[x + y * 16] -= 0.1f;
|
||||
if (Mth::random() < 0.05f) {
|
||||
heata[x + y * 16] = 0.5f;
|
||||
if (heat[x + y * 16] < 0) heat[x + y * 16] = 0;
|
||||
heata[x + y * 16] -= 0.1f;
|
||||
if (Mth::random() < 0.05f) {
|
||||
heata[x + y * 16] = 0.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float* tmp = next;
|
||||
next = current;
|
||||
current = tmp;
|
||||
float* tmp = next;
|
||||
next = current;
|
||||
current = tmp;
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
float pow = current[i];
|
||||
if (pow > 1) pow = 1;
|
||||
if (pow < 0) pow = 0;
|
||||
for (int i = 0; i < 256; i++) {
|
||||
float pow = current[i];
|
||||
if (pow > 1) pow = 1;
|
||||
if (pow < 0) pow = 0;
|
||||
|
||||
float pp = pow * pow;
|
||||
float pp = pow * pow;
|
||||
|
||||
int r = (int) (32 + pp * 32);
|
||||
int g = (int) (50 + pp * 64);
|
||||
int b = (int) (255);
|
||||
int a = (int) (146 + pp * 50);
|
||||
int r = (int) (32 + pp * 32);
|
||||
int g = (int) (50 + pp * 64);
|
||||
int b = (int) (255);
|
||||
int a = (int) (146 + pp * 50);
|
||||
|
||||
//if (anaglyph3d) {
|
||||
// int rr = (r * 30 + g * 59 + b * 11) / 100;
|
||||
// int gg = (r * 30 + g * 70) / (100);
|
||||
// int bb = (r * 30 + b * 70) / (100);
|
||||
//if (anaglyph3d) {
|
||||
// int rr = (r * 30 + g * 59 + b * 11) / 100;
|
||||
// int gg = (r * 30 + g * 70) / (100);
|
||||
// int bb = (r * 30 + b * 70) / (100);
|
||||
|
||||
// r = rr;
|
||||
// g = gg;
|
||||
// b = bb;
|
||||
//}
|
||||
// r = rr;
|
||||
// g = gg;
|
||||
// b = bb;
|
||||
//}
|
||||
|
||||
pixels[i * 4 + 0] = r;
|
||||
pixels[i * 4 + 1] = g;
|
||||
pixels[i * 4 + 2] = b;
|
||||
pixels[i * 4 + 3] = a;
|
||||
}
|
||||
pixels[i * 4 + 0] = r;
|
||||
pixels[i * 4 + 1] = g;
|
||||
pixels[i * 4 + 2] = b;
|
||||
pixels[i * 4 + 3] = a;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// WaterSideTexture
|
||||
//
|
||||
WaterSideTexture::WaterSideTexture()
|
||||
: super(Tile::water->tex + 1),
|
||||
: super(Tile::water->tex + 1),
|
||||
_tick(0),
|
||||
_frame(0),
|
||||
_tickCount(0)
|
||||
@@ -164,51 +164,237 @@ void WaterSideTexture::tick() {
|
||||
next[x + y * 16] = pow / 3.2f + heat[x + y * 16] * 0.8f;
|
||||
}
|
||||
|
||||
for (int x = 0; x < 16; x++)
|
||||
for (int y = 0; y < 16; y++) {
|
||||
heat[x + y * 16] += heata[x + y * 16] * 0.05f;
|
||||
for (int x = 0; x < 16; x++)
|
||||
for (int y = 0; y < 16; y++) {
|
||||
heat[x + y * 16] += heata[x + y * 16] * 0.05f;
|
||||
|
||||
if (heat[x + y * 16] < 0) heat[x + y * 16] = 0;
|
||||
heata[x + y * 16] -= 0.3f;
|
||||
if (Mth::random() < 0.2) {
|
||||
heata[x + y * 16] = 0.5f;
|
||||
if (heat[x + y * 16] < 0) heat[x + y * 16] = 0;
|
||||
heata[x + y * 16] -= 0.3f;
|
||||
if (Mth::random() < 0.2) {
|
||||
heata[x + y * 16] = 0.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
float* tmp = next;
|
||||
next = current;
|
||||
current = tmp;
|
||||
float* tmp = next;
|
||||
next = current;
|
||||
current = tmp;
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
float pow = current[(i - _tickCount * 16) & 255];
|
||||
if (pow > 1) pow = 1;
|
||||
if (pow < 0) pow = 0;
|
||||
for (int i = 0; i < 256; i++) {
|
||||
float pow = current[(i - _tickCount * 16) & 255];
|
||||
if (pow > 1) pow = 1;
|
||||
if (pow < 0) pow = 0;
|
||||
|
||||
float pp = pow * pow;
|
||||
float pp = pow * pow;
|
||||
|
||||
int r = (int) (32 + pp * 32);
|
||||
int g = (int) (50 + pp * 64);
|
||||
int b = (int) (255);
|
||||
int a = (int) (146 + pp * 50);
|
||||
int r = (int) (32 + pp * 32);
|
||||
int g = (int) (50 + pp * 64);
|
||||
int b = (int) (255);
|
||||
int a = (int) (146 + pp * 50);
|
||||
|
||||
//if (anaglyph3d) {
|
||||
// int rr = (r * 30 + g * 59 + b * 11) / 100;
|
||||
// int gg = (r * 30 + g * 70) / (100);
|
||||
// int bb = (r * 30 + b * 70) / (100);
|
||||
//if (anaglyph3d) {
|
||||
// int rr = (r * 30 + g * 59 + b * 11) / 100;
|
||||
// int gg = (r * 30 + g * 70) / (100);
|
||||
// int bb = (r * 30 + b * 70) / (100);
|
||||
|
||||
// r = rr;
|
||||
// g = gg;
|
||||
// b = bb;
|
||||
//}
|
||||
// r = rr;
|
||||
// g = gg;
|
||||
// b = bb;
|
||||
//}
|
||||
|
||||
pixels[i * 4 + 0] = r;
|
||||
pixels[i * 4 + 1] = g;
|
||||
pixels[i * 4 + 2] = b;
|
||||
pixels[i * 4 + 3] = a;
|
||||
pixels[i * 4 + 0] = r;
|
||||
pixels[i * 4 + 1] = g;
|
||||
pixels[i * 4 + 2] = b;
|
||||
pixels[i * 4 + 3] = a;
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Lava Texture
|
||||
///
|
||||
|
||||
LavaTexture::LavaTexture()
|
||||
: super(Tile::lava->tex),
|
||||
_tick(0),
|
||||
_frame(0)
|
||||
{
|
||||
current = new float[16*16];
|
||||
next = new float[16*16];
|
||||
heat = new float[16*16];
|
||||
heata = new float[16*16];
|
||||
|
||||
for (int i = 0; i < 256; ++i) {
|
||||
current[i] = 0;
|
||||
next[i] = 0;
|
||||
heat[i] = 0;
|
||||
heata[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
LavaTexture::~LavaTexture() {
|
||||
delete[] current;
|
||||
delete[] next;
|
||||
delete[] heat;
|
||||
delete[] heata;
|
||||
}
|
||||
|
||||
void LavaTexture::tick()
|
||||
{
|
||||
for (int x = 0; x < 16; x++)
|
||||
for (int y = 0; y < 16; y++) {
|
||||
float pow = 0;
|
||||
int xxo = (int)(Mth::sin((float)(y) * (float)(Mth::PI) * 2.0f / 16.0f) * 1.2f);
|
||||
int yyo = (int)(Mth::sin((float)(x) * (float)(Mth::PI) * 2.0f / 16.0f) * 1.2f);
|
||||
for (int xx = x - 1; xx <= x + 1; xx++) {
|
||||
for (int yy = y - 1; yy <= y + 1; yy++) {
|
||||
int xi = xx + xxo & 15;
|
||||
int yi = yy + yyo & 15;
|
||||
pow += current[xi + yi * 16];
|
||||
}
|
||||
}
|
||||
next[x + y * 16] = pow / 10.0f + (heat[(x + 0 & 15) + (y + 0 & 15) * 16] + heat[(x + 1 & 15) + (y + 0 & 15) * 16] + heat[(x + 1 & 15) + (y + 1 & 15) * 16] + heat[(x + 0 & 15) + (y + 1 & 15) * 16]) / 4.0f * 0.8f;
|
||||
heat[x + y * 16] = heat[x + y * 16] + heata[x + y * 16] * 0.01f;
|
||||
if (heat[x + y * 16] < 0.0f) {
|
||||
heat[x + y * 16] = 0.0f;
|
||||
}
|
||||
heata[x + y * 16] = heata[x + y * 16] - 0.06f;
|
||||
if (Mth::random() < 0.005) {
|
||||
heata[x + y * 16] = 1.5f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float* tmp = next;
|
||||
next = current;
|
||||
current = tmp;
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
float pow = current[i] * 2.0f;
|
||||
if (pow > 1) pow = 1;
|
||||
if (pow < 0) pow = 0;
|
||||
|
||||
float pp = pow * pow;
|
||||
|
||||
int r = (int) (pow * 100.0f + 155.0f);
|
||||
int g = (int) (pp * 255.0f);
|
||||
int b = (int) (pp * pp * 128.0f);
|
||||
|
||||
//if (anaglyph3d) {
|
||||
// int rr = (r * 30 + g * 59 + b * 11) / 100;
|
||||
// int gg = (r * 30 + g * 70) / (100);
|
||||
// int bb = (r * 30 + b * 70) / (100);
|
||||
|
||||
// r = rr;
|
||||
// g = gg;
|
||||
// b = bb;
|
||||
//}
|
||||
|
||||
pixels[i * 4 + 0] = r;
|
||||
pixels[i * 4 + 1] = g;
|
||||
pixels[i * 4 + 2] = b;
|
||||
pixels[i * 4 + 3] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Lava Side Texture
|
||||
///
|
||||
|
||||
LavaSideTexture::LavaSideTexture()
|
||||
: super(Tile::lava->tex + 1),
|
||||
_tick(0),
|
||||
_frame(0),
|
||||
_tickCount(0)
|
||||
{
|
||||
replicate = 2;
|
||||
|
||||
current = new float[16*16];
|
||||
next = new float[16*16];
|
||||
heat = new float[16*16];
|
||||
heata = new float[16*16];
|
||||
|
||||
for (int i = 0; i < 256; ++i) {
|
||||
current[i] = 0;
|
||||
next[i] = 0;
|
||||
heat[i] = 0;
|
||||
heata[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
LavaSideTexture::~LavaSideTexture() {
|
||||
delete[] current;
|
||||
delete[] next;
|
||||
delete[] heat;
|
||||
delete[] heata;
|
||||
}
|
||||
|
||||
void LavaSideTexture::tick() {
|
||||
++_tickCount;
|
||||
for (int x = 0; x < 16; x++)
|
||||
for (int y = 0; y < 16; y++) {
|
||||
float pow = 0;
|
||||
int yl = (int)(Mth::sin((float)(y) * (float)(Mth::PI)* 2.0f / 16.0f) * 1.2f); // var2 is y
|
||||
int xl = (int)(Mth::sin((float)(x) * (float)(Mth::PI)* 2.0f / 16.0f) * 1.2f); // var1 is x
|
||||
for (int yy = x - 1; yy <= x + 1; yy++) {
|
||||
for (int xx = y - 1; xx <= y + 1; xx++) {
|
||||
int xi = (yy + yl) & 15; // var8
|
||||
int yi = (xx + xl) & 15; //var9
|
||||
pow += current[xi + yi * 16];
|
||||
}
|
||||
}
|
||||
next[x + y * 16] =
|
||||
next[x + y * 16] =
|
||||
pow / 10.0f + (
|
||||
heat[(x + 0 & 15) + (y + 0 & 15) *
|
||||
16] + heat[
|
||||
(x + 1 & 15) + (y + 0 & 15) * 16] + heat[(x + 1 & 15) + (y + 1 & 15) *
|
||||
16] + heat[
|
||||
(x + 0 & 15) + (y + 1 & 15) * 16]) / 4.0f
|
||||
* 0.8f;
|
||||
heat[x + y * 16] = heat[x + y * 16] + heata[x + y * 16] * 0.01f;
|
||||
|
||||
if (heat[x + y * 16] < 0.0f) {
|
||||
heat[x + y * 16] = 0.0f;
|
||||
}
|
||||
heata[x + y * 16] = heata[x + y * 16] - 0.06f;
|
||||
|
||||
if (Mth::random() < 0.005) {
|
||||
heata[x + y * 16] = 1.5f;
|
||||
}
|
||||
}
|
||||
float* tmp = next;
|
||||
next = current;
|
||||
current = tmp;
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
float pow = current[(i - _tickCount / 3 * 16) & 255] * 2.0f;
|
||||
if (pow > 1) pow = 1;
|
||||
if (pow < 0) pow = 0;
|
||||
|
||||
float pp = pow * pow;
|
||||
|
||||
int r = (int) (pow * 100.0f + 155.0f);
|
||||
int g = (int) (pow * pow * 255.0f);
|
||||
int b = (int) (pow * pow * pow * pow * 128.0f);
|
||||
// int a = (int) (146 + pp * 50);
|
||||
|
||||
//if (anaglyph3d) {
|
||||
// int rr = (r * 30 + g * 59 + b * 11) / 100;
|
||||
// int gg = (r * 30 + g * 70) / (100);
|
||||
// int bb = (r * 30 + b * 70) / (100);
|
||||
|
||||
// r = rr;
|
||||
// g = gg;
|
||||
// b = bb;
|
||||
//}
|
||||
|
||||
pixels[i * 4 + 0] = r;
|
||||
pixels[i * 4 + 1] = g;
|
||||
pixels[i * 4 + 2] = b;
|
||||
pixels[i * 4 + 3] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
FireTexture::FireTexture()
|
||||
: super(((Tile*)Tile::fire)->tex),
|
||||
: super(((Tile*)Tile::fire)->tex),
|
||||
_tick(0),
|
||||
_frame(0)
|
||||
{
|
||||
@@ -236,63 +422,63 @@ FireTexture::~FireTexture() {
|
||||
// oh boy time to implement fire textures, i am so fucked - shredder
|
||||
|
||||
void FireTexture::tick() {
|
||||
// loop generates fire texture on the empty texture grid, hopefully shouldnt be too taxing on older hardware - shredder
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int y = 0; y < 20; y++) {
|
||||
int count = 18;
|
||||
float pow = this->current[x + (y + 1) % 20 * 16] * (float)(count);
|
||||
for (int xx = x - 1; xx <= x + 1; xx++) {
|
||||
for (int yy = y; yy <= y + 1; yy++) {
|
||||
if (xx >= 0 && yy >= 0 && xx < 16 && yy < 20) {
|
||||
pow += this->current[xx + yy * 16];
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
this->next[x + y * 16] = pow / (float(count) * 1.06f);
|
||||
if (y >= 19) {
|
||||
this->next[x + y * 16] = float(Mth::random() * Mth::random() * Mth::random() * 4.0 + Mth::random() * 0.1f + 0.2f);
|
||||
}
|
||||
}
|
||||
}
|
||||
// loop generates fire texture on the empty texture grid, hopefully shouldnt be too taxing on older hardware - shredder
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int y = 0; y < 20; y++) {
|
||||
int count = 18;
|
||||
float pow = this->current[x + (y + 1) % 20 * 16] * (float)(count);
|
||||
for (int xx = x - 1; xx <= x + 1; xx++) {
|
||||
for (int yy = y; yy <= y + 1; yy++) {
|
||||
if (xx >= 0 && yy >= 0 && xx < 16 && yy < 20) {
|
||||
pow += this->current[xx + yy * 16];
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
this->next[x + y * 16] = pow / (float(count) * 1.06f);
|
||||
if (y >= 19) {
|
||||
this->next[x + y * 16] = float(Mth::random() * Mth::random() * Mth::random() * 4.0 + Mth::random() * 0.1f + 0.2f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// hopefully this doesn't cause any mysterious issues - shredder
|
||||
// hopefully this doesn't cause any mysterious issues - shredder
|
||||
float* tmp = next;
|
||||
next = current;
|
||||
current = tmp;
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
float pow = this->current[i] * 1.8f;
|
||||
if (pow > 1.0f) {
|
||||
pow = 1.0f;
|
||||
}
|
||||
if (pow < 0.0f) {
|
||||
pow = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
int r = (int) (pow * 155.0f + 100.0f);
|
||||
int g = (int)(pow * pow * 255.0f);
|
||||
int b = (int)(pow * pow * pow * pow * pow * pow * pow * pow * pow * pow * 255.0f);
|
||||
int a = 255;
|
||||
if (pow < 0.5f) {
|
||||
a = 0;
|
||||
}
|
||||
for (int i = 0; i < 256; i++) {
|
||||
float pow = this->current[i] * 1.8f;
|
||||
if (pow > 1.0f) {
|
||||
pow = 1.0f;
|
||||
}
|
||||
if (pow < 0.0f) {
|
||||
pow = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
int r = (int) (pow * 155.0f + 100.0f);
|
||||
int g = (int)(pow * pow * 255.0f);
|
||||
int b = (int)(pow * pow * pow * pow * pow * pow * pow * pow * pow * pow * 255.0f);
|
||||
int a = 255;
|
||||
if (pow < 0.5f) {
|
||||
a = 0;
|
||||
}
|
||||
|
||||
// @TODO: cant be arsed rn to implement the anaglyph3d check would be nice to check if it does - shredder
|
||||
//if (this->anaglyph3d) {
|
||||
// float rr = (r * 30 + g * 59 + b * 11) / 100;
|
||||
// float gg = (r * 30 + g * 70) / 100;
|
||||
// float bb = (r * 30 + b * 70) / 100;
|
||||
// r = rr;
|
||||
// g = gg;
|
||||
// b = bb;
|
||||
//}
|
||||
//if (this->anaglyph3d) {
|
||||
// float rr = (r * 30 + g * 59 + b * 11) / 100;
|
||||
// float gg = (r * 30 + g * 70) / 100;
|
||||
// float bb = (r * 30 + b * 70) / 100;
|
||||
// r = rr;
|
||||
// g = gg;
|
||||
// b = bb;
|
||||
//}
|
||||
|
||||
pixels[i * 4 + 0] = r;
|
||||
pixels[i * 4 + 1] = g;
|
||||
pixels[i * 4 + 2] = b;
|
||||
pixels[i * 4 + 3] = a;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,44 @@ public:
|
||||
void tick();
|
||||
};
|
||||
|
||||
class LavaTexture: public DynamicTexture
|
||||
{
|
||||
typedef DynamicTexture super;
|
||||
int _tick;
|
||||
int _frame;
|
||||
|
||||
float* current;
|
||||
float* next;
|
||||
float* heat;
|
||||
float* heata;
|
||||
|
||||
public:
|
||||
LavaTexture();
|
||||
~LavaTexture();
|
||||
|
||||
void tick();
|
||||
};
|
||||
|
||||
class LavaSideTexture: public DynamicTexture
|
||||
{
|
||||
typedef DynamicTexture super;
|
||||
int _tick;
|
||||
int _frame;
|
||||
int _tickCount;
|
||||
|
||||
float* current;
|
||||
float* next;
|
||||
float* heat;
|
||||
float* heata;
|
||||
|
||||
public:
|
||||
LavaSideTexture();
|
||||
~LavaSideTexture();
|
||||
|
||||
void tick();
|
||||
};
|
||||
|
||||
|
||||
class FireTexture: public DynamicTexture
|
||||
{
|
||||
typedef DynamicTexture super;
|
||||
|
||||
@@ -191,8 +191,13 @@ int main(void) {
|
||||
App* app = new MAIN_CLASS();
|
||||
|
||||
g_app = app;
|
||||
#ifdef __HAIKU__
|
||||
((MAIN_CLASS*)g_app)->externalStoragePath = "/system/settings/minecraftpe";
|
||||
((MAIN_CLASS*)g_app)->externalCacheStoragePath = "/system/settings/minecraftpe";
|
||||
#else
|
||||
((MAIN_CLASS*)g_app)->externalStoragePath = ".";
|
||||
((MAIN_CLASS*)g_app)->externalCacheStoragePath = ".";
|
||||
#endif
|
||||
g_app->init(appContext);
|
||||
g_app->setSize(appContext.platform->getScreenWidth(), appContext.platform->getScreenHeight());
|
||||
|
||||
|
||||
@@ -31,6 +31,13 @@
|
||||
pthread_attr_init(&m_attributes);
|
||||
pthread_attr_setdetachstate( &m_attributes, PTHREAD_CREATE_DETACHED );
|
||||
/*int error =*/ pthread_create(&m_thread, &m_attributes, mp_threadFunc, threadParam);
|
||||
#endif
|
||||
#if defined(__HAIKU__)
|
||||
|
||||
mp_threadFunc = (thread_func)threadFunc;
|
||||
m_thread = spawn_thread(mp_threadFunc, "CThread", 10, threadParam);
|
||||
int res = resume_thread(m_thread);
|
||||
|
||||
#endif
|
||||
#ifdef MACOSX
|
||||
mp_threadFunc = (TaskProc) threadFunc;
|
||||
@@ -56,6 +63,9 @@
|
||||
#if defined(LINUX) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX)
|
||||
usleep(millis * 1000);
|
||||
#endif
|
||||
#if defined(__HAIKU__)
|
||||
snooze((bigtime_t)(millis * 1000));
|
||||
#endif
|
||||
}
|
||||
|
||||
CThread::~CThread()
|
||||
@@ -68,6 +78,9 @@
|
||||
// and causes SIGABRT when the pthread_t is no longer valid.
|
||||
pthread_attr_destroy(&m_attributes);
|
||||
#endif
|
||||
#if defined(__HAIKU__)
|
||||
kill_thread(m_thread);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@ typedef void *( * pthread_fn )( void * );
|
||||
#ifdef MACOSX
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef __HAIKU__
|
||||
#include <kernel/OS.h>
|
||||
#endif
|
||||
|
||||
class CThread
|
||||
@@ -43,6 +46,10 @@ typedef void *( * pthread_fn )( void * );
|
||||
pthread_t m_thread;
|
||||
pthread_attr_t m_attributes;
|
||||
#endif
|
||||
#if defined(__HAIKU__)
|
||||
thread_func mp_threadFunc;
|
||||
thread_id m_thread;
|
||||
#endif
|
||||
#ifdef MACOSX
|
||||
TaskProc mp_threadFunc;
|
||||
MPTaskID m_threadID;
|
||||
|
||||
@@ -351,7 +351,8 @@ StartupResult RakPeer::Startup( unsigned short maxConnections, SocketDescriptor
|
||||
#if defined(_WIN32)
|
||||
threadPriority=0;
|
||||
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
threadPriority=40;
|
||||
#else
|
||||
threadPriority=1000;
|
||||
#endif
|
||||
|
||||
@@ -19,6 +19,8 @@ using namespace RakNet;
|
||||
|
||||
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
#include <kernel/OS.h>
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
@@ -92,10 +94,10 @@ int RakThread::Create( void* start_address( void* ), void *arglist, int priority
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
thread_id threadHandle = spawn_thread((thread_func)start_address, "RakThread", priority, arglist);
|
||||
int res = resume_thread(threadHandle);
|
||||
return res == B_OK ? 0 : 1;
|
||||
#else
|
||||
pthread_t threadHandle;
|
||||
// Create thread linux
|
||||
|
||||
@@ -42,11 +42,10 @@ SocketLayerOverride *SocketLayer::slo=0;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined(__HAIKU__)
|
||||
#include <sys/types.h>
|
||||
#include <ifaddrs.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1436,6 +1435,24 @@ RakNet::RakString SocketLayer::GetSubNetForSocketAndIp(SOCKET inSock, RakNet::Ra
|
||||
}
|
||||
}
|
||||
return "";
|
||||
#elif defined(__HAIKU__)
|
||||
struct ifaddrs *ifap, *ifa;
|
||||
getifaddrs (&ifap);
|
||||
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
|
||||
if (ifa->ifa_addr && ifa->ifa_addr->sa_family==AF_INET) {
|
||||
sockaddr_in* sa = (sockaddr_in*)ifa->ifa_addr;
|
||||
char* ip_addr = inet_ntoa(sa->sin_addr);
|
||||
if (inIpString == ip_addr) {
|
||||
sockaddr_in* sa = (sockaddr_in*)ifa->ifa_netmask;
|
||||
char* netmask = inet_ntoa(sa->sin_addr);
|
||||
|
||||
freeifaddrs(ifap);
|
||||
return netmask;
|
||||
}
|
||||
}
|
||||
}
|
||||
freeifaddrs(ifap);
|
||||
return "";
|
||||
#else
|
||||
|
||||
int fd,fd2;
|
||||
@@ -1648,7 +1665,7 @@ void GetMyIP_Win32( SystemAddress addresses[MAXIMUM_NUMBER_OF_INTERNAL_IDS] )
|
||||
}
|
||||
}
|
||||
// #else
|
||||
/*
|
||||
|
||||
void GetMyIP_Linux( SystemAddress addresses[MAXIMUM_NUMBER_OF_INTERNAL_IDS] )
|
||||
{
|
||||
struct ifaddrs *ifaddr, *ifa;
|
||||
@@ -1699,7 +1716,7 @@ void GetMyIP_Linux( SystemAddress addresses[MAXIMUM_NUMBER_OF_INTERNAL_IDS] )
|
||||
|
||||
freeifaddrs(ifaddr);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1711,6 +1728,8 @@ void SocketLayer::GetMyIP( SystemAddress addresses[MAXIMUM_NUMBER_OF_INTERNAL_ID
|
||||
|
||||
#if defined(_WIN32)
|
||||
GetMyIP_Win32(addresses);
|
||||
#elif defined(__HAIKU__)
|
||||
GetMyIP_Linux(addresses);
|
||||
#else
|
||||
// GetMyIP_Linux(addresses);
|
||||
GetMyIP_Win32(addresses);
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#include "UDPForwarder.h"
|
||||
|
||||
#if defined(__HAIKU__)
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#if _RAKNET_SUPPORT_UDPForwarder==1
|
||||
|
||||
#include "GetTime.h"
|
||||
|
||||
@@ -102,8 +102,8 @@ void Chicken::dropDeathLoot( /*bool wasKilledByPlayer, int playerBonusLevel*/ )
|
||||
spawnAtLocation(Item::feather->id, 1);
|
||||
}
|
||||
//// and some meat
|
||||
//if (isOnFire()) spawnAtLocation(Item::chicken_cooked->id, 1); //@fire
|
||||
//else
|
||||
if (isOnFire()) spawnAtLocation(Item::chicken_cooked->id, 1); //@fire
|
||||
else
|
||||
spawnAtLocation(Item::chicken_raw->id, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,11 +66,11 @@ void Cow::dropDeathLoot( /*bool wasKilledByPlayer, int playerBonusLevel*/ ) {
|
||||
// and some meat
|
||||
count = random.nextInt(3) + 1;
|
||||
for (int i = 0; i < count; i++) {
|
||||
// if (isOnFire()) { //@fire
|
||||
// spawnAtLocation(Item::beef_cooked->id, 1);
|
||||
// } else {
|
||||
if (isOnFire()) { //@fire
|
||||
spawnAtLocation(Item::beef_cooked->id, 1);
|
||||
} else {
|
||||
spawnAtLocation(Item::beef_raw->id, 1);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,8 +54,8 @@ std::string Pig::getDeathSound()
|
||||
int Pig::getDeathLoot()
|
||||
{
|
||||
//@fire
|
||||
//if (isOnFire())
|
||||
// return Item::porkChop_cooked->id;
|
||||
if (isOnFire())
|
||||
return Item::porkChop_cooked->id;
|
||||
return Item::porkChop_raw->id;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ void Biome::teardownBiomes() {
|
||||
Feature* Biome::getTreeFeature( Random* random )
|
||||
{
|
||||
if (random->nextInt(10) == 0) {
|
||||
return new BasicTree(false);
|
||||
// return new BasicTree(false); // temporarily disabled
|
||||
}
|
||||
return new TreeFeature(false);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
return new BirchFeature();
|
||||
}
|
||||
if (random->nextInt(3) == 0) {
|
||||
return new BasicTree(false);
|
||||
// return new BasicTree(false); // temporarily disabled
|
||||
}
|
||||
return new TreeFeature(false);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class RainforestBiome: public Biome
|
||||
public:
|
||||
Feature* getTreeFeature(Random* random) {
|
||||
if (random->nextInt(3) == 0) {
|
||||
return new BasicTree(false);
|
||||
// return new BasicTree(false); // temporarily disabled
|
||||
}
|
||||
return new TreeFeature(false);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ void CanyonFeature::addTunnel( int xOffs, int zOffs, unsigned char* blocks, floa
|
||||
}
|
||||
}
|
||||
|
||||
void CanyonFeature::addFeature(Level* level, int x, int z, int xOffs, int zOffs,unsigned char* blocks)
|
||||
void CanyonFeature::addFeature(Level* level, int x, int z, int xOffs, int zOffs, unsigned char* blocks, int blocksSize)
|
||||
{
|
||||
if (random.nextInt(15) != 0) return;
|
||||
|
||||
|
||||
@@ -11,8 +11,12 @@ class CanyonFeature: public LargeFeature {
|
||||
|
||||
/*protected*/
|
||||
void addTunnel(int xOffs, int zOffs, unsigned char* blocks, float xCave, float yCave, float zCave, float thickness, float yRot, float xRot, int step, int dist, float yScale);
|
||||
|
||||
/*protected*/
|
||||
void addFeature(Level* level, int x, int z, int xOffs, int zOffs,unsigned char* blocks);
|
||||
void addFeature(Level* level, int x, int z, int xOffs, int zOffs, unsigned char* blocks, int blocksSize);
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -25,6 +25,7 @@ class LevelChunk;
|
||||
|
||||
#include "../chunk/ChunkSource.h"
|
||||
#include "LargeCaveFeature.h"
|
||||
#include "CanyonFeature.h"
|
||||
#include "synth/PerlinNoise.h"
|
||||
#include "../../../SharedConstants.h"
|
||||
|
||||
@@ -63,6 +64,7 @@ private:
|
||||
public:
|
||||
//Biome** biomes;
|
||||
LargeCaveFeature caveFeature;
|
||||
CanyonFeature canyonFeature;
|
||||
int waterDepths[16+16][16+16];
|
||||
private:
|
||||
ChunkMap chunkMap;
|
||||
@@ -92,6 +94,7 @@ private:
|
||||
float* fi;
|
||||
float* fis;
|
||||
///*private*/ float[] temperatures;
|
||||
float* temperatures; // normally unused like above, but restored this maybe might come handy - shredder
|
||||
};
|
||||
|
||||
class PerformanceTestChunkSource : public ChunkSource
|
||||
|
||||
@@ -17,7 +17,7 @@ class BasicTree : public Feature
|
||||
typedef Feature super;
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned char axisConversionArray[6];
|
||||
Random *rnd;
|
||||
@@ -25,11 +25,11 @@ private:
|
||||
int origin[3];
|
||||
int height;
|
||||
int trunkHeight;
|
||||
double trunkHeightScale;
|
||||
double branchDensity;
|
||||
double branchSlope;
|
||||
double widthScale;
|
||||
double foliageDensity;
|
||||
float trunkHeightScale;
|
||||
float branchDensity;
|
||||
float branchSlope;
|
||||
float widthScale;
|
||||
float foliageDensity;
|
||||
int trunkWidth;
|
||||
int heightVariance;
|
||||
int foliageHeight;
|
||||
@@ -38,7 +38,7 @@ private:
|
||||
void prepare(){
|
||||
trunkHeight = (int) (height * trunkHeightScale);
|
||||
if (trunkHeight >= height) trunkHeight = height - 1;
|
||||
int clustersPerY = (int) (1.382 + pow(foliageDensity * height / 13.0, 2));
|
||||
int clustersPerY = (int) (1.382f + pow(foliageDensity * height / 13.0, 2));
|
||||
if (clustersPerY < 1) clustersPerY = 1;
|
||||
int **tempFoliageCoords = new int *[clustersPerY * height];
|
||||
for( int i = 0; i < clustersPerY * height; i++ )
|
||||
@@ -68,19 +68,19 @@ private:
|
||||
continue;
|
||||
}
|
||||
|
||||
double originOffset = 0.5;
|
||||
float originOffset = 0.5f;
|
||||
while (num < clustersPerY)
|
||||
{
|
||||
double radius = widthScale * (shapefac * (rnd->nextFloat() + 0.328));
|
||||
double angle = rnd->nextFloat() * 2.0 * 3.14159;
|
||||
float radius = widthScale * (shapefac * (rnd->nextFloat() + 0.328f));
|
||||
float angle = rnd->nextFloat() * 2.0f * 3.14159f;
|
||||
int x = Mth::floor(radius * sin(angle) + origin[0] + originOffset);
|
||||
int z = Mth::floor(radius * cos(angle) + origin[2] + originOffset);
|
||||
int checkStart[] = { x, y, z };
|
||||
int checkEnd[] = { x, y + foliageHeight, z };
|
||||
if (checkLine(checkStart, checkEnd) == -1) {
|
||||
int checkBranchBase[] = { origin[0], origin[1], origin[2] };
|
||||
double distance = sqrt(pow(abs(origin[0] - checkStart[0]), 2.0) + pow(abs(origin[2] - checkStart[2]), 2.0));
|
||||
double branchHeight = distance * branchSlope;
|
||||
float distance = sqrt(pow(abs(origin[0] - checkStart[0]), 2.0f) + pow(abs(origin[2] - checkStart[2]), 2.0f));
|
||||
float branchHeight = distance * branchSlope;
|
||||
if ((checkStart[1] - branchHeight) > trunkTop)
|
||||
{
|
||||
checkBranchBase[1] = trunkTop;
|
||||
@@ -134,7 +134,9 @@ private:
|
||||
offset2 = -rad;
|
||||
while (offset2 <= rad)
|
||||
{
|
||||
double thisdistance = pow(abs(offset1) + 0.5, 2) + pow(abs(offset2) + 0.5, 2);
|
||||
float off1 = (float)offset1 + 0.5f;
|
||||
float off2 = (float)offset2 + 0.5f;
|
||||
float thisdistance = (off1 * off1) + (off2 * off2);
|
||||
if (thisdistance > radius * radius)
|
||||
{
|
||||
offset2++;
|
||||
@@ -159,14 +161,14 @@ private:
|
||||
|
||||
}
|
||||
float treeShape(int y){
|
||||
if (y < (((float) height) * 0.3)) return (float) -1.618;
|
||||
float radius = ((float) height) / ((float) 2.0);
|
||||
float adjacent = (((float) height) / ((float) 2.0)) - y;
|
||||
if (y < (((float) height) * 0.3f)) return (float) -1.618f;
|
||||
float radius = ((float) height) / ((float) 2.0f);
|
||||
float adjacent = (((float) height) / ((float) 2.0f)) - y;
|
||||
float distance;
|
||||
if (adjacent == 0) distance = radius;
|
||||
else if (abs(adjacent) >= radius) distance = (float) 0.0;
|
||||
else if (abs(adjacent) >= radius) distance = (float) 0.0f;
|
||||
else distance = (float) sqrt(pow(abs(radius), 2) - pow(abs(adjacent), 2));
|
||||
distance *= (float) 0.5;
|
||||
distance *= (float) 0.5f;
|
||||
return distance;
|
||||
}
|
||||
float foliageShape(int y){
|
||||
@@ -207,8 +209,8 @@ private:
|
||||
char primsign;
|
||||
if (delta[primidx] > 0) primsign = 1;
|
||||
else primsign = -1;
|
||||
double secfac1 = ((double) delta[secidx1]) / ((double) delta[primidx]);
|
||||
double secfac2 = ((double) delta[secidx2]) / ((double) delta[primidx]);
|
||||
float secfac1 = ((float) delta[secidx1]) / ((float) delta[primidx]);
|
||||
float secfac2 = ((float) delta[secidx2]) / ((float) delta[primidx]);
|
||||
int coordinate[] = { 0, 0, 0 };
|
||||
int primoffset = 0;
|
||||
int endoffset = delta[primidx] + primsign;
|
||||
@@ -312,8 +314,8 @@ private:
|
||||
char primsign;
|
||||
if (delta[primidx] > 0) primsign = 1;
|
||||
else primsign = -1;
|
||||
double secfac1 = ((double) delta[secidx1]) / ((double) delta[primidx]);
|
||||
double secfac2 = ((double) delta[secidx2]) / ((double) delta[primidx]);
|
||||
float secfac1 = ((float) delta[secidx1]) / ((float) delta[primidx]);
|
||||
float secfac2 = ((float) delta[secidx2]) / ((float) delta[primidx]);
|
||||
int coordinate[] = { 0, 0, 0 };
|
||||
int primoffset = 0;
|
||||
int endoffset = delta[primidx] + primsign;
|
||||
@@ -331,19 +333,19 @@ private:
|
||||
}
|
||||
primoffset += primsign;
|
||||
}
|
||||
|
||||
|
||||
if (primoffset == endoffset)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
return abs(primoffset);
|
||||
}
|
||||
}
|
||||
bool checkLocation(){
|
||||
|
||||
|
||||
int startPosition[] = { origin[0], origin[1], origin[2] };
|
||||
int endPosition[] = { origin[0], origin[1] + height - 1, origin[2] };
|
||||
|
||||
@@ -373,11 +375,11 @@ private:
|
||||
public:
|
||||
BasicTree(bool doUpdate){
|
||||
axisConversionArray[0] = 2;
|
||||
axisConversionArray[1] = 0;
|
||||
axisConversionArray[2] = 0;
|
||||
axisConversionArray[3] = 1;
|
||||
axisConversionArray[4] = 2;
|
||||
axisConversionArray[5] = 1;
|
||||
axisConversionArray[1] = 0;
|
||||
axisConversionArray[2] = 0;
|
||||
axisConversionArray[3] = 1;
|
||||
axisConversionArray[4] = 2;
|
||||
axisConversionArray[5] = 1;
|
||||
rnd = new Random();
|
||||
origin[0] = 0;
|
||||
origin[1] = 0;
|
||||
@@ -405,7 +407,7 @@ public:
|
||||
delete [] foliageCoords;
|
||||
}
|
||||
|
||||
virtual void init(double heightInit, double widthInit, double foliageDensityInit){
|
||||
virtual void init(float heightInit, float widthInit, float foliageDensityInit){
|
||||
|
||||
heightVariance = (int) (heightInit * 12);
|
||||
if (heightInit > 0.5) foliageHeight = 5;
|
||||
@@ -430,7 +432,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
prepare();
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
#include <cstdio>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined(__HAIKU__)
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "MoveFolder.h"
|
||||
#endif
|
||||
@@ -66,7 +70,7 @@ void ExternalFileLevelStorageSource::addLevelSummaryIfExists(LevelSummaryList& d
|
||||
|
||||
void ExternalFileLevelStorageSource::getLevelList(LevelSummaryList& dest)
|
||||
{
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32)
|
||||
|
||||
WIN32_FIND_DATAA fileData;
|
||||
HANDLE hFind;
|
||||
@@ -83,8 +87,6 @@ void ExternalFileLevelStorageSource::getLevelList(LevelSummaryList& dest)
|
||||
} while (FindNextFileA(hFind, &fileData));
|
||||
FindClose(hFind);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
DIR *dp;
|
||||
struct dirent *dirp;
|
||||
@@ -94,10 +96,20 @@ void ExternalFileLevelStorageSource::getLevelList(LevelSummaryList& dest)
|
||||
}
|
||||
|
||||
while ((dirp = readdir(dp)) != NULL) {
|
||||
#if defined(__HAIKU__)
|
||||
struct stat st;
|
||||
const auto fullPath = basePath + "/" + dirp->d_name;
|
||||
if (!lstat(fullPath.c_str(), &st)) {
|
||||
if(st.st_mode & S_IFDIR) {
|
||||
addLevelSummaryIfExists(dest, dirp->d_name);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (dirp->d_type == DT_DIR)
|
||||
{
|
||||
addLevelSummaryIfExists(dest, dirp->d_name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
closedir(dp);
|
||||
#endif
|
||||
|
||||
@@ -131,6 +131,10 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
int getRenderLayer() {
|
||||
return Tile::RENDERLAYER_ALPHATEST;
|
||||
}
|
||||
|
||||
bool canBurn(LevelSource* level, int x, int y, int z) {
|
||||
return flameOdds[level->getTile(x, y, z)] > 0;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "../levelgen/feature/SpruceFeature.h"
|
||||
#include "../levelgen/feature/BirchFeature.h"
|
||||
#include "../levelgen/feature/TreeFeature.h"
|
||||
#include "../levelgen/feature/BasicTree.h"
|
||||
|
||||
class Sapling: public Bush
|
||||
{
|
||||
@@ -90,9 +91,9 @@ public:
|
||||
// f = new TreeFeature(true, 4 + random.nextInt(7), TreeTile::JUNGLE_TRUNK, LeafTile::JUNGLE_LEAF, false);
|
||||
// }
|
||||
} else {
|
||||
//if (random->nextInt(10) == 0) {
|
||||
// f = new BasicTree(true);
|
||||
//} else
|
||||
if (random->nextInt(10) == 0) {
|
||||
// f = new BasicTree(true); // temporarily disabled
|
||||
} else
|
||||
f = new TreeFeature(true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user