mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-11 20:11:18 +03:00
* Add FireTexture.
This commit is contained in:
@@ -669,6 +669,7 @@ void Minecraft::init()
|
||||
m_pTextures->addDynamicTexture(new WaterSideTexture);
|
||||
m_pTextures->addDynamicTexture(new LavaTexture);
|
||||
m_pTextures->addDynamicTexture(new LavaSideTexture);
|
||||
m_pTextures->addDynamicTexture(new FireTexture(0));
|
||||
m_pLevelRenderer = new LevelRenderer(this, m_pTextures);
|
||||
m_pGameRenderer = new GameRenderer(this);
|
||||
m_pParticleEngine = new ParticleEngine(m_pLevel, m_pTextures);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Textures.hpp"
|
||||
#include "client/common/Random.hpp"
|
||||
class Textures; // in case we are being included from Textures. We don't need a complete type
|
||||
|
||||
// Essentially, the way these work is by patching themselves into terrain.png with a
|
||||
@@ -100,3 +101,17 @@ public:
|
||||
float* m_data3;
|
||||
float* m_data4;
|
||||
};
|
||||
|
||||
class FireTexture : public DynamicTexture
|
||||
{
|
||||
public:
|
||||
FireTexture(int);
|
||||
~FireTexture();
|
||||
|
||||
void tick() override;
|
||||
|
||||
public:
|
||||
float* m_data1;
|
||||
float* m_data2;
|
||||
Random m_random;
|
||||
};
|
||||
|
||||
80
source/client/renderer/FireTexture.cpp
Normal file
80
source/client/renderer/FireTexture.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "DynamicTexture.hpp"
|
||||
#include "world/tile/Tile.hpp"
|
||||
|
||||
// Ported from v0.6.1
|
||||
|
||||
FireTexture::FireTexture(int a2) : DynamicTexture(Tile::fire->m_TextureFrame + 16 * a2)
|
||||
{
|
||||
m_data1 = new float[320];
|
||||
m_data2 = new float[320];
|
||||
}
|
||||
|
||||
FireTexture::~FireTexture()
|
||||
{
|
||||
SAFE_DELETE(m_data1);
|
||||
SAFE_DELETE(m_data2);
|
||||
}
|
||||
|
||||
void FireTexture::tick()
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
for (int j = 0; j < 20; j++)
|
||||
{
|
||||
int l = 18;
|
||||
float f1 = m_data1[i + ((j + 1) % 20) * 16] * l;
|
||||
for (int i1 = i - 1; i1 <= i + 1; i1++)
|
||||
{
|
||||
for (int k1 = j; k1 <= j + 1; k1++)
|
||||
{
|
||||
int i2 = i1;
|
||||
int k2 = k1;
|
||||
if (i2 >= 0 && k2 >= 0 && i2 < 16 && k2 < 20)
|
||||
{
|
||||
f1 += m_data1[i2 + k2 * 16];
|
||||
}
|
||||
l++;
|
||||
}
|
||||
}
|
||||
|
||||
m_data2[i + j * 16] = f1 / 25.2f;
|
||||
if (j >= 19)
|
||||
{
|
||||
// the original disassembly used things like HIBYTE(), LOBYTE() etc.
|
||||
union
|
||||
{
|
||||
uint32_t x;
|
||||
uint8_t b[4];
|
||||
}
|
||||
a;
|
||||
|
||||
a.x = m_random.genrand_int32();
|
||||
this->m_data2[i + j * 16] = 0.2f + (((a.b[3] / 256.0f) * 0.1f) + ((((a.b[0] / 256.0f) * (a.b[1] / 256.0f)) * (a.b[2] / 256.0f)) * 4.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::swap(m_data1, m_data2);
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
float x = this->m_data1[i] * 1.8f;
|
||||
if (x > 1.0f)
|
||||
x = 1.0f;
|
||||
if (x < 0.0f)
|
||||
x = 0.0f;
|
||||
|
||||
m_pixels[4 * i + 0] = int(x * 155.0f + 100.0f);
|
||||
m_pixels[4 * i + 1] = int(x * x * 255.0f);
|
||||
m_pixels[4 * i + 2] = int(x * x * x * x * x * x * x * x * x * x * 255.0f);
|
||||
m_pixels[4 * i + 3] = x >= 0.5f ? 255 : 0;
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,10 @@ LavaSideTexture::LavaSideTexture() : DynamicTexture(Tile::lava->m_TextureFrame +
|
||||
field_18 = 0;
|
||||
field_1C = 0;
|
||||
|
||||
m_data1 = new float[0x400];
|
||||
m_data2 = new float[0x400];
|
||||
m_data3 = new float[0x400];
|
||||
m_data4 = new float[0x400];
|
||||
m_data1 = new float[256];
|
||||
m_data2 = new float[256];
|
||||
m_data3 = new float[256];
|
||||
m_data4 = new float[256];
|
||||
m_textureSize = 2;
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
|
||||
@@ -16,10 +16,10 @@ LavaTexture::LavaTexture() : DynamicTexture(Tile::lava->m_TextureFrame)
|
||||
field_14 = 0;
|
||||
field_18 = 0;
|
||||
|
||||
m_data1 = new float[0x400];
|
||||
m_data2 = new float[0x400];
|
||||
m_data3 = new float[0x400];
|
||||
m_data4 = new float[0x400];
|
||||
m_data1 = new float[256];
|
||||
m_data2 = new float[256];
|
||||
m_data3 = new float[256];
|
||||
m_data4 = new float[256];
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
|
||||
@@ -15,10 +15,10 @@ WaterSideTexture::WaterSideTexture() : DynamicTexture(Tile::water->m_TextureFram
|
||||
field_410 = 0;
|
||||
field_414 = 0;
|
||||
|
||||
m_data1 = new float[0x400];
|
||||
m_data2 = new float[0x400];
|
||||
m_data3 = new float[0x400];
|
||||
m_data4 = new float[0x400];
|
||||
m_data1 = new float[256];
|
||||
m_data2 = new float[256];
|
||||
m_data3 = new float[256];
|
||||
m_data4 = new float[256];
|
||||
m_textureSize = 2;
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
|
||||
@@ -14,10 +14,10 @@ WaterTexture::WaterTexture() : DynamicTexture(Tile::water->m_TextureFrame)
|
||||
field_40C = 0;
|
||||
field_410 = 0;
|
||||
|
||||
m_data1 = new float[0x400];
|
||||
m_data2 = new float[0x400];
|
||||
m_data3 = new float[0x400];
|
||||
m_data4 = new float[0x400];
|
||||
m_data1 = new float[256];
|
||||
m_data2 = new float[256];
|
||||
m_data3 = new float[256];
|
||||
m_data4 = new float[256];
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
|
||||
@@ -415,6 +415,7 @@
|
||||
<ClCompile Include="..\source\client\renderer\entity\MobRenderer.cpp" />
|
||||
<ClCompile Include="..\source\client\renderer\entity\TntRenderer.cpp" />
|
||||
<ClCompile Include="..\source\client\renderer\entity\TripodCameraRenderer.cpp" />
|
||||
<ClCompile Include="..\source\client\renderer\FireTexture.cpp" />
|
||||
<ClCompile Include="..\source\client\renderer\Font.cpp" />
|
||||
<ClCompile Include="..\source\client\renderer\Frustum.cpp" />
|
||||
<ClCompile Include="..\source\client\renderer\FrustumCuller.cpp" />
|
||||
|
||||
Reference in New Issue
Block a user