forked from Kolyah35/minecraft-pe-0.6.1
Compare commits
21 Commits
ios-suppor
...
fix-settin
| Author | SHA1 | Date | |
|---|---|---|---|
| b3561e773d | |||
| 162ec7adfa | |||
| 4cfaa43d77 | |||
| 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
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -35,6 +35,17 @@ void GuiElementContainer::removeChild( GuiElement* element ) {
|
||||
children.erase(it);
|
||||
}
|
||||
|
||||
bool GuiElementContainer::containsPointInChildren(int x, int y) const {
|
||||
for (std::vector<GuiElement*>::const_iterator it = children.begin(); it != children.end(); ++it) {
|
||||
GuiElement* child = *it;
|
||||
if (child == NULL || !child->visible) continue;
|
||||
if (child->pointInside(x, y)) return true;
|
||||
const GuiElementContainer* container = dynamic_cast<const GuiElementContainer*>(child);
|
||||
if (container != NULL && container->containsPointInChildren(x, y)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void GuiElementContainer::tick( Minecraft* minecraft ) {
|
||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
||||
(*it)->tick(minecraft);
|
||||
|
||||
@@ -5,16 +5,17 @@
|
||||
class Tesselator;
|
||||
class Minecraft;
|
||||
|
||||
class GuiElementContainer : public GuiElement {
|
||||
public:
|
||||
GuiElementContainer(bool active=false, bool visible=true, int x = 0, int y = 0, int width=24, int height=24);
|
||||
virtual ~GuiElementContainer();
|
||||
virtual void render(Minecraft* minecraft, int xm, int ym);
|
||||
virtual void setupPositions();
|
||||
virtual void addChild(GuiElement* element);
|
||||
virtual void removeChild(GuiElement* element);
|
||||
|
||||
virtual void tick( Minecraft* minecraft );
|
||||
class GuiElementContainer : public GuiElement {
|
||||
public:
|
||||
GuiElementContainer(bool active=false, bool visible=true, int x = 0, int y = 0, int width=24, int height=24);
|
||||
virtual ~GuiElementContainer();
|
||||
virtual void render(Minecraft* minecraft, int xm, int ym);
|
||||
virtual void setupPositions();
|
||||
virtual void addChild(GuiElement* element);
|
||||
virtual void removeChild(GuiElement* element);
|
||||
bool containsPointInChildren(int x, int y) const;
|
||||
|
||||
virtual void tick( Minecraft* minecraft );
|
||||
|
||||
virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum );
|
||||
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum );
|
||||
|
||||
@@ -1,115 +1,230 @@
|
||||
#include "OptionsGroup.h"
|
||||
#include "../../Minecraft.h"
|
||||
#include "ImageButton.h"
|
||||
#include "OptionsItem.h"
|
||||
#include "Slider.h"
|
||||
#include "../../../locale/I18n.h"
|
||||
#include "TextOption.h"
|
||||
#include "KeyOption.h"
|
||||
|
||||
OptionsGroup::OptionsGroup( std::string labelID ) {
|
||||
label = I18n::get(labelID);
|
||||
}
|
||||
|
||||
void OptionsGroup::setupPositions() {
|
||||
// First we write the header and then we add the items
|
||||
int curY = y + 18;
|
||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
||||
(*it)->width = width - 5;
|
||||
|
||||
(*it)->y = curY;
|
||||
(*it)->x = x + 10;
|
||||
(*it)->setupPositions();
|
||||
curY += (*it)->height + 3;
|
||||
}
|
||||
height = curY;
|
||||
}
|
||||
|
||||
void OptionsGroup::render( Minecraft* minecraft, int xm, int ym ) {
|
||||
float padX = 10.0f;
|
||||
float padY = 5.0f;
|
||||
|
||||
minecraft->font->draw(label, (float)x + padX, (float)y + padY, 0xffffffff, false);
|
||||
|
||||
super::render(minecraft, xm, ym);
|
||||
}
|
||||
|
||||
OptionsGroup& OptionsGroup::addOptionItem(OptionId optId, Minecraft* minecraft ) {
|
||||
auto option = minecraft->options.getOpt(optId);
|
||||
|
||||
if (option == nullptr) return *this;
|
||||
|
||||
// TODO: do a options key class to check it faster via dynamic_cast
|
||||
if (option->getStringId().find("options.key") != std::string::npos) createKey(optId, minecraft);
|
||||
else if (dynamic_cast<OptionBool*>(option)) createToggle(optId, minecraft);
|
||||
else if (dynamic_cast<OptionFloat*>(option)) createProgressSlider(optId, minecraft);
|
||||
else if (dynamic_cast<OptionInt*>(option)) createStepSlider(optId, minecraft);
|
||||
else if (dynamic_cast<OptionString*>(option)) createTextbox(optId, minecraft);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// TODO: wrap this copypaste shit into templates
|
||||
|
||||
void OptionsGroup::createToggle(OptionId optId, Minecraft* minecraft ) {
|
||||
ImageDef def;
|
||||
|
||||
def.setSrc(IntRectangle(160, 206, 39, 20));
|
||||
def.name = "gui/touchgui.png";
|
||||
def.width = 39 * 0.7f;
|
||||
def.height = 20 * 0.7f;
|
||||
|
||||
OptionButton* element = new OptionButton(optId);
|
||||
element->setImageDef(def, true);
|
||||
element->updateImage(&minecraft->options);
|
||||
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
}
|
||||
|
||||
void OptionsGroup::createProgressSlider(OptionId optId, Minecraft* minecraft ) {
|
||||
Slider* element = new SliderFloat(minecraft, optId);
|
||||
element->width = 100;
|
||||
element->height = 20;
|
||||
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
}
|
||||
|
||||
void OptionsGroup::createStepSlider(OptionId optId, Minecraft* minecraft ) {
|
||||
Slider* element = new SliderInt(minecraft, optId);
|
||||
element->width = 100;
|
||||
element->height = 20;
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
}
|
||||
|
||||
void OptionsGroup::createTextbox(OptionId optId, Minecraft* minecraft) {
|
||||
TextBox* element = new TextOption(minecraft, optId);
|
||||
element->width = 100;
|
||||
element->height = 20;
|
||||
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
}
|
||||
|
||||
void OptionsGroup::createKey(OptionId optId, Minecraft* minecraft) {
|
||||
KeyOption* element = new KeyOption(minecraft, optId);
|
||||
element->width = 50;
|
||||
element->height = 20;
|
||||
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
}
|
||||
#include "OptionsGroup.h"
|
||||
#include "../../Minecraft.h"
|
||||
#include "ImageButton.h"
|
||||
#include "OptionsItem.h"
|
||||
#include "Slider.h"
|
||||
#include "../../../locale/I18n.h"
|
||||
#include "TextOption.h"
|
||||
#include "KeyOption.h"
|
||||
#include <algorithm>
|
||||
#include "../Gui.h"
|
||||
#include "../Screen.h"
|
||||
#include "../../../platform/input/Mouse.h"
|
||||
#include "../../../util/Mth.h"
|
||||
|
||||
OptionsGroup::OptionsGroup( std::string labelID )
|
||||
: contentHeight(0),
|
||||
scrollOffsetY(0.0f),
|
||||
maxScrollOffsetY(0.0f),
|
||||
trackingScrollGesture(false),
|
||||
scrollingGesture(false),
|
||||
touchDispatched(false),
|
||||
dragStartX(0),
|
||||
dragStartY(0),
|
||||
lastDragY(0),
|
||||
touchStartX(0),
|
||||
touchStartY(0) {
|
||||
label = I18n::get(labelID);
|
||||
}
|
||||
|
||||
void OptionsGroup::setupPositions() {
|
||||
const int labelHeight = 18;
|
||||
const int bottomPadding = 36;
|
||||
const float requestedScroll = scrollOffsetY;
|
||||
const int scrollOffset = (int)requestedScroll;
|
||||
int curY = y + labelHeight - scrollOffset;
|
||||
const int contentStartY = y + labelHeight;
|
||||
|
||||
// First we write the header and then we add the items
|
||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
||||
(*it)->width = width - 5;
|
||||
|
||||
(*it)->y = curY;
|
||||
(*it)->x = x + 10;
|
||||
(*it)->setupPositions();
|
||||
curY += (*it)->height + 3;
|
||||
}
|
||||
curY += bottomPadding;
|
||||
contentHeight = std::max(0, curY - contentStartY + scrollOffset);
|
||||
maxScrollOffsetY = std::max(0, contentHeight - (height - labelHeight));
|
||||
const float clampedScroll = Mth::clamp(requestedScroll, 0.0f, maxScrollOffsetY);
|
||||
if (clampedScroll != requestedScroll) {
|
||||
scrollOffsetY = clampedScroll;
|
||||
setupPositions();
|
||||
}
|
||||
}
|
||||
|
||||
void OptionsGroup::render( Minecraft* minecraft, int xm, int ym ) {
|
||||
float padX = 10.0f;
|
||||
float padY = 5.0f;
|
||||
const int labelHeight = 18;
|
||||
|
||||
minecraft->font->draw(label, (float)x + padX, (float)y + padY, 0xffffffff, false);
|
||||
|
||||
glEnable2(GL_SCISSOR_TEST);
|
||||
glScissor(
|
||||
Gui::GuiScale * x,
|
||||
minecraft->height - Gui::GuiScale * (y + height),
|
||||
Gui::GuiScale * width,
|
||||
Gui::GuiScale * (height - labelHeight)
|
||||
);
|
||||
|
||||
super::render(minecraft, xm, ym);
|
||||
glDisable2(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
void OptionsGroup::tick(Minecraft* minecraft) {
|
||||
int xm = Mouse::getX();
|
||||
int ym = Mouse::getY();
|
||||
if (minecraft->screen != NULL) {
|
||||
minecraft->screen->toGUICoordinate(xm, ym);
|
||||
}
|
||||
|
||||
bool leftDown = Mouse::isButtonDown(MouseAction::ACTION_LEFT);
|
||||
|
||||
if (trackingScrollGesture && leftDown) {
|
||||
int dy = ym - lastDragY;
|
||||
int dx = xm - dragStartX;
|
||||
if (!scrollingGesture) {
|
||||
int totalDx = xm - dragStartX;
|
||||
int totalDy = ym - dragStartY;
|
||||
if (std::abs(totalDx) >= ScrollStartThreshold || std::abs(totalDy) >= ScrollStartThreshold) {
|
||||
if (std::abs(totalDy) >= std::abs(totalDx)) {
|
||||
scrollingGesture = true;
|
||||
} else if (!touchDispatched) {
|
||||
super::mouseClicked(minecraft, touchStartX, touchStartY, MouseAction::ACTION_LEFT);
|
||||
touchDispatched = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (scrollingGesture && dy != 0) {
|
||||
scrollByPixels((float)dy);
|
||||
}
|
||||
lastDragY = ym;
|
||||
}
|
||||
super::tick(minecraft);
|
||||
}
|
||||
|
||||
void OptionsGroup::mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum) {
|
||||
trackingScrollGesture = false;
|
||||
scrollingGesture = false;
|
||||
touchDispatched = false;
|
||||
|
||||
if (buttonNum == MouseAction::ACTION_LEFT && pointInside(x, y)) {
|
||||
trackingScrollGesture = true;
|
||||
dragStartX = x;
|
||||
dragStartY = y;
|
||||
lastDragY = y;
|
||||
touchStartX = x;
|
||||
touchStartY = y;
|
||||
return;
|
||||
}
|
||||
|
||||
super::mouseClicked(minecraft, x, y, buttonNum);
|
||||
}
|
||||
|
||||
void OptionsGroup::mouseReleased(Minecraft* minecraft, int x, int y, int buttonNum) {
|
||||
bool wasScrolling = scrollingGesture;
|
||||
bool wasTracking = trackingScrollGesture;
|
||||
trackingScrollGesture = false;
|
||||
scrollingGesture = false;
|
||||
if (buttonNum == MouseAction::ACTION_LEFT && wasTracking && !touchDispatched && pointInside(touchStartX, touchStartY)) {
|
||||
super::mouseClicked(minecraft, touchStartX, touchStartY, buttonNum);
|
||||
touchDispatched = true;
|
||||
}
|
||||
|
||||
if (!wasScrolling) {
|
||||
super::mouseReleased(minecraft, x, y, buttonNum);
|
||||
}
|
||||
}
|
||||
|
||||
void OptionsGroup::scrollByPixels(float deltaY) {
|
||||
if (deltaY == 0.0f || maxScrollOffsetY <= 0.0f) return;
|
||||
|
||||
scrollOffsetY = Mth::clamp(scrollOffsetY - deltaY, 0.0f, maxScrollOffsetY);
|
||||
setupPositions();
|
||||
}
|
||||
|
||||
bool OptionsGroup::isScrollingGestureActive() const {
|
||||
return trackingScrollGesture || scrollingGesture;
|
||||
}
|
||||
|
||||
OptionsGroup& OptionsGroup::addOptionItem(OptionId optId, Minecraft* minecraft ) {
|
||||
auto option = minecraft->options.getOpt(optId);
|
||||
|
||||
if (option == nullptr) return *this;
|
||||
|
||||
// TODO: do a options key class to check it faster via dynamic_cast
|
||||
if (option->getStringId().find("options.key") != std::string::npos) createKey(optId, minecraft);
|
||||
else if (dynamic_cast<OptionBool*>(option)) createToggle(optId, minecraft);
|
||||
else if (dynamic_cast<OptionFloat*>(option)) createProgressSlider(optId, minecraft);
|
||||
else if (dynamic_cast<OptionInt*>(option)) createStepSlider(optId, minecraft);
|
||||
else if (dynamic_cast<OptionString*>(option)) createTextbox(optId, minecraft);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// TODO: wrap this copypaste shit into templates
|
||||
|
||||
void OptionsGroup::createToggle(OptionId optId, Minecraft* minecraft ) {
|
||||
ImageDef def;
|
||||
|
||||
def.setSrc(IntRectangle(160, 206, 39, 20));
|
||||
def.name = "gui/touchgui.png";
|
||||
def.width = 39 * 0.7f;
|
||||
def.height = 20 * 0.7f;
|
||||
|
||||
OptionButton* element = new OptionButton(optId);
|
||||
element->setImageDef(def, true);
|
||||
element->updateImage(&minecraft->options);
|
||||
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
}
|
||||
|
||||
void OptionsGroup::createProgressSlider(OptionId optId, Minecraft* minecraft ) {
|
||||
Slider* element = new SliderFloat(minecraft, optId);
|
||||
element->width = 100;
|
||||
element->height = 20;
|
||||
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
}
|
||||
|
||||
void OptionsGroup::createStepSlider(OptionId optId, Minecraft* minecraft ) {
|
||||
Slider* element = new SliderInt(minecraft, optId);
|
||||
element->width = 100;
|
||||
element->height = 20;
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
}
|
||||
|
||||
void OptionsGroup::createTextbox(OptionId optId, Minecraft* minecraft) {
|
||||
TextBox* element = new TextOption(minecraft, optId);
|
||||
element->width = 100;
|
||||
element->height = 20;
|
||||
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
}
|
||||
|
||||
void OptionsGroup::createKey(OptionId optId, Minecraft* minecraft) {
|
||||
KeyOption* element = new KeyOption(minecraft, optId);
|
||||
element->width = 50;
|
||||
element->height = 20;
|
||||
|
||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||
addChild(item);
|
||||
setupPositions();
|
||||
}
|
||||
|
||||
@@ -11,22 +11,39 @@
|
||||
class Font;
|
||||
class Minecraft;
|
||||
|
||||
class OptionsGroup: public GuiElementContainer {
|
||||
typedef GuiElementContainer super;
|
||||
public:
|
||||
OptionsGroup(std::string labelID);
|
||||
virtual void setupPositions();
|
||||
virtual void render(Minecraft* minecraft, int xm, int ym);
|
||||
OptionsGroup& addOptionItem(OptionId optId, Minecraft* minecraft);
|
||||
protected:
|
||||
class OptionsGroup: public GuiElementContainer {
|
||||
typedef GuiElementContainer super;
|
||||
public:
|
||||
OptionsGroup(std::string labelID);
|
||||
virtual void setupPositions();
|
||||
virtual void render(Minecraft* minecraft, int xm, int ym);
|
||||
virtual void tick(Minecraft* minecraft);
|
||||
virtual void mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum);
|
||||
virtual void mouseReleased(Minecraft* minecraft, int x, int y, int buttonNum);
|
||||
OptionsGroup& addOptionItem(OptionId optId, Minecraft* minecraft);
|
||||
void scrollByPixels(float deltaY);
|
||||
bool isScrollingGestureActive() const;
|
||||
protected:
|
||||
|
||||
void createToggle(OptionId optId, Minecraft* minecraft);
|
||||
void createProgressSlider(OptionId optId, Minecraft* minecraft);
|
||||
void createStepSlider(OptionId optId, Minecraft* minecraft);
|
||||
void createTextbox(OptionId optId, Minecraft* minecraft);
|
||||
void createKey(OptionId optId, Minecraft* minecraft);
|
||||
|
||||
std::string label;
|
||||
};
|
||||
void createKey(OptionId optId, Minecraft* minecraft);
|
||||
|
||||
std::string label;
|
||||
int contentHeight;
|
||||
float scrollOffsetY;
|
||||
float maxScrollOffsetY;
|
||||
bool trackingScrollGesture;
|
||||
bool scrollingGesture;
|
||||
bool touchDispatched;
|
||||
int dragStartX;
|
||||
int dragStartY;
|
||||
int lastDragY;
|
||||
int touchStartX;
|
||||
int touchStartY;
|
||||
static const int ScrollStartThreshold = 5;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsGroup_H__*/
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -121,6 +121,7 @@ void OptionsScreen::setupPositions() {
|
||||
(*it)->x = categoryButtons[0]->width;
|
||||
(*it)->y = bHeader->height;
|
||||
(*it)->width = width - categoryButtons[0]->width;
|
||||
(*it)->height = height - bHeader->height;
|
||||
|
||||
(*it)->setupPositions();
|
||||
}
|
||||
@@ -208,7 +209,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 +227,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);
|
||||
|
||||
}
|
||||
|
||||
@@ -249,6 +254,12 @@ void OptionsScreen::mouseReleased(int x, int y, int buttonNum) {
|
||||
super::mouseReleased(x, y, buttonNum);
|
||||
}
|
||||
|
||||
void OptionsScreen::mouseWheel(int dx, int dy, int xm, int ym) {
|
||||
if (currentOptionsGroup != NULL && currentOptionsGroup->pointInside(xm, ym) && dy != 0) {
|
||||
currentOptionsGroup->scrollByPixels((float)dy * 18.0f);
|
||||
}
|
||||
}
|
||||
|
||||
void OptionsScreen::keyPressed(int eventKey) {
|
||||
if (currentOptionsGroup != NULL)
|
||||
currentOptionsGroup->keyPressed(minecraft, eventKey);
|
||||
|
||||
@@ -27,6 +27,7 @@ public:
|
||||
|
||||
virtual void mouseClicked(int x, int y, int buttonNum);
|
||||
virtual void mouseReleased(int x, int y, int buttonNum);
|
||||
virtual void mouseWheel(int dx, int dy, int xm, int ym);
|
||||
virtual void keyPressed(int eventKey);
|
||||
virtual void charPressed(char inputChar);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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