mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-07-25 21:47:07 +00:00
TU19: merge Minecraft.Client/Rendering
This commit is contained in:
parent
a493e42532
commit
8f90088611
|
|
@ -89,11 +89,12 @@ zPlayerOffs = position->get(2);
|
|||
ya = cosf(xRot * PI / 180.0f);
|
||||
}
|
||||
|
||||
TilePos* Camera::getCameraTilePos(std::shared_ptr<Mob> player, double alpha) {
|
||||
TilePos* Camera::getCameraTilePos(std::shared_ptr<LivingEntity> player,
|
||||
double alpha) {
|
||||
return new TilePos(getCameraPos(player, alpha));
|
||||
}
|
||||
|
||||
Vec3* Camera::getCameraPos(std::shared_ptr<Mob> player, double alpha) {
|
||||
Vec3* Camera::getCameraPos(std::shared_ptr<LivingEntity> player, double alpha) {
|
||||
double xx = player->xo + (player->x - player->xo) * alpha;
|
||||
double yy =
|
||||
player->yo + (player->y - player->yo) * alpha + player->getHeadHeight();
|
||||
|
|
@ -106,7 +107,8 @@ Vec3* Camera::getCameraPos(std::shared_ptr<Mob> player, double alpha) {
|
|||
return Vec3::newTemp(xt, yt, zt);
|
||||
}
|
||||
|
||||
int Camera::getBlockAt(Level* level, std::shared_ptr<Mob> player, float alpha) {
|
||||
int Camera::getBlockAt(Level* level, std::shared_ptr<LivingEntity> player,
|
||||
float alpha) {
|
||||
Vec3* p = Camera::getCameraPos(player, alpha);
|
||||
TilePos tp = TilePos(p);
|
||||
int t = level->getTile(tp.x, tp.y, tp.z);
|
||||
|
|
|
|||
|
|
@ -24,8 +24,10 @@ public:
|
|||
|
||||
static void prepare(std::shared_ptr<Player> player, bool mirror);
|
||||
|
||||
static TilePos* getCameraTilePos(std::shared_ptr<Mob> player, double alpha);
|
||||
static Vec3* getCameraPos(std::shared_ptr<Mob> player, double alpha);
|
||||
static int getBlockAt(Level* level, std::shared_ptr<Mob> player,
|
||||
static TilePos* getCameraTilePos(std::shared_ptr<LivingEntity> player,
|
||||
double alpha);
|
||||
static Vec3* getCameraPos(std::shared_ptr<LivingEntity> player,
|
||||
double alpha);
|
||||
static int getBlockAt(Level* level, std::shared_ptr<LivingEntity> player,
|
||||
float alpha);
|
||||
};
|
||||
|
|
@ -204,8 +204,8 @@ void Chunk::rebuild() {
|
|||
|
||||
LevelChunk::touchedSky = false;
|
||||
|
||||
// std::unordered_set<std::shared_ptr<TileEntity> >
|
||||
//oldTileEntities(renderableTileEntities.begin(),renderableTileEntities.end());
|
||||
// unordered_set<shared_ptr<TileEntity> >
|
||||
// oldTileEntities(renderableTileEntities.begin(),renderableTileEntities.end());
|
||||
//// 4J removed this & next line renderableTileEntities.clear();
|
||||
|
||||
std::vector<std::shared_ptr<TileEntity> >
|
||||
|
|
@ -242,7 +242,7 @@ void Chunk::rebuild() {
|
|||
// the whole thing
|
||||
|
||||
LevelSource* region =
|
||||
new Region(level, x0 - r, y0 - r, z0 - r, x1 + r, y1 + r, z1 + r);
|
||||
new Region(level, x0 - r, y0 - r, z0 - r, x1 + r, y1 + r, z1 + r, r);
|
||||
TileRenderer* tileRenderer =
|
||||
new TileRenderer(region, this->x, this->y, this->z, tileIds);
|
||||
|
||||
|
|
@ -294,27 +294,27 @@ void Chunk::rebuild() {
|
|||
// of rock, dirt, unbreakable tiles, or have already been
|
||||
// determined to meet this criteria themselves and have a tile
|
||||
// of 255 set.
|
||||
if (!((tileId == Tile::rock_Id) || (tileId == Tile::dirt_Id) ||
|
||||
if (!((tileId == Tile::stone_Id) || (tileId == Tile::dirt_Id) ||
|
||||
(tileId == Tile::unbreakable_Id) || (tileId == 255)))
|
||||
continue;
|
||||
tileId = tileIds[offset + (((xx - 1) << 11) | ((zz + 0) << 7) |
|
||||
(indexY + 0))];
|
||||
if (!((tileId == Tile::rock_Id) || (tileId == Tile::dirt_Id) ||
|
||||
if (!((tileId == Tile::stone_Id) || (tileId == Tile::dirt_Id) ||
|
||||
(tileId == Tile::unbreakable_Id) || (tileId == 255)))
|
||||
continue;
|
||||
tileId = tileIds[offset + (((xx + 1) << 11) | ((zz + 0) << 7) |
|
||||
(indexY + 0))];
|
||||
if (!((tileId == Tile::rock_Id) || (tileId == Tile::dirt_Id) ||
|
||||
if (!((tileId == Tile::stone_Id) || (tileId == Tile::dirt_Id) ||
|
||||
(tileId == Tile::unbreakable_Id) || (tileId == 255)))
|
||||
continue;
|
||||
tileId = tileIds[offset + (((xx + 0) << 11) | ((zz - 1) << 7) |
|
||||
(indexY + 0))];
|
||||
if (!((tileId == Tile::rock_Id) || (tileId == Tile::dirt_Id) ||
|
||||
if (!((tileId == Tile::stone_Id) || (tileId == Tile::dirt_Id) ||
|
||||
(tileId == Tile::unbreakable_Id) || (tileId == 255)))
|
||||
continue;
|
||||
tileId = tileIds[offset + (((xx + 0) << 11) | ((zz + 1) << 7) |
|
||||
(indexY + 0))];
|
||||
if (!((tileId == Tile::rock_Id) || (tileId == Tile::dirt_Id) ||
|
||||
if (!((tileId == Tile::stone_Id) || (tileId == Tile::dirt_Id) ||
|
||||
(tileId == Tile::unbreakable_Id) || (tileId == 255)))
|
||||
continue;
|
||||
// Treat the bottom of the world differently - we shouldn't ever
|
||||
|
|
@ -332,7 +332,7 @@ void Chunk::rebuild() {
|
|||
tileId = tileIds[yMinusOneOffset + (((xx + 0) << 11) |
|
||||
((zz + 0) << 7) |
|
||||
indexYMinusOne)];
|
||||
if (!((tileId == Tile::rock_Id) ||
|
||||
if (!((tileId == Tile::stone_Id) ||
|
||||
(tileId == Tile::dirt_Id) ||
|
||||
(tileId == Tile::unbreakable_Id) || (tileId == 255)))
|
||||
continue;
|
||||
|
|
@ -346,7 +346,7 @@ void Chunk::rebuild() {
|
|||
tileId =
|
||||
tileIds[yPlusOneOffset + (((xx + 0) << 11) |
|
||||
((zz + 0) << 7) | indexYPlusOne)];
|
||||
if (!((tileId == Tile::rock_Id) || (tileId == Tile::dirt_Id) ||
|
||||
if (!((tileId == Tile::stone_Id) || (tileId == Tile::dirt_Id) ||
|
||||
(tileId == Tile::unbreakable_Id) || (tileId == 255)))
|
||||
continue;
|
||||
|
||||
|
|
@ -416,7 +416,7 @@ void Chunk::rebuild() {
|
|||
// If flagged as not visible, drop out straight away
|
||||
if (tileId == 0xff) continue;
|
||||
// int tileId =
|
||||
//region->getTile(x,y,z);
|
||||
// region->getTile(x,y,z);
|
||||
if (tileId > 0) {
|
||||
if (!started) {
|
||||
started = true;
|
||||
|
|
@ -425,8 +425,8 @@ void Chunk::rebuild() {
|
|||
glNewList(lists + currentLayer, GL_COMPILE);
|
||||
MemSect(0);
|
||||
glPushMatrix();
|
||||
glDepthMask(true); // 4J added
|
||||
t->useCompactVertices(false); // 4J added
|
||||
glDepthMask(true); // 4J added
|
||||
t->useCompactVertices(true); // 4J added
|
||||
translateToPos();
|
||||
float ss = 1.000001f;
|
||||
// 4J - have removed this scale as I don't think we
|
||||
|
|
@ -666,8 +666,6 @@ TileCompressData_SPU g_tileCompressDataIn __attribute__((__aligned__(16)));
|
|||
unsigned char* g_tileCompressDataOut =
|
||||
(unsigned char*)&g_rebuildDataIn.m_tileIds;
|
||||
|
||||
#define TILE_RENDER_SPU
|
||||
|
||||
void RunSPURebuild() {
|
||||
static C4JSpursJobQueue::Port p("C4JSpursJob_ChunkUpdate");
|
||||
C4JSpursJob_CompressedTile tileJob(&g_tileCompressDataIn,
|
||||
|
|
@ -702,8 +700,8 @@ void Chunk::rebuild_SPU() {
|
|||
|
||||
LevelChunk::touchedSky = false;
|
||||
|
||||
// std::unordered_set<std::shared_ptr<TileEntity> >
|
||||
//oldTileEntities(renderableTileEntities.begin(),renderableTileEntities.end());
|
||||
// unordered_set<shared_ptr<TileEntity> >
|
||||
// oldTileEntities(renderableTileEntities.begin(),renderableTileEntities.end());
|
||||
//// 4J removed this & next line renderableTileEntities.clear();
|
||||
|
||||
std::vector<std::shared_ptr<TileEntity> >
|
||||
|
|
@ -715,7 +713,7 @@ void Chunk::rebuild_SPU() {
|
|||
|
||||
int r = 1;
|
||||
|
||||
Region region(level, x0 - r, y0 - r, z0 - r, x1 + r, y1 + r, z1 + r);
|
||||
Region region(level, x0 - r, y0 - r, z0 - r, x1 + r, y1 + r, z1 + r, r);
|
||||
TileRenderer tileRenderer(®ion);
|
||||
|
||||
int lists = levelRenderer->getGlobalIndexForChunk(this->x, this->y, this->z,
|
||||
|
|
@ -754,8 +752,8 @@ void Chunk::rebuild_SPU() {
|
|||
glNewList(lists + currentLayer, GL_COMPILE);
|
||||
MemSect(0);
|
||||
glPushMatrix();
|
||||
glDepthMask(true); // 4J added
|
||||
t->useCompactVertices(false); // 4J added
|
||||
glDepthMask(true); // 4J added
|
||||
t->useCompactVertices(true); // 4J added
|
||||
translateToPos();
|
||||
float ss = 1.000001f;
|
||||
// 4J - have removed this scale as I don't think we should need it,
|
||||
|
|
@ -775,19 +773,11 @@ void Chunk::rebuild_SPU() {
|
|||
(unsigned int*)g_rebuildDataIn.m_tesselator.m_PPUArray);
|
||||
g_rebuildDataIn.m_tesselator._array = &tesselatorArray;
|
||||
g_rebuildDataIn.m_currentLayer = currentLayer;
|
||||
#ifdef TILE_RENDER_SPU
|
||||
g_tileCompressDataIn.setForChunk(®ion, x0, y0, z0);
|
||||
RunSPURebuild();
|
||||
g_rebuildDataOut.storeInTesselator();
|
||||
pOutData = &g_rebuildDataOut;
|
||||
#else
|
||||
g_rebuildDataIn.disableUnseenTiles();
|
||||
TileRenderer_SPU* pTileRenderer =
|
||||
new TileRenderer_SPU(&g_rebuildDataIn);
|
||||
g_rebuildDataIn.tesselateAllTiles(pTileRenderer);
|
||||
g_rebuildDataIn.storeInTesselator();
|
||||
pOutData = &g_rebuildDataIn;
|
||||
#endif
|
||||
|
||||
if (pOutData->m_flags & ChunkRebuildData::e_flag_Rendered)
|
||||
rendered = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.player.h"
|
||||
#include "../Chunk.h"
|
||||
|
||||
DirtyChunkSorter::DirtyChunkSorter(std::shared_ptr<Mob> cameraEntity,
|
||||
DirtyChunkSorter::DirtyChunkSorter(std::shared_ptr<LivingEntity> cameraEntity,
|
||||
int playerIndex) // 4J - added player index
|
||||
{
|
||||
this->cameraEntity = cameraEntity;
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@
|
|||
class Chunk;
|
||||
class Mob;
|
||||
|
||||
class DirtyChunkSorter {
|
||||
class DirtyChunkSorter
|
||||
: public std::binary_function<const Chunk*, const Chunk*, bool> {
|
||||
private:
|
||||
std::shared_ptr<Mob> cameraEntity;
|
||||
std::shared_ptr<LivingEntity> cameraEntity;
|
||||
int playerIndex; // 4J added
|
||||
|
||||
public:
|
||||
DirtyChunkSorter(std::shared_ptr<Mob> cameraEntity,
|
||||
DirtyChunkSorter(std::shared_ptr<LivingEntity> cameraEntity,
|
||||
int playerIndex); // 4J - added player index
|
||||
bool operator()(const Chunk* a, const Chunk* b) const;
|
||||
};
|
||||
|
|
@ -2,7 +2,8 @@
|
|||
class Entity;
|
||||
class Chunk;
|
||||
|
||||
class DistanceChunkSorter {
|
||||
class DistanceChunkSorter
|
||||
: public std::binary_function<const Chunk*, const Chunk*, bool> {
|
||||
private:
|
||||
double ix, iy, iz;
|
||||
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ bool ViewportCuller::Face::fullyInFront(double x0, double y0, double z0,
|
|||
return true;
|
||||
}
|
||||
|
||||
ViewportCuller::ViewportCuller(std::shared_ptr<Mob> mob, double fogDistance,
|
||||
float a) {
|
||||
ViewportCuller::ViewportCuller(std::shared_ptr<LivingEntity> mob,
|
||||
double fogDistance, float a) {
|
||||
float yRot = mob->yRotO + (mob->yRot - mob->yRotO) * a;
|
||||
float xRot = mob->xRotO + (mob->xRot - mob->xRotO) * a;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ private:
|
|||
double xOff, yOff, zOff;
|
||||
|
||||
public:
|
||||
ViewportCuller(std::shared_ptr<Mob> mob, double fogDistance, float a);
|
||||
ViewportCuller(std::shared_ptr<LivingEntity> mob, double fogDistance,
|
||||
float a);
|
||||
virtual bool isVisible(AABB bb);
|
||||
virtual bool cubeInFrustum(double x0, double y0, double z0, double x1,
|
||||
double y1, double z1);
|
||||
|
|
|
|||
|
|
@ -3,13 +3,16 @@
|
|||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.projectile.h"
|
||||
#include "../../../Minecraft.World/Util/Mth.h"
|
||||
|
||||
ResourceLocation ArrowRenderer::ARROW_LOCATION =
|
||||
ResourceLocation(TN_ITEM_ARROWS);
|
||||
|
||||
void ArrowRenderer::render(std::shared_ptr<Entity> _arrow, double x, double y,
|
||||
double z, float rot, float a) {
|
||||
// 4J - original version used generics and thus had an input parameter of
|
||||
// type Arrow rather than std::shared_ptr<Entity> we have here - do some
|
||||
// casting around instead
|
||||
// type Arrow rather than shared_ptr<Entity> we have here - do some casting
|
||||
// around instead
|
||||
std::shared_ptr<Arrow> arrow = std::dynamic_pointer_cast<Arrow>(_arrow);
|
||||
bindTexture(TN_ITEM_ARROWS); // 4J - was L"/item/arrows.png"
|
||||
bindTexture(_arrow); // 4J - was L"/item/arrows.png"
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
|
|
@ -98,4 +101,9 @@ void ArrowRenderer::render(std::shared_ptr<Entity> _arrow, double x, double y,
|
|||
}
|
||||
glDisable(GL_RESCALE_NORMAL);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
ResourceLocation* ArrowRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &ARROW_LOCATION;
|
||||
}
|
||||
|
|
@ -2,7 +2,11 @@
|
|||
#include "EntityRenderer.h"
|
||||
|
||||
class ArrowRenderer : public EntityRenderer {
|
||||
private:
|
||||
static ResourceLocation ARROW_LOCATION;
|
||||
|
||||
public:
|
||||
virtual void render(std::shared_ptr<Entity> _arrow, double x, double y,
|
||||
double z, float rot, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
};
|
||||
|
|
|
|||
44
Minecraft.Client/Rendering/EntityRenderers/BatRenderer.cpp
Normal file
44
Minecraft.Client/Rendering/EntityRenderers/BatRenderer.cpp
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.ambient.h"
|
||||
#include "BatRenderer.h"
|
||||
#include "../Models/BatModel.h"
|
||||
|
||||
ResourceLocation BatRenderer::BAT_LOCATION = ResourceLocation(TN_MOB_BAT);
|
||||
|
||||
BatRenderer::BatRenderer() : MobRenderer(new BatModel(), 0.25f) {
|
||||
modelVersion = ((BatModel*)model)->modelVersion();
|
||||
}
|
||||
|
||||
void BatRenderer::render(std::shared_ptr<Entity> _mob, double x, double y,
|
||||
double z, float rot, float a) {
|
||||
int modelVersion = (dynamic_cast<BatModel*>(model))->modelVersion();
|
||||
if (modelVersion != this->modelVersion) {
|
||||
this->modelVersion = modelVersion;
|
||||
model = new BatModel();
|
||||
}
|
||||
MobRenderer::render(_mob, x, y, z, rot, a);
|
||||
}
|
||||
|
||||
ResourceLocation* BatRenderer::getTextureLocation(std::shared_ptr<Entity> mob) {
|
||||
return &BAT_LOCATION;
|
||||
}
|
||||
|
||||
void BatRenderer::scale(std::shared_ptr<LivingEntity> mob, float a) {
|
||||
glScalef(.35f, .35f, .35f);
|
||||
}
|
||||
|
||||
void BatRenderer::setupPosition(std::shared_ptr<LivingEntity> mob, double x,
|
||||
double y, double z) {
|
||||
MobRenderer::setupPosition(mob, x, y, z);
|
||||
}
|
||||
|
||||
void BatRenderer::setupRotations(std::shared_ptr<LivingEntity> _mob, float bob,
|
||||
float bodyRot, float a) {
|
||||
std::shared_ptr<Bat> mob = std::dynamic_pointer_cast<Bat>(_mob);
|
||||
if (!mob->isResting()) {
|
||||
glTranslatef(0, cos(bob * .3f) * .1f, 0);
|
||||
} else {
|
||||
glTranslatef(0, -.1f, 0);
|
||||
}
|
||||
MobRenderer::setupRotations(mob, bob, bodyRot, a);
|
||||
}
|
||||
22
Minecraft.Client/Rendering/EntityRenderers/BatRenderer.h
Normal file
22
Minecraft.Client/Rendering/EntityRenderers/BatRenderer.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
#include "MobRenderer.h"
|
||||
|
||||
class BatModel;
|
||||
|
||||
class BatRenderer : public MobRenderer {
|
||||
static ResourceLocation BAT_LOCATION;
|
||||
int modelVersion;
|
||||
|
||||
public:
|
||||
BatRenderer();
|
||||
virtual void render(std::shared_ptr<Entity> _mob, double x, double y,
|
||||
double z, float rot, float a);
|
||||
|
||||
protected:
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
virtual void scale(std::shared_ptr<LivingEntity> mob, float a);
|
||||
virtual void setupPosition(std::shared_ptr<LivingEntity> mob, double x,
|
||||
double y, double z);
|
||||
virtual void setupRotations(std::shared_ptr<LivingEntity> mob, float bob,
|
||||
float bodyRot, float a);
|
||||
};
|
||||
140
Minecraft.Client/Rendering/EntityRenderers/BeaconRenderer.cpp
Normal file
140
Minecraft.Client/Rendering/EntityRenderers/BeaconRenderer.cpp
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.level.tile.entity.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
||||
#include "BeaconRenderer.h"
|
||||
#include "../Tesselator.h"
|
||||
|
||||
ResourceLocation BeaconRenderer::BEAM_LOCATION =
|
||||
ResourceLocation(TN_MISC_BEACON_BEAM);
|
||||
|
||||
void BeaconRenderer::render(std::shared_ptr<TileEntity> _beacon, double x,
|
||||
double y, double z, float a, bool setColor,
|
||||
float alpha, bool useCompiled) {
|
||||
std::shared_ptr<BeaconTileEntity> beacon =
|
||||
std::dynamic_pointer_cast<BeaconTileEntity>(_beacon);
|
||||
|
||||
float scale = beacon->getAndUpdateClientSideScale();
|
||||
|
||||
if (scale > 0) {
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
|
||||
bindTexture(&BEAM_LOCATION);
|
||||
|
||||
// TODO: 4J: Put this back in
|
||||
// assert(0);
|
||||
// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
// glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_BLEND);
|
||||
glDepthMask(true);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
|
||||
float tt = beacon->getLevel()->getGameTime() + a;
|
||||
float texVOff = -tt * .20f - floor(-tt * .10f);
|
||||
|
||||
{
|
||||
int r = 1;
|
||||
|
||||
double rot = tt * .025 * (1 - (r & 1) * 2.5);
|
||||
|
||||
t->begin();
|
||||
t->color(255, 255, 255, 32);
|
||||
|
||||
double rr1 = r * 0.2;
|
||||
|
||||
double wnx = .5 + cos(rot + PI * .75) * rr1;
|
||||
double wnz = .5 + sin(rot + PI * .75) * rr1;
|
||||
double enx = .5 + cos(rot + PI * .25) * rr1;
|
||||
double enz = .5 + sin(rot + PI * .25) * rr1;
|
||||
|
||||
double wsx = .5 + cos(rot + PI * 1.25) * rr1;
|
||||
double wsz = .5 + sin(rot + PI * 1.25) * rr1;
|
||||
double esx = .5 + cos(rot + PI * 1.75) * rr1;
|
||||
double esz = .5 + sin(rot + PI * 1.75) * rr1;
|
||||
|
||||
double top = 256 * scale;
|
||||
|
||||
double uu1 = 0;
|
||||
double uu2 = 1;
|
||||
double vv2 = -1 + texVOff;
|
||||
double vv1 = 256 * scale * (.5 / rr1) + vv2;
|
||||
|
||||
t->vertexUV(x + wnx, y + top, z + wnz, uu2, vv1);
|
||||
t->vertexUV(x + wnx, y, z + wnz, uu2, vv2);
|
||||
t->vertexUV(x + enx, y, z + enz, uu1, vv2);
|
||||
t->vertexUV(x + enx, y + top, z + enz, uu1, vv1);
|
||||
|
||||
t->vertexUV(x + esx, y + top, z + esz, uu2, vv1);
|
||||
t->vertexUV(x + esx, y, z + esz, uu2, vv2);
|
||||
t->vertexUV(x + wsx, y, z + wsz, uu1, vv2);
|
||||
t->vertexUV(x + wsx, y + top, z + wsz, uu1, vv1);
|
||||
|
||||
t->vertexUV(x + enx, y + top, z + enz, uu2, vv1);
|
||||
t->vertexUV(x + enx, y, z + enz, uu2, vv2);
|
||||
t->vertexUV(x + esx, y, z + esz, uu1, vv2);
|
||||
t->vertexUV(x + esx, y + top, z + esz, uu1, vv1);
|
||||
|
||||
t->vertexUV(x + wsx, y + top, z + wsz, uu2, vv1);
|
||||
t->vertexUV(x + wsx, y, z + wsz, uu2, vv2);
|
||||
t->vertexUV(x + wnx, y, z + wnz, uu1, vv2);
|
||||
t->vertexUV(x + wnx, y + top, z + wnz, uu1, vv1);
|
||||
|
||||
t->end();
|
||||
}
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDepthMask(false);
|
||||
|
||||
{
|
||||
t->begin();
|
||||
t->color(255, 255, 255, 32);
|
||||
|
||||
double wnx = .2;
|
||||
double wnz = .2;
|
||||
double enx = .8;
|
||||
double enz = .2;
|
||||
|
||||
double wsx = .2;
|
||||
double wsz = .8;
|
||||
double esx = .8;
|
||||
double esz = .8;
|
||||
|
||||
double top = 256 * scale;
|
||||
|
||||
double uu1 = 0;
|
||||
double uu2 = 1;
|
||||
double vv2 = -1 + texVOff;
|
||||
double vv1 = 256 * scale + vv2;
|
||||
|
||||
t->vertexUV(x + wnx, y + top, z + wnz, uu2, vv1);
|
||||
t->vertexUV(x + wnx, y, z + wnz, uu2, vv2);
|
||||
t->vertexUV(x + enx, y, z + enz, uu1, vv2);
|
||||
t->vertexUV(x + enx, y + top, z + enz, uu1, vv1);
|
||||
|
||||
t->vertexUV(x + esx, y + top, z + esz, uu2, vv1);
|
||||
t->vertexUV(x + esx, y, z + esz, uu2, vv2);
|
||||
t->vertexUV(x + wsx, y, z + wsz, uu1, vv2);
|
||||
t->vertexUV(x + wsx, y + top, z + wsz, uu1, vv1);
|
||||
|
||||
t->vertexUV(x + enx, y + top, z + enz, uu2, vv1);
|
||||
t->vertexUV(x + enx, y, z + enz, uu2, vv2);
|
||||
t->vertexUV(x + esx, y, z + esz, uu1, vv2);
|
||||
t->vertexUV(x + esx, y + top, z + esz, uu1, vv1);
|
||||
|
||||
t->vertexUV(x + wsx, y + top, z + wsz, uu2, vv1);
|
||||
t->vertexUV(x + wsx, y, z + wsz, uu2, vv2);
|
||||
t->vertexUV(x + wnx, y, z + wnz, uu1, vv2);
|
||||
t->vertexUV(x + wnx, y + top, z + wnz, uu1, vv1);
|
||||
|
||||
t->end();
|
||||
}
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glDepthMask(true);
|
||||
}
|
||||
}
|
||||
14
Minecraft.Client/Rendering/EntityRenderers/BeaconRenderer.h
Normal file
14
Minecraft.Client/Rendering/EntityRenderers/BeaconRenderer.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#pragma once
|
||||
#include "TileEntityRenderer.h"
|
||||
|
||||
class BeaconTileEntity;
|
||||
|
||||
class BeaconRenderer : public TileEntityRenderer {
|
||||
private:
|
||||
static ResourceLocation BEAM_LOCATION;
|
||||
|
||||
public:
|
||||
virtual void render(std::shared_ptr<TileEntity> _beacon, double x, double y,
|
||||
double z, float a, bool setColor, float alpha,
|
||||
bool useCompiled);
|
||||
};
|
||||
|
|
@ -3,15 +3,17 @@
|
|||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.monster.h"
|
||||
#include "BlazeRenderer.h"
|
||||
|
||||
ResourceLocation BlazeRenderer::BLAZE_LOCATION = ResourceLocation(TN_MOB_BLAZE);
|
||||
|
||||
BlazeRenderer::BlazeRenderer() : MobRenderer(new BlazeModel(), 0.5f) {
|
||||
this->modelVersion = ((BlazeModel*)model)->modelVersion();
|
||||
modelVersion = ((BlazeModel*)model)->modelVersion();
|
||||
}
|
||||
|
||||
void BlazeRenderer::render(std::shared_ptr<Entity> _mob, double x, double y,
|
||||
double z, float rot, float a) {
|
||||
// 4J - original version used generics and thus had an input parameter of
|
||||
// type Blaze rather than std::shared_ptr<Entity> we have here - do some
|
||||
// casting around instead
|
||||
// type Blaze rather than shared_ptr<Entity> we have here - do some casting
|
||||
// around instead
|
||||
std::shared_ptr<Blaze> mob = std::dynamic_pointer_cast<Blaze>(_mob);
|
||||
|
||||
int modelVersion = ((BlazeModel*)model)->modelVersion();
|
||||
|
|
@ -20,4 +22,9 @@ void BlazeRenderer::render(std::shared_ptr<Entity> _mob, double x, double y,
|
|||
model = new BlazeModel();
|
||||
}
|
||||
MobRenderer::render(mob, x, y, z, rot, a);
|
||||
}
|
||||
|
||||
ResourceLocation* BlazeRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &BLAZE_LOCATION;
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include "MobRenderer.h"
|
||||
|
||||
class BlazeRenderer : public MobRenderer {
|
||||
private:
|
||||
static ResourceLocation BLAZE_LOCATION;
|
||||
int modelVersion;
|
||||
|
||||
public:
|
||||
|
|
@ -11,4 +11,5 @@ public:
|
|||
|
||||
virtual void render(std::shared_ptr<Entity> mob, double x, double y,
|
||||
double z, float rot, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
};
|
||||
|
|
@ -4,6 +4,8 @@
|
|||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.item.h"
|
||||
#include "../../../Minecraft.World/Util/Mth.h"
|
||||
|
||||
ResourceLocation BoatRenderer::BOAT_LOCATION = ResourceLocation(TN_ITEM_BOAT);
|
||||
|
||||
BoatRenderer::BoatRenderer() : EntityRenderer() {
|
||||
this->shadowRadius = 0.5f;
|
||||
model = new BoatModel();
|
||||
|
|
@ -12,8 +14,8 @@ BoatRenderer::BoatRenderer() : EntityRenderer() {
|
|||
void BoatRenderer::render(std::shared_ptr<Entity> _boat, double x, double y,
|
||||
double z, float rot, float a) {
|
||||
// 4J - original version used generics and thus had an input parameter of
|
||||
// type Boat rather than std::shared_ptr<Entity> we have here - do some
|
||||
// casting around instead
|
||||
// type Boat rather than shared_ptr<Entity> we have here - do some casting
|
||||
// around instead
|
||||
std::shared_ptr<Boat> boat = std::dynamic_pointer_cast<Boat>(_boat);
|
||||
|
||||
glPushMatrix();
|
||||
|
|
@ -29,13 +31,17 @@ void BoatRenderer::render(std::shared_ptr<Entity> _boat, double x, double y,
|
|||
0);
|
||||
}
|
||||
|
||||
bindTexture(TN_TERRAIN); // 4J was L"/terrain.png"
|
||||
float ss = 12 / 16.0f;
|
||||
glScalef(ss, ss, ss);
|
||||
glScalef(1 / ss, 1 / ss, 1 / ss);
|
||||
|
||||
bindTexture(TN_ITEM_BOAT); // 4J was L"/item/boat.png"
|
||||
bindTexture(boat);
|
||||
glScalef(-1, -1, 1);
|
||||
model->render(boat, 0, 0, -0.1f, 0, 0, 1 / 16.0f, true);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
ResourceLocation* BoatRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &BOAT_LOCATION;
|
||||
}
|
||||
|
|
@ -2,6 +2,9 @@
|
|||
#include "EntityRenderer.h"
|
||||
|
||||
class BoatRenderer : public EntityRenderer {
|
||||
private:
|
||||
static ResourceLocation BOAT_LOCATION;
|
||||
|
||||
protected:
|
||||
Model* model;
|
||||
|
||||
|
|
@ -10,4 +13,5 @@ public:
|
|||
|
||||
virtual void render(std::shared_ptr<Entity> boat, double x, double y,
|
||||
double z, float rot, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
};
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "CaveSpiderRenderer.h"
|
||||
|
||||
ResourceLocation CaveSpiderRenderer::CAVE_SPIDER_LOCATION =
|
||||
ResourceLocation(TN_MOB_CAVE_SPIDER);
|
||||
float CaveSpiderRenderer::s_scale = 0.7f;
|
||||
|
||||
CaveSpiderRenderer::CaveSpiderRenderer() : SpiderRenderer() {
|
||||
shadowRadius *= s_scale;
|
||||
}
|
||||
|
||||
void CaveSpiderRenderer::scale(std::shared_ptr<LivingEntity> mob, float a) {
|
||||
glScalef(s_scale, s_scale, s_scale);
|
||||
}
|
||||
|
||||
ResourceLocation* CaveSpiderRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &CAVE_SPIDER_LOCATION;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
#include "SpiderRenderer.h"
|
||||
|
||||
class CaveSpider;
|
||||
|
||||
class CaveSpiderRenderer : public SpiderRenderer {
|
||||
private:
|
||||
static ResourceLocation CAVE_SPIDER_LOCATION;
|
||||
static float s_scale;
|
||||
|
||||
public:
|
||||
CaveSpiderRenderer();
|
||||
|
||||
protected:
|
||||
virtual void scale(std::shared_ptr<LivingEntity> mob, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
};
|
||||
|
|
@ -5,10 +5,34 @@
|
|||
#include "../Models/ModelPart.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.level.tile.entity.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.level.tile.h"
|
||||
#include "../../../Minecraft.World/Level/Calendar.h"
|
||||
|
||||
ChestRenderer::ChestRenderer() {
|
||||
ResourceLocation ChestRenderer::CHEST_LARGE_TRAP_LOCATION =
|
||||
ResourceLocation(TN_TILE_LARGE_TRAP_CHEST);
|
||||
// ResourceLocation ChestRenderer::CHEST_LARGE_XMAS_LOCATION =
|
||||
// ResourceLocation(TN_TILE_LARGE_XMAS_CHEST);
|
||||
ResourceLocation ChestRenderer::CHEST_LARGE_LOCATION =
|
||||
ResourceLocation(TN_TILE_LARGE_CHEST);
|
||||
ResourceLocation ChestRenderer::CHEST_TRAP_LOCATION =
|
||||
ResourceLocation(TN_TILE_TRAP_CHEST);
|
||||
// ResourceLocation ChestRenderer::CHEST_XMAS_LOCATION =
|
||||
// ResourceLocation(TN_TILE_XMAS_CHEST);
|
||||
ResourceLocation ChestRenderer::CHEST_LOCATION =
|
||||
ResourceLocation(TN_TILE_CHEST);
|
||||
|
||||
ChestRenderer::ChestRenderer() : TileEntityRenderer() {
|
||||
chestModel = new ChestModel();
|
||||
largeChestModel = new LargeChestModel();
|
||||
|
||||
xmasTextures = false;
|
||||
|
||||
// 4J Stu - Disable this
|
||||
#if 0
|
||||
if (Calendar::GetMonth() + 1 == 12 && Calendar::GetDayOfMonth() >= 24 && Calendar::GetDayOfMonth() <= 26)
|
||||
{
|
||||
xmasTextures = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ChestRenderer::~ChestRenderer() {
|
||||
|
|
@ -31,7 +55,7 @@ void ChestRenderer::render(std::shared_ptr<TileEntity> _chest, double x,
|
|||
Tile* tile = chest->getTile();
|
||||
data = chest->getData();
|
||||
|
||||
if (tile != NULL && data == 0) {
|
||||
if (dynamic_cast<ChestTile*>(tile) != NULL && data == 0) {
|
||||
((ChestTile*)tile)
|
||||
->recalcLockDir(chest->getLevel(), chest->x, chest->y,
|
||||
chest->z);
|
||||
|
|
@ -45,10 +69,29 @@ void ChestRenderer::render(std::shared_ptr<TileEntity> _chest, double x,
|
|||
ChestModel* model;
|
||||
if (chest->e.lock() != NULL || chest->s.lock() != NULL) {
|
||||
model = largeChestModel;
|
||||
bindTexture(TN_TILE_LARGE_CHEST); // 4J Was "/item/largechest.png"
|
||||
|
||||
if (chest->getType() == ChestTile::TYPE_TRAP) {
|
||||
bindTexture(&CHEST_LARGE_TRAP_LOCATION);
|
||||
}
|
||||
// else if (xmasTextures)
|
||||
//{
|
||||
// bindTexture(&CHEST_LARGE_XMAS_LOCATION);
|
||||
// }
|
||||
else {
|
||||
bindTexture(&CHEST_LARGE_LOCATION);
|
||||
}
|
||||
} else {
|
||||
model = chestModel;
|
||||
bindTexture(TN_TILE_CHEST); // 4J Was "/item/chest.png"
|
||||
if (chest->getType() == ChestTile::TYPE_TRAP) {
|
||||
bindTexture(&CHEST_TRAP_LOCATION);
|
||||
}
|
||||
// else if (xmasTextures)
|
||||
//{
|
||||
// bindTexture(&CHEST_XMAS_LOCATION);
|
||||
// }
|
||||
else {
|
||||
bindTexture(&CHEST_LOCATION);
|
||||
}
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
|
|
|
|||
|
|
@ -1,13 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include "TileEntityRenderer.h"
|
||||
|
||||
class ChestModel;
|
||||
|
||||
class ChestRenderer : public TileEntityRenderer {
|
||||
private:
|
||||
static ResourceLocation CHEST_LARGE_TRAP_LOCATION;
|
||||
// static ResourceLocation CHEST_LARGE_XMAS_LOCATION;
|
||||
static ResourceLocation CHEST_LARGE_LOCATION;
|
||||
static ResourceLocation CHEST_TRAP_LOCATION;
|
||||
// static ResourceLocation CHEST_XMAS_LOCATION;
|
||||
static ResourceLocation CHEST_LOCATION;
|
||||
|
||||
ChestModel* chestModel;
|
||||
ChestModel* largeChestModel;
|
||||
boolean xmasTextures;
|
||||
|
||||
public:
|
||||
ChestRenderer();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
#include "ChickenRenderer.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.animal.h"
|
||||
|
||||
ResourceLocation ChickenRenderer::CHICKEN_LOCATION =
|
||||
ResourceLocation(TN_MOB_CHICKEN);
|
||||
|
||||
ChickenRenderer::ChickenRenderer(Model* model, float shadow)
|
||||
: MobRenderer(model, shadow) {}
|
||||
|
||||
|
|
@ -11,7 +14,7 @@ void ChickenRenderer::render(std::shared_ptr<Entity> _mob, double x, double y,
|
|||
MobRenderer::render(_mob, x, y, z, rot, a);
|
||||
}
|
||||
|
||||
float ChickenRenderer::getBob(std::shared_ptr<Mob> _mob, float a) {
|
||||
float ChickenRenderer::getBob(std::shared_ptr<LivingEntity> _mob, float a) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
std::shared_ptr<Chicken> mob = std::dynamic_pointer_cast<Chicken>(_mob);
|
||||
|
|
@ -20,4 +23,9 @@ float ChickenRenderer::getBob(std::shared_ptr<Mob> _mob, float a) {
|
|||
float flapSpeed = mob->oFlapSpeed + (mob->flapSpeed - mob->oFlapSpeed) * a;
|
||||
|
||||
return (Mth::sin(flap) + 1) * flapSpeed;
|
||||
}
|
||||
|
||||
ResourceLocation* ChickenRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &CHICKEN_LOCATION;
|
||||
}
|
||||
|
|
@ -2,11 +2,15 @@
|
|||
#include "MobRenderer.h"
|
||||
|
||||
class ChickenRenderer : public MobRenderer {
|
||||
private:
|
||||
static ResourceLocation CHICKEN_LOCATION;
|
||||
|
||||
public:
|
||||
ChickenRenderer(Model* model, float shadow);
|
||||
virtual void render(std::shared_ptr<Entity> _mob, double x, double y,
|
||||
double z, float rot, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
|
||||
protected:
|
||||
virtual float getBob(std::shared_ptr<Mob> _mob, float a);
|
||||
virtual float getBob(std::shared_ptr<LivingEntity> _mob, float a);
|
||||
};
|
||||
|
|
@ -1,10 +1,16 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "CowRenderer.h"
|
||||
|
||||
ResourceLocation CowRenderer::COW_LOCATION = ResourceLocation(TN_MOB_COW);
|
||||
|
||||
CowRenderer::CowRenderer(Model* model, float shadow)
|
||||
: MobRenderer(model, shadow) {}
|
||||
|
||||
void CowRenderer::render(std::shared_ptr<Entity> _mob, double x, double y,
|
||||
double z, float rot, float a) {
|
||||
MobRenderer::render(_mob, x, y, z, rot, a);
|
||||
}
|
||||
|
||||
ResourceLocation* CowRenderer::getTextureLocation(std::shared_ptr<Entity> mob) {
|
||||
return &COW_LOCATION;
|
||||
}
|
||||
|
|
@ -2,8 +2,13 @@
|
|||
#include "MobRenderer.h"
|
||||
|
||||
class CowRenderer : public MobRenderer {
|
||||
private:
|
||||
static ResourceLocation COW_LOCATION;
|
||||
|
||||
public:
|
||||
CowRenderer(Model* model, float shadow);
|
||||
|
||||
virtual void render(std::shared_ptr<Entity> _mob, double x, double y,
|
||||
double z, float rot, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
};
|
||||
|
|
@ -4,11 +4,16 @@
|
|||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.monster.h"
|
||||
#include "../../../Minecraft.World/Util/Mth.h"
|
||||
|
||||
ResourceLocation CreeperRenderer::POWER_LOCATION =
|
||||
ResourceLocation(TN_POWERED_CREEPER);
|
||||
ResourceLocation CreeperRenderer::CREEPER_LOCATION =
|
||||
ResourceLocation(TN_MOB_CREEPER);
|
||||
|
||||
CreeperRenderer::CreeperRenderer() : MobRenderer(new CreeperModel(), 0.5f) {
|
||||
armorModel = new CreeperModel(2);
|
||||
}
|
||||
|
||||
void CreeperRenderer::scale(std::shared_ptr<Mob> mob, float a) {
|
||||
void CreeperRenderer::scale(std::shared_ptr<LivingEntity> mob, float a) {
|
||||
std::shared_ptr<Creeper> creeper = std::dynamic_pointer_cast<Creeper>(mob);
|
||||
|
||||
float g = creeper->getSwelling(a);
|
||||
|
|
@ -23,8 +28,8 @@ void CreeperRenderer::scale(std::shared_ptr<Mob> mob, float a) {
|
|||
glScalef(s, hs, s);
|
||||
}
|
||||
|
||||
int CreeperRenderer::getOverlayColor(std::shared_ptr<Mob> mob, float br,
|
||||
float a) {
|
||||
int CreeperRenderer::getOverlayColor(std::shared_ptr<LivingEntity> mob,
|
||||
float br, float a) {
|
||||
std::shared_ptr<Creeper> creeper = std::dynamic_pointer_cast<Creeper>(mob);
|
||||
|
||||
float step = creeper->getSwelling(a);
|
||||
|
|
@ -44,7 +49,7 @@ int CreeperRenderer::getOverlayColor(std::shared_ptr<Mob> mob, float br,
|
|||
return (_a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
int CreeperRenderer::prepareArmor(std::shared_ptr<Mob> _mob, int layer,
|
||||
int CreeperRenderer::prepareArmor(std::shared_ptr<LivingEntity> _mob, int layer,
|
||||
float a) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
|
|
@ -57,7 +62,7 @@ int CreeperRenderer::prepareArmor(std::shared_ptr<Mob> _mob, int layer,
|
|||
|
||||
if (layer == 1) {
|
||||
float time = mob->tickCount + a;
|
||||
bindTexture(TN_POWERED_CREEPER); // was L"/armor/power.png");
|
||||
bindTexture(&POWER_LOCATION);
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
float uo = time * 0.01f;
|
||||
|
|
@ -83,7 +88,12 @@ int CreeperRenderer::prepareArmor(std::shared_ptr<Mob> _mob, int layer,
|
|||
return -1;
|
||||
}
|
||||
|
||||
int CreeperRenderer::prepareArmorOverlay(std::shared_ptr<Mob> mob, int layer,
|
||||
float a) {
|
||||
int CreeperRenderer::prepareArmorOverlay(std::shared_ptr<LivingEntity> mob,
|
||||
int layer, float a) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ResourceLocation* CreeperRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &CREEPER_LOCATION;
|
||||
}
|
||||
|
|
@ -3,15 +3,20 @@
|
|||
|
||||
class CreeperRenderer : public MobRenderer {
|
||||
private:
|
||||
static ResourceLocation POWER_LOCATION;
|
||||
static ResourceLocation CREEPER_LOCATION;
|
||||
Model* armorModel;
|
||||
|
||||
public:
|
||||
CreeperRenderer();
|
||||
|
||||
protected:
|
||||
virtual void scale(std::shared_ptr<Mob> _mob, float a);
|
||||
virtual int getOverlayColor(std::shared_ptr<Mob> mob, float br, float a);
|
||||
virtual int prepareArmor(std::shared_ptr<Mob> mob, int layer, float a);
|
||||
virtual int prepareArmorOverlay(std::shared_ptr<Mob> _mob, int layer,
|
||||
float a);
|
||||
virtual void scale(std::shared_ptr<LivingEntity> _mob, float a);
|
||||
virtual int getOverlayColor(std::shared_ptr<LivingEntity> mob, float br,
|
||||
float a);
|
||||
virtual int prepareArmor(std::shared_ptr<LivingEntity> mob, int layer,
|
||||
float a);
|
||||
virtual int prepareArmorOverlay(std::shared_ptr<LivingEntity> _mob,
|
||||
int layer, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
};
|
||||
|
|
@ -5,4 +5,7 @@ class DefaultRenderer : public EntityRenderer {
|
|||
public:
|
||||
virtual void render(std::shared_ptr<Entity> entity, double x, double y,
|
||||
double z, float rot, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob) {
|
||||
return NULL;
|
||||
};
|
||||
};
|
||||
|
|
@ -4,6 +4,9 @@
|
|||
#include "../../../Minecraft.World/Util/Mth.h"
|
||||
#include "EnchantTableRenderer.h"
|
||||
|
||||
ResourceLocation EnchantTableRenderer::BOOK_LOCATION =
|
||||
ResourceLocation(TN_ITEM_BOOK);
|
||||
|
||||
EnchantTableRenderer::EnchantTableRenderer() { bookModel = new BookModel(); }
|
||||
|
||||
EnchantTableRenderer::~EnchantTableRenderer() { delete bookModel; }
|
||||
|
|
@ -38,7 +41,7 @@ void EnchantTableRenderer::render(std::shared_ptr<TileEntity> _table, double x,
|
|||
|
||||
glRotatef(-yRot * 180 / PI, 0, 1, 0);
|
||||
glRotatef(80, 0, 0, 1);
|
||||
bindTexture(TN_ITEM_BOOK); // 4J was "/item/book.png"
|
||||
bindTexture(&BOOK_LOCATION); // 4J was "/item/book.png"
|
||||
|
||||
float ff1 = table->oFlip + (table->flip - table->oFlip) * a + 0.25f;
|
||||
float ff2 = table->oFlip + (table->flip - table->oFlip) * a + 0.75f;
|
||||
|
|
@ -51,6 +54,7 @@ void EnchantTableRenderer::render(std::shared_ptr<TileEntity> _table, double x,
|
|||
if (ff2 > 1) ff2 = 1;
|
||||
|
||||
float o = table->oOpen + (table->open - table->oOpen) * a;
|
||||
glEnable(GL_CULL_FACE);
|
||||
bookModel->render(nullptr, tt, ff1, ff2, o, 0, 1 / 16.0f, true);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#pragma once
|
||||
|
||||
#include "TileEntityRenderer.h"
|
||||
|
||||
class BookModel;
|
||||
|
|
@ -9,6 +8,8 @@ class EnchantTableRenderer : public TileEntityRenderer {
|
|||
friend class UIControl_EnchantmentBook;
|
||||
|
||||
private:
|
||||
static ResourceLocation BOOK_LOCATION;
|
||||
|
||||
BookModel* bookModel;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
#include "../Models/ModelPart.h"
|
||||
#include "EnderChestRenderer.h"
|
||||
|
||||
ResourceLocation EnderChestRenderer::ENDER_CHEST_LOCATION =
|
||||
ResourceLocation(TN_TILE_ENDER_CHEST);
|
||||
|
||||
void EnderChestRenderer::render(std::shared_ptr<TileEntity> _chest, double x,
|
||||
double y, double z, float a, bool setColor,
|
||||
float alpha, bool useCompiled) {
|
||||
|
|
@ -16,7 +19,7 @@ void EnderChestRenderer::render(std::shared_ptr<TileEntity> _chest, double x,
|
|||
data = chest->getData();
|
||||
}
|
||||
|
||||
bindTexture(TN_TILE_ENDER_CHEST); //"/item/enderchest.png");
|
||||
bindTexture(&ENDER_CHEST_LOCATION);
|
||||
|
||||
glPushMatrix();
|
||||
glEnable(GL_RESCALE_NORMAL);
|
||||
|
|
@ -32,12 +35,6 @@ void EnderChestRenderer::render(std::shared_ptr<TileEntity> _chest, double x,
|
|||
if (data == 4) rot = 90;
|
||||
if (data == 5) rot = -90;
|
||||
|
||||
// if (data == 2) {
|
||||
// glTranslatef(1, 0, 0);
|
||||
// }
|
||||
// if (data == 5) {
|
||||
// glTranslatef(0, 0, -1);
|
||||
// }
|
||||
glRotatef(rot, 0, 1, 0);
|
||||
glTranslatef(-0.5f, -0.5f, -0.5f);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "TileEntityRenderer.h"
|
||||
#include "../Models/ChestModel.h"
|
||||
|
||||
class EnderChestRenderer : public TileEntityRenderer {
|
||||
private:
|
||||
static ResourceLocation ENDER_CHEST_LOCATION;
|
||||
ChestModel chestModel;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.boss.enderdragon.h"
|
||||
#include "EnderCrystalRenderer.h"
|
||||
|
||||
ResourceLocation EnderCrystalRenderer::ENDER_CRYSTAL_LOCATION =
|
||||
ResourceLocation(TN_MOB_ENDERDRAGON_ENDERCRYSTAL);
|
||||
|
||||
EnderCrystalRenderer::EnderCrystalRenderer() {
|
||||
currentModel = -1;
|
||||
this->shadowRadius = 0.5f;
|
||||
|
|
@ -11,8 +14,8 @@ EnderCrystalRenderer::EnderCrystalRenderer() {
|
|||
void EnderCrystalRenderer::render(std::shared_ptr<Entity> _crystal, double x,
|
||||
double y, double z, float rot, float a) {
|
||||
// 4J - original version used generics and thus had an input parameter of
|
||||
// type EnderCrystal rather than std::shared_ptr<Entity> we have here - do
|
||||
// some casting around instead
|
||||
// type EnderCrystal rather than shared_ptr<Entity> we have here - do some
|
||||
// casting around instead
|
||||
std::shared_ptr<EnderCrystal> crystal =
|
||||
std::dynamic_pointer_cast<EnderCrystal>(_crystal);
|
||||
if (currentModel != EnderCrystalModel::MODEL_ID) {
|
||||
|
|
@ -23,12 +26,15 @@ void EnderCrystalRenderer::render(std::shared_ptr<Entity> _crystal, double x,
|
|||
float tt = crystal->time + a;
|
||||
glPushMatrix();
|
||||
glTranslatef((float)x, (float)y, (float)z);
|
||||
bindTexture(
|
||||
TN_MOB_ENDERDRAGON_ENDERCRYSTAL); // 4J was
|
||||
// "/mob/enderdragon/crystal.png"
|
||||
bindTexture(&ENDER_CRYSTAL_LOCATION);
|
||||
float hh = sin(tt * 0.2f) / 2 + 0.5f;
|
||||
hh = hh * hh + hh;
|
||||
model->render(crystal, 0, tt * 3, hh * 0.2f, 0, 0, 1 / 16.0f, true);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
ResourceLocation* EnderCrystalRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &ENDER_CRYSTAL_LOCATION;
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
#pragma once
|
||||
|
||||
#include "EntityRenderer.h"
|
||||
|
||||
class Model;
|
||||
|
|
@ -8,10 +7,12 @@ class EnderCrystalRenderer : public EntityRenderer {
|
|||
private:
|
||||
int currentModel;
|
||||
Model* model;
|
||||
static ResourceLocation ENDER_CRYSTAL_LOCATION;
|
||||
|
||||
public:
|
||||
EnderCrystalRenderer();
|
||||
|
||||
virtual void render(std::shared_ptr<Entity> _crystal, double x, double y,
|
||||
double z, float rot, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
};
|
||||
|
|
@ -4,19 +4,25 @@
|
|||
#include "../Tesselator.h"
|
||||
#include "../Lighting.h"
|
||||
#include "EnderDragonRenderer.h"
|
||||
#include "../../UI/BossMobGuiInfo.h"
|
||||
|
||||
std::shared_ptr<EnderDragon> EnderDragonRenderer::bossInstance;
|
||||
int EnderDragonRenderer::currentModel;
|
||||
ResourceLocation EnderDragonRenderer::DRAGON_EXPLODING_LOCATION =
|
||||
ResourceLocation(TN_MOB_ENDERDRAGON_SHUFFLE);
|
||||
ResourceLocation EnderDragonRenderer::CRYSTAL_BEAM_LOCATION =
|
||||
ResourceLocation(TN_MOB_ENDERDRAGON_BEAM);
|
||||
ResourceLocation EnderDragonRenderer::DRAGON_EYES_LOCATION =
|
||||
ResourceLocation(TN_MOB_ENDERDRAGON_ENDEREYES);
|
||||
ResourceLocation EnderDragonRenderer::DRAGON_LOCATION =
|
||||
ResourceLocation(TN_MOB_ENDERDRAGON);
|
||||
|
||||
EnderDragonRenderer::EnderDragonRenderer()
|
||||
: MobRenderer(new DragonModel(0), 0.5f) {
|
||||
currentModel = 0;
|
||||
dragonModel = (DragonModel*)model;
|
||||
this->setArmor(model);
|
||||
setArmor(model); // TODO: Make second constructor that assigns this.
|
||||
}
|
||||
|
||||
void EnderDragonRenderer::setupRotations(std::shared_ptr<Mob> _mob, float bob,
|
||||
float bodyRot, float a) {
|
||||
void EnderDragonRenderer::setupRotations(std::shared_ptr<LivingEntity> _mob,
|
||||
float bob, float bodyRot, float a) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
std::shared_ptr<EnderDragon> mob =
|
||||
|
|
@ -47,8 +53,8 @@ void EnderDragonRenderer::setupRotations(std::shared_ptr<Mob> _mob, float bob,
|
|||
}
|
||||
}
|
||||
|
||||
void EnderDragonRenderer::renderModel(std::shared_ptr<Entity> _mob, float wp,
|
||||
float ws, float bob,
|
||||
void EnderDragonRenderer::renderModel(std::shared_ptr<LivingEntity> _mob,
|
||||
float wp, float ws, float bob,
|
||||
float headRotMinusBodyRot, float headRotx,
|
||||
float scale) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
|
|
@ -62,8 +68,7 @@ void EnderDragonRenderer::renderModel(std::shared_ptr<Entity> _mob, float wp,
|
|||
glEnable(GL_ALPHA_TEST);
|
||||
glAlphaFunc(GL_GREATER, tt);
|
||||
bindTexture(
|
||||
mob->customTextureUrl,
|
||||
TN_MOB_ENDERDRAGON_SHUFFLE); // 4J was
|
||||
&DRAGON_EXPLODING_LOCATION); // 4J was
|
||||
// "/mob/enderdragon/shuffle.png"
|
||||
model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale,
|
||||
true);
|
||||
|
|
@ -72,7 +77,7 @@ void EnderDragonRenderer::renderModel(std::shared_ptr<Entity> _mob, float wp,
|
|||
glDepthFunc(GL_EQUAL);
|
||||
}
|
||||
|
||||
bindTexture(mob->customTextureUrl, mob->getTexture());
|
||||
bindTexture(mob);
|
||||
model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale, true);
|
||||
|
||||
if (mob->hurtTime > 0) {
|
||||
|
|
@ -103,11 +108,7 @@ void EnderDragonRenderer::render(std::shared_ptr<Entity> _mob, double x,
|
|||
// our version
|
||||
std::shared_ptr<EnderDragon> mob =
|
||||
std::dynamic_pointer_cast<EnderDragon>(_mob);
|
||||
EnderDragonRenderer::bossInstance = mob;
|
||||
if (currentModel != DragonModel::MODEL_ID) {
|
||||
model = new DragonModel(0);
|
||||
currentModel = DragonModel::MODEL_ID;
|
||||
}
|
||||
BossMobGuiInfo::setBossHealth(mob, false);
|
||||
MobRenderer::render(mob, x, y, z, rot, a);
|
||||
if (mob->nearestCrystal != NULL) {
|
||||
float tt = mob->nearestCrystal->time + a;
|
||||
|
|
@ -150,7 +151,7 @@ void EnderDragonRenderer::render(std::shared_ptr<Entity> _mob, double x,
|
|||
glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
|
||||
|
||||
bindTexture(
|
||||
TN_MOB_ENDERDRAGON_BEAM); // 4J was "/mob/enderdragon/beam.png"
|
||||
&CRYSTAL_BEAM_LOCATION); // 4J was "/mob/enderdragon/beam.png"
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
|
|
@ -184,8 +185,13 @@ void EnderDragonRenderer::render(std::shared_ptr<Entity> _mob, double x,
|
|||
}
|
||||
}
|
||||
|
||||
void EnderDragonRenderer::additionalRendering(std::shared_ptr<Mob> _mob,
|
||||
float a) {
|
||||
ResourceLocation* EnderDragonRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &DRAGON_LOCATION;
|
||||
}
|
||||
|
||||
void EnderDragonRenderer::additionalRendering(
|
||||
std::shared_ptr<LivingEntity> _mob, float a) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
std::shared_ptr<EnderDragon> mob =
|
||||
|
|
@ -242,8 +248,8 @@ void EnderDragonRenderer::additionalRendering(std::shared_ptr<Mob> _mob,
|
|||
}
|
||||
}
|
||||
|
||||
int EnderDragonRenderer::prepareArmor(std::shared_ptr<Mob> _mob, int layer,
|
||||
float a) {
|
||||
int EnderDragonRenderer::prepareArmor(std::shared_ptr<LivingEntity> _mob,
|
||||
int layer, float a) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
std::shared_ptr<EnderDragon> mob =
|
||||
|
|
@ -255,8 +261,7 @@ int EnderDragonRenderer::prepareArmor(std::shared_ptr<Mob> _mob, int layer,
|
|||
if (layer != 0) return -1;
|
||||
|
||||
bindTexture(
|
||||
TN_MOB_ENDERDRAGON_ENDEREYES); // 4J was
|
||||
// "/mob/enderdragon/ender_eyes.png"
|
||||
&DRAGON_EYES_LOCATION); // 4J was "/mob/enderdragon/ender_eyes.png"
|
||||
float br = 1;
|
||||
glEnable(GL_BLEND);
|
||||
// 4J Stu - We probably don't need to do this on 360 either (as we force it
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#pragma once
|
||||
|
||||
#include "MobRenderer.h"
|
||||
|
||||
#ifdef _XBOX
|
||||
|
|
@ -8,11 +7,11 @@ class EnderDragon;
|
|||
class DragonModel;
|
||||
|
||||
class EnderDragonRenderer : public MobRenderer {
|
||||
public:
|
||||
static std::shared_ptr<EnderDragon> bossInstance;
|
||||
|
||||
private:
|
||||
static int currentModel;
|
||||
static ResourceLocation DRAGON_EXPLODING_LOCATION;
|
||||
static ResourceLocation CRYSTAL_BEAM_LOCATION;
|
||||
static ResourceLocation DRAGON_EYES_LOCATION;
|
||||
static ResourceLocation DRAGON_LOCATION;
|
||||
|
||||
protected:
|
||||
DragonModel* dragonModel;
|
||||
|
|
@ -21,19 +20,20 @@ public:
|
|||
EnderDragonRenderer();
|
||||
|
||||
protected:
|
||||
virtual void setupRotations(std::shared_ptr<Mob> _mob, float bob,
|
||||
virtual void setupRotations(std::shared_ptr<LivingEntity> _mob, float bob,
|
||||
float bodyRot, float a);
|
||||
|
||||
protected:
|
||||
void renderModel(std::shared_ptr<Entity> _mob, float wp, float ws,
|
||||
float bob, float headRotMinusBodyRot, float headRotx,
|
||||
float scale);
|
||||
virtual void renderModel(std::shared_ptr<LivingEntity> _mob, float wp,
|
||||
float ws, float bob, float headRotMinusBodyRot,
|
||||
float headRotx, float scale);
|
||||
|
||||
public:
|
||||
virtual void render(std::shared_ptr<Entity> _mob, double x, double y,
|
||||
double z, float rot, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
|
||||
protected:
|
||||
virtual void additionalRendering(std::shared_ptr<Mob> _mob, float a);
|
||||
virtual int prepareArmor(std::shared_ptr<Mob> _mob, int layer, float a);
|
||||
virtual void additionalRendering(std::shared_ptr<LivingEntity> _mob,
|
||||
float a);
|
||||
virtual int prepareArmor(std::shared_ptr<LivingEntity> _mob, int layer,
|
||||
float a);
|
||||
};
|
||||
|
|
@ -1,9 +1,15 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "EnderManRenderer.h"
|
||||
#include "../Models/EnderManModel.h"
|
||||
#include "../../Textures/TextureAtlas.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.monster.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.level.tile.h"
|
||||
|
||||
ResourceLocation EndermanRenderer::ENDERMAN_EYES_LOCATION =
|
||||
ResourceLocation(TN_MOB_ENDERMAN_EYES);
|
||||
ResourceLocation EndermanRenderer::ENDERMAN_LOCATION =
|
||||
ResourceLocation(TN_MOB_ENDERMAN);
|
||||
|
||||
EndermanRenderer::EndermanRenderer() : MobRenderer(new EndermanModel(), 0.5f) {
|
||||
model = (EndermanModel*)MobRenderer::model;
|
||||
this->setArmor(model);
|
||||
|
|
@ -12,8 +18,8 @@ EndermanRenderer::EndermanRenderer() : MobRenderer(new EndermanModel(), 0.5f) {
|
|||
void EndermanRenderer::render(std::shared_ptr<Entity> _mob, double x, double y,
|
||||
double z, float rot, float a) {
|
||||
// 4J - original version used generics and thus had an input parameter of
|
||||
// type Boat rather than std::shared_ptr<Entity> we have here - do some
|
||||
// casting around instead
|
||||
// type Boat rather than shared_ptr<Entity> we have here - do some casting
|
||||
// around instead
|
||||
std::shared_ptr<EnderMan> mob = std::dynamic_pointer_cast<EnderMan>(_mob);
|
||||
|
||||
model->carrying = mob->getCarryingTile() > 0;
|
||||
|
|
@ -28,10 +34,16 @@ void EndermanRenderer::render(std::shared_ptr<Entity> _mob, double x, double y,
|
|||
MobRenderer::render(mob, x, y, z, rot, a);
|
||||
}
|
||||
|
||||
void EndermanRenderer::additionalRendering(std::shared_ptr<Mob> _mob, float a) {
|
||||
ResourceLocation* EndermanRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &ENDERMAN_LOCATION;
|
||||
}
|
||||
|
||||
void EndermanRenderer::additionalRendering(std::shared_ptr<LivingEntity> _mob,
|
||||
float a) {
|
||||
// 4J - original version used generics and thus had an input parameter of
|
||||
// type Boat rather than std::shared_ptr<Entity> we have here - do some
|
||||
// casting around instead
|
||||
// type Boat rather than shared_ptr<Entity> we have here - do some casting
|
||||
// around instead
|
||||
std::shared_ptr<EnderMan> mob = std::dynamic_pointer_cast<EnderMan>(_mob);
|
||||
|
||||
MobRenderer::additionalRendering(_mob, a);
|
||||
|
|
@ -45,7 +57,7 @@ void EndermanRenderer::additionalRendering(std::shared_ptr<Mob> _mob, float a) {
|
|||
s *= 1.00f;
|
||||
glRotatef(20, 1, 0, 0);
|
||||
glRotatef(45, 0, 1, 0);
|
||||
glScalef(s, -s, s);
|
||||
glScalef(-s, -s, s);
|
||||
|
||||
if (SharedConstants::TEXTURE_LIGHTING) {
|
||||
int col = mob->getLightColor(a);
|
||||
|
|
@ -57,7 +69,7 @@ void EndermanRenderer::additionalRendering(std::shared_ptr<Mob> _mob, float a) {
|
|||
}
|
||||
|
||||
glColor4f(1, 1, 1, 1);
|
||||
bindTexture(TN_TERRAIN); // 4J was L"/terrain.png"
|
||||
bindTexture(&TextureAtlas::LOCATION_BLOCKS); // TODO: bind by icon
|
||||
tileRenderer->renderTile(Tile::tiles[mob->getCarryingTile()],
|
||||
mob->getCarryingData(), 1);
|
||||
glPopMatrix();
|
||||
|
|
@ -65,16 +77,16 @@ void EndermanRenderer::additionalRendering(std::shared_ptr<Mob> _mob, float a) {
|
|||
}
|
||||
}
|
||||
|
||||
int EndermanRenderer::prepareArmor(std::shared_ptr<Mob> _mob, int layer,
|
||||
float a) {
|
||||
int EndermanRenderer::prepareArmor(std::shared_ptr<LivingEntity> _mob,
|
||||
int layer, float a) {
|
||||
// 4J - original version used generics and thus had an input parameter of
|
||||
// type Boat rather than std::shared_ptr<Entity> we have here - do some
|
||||
// casting around instead
|
||||
// type Boat rather than shared_ptr<Entity> we have here - do some casting
|
||||
// around instead
|
||||
std::shared_ptr<EnderMan> mob = std::dynamic_pointer_cast<EnderMan>(_mob);
|
||||
|
||||
if (layer != 0) return -1;
|
||||
|
||||
bindTexture(TN_MOB_ENDERMAN_EYES); // 4J was L"/mob/enderman_eyes.png"
|
||||
bindTexture(&ENDERMAN_EYES_LOCATION); // 4J was L"/mob/enderman_eyes.png"
|
||||
float br = 1;
|
||||
glEnable(GL_BLEND);
|
||||
// 4J Stu - We probably don't need to do this on 360 either (as we force it
|
||||
|
|
@ -87,10 +99,11 @@ int EndermanRenderer::prepareArmor(std::shared_ptr<Mob> _mob, int layer,
|
|||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
if (mob->isInvisible())
|
||||
if (mob->isInvisible()) {
|
||||
glDepthMask(false);
|
||||
else
|
||||
} else {
|
||||
glDepthMask(true);
|
||||
}
|
||||
|
||||
if (SharedConstants::TEXTURE_LIGHTING) {
|
||||
int col = 0xf0f0;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#pragma once
|
||||
|
||||
#include "MobRenderer.h"
|
||||
|
||||
class EnderMan;
|
||||
|
|
@ -9,14 +8,17 @@ class EndermanRenderer : public MobRenderer {
|
|||
private:
|
||||
EndermanModel* model;
|
||||
Random random;
|
||||
static ResourceLocation ENDERMAN_EYES_LOCATION;
|
||||
static ResourceLocation ENDERMAN_LOCATION;
|
||||
|
||||
public:
|
||||
EndermanRenderer();
|
||||
|
||||
virtual void render(std::shared_ptr<Entity> _mob, double x, double y,
|
||||
double z, float rot, float a);
|
||||
virtual void additionalRendering(std::shared_ptr<Mob> _mob, float a);
|
||||
void render(std::shared_ptr<Entity> _mob, double x, double y, double z,
|
||||
float rot, float a);
|
||||
ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
void additionalRendering(std::shared_ptr<LivingEntity> _mob, float a);
|
||||
|
||||
protected:
|
||||
virtual int prepareArmor(std::shared_ptr<Mob> _mob, int layer, float a);
|
||||
int prepareArmor(std::shared_ptr<LivingEntity> _mob, int layer, float a);
|
||||
};
|
||||
|
|
@ -50,6 +50,14 @@
|
|||
#include "EnderDragonRenderer.h"
|
||||
#include "EnderCrystalRenderer.h"
|
||||
#include "BlazeRenderer.h"
|
||||
#include "SkeletonRenderer.h"
|
||||
#include "WitchRenderer.h"
|
||||
#include "WitherBossRenderer.h"
|
||||
#include "LeashKnotRenderer.h"
|
||||
#include "WitherSkullRenderer.h"
|
||||
#include "TntMinecartRenderer.h"
|
||||
#include "MinecartSpawnerRenderer.h"
|
||||
#include "HorseRenderer.h"
|
||||
#include "../Models/SpiderModel.h"
|
||||
#include "../Models/PigModel.h"
|
||||
#include "../Models/SheepModel.h"
|
||||
|
|
@ -65,12 +73,15 @@
|
|||
#include "../Models/HumanoidModel.h"
|
||||
#include "../Models/SheepFurModel.h"
|
||||
#include "../Models/SkeletonModel.h"
|
||||
#include "../Models/ModelHorse.h"
|
||||
#include "../../GameState/Options.h"
|
||||
#include "ItemFrameRenderer.h"
|
||||
#include "OcelotRenderer.h"
|
||||
#include "VillagerGolemRenderer.h"
|
||||
#include "../Models/OcelotModel.h"
|
||||
#include "ZombieRenderer.h"
|
||||
#include "BatRenderer.h"
|
||||
#include "CaveSpiderRenderer.h"
|
||||
|
||||
double EntityRenderDispatcher::xOff = 0.0;
|
||||
double EntityRenderDispatcher::yOff = 0.0;
|
||||
|
|
@ -85,7 +96,7 @@ void EntityRenderDispatcher::staticCtor() {
|
|||
EntityRenderDispatcher::EntityRenderDispatcher() {
|
||||
glEnable(GL_LIGHTING);
|
||||
renderers[eTYPE_SPIDER] = new SpiderRenderer();
|
||||
renderers[eTYPE_CAVESPIDER] = new SpiderRenderer();
|
||||
renderers[eTYPE_CAVESPIDER] = new CaveSpiderRenderer();
|
||||
renderers[eTYPE_PIG] =
|
||||
new PigRenderer(new PigModel(), new PigModel(0.5f), 0.7f);
|
||||
renderers[eTYPE_SHEEP] =
|
||||
|
|
@ -96,17 +107,16 @@ EntityRenderDispatcher::EntityRenderDispatcher() {
|
|||
renderers[eTYPE_WOLF] =
|
||||
new WolfRenderer(new WolfModel(), new WolfModel(), 0.5f);
|
||||
renderers[eTYPE_CHICKEN] = new ChickenRenderer(new ChickenModel(), 0.3f);
|
||||
renderers[eTYPE_OZELOT] = new OzelotRenderer(new OzelotModel(), 0.4f);
|
||||
renderers[eTYPE_OCELOT] = new OcelotRenderer(new OcelotModel(), 0.4f);
|
||||
renderers[eTYPE_SILVERFISH] = new SilverfishRenderer();
|
||||
renderers[eTYPE_CREEPER] = new CreeperRenderer();
|
||||
renderers[eTYPE_ENDERMAN] = new EndermanRenderer();
|
||||
renderers[eTYPE_SNOWMAN] = new SnowManRenderer();
|
||||
renderers[eTYPE_SKELETON] =
|
||||
new HumanoidMobRenderer(new SkeletonModel(), 0.5f);
|
||||
renderers[eTYPE_SKELETON] = new SkeletonRenderer();
|
||||
renderers[eTYPE_WITCH] = new WitchRenderer();
|
||||
renderers[eTYPE_BLAZE] = new BlazeRenderer();
|
||||
renderers[eTYPE_ZOMBIE] = new ZombieRenderer();
|
||||
renderers[eTYPE_PIGZOMBIE] =
|
||||
new HumanoidMobRenderer(new ZombieModel(), 0.5f);
|
||||
renderers[eTYPE_PIGZOMBIE] = new ZombieRenderer();
|
||||
renderers[eTYPE_SLIME] =
|
||||
new SlimeRenderer(new SlimeModel(16), new SlimeModel(0), 0.25f);
|
||||
renderers[eTYPE_LAVASLIME] = new LavaSlimeRenderer();
|
||||
|
|
@ -116,12 +126,19 @@ EntityRenderDispatcher::EntityRenderDispatcher() {
|
|||
renderers[eTYPE_SQUID] = new SquidRenderer(new SquidModel(), 0.7f);
|
||||
renderers[eTYPE_VILLAGER] = new VillagerRenderer();
|
||||
renderers[eTYPE_VILLAGERGOLEM] = new VillagerGolemRenderer();
|
||||
renderers[eTYPE_BAT] = new BatRenderer();
|
||||
|
||||
renderers[eTYPE_MOB] = new MobRenderer(new HumanoidModel(), 0.5f);
|
||||
|
||||
renderers[eTYPE_ENDERDRAGON] = new EnderDragonRenderer();
|
||||
renderers[eTYPE_ENDER_CRYSTAL] = new EnderCrystalRenderer();
|
||||
|
||||
renderers[eTYPE_WITHERBOSS] = new WitherBossRenderer();
|
||||
|
||||
renderers[eTYPE_ENTITY] = new DefaultRenderer();
|
||||
renderers[eTYPE_PAINTING] = new PaintingRenderer();
|
||||
renderers[eTYPE_ITEM_FRAME] = new ItemFrameRenderer();
|
||||
renderers[eTYPE_LEASHFENCEKNOT] = new LeashKnotRenderer();
|
||||
renderers[eTYPE_ARROW] = new ArrowRenderer();
|
||||
renderers[eTYPE_SNOWBALL] = new ItemSpriteRenderer(Item::snowBall);
|
||||
renderers[eTYPE_THROWNENDERPEARL] =
|
||||
|
|
@ -132,19 +149,31 @@ EntityRenderDispatcher::EntityRenderDispatcher() {
|
|||
renderers[eTYPE_THROWNPOTION] =
|
||||
new ItemSpriteRenderer(Item::potion, PotionBrewing::THROWABLE_MASK);
|
||||
renderers[eTYPE_THROWNEXPBOTTLE] = new ItemSpriteRenderer(Item::expBottle);
|
||||
renderers[eTYPE_FIREBALL] = new FireballRenderer(2.0f);
|
||||
renderers[eTYPE_FIREWORKS_ROCKET] = new ItemSpriteRenderer(Item::fireworks);
|
||||
renderers[eTYPE_LARGE_FIREBALL] = new FireballRenderer(2.0f);
|
||||
renderers[eTYPE_SMALL_FIREBALL] = new FireballRenderer(0.5f);
|
||||
renderers[eTYPE_DRAGON_FIREBALL] =
|
||||
new FireballRenderer(2.0f); // 4J Added TU9
|
||||
renderers[eTYPE_WITHER_SKULL] = new WitherSkullRenderer();
|
||||
renderers[eTYPE_ITEMENTITY] = new ItemRenderer();
|
||||
renderers[eTYPE_EXPERIENCEORB] = new ExperienceOrbRenderer();
|
||||
renderers[eTYPE_PRIMEDTNT] = new TntRenderer();
|
||||
renderers[eTYPE_FALLINGTILE] = new FallingTileRenderer();
|
||||
renderers[eTYPE_MINECART] = new MinecartRenderer();
|
||||
|
||||
renderers[eTYPE_MINECART_TNT] = new TntMinecartRenderer();
|
||||
renderers[eTYPE_MINECART_SPAWNER] = new MinecartSpawnerRenderer();
|
||||
renderers[eTYPE_MINECART_RIDEABLE] = new MinecartRenderer();
|
||||
|
||||
renderers[eTYPE_MINECART_FURNACE] = new MinecartRenderer();
|
||||
renderers[eTYPE_MINECART_CHEST] = new MinecartRenderer();
|
||||
renderers[eTYPE_MINECART_HOPPER] = new MinecartRenderer();
|
||||
|
||||
renderers[eTYPE_BOAT] = new BoatRenderer();
|
||||
renderers[eTYPE_FISHINGHOOK] = new FishingHookRenderer();
|
||||
|
||||
renderers[eTYPE_HORSE] = new HorseRenderer(new ModelHorse(), .75f);
|
||||
|
||||
renderers[eTYPE_LIGHTNINGBOLT] = new LightningBoltRenderer();
|
||||
renderers[eTYPE_ARROW] = new ArrowRenderer();
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
AUTO_VAR(itEnd, renderers.end());
|
||||
|
|
@ -157,23 +186,25 @@ EntityRenderDispatcher::EntityRenderDispatcher() {
|
|||
}
|
||||
|
||||
EntityRenderer* EntityRenderDispatcher::getRenderer(eINSTANCEOF e) {
|
||||
if ((e & eTYPE_PLAYER) == eTYPE_PLAYER) e = eTYPE_PLAYER;
|
||||
// EntityRenderer * r = renderers[e];
|
||||
AUTO_VAR(it, renderers.find(e)); // 4J Stu - The .at and [] accessors
|
||||
// insert elements if they don't exist
|
||||
|
||||
if (it == renderers.end()) {
|
||||
app.DebugPrintf("Couldn't find renderer for entity of type %d\n", e);
|
||||
// New renderer mapping required in above table
|
||||
__debugbreak();
|
||||
}
|
||||
/* 4J - not doing this hierarchical search anymore. We need to explicitly
|
||||
add renderers for any eINSTANCEOF type that we want to be able to render if (it
|
||||
== renderers.end() && e != Entity::_class)
|
||||
add renderers for any eINSTANCEOF type that we want to be able to render if
|
||||
(it == renderers.end() && e != Entity::_class)
|
||||
{
|
||||
EntityRenderer *r = getRenderer(dynamic_cast<Entity::Class *>(
|
||||
e->getSuperclass() )); renderers.insert( classToRendererMap::value_type( e, r )
|
||||
); return r;
|
||||
//assert(false);
|
||||
}*/
|
||||
e->getSuperclass() )); renderers.insert( classToRendererMap::value_type( e,
|
||||
r ) ); return r;
|
||||
//assert(false);
|
||||
}*/
|
||||
return it->second;
|
||||
}
|
||||
|
||||
|
|
@ -181,14 +212,16 @@ EntityRenderer* EntityRenderDispatcher::getRenderer(std::shared_ptr<Entity> e) {
|
|||
return getRenderer(e->GetType());
|
||||
}
|
||||
|
||||
void EntityRenderDispatcher::prepare(Level* level, Textures* textures,
|
||||
Font* font, std::shared_ptr<Mob> player,
|
||||
Options* options, float a) {
|
||||
void EntityRenderDispatcher::prepare(
|
||||
Level* level, Textures* textures, Font* font,
|
||||
std::shared_ptr<LivingEntity> player,
|
||||
std::shared_ptr<LivingEntity> crosshairPickMob, Options* options, float a) {
|
||||
this->level = level;
|
||||
this->textures = textures;
|
||||
this->options = options;
|
||||
this->cameraEntity = player;
|
||||
this->font = font;
|
||||
this->crosshairPickMob = crosshairPickMob;
|
||||
|
||||
if (player->isSleeping()) {
|
||||
int t = level->getTile(Mth::floor(player->x), Mth::floor(player->y),
|
||||
|
|
@ -275,4 +308,61 @@ void EntityRenderDispatcher::registerTerrainTextures(
|
|||
EntityRenderer* renderer = it->second;
|
||||
renderer->registerTerrainTextures(iconRegister);
|
||||
}
|
||||
}
|
||||
|
||||
void EntityRenderDispatcher::renderHitbox(std::shared_ptr<Entity> entity,
|
||||
double x, double y, double z,
|
||||
float rot, float a) {
|
||||
glDepthMask(false);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
glPushMatrix();
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
|
||||
t->begin();
|
||||
t->color(255, 255, 255, 32);
|
||||
|
||||
double wnx = -entity->bbWidth / 2;
|
||||
double wnz = -entity->bbWidth / 2;
|
||||
double enx = entity->bbWidth / 2;
|
||||
double enz = -entity->bbWidth / 2;
|
||||
|
||||
double wsx = -entity->bbWidth / 2;
|
||||
double wsz = entity->bbWidth / 2;
|
||||
double esx = entity->bbWidth / 2;
|
||||
double esz = entity->bbWidth / 2;
|
||||
|
||||
double top = entity->bbHeight;
|
||||
|
||||
t->vertex(x + wnx, y + top, z + wnz);
|
||||
t->vertex(x + wnx, y, z + wnz);
|
||||
t->vertex(x + enx, y, z + enz);
|
||||
t->vertex(x + enx, y + top, z + enz);
|
||||
|
||||
t->vertex(x + esx, y + top, z + esz);
|
||||
t->vertex(x + esx, y, z + esz);
|
||||
t->vertex(x + wsx, y, z + wsz);
|
||||
t->vertex(x + wsx, y + top, z + wsz);
|
||||
|
||||
t->vertex(x + enx, y + top, z + enz);
|
||||
t->vertex(x + enx, y, z + enz);
|
||||
t->vertex(x + esx, y, z + esz);
|
||||
t->vertex(x + esx, y + top, z + esz);
|
||||
|
||||
t->vertex(x + wsx, y + top, z + wsz);
|
||||
t->vertex(x + wsx, y, z + wsz);
|
||||
t->vertex(x + wnx, y, z + wnz);
|
||||
t->vertex(x + wnx, y + top, z + wnz);
|
||||
|
||||
t->end();
|
||||
glPopMatrix();
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glDisable(GL_BLEND);
|
||||
glDepthMask(true);
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ private:
|
|||
// 4J - was:
|
||||
// Map<Class<? extends Entity>, EntityRenderer<? extends Entity>> renderers
|
||||
//= new HashMap<Class<? extends Entity>, EntityRenderer<? extends
|
||||
//Entity>>();
|
||||
// Entity>>();
|
||||
|
||||
public:
|
||||
static EntityRenderDispatcher* instance;
|
||||
|
|
@ -29,7 +29,8 @@ public:
|
|||
Textures* textures;
|
||||
ItemInHandRenderer* itemInHandRenderer;
|
||||
Level* level;
|
||||
std::shared_ptr<Mob> cameraEntity;
|
||||
std::shared_ptr<LivingEntity> cameraEntity;
|
||||
std::shared_ptr<LivingEntity> crosshairPickMob;
|
||||
float playerRotY;
|
||||
float playerRotX;
|
||||
Options* options;
|
||||
|
|
@ -44,7 +45,9 @@ public:
|
|||
EntityRenderer* getRenderer(eINSTANCEOF e);
|
||||
EntityRenderer* getRenderer(std::shared_ptr<Entity> e);
|
||||
void prepare(Level* level, Textures* textures, Font* font,
|
||||
std::shared_ptr<Mob> player, Options* options, float a);
|
||||
std::shared_ptr<LivingEntity> player,
|
||||
std::shared_ptr<LivingEntity> crosshairPickMob,
|
||||
Options* options, float a);
|
||||
void render(std::shared_ptr<Entity> entity, float a);
|
||||
void render(std::shared_ptr<Entity> entity, double x, double y, double z,
|
||||
float rot, float a, bool bItemFrame = false,
|
||||
|
|
@ -53,4 +56,8 @@ public:
|
|||
double distanceToSqr(double x, double y, double z);
|
||||
Font* getFont();
|
||||
void registerTerrainTextures(IconRegister* iconRegister);
|
||||
|
||||
private:
|
||||
void renderHitbox(std::shared_ptr<Entity> entity, double x, double y,
|
||||
double z, float rot, float a);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,16 +1,20 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "EntityRenderer.h"
|
||||
#include "../Models/HumanoidModel.h"
|
||||
#include "EntityRenderDispatcher.h"
|
||||
#include "../Models/HumanoidModel.h"
|
||||
#include "../../Player/LocalPlayer.h"
|
||||
#include "../../GameState/Options.h"
|
||||
#include "../../Textures/TextureAtlas.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.level.tile.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.h"
|
||||
#include "../../../Minecraft.World/Entities/Entity.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.h"
|
||||
#include "../../../Minecraft.World/Level/Level.h"
|
||||
#include "../../../Minecraft.World/Util/AABB.h"
|
||||
#include "../../../Minecraft.World/Util/Mth.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.animal.h"
|
||||
#include "../../Player/LocalPlayer.h"
|
||||
|
||||
ResourceLocation EntityRenderer::SHADOW_LOCATION =
|
||||
ResourceLocation(TN__CLAMP__MISC_SHADOW);
|
||||
|
||||
// 4J - added
|
||||
EntityRenderer::EntityRenderer() {
|
||||
|
|
@ -22,12 +26,12 @@ EntityRenderer::EntityRenderer() {
|
|||
|
||||
EntityRenderer::~EntityRenderer() { delete tileRenderer; }
|
||||
|
||||
void EntityRenderer::bindTexture(int resourceName) {
|
||||
entityRenderDispatcher->textures->bindTexture(resourceName);
|
||||
void EntityRenderer::bindTexture(std::shared_ptr<Entity> entity) {
|
||||
bindTexture(getTextureLocation(entity));
|
||||
}
|
||||
|
||||
void EntityRenderer::bindTexture(const std::wstring& resourceName) {
|
||||
entityRenderDispatcher->textures->bindTexture(resourceName);
|
||||
void EntityRenderer::bindTexture(ResourceLocation* location) {
|
||||
entityRenderDispatcher->textures->bindTexture(location);
|
||||
}
|
||||
|
||||
bool EntityRenderer::bindTexture(const std::wstring& urlTexture,
|
||||
|
|
@ -79,7 +83,7 @@ void EntityRenderer::renderFlame(std::shared_ptr<Entity> e, double x, double y,
|
|||
float s = e->bbWidth * 1.4f;
|
||||
glScalef(s, s, s);
|
||||
MemSect(31);
|
||||
bindTexture(TN_TERRAIN); // 4J was L"/terrain.png"
|
||||
bindTexture(&TextureAtlas::LOCATION_BLOCKS);
|
||||
MemSect(0);
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
|
||||
|
|
@ -139,33 +143,24 @@ void EntityRenderer::renderShadow(std::shared_ptr<Entity> e, double x, double y,
|
|||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
MemSect(31);
|
||||
entityRenderDispatcher->textures->bindTexture(
|
||||
TN__CLAMP__MISC_SHADOW); // L"%clamp%/misc/shadow.png"));
|
||||
entityRenderDispatcher->textures->bindTexture(&SHADOW_LOCATION);
|
||||
MemSect(0);
|
||||
|
||||
Level* level = getLevel();
|
||||
|
||||
glDepthMask(false);
|
||||
float r = shadowRadius;
|
||||
std::shared_ptr<Mob> mob = std::dynamic_pointer_cast<Mob>(e);
|
||||
bool isLocalPlayer = false;
|
||||
float fYLocalPlayerShadowOffset = 0.0f;
|
||||
|
||||
// if (std::dynamic_pointer_cast<Mob>(e) != NULL)
|
||||
if (mob != NULL) {
|
||||
// std::shared_ptr<Mob> mob = std::dynamic_pointer_cast<Mob>(e);
|
||||
if (e->instanceof(eTYPE_MOB)) {
|
||||
std::shared_ptr<Mob> mob = std::dynamic_pointer_cast<Mob>(e);
|
||||
r *= mob->getSizeScale();
|
||||
|
||||
std::shared_ptr<Animal> animal = std::dynamic_pointer_cast<Animal>(mob);
|
||||
if (animal != NULL) {
|
||||
if (animal->isBaby()) {
|
||||
if (mob->instanceof(eTYPE_ANIMAL)) {
|
||||
if (std::dynamic_pointer_cast<Animal>(mob)->isBaby()) {
|
||||
r *= 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
if (std::dynamic_pointer_cast<LocalPlayer>(mob) != NULL) {
|
||||
isLocalPlayer = true;
|
||||
}
|
||||
}
|
||||
|
||||
double ex = e->xOld + (e->x - e->xOld) * a;
|
||||
|
|
@ -174,7 +169,7 @@ void EntityRenderer::renderShadow(std::shared_ptr<Entity> e, double x, double y,
|
|||
// 4J-PB - local players seem to have a position at their head, and remote
|
||||
// players have a foot position. get the shadow to render by changing the
|
||||
// check here depending on the player type
|
||||
if (isLocalPlayer) {
|
||||
if (e->instanceof(eTYPE_LOCALPLAYER)) {
|
||||
ey -= 1.62;
|
||||
fYLocalPlayerShadowOffset = -1.62f;
|
||||
}
|
||||
|
|
@ -394,4 +389,9 @@ void EntityRenderer::postRender(std::shared_ptr<Entity> entity, double x,
|
|||
|
||||
Font* EntityRenderer::getFont() { return entityRenderDispatcher->getFont(); }
|
||||
|
||||
void EntityRenderer::registerTerrainTextures(IconRegister* iconRegister) {}
|
||||
void EntityRenderer::registerTerrainTextures(IconRegister* iconRegister) {}
|
||||
|
||||
ResourceLocation* EntityRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1,15 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include "../Models/Model.h"
|
||||
#include "TileRenderer.h"
|
||||
#include "../Tesselator.h"
|
||||
#include "../../Textures/Textures.h"
|
||||
#include "ItemInHandRenderer.h"
|
||||
#include "../../Textures/ResourceLocation.h"
|
||||
|
||||
class Tile;
|
||||
class Entity;
|
||||
class Level;
|
||||
class AABB;
|
||||
class IconRegister;
|
||||
class ResourceLocation;
|
||||
|
||||
class EntityRenderDispatcher;
|
||||
class Font;
|
||||
|
|
@ -22,8 +24,12 @@ protected:
|
|||
EntityRenderDispatcher* entityRenderDispatcher;
|
||||
|
||||
private:
|
||||
Model* model; // 4J - TODO - check why exactly this is here, it seems to
|
||||
// get shadowed by classes inheriting from this by their own
|
||||
static ResourceLocation SHADOW_LOCATION;
|
||||
|
||||
protected:
|
||||
Model* model; // TODO 4J: Check why exactly this is here, it seems to get
|
||||
// shadowed by classes inheriting from this by their own
|
||||
|
||||
protected:
|
||||
TileRenderer* tileRenderer; // 4J - changed to protected so derived classes
|
||||
// can use instead of shadowing their own
|
||||
|
|
@ -41,14 +47,14 @@ public:
|
|||
double z, float rot, float a) = 0;
|
||||
|
||||
protected:
|
||||
virtual void bindTexture(int resourceName); // 4J - added
|
||||
virtual void bindTexture(const std::wstring& resourceName);
|
||||
|
||||
virtual bool bindTexture(const std::wstring& urlTexture,
|
||||
int backupTexture); // 4J added
|
||||
virtual void bindTexture(std::shared_ptr<Entity> entity);
|
||||
virtual void bindTexture(ResourceLocation* location);
|
||||
virtual bool bindTexture(const std::wstring& urlTexture, int backupTexture);
|
||||
virtual bool bindTexture(const std::wstring& urlTexture,
|
||||
const std::wstring& backupTexture);
|
||||
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
|
||||
private:
|
||||
virtual void renderFlame(std::shared_ptr<Entity> e, double x, double y,
|
||||
double z, float a);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "EntityTileRenderer.h"
|
||||
#include "TileEntityRenderDispatcher.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.level.tile.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.level.tile.entity.h"
|
||||
|
||||
EntityTileRenderer* EntityTileRenderer::instance = new EntityTileRenderer;
|
||||
|
||||
EntityTileRenderer::EntityTileRenderer() {
|
||||
chest = std::shared_ptr<ChestTileEntity>(new ChestTileEntity());
|
||||
trappedChest = std::shared_ptr<ChestTileEntity>(
|
||||
new ChestTileEntity(ChestTile::TYPE_TRAP));
|
||||
enderChest =
|
||||
std::shared_ptr<EnderChestTileEntity>(new EnderChestTileEntity());
|
||||
}
|
||||
|
|
@ -16,6 +19,9 @@ void EntityTileRenderer::render(Tile* tile, int data, float brightness,
|
|||
if (tile->id == Tile::enderChest_Id) {
|
||||
TileEntityRenderDispatcher::instance->render(
|
||||
enderChest, 0, 0, 0, 0, setColor, alpha, useCompiled);
|
||||
} else if (tile->id == Tile::chest_trap_Id) {
|
||||
TileEntityRenderDispatcher::instance->render(
|
||||
trappedChest, 0, 0, 0, 0, setColor, alpha, useCompiled);
|
||||
} else {
|
||||
TileEntityRenderDispatcher::instance->render(
|
||||
chest, 0, 0, 0, 0, setColor, alpha, useCompiled);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ public:
|
|||
|
||||
private:
|
||||
std::shared_ptr<ChestTileEntity> chest;
|
||||
std::shared_ptr<ChestTileEntity> trappedChest;
|
||||
std::shared_ptr<EnderChestTileEntity> enderChest;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -8,13 +8,12 @@
|
|||
#include "../../../Minecraft.World/Util/Mth.h"
|
||||
#include "../../../Minecraft.World/Util/JavaMath.h"
|
||||
|
||||
ExperienceOrbRenderer::ExperienceOrbRenderer() {
|
||||
// 4J In class Java initialisors
|
||||
tileRenderer = new TileRenderer();
|
||||
setColor = true;
|
||||
ResourceLocation ExperienceOrbRenderer::XP_ORB_LOCATION =
|
||||
ResourceLocation(TN_ITEM_EXPERIENCE_ORB);
|
||||
|
||||
this->shadowRadius = 0.15f;
|
||||
this->shadowStrength = 0.75f;
|
||||
ExperienceOrbRenderer::ExperienceOrbRenderer() {
|
||||
shadowRadius = 0.15f;
|
||||
shadowStrength = 0.75f;
|
||||
}
|
||||
|
||||
void ExperienceOrbRenderer::render(std::shared_ptr<Entity> _orb, double x,
|
||||
|
|
@ -25,8 +24,7 @@ void ExperienceOrbRenderer::render(std::shared_ptr<Entity> _orb, double x,
|
|||
glTranslatef((float)x, (float)y, (float)z);
|
||||
|
||||
int icon = orb->getIcon();
|
||||
bindTexture(TN_ITEM_EXPERIENCE_ORB); // 4J was L"/item/xporb.png"
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
bindTexture(orb); // 4J was L"/item/xporb.png"
|
||||
|
||||
float u0 = ((icon % 4) * 16 + 0) / 64.0f;
|
||||
float u1 = ((icon % 4) * 16 + 16) / 64.0f;
|
||||
|
|
@ -57,6 +55,7 @@ void ExperienceOrbRenderer::render(std::shared_ptr<Entity> _orb, double x,
|
|||
glRotatef(-entityRenderDispatcher->playerRotX, 1, 0, 0);
|
||||
float s = 0.3f;
|
||||
glScalef(s, s, s);
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
t->begin();
|
||||
t->color(col, 128);
|
||||
t->normal(0, 1, 0);
|
||||
|
|
@ -71,6 +70,11 @@ void ExperienceOrbRenderer::render(std::shared_ptr<Entity> _orb, double x,
|
|||
glPopMatrix();
|
||||
}
|
||||
|
||||
ResourceLocation* ExperienceOrbRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &XP_ORB_LOCATION;
|
||||
}
|
||||
|
||||
void ExperienceOrbRenderer::blit(int x, int y, int sx, int sy, int w, int h) {
|
||||
float blitOffset = 0;
|
||||
float us = 1 / 256.0f;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include "EntityRenderer.h"
|
||||
|
||||
class ExperienceOrbRenderer : public EntityRenderer {
|
||||
private:
|
||||
TileRenderer* tileRenderer;
|
||||
static ResourceLocation XP_ORB_LOCATION;
|
||||
|
||||
public:
|
||||
bool setColor;
|
||||
|
||||
ExperienceOrbRenderer();
|
||||
|
||||
void render(std::shared_ptr<Entity> _orb, double x, double y, double z,
|
||||
float rot, float a);
|
||||
virtual void render(std::shared_ptr<Entity> _orb, double x, double y,
|
||||
double z, float rot, float a);
|
||||
void blit(int x, int y, int sx, int sy, int w, int h);
|
||||
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
};
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "FallingTileRenderer.h"
|
||||
#include "../../Textures/TextureAtlas.h"
|
||||
#include "TileRenderer.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.item.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
||||
|
|
@ -17,46 +18,57 @@ void FallingTileRenderer::render(std::shared_ptr<Entity> _tile, double x,
|
|||
// our version
|
||||
std::shared_ptr<FallingTile> tile =
|
||||
std::dynamic_pointer_cast<FallingTile>(_tile);
|
||||
glPushMatrix();
|
||||
glTranslatef((float)x, (float)y, (float)z);
|
||||
|
||||
bindTexture(TN_TERRAIN); // 4J was L"/terrain.png"
|
||||
Tile* tt = Tile::tiles[tile->tile];
|
||||
|
||||
Level* level = tile->getLevel();
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
glColor4f(1, 1, 1,
|
||||
1); // 4J added - this wouldn't be needed in real opengl as the
|
||||
// block render has vertex colours and so this isn't use, but
|
||||
// our pretend gl always modulates with this
|
||||
if (tt == Tile::anvil && tt->getRenderShape() == Tile::SHAPE_ANVIL) {
|
||||
tileRenderer->level = level;
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
t->begin();
|
||||
t->offset(-Mth::floor(tile->x) - 0.5f, -Mth::floor(tile->y) - 0.5f,
|
||||
-Mth::floor(tile->z) - 0.5f);
|
||||
tileRenderer->tesselateAnvilInWorld((AnvilTile*)tt, Mth::floor(tile->x),
|
||||
Mth::floor(tile->y),
|
||||
Mth::floor(tile->z), tile->data);
|
||||
t->offset(0, 0, 0);
|
||||
t->end();
|
||||
} else if (tt == Tile::dragonEgg) {
|
||||
tileRenderer->level = level;
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
t->begin();
|
||||
t->offset(-Mth::floor(tile->x) - 0.5f, -Mth::floor(tile->y) - 0.5f,
|
||||
-Mth::floor(tile->z) - 0.5f);
|
||||
tileRenderer->tesselateInWorld(
|
||||
tt, Mth::floor(tile->x), Mth::floor(tile->y), Mth::floor(tile->z));
|
||||
t->offset(0, 0, 0);
|
||||
t->end();
|
||||
} else if (tt != NULL) {
|
||||
tileRenderer->setShape(tt);
|
||||
tileRenderer->renderBlock(tt, level, Mth::floor(tile->x),
|
||||
Mth::floor(tile->y), Mth::floor(tile->z),
|
||||
tile->data);
|
||||
if (level->getTile(floor(tile->x), floor(tile->y), floor(tile->z)) !=
|
||||
tile->tile) {
|
||||
glPushMatrix();
|
||||
glTranslatef((float)x, (float)y, (float)z);
|
||||
|
||||
bindTexture(tile); // 4J was L"/terrain.png"
|
||||
Tile* tt = Tile::tiles[tile->tile];
|
||||
|
||||
Level* level = tile->getLevel();
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
glColor4f(1, 1, 1,
|
||||
1); // 4J added - this wouldn't be needed in real opengl as
|
||||
// the block render has vertex colours and so this isn't
|
||||
// use, but our pretend gl always modulates with this
|
||||
if (tt == Tile::anvil && tt->getRenderShape() == Tile::SHAPE_ANVIL) {
|
||||
tileRenderer->level = level;
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
t->begin();
|
||||
t->offset(-Mth::floor(tile->x) - 0.5f, -Mth::floor(tile->y) - 0.5f,
|
||||
-Mth::floor(tile->z) - 0.5f);
|
||||
tileRenderer->tesselateAnvilInWorld(
|
||||
(AnvilTile*)tt, Mth::floor(tile->x), Mth::floor(tile->y),
|
||||
Mth::floor(tile->z), tile->data);
|
||||
t->offset(0, 0, 0);
|
||||
t->end();
|
||||
} else if (tt == Tile::dragonEgg) {
|
||||
tileRenderer->level = level;
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
t->begin();
|
||||
t->offset(-Mth::floor(tile->x) - 0.5f, -Mth::floor(tile->y) - 0.5f,
|
||||
-Mth::floor(tile->z) - 0.5f);
|
||||
tileRenderer->tesselateInWorld(tt, Mth::floor(tile->x),
|
||||
Mth::floor(tile->y),
|
||||
Mth::floor(tile->z));
|
||||
t->offset(0, 0, 0);
|
||||
t->end();
|
||||
} else if (tt != NULL) {
|
||||
tileRenderer->setShape(tt);
|
||||
tileRenderer->renderBlock(tt, level, Mth::floor(tile->x),
|
||||
Mth::floor(tile->y), Mth::floor(tile->z),
|
||||
tile->data);
|
||||
}
|
||||
glEnable(GL_LIGHTING);
|
||||
glPopMatrix();
|
||||
}
|
||||
glEnable(GL_LIGHTING);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
ResourceLocation* FallingTileRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &TextureAtlas::LOCATION_BLOCKS;
|
||||
}
|
||||
|
|
@ -10,4 +10,5 @@ public:
|
|||
|
||||
virtual void render(std::shared_ptr<Entity> _tile, double x, double y,
|
||||
double z, float rot, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
};
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "FireballRenderer.h"
|
||||
#include "EntityRenderDispatcher.h"
|
||||
#include "../../Textures/TextureAtlas.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.projectile.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.item.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.level.tile.h"
|
||||
|
|
@ -25,7 +26,7 @@ void FireballRenderer::render(std::shared_ptr<Entity> _fireball, double x,
|
|||
Icon* icon = Item::fireball->getIcon(
|
||||
fireball->GetType() == eTYPE_DRAGON_FIREBALL ? 1 : 0); // 14 + 2 * 16;
|
||||
MemSect(31);
|
||||
bindTexture(TN_GUI_ITEMS); // 4J was L"/gui/items.png"
|
||||
bindTexture(fireball);
|
||||
MemSect(0);
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
|
||||
|
|
@ -68,7 +69,7 @@ void FireballRenderer::renderFlame(std::shared_ptr<Entity> e, double x,
|
|||
float s = e->bbWidth * 1.4f;
|
||||
glScalef(s, s, s);
|
||||
MemSect(31);
|
||||
bindTexture(TN_TERRAIN); // 4J was L"/terrain.png"
|
||||
bindTexture(&TextureAtlas::LOCATION_BLOCKS);
|
||||
MemSect(0);
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
|
||||
|
|
@ -112,4 +113,9 @@ void FireballRenderer::renderFlame(std::shared_ptr<Entity> e, double x,
|
|||
t->end();
|
||||
glPopMatrix();
|
||||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
|
||||
ResourceLocation* FireballRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &TextureAtlas::LOCATION_ITEMS;
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ public:
|
|||
|
||||
private:
|
||||
// 4J Added override
|
||||
virtual void renderFlame(std::shared_ptr<Entity> e, double x, double y,
|
||||
virtual void renderFlame(std::shared_ptr<Entity> entity, double x, double y,
|
||||
double z, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@
|
|||
#include "../../../Minecraft.World/Util/Mth.h"
|
||||
#include "../../Player/MultiPlayerLocalPlayer.h"
|
||||
|
||||
ResourceLocation FishingHookRenderer::PARTICLE_LOCATION =
|
||||
ResourceLocation(TN_PARTICLES);
|
||||
|
||||
void FishingHookRenderer::render(std::shared_ptr<Entity> _hook, double x,
|
||||
double y, double z, float rot, float a) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
|
|
@ -22,13 +25,13 @@ void FishingHookRenderer::render(std::shared_ptr<Entity> _hook, double x,
|
|||
glScalef(1 / 2.0f, 1 / 2.0f, 1 / 2.0f);
|
||||
int xi = 1;
|
||||
int yi = 2;
|
||||
bindTexture(TN_PARTICLES); // 4J was L"/particles.png"
|
||||
bindTexture(hook); // 4J was L"/particles.png"
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
|
||||
float u0 = ((xi) * 8 + 0) / 128.0f;
|
||||
float u1 = ((xi) * 8 + 8) / 128.0f;
|
||||
float v0 = ((yi) * 8 + 0) / 128.0f;
|
||||
float v1 = ((yi) * 8 + 8) / 128.0f;
|
||||
float u0 = (xi * 8 + 0) / 128.0f;
|
||||
float u1 = (xi * 8 + 8) / 128.0f;
|
||||
float v0 = (yi * 8 + 0) / 128.0f;
|
||||
float v1 = (yi * 8 + 8) / 128.0f;
|
||||
|
||||
float r = 1.0f;
|
||||
float xo = 0.5f;
|
||||
|
|
@ -53,7 +56,7 @@ void FishingHookRenderer::render(std::shared_ptr<Entity> _hook, double x,
|
|||
|
||||
if (hook->owner != NULL) {
|
||||
float swing = hook->owner->getAttackAnim(a);
|
||||
float swing2 = (float)Mth::sin((sqrt(swing)) * PI);
|
||||
float swing2 = (float)Mth::sin(sqrt(swing) * PI);
|
||||
|
||||
Vec3* vv = Vec3::newTemp(-0.5, 0.03, 0.8);
|
||||
vv->xRot(-(hook->owner->xRotO +
|
||||
|
|
@ -71,10 +74,10 @@ void FishingHookRenderer::render(std::shared_ptr<Entity> _hook, double x,
|
|||
hook->owner->yo + (hook->owner->y - hook->owner->yo) * a + vv->y;
|
||||
double zp =
|
||||
hook->owner->zo + (hook->owner->z - hook->owner->zo) * a + vv->z;
|
||||
double yOffset = hook->owner != std::dynamic_pointer_cast<Player>(
|
||||
double yOffset = hook->owner == std::dynamic_pointer_cast<Player>(
|
||||
Minecraft::GetInstance()->player)
|
||||
? hook->owner->getHeadHeight()
|
||||
: 0;
|
||||
? 0
|
||||
: hook->owner->getHeadHeight();
|
||||
|
||||
// 4J-PB - changing this to be per player
|
||||
// if (this->entityRenderDispatcher->options->thirdPersonView)
|
||||
|
|
@ -117,3 +120,8 @@ void FishingHookRenderer::render(std::shared_ptr<Entity> _hook, double x,
|
|||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
}
|
||||
|
||||
ResourceLocation* FishingHookRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &PARTICLE_LOCATION;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@
|
|||
#include "EntityRenderer.h"
|
||||
|
||||
class FishingHookRenderer : public EntityRenderer {
|
||||
private:
|
||||
static ResourceLocation PARTICLE_LOCATION;
|
||||
|
||||
public:
|
||||
virtual void render(std::shared_ptr<Entity> _hook, double x, double y,
|
||||
double z, float rot, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
};
|
||||
|
|
@ -3,9 +3,13 @@
|
|||
#include "../Models/GhastModel.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.monster.h"
|
||||
|
||||
ResourceLocation GhastRenderer::GHAST_LOCATION = ResourceLocation(TN_MOB_GHAST);
|
||||
ResourceLocation GhastRenderer::GHAST_SHOOTING_LOCATION =
|
||||
ResourceLocation(TN_MOB_GHAST_FIRE);
|
||||
|
||||
GhastRenderer::GhastRenderer() : MobRenderer(new GhastModel(), 0.5f) {}
|
||||
|
||||
void GhastRenderer::scale(std::shared_ptr<Mob> mob, float a) {
|
||||
void GhastRenderer::scale(std::shared_ptr<LivingEntity> mob, float a) {
|
||||
std::shared_ptr<Ghast> ghast = std::dynamic_pointer_cast<Ghast>(mob);
|
||||
|
||||
float ss = (ghast->oCharge + (ghast->charge - ghast->oCharge) * a) / 20.0f;
|
||||
|
|
@ -15,4 +19,15 @@ void GhastRenderer::scale(std::shared_ptr<Mob> mob, float a) {
|
|||
float hs = (8 + 1 / ss) / 2;
|
||||
glScalef(hs, s, hs);
|
||||
glColor4f(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
ResourceLocation* GhastRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
std::shared_ptr<Ghast> ghast = std::dynamic_pointer_cast<Ghast>(mob);
|
||||
|
||||
if (ghast->isCharging()) {
|
||||
return &GHAST_SHOOTING_LOCATION;
|
||||
}
|
||||
|
||||
return &GHAST_LOCATION;
|
||||
}
|
||||
|
|
@ -2,9 +2,14 @@
|
|||
#include "MobRenderer.h"
|
||||
|
||||
class GhastRenderer : public MobRenderer {
|
||||
private:
|
||||
static ResourceLocation GHAST_LOCATION;
|
||||
static ResourceLocation GHAST_SHOOTING_LOCATION;
|
||||
|
||||
public:
|
||||
GhastRenderer();
|
||||
|
||||
protected:
|
||||
virtual void scale(std::shared_ptr<Mob> mob, float a);
|
||||
virtual void scale(std::shared_ptr<LivingEntity> mob, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
};
|
||||
|
|
@ -1,11 +1,19 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "GiantMobRenderer.h"
|
||||
|
||||
ResourceLocation GiantMobRenderer::ZOMBIE_LOCATION =
|
||||
ResourceLocation(TN_ITEM_ARROWS);
|
||||
|
||||
GiantMobRenderer::GiantMobRenderer(Model* model, float shadow, float _scale)
|
||||
: MobRenderer(model, shadow * _scale) {
|
||||
this->_scale = _scale;
|
||||
}
|
||||
|
||||
void GiantMobRenderer::scale(std::shared_ptr<Mob> mob, float a) {
|
||||
void GiantMobRenderer::scale(std::shared_ptr<LivingEntity> mob, float a) {
|
||||
glScalef(_scale, _scale, _scale);
|
||||
}
|
||||
|
||||
ResourceLocation* GiantMobRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &ZOMBIE_LOCATION;
|
||||
}
|
||||
|
|
@ -3,11 +3,13 @@
|
|||
|
||||
class GiantMobRenderer : public MobRenderer {
|
||||
private:
|
||||
static ResourceLocation ZOMBIE_LOCATION;
|
||||
float _scale;
|
||||
|
||||
public:
|
||||
GiantMobRenderer(Model* model, float shadow, float scale);
|
||||
|
||||
protected:
|
||||
virtual void scale(std::shared_ptr<Mob> mob, float a);
|
||||
virtual void scale(std::shared_ptr<LivingEntity> mob, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
};
|
||||
103
Minecraft.Client/Rendering/EntityRenderers/HorseRenderer.cpp
Normal file
103
Minecraft.Client/Rendering/EntityRenderers/HorseRenderer.cpp
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "HorseRenderer.h"
|
||||
#include "MobRenderer.h"
|
||||
#include "EntityRenderDispatcher.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.animal.h"
|
||||
|
||||
ResourceLocation HorseRenderer::HORSE_LOCATION =
|
||||
ResourceLocation(TN_MOB_HORSE_WHITE);
|
||||
ResourceLocation HorseRenderer::HORSE_MULE_LOCATION =
|
||||
ResourceLocation(TN_MOB_MULE);
|
||||
ResourceLocation HorseRenderer::HORSE_DONKEY_LOCATION =
|
||||
ResourceLocation(TN_MOB_DONKEY);
|
||||
ResourceLocation HorseRenderer::HORSE_ZOMBIE_LOCATION =
|
||||
ResourceLocation(TN_MOB_HORSE_ZOMBIE);
|
||||
ResourceLocation HorseRenderer::HORSE_SKELETON_LOCATION =
|
||||
ResourceLocation(TN_MOB_HORSE_SKELETON);
|
||||
|
||||
std::map<std::wstring, ResourceLocation*> HorseRenderer::LAYERED_LOCATION_CACHE;
|
||||
|
||||
HorseRenderer::HorseRenderer(Model* model, float f) : MobRenderer(model, f) {}
|
||||
|
||||
void HorseRenderer::adjustHeight(std::shared_ptr<PathfinderMob> mob,
|
||||
float FHeight) {
|
||||
glTranslatef(0.0F, FHeight, 0.0F);
|
||||
}
|
||||
|
||||
void HorseRenderer::scale(std::shared_ptr<LivingEntity> entityliving, float f) {
|
||||
float sizeFactor = 1.0f;
|
||||
|
||||
int type = std::dynamic_pointer_cast<EntityHorse>(entityliving)->getType();
|
||||
if (type == EntityHorse::TYPE_DONKEY) {
|
||||
sizeFactor *= 0.87F;
|
||||
} else if (type == EntityHorse::TYPE_MULE) {
|
||||
sizeFactor *= 0.92F;
|
||||
}
|
||||
glScalef(sizeFactor, sizeFactor, sizeFactor);
|
||||
MobRenderer::scale(entityliving, f);
|
||||
}
|
||||
|
||||
void HorseRenderer::renderModel(std::shared_ptr<LivingEntity> mob, float wp,
|
||||
float ws, float bob, float headRotMinusBodyRot,
|
||||
float headRotx, float scale) {
|
||||
if (mob->isInvisible()) {
|
||||
model->setupAnim(wp, ws, bob, headRotMinusBodyRot, headRotx, scale,
|
||||
mob);
|
||||
} else {
|
||||
EntityRenderer::bindTexture(mob);
|
||||
model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale,
|
||||
true);
|
||||
// Ensure that any extra layers of texturing are disabled after
|
||||
// rendering this horse
|
||||
RenderManager.TextureBind(1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
void HorseRenderer::bindTexture(ResourceLocation* location) {
|
||||
// Set up (potentially) multiple texture layers for the horse
|
||||
entityRenderDispatcher->textures->bindTextureLayers(location);
|
||||
}
|
||||
|
||||
ResourceLocation* HorseRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> entity) {
|
||||
std::shared_ptr<EntityHorse> horse =
|
||||
std::dynamic_pointer_cast<EntityHorse>(entity);
|
||||
|
||||
if (!horse->hasLayeredTextures()) {
|
||||
switch (horse->getType()) {
|
||||
default:
|
||||
case EntityHorse::TYPE_HORSE:
|
||||
return &HORSE_LOCATION;
|
||||
case EntityHorse::TYPE_MULE:
|
||||
return &HORSE_MULE_LOCATION;
|
||||
case EntityHorse::TYPE_DONKEY:
|
||||
return &HORSE_DONKEY_LOCATION;
|
||||
case EntityHorse::TYPE_UNDEAD:
|
||||
return &HORSE_ZOMBIE_LOCATION;
|
||||
case EntityHorse::TYPE_SKELETON:
|
||||
return &HORSE_SKELETON_LOCATION;
|
||||
}
|
||||
}
|
||||
|
||||
return getOrCreateLayeredTextureLocation(horse);
|
||||
}
|
||||
|
||||
ResourceLocation* HorseRenderer::getOrCreateLayeredTextureLocation(
|
||||
std::shared_ptr<EntityHorse> horse) {
|
||||
std::wstring textureName = horse->getLayeredTextureHashName();
|
||||
|
||||
AUTO_VAR(it, LAYERED_LOCATION_CACHE.find(textureName));
|
||||
|
||||
ResourceLocation* location;
|
||||
if (it != LAYERED_LOCATION_CACHE.end()) {
|
||||
location = it->second;
|
||||
} else {
|
||||
LAYERED_LOCATION_CACHE[textureName] =
|
||||
new ResourceLocation(horse->getLayeredTextureLayers());
|
||||
|
||||
it = LAYERED_LOCATION_CACHE.find(textureName);
|
||||
location = it->second;
|
||||
}
|
||||
|
||||
return location;
|
||||
}
|
||||
34
Minecraft.Client/Rendering/EntityRenderers/HorseRenderer.h
Normal file
34
Minecraft.Client/Rendering/EntityRenderers/HorseRenderer.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#pragma once
|
||||
#include "MobRenderer.h"
|
||||
#include "../../Textures/ResourceLocation.h"
|
||||
|
||||
class EntityHorse;
|
||||
class PathfinderMob;
|
||||
|
||||
class HorseRenderer : public MobRenderer {
|
||||
private:
|
||||
static std::map<std::wstring, ResourceLocation*> LAYERED_LOCATION_CACHE;
|
||||
|
||||
static ResourceLocation HORSE_LOCATION;
|
||||
static ResourceLocation HORSE_MULE_LOCATION;
|
||||
static ResourceLocation HORSE_DONKEY_LOCATION;
|
||||
static ResourceLocation HORSE_ZOMBIE_LOCATION;
|
||||
static ResourceLocation HORSE_SKELETON_LOCATION;
|
||||
|
||||
public:
|
||||
HorseRenderer(Model* model, float f);
|
||||
|
||||
protected:
|
||||
void adjustHeight(std::shared_ptr<PathfinderMob> mob, float FHeight);
|
||||
virtual void scale(std::shared_ptr<LivingEntity> entityliving, float f);
|
||||
virtual void renderModel(std::shared_ptr<LivingEntity> mob, float wp,
|
||||
float ws, float bob, float headRotMinusBodyRot,
|
||||
float headRotx, float scale);
|
||||
virtual void bindTexture(ResourceLocation* location);
|
||||
virtual ResourceLocation* getTextureLocation(
|
||||
std::shared_ptr<Entity> entity);
|
||||
|
||||
private:
|
||||
ResourceLocation* getOrCreateLayeredTextureLocation(
|
||||
std::shared_ptr<EntityHorse> horse);
|
||||
};
|
||||
|
|
@ -10,11 +10,18 @@
|
|||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.monster.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.h"
|
||||
|
||||
const std::wstring HumanoidMobRenderer::MATERIAL_NAMES[5] = {
|
||||
L"cloth", L"chain", L"iron", L"diamond", L"gold"};
|
||||
std::map<std::wstring, ResourceLocation>
|
||||
HumanoidMobRenderer::ARMOR_LOCATION_CACHE;
|
||||
|
||||
void HumanoidMobRenderer::_init(HumanoidModel* humanoidModel, float scale) {
|
||||
this->humanoidModel = humanoidModel;
|
||||
this->_scale = scale;
|
||||
armorParts1 = NULL;
|
||||
armorParts2 = NULL;
|
||||
|
||||
createArmorParts();
|
||||
}
|
||||
|
||||
HumanoidMobRenderer::HumanoidMobRenderer(HumanoidModel* humanoidModel,
|
||||
|
|
@ -27,8 +34,66 @@ HumanoidMobRenderer::HumanoidMobRenderer(HumanoidModel* humanoidModel,
|
|||
float shadow, float scale)
|
||||
: MobRenderer(humanoidModel, shadow) {
|
||||
_init(humanoidModel, scale);
|
||||
}
|
||||
|
||||
createArmorParts();
|
||||
ResourceLocation* HumanoidMobRenderer::getArmorLocation(ArmorItem* armorItem,
|
||||
int layer) {
|
||||
return getArmorLocation(armorItem, layer, false);
|
||||
}
|
||||
|
||||
ResourceLocation* HumanoidMobRenderer::getArmorLocation(ArmorItem* armorItem,
|
||||
int layer,
|
||||
bool overlay) {
|
||||
switch (armorItem->modelIndex) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
};
|
||||
std::wstring path =
|
||||
std::wstring(L"armor/" + MATERIAL_NAMES[armorItem->modelIndex])
|
||||
.append(L"_")
|
||||
.append(_toString<int>(layer == 2 ? 2 : 1))
|
||||
.append((overlay ? L"_b" : L""))
|
||||
.append(L".png");
|
||||
|
||||
std::map<std::wstring, ResourceLocation>::iterator it =
|
||||
ARMOR_LOCATION_CACHE.find(path);
|
||||
|
||||
ResourceLocation* location;
|
||||
if (it != ARMOR_LOCATION_CACHE.end()) {
|
||||
location = &it->second;
|
||||
} else {
|
||||
ARMOR_LOCATION_CACHE.insert(std::pair<std::wstring, ResourceLocation>(
|
||||
path, ResourceLocation(path)));
|
||||
|
||||
it = ARMOR_LOCATION_CACHE.find(path);
|
||||
location = &it->second;
|
||||
}
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
void HumanoidMobRenderer::prepareSecondPassArmor(
|
||||
std::shared_ptr<LivingEntity> mob, int layer, float a) {
|
||||
std::shared_ptr<ItemInstance> itemInstance = mob->getArmor(3 - layer);
|
||||
if (itemInstance != NULL) {
|
||||
Item* item = itemInstance->getItem();
|
||||
if (dynamic_cast<ArmorItem*>(item) != NULL) {
|
||||
bindTexture(
|
||||
getArmorLocation(dynamic_cast<ArmorItem*>(item), layer, true));
|
||||
|
||||
float brightness =
|
||||
SharedConstants::TEXTURE_LIGHTING ? 1 : mob->getBrightness(a);
|
||||
glColor3f(brightness, brightness, brightness);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HumanoidMobRenderer::createArmorParts() {
|
||||
|
|
@ -36,7 +101,98 @@ void HumanoidMobRenderer::createArmorParts() {
|
|||
armorParts2 = new HumanoidModel(0.5f);
|
||||
}
|
||||
|
||||
void HumanoidMobRenderer::additionalRendering(std::shared_ptr<Mob> mob,
|
||||
int HumanoidMobRenderer::prepareArmor(std::shared_ptr<LivingEntity> _mob,
|
||||
int layer, float a) {
|
||||
std::shared_ptr<LivingEntity> mob =
|
||||
std::dynamic_pointer_cast<LivingEntity>(_mob);
|
||||
|
||||
std::shared_ptr<ItemInstance> itemInstance = mob->getArmor(3 - layer);
|
||||
if (itemInstance != NULL) {
|
||||
Item* item = itemInstance->getItem();
|
||||
if (dynamic_cast<ArmorItem*>(item) != NULL) {
|
||||
ArmorItem* armorItem = dynamic_cast<ArmorItem*>(item);
|
||||
bindTexture(getArmorLocation(armorItem, layer));
|
||||
|
||||
HumanoidModel* armor = layer == 2 ? armorParts2 : armorParts1;
|
||||
|
||||
armor->head->visible = layer == 0;
|
||||
armor->hair->visible = layer == 0;
|
||||
armor->body->visible = layer == 1 || layer == 2;
|
||||
armor->arm0->visible = layer == 1;
|
||||
armor->arm1->visible = layer == 1;
|
||||
armor->leg0->visible = layer == 2 || layer == 3;
|
||||
armor->leg1->visible = layer == 2 || layer == 3;
|
||||
|
||||
setArmor(armor);
|
||||
armor->attackTime = model->attackTime;
|
||||
armor->riding = model->riding;
|
||||
armor->young = model->young;
|
||||
|
||||
float brightness =
|
||||
SharedConstants::TEXTURE_LIGHTING ? 1 : mob->getBrightness(a);
|
||||
if (armorItem->getMaterial() == ArmorItem::ArmorMaterial::CLOTH) {
|
||||
int color = armorItem->getColor(itemInstance);
|
||||
float red = (float)((color >> 16) & 0xFF) / 0xFF;
|
||||
float green = (float)((color >> 8) & 0xFF) / 0xFF;
|
||||
float blue = (float)(color & 0xFF) / 0xFF;
|
||||
glColor3f(brightness * red, brightness * green,
|
||||
brightness * blue);
|
||||
|
||||
if (itemInstance->isEnchanted()) return 0x1f;
|
||||
return 0x10;
|
||||
|
||||
} else {
|
||||
glColor3f(brightness, brightness, brightness);
|
||||
}
|
||||
|
||||
if (itemInstance->isEnchanted()) return 15;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void HumanoidMobRenderer::render(std::shared_ptr<Entity> _mob, double x,
|
||||
double y, double z, float rot, float a) {
|
||||
std::shared_ptr<LivingEntity> mob =
|
||||
std::dynamic_pointer_cast<LivingEntity>(_mob);
|
||||
|
||||
float brightness =
|
||||
SharedConstants::TEXTURE_LIGHTING ? 1 : mob->getBrightness(a);
|
||||
glColor3f(brightness, brightness, brightness);
|
||||
std::shared_ptr<ItemInstance> item = mob->getCarriedItem();
|
||||
|
||||
prepareCarriedItem(mob, item);
|
||||
|
||||
double yp = y - mob->heightOffset;
|
||||
if (mob->isSneaking()) {
|
||||
yp -= 2 / 16.0f;
|
||||
}
|
||||
MobRenderer::render(mob, x, yp, z, rot, a);
|
||||
armorParts1->bowAndArrow = armorParts2->bowAndArrow =
|
||||
humanoidModel->bowAndArrow = false;
|
||||
armorParts1->sneaking = armorParts2->sneaking = humanoidModel->sneaking =
|
||||
false;
|
||||
armorParts1->holdingRightHand = armorParts2->holdingRightHand =
|
||||
humanoidModel->holdingRightHand = 0;
|
||||
}
|
||||
|
||||
ResourceLocation* HumanoidMobRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
// TODO -- Figure out of we need some data in here
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void HumanoidMobRenderer::prepareCarriedItem(
|
||||
std::shared_ptr<Entity> mob, std::shared_ptr<ItemInstance> item) {
|
||||
armorParts1->holdingRightHand = armorParts2->holdingRightHand =
|
||||
humanoidModel->holdingRightHand = item != NULL ? 1 : 0;
|
||||
armorParts1->sneaking = armorParts2->sneaking = humanoidModel->sneaking =
|
||||
mob->isSneaking();
|
||||
}
|
||||
|
||||
void HumanoidMobRenderer::additionalRendering(std::shared_ptr<LivingEntity> mob,
|
||||
float a) {
|
||||
float brightness =
|
||||
SharedConstants::TEXTURE_LIGHTING ? 1 : mob->getBrightness(a);
|
||||
|
|
@ -138,6 +294,6 @@ void HumanoidMobRenderer::additionalRendering(std::shared_ptr<Mob> mob,
|
|||
}
|
||||
}
|
||||
|
||||
void HumanoidMobRenderer::scale(std::shared_ptr<Mob> mob, float a) {
|
||||
void HumanoidMobRenderer::scale(std::shared_ptr<LivingEntity> mob, float a) {
|
||||
glScalef(_scale, _scale, _scale);
|
||||
}
|
||||
|
|
@ -1,9 +1,15 @@
|
|||
#pragma once
|
||||
#include "MobRenderer.h"
|
||||
|
||||
class HumanoidModel;
|
||||
class Giant;
|
||||
class ArmorItem;
|
||||
|
||||
class HumanoidMobRenderer : public MobRenderer {
|
||||
private:
|
||||
static const std::wstring MATERIAL_NAMES[5];
|
||||
static std::map<std::wstring, ResourceLocation> ARMOR_LOCATION_CACHE;
|
||||
|
||||
protected:
|
||||
HumanoidModel* humanoidModel;
|
||||
float _scale;
|
||||
|
|
@ -13,12 +19,27 @@ protected:
|
|||
void _init(HumanoidModel* humanoidModel, float scale);
|
||||
|
||||
public:
|
||||
static ResourceLocation* getArmorLocation(ArmorItem* armorItem, int layer);
|
||||
static ResourceLocation* getArmorLocation(ArmorItem* armorItem, int layer,
|
||||
bool overlay);
|
||||
|
||||
HumanoidMobRenderer(HumanoidModel* humanoidModel, float shadow);
|
||||
HumanoidMobRenderer(HumanoidModel* humanoidModel, float shadow,
|
||||
float scale);
|
||||
|
||||
virtual void prepareSecondPassArmor(std::shared_ptr<LivingEntity> mob,
|
||||
int layer, float a);
|
||||
|
||||
protected:
|
||||
virtual void createArmorParts();
|
||||
virtual void additionalRendering(std::shared_ptr<Mob> mob, float a);
|
||||
void scale(std::shared_ptr<Mob> mob, float a);
|
||||
virtual int prepareArmor(std::shared_ptr<LivingEntity> _mob, int layer,
|
||||
float a);
|
||||
virtual void render(std::shared_ptr<Entity> _mob, double x, double y,
|
||||
double z, float rot, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
virtual void prepareCarriedItem(std::shared_ptr<Entity> mob,
|
||||
std::shared_ptr<ItemInstance> item);
|
||||
virtual void additionalRendering(std::shared_ptr<LivingEntity> mob,
|
||||
float a);
|
||||
virtual void scale(std::shared_ptr<LivingEntity> mob, float a);
|
||||
};
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
#include "EntityRenderDispatcher.h"
|
||||
// #include "ItemFrame"
|
||||
#include "ItemFrameRenderer.h"
|
||||
#include "../../Textures/TextureAtlas.h"
|
||||
|
||||
#include "../../../Minecraft.World/Util/JavaMath.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.item.h"
|
||||
|
|
@ -18,6 +19,9 @@
|
|||
#include "../../Textures/CompassTexture.h"
|
||||
#include "../Minimap.h"
|
||||
|
||||
ResourceLocation ItemFrameRenderer::MAP_BACKGROUND_LOCATION =
|
||||
ResourceLocation(TN_MISC_MAPBG);
|
||||
|
||||
void ItemFrameRenderer::registerTerrainTextures(IconRegister* iconRegister) {
|
||||
backTexture = iconRegister->registerIcon(L"itemframe_back");
|
||||
}
|
||||
|
|
@ -25,8 +29,8 @@ void ItemFrameRenderer::registerTerrainTextures(IconRegister* iconRegister) {
|
|||
void ItemFrameRenderer::render(std::shared_ptr<Entity> _itemframe, double x,
|
||||
double y, double z, float rot, float a) {
|
||||
// 4J - original version used generics and thus had an input parameter of
|
||||
// type EnderCrystal rather than std::shared_ptr<Entity> we have here - do
|
||||
// some casting around instead
|
||||
// type EnderCrystal rather than shared_ptr<Entity> we have here - do some
|
||||
// casting around instead
|
||||
std::shared_ptr<ItemFrame> itemFrame =
|
||||
std::dynamic_pointer_cast<ItemFrame>(_itemframe);
|
||||
|
||||
|
|
@ -51,7 +55,8 @@ void ItemFrameRenderer::drawFrame(std::shared_ptr<ItemFrame> itemFrame) {
|
|||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
glPushMatrix();
|
||||
entityRenderDispatcher->textures->bindTexture(TN_TERRAIN);
|
||||
entityRenderDispatcher->textures->bindTexture(
|
||||
&TextureAtlas::LOCATION_BLOCKS);
|
||||
glRotatef(itemFrame->yRot, 0, 1, 0);
|
||||
|
||||
Tile* wood = Tile::wood;
|
||||
|
|
@ -142,7 +147,7 @@ void ItemFrameRenderer::drawItem(std::shared_ptr<ItemFrame> entity) {
|
|||
}
|
||||
|
||||
if (itemEntity->getItem()->getItem() == Item::map) {
|
||||
entityRenderDispatcher->textures->bindTexture(TN_MISC_MAPBG);
|
||||
entityRenderDispatcher->textures->bindTexture(&MAP_BACKGROUND_LOCATION);
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
|
||||
glRotatef(180, 0, 1, 0);
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
class ItemFrameRenderer : public EntityRenderer {
|
||||
private:
|
||||
static ResourceLocation MAP_BACKGROUND_LOCATION;
|
||||
Icon* backTexture;
|
||||
|
||||
//@Override
|
||||
public:
|
||||
void registerTerrainTextures(IconRegister* iconRegister);
|
||||
virtual void render(std::shared_ptr<Entity> _itemframe, double x, double y,
|
||||
|
|
|
|||
|
|
@ -3,11 +3,12 @@
|
|||
#include "TileRenderer.h"
|
||||
#include "../Tesselator.h"
|
||||
#include "../../Textures/Textures.h"
|
||||
#include "../../Textures/TextureAtlas.h"
|
||||
#include "EntityRenderer.h"
|
||||
#include "PlayerRenderer.h"
|
||||
#include "EntityRenderDispatcher.h"
|
||||
#include "../Lighting.h"
|
||||
#include "../../Player/MultiPlayerLocalPlayer.h"
|
||||
#include "MultiPlayerLocalPlayer.h"
|
||||
#include "../Minimap.h"
|
||||
#include "../../Level/MultiPlayerLevel.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.item.h"
|
||||
|
|
@ -17,10 +18,19 @@
|
|||
#include "../../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.h"
|
||||
|
||||
int ItemInHandRenderer::list = -1;
|
||||
ResourceLocation ItemInHandRenderer::ENCHANT_GLINT_LOCATION =
|
||||
ResourceLocation(TN__BLUR__MISC_GLINT);
|
||||
ResourceLocation ItemInHandRenderer::MAP_BACKGROUND_LOCATION =
|
||||
ResourceLocation(TN_MISC_MAPBG);
|
||||
ResourceLocation ItemInHandRenderer::UNDERWATER_LOCATION =
|
||||
ResourceLocation(TN_MISC_WATER);
|
||||
|
||||
int ItemInHandRenderer::listItem = -1;
|
||||
int ItemInHandRenderer::listTerrain = -1;
|
||||
int ItemInHandRenderer::listGlint = -1;
|
||||
|
||||
ItemInHandRenderer::ItemInHandRenderer(Minecraft* mc, bool optimisedMinimap) {
|
||||
ItemInHandRenderer::ItemInHandRenderer(Minecraft* minecraft,
|
||||
bool optimisedMinimap) {
|
||||
// 4J - added
|
||||
height = 0;
|
||||
oHeight = 0;
|
||||
|
|
@ -28,20 +38,20 @@ ItemInHandRenderer::ItemInHandRenderer(Minecraft* mc, bool optimisedMinimap) {
|
|||
tileRenderer = new TileRenderer();
|
||||
lastSlot = -1;
|
||||
|
||||
this->mc = mc;
|
||||
minimap =
|
||||
new Minimap(mc->font, mc->options, mc->textures, optimisedMinimap);
|
||||
this->minecraft = minecraft;
|
||||
minimap = new Minimap(minecraft->font, minecraft->options,
|
||||
minecraft->textures, optimisedMinimap);
|
||||
|
||||
// 4J - replaced mesh that is used to render held items with individual
|
||||
// cubes, so we can make it all join up properly without seams. This has a
|
||||
// lot more quads in it than the original, so is now precompiled with a UV
|
||||
// matrix offset to put it in the final place for the current icon. Compile
|
||||
// it on demand for the first ItemInHandRenderer (list is static)
|
||||
if (list == -1) {
|
||||
list = MemoryTracker::genLists(1);
|
||||
if (listItem == -1) {
|
||||
listItem = MemoryTracker::genLists(1);
|
||||
float dd = 1 / 16.0f;
|
||||
|
||||
glNewList(list, GL_COMPILE);
|
||||
glNewList(listItem, GL_COMPILE);
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
t->begin();
|
||||
for (int yp = 0; yp < 16; yp++)
|
||||
|
|
@ -92,6 +102,62 @@ ItemInHandRenderer::ItemInHandRenderer(Minecraft* mc, bool optimisedMinimap) {
|
|||
glEndList();
|
||||
}
|
||||
|
||||
// Terrain texture is a different layout from the item texture
|
||||
if (listTerrain == -1) {
|
||||
listTerrain = MemoryTracker::genLists(1);
|
||||
float dd = 1 / 16.0f;
|
||||
|
||||
glNewList(listTerrain, GL_COMPILE);
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
t->begin();
|
||||
for (int yp = 0; yp < 16; yp++)
|
||||
for (int xp = 0; xp < 16; xp++) {
|
||||
float u = (15 - xp) / 256.0f;
|
||||
float v = (15 - yp) / 512.0f;
|
||||
u += 0.5f / 256.0f;
|
||||
v += 0.5f / 512.0f;
|
||||
float x0 = xp / 16.0f;
|
||||
float x1 = x0 + 1.0f / 16.0f;
|
||||
float y0 = yp / 16.0f;
|
||||
float y1 = y0 + 1.0f / 16.0f;
|
||||
float z0 = 0.0f;
|
||||
float z1 = -dd;
|
||||
|
||||
t->normal(0, 0, 1);
|
||||
t->vertexUV(x0, y0, z0, u, v);
|
||||
t->vertexUV(x1, y0, z0, u, v);
|
||||
t->vertexUV(x1, y1, z0, u, v);
|
||||
t->vertexUV(x0, y1, z0, u, v);
|
||||
t->normal(0, 0, -1);
|
||||
t->vertexUV(x0, y1, z1, u, v);
|
||||
t->vertexUV(x1, y1, z1, u, v);
|
||||
t->vertexUV(x1, y0, z1, u, v);
|
||||
t->vertexUV(x0, y0, z1, u, v);
|
||||
t->normal(-1, 0, 0);
|
||||
t->vertexUV(x0, y0, z1, u, v);
|
||||
t->vertexUV(x0, y0, z0, u, v);
|
||||
t->vertexUV(x0, y1, z0, u, v);
|
||||
t->vertexUV(x0, y1, z1, u, v);
|
||||
t->normal(1, 0, 0);
|
||||
t->vertexUV(x1, y1, z1, u, v);
|
||||
t->vertexUV(x1, y1, z0, u, v);
|
||||
t->vertexUV(x1, y0, z0, u, v);
|
||||
t->vertexUV(x1, y0, z1, u, v);
|
||||
t->normal(0, 1, 0);
|
||||
t->vertexUV(x1, y0, z0, u, v);
|
||||
t->vertexUV(x0, y0, z0, u, v);
|
||||
t->vertexUV(x0, y0, z1, u, v);
|
||||
t->vertexUV(x1, y0, z1, u, v);
|
||||
t->normal(0, -1, 0);
|
||||
t->vertexUV(x1, y1, z1, u, v);
|
||||
t->vertexUV(x0, y1, z1, u, v);
|
||||
t->vertexUV(x0, y1, z0, u, v);
|
||||
t->vertexUV(x1, y1, z0, u, v);
|
||||
}
|
||||
t->end();
|
||||
glEndList();
|
||||
}
|
||||
|
||||
// Also create special object for glint overlays - this is the same as the
|
||||
// previous one, with a different UV scalings, and depth test set to equal
|
||||
if (listGlint == -1) {
|
||||
|
|
@ -159,7 +225,7 @@ ItemInHandRenderer::ItemInHandRenderer(Minecraft* mc, bool optimisedMinimap) {
|
|||
}
|
||||
}
|
||||
|
||||
void ItemInHandRenderer::renderItem(std::shared_ptr<Mob> mob,
|
||||
void ItemInHandRenderer::renderItem(std::shared_ptr<LivingEntity> mob,
|
||||
std::shared_ptr<ItemInstance> item,
|
||||
int layer, bool setColor /* = true*/) {
|
||||
// 4J - code borrowed from render method below, although not factoring in
|
||||
|
|
@ -179,10 +245,11 @@ void ItemInHandRenderer::renderItem(std::shared_ptr<Mob> mob,
|
|||
if (item->getIconType() == Icon::TYPE_TERRAIN && tile != NULL &&
|
||||
TileRenderer::canRender(tile->getRenderShape())) {
|
||||
MemSect(31);
|
||||
mc->textures->bindTexture(TN_TERRAIN); // 4J was L"/terrain.png"
|
||||
minecraft->textures->bindTexture(
|
||||
minecraft->textures->getTextureLocation(Icon::TYPE_TERRAIN));
|
||||
MemSect(0);
|
||||
tileRenderer->renderTile(
|
||||
tile, item->getAuxValue(),
|
||||
Tile::tiles[item->id], item->getAuxValue(),
|
||||
SharedConstants::TEXTURE_LIGHTING
|
||||
? 1.0f
|
||||
: mob->getBrightness(
|
||||
|
|
@ -196,12 +263,10 @@ void ItemInHandRenderer::renderItem(std::shared_ptr<Mob> mob,
|
|||
return;
|
||||
}
|
||||
|
||||
if (item->getIconType() == Icon::TYPE_TERRAIN) {
|
||||
mc->textures->bindTexture(TN_TERRAIN); // 4J was L"/terrain.png"
|
||||
} else {
|
||||
mc->textures->bindTexture(
|
||||
TN_GUI_ITEMS); // 4J was L"/gui/items.png"
|
||||
}
|
||||
bool bIsTerrain = item->getIconType() == Icon::TYPE_TERRAIN;
|
||||
minecraft->textures->bindTexture(
|
||||
minecraft->textures->getTextureLocation(item->getIconType()));
|
||||
|
||||
MemSect(0);
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
|
||||
|
|
@ -241,13 +306,12 @@ void ItemInHandRenderer::renderItem(std::shared_ptr<Mob> mob,
|
|||
float dd = 1 / 16.0f;
|
||||
|
||||
renderItem3D(t, u0, v0, u1, v1, icon->getSourceWidth(),
|
||||
icon->getSourceHeight(), 1 / 16.0f, false);
|
||||
icon->getSourceHeight(), 1 / 16.0f, false, bIsTerrain);
|
||||
|
||||
if (item != NULL && item->isFoil() && layer == 0) {
|
||||
glDepthFunc(GL_EQUAL);
|
||||
glDisable(GL_LIGHTING);
|
||||
mc->textures->bind(mc->textures->loadTexture(
|
||||
TN__BLUR__MISC_GLINT)); // 4J was L"%blur%/misc/glint.png"
|
||||
minecraft->textures->bindTexture(&ENCHANT_GLINT_LOCATION);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_COLOR, GL_ONE);
|
||||
float br = 0.76f;
|
||||
|
|
@ -263,7 +327,7 @@ void ItemInHandRenderer::renderItem(std::shared_ptr<Mob> mob,
|
|||
glTranslatef(sx, 0, 0);
|
||||
glRotatef(-50, 0, 0, 1);
|
||||
|
||||
renderItem3D(t, 0, 0, 1, 1, 256, 256, 1 / 16.0f, true);
|
||||
renderItem3D(t, 0, 0, 1, 1, 256, 256, 1 / 16.0f, true, bIsTerrain);
|
||||
glPopMatrix();
|
||||
glPushMatrix();
|
||||
glScalef(ss, ss, ss);
|
||||
|
|
@ -271,7 +335,7 @@ void ItemInHandRenderer::renderItem(std::shared_ptr<Mob> mob,
|
|||
(3000 + 1873.0f) * 8;
|
||||
glTranslatef(-sx, 0, 0);
|
||||
glRotatef(10, 0, 0, 1);
|
||||
renderItem3D(t, 0, 0, 1, 1, 256, 256, 1 / 16.0f, true);
|
||||
renderItem3D(t, 0, 0, 1, 1, 256, 256, 1 / 16.0f, true, bIsTerrain);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glDisable(GL_BLEND);
|
||||
|
|
@ -289,7 +353,8 @@ void ItemInHandRenderer::renderItem(std::shared_ptr<Mob> mob,
|
|||
// 4J added useList parameter
|
||||
void ItemInHandRenderer::renderItem3D(Tesselator* t, float u0, float v0,
|
||||
float u1, float v1, int width, int height,
|
||||
float depth, bool isGlint) {
|
||||
float depth, bool isGlint,
|
||||
bool isTerrain) {
|
||||
float r = 1.0f;
|
||||
|
||||
// 4J - replaced mesh that is used to render held items with individual
|
||||
|
|
@ -308,7 +373,7 @@ void ItemInHandRenderer::renderItem3D(Tesselator* t, float u0, float v0,
|
|||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
glTranslatef(u0, v0, 0);
|
||||
glCallList(list);
|
||||
glCallList(isTerrain ? listTerrain : listItem);
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
|
@ -318,12 +383,8 @@ void ItemInHandRenderer::renderItem3D(Tesselator* t, float u0, float v0,
|
|||
}
|
||||
|
||||
void ItemInHandRenderer::render(float a) {
|
||||
// 4jcraft: null checks here fix player hand rendering on linux
|
||||
// TOOD: determine why these are null in the first place
|
||||
if (!mc->player || !mc->level) return;
|
||||
|
||||
float h = oHeight + (height - oHeight) * a;
|
||||
std::shared_ptr<Player> player = mc->player;
|
||||
std::shared_ptr<Player> player = minecraft->player;
|
||||
|
||||
// 4J - added so we can adjust the position of the hands for horizontal &
|
||||
// vertical split screens
|
||||
|
|
@ -370,14 +431,14 @@ void ItemInHandRenderer::render(float a) {
|
|||
|
||||
std::shared_ptr<ItemInstance> item = selectedItem;
|
||||
|
||||
float br = mc->level->getBrightness(
|
||||
float br = minecraft->level->getBrightness(
|
||||
Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
|
||||
// 4J - change brought forward from 1.8.2
|
||||
if (SharedConstants::TEXTURE_LIGHTING) {
|
||||
br = 1;
|
||||
int col = mc->level->getLightColor(Mth::floor(player->x),
|
||||
Mth::floor(player->y),
|
||||
Mth::floor(player->z), 0);
|
||||
int col = minecraft->level->getLightColor(Mth::floor(player->x),
|
||||
Mth::floor(player->y),
|
||||
Mth::floor(player->z), 0);
|
||||
int u = col % 65536;
|
||||
int v = col / 65536;
|
||||
glMultiTexCoord2f(GL_TEXTURE1, u / 1.0f, v / 1.0f);
|
||||
|
|
@ -428,12 +489,13 @@ void ItemInHandRenderer::render(float a) {
|
|||
{
|
||||
// 4J-PB - if we've got a player texture, use that
|
||||
// glBindTexture(GL_TEXTURE_2D,
|
||||
// mc->textures->loadHttpTexture(mc->player->customTextureUrl,
|
||||
// mc->player->getTexture()));
|
||||
glBindTexture(GL_TEXTURE_2D, mc->textures->loadMemTexture(
|
||||
mc->player->customTextureUrl,
|
||||
mc->player->getTexture()));
|
||||
mc->textures->clearLastBoundId();
|
||||
// minecraft->textures->loadHttpTexture(minecraft->player->customTextureUrl,
|
||||
// minecraft->player->getTexture()));
|
||||
glBindTexture(GL_TEXTURE_2D,
|
||||
minecraft->textures->loadMemTexture(
|
||||
minecraft->player->customTextureUrl,
|
||||
minecraft->player->getTexture()));
|
||||
minecraft->textures->clearLastBoundId();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
int flip = i * 2 - 1;
|
||||
glPushMatrix();
|
||||
|
|
@ -445,7 +507,8 @@ void ItemInHandRenderer::render(float a) {
|
|||
glRotatef((float)(-65 * flip), 0, 1, 0);
|
||||
|
||||
EntityRenderer* er =
|
||||
EntityRenderDispatcher::instance->getRenderer(mc->player);
|
||||
EntityRenderDispatcher::instance->getRenderer(
|
||||
minecraft->player);
|
||||
PlayerRenderer* playerRenderer = (PlayerRenderer*)er;
|
||||
float ss = 1;
|
||||
glScalef(ss, ss, ss);
|
||||
|
|
@ -484,7 +547,8 @@ void ItemInHandRenderer::render(float a) {
|
|||
glScalef(s, s, s);
|
||||
|
||||
MemSect(31);
|
||||
mc->textures->bindTexture(TN_MISC_MAPBG); // 4J was L"/misc/mapbg.png"
|
||||
minecraft->textures->bindTexture(
|
||||
&MAP_BACKGROUND_LOCATION); // 4J was L"/misc/mapbg.png"
|
||||
MemSect(0);
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
|
||||
|
|
@ -503,11 +567,11 @@ void ItemInHandRenderer::render(float a) {
|
|||
t->end();
|
||||
|
||||
std::shared_ptr<MapItemSavedData> data =
|
||||
Item::map->getSavedData(item, mc->level);
|
||||
Item::map->getSavedData(item, minecraft->level);
|
||||
PIXBeginNamedEvent(0, "Minimap render");
|
||||
if (data != NULL)
|
||||
minimap->render(mc->player, mc->textures, data,
|
||||
mc->player->entityId);
|
||||
minimap->render(minecraft->player, minecraft->textures, data,
|
||||
minecraft->player->entityId);
|
||||
PIXEndNamedEvent();
|
||||
|
||||
glPopMatrix();
|
||||
|
|
@ -653,15 +717,15 @@ void ItemInHandRenderer::render(float a) {
|
|||
// 4J-PB - if we've got a player texture, use that
|
||||
|
||||
// glBindTexture(GL_TEXTURE_2D,
|
||||
// mc->textures->loadHttpTexture(mc->player->customTextureUrl,
|
||||
// mc->player->getTexture()));
|
||||
// minecraft->textures->loadHttpTexture(minecraft->player->customTextureUrl,
|
||||
// minecraft->player->getTexture()));
|
||||
|
||||
MemSect(31);
|
||||
glBindTexture(GL_TEXTURE_2D,
|
||||
mc->textures->loadMemTexture(mc->player->customTextureUrl,
|
||||
mc->player->getTexture()));
|
||||
glBindTexture(GL_TEXTURE_2D, minecraft->textures->loadMemTexture(
|
||||
minecraft->player->customTextureUrl,
|
||||
minecraft->player->getTexture()));
|
||||
MemSect(0);
|
||||
mc->textures->clearLastBoundId();
|
||||
minecraft->textures->clearLastBoundId();
|
||||
glTranslatef(-1.0f, +3.6f, +3.5f);
|
||||
glRotatef(120, 0, 0, 1);
|
||||
glRotatef(180 + 20, 1, 0, 0);
|
||||
|
|
@ -670,7 +734,7 @@ void ItemInHandRenderer::render(float a) {
|
|||
glTranslatef(5.6f, 0, 0);
|
||||
|
||||
EntityRenderer* er =
|
||||
EntityRenderDispatcher::instance->getRenderer(mc->player);
|
||||
EntityRenderDispatcher::instance->getRenderer(minecraft->player);
|
||||
PlayerRenderer* playerRenderer = (PlayerRenderer*)er;
|
||||
float ss = 1;
|
||||
glScalef(ss, ss, ss);
|
||||
|
|
@ -694,35 +758,32 @@ void ItemInHandRenderer::render(float a) {
|
|||
|
||||
void ItemInHandRenderer::renderScreenEffect(float a) {
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
if (mc->player->isOnFire()) {
|
||||
MemSect(31);
|
||||
mc->textures->bindTexture(TN_TERRAIN); // 4J was L"/terrain.png"
|
||||
MemSect(0);
|
||||
if (minecraft->player->isOnFire()) {
|
||||
renderFire(a);
|
||||
}
|
||||
|
||||
if (mc->player->isInWall()) // Inside a tile
|
||||
if (minecraft->player->isInWall()) // Inside a tile
|
||||
{
|
||||
int x = Mth::floor(mc->player->x);
|
||||
int y = Mth::floor(mc->player->y);
|
||||
int z = Mth::floor(mc->player->z);
|
||||
int x = Mth::floor(minecraft->player->x);
|
||||
int y = Mth::floor(minecraft->player->y);
|
||||
int z = Mth::floor(minecraft->player->z);
|
||||
|
||||
MemSect(31);
|
||||
mc->textures->bindTexture(TN_TERRAIN); // 4J was L"/terrain.png"
|
||||
MemSect(0);
|
||||
int tile = mc->level->getTile(x, y, z);
|
||||
if (mc->level->isSolidBlockingTile(x, y, z)) {
|
||||
int tile = minecraft->level->getTile(x, y, z);
|
||||
if (minecraft->level->isSolidBlockingTile(x, y, z)) {
|
||||
renderTex(a, Tile::tiles[tile]->getTexture(2));
|
||||
} else {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
float xo = ((i >> 0) % 2 - 0.5f) * mc->player->bbWidth * 0.9f;
|
||||
float yo = ((i >> 1) % 2 - 0.5f) * mc->player->bbHeight * 0.2f;
|
||||
float zo = ((i >> 2) % 2 - 0.5f) * mc->player->bbWidth * 0.9f;
|
||||
float xo =
|
||||
((i >> 0) % 2 - 0.5f) * minecraft->player->bbWidth * 0.9f;
|
||||
float yo =
|
||||
((i >> 1) % 2 - 0.5f) * minecraft->player->bbHeight * 0.2f;
|
||||
float zo =
|
||||
((i >> 2) % 2 - 0.5f) * minecraft->player->bbWidth * 0.9f;
|
||||
int xt = Mth::floor(x + xo);
|
||||
int yt = Mth::floor(y + yo);
|
||||
int zt = Mth::floor(z + zo);
|
||||
if (mc->level->isSolidBlockingTile(xt, yt, zt)) {
|
||||
tile = mc->level->getTile(xt, yt, zt);
|
||||
if (minecraft->level->isSolidBlockingTile(xt, yt, zt)) {
|
||||
tile = minecraft->level->getTile(xt, yt, zt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -731,9 +792,10 @@ void ItemInHandRenderer::renderScreenEffect(float a) {
|
|||
renderTex(a, Tile::tiles[tile]->getTexture(2));
|
||||
}
|
||||
|
||||
if (mc->player->isUnderLiquid(Material::water)) {
|
||||
if (minecraft->player->isUnderLiquid(Material::water)) {
|
||||
MemSect(31);
|
||||
mc->textures->bindTexture(TN_MISC_WATER); // 4J was L"/misc/water.png"
|
||||
minecraft->textures->bindTexture(
|
||||
&UNDERWATER_LOCATION); // 4J was L"/misc/water.png"
|
||||
MemSect(0);
|
||||
renderWater(a);
|
||||
}
|
||||
|
|
@ -741,6 +803,9 @@ void ItemInHandRenderer::renderScreenEffect(float a) {
|
|||
}
|
||||
|
||||
void ItemInHandRenderer::renderTex(float a, Icon* slot) {
|
||||
minecraft->textures->bindTexture(
|
||||
&TextureAtlas::LOCATION_BLOCKS); // TODO: get this data from Icon
|
||||
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
|
||||
float br = 0.1f;
|
||||
|
|
@ -777,9 +842,11 @@ void ItemInHandRenderer::renderTex(float a, Icon* slot) {
|
|||
}
|
||||
|
||||
void ItemInHandRenderer::renderWater(float a) {
|
||||
minecraft->textures->bindTexture(&UNDERWATER_LOCATION);
|
||||
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
|
||||
float br = mc->player->getBrightness(a);
|
||||
float br = minecraft->player->getBrightness(a);
|
||||
glColor4f(br, br, br, 0.5f);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
|
@ -794,8 +861,8 @@ void ItemInHandRenderer::renderWater(float a) {
|
|||
float y1 = +1;
|
||||
float z0 = -0.5f;
|
||||
|
||||
float uo = -mc->player->yRot / 64.0f;
|
||||
float vo = +mc->player->xRot / 64.0f;
|
||||
float uo = -minecraft->player->yRot / 64.0f;
|
||||
float vo = +minecraft->player->xRot / 64.0f;
|
||||
|
||||
t->begin();
|
||||
t->vertexUV((float)(x0), (float)(y0), (float)(z0), (float)(size + uo),
|
||||
|
|
@ -815,7 +882,15 @@ void ItemInHandRenderer::renderWater(float a) {
|
|||
|
||||
void ItemInHandRenderer::renderFire(float a) {
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
glColor4f(1, 1, 1, 0.9f);
|
||||
|
||||
unsigned int col = Minecraft::GetInstance()->getColourTable()->getColor(
|
||||
eMinecraftColour_Fire_Overlay);
|
||||
float aCol = ((col >> 24) & 0xFF) / 255.0f;
|
||||
float rCol = ((col >> 16) & 0xFF) / 255.0f;
|
||||
float gCol = ((col >> 8) & 0xFF) / 255.0;
|
||||
float bCol = (col & 0xFF) / 255.0;
|
||||
|
||||
glColor4f(rCol, gCol, bCol, aCol);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
|
|
@ -823,6 +898,8 @@ void ItemInHandRenderer::renderFire(float a) {
|
|||
for (int i = 0; i < 2; i++) {
|
||||
glPushMatrix();
|
||||
Icon* slot = Tile::fire->getTextureLayer(1);
|
||||
minecraft->textures->bindTexture(
|
||||
&TextureAtlas::LOCATION_BLOCKS); // TODO: Get this from Icon
|
||||
|
||||
float u0 = slot->getU0(true);
|
||||
float u1 = slot->getU1(true);
|
||||
|
|
@ -856,7 +933,7 @@ void ItemInHandRenderer::renderFire(float a) {
|
|||
void ItemInHandRenderer::tick() {
|
||||
oHeight = height;
|
||||
|
||||
std::shared_ptr<Player> player = mc->player;
|
||||
std::shared_ptr<Player> player = minecraft->player;
|
||||
std::shared_ptr<ItemInstance> nextTile = player->inventory->getSelected();
|
||||
|
||||
bool matches =
|
||||
|
|
|
|||
|
|
@ -3,18 +3,24 @@
|
|||
class Minecraft;
|
||||
class ItemInstance;
|
||||
class Minimap;
|
||||
class Mob;
|
||||
class LivingEntity;
|
||||
class TileRenderer;
|
||||
class Tesselator;
|
||||
|
||||
class ItemInHandRenderer {
|
||||
public:
|
||||
// 4J - made these public
|
||||
static ResourceLocation ENCHANT_GLINT_LOCATION;
|
||||
static ResourceLocation MAP_BACKGROUND_LOCATION;
|
||||
static ResourceLocation UNDERWATER_LOCATION;
|
||||
|
||||
private:
|
||||
Minecraft* mc;
|
||||
Minecraft* minecraft;
|
||||
std::shared_ptr<ItemInstance> selectedItem;
|
||||
float height;
|
||||
float oHeight;
|
||||
TileRenderer* tileRenderer;
|
||||
static int list, listGlint;
|
||||
static int listItem, listGlint, listTerrain;
|
||||
|
||||
public:
|
||||
// 4J Stu - Made public so we can use it from ItemFramRenderer
|
||||
|
|
@ -24,12 +30,13 @@ public:
|
|||
ItemInHandRenderer(
|
||||
Minecraft* mc,
|
||||
bool optimisedMinimap = true); // 4J Added optimisedMinimap param
|
||||
void renderItem(std::shared_ptr<Mob> mob,
|
||||
void renderItem(std::shared_ptr<LivingEntity> mob,
|
||||
std::shared_ptr<ItemInstance> item, int layer,
|
||||
bool setColor = true); // 4J added setColor parameter
|
||||
static void renderItem3D(Tesselator* t, float u0, float v0, float u1,
|
||||
float v1, int width, int height, float depth,
|
||||
bool isGlint); // 4J added isGlint parameter
|
||||
static void renderItem3D(
|
||||
Tesselator* t, float u0, float v0, float u1, float v1, int width,
|
||||
int height, float depth, bool isGlint,
|
||||
bool isTerrain); // 4J added isGlint and isTerrain parameter
|
||||
public:
|
||||
void render(float a);
|
||||
void renderScreenEffect(float a);
|
||||
|
|
|
|||
|
|
@ -10,14 +10,19 @@
|
|||
#include "../../../Minecraft.World/Util/StringHelpers.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.h"
|
||||
#include "../../GameState/Options.h"
|
||||
#include "../../Textures/TextureAtlas.h"
|
||||
|
||||
#ifdef _XBOX
|
||||
extern IDirect3DDevice9* g_pD3DDevice;
|
||||
#endif
|
||||
|
||||
ItemRenderer::ItemRenderer() : EntityRenderer() {
|
||||
random = new Random();
|
||||
setColor = true;
|
||||
blitOffset = 0;
|
||||
|
||||
this->shadowRadius = 0.15f;
|
||||
this->shadowStrength = 0.75f;
|
||||
shadowRadius = 0.15f;
|
||||
shadowStrength = 0.75f;
|
||||
|
||||
// 4J added
|
||||
m_bItemFrame = false;
|
||||
|
|
@ -25,15 +30,38 @@ ItemRenderer::ItemRenderer() : EntityRenderer() {
|
|||
|
||||
ItemRenderer::~ItemRenderer() { delete random; }
|
||||
|
||||
ResourceLocation* ItemRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> entity) {
|
||||
std::shared_ptr<ItemEntity> itemEntity =
|
||||
std::dynamic_pointer_cast<ItemEntity>(entity);
|
||||
return getTextureLocation(itemEntity->getItem()->getIconType());
|
||||
}
|
||||
|
||||
ResourceLocation* ItemRenderer::getTextureLocation(int iconType) {
|
||||
if (iconType == Icon::TYPE_TERRAIN) {
|
||||
return &TextureAtlas::LOCATION_BLOCKS; // L"/terrain.png"));
|
||||
} else {
|
||||
#ifdef _XBOX
|
||||
// 4J - make sure we've got linear sampling on minification here as
|
||||
// non-mipmapped things like this currently default to having point
|
||||
// sampling, which makes very small icons render rather badly
|
||||
g_pD3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||
#endif
|
||||
return &TextureAtlas::LOCATION_ITEMS; // L"/gui/items.png"));
|
||||
}
|
||||
}
|
||||
|
||||
void ItemRenderer::render(std::shared_ptr<Entity> _itemEntity, double x,
|
||||
double y, double z, float rot, float a) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
std::shared_ptr<ItemEntity> itemEntity =
|
||||
std::dynamic_pointer_cast<ItemEntity>(_itemEntity);
|
||||
bindTexture(itemEntity);
|
||||
|
||||
random->setSeed(187);
|
||||
std::shared_ptr<ItemInstance> item = itemEntity->getItem();
|
||||
if (item->getItem() == NULL) return;
|
||||
|
||||
glPushMatrix();
|
||||
float bob =
|
||||
|
|
@ -46,11 +74,13 @@ void ItemRenderer::render(std::shared_ptr<Entity> _itemEntity, double x,
|
|||
if (itemEntity->getItem()->count > 1) count = 2;
|
||||
if (itemEntity->getItem()->count > 5) count = 3;
|
||||
if (itemEntity->getItem()->count > 20) count = 4;
|
||||
if (itemEntity->getItem()->count > 40) count = 5;
|
||||
|
||||
glTranslatef((float)x, (float)y + bob, (float)z);
|
||||
glEnable(GL_RESCALE_NORMAL);
|
||||
|
||||
Tile* tile = Tile::tiles[item->id];
|
||||
|
||||
if (item->getIconType() == Icon::TYPE_TERRAIN && tile != NULL &&
|
||||
TileRenderer::canRender(tile->getRenderShape())) {
|
||||
glRotatef(spin, 0, 1, 0);
|
||||
|
|
@ -61,7 +91,6 @@ void ItemRenderer::render(std::shared_ptr<Entity> _itemEntity, double x,
|
|||
glRotatef(-90, 0, 1, 0);
|
||||
}
|
||||
|
||||
bindTexture(TN_TERRAIN); // 4J was L"/terrain.png"
|
||||
float s = 1 / 4.0f;
|
||||
int shape = tile->getRenderShape();
|
||||
if (shape == Tile::SHAPE_CROSS_TEXTURE || shape == Tile::SHAPE_STEM ||
|
||||
|
|
@ -85,7 +114,8 @@ void ItemRenderer::render(std::shared_ptr<Entity> _itemEntity, double x,
|
|||
tileRenderer->renderTile(tile, item->getAuxValue(), br);
|
||||
glPopMatrix();
|
||||
}
|
||||
} else if (item->getItem()->hasMultipleSpriteLayers()) {
|
||||
} else if (item->getIconType() == Icon::TYPE_ITEM &&
|
||||
item->getItem()->hasMultipleSpriteLayers()) {
|
||||
if (m_bItemFrame) {
|
||||
glScalef(1 / 1.95f, 1 / 1.95f, 1 / 1.95f);
|
||||
glTranslatef(0, -0.05f, 0);
|
||||
|
|
@ -94,7 +124,7 @@ void ItemRenderer::render(std::shared_ptr<Entity> _itemEntity, double x,
|
|||
glScalef(1 / 2.0f, 1 / 2.0f, 1 / 2.0f);
|
||||
}
|
||||
|
||||
bindTexture(TN_GUI_ITEMS); // 4J was "/gui/items.png"
|
||||
bindTexture(&TextureAtlas::LOCATION_ITEMS); // 4J was "/gui/items.png"
|
||||
|
||||
for (int layer = 0; layer <= 1; layer++) {
|
||||
random->setSeed(187);
|
||||
|
|
@ -129,13 +159,9 @@ void ItemRenderer::render(std::shared_ptr<Entity> _itemEntity, double x,
|
|||
// 4J Stu - For rendering the static compass, we give it a non-zero aux
|
||||
// value
|
||||
if (item->id == Item::compass_Id) item->setAuxValue(255);
|
||||
Icon* icon = item->getIcon();
|
||||
if (item->id == Item::compass_Id) item->setAuxValue(0);
|
||||
if (item->getIconType() == Icon::TYPE_TERRAIN) {
|
||||
bindTexture(TN_TERRAIN); // 4J was L"/terrain.png"
|
||||
} else {
|
||||
bindTexture(TN_GUI_ITEMS); // 4J was L"/gui/items.png"
|
||||
}
|
||||
|
||||
Icon* icon = item->getIcon();
|
||||
if (setColor) {
|
||||
int col = Item::items[item->id]->getColor(item, 0);
|
||||
float red = ((col >> 16) & 0xff) / 255.0f;
|
||||
|
|
@ -218,25 +244,31 @@ void ItemRenderer::renderItemBillboard(std::shared_ptr<ItemEntity> entity,
|
|||
|
||||
for (int i = 0; i < count; i++) {
|
||||
glTranslatef(0, 0, width + margin);
|
||||
|
||||
bool bIsTerrain = false;
|
||||
if (item->getIconType() == Icon::TYPE_TERRAIN &&
|
||||
Tile::tiles[item->id] != NULL) {
|
||||
bindTexture(TN_TERRAIN); // Was L"/terrain.png");
|
||||
bIsTerrain = true;
|
||||
bindTexture(&TextureAtlas::LOCATION_BLOCKS); // TODO: Do this
|
||||
// sanely by Icon
|
||||
} else {
|
||||
bindTexture(TN_GUI_ITEMS); // L"/gui/items.png");
|
||||
bindTexture(&TextureAtlas::LOCATION_ITEMS); // TODO: Do this
|
||||
// sanely by Icon
|
||||
}
|
||||
|
||||
glColor4f(red, green, blue, 1);
|
||||
// 4J Stu - u coords were swapped in Java
|
||||
// ItemInHandRenderer::renderItem3D(t, u1, v0, u0, v1,
|
||||
// icon->getSourceWidth(), icon->getSourceHeight(), width, false);
|
||||
ItemInHandRenderer::renderItem3D(
|
||||
t, u0, v0, u1, v1, icon->getSourceWidth(),
|
||||
icon->getSourceHeight(), width, false);
|
||||
icon->getSourceHeight(), width, false, bIsTerrain);
|
||||
|
||||
if (item != NULL && item->isFoil()) {
|
||||
glDepthFunc(GL_EQUAL);
|
||||
glDisable(GL_LIGHTING);
|
||||
entityRenderDispatcher->textures->bindTexture(
|
||||
TN__BLUR__MISC_GLINT); // was L"%blur%/misc/glint.png");
|
||||
&ItemInHandRenderer::ENCHANT_GLINT_LOCATION);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_COLOR, GL_ONE);
|
||||
float br = 0.76f;
|
||||
|
|
@ -251,7 +283,7 @@ void ItemRenderer::renderItemBillboard(std::shared_ptr<ItemEntity> entity,
|
|||
glRotatef(-50, 0, 0, 1);
|
||||
|
||||
ItemInHandRenderer::renderItem3D(t, 0, 0, 1, 1, 255, 255, width,
|
||||
true);
|
||||
true, bIsTerrain);
|
||||
glPopMatrix();
|
||||
glPushMatrix();
|
||||
glScalef(ss, ss, ss);
|
||||
|
|
@ -260,7 +292,7 @@ void ItemRenderer::renderItemBillboard(std::shared_ptr<ItemEntity> entity,
|
|||
glTranslatef(-sx, 0, 0);
|
||||
glRotatef(10, 0, 0, 1);
|
||||
ItemInHandRenderer::renderItem3D(t, 0, 0, 1, 1, 255, 255, width,
|
||||
true);
|
||||
true, bIsTerrain);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glDisable(GL_BLEND);
|
||||
|
|
@ -307,17 +339,12 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures,
|
|||
renderGuiItem(font, textures, item, x, y, fScale, fScale, fAlpha, true);
|
||||
}
|
||||
|
||||
#ifdef _XBOX
|
||||
extern IDirect3DDevice9* g_pD3DDevice;
|
||||
#endif
|
||||
|
||||
// 4J - this used to take x and y as ints, and no scale and alpha - but this
|
||||
// interface is now implemented as a wrapper round this more fully featured one
|
||||
void ItemRenderer::renderGuiItem(Font* font, Textures* textures,
|
||||
std::shared_ptr<ItemInstance> item, float x,
|
||||
float y, float fScaleX, float fScaleY,
|
||||
float fAlpha, bool useCompiled) {
|
||||
if (!item) return;
|
||||
int itemId = item->id;
|
||||
int itemAuxValue = item->getAuxValue();
|
||||
Icon* itemIcon = item->getIcon();
|
||||
|
|
@ -326,20 +353,17 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures,
|
|||
TileRenderer::canRender(Tile::tiles[itemId]->getRenderShape())) {
|
||||
PIXBeginNamedEvent(0, "3D gui item render %d\n", itemId);
|
||||
MemSect(31);
|
||||
textures->bindTexture(TN_TERRAIN); // L"/terrain.png"));
|
||||
textures->bindTexture(&TextureAtlas::LOCATION_BLOCKS);
|
||||
MemSect(0);
|
||||
|
||||
Tile* tile = Tile::tiles[itemId];
|
||||
glPushMatrix();
|
||||
// 4J - original code left here for reference
|
||||
// 4jcraft: re-enable said original code to fix hotbar block rendering
|
||||
#if 1
|
||||
glTranslatef((float)(x), (float)(y), 0.0f);
|
||||
// glScalef(fScale, fScale, fScale);
|
||||
glScalef(fScaleX, fScaleY,
|
||||
1.0f); // 4jcraft: tweaked to use the new variables
|
||||
glTranslatef(-2.0f, 3.0f, -3.0f + blitOffset);
|
||||
glScalef(10.0f, 10.0f, 10.0f);
|
||||
#if 0
|
||||
glTranslatef((float)(x), (float)(y), 0.0f);
|
||||
glScalef(fScale, fScale, fScale);
|
||||
glTranslatef(-2.0f,3.0f, -3.0f + blitOffset);
|
||||
glScalef(10.0f, 10.0f, 10.0f);
|
||||
glTranslatef(1.0f, 0.5f, 8.0f);
|
||||
glScalef(1.0f, 1.0f, -1.0f);
|
||||
glRotatef(180.0f + 30.0f, 1.0f, 0.0f, 0.0f);
|
||||
|
|
@ -360,8 +384,9 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures,
|
|||
glRotatef(45.0f, 0.0f, 1.0f,
|
||||
0.0f); // Rotate round y axis (centre at origin)
|
||||
#endif
|
||||
// 4J-PB - pass the alpha value in - the grass block render has the top
|
||||
// surface coloured differently to the rest of the block
|
||||
// 4J-PB - pass the alpha value in - the grass block
|
||||
// render has the top surface coloured differently to
|
||||
// the rest of the block
|
||||
glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);
|
||||
tileRenderer->renderTile(tile, itemAuxValue, 1, fAlpha, useCompiled);
|
||||
|
||||
|
|
@ -371,7 +396,9 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures,
|
|||
PIXBeginNamedEvent(0, "Potion gui item render %d\n", itemIcon);
|
||||
// special double-layered
|
||||
glDisable(GL_LIGHTING);
|
||||
textures->bindTexture(TN_GUI_ITEMS); // "/gui/items.png"
|
||||
|
||||
ResourceLocation* location = getTextureLocation(item->getIconType());
|
||||
textures->bindTexture(location);
|
||||
|
||||
for (int layer = 0; layer <= 1; layer++) {
|
||||
Icon* fillingIcon =
|
||||
|
|
@ -397,14 +424,17 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures,
|
|||
glDisable(GL_LIGHTING);
|
||||
MemSect(31);
|
||||
if (item->getIconType() == Icon::TYPE_TERRAIN) {
|
||||
textures->bindTexture(TN_TERRAIN); // L"/terrain.png"));
|
||||
textures->bindTexture(
|
||||
&TextureAtlas::LOCATION_BLOCKS); // L"/terrain.png"));
|
||||
} else {
|
||||
textures->bindTexture(
|
||||
TN_GUI_ITEMS); // L"/gui/items.png"));
|
||||
&TextureAtlas::LOCATION_ITEMS); // L"/gui/items.png"));
|
||||
#ifdef _XBOX
|
||||
// 4J - make sure we've got linear sampling on
|
||||
// minification here as non-mipmapped things
|
||||
// like this currently
|
||||
// 4J - make sure we've got
|
||||
// linear sampling on
|
||||
// minification here as
|
||||
// non-mipmapped things like
|
||||
// this currently
|
||||
// default to having point sampling, which makes very small icons
|
||||
// render rather badly
|
||||
g_pD3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||
|
|
@ -474,7 +504,8 @@ void ItemRenderer::renderAndDecorateItem(
|
|||
glDisable(GL_LIGHTING);
|
||||
glDepthMask(false);
|
||||
textures->bindTexture(
|
||||
TN__BLUR__MISC_GLINT); // 4J was "%blur%/misc/glint.png"
|
||||
&ItemInHandRenderer::
|
||||
ENCHANT_GLINT_LOCATION); // 4J was "%blur%/misc/glint.png"
|
||||
blitOffset -= 50;
|
||||
if (!isConstantBlended) glEnable(GL_BLEND);
|
||||
|
||||
|
|
@ -585,10 +616,6 @@ void ItemRenderer::renderGuiItemDecorations(Font* font, Textures* textures,
|
|||
return;
|
||||
}
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
RenderManager.StateSetBlendFactor(0xffffff |
|
||||
(((unsigned int)(fAlpha * 0xff)) << 24));
|
||||
glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA);
|
||||
if (item->count > 1 || !countText.empty() ||
|
||||
item->GetForceNumberDisplay()) {
|
||||
MemSect(31);
|
||||
|
|
@ -605,7 +632,7 @@ void ItemRenderer::renderGuiItemDecorations(Font* font, Textures* textures,
|
|||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
font->drawShadow(amount, x + 19 - 2 - font->width(amount), y + 6 + 3,
|
||||
0xffffff);
|
||||
0xffffff | (((unsigned int)(fAlpha * 0xff)) << 24));
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class ItemEntity;
|
|||
class ItemRenderer : public EntityRenderer {
|
||||
private:
|
||||
// TileRenderer *tileRenderer; // 4J - removed - this is shadowing the
|
||||
//tilerenderer from entityrenderer
|
||||
// tilerenderer from entityrenderer
|
||||
Random* random;
|
||||
bool m_bItemFrame;
|
||||
|
||||
|
|
@ -21,6 +21,9 @@ public:
|
|||
virtual ~ItemRenderer();
|
||||
virtual void render(std::shared_ptr<Entity> _itemEntity, double x, double y,
|
||||
double z, float rot, float a);
|
||||
virtual ResourceLocation* getTextureLocation(
|
||||
std::shared_ptr<Entity> entity);
|
||||
virtual ResourceLocation* getTextureLocation(int iconType);
|
||||
|
||||
private:
|
||||
virtual void renderItemBillboard(std::shared_ptr<ItemEntity> entity,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "ItemSpriteRenderer.h"
|
||||
#include "EntityRenderDispatcher.h"
|
||||
#include "../../Textures/TextureAtlas.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.projectile.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.item.alchemy.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.item.h"
|
||||
|
|
@ -32,7 +33,7 @@ void ItemSpriteRenderer::render(std::shared_ptr<Entity> e, double x, double y,
|
|||
glTranslatef((float)x, (float)y, (float)z);
|
||||
glEnable(GL_RESCALE_NORMAL);
|
||||
glScalef(1 / 2.0f, 1 / 2.0f, 1 / 2.0f);
|
||||
bindTexture(TN_GUI_ITEMS); // 4J - was L"/gui/items.png"
|
||||
bindTexture(e);
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
|
||||
if (icon == PotionItem::getTexture(PotionItem::THROWABLE_ICON)) {
|
||||
|
|
@ -79,4 +80,9 @@ void ItemSpriteRenderer::renderIcon(Tesselator* t, Icon* icon) {
|
|||
t->vertexUV((float)(0 - xo), (float)(r - yo), (float)(0), (float)(u0),
|
||||
(float)(v0));
|
||||
t->end();
|
||||
}
|
||||
|
||||
ResourceLocation* ItemSpriteRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &TextureAtlas::LOCATION_ITEMS;
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ public:
|
|||
// ItemSpriteRenderer(Item *icon);
|
||||
virtual void render(std::shared_ptr<Entity> e, double x, double y, double z,
|
||||
float rot, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
|
||||
private:
|
||||
void renderIcon(Tesselator* t, Icon* icon);
|
||||
|
|
|
|||
|
|
@ -3,29 +3,22 @@
|
|||
#include "../Models/LavaSlimeModel.h"
|
||||
#include "LavaSlimeRenderer.h"
|
||||
|
||||
ResourceLocation LavaSlimeRenderer::MAGMACUBE_LOCATION =
|
||||
ResourceLocation(TN_MOB_LAVA);
|
||||
|
||||
LavaSlimeRenderer::LavaSlimeRenderer()
|
||||
: MobRenderer(new LavaSlimeModel(), .25f) {
|
||||
this->modelVersion = ((LavaSlimeModel*)model)->getModelVersion();
|
||||
}
|
||||
|
||||
void LavaSlimeRenderer::render(std::shared_ptr<Entity> _mob, double x, double y,
|
||||
double z, float rot, float a) {
|
||||
// 4J - original version used generics and thus had an input parameter of
|
||||
// type LavaSlime rather than std::shared_ptr<Entity> we have here - do
|
||||
// some casting around instead
|
||||
std::shared_ptr<LavaSlime> mob = std::dynamic_pointer_cast<LavaSlime>(_mob);
|
||||
int modelVersion = ((LavaSlimeModel*)model)->getModelVersion();
|
||||
if (modelVersion != this->modelVersion) {
|
||||
this->modelVersion = modelVersion;
|
||||
model = new LavaSlimeModel();
|
||||
app.DebugPrintf("new lava slime model\n");
|
||||
}
|
||||
MobRenderer::render(mob, x, y, z, rot, a);
|
||||
ResourceLocation* LavaSlimeRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &MAGMACUBE_LOCATION;
|
||||
}
|
||||
|
||||
void LavaSlimeRenderer::scale(std::shared_ptr<Mob> _slime, float a) {
|
||||
void LavaSlimeRenderer::scale(std::shared_ptr<LivingEntity> _slime, float a) {
|
||||
// 4J - original version used generics and thus had an input parameter of
|
||||
// type LavaSlime rather than std::shared_ptr<Mob> we have here - do some
|
||||
// type LavaSlime rather than shared_ptr<Mob> we have here - do some
|
||||
// casting around instead
|
||||
std::shared_ptr<LavaSlime> slime =
|
||||
std::dynamic_pointer_cast<LavaSlime>(_slime);
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include "MobRenderer.h"
|
||||
|
||||
class LavaSlimeRenderer : public MobRenderer {
|
||||
private:
|
||||
int modelVersion;
|
||||
static ResourceLocation MAGMACUBE_LOCATION;
|
||||
|
||||
public:
|
||||
LavaSlimeRenderer();
|
||||
|
||||
virtual void render(std::shared_ptr<Entity> _mob, double x, double y,
|
||||
double z, float rot, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
|
||||
protected:
|
||||
virtual void scale(std::shared_ptr<Mob> _slime, float a);
|
||||
virtual void scale(std::shared_ptr<LivingEntity> _slime, float a);
|
||||
};
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "LeashKnotRenderer.h"
|
||||
#include "../Models/LeashKnotModel.h"
|
||||
|
||||
ResourceLocation LeashKnotRenderer::KNOT_LOCATION =
|
||||
ResourceLocation(TN_ITEM_LEASHKNOT);
|
||||
|
||||
LeashKnotRenderer::LeashKnotRenderer() : EntityRenderer() {
|
||||
model = new LeashKnotModel();
|
||||
}
|
||||
|
||||
LeashKnotRenderer::~LeashKnotRenderer() { delete model; }
|
||||
|
||||
void LeashKnotRenderer::render(std::shared_ptr<Entity> entity, double x,
|
||||
double y, double z, float rot, float a) {
|
||||
glPushMatrix();
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
glTranslatef((float)x, (float)y, (float)z);
|
||||
|
||||
float scale = 1 / 16.0f;
|
||||
glEnable(GL_RESCALE_NORMAL);
|
||||
glScalef(-1, -1, 1);
|
||||
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
|
||||
bindTexture(entity);
|
||||
model->render(entity, 0, 0, 0, 0, 0, scale, true);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
ResourceLocation* LeashKnotRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> entity) {
|
||||
return &KNOT_LOCATION;
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
#include "EntityRenderer.h"
|
||||
|
||||
class LeashKnotModel;
|
||||
|
||||
class LeashKnotRenderer : public EntityRenderer {
|
||||
private:
|
||||
static ResourceLocation KNOT_LOCATION;
|
||||
LeashKnotModel* model;
|
||||
|
||||
public:
|
||||
LeashKnotRenderer();
|
||||
~LeashKnotRenderer();
|
||||
virtual void render(std::shared_ptr<Entity> entity, double x, double y,
|
||||
double z, float rot, float a);
|
||||
|
||||
protected:
|
||||
virtual ResourceLocation* getTextureLocation(
|
||||
std::shared_ptr<Entity> entity);
|
||||
};
|
||||
|
|
@ -0,0 +1,616 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "LivingEntityRenderer.h"
|
||||
#include "../Lighting.h"
|
||||
#include "../Cube.h"
|
||||
#include "../Models/ModelPart.h"
|
||||
#include "EntityRenderDispatcher.h"
|
||||
#include "../../Player/MultiPlayerLocalPlayer.h"
|
||||
#include "../../../Minecraft.World/Entities/Mobs/Arrow.h"
|
||||
#include "../../../Minecraft.World/Util/Mth.h"
|
||||
#include "../../../Minecraft.World/Player/Player.h"
|
||||
|
||||
ResourceLocation LivingEntityRenderer::ENCHANT_GLINT_LOCATION =
|
||||
ResourceLocation(TN__BLUR__MISC_GLINT);
|
||||
int LivingEntityRenderer::MAX_ARMOR_LAYERS = 4;
|
||||
|
||||
LivingEntityRenderer::LivingEntityRenderer(Model* model, float shadow) {
|
||||
this->model = model;
|
||||
shadowRadius = shadow;
|
||||
armor = NULL;
|
||||
}
|
||||
|
||||
void LivingEntityRenderer::setArmor(Model* armor) { this->armor = armor; }
|
||||
|
||||
float LivingEntityRenderer::rotlerp(float from, float to, float a) {
|
||||
float diff = to - from;
|
||||
while (diff < -180) diff += 360;
|
||||
while (diff >= 180) diff -= 360;
|
||||
return from + a * diff;
|
||||
}
|
||||
|
||||
void LivingEntityRenderer::render(std::shared_ptr<Entity> _mob, double x,
|
||||
double y, double z, float rot, float a) {
|
||||
std::shared_ptr<LivingEntity> mob =
|
||||
std::dynamic_pointer_cast<LivingEntity>(_mob);
|
||||
|
||||
glPushMatrix();
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
model->attackTime = getAttackAnim(mob, a);
|
||||
if (armor != NULL) armor->attackTime = model->attackTime;
|
||||
model->riding = mob->isRiding();
|
||||
if (armor != NULL) armor->riding = model->riding;
|
||||
model->young = mob->isBaby();
|
||||
if (armor != NULL) armor->young = model->young;
|
||||
|
||||
/*try*/
|
||||
{
|
||||
float bodyRot = rotlerp(mob->yBodyRotO, mob->yBodyRot, a);
|
||||
float headRot = rotlerp(mob->yHeadRotO, mob->yHeadRot, a);
|
||||
|
||||
if (mob->isRiding() && mob->riding->instanceof(eTYPE_LIVINGENTITY)) {
|
||||
std::shared_ptr<LivingEntity> riding =
|
||||
std::dynamic_pointer_cast<LivingEntity>(mob->riding);
|
||||
bodyRot = rotlerp(riding->yBodyRotO, riding->yBodyRot, a);
|
||||
|
||||
float headDiff = Mth::wrapDegrees(headRot - bodyRot);
|
||||
if (headDiff < -85) headDiff = -85;
|
||||
if (headDiff >= 85) headDiff = +85;
|
||||
bodyRot = headRot - headDiff;
|
||||
if (headDiff * headDiff > 50 * 50) {
|
||||
bodyRot += headDiff * 0.2f;
|
||||
}
|
||||
}
|
||||
|
||||
float headRotx = (mob->xRotO + (mob->xRot - mob->xRotO) * a);
|
||||
|
||||
setupPosition(mob, x, y, z);
|
||||
|
||||
float bob = getBob(mob, a);
|
||||
setupRotations(mob, bob, bodyRot, a);
|
||||
|
||||
float fScale = 1 / 16.0f;
|
||||
glEnable(GL_RESCALE_NORMAL);
|
||||
glScalef(-1, -1, 1);
|
||||
|
||||
scale(mob, a);
|
||||
glTranslatef(0, -24 * fScale - 0.125f / 16.0f, 0);
|
||||
|
||||
float ws = mob->walkAnimSpeedO +
|
||||
(mob->walkAnimSpeed - mob->walkAnimSpeedO) * a;
|
||||
float wp = mob->walkAnimPos - mob->walkAnimSpeed * (1 - a);
|
||||
if (mob->isBaby()) {
|
||||
wp *= 3.0f;
|
||||
}
|
||||
|
||||
if (ws > 1) ws = 1;
|
||||
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
model->prepareMobModel(mob, wp, ws, a);
|
||||
renderModel(mob, wp, ws, bob, headRot - bodyRot, headRotx, fScale);
|
||||
|
||||
for (int i = 0; i < MAX_ARMOR_LAYERS; i++) {
|
||||
int armorType = prepareArmor(mob, i, a);
|
||||
if (armorType > 0) {
|
||||
armor->prepareMobModel(mob, wp, ws, a);
|
||||
armor->render(mob, wp, ws, bob, headRot - bodyRot, headRotx,
|
||||
fScale, true);
|
||||
if ((armorType & 0xf0) == 16) {
|
||||
prepareSecondPassArmor(mob, i, a);
|
||||
armor->render(mob, wp, ws, bob, headRot - bodyRot, headRotx,
|
||||
fScale, true);
|
||||
}
|
||||
// 4J - added condition here for rendering player as part of the
|
||||
// gui. Avoiding rendering the glint here as it involves using
|
||||
// its own blending, and for gui rendering we are globally
|
||||
// blending to be able to offer user configurable gui opacity.
|
||||
// Note that I really don't know why GL_BLEND is turned off at
|
||||
// the end of the first armour layer anyway, or why alpha
|
||||
// testing is turned on... but we definitely don't want to be
|
||||
// turning blending off during the gui render.
|
||||
if (!entityRenderDispatcher->isGuiRender) {
|
||||
if ((armorType & 0xf) == 0xf) {
|
||||
float time = mob->tickCount + a;
|
||||
bindTexture(&ENCHANT_GLINT_LOCATION);
|
||||
glEnable(GL_BLEND);
|
||||
float br = 0.5f;
|
||||
glColor4f(br, br, br, 1);
|
||||
glDepthFunc(GL_EQUAL);
|
||||
glDepthMask(false);
|
||||
|
||||
for (int j = 0; j < 2; j++) {
|
||||
glDisable(GL_LIGHTING);
|
||||
float brr = 0.76f;
|
||||
glColor4f(0.5f * brr, 0.25f * brr, 0.8f * brr, 1);
|
||||
glBlendFunc(GL_SRC_COLOR, GL_ONE);
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
float uo = time * (0.001f + j * 0.003f) * 20;
|
||||
float ss = 1 / 3.0f;
|
||||
glScalef(ss, ss, ss);
|
||||
glRotatef(30 - (j) * 60.0f, 0, 0, 1);
|
||||
glTranslatef(0, uo, 0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
armor->render(mob, wp, ws, bob, headRot - bodyRot,
|
||||
headRotx, fScale, false);
|
||||
}
|
||||
|
||||
glColor4f(1, 1, 1, 1);
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glDepthMask(true);
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glEnable(GL_LIGHTING);
|
||||
glDisable(GL_BLEND);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
}
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
}
|
||||
}
|
||||
glDepthMask(true);
|
||||
|
||||
additionalRendering(mob, a);
|
||||
float br = mob->getBrightness(a);
|
||||
int overlayColor = getOverlayColor(mob, br, a);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
if (((overlayColor >> 24) & 0xff) > 0 || mob->hurtTime > 0 ||
|
||||
mob->deathTime > 0) {
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDepthFunc(GL_EQUAL);
|
||||
|
||||
// 4J - changed these renders to not use the compiled version of
|
||||
// their models, because otherwise the render states set about (in
|
||||
// particular the depth & alpha test) don't work with our command
|
||||
// buffer versions
|
||||
if (mob->hurtTime > 0 || mob->deathTime > 0) {
|
||||
glColor4f(br, 0, 0, 0.4f);
|
||||
model->render(mob, wp, ws, bob, headRot - bodyRot, headRotx,
|
||||
fScale, false);
|
||||
for (int i = 0; i < MAX_ARMOR_LAYERS; i++) {
|
||||
if (prepareArmorOverlay(mob, i, a) >= 0) {
|
||||
glColor4f(br, 0, 0, 0.4f);
|
||||
armor->render(mob, wp, ws, bob, headRot - bodyRot,
|
||||
headRotx, fScale, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (((overlayColor >> 24) & 0xff) > 0) {
|
||||
float r = ((overlayColor >> 16) & 0xff) / 255.0f;
|
||||
float g = ((overlayColor >> 8) & 0xff) / 255.0f;
|
||||
float b = ((overlayColor) & 0xff) / 255.0f;
|
||||
float aa = ((overlayColor >> 24) & 0xff) / 255.0f;
|
||||
glColor4f(r, g, b, aa);
|
||||
model->render(mob, wp, ws, bob, headRot - bodyRot, headRotx,
|
||||
fScale, false);
|
||||
for (int i = 0; i < MAX_ARMOR_LAYERS; i++) {
|
||||
if (prepareArmorOverlay(mob, i, a) >= 0) {
|
||||
glColor4f(r, g, b, aa);
|
||||
armor->render(mob, wp, ws, bob, headRot - bodyRot,
|
||||
headRotx, fScale, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
glDisable(GL_RESCALE_NORMAL);
|
||||
}
|
||||
/* catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
MemSect(31);
|
||||
renderName(mob, x, y, z);
|
||||
MemSect(0);
|
||||
}
|
||||
|
||||
void LivingEntityRenderer::renderModel(std::shared_ptr<LivingEntity> mob,
|
||||
float wp, float ws, float bob,
|
||||
float headRotMinusBodyRot,
|
||||
float headRotx, float scale) {
|
||||
bindTexture(mob);
|
||||
if (!mob->isInvisible()) {
|
||||
model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale,
|
||||
true);
|
||||
} else if (!mob->isInvisibleTo(std::dynamic_pointer_cast<Player>(
|
||||
Minecraft::GetInstance()->player))) {
|
||||
glPushMatrix();
|
||||
glColor4f(1, 1, 1, 0.15f);
|
||||
glDepthMask(false);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glAlphaFunc(GL_GREATER, 1.0f / 255.0f);
|
||||
model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale,
|
||||
true);
|
||||
glDisable(GL_BLEND);
|
||||
glAlphaFunc(GL_GREATER, .1f);
|
||||
glPopMatrix();
|
||||
glDepthMask(true);
|
||||
} else {
|
||||
model->setupAnim(wp, ws, bob, headRotMinusBodyRot, headRotx, scale,
|
||||
mob);
|
||||
}
|
||||
}
|
||||
|
||||
void LivingEntityRenderer::setupPosition(std::shared_ptr<LivingEntity> mob,
|
||||
double x, double y, double z) {
|
||||
glTranslatef((float)x, (float)y, (float)z);
|
||||
}
|
||||
|
||||
void LivingEntityRenderer::setupRotations(std::shared_ptr<LivingEntity> mob,
|
||||
float bob, float bodyRot, float a) {
|
||||
glRotatef(180 - bodyRot, 0, 1, 0);
|
||||
if (mob->deathTime > 0) {
|
||||
float fall = (mob->deathTime + a - 1) / 20.0f * 1.6f;
|
||||
fall = sqrt(fall);
|
||||
if (fall > 1) fall = 1;
|
||||
glRotatef(fall * getFlipDegrees(mob), 0, 0, 1);
|
||||
} else {
|
||||
std::wstring name = mob->getAName();
|
||||
if (name == L"Dinnerbone" || name == L"Grumm") {
|
||||
if (!mob->instanceof(eTYPE_PLAYER) ||
|
||||
!std::dynamic_pointer_cast<Player>(mob)->isCapeHidden()) {
|
||||
glTranslatef(0, mob->bbHeight + 0.1f, 0);
|
||||
glRotatef(180, 0, 0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float LivingEntityRenderer::getAttackAnim(std::shared_ptr<LivingEntity> mob,
|
||||
float a) {
|
||||
return mob->getAttackAnim(a);
|
||||
}
|
||||
|
||||
float LivingEntityRenderer::getBob(std::shared_ptr<LivingEntity> mob, float a) {
|
||||
return (mob->tickCount + a);
|
||||
}
|
||||
|
||||
void LivingEntityRenderer::additionalRendering(
|
||||
std::shared_ptr<LivingEntity> mob, float a) {}
|
||||
|
||||
void LivingEntityRenderer::renderArrows(std::shared_ptr<LivingEntity> mob,
|
||||
float a) {
|
||||
int arrowCount = mob->getArrowCount();
|
||||
if (arrowCount > 0) {
|
||||
std::shared_ptr<Entity> arrow = std::shared_ptr<Entity>(
|
||||
new Arrow(mob->level, mob->x, mob->y, mob->z));
|
||||
Random random = Random(mob->entityId);
|
||||
Lighting::turnOff();
|
||||
for (int i = 0; i < arrowCount; i++) {
|
||||
glPushMatrix();
|
||||
ModelPart* modelPart = model->getRandomModelPart(random);
|
||||
Cube* cube =
|
||||
modelPart->cubes[random.nextInt(modelPart->cubes.size())];
|
||||
modelPart->translateTo(1 / 16.0f);
|
||||
float xd = random.nextFloat();
|
||||
float yd = random.nextFloat();
|
||||
float zd = random.nextFloat();
|
||||
float xo = (cube->x0 + (cube->x1 - cube->x0) * xd) / 16.0f;
|
||||
float yo = (cube->y0 + (cube->y1 - cube->y0) * yd) / 16.0f;
|
||||
float zo = (cube->z0 + (cube->z1 - cube->z0) * zd) / 16.0f;
|
||||
glTranslatef(xo, yo, zo);
|
||||
xd = xd * 2 - 1;
|
||||
yd = yd * 2 - 1;
|
||||
zd = zd * 2 - 1;
|
||||
if (true) {
|
||||
xd *= -1;
|
||||
yd *= -1;
|
||||
zd *= -1;
|
||||
}
|
||||
float sd = (float)sqrt(xd * xd + zd * zd);
|
||||
arrow->yRotO = arrow->yRot = (float)(atan2(xd, zd) * 180 / PI);
|
||||
arrow->xRotO = arrow->xRot = (float)(atan2(yd, sd) * 180 / PI);
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
double z = 0;
|
||||
float yRot = 0;
|
||||
entityRenderDispatcher->render(arrow, x, y, z, yRot, a);
|
||||
glPopMatrix();
|
||||
}
|
||||
Lighting::turnOn();
|
||||
}
|
||||
}
|
||||
|
||||
int LivingEntityRenderer::prepareArmorOverlay(std::shared_ptr<LivingEntity> mob,
|
||||
int layer, float a) {
|
||||
return prepareArmor(mob, layer, a);
|
||||
}
|
||||
|
||||
int LivingEntityRenderer::prepareArmor(std::shared_ptr<LivingEntity> mob,
|
||||
int layer, float a) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void LivingEntityRenderer::prepareSecondPassArmor(
|
||||
std::shared_ptr<LivingEntity> mob, int layer, float a) {}
|
||||
|
||||
float LivingEntityRenderer::getFlipDegrees(std::shared_ptr<LivingEntity> mob) {
|
||||
return 90;
|
||||
}
|
||||
|
||||
int LivingEntityRenderer::getOverlayColor(std::shared_ptr<LivingEntity> mob,
|
||||
float br, float a) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void LivingEntityRenderer::scale(std::shared_ptr<LivingEntity> mob, float a) {}
|
||||
|
||||
void LivingEntityRenderer::renderName(std::shared_ptr<LivingEntity> mob,
|
||||
double x, double y, double z) {
|
||||
if (shouldShowName(mob) || Minecraft::renderDebug()) {
|
||||
float size = 1.60f;
|
||||
float s = 1 / 60.0f * size;
|
||||
double dist = mob->distanceToSqr(entityRenderDispatcher->cameraEntity);
|
||||
|
||||
float maxDist = mob->isSneaking() ? 32 : 64;
|
||||
|
||||
if (dist < maxDist * maxDist) {
|
||||
std::wstring msg = mob->getDisplayName();
|
||||
|
||||
if (!msg.empty()) {
|
||||
if (mob->isSneaking()) {
|
||||
if (app.GetGameSettings(eGameSetting_DisplayHUD) == 0) {
|
||||
// 4J-PB - turn off gamertag render
|
||||
return;
|
||||
}
|
||||
|
||||
if (app.GetGameHostOption(eGameHostOption_Gamertags) == 0) {
|
||||
// turn off gamertags if the host has set them off
|
||||
return;
|
||||
}
|
||||
|
||||
Font* font = getFont();
|
||||
glPushMatrix();
|
||||
glTranslatef((float)x + 0, (float)y + mob->bbHeight + 0.5f,
|
||||
(float)z);
|
||||
glNormal3f(0, 1, 0);
|
||||
|
||||
glRotatef(-entityRenderDispatcher->playerRotY, 0, 1, 0);
|
||||
glRotatef(entityRenderDispatcher->playerRotX, 1, 0, 0);
|
||||
|
||||
glScalef(-s, -s, s);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
glTranslatef(0, 0.25f / s, 0);
|
||||
glDepthMask(false);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
t->begin();
|
||||
int w = font->width(msg) / 2;
|
||||
t->color(0.f, 0.f, 0.f, 0.25f);
|
||||
t->vertex(-w - 1, -1, 0);
|
||||
t->vertex(-w - 1, +8, 0);
|
||||
t->vertex(+w + 1, +8, 0);
|
||||
t->vertex(+w + 1, -1, 0);
|
||||
t->end();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glDepthMask(true);
|
||||
font->draw(msg, -font->width(msg) / 2, 0, 0x20ffffff);
|
||||
glEnable(GL_LIGHTING);
|
||||
glDisable(GL_BLEND);
|
||||
glColor4f(1, 1, 1, 1);
|
||||
glPopMatrix();
|
||||
} else {
|
||||
renderNameTags(mob, x, y, z, msg, s, dist);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool LivingEntityRenderer::shouldShowName(std::shared_ptr<LivingEntity> mob) {
|
||||
return Minecraft::renderNames() &&
|
||||
mob != entityRenderDispatcher->cameraEntity &&
|
||||
!mob->isInvisibleTo(Minecraft::GetInstance()->player) &&
|
||||
mob->rider.lock() == NULL;
|
||||
}
|
||||
|
||||
void LivingEntityRenderer::renderNameTags(std::shared_ptr<LivingEntity> mob,
|
||||
double x, double y, double z,
|
||||
const std::wstring& msg, float scale,
|
||||
double dist) {
|
||||
if (mob->isSleeping()) {
|
||||
renderNameTag(mob, msg, x, y - 1.5f, z, 64);
|
||||
} else {
|
||||
renderNameTag(mob, msg, x, y, z, 64);
|
||||
}
|
||||
}
|
||||
|
||||
// 4J Added parameter for color here so that we can colour players names
|
||||
void LivingEntityRenderer::renderNameTag(std::shared_ptr<LivingEntity> mob,
|
||||
const std::wstring& name, double x,
|
||||
double y, double z, int maxDist,
|
||||
int color /*= 0xff000000*/) {
|
||||
if (app.GetGameSettings(eGameSetting_DisplayHUD) == 0) {
|
||||
// 4J-PB - turn off gamertag render
|
||||
return;
|
||||
}
|
||||
|
||||
if (app.GetGameHostOption(eGameHostOption_Gamertags) == 0) {
|
||||
// turn off gamertags if the host has set them off
|
||||
return;
|
||||
}
|
||||
|
||||
float dist = mob->distanceTo(entityRenderDispatcher->cameraEntity);
|
||||
|
||||
if (dist > maxDist) {
|
||||
return;
|
||||
}
|
||||
|
||||
Font* font = getFont();
|
||||
|
||||
float size = 1.60f;
|
||||
float s = 1 / 60.0f * size;
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef((float)x + 0, (float)y + 2.3f, (float)z);
|
||||
glNormal3f(0, 1, 0);
|
||||
|
||||
glRotatef(-this->entityRenderDispatcher->playerRotY, 0, 1, 0);
|
||||
glRotatef(this->entityRenderDispatcher->playerRotX, 1, 0, 0);
|
||||
|
||||
glScalef(-s, -s, s);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
// 4J Stu - If it's beyond readable distance, then just render a coloured
|
||||
// box
|
||||
int readableDist = PLAYER_NAME_READABLE_FULLSCREEN;
|
||||
if (!RenderManager.IsHiDef()) {
|
||||
readableDist = PLAYER_NAME_READABLE_DISTANCE_SD;
|
||||
} else if (app.GetLocalPlayerCount() > 2) {
|
||||
readableDist = PLAYER_NAME_READABLE_DISTANCE_SPLITSCREEN;
|
||||
}
|
||||
|
||||
float textOpacity = 1.0f;
|
||||
if (dist >= readableDist) {
|
||||
int diff = dist - readableDist;
|
||||
|
||||
textOpacity /= (diff / 2);
|
||||
|
||||
if (diff > readableDist) textOpacity = 0.0f;
|
||||
}
|
||||
|
||||
if (textOpacity < 0.0f) textOpacity = 0.0f;
|
||||
if (textOpacity > 1.0f) textOpacity = 1.0f;
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
|
||||
int offs = 0;
|
||||
|
||||
std::wstring playerName;
|
||||
WCHAR wchName[2];
|
||||
|
||||
if (mob->instanceof(eTYPE_PLAYER)) {
|
||||
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(mob);
|
||||
|
||||
if (app.isXuidDeadmau5(player->getXuid())) offs = -10;
|
||||
|
||||
#if defined(__PS3__) || defined(__ORBIS__)
|
||||
// Check we have all the font characters for this player name
|
||||
switch (player->GetPlayerNameValidState()) {
|
||||
case Player::ePlayerNameValid_NotSet:
|
||||
if (font->AllCharactersValid(name)) {
|
||||
playerName = name;
|
||||
player->SetPlayerNameValidState(true);
|
||||
} else {
|
||||
memset(wchName, 0, sizeof(WCHAR) * 2);
|
||||
swprintf(wchName, 2, L"%d", player->getPlayerIndex() + 1);
|
||||
playerName = wchName;
|
||||
player->SetPlayerNameValidState(false);
|
||||
}
|
||||
break;
|
||||
case Player::ePlayerNameValid_True:
|
||||
playerName = name;
|
||||
break;
|
||||
case Player::ePlayerNameValid_False:
|
||||
memset(wchName, 0, sizeof(WCHAR) * 2);
|
||||
swprintf(wchName, 2, L"%d", player->getPlayerIndex() + 1);
|
||||
playerName = wchName;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
playerName = name;
|
||||
#endif
|
||||
} else {
|
||||
playerName = name;
|
||||
}
|
||||
|
||||
if (textOpacity > 0.0f) {
|
||||
glColor4f(1.0f, 1.0f, 1.0f, textOpacity);
|
||||
|
||||
glDepthMask(false);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
t->begin();
|
||||
int w = font->width(playerName) / 2;
|
||||
|
||||
if (textOpacity < 1.0f) {
|
||||
t->color(color, 255 * textOpacity);
|
||||
} else {
|
||||
t->color(0.0f, 0.0f, 0.0f, 0.25f);
|
||||
}
|
||||
t->vertex((float)(-w - 1), (float)(-1 + offs), (float)(0));
|
||||
t->vertex((float)(-w - 1), (float)(+8 + offs + 1), (float)(0));
|
||||
t->vertex((float)(+w + 1), (float)(+8 + offs + 1), (float)(0));
|
||||
t->vertex((float)(+w + 1), (float)(-1 + offs), (float)(0));
|
||||
t->end();
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(true);
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
glLineWidth(2.0f);
|
||||
t->begin(GL_LINE_STRIP);
|
||||
t->color(color, 255 * textOpacity);
|
||||
t->vertex((float)(-w - 1), (float)(-1 + offs), (float)(0));
|
||||
t->vertex((float)(-w - 1), (float)(+8 + offs + 1), (float)(0));
|
||||
t->vertex((float)(+w + 1), (float)(+8 + offs + 1), (float)(0));
|
||||
t->vertex((float)(+w + 1), (float)(-1 + offs), (float)(0));
|
||||
t->vertex((float)(-w - 1), (float)(-1 + offs), (float)(0));
|
||||
t->end();
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glDepthMask(false);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
font->draw(playerName, -font->width(playerName) / 2, offs, 0x20ffffff);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
glDepthMask(true);
|
||||
}
|
||||
|
||||
if (textOpacity < 1.0f) {
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
t->begin();
|
||||
int w = font->width(playerName) / 2;
|
||||
t->color(color, 255);
|
||||
t->vertex((float)(-w - 1), (float)(-1 + offs), (float)(0));
|
||||
t->vertex((float)(-w - 1), (float)(+8 + offs), (float)(0));
|
||||
t->vertex((float)(+w + 1), (float)(+8 + offs), (float)(0));
|
||||
t->vertex((float)(+w + 1), (float)(-1 + offs), (float)(0));
|
||||
t->end();
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glTranslatef(0.0f, 0.0f, -0.04f);
|
||||
}
|
||||
|
||||
if (textOpacity > 0.0f) {
|
||||
int textColor = (((int)(textOpacity * 255) << 24) | 0xffffff);
|
||||
font->draw(playerName, -font->width(playerName) / 2, offs, textColor);
|
||||
}
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
glDisable(GL_BLEND);
|
||||
glColor4f(1, 1, 1, 1);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
#pragma once
|
||||
#include "../../Textures/ResourceLocation.h"
|
||||
#include "EntityRenderer.h"
|
||||
#include "../../../Minecraft.World/Entities/LivingEntity.h"
|
||||
|
||||
class LivingEntity;
|
||||
|
||||
class LivingEntityRenderer : public EntityRenderer {
|
||||
static const int PLAYER_NAME_READABLE_FULLSCREEN = 16;
|
||||
static const int PLAYER_NAME_READABLE_DISTANCE_SPLITSCREEN = 8;
|
||||
static const int PLAYER_NAME_READABLE_DISTANCE_SD = 8;
|
||||
|
||||
static ResourceLocation ENCHANT_GLINT_LOCATION;
|
||||
static int MAX_ARMOR_LAYERS;
|
||||
|
||||
protected:
|
||||
// Model *model; // 4J Stu - This shadows the one in EntityRenderer
|
||||
Model* armor;
|
||||
|
||||
public:
|
||||
LivingEntityRenderer(Model* model, float shadow);
|
||||
virtual void render(std::shared_ptr<Entity> mob, double x, double y,
|
||||
double z, float rot, float a);
|
||||
virtual void setArmor(Model* armor);
|
||||
|
||||
private:
|
||||
float rotlerp(float from, float to, float a);
|
||||
|
||||
protected:
|
||||
virtual void renderModel(std::shared_ptr<LivingEntity> mob, float wp,
|
||||
float ws, float bob, float headRotMinusBodyRot,
|
||||
float headRotx, float scale);
|
||||
virtual void setupPosition(std::shared_ptr<LivingEntity> mob, double x,
|
||||
double y, double z);
|
||||
virtual void setupRotations(std::shared_ptr<LivingEntity> mob, float bob,
|
||||
float bodyRot, float a);
|
||||
virtual float getAttackAnim(std::shared_ptr<LivingEntity> mob, float a);
|
||||
virtual float getBob(std::shared_ptr<LivingEntity> mob, float a);
|
||||
virtual void additionalRendering(std::shared_ptr<LivingEntity> mob,
|
||||
float a);
|
||||
virtual void renderArrows(std::shared_ptr<LivingEntity> mob, float a);
|
||||
virtual int prepareArmorOverlay(std::shared_ptr<LivingEntity> mob,
|
||||
int layer, float a);
|
||||
virtual int prepareArmor(std::shared_ptr<LivingEntity> mob, int layer,
|
||||
float a);
|
||||
virtual void prepareSecondPassArmor(std::shared_ptr<LivingEntity> mob,
|
||||
int layer, float a);
|
||||
virtual float getFlipDegrees(std::shared_ptr<LivingEntity> mob);
|
||||
virtual int getOverlayColor(std::shared_ptr<LivingEntity> mob, float br,
|
||||
float a);
|
||||
virtual void scale(std::shared_ptr<LivingEntity> mob, float a);
|
||||
virtual void renderName(std::shared_ptr<LivingEntity> mob, double x,
|
||||
double y, double z);
|
||||
virtual bool shouldShowName(std::shared_ptr<LivingEntity> mob);
|
||||
virtual void renderNameTags(std::shared_ptr<LivingEntity> mob, double x,
|
||||
double y, double z, const std::wstring& msg,
|
||||
float scale, double dist);
|
||||
virtual void renderNameTag(std::shared_ptr<LivingEntity> mob,
|
||||
const std::wstring& name, double x, double y,
|
||||
double z, int maxDist, int color = 0xff000000);
|
||||
};
|
||||
|
|
@ -1,12 +1,16 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "MinecartRenderer.h"
|
||||
#include "../Models/MinecartModel.h"
|
||||
#include "../../Textures/TextureAtlas.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.item.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.level.tile.h"
|
||||
|
||||
ResourceLocation MinecartRenderer::MINECART_LOCATION(TN_ITEM_CART);
|
||||
|
||||
MinecartRenderer::MinecartRenderer() {
|
||||
this->shadowRadius = 0.5f;
|
||||
model = new MinecartModel();
|
||||
renderer = new TileRenderer();
|
||||
}
|
||||
|
||||
void MinecartRenderer::render(std::shared_ptr<Entity> _cart, double x, double y,
|
||||
|
|
@ -68,32 +72,76 @@ void MinecartRenderer::render(std::shared_ptr<Entity> _cart, double x, double y,
|
|||
0);
|
||||
}
|
||||
|
||||
if (cart->type != Minecart::RIDEABLE) {
|
||||
glPushMatrix();
|
||||
bindTexture(TN_TERRAIN); // 4J was L"/terrain.png"
|
||||
float ss = 12 / 16.0f;
|
||||
glScalef(ss, ss, ss);
|
||||
int yOffset = cart->getDisplayOffset();
|
||||
Tile* tile = cart->getDisplayTile();
|
||||
int tileData = cart->getDisplayData();
|
||||
|
||||
if (tile != NULL) {
|
||||
glPushMatrix();
|
||||
|
||||
bindTexture(&TextureAtlas::LOCATION_BLOCKS);
|
||||
float ss = 12 / 16.0f;
|
||||
|
||||
glScalef(ss, ss, ss);
|
||||
glTranslatef(0 / 16.f, yOffset / 16.f, 0 / 16.f);
|
||||
renderMinecartContents(cart, a, tile, tileData);
|
||||
|
||||
// 4J - changes here brought forward from 1.2.3
|
||||
if (cart->type == Minecart::CHEST) {
|
||||
glTranslatef(0 / 16.0f, 8 / 16.0f, 0 / 16.0f);
|
||||
TileRenderer* tr = new TileRenderer();
|
||||
tr->renderTile(Tile::chest, 0, cart->getBrightness(a));
|
||||
delete tr;
|
||||
} else if (cart->type == Minecart::FURNACE) {
|
||||
glTranslatef(0, 6 / 16.0f, 0);
|
||||
TileRenderer* tr = new TileRenderer();
|
||||
tr->renderTile(Tile::furnace, 0, cart->getBrightness(a));
|
||||
delete tr;
|
||||
}
|
||||
glPopMatrix();
|
||||
glColor4f(1, 1, 1, 1);
|
||||
bindTexture(cart);
|
||||
}
|
||||
|
||||
bindTexture(TN_ITEM_CART); // 4J - was L"/item/cart.png"
|
||||
glScalef(-1, -1, 1);
|
||||
model->render(cart, 0, 0, -0.1f, 0, 0, 1 / 16.0f, true);
|
||||
glPopMatrix();
|
||||
|
||||
/*
|
||||
if (cart->type != Minecart::RIDEABLE)
|
||||
{
|
||||
glPushMatrix();
|
||||
bindTexture(TN_TERRAIN); // 4J was L"/terrain.png"
|
||||
float ss = 12 / 16.0f;
|
||||
glScalef(ss, ss, ss);
|
||||
|
||||
// 4J - changes here brought forward from 1.2.3
|
||||
if (cart->type == Minecart::CHEST)
|
||||
{
|
||||
glTranslatef(0 / 16.0f, 8 / 16.0f, 0 / 16.0f);
|
||||
TileRenderer *tr = new TileRenderer();
|
||||
tr->renderTile(Tile::chest, 0, cart->getBrightness(a));
|
||||
delete tr;
|
||||
}
|
||||
else if (cart->type == Minecart::FURNACE)
|
||||
{
|
||||
glTranslatef(0, 6 / 16.0f, 0);
|
||||
TileRenderer *tr = new TileRenderer();
|
||||
tr->renderTile(Tile::furnace, 0, cart->getBrightness(a));
|
||||
delete tr;
|
||||
}
|
||||
glPopMatrix();
|
||||
glColor4f(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
bindTexture(TN_ITEM_CART); // 4J - was L"/item/cart.png"
|
||||
glScalef(-1, -1, 1);
|
||||
// model.render(0, 0, cart->getLootContent() * 7.1f - 0.1f, 0, 0, 1 /
|
||||
// 16.0f);
|
||||
model->render(cart, 0, 0, -0.1f, 0, 0, 1 / 16.0f, true);
|
||||
glPopMatrix();
|
||||
*/
|
||||
}
|
||||
|
||||
ResourceLocation* MinecartRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &MINECART_LOCATION;
|
||||
}
|
||||
|
||||
void MinecartRenderer::renderMinecartContents(std::shared_ptr<Minecart> cart,
|
||||
float a, Tile* tile,
|
||||
int tileData) {
|
||||
float brightness = cart->getBrightness(a);
|
||||
|
||||
glPushMatrix();
|
||||
renderer->renderTile(tile, tileData, brightness);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
|
@ -1,12 +1,23 @@
|
|||
#pragma once
|
||||
#include "EntityRenderer.h"
|
||||
|
||||
class Minecart;
|
||||
|
||||
class MinecartRenderer : public EntityRenderer {
|
||||
private:
|
||||
static ResourceLocation MINECART_LOCATION;
|
||||
|
||||
protected:
|
||||
Model* model;
|
||||
TileRenderer* renderer;
|
||||
|
||||
public:
|
||||
MinecartRenderer();
|
||||
void render(std::shared_ptr<Entity> _cart, double x, double y, double z,
|
||||
float rot, float a);
|
||||
virtual void render(std::shared_ptr<Entity> _cart, double x, double y,
|
||||
double z, float rot, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
|
||||
protected:
|
||||
virtual void renderMinecartContents(std::shared_ptr<Minecart> cart, float a,
|
||||
Tile* tile, int tileData);
|
||||
};
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "MinecartSpawnerRenderer.h"
|
||||
#include "../../../Minecraft.World/Blocks/Tile.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.item.h"
|
||||
#include "MobSpawnerRenderer.h"
|
||||
|
||||
void MinecartSpawnerRenderer::renderMinecartContents(
|
||||
std::shared_ptr<MinecartSpawner> cart, float a, Tile* tile, int tileData) {
|
||||
MinecartRenderer::renderMinecartContents(cart, a, tile, tileData);
|
||||
|
||||
if (tile == Tile::mobSpawner) {
|
||||
MobSpawnerRenderer::render(cart->getSpawner(), cart->x, cart->y,
|
||||
cart->z, a);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
#pragma once
|
||||
#include "MinecartRenderer.h"
|
||||
|
||||
class MinecartSpawner;
|
||||
|
||||
class MinecartSpawnerRenderer : public MinecartRenderer {
|
||||
protected:
|
||||
void renderMinecartContents(std::shared_ptr<MinecartSpawner> cart, float a,
|
||||
Tile* tile, int tileData);
|
||||
};
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "MobRenderer.h"
|
||||
#include "LivingEntityRenderer.h"
|
||||
#include "../../Player/MultiPlayerLocalPlayer.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.player.h"
|
||||
|
|
@ -8,475 +9,139 @@
|
|||
#include "../../../Minecraft.World/Util/Mth.h"
|
||||
#include "EntityRenderDispatcher.h"
|
||||
|
||||
MobRenderer::MobRenderer(Model* model, float shadow) : EntityRenderer() {
|
||||
this->model = model;
|
||||
this->shadowRadius = shadow;
|
||||
|
||||
this->armor = NULL;
|
||||
}
|
||||
|
||||
void MobRenderer::setArmor(Model* armor) { this->armor = armor; }
|
||||
|
||||
float MobRenderer::rotlerp(float from, float to, float a) {
|
||||
float diff = to - from;
|
||||
while (diff < -180) diff += 360;
|
||||
while (diff >= 180) diff -= 360;
|
||||
return from + a * diff;
|
||||
}
|
||||
MobRenderer::MobRenderer(Model* model, float shadow)
|
||||
: LivingEntityRenderer(model, shadow) {}
|
||||
|
||||
void MobRenderer::render(std::shared_ptr<Entity> _mob, double x, double y,
|
||||
double z, float rot, float a) {
|
||||
// 4J - added - this used to use generics so the input parameter could be a
|
||||
// mob (or derived type), but we aren't able to do that so dynamically
|
||||
// casting to get the more specific type here.
|
||||
std::shared_ptr<Mob> mob = std::dynamic_pointer_cast<Mob>(_mob);
|
||||
glPushMatrix();
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
model->attackTime = getAttackAnim(mob, a);
|
||||
if (armor != NULL) armor->attackTime = model->attackTime;
|
||||
model->riding = mob->isRiding();
|
||||
if (armor != NULL) armor->riding = model->riding;
|
||||
model->young = mob->isBaby();
|
||||
if (armor != NULL) armor->young = model->young;
|
||||
|
||||
// 4J - removed try/catch
|
||||
// try
|
||||
// {
|
||||
float bodyRot = rotlerp(mob->yBodyRotO, mob->yBodyRot, a);
|
||||
float headRot = rotlerp(mob->yHeadRotO, mob->yHeadRot, a);
|
||||
|
||||
if (mob->isRiding() && std::dynamic_pointer_cast<Mob>(mob->riding)) {
|
||||
std::shared_ptr<Mob> riding =
|
||||
std::dynamic_pointer_cast<Mob>(mob->riding);
|
||||
bodyRot = rotlerp(riding->yBodyRotO, riding->yBodyRot, a);
|
||||
|
||||
float headDiff = Mth::wrapDegrees(headRot - bodyRot);
|
||||
if (headDiff < -85) headDiff = -85;
|
||||
if (headDiff >= 85) headDiff = +85;
|
||||
bodyRot = headRot - headDiff;
|
||||
if (headDiff * headDiff > 50 * 50) {
|
||||
bodyRot += headDiff * 0.2f;
|
||||
}
|
||||
}
|
||||
|
||||
float headRotx = (mob->xRotO + (mob->xRot - mob->xRotO) * a);
|
||||
|
||||
setupPosition(mob, x, y, z);
|
||||
|
||||
float bob = getBob(mob, a);
|
||||
setupRotations(mob, bob, bodyRot, a);
|
||||
|
||||
float _scale = 1 / 16.0f;
|
||||
glEnable(GL_RESCALE_NORMAL);
|
||||
glScalef(-1, -1, 1);
|
||||
|
||||
scale(mob, a);
|
||||
glTranslatef(0, -24 * _scale - 0.125f / 16.0f, 0);
|
||||
|
||||
float ws =
|
||||
mob->walkAnimSpeedO + (mob->walkAnimSpeed - mob->walkAnimSpeedO) * a;
|
||||
float wp = mob->walkAnimPos - mob->walkAnimSpeed * (1 - a);
|
||||
if (mob->isBaby()) {
|
||||
wp *= 3.0f;
|
||||
}
|
||||
|
||||
if (ws > 1) ws = 1;
|
||||
|
||||
MemSect(31);
|
||||
bindTexture(mob->customTextureUrl, mob->getTexture());
|
||||
MemSect(0);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
|
||||
model->prepareMobModel(mob, wp, ws, a);
|
||||
renderModel(mob, wp, ws, bob, headRot - bodyRot, headRotx, _scale);
|
||||
for (int i = 0; i < MAX_ARMOR_LAYERS; i++) {
|
||||
int armorType = prepareArmor(mob, i, a);
|
||||
if (armorType > 0) {
|
||||
armor->prepareMobModel(mob, wp, ws, a);
|
||||
armor->render(mob, wp, ws, bob, headRot - bodyRot, headRotx, _scale,
|
||||
true);
|
||||
if ((armorType & 0xf0) == 16) {
|
||||
prepareSecondPassArmor(mob, i, a);
|
||||
armor->render(mob, wp, ws, bob, headRot - bodyRot, headRotx,
|
||||
_scale, true);
|
||||
}
|
||||
// 4J - added condition here for rendering player as part of the
|
||||
// gui. Avoiding rendering the glint here as it involves using its
|
||||
// own blending, and for gui rendering we are globally blending to
|
||||
// be able to offer user configurable gui opacity. Note that I
|
||||
// really don't know why GL_BLEND is turned off at the end of the
|
||||
// first armour layer anyway, or why alpha testing is turned on...
|
||||
// but we definitely don't want to be turning blending off during
|
||||
// the gui render.
|
||||
if (!entityRenderDispatcher->isGuiRender) {
|
||||
if ((armorType & 0xf) ==
|
||||
0xf) // MGH - fix for missing enchantment glow
|
||||
{
|
||||
float time = mob->tickCount + a;
|
||||
bindTexture(
|
||||
TN__BLUR__MISC_GLINT); // 4J was
|
||||
// "%blur%/misc/glint.png"
|
||||
glEnable(GL_BLEND);
|
||||
float br = 0.5f;
|
||||
glColor4f(br, br, br, 1);
|
||||
glDepthFunc(GL_EQUAL);
|
||||
glDepthMask(false);
|
||||
|
||||
for (int j = 0; j < 2; j++) {
|
||||
glDisable(GL_LIGHTING);
|
||||
float brr = 0.76f;
|
||||
glColor4f(0.5f * brr, 0.25f * brr, 0.8f * brr, 1);
|
||||
glBlendFunc(GL_SRC_COLOR, GL_ONE);
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
float uo = time * (0.001f + j * 0.003f) * 20;
|
||||
float ss = 1 / 3.0f;
|
||||
glScalef(ss, ss, ss);
|
||||
glRotatef(30 - (j) * 60.0f, 0, 0, 1);
|
||||
glTranslatef(0, uo, 0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
armor->render(mob, wp, ws, bob, headRot - bodyRot,
|
||||
headRotx, _scale, false);
|
||||
}
|
||||
|
||||
glColor4f(1, 1, 1, 1);
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glDepthMask(true);
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glEnable(GL_LIGHTING);
|
||||
glDisable(GL_BLEND);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
}
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
glDepthMask(true);
|
||||
|
||||
additionalRendering(mob, a);
|
||||
float br = mob->getBrightness(a);
|
||||
int overlayColor = getOverlayColor(mob, br, a);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
if (((overlayColor >> 24) & 0xff) > 0 || mob->hurtTime > 0 ||
|
||||
mob->deathTime > 0) {
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDepthFunc(GL_EQUAL);
|
||||
|
||||
// 4J - changed these renders to not use the compiled version of their
|
||||
// models, because otherwise the render states set about (in particular
|
||||
// the depth & alpha test) don't work with our command buffer versions
|
||||
if (mob->hurtTime > 0 || mob->deathTime > 0) {
|
||||
glColor4f(br, 0, 0, 0.4f);
|
||||
model->render(mob, wp, ws, bob, headRot - bodyRot, headRotx, _scale,
|
||||
false);
|
||||
for (int i = 0; i < MAX_ARMOR_LAYERS; i++) {
|
||||
if (prepareArmorOverlay(mob, i, a) >= 0) {
|
||||
glColor4f(br, 0, 0, 0.4f);
|
||||
armor->render(mob, wp, ws, bob, headRot - bodyRot, headRotx,
|
||||
_scale, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (((overlayColor >> 24) & 0xff) > 0) {
|
||||
float r = ((overlayColor >> 16) & 0xff) / 255.0f;
|
||||
float g = ((overlayColor >> 8) & 0xff) / 255.0f;
|
||||
float b = ((overlayColor) & 0xff) / 255.0f;
|
||||
float aa = ((overlayColor >> 24) & 0xff) / 255.0f;
|
||||
glColor4f(r, g, b, aa);
|
||||
model->render(mob, wp, ws, bob, headRot - bodyRot, headRotx, _scale,
|
||||
false);
|
||||
for (int i = 0; i < MAX_ARMOR_LAYERS; i++) {
|
||||
if (prepareArmorOverlay(mob, i, a) >= 0) {
|
||||
glColor4f(r, g, b, aa);
|
||||
armor->render(mob, wp, ws, bob, headRot - bodyRot, headRotx,
|
||||
_scale, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
glDisable(GL_RESCALE_NORMAL);
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// // System.out.println("Failed: " + modelNames[model]);
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
MemSect(31);
|
||||
renderName(mob, x, y, z);
|
||||
MemSect(0);
|
||||
LivingEntityRenderer::render(mob, x, y, z, rot, a);
|
||||
renderLeash(mob, x, y, z, rot, a);
|
||||
}
|
||||
|
||||
void MobRenderer::renderModel(std::shared_ptr<Entity> mob, float wp, float ws,
|
||||
float bob, float headRotMinusBodyRot,
|
||||
float headRotx, float scale) {
|
||||
std::shared_ptr<Player> player =
|
||||
std::dynamic_pointer_cast<Player>(Minecraft::GetInstance()->player);
|
||||
|
||||
bindTexture(mob->customTextureUrl, mob->getTexture());
|
||||
if (!mob->isInvisible()) {
|
||||
model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale,
|
||||
true);
|
||||
} else if (!mob->isInvisibleTo(player)) {
|
||||
glPushMatrix();
|
||||
glColor4f(1, 1, 1, 0.15f);
|
||||
glDepthMask(false);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glAlphaFunc(GL_GREATER, 1.0f / 255.0f);
|
||||
model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale,
|
||||
true);
|
||||
glDisable(GL_BLEND);
|
||||
glAlphaFunc(GL_GREATER, .1f);
|
||||
glPopMatrix();
|
||||
glDepthMask(true);
|
||||
} else {
|
||||
model->setupAnim(wp, ws, bob, headRotMinusBodyRot, headRotx,
|
||||
scale); //, mob);
|
||||
}
|
||||
bool MobRenderer::shouldShowName(std::shared_ptr<LivingEntity> mob) {
|
||||
return LivingEntityRenderer::shouldShowName(mob) &&
|
||||
(mob->shouldShowName() ||
|
||||
std::dynamic_pointer_cast<Mob>(mob)->hasCustomName() &&
|
||||
mob == entityRenderDispatcher->crosshairPickMob);
|
||||
}
|
||||
|
||||
void MobRenderer::setupPosition(std::shared_ptr<Mob> mob, double x, double y,
|
||||
double z) {
|
||||
glTranslatef((float)x, (float)y, (float)z);
|
||||
}
|
||||
|
||||
void MobRenderer::setupRotations(std::shared_ptr<Mob> mob, float bob,
|
||||
float bodyRot, float a) {
|
||||
glRotatef(180 - bodyRot, 0, 1, 0);
|
||||
if (mob->deathTime > 0) {
|
||||
float fall = (mob->deathTime + a - 1) / 20.0f * 1.6f;
|
||||
fall = (float)sqrt(fall);
|
||||
if (fall > 1) fall = 1;
|
||||
glRotatef(fall * getFlipDegrees(mob), 0, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
float MobRenderer::getAttackAnim(std::shared_ptr<Mob> mob, float a) {
|
||||
return mob->getAttackAnim(a);
|
||||
}
|
||||
|
||||
float MobRenderer::getBob(std::shared_ptr<Mob> mob, float a) {
|
||||
return (mob->tickCount + a);
|
||||
}
|
||||
|
||||
void MobRenderer::additionalRendering(std::shared_ptr<Mob> mob, float a) {}
|
||||
|
||||
int MobRenderer::prepareArmorOverlay(std::shared_ptr<Mob> mob, int layer,
|
||||
float a) {
|
||||
return prepareArmor(mob, layer, a);
|
||||
}
|
||||
|
||||
int MobRenderer::prepareArmor(std::shared_ptr<Mob> mob, int layer, float a) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void MobRenderer::prepareSecondPassArmor(std::shared_ptr<Mob> mob, int layer,
|
||||
float a) {}
|
||||
|
||||
float MobRenderer::getFlipDegrees(std::shared_ptr<Mob> mob) { return 90; }
|
||||
|
||||
int MobRenderer::getOverlayColor(std::shared_ptr<Mob> mob, float br, float a) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MobRenderer::scale(std::shared_ptr<Mob> mob, float a) {}
|
||||
|
||||
void MobRenderer::renderName(std::shared_ptr<Mob> mob, double x, double y,
|
||||
double z) {
|
||||
if (Minecraft::renderDebug()) {
|
||||
// renderNameTag(mob, _toString<int>(mob->entityId), x, y, z, 64);
|
||||
}
|
||||
}
|
||||
|
||||
// 4J Added parameter for color here so that we can colour players names
|
||||
void MobRenderer::renderNameTag(std::shared_ptr<Mob> mob,
|
||||
const std::wstring& OriginalName, double x,
|
||||
double y, double z, int maxDist,
|
||||
int color /*= 0xffffffff*/) {
|
||||
if (app.GetGameSettings(eGameSetting_DisplayHUD) == 0) {
|
||||
// 4J-PB - turn off gamertag render
|
||||
return;
|
||||
}
|
||||
|
||||
if (app.GetGameHostOption(eGameHostOption_Gamertags) == 0) {
|
||||
// turn off gamertags if the host has set them off
|
||||
return;
|
||||
}
|
||||
|
||||
float dist = mob->distanceTo(entityRenderDispatcher->cameraEntity);
|
||||
|
||||
if (dist > maxDist) {
|
||||
return;
|
||||
}
|
||||
|
||||
Font* font = getFont();
|
||||
|
||||
float size = 1.60f;
|
||||
float s = 1 / 60.0f * size;
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef((float)x + 0, (float)y + 2.3f, (float)z);
|
||||
glNormal3f(0, 1, 0);
|
||||
|
||||
glRotatef(-this->entityRenderDispatcher->playerRotY, 0, 1, 0);
|
||||
glRotatef(this->entityRenderDispatcher->playerRotX, 1, 0, 0);
|
||||
|
||||
glScalef(-s, -s, s);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
// 4J Stu - If it's beyond readable distance, then just render a coloured
|
||||
// box
|
||||
int readableDist = PLAYER_NAME_READABLE_FULLSCREEN;
|
||||
if (!RenderManager.IsHiDef()) {
|
||||
readableDist = PLAYER_NAME_READABLE_DISTANCE_SD;
|
||||
} else if (app.GetLocalPlayerCount() > 2) {
|
||||
readableDist = PLAYER_NAME_READABLE_DISTANCE_SPLITSCREEN;
|
||||
}
|
||||
|
||||
float textOpacity = 1.0f;
|
||||
if (dist >= readableDist) {
|
||||
int diff = dist - readableDist;
|
||||
|
||||
textOpacity /= (diff / 2);
|
||||
|
||||
if (diff > readableDist) textOpacity = 0.0f;
|
||||
}
|
||||
|
||||
if (textOpacity < 0.0f) textOpacity = 0.0f;
|
||||
if (textOpacity > 1.0f) textOpacity = 1.0f;
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
|
||||
int offs = 0;
|
||||
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(mob);
|
||||
if (player != NULL && app.isXuidDeadmau5(player->getXuid())) offs = -10;
|
||||
|
||||
std::wstring playerName;
|
||||
WCHAR wchName[2];
|
||||
|
||||
#if defined(__PS3__) || defined(__ORBIS__)
|
||||
// Check we have all the font characters for this player name
|
||||
switch (player->GetPlayerNameValidState()) {
|
||||
case Player::ePlayerNameValid_NotSet:
|
||||
if (font->AllCharactersValid(OriginalName)) {
|
||||
playerName = OriginalName;
|
||||
player->SetPlayerNameValidState(true);
|
||||
} else {
|
||||
memset(wchName, 0, sizeof(WCHAR) * 2);
|
||||
swprintf(wchName, 2, L"%d", player->getPlayerIndex() + 1);
|
||||
playerName = wchName;
|
||||
player->SetPlayerNameValidState(false);
|
||||
}
|
||||
break;
|
||||
case Player::ePlayerNameValid_True:
|
||||
playerName = OriginalName;
|
||||
break;
|
||||
case Player::ePlayerNameValid_False:
|
||||
memset(wchName, 0, sizeof(WCHAR) * 2);
|
||||
swprintf(wchName, 2, L"%d", player->getPlayerIndex() + 1);
|
||||
playerName = wchName;
|
||||
break;
|
||||
}
|
||||
|
||||
#else
|
||||
playerName = OriginalName;
|
||||
#endif
|
||||
|
||||
if (textOpacity > 0.0f) {
|
||||
glColor4f(1.0f, 1.0f, 1.0f, textOpacity);
|
||||
|
||||
glDepthMask(false);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
t->begin();
|
||||
int w = font->width(playerName) / 2;
|
||||
|
||||
if (textOpacity < 1.0f) {
|
||||
t->color(color, 255 * textOpacity);
|
||||
} else {
|
||||
t->color(0.0f, 0.0f, 0.0f, 0.25f);
|
||||
}
|
||||
t->vertex((float)(-w - 1), (float)(-1 + offs), (float)(0));
|
||||
t->vertex((float)(-w - 1), (float)(+8 + offs + 1), (float)(0));
|
||||
t->vertex((float)(+w + 1), (float)(+8 + offs + 1), (float)(0));
|
||||
t->vertex((float)(+w + 1), (float)(-1 + offs), (float)(0));
|
||||
t->end();
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(true);
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
glLineWidth(2.0f);
|
||||
t->begin(GL_LINE_STRIP);
|
||||
t->color(color, 255 * textOpacity);
|
||||
t->vertex((float)(-w - 1), (float)(-1 + offs), (float)(0));
|
||||
t->vertex((float)(-w - 1), (float)(+8 + offs + 1), (float)(0));
|
||||
t->vertex((float)(+w + 1), (float)(+8 + offs + 1), (float)(0));
|
||||
t->vertex((float)(+w + 1), (float)(-1 + offs), (float)(0));
|
||||
t->vertex((float)(-w - 1), (float)(-1 + offs), (float)(0));
|
||||
t->end();
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glDepthMask(false);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
font->draw(playerName, -font->width(playerName) / 2, offs, 0x20ffffff);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
glDepthMask(true);
|
||||
}
|
||||
|
||||
if (textOpacity < 1.0f) {
|
||||
void MobRenderer::renderLeash(std::shared_ptr<Mob> entity, double x, double y,
|
||||
double z, float rot, float a) {
|
||||
std::shared_ptr<Entity> roper = entity->getLeashHolder();
|
||||
// roper = entityRenderDispatcher.cameraEntity;
|
||||
if (roper != NULL) {
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
y -= (1.6 - entity->bbHeight) * .5;
|
||||
Tesselator* tessellator = Tesselator::getInstance();
|
||||
double roperYRot =
|
||||
lerp(roper->yRotO, roper->yRot, a * .5f) * Mth::RAD_TO_GRAD;
|
||||
double roperXRot =
|
||||
lerp(roper->xRotO, roper->xRot, a * .5f) * Mth::RAD_TO_GRAD;
|
||||
double rotOffCos = cos(roperYRot);
|
||||
double rotOffSin = sin(roperYRot);
|
||||
double yOff = sin(roperXRot);
|
||||
if (roper->instanceof(eTYPE_HANGING_ENTITY)) {
|
||||
rotOffCos = 0;
|
||||
rotOffSin = 0;
|
||||
yOff = -1;
|
||||
}
|
||||
double swingOff = cos(roperXRot);
|
||||
double endX = lerp(roper->xo, roper->x, a) - (rotOffCos * 0.7) -
|
||||
(rotOffSin * 0.5 * swingOff);
|
||||
double endY = lerp(roper->yo + roper->getHeadHeight() * .7,
|
||||
roper->y + roper->getHeadHeight() * .7, a) -
|
||||
(yOff * 0.5) - .25;
|
||||
double endZ = lerp(roper->zo, roper->z, a) - (rotOffSin * 0.7) +
|
||||
(rotOffCos * 0.5 * swingOff);
|
||||
|
||||
double entityYRot =
|
||||
lerp(entity->yBodyRotO, entity->yBodyRot, a) * Mth::RAD_TO_GRAD +
|
||||
PI * .5;
|
||||
rotOffCos = cos(entityYRot) * entity->bbWidth * .4;
|
||||
rotOffSin = sin(entityYRot) * entity->bbWidth * .4;
|
||||
double startX = lerp(entity->xo, entity->x, a) + rotOffCos;
|
||||
double startY = lerp(entity->yo, entity->y, a);
|
||||
double startZ = lerp(entity->zo, entity->z, a) + rotOffSin;
|
||||
x += rotOffCos;
|
||||
z += rotOffSin;
|
||||
|
||||
double dx = (float)(endX - startX);
|
||||
double dy = (float)(endY - startY);
|
||||
double dz = (float)(endZ - startZ);
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
t->begin();
|
||||
int w = font->width(playerName) / 2;
|
||||
t->color(color, 255);
|
||||
t->vertex((float)(-w - 1), (float)(-1 + offs), (float)(0));
|
||||
t->vertex((float)(-w - 1), (float)(+8 + offs), (float)(0));
|
||||
t->vertex((float)(+w + 1), (float)(+8 + offs), (float)(0));
|
||||
t->vertex((float)(+w + 1), (float)(-1 + offs), (float)(0));
|
||||
t->end();
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
unsigned int lightCol =
|
||||
Minecraft::GetInstance()->getColourTable()->getColor(
|
||||
eMinecraftColour_Leash_Light_Colour);
|
||||
float rLightCol = ((lightCol >> 16) & 0xFF) / 255.0f;
|
||||
float gLightCol = ((lightCol >> 8) & 0xFF) / 255.0;
|
||||
float bLightCol = (lightCol & 0xFF) / 255.0;
|
||||
|
||||
unsigned int darkCol =
|
||||
Minecraft::GetInstance()->getColourTable()->getColor(
|
||||
eMinecraftColour_Leash_Dark_Colour);
|
||||
float rDarkCol = ((darkCol >> 16) & 0xFF) / 255.0f;
|
||||
float gDarkCol = ((darkCol >> 8) & 0xFF) / 255.0;
|
||||
float bDarkCol = (darkCol & 0xFF) / 255.0;
|
||||
|
||||
int steps = 24;
|
||||
double width = .025;
|
||||
tessellator->begin(GL_TRIANGLE_STRIP);
|
||||
for (int k = 0; k <= steps; k++) {
|
||||
if (k % 2 == 0) {
|
||||
tessellator->color(rLightCol, gLightCol, bLightCol, 1.0F);
|
||||
} else {
|
||||
tessellator->color(rDarkCol, gDarkCol, bDarkCol, 1.0F);
|
||||
}
|
||||
float aa = (float)k / (float)steps;
|
||||
tessellator->vertex(
|
||||
x + (dx * aa) + 0,
|
||||
y + (dy * ((aa * aa) + aa) * 0.5) +
|
||||
((((float)steps - (float)k) / (steps * 0.75F)) + 0.125F),
|
||||
z + (dz * aa));
|
||||
tessellator->vertex(
|
||||
x + (dx * aa) + width,
|
||||
y + (dy * ((aa * aa) + aa) * 0.5) +
|
||||
((((float)steps - (float)k) / (steps * 0.75F)) + 0.125F) +
|
||||
width,
|
||||
z + (dz * aa));
|
||||
}
|
||||
tessellator->end();
|
||||
|
||||
tessellator->begin(GL_TRIANGLE_STRIP);
|
||||
for (int k = 0; k <= steps; k++) {
|
||||
if (k % 2 == 0) {
|
||||
tessellator->color(rLightCol, gLightCol, bLightCol, 1.0F);
|
||||
} else {
|
||||
tessellator->color(rDarkCol, gDarkCol, bDarkCol, 1.0F);
|
||||
}
|
||||
float aa = (float)k / (float)steps;
|
||||
tessellator->vertex(
|
||||
x + (dx * aa) + 0,
|
||||
y + (dy * ((aa * aa) + aa) * 0.5) +
|
||||
((((float)steps - (float)k) / (steps * 0.75F)) + 0.125F) +
|
||||
width,
|
||||
z + (dz * aa));
|
||||
tessellator->vertex(
|
||||
x + (dx * aa) + width,
|
||||
y + (dy * ((aa * aa) + aa) * 0.5) +
|
||||
((((float)steps - (float)k) / (steps * 0.75F)) + 0.125F),
|
||||
z + (dz * aa) + width);
|
||||
}
|
||||
tessellator->end();
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glTranslatef(0.0f, 0.0f, -0.04f);
|
||||
glEnable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
if (textOpacity > 0.0f) {
|
||||
int textColor = (((int)(textOpacity * 255) << 24) | 0xffffff);
|
||||
font->draw(playerName, -font->width(playerName) / 2, offs, textColor);
|
||||
}
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
glDisable(GL_BLEND);
|
||||
glColor4f(1, 1, 1, 1);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
double MobRenderer::lerp(double prev, double next, double a) {
|
||||
return prev + (next - prev) * a;
|
||||
}
|
||||
|
|
@ -1,58 +1,26 @@
|
|||
#pragma once
|
||||
#include "EntityRenderer.h"
|
||||
#include "LivingEntityRenderer.h"
|
||||
class Mob;
|
||||
|
||||
#define PLAYER_NAME_READABLE_FULLSCREEN 16
|
||||
// This was used in MobRenderer but lots of code moved to LivingEntity and I
|
||||
// haven't put this back yet
|
||||
/*#define PLAYER_NAME_READABLE_FULLSCREEN 16
|
||||
#define PLAYER_NAME_READABLE_DISTANCE_SPLITSCREEN 8
|
||||
#define PLAYER_NAME_READABLE_DISTANCE_SD 8
|
||||
#define PLAYER_NAME_READABLE_DISTANCE_SD 8*/
|
||||
|
||||
// 4J - this used to be a generic : public class MobRenderer<T extends Mob>
|
||||
// extends EntityRenderer<T>
|
||||
class MobRenderer : public EntityRenderer {
|
||||
private:
|
||||
static const int MAX_ARMOR_LAYERS = 4;
|
||||
|
||||
protected:
|
||||
Model* model;
|
||||
Model* armor;
|
||||
|
||||
class MobRenderer : public LivingEntityRenderer {
|
||||
public:
|
||||
MobRenderer(Model* model, float shadow);
|
||||
virtual void setArmor(Model* armor);
|
||||
|
||||
private:
|
||||
float rotlerp(float from, float to, float a);
|
||||
|
||||
public:
|
||||
virtual void render(std::shared_ptr<Entity> mob, double x, double y,
|
||||
double z, float rot, float a);
|
||||
|
||||
protected:
|
||||
virtual void renderModel(std::shared_ptr<Entity> mob, float wp, float ws,
|
||||
float bob, float headRotMinusBodyRot,
|
||||
float headRotx, float scale);
|
||||
virtual void setupPosition(std::shared_ptr<Mob> mob, double x, double y,
|
||||
double z);
|
||||
virtual void setupRotations(std::shared_ptr<Mob> mob, float bob,
|
||||
float bodyRot, float a);
|
||||
virtual float getAttackAnim(std::shared_ptr<Mob> mob, float a);
|
||||
virtual float getBob(std::shared_ptr<Mob> mob, float a);
|
||||
virtual void additionalRendering(std::shared_ptr<Mob> mob, float a);
|
||||
virtual int prepareArmorOverlay(std::shared_ptr<Mob> mob, int layer,
|
||||
float a);
|
||||
virtual int prepareArmor(std::shared_ptr<Mob> mob, int layer, float a);
|
||||
virtual void prepareSecondPassArmor(std::shared_ptr<Mob> mob, int layer,
|
||||
float a);
|
||||
virtual float getFlipDegrees(std::shared_ptr<Mob> mob);
|
||||
virtual int getOverlayColor(std::shared_ptr<Mob> mob, float br, float a);
|
||||
virtual void scale(std::shared_ptr<Mob> mob, float a);
|
||||
virtual void renderName(std::shared_ptr<Mob> mob, double x, double y,
|
||||
double z);
|
||||
virtual void renderNameTag(std::shared_ptr<Mob> mob,
|
||||
const std::wstring& name, double x, double y,
|
||||
double z, int maxDist, int color = 0xff000000);
|
||||
virtual bool shouldShowName(std::shared_ptr<LivingEntity> mob);
|
||||
virtual void renderLeash(std::shared_ptr<Mob> entity, double x, double y,
|
||||
double z, float rot, float a);
|
||||
|
||||
public:
|
||||
// 4J Added
|
||||
virtual Model* getModel() { return model; }
|
||||
private:
|
||||
double lerp(double prev, double next, double a);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,13 +12,18 @@ void MobSpawnerRenderer::render(std::shared_ptr<TileEntity> _spawner, double x,
|
|||
// our version
|
||||
std::shared_ptr<MobSpawnerTileEntity> spawner =
|
||||
std::dynamic_pointer_cast<MobSpawnerTileEntity>(_spawner);
|
||||
render(spawner->getSpawner(), x, y, z, a);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void MobSpawnerRenderer::render(BaseMobSpawner* spawner, double x, double y,
|
||||
double z, float a) {
|
||||
glPushMatrix();
|
||||
glTranslatef((float)x + 0.5f, (float)y, (float)z + 0.5f);
|
||||
|
||||
std::shared_ptr<Entity> e = spawner->getDisplayEntity();
|
||||
if (e != NULL) {
|
||||
e->setLevel(spawner->level);
|
||||
e->setLevel(spawner->getLevel());
|
||||
float s = 7 / 16.0f;
|
||||
glTranslatef(0, 0.4f, 0);
|
||||
glRotatef(
|
||||
|
|
@ -30,5 +35,4 @@ void MobSpawnerRenderer::render(std::shared_ptr<TileEntity> _spawner, double x,
|
|||
e->moveTo(x, y, z, 0, 0);
|
||||
EntityRenderDispatcher::instance->render(e, 0, 0, 0, 0, a);
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
#pragma once
|
||||
#include "TileEntityRenderer.h"
|
||||
|
||||
class BaseMobSpawner;
|
||||
|
||||
class MobSpawnerRenderer : public TileEntityRenderer {
|
||||
private:
|
||||
std::unordered_map<std::wstring, std::shared_ptr<Entity> > models;
|
||||
|
||||
public:
|
||||
static void render(BaseMobSpawner* spawner, double x, double y, double z,
|
||||
float a);
|
||||
virtual void render(std::shared_ptr<TileEntity> _spawner, double x,
|
||||
double y, double z, float a, bool setColor,
|
||||
float alpha = 1.0f,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.animal.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.level.tile.h"
|
||||
#include "../Models/QuadrupedModel.h"
|
||||
#include "../Models/ModelPart.h"
|
||||
#include "MushroomCowRenderer.h"
|
||||
#include "../../Textures/TextureAtlas.h"
|
||||
#include "../Models/QuadrupedModel.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.animal.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.level.tile.h"
|
||||
|
||||
ResourceLocation MushroomCowRenderer::MOOSHROOM_LOCATION =
|
||||
ResourceLocation(TN_MOB_RED_COW);
|
||||
|
||||
MushroomCowRenderer::MushroomCowRenderer(Model* model, float shadow)
|
||||
: MobRenderer(model, shadow) {}
|
||||
|
|
@ -11,34 +15,34 @@ MushroomCowRenderer::MushroomCowRenderer(Model* model, float shadow)
|
|||
void MushroomCowRenderer::render(std::shared_ptr<Entity> _mob, double x,
|
||||
double y, double z, float rot, float a) {
|
||||
// 4J - original version used generics and thus had an input parameter of
|
||||
// type MushroomCow rather than std::shared_ptr<Entity> we have here - do
|
||||
// some casting around instead
|
||||
// std::shared_ptr<MushroomCow> mob =
|
||||
// type MushroomCow rather than shared_ptr<Entity> we have here - do some
|
||||
// casting around instead
|
||||
// shared_ptr<MushroomCow> mob =
|
||||
// std::dynamic_pointer_cast<MushroomCow>(_mob);
|
||||
|
||||
// 4J Stu - No need to do the cast, just pass through as-is
|
||||
MobRenderer::render(_mob, x, y, z, rot, a);
|
||||
}
|
||||
|
||||
void MushroomCowRenderer::additionalRendering(std::shared_ptr<Mob> _mob,
|
||||
float a) {
|
||||
void MushroomCowRenderer::additionalRendering(
|
||||
std::shared_ptr<LivingEntity> _mob, float a) {
|
||||
// 4J - original version used generics and thus had an input parameter of
|
||||
// type MushroomCow rather than std::shared_ptr<Mob> we have here - do some
|
||||
// type MushroomCow rather than shared_ptr<Mob> we have here - do some
|
||||
// casting around instead
|
||||
std::shared_ptr<MushroomCow> mob =
|
||||
std::dynamic_pointer_cast<MushroomCow>(_mob);
|
||||
MobRenderer::additionalRendering(mob, a);
|
||||
if (mob->isBaby()) return;
|
||||
bindTexture(TN_TERRAIN); // 4J was "/terrain.png"
|
||||
bindTexture(&TextureAtlas::LOCATION_BLOCKS); // 4J was "/terrain.png"
|
||||
glEnable(GL_CULL_FACE);
|
||||
glPushMatrix();
|
||||
glScalef(1, -1, 1);
|
||||
glTranslatef(0.2f, 0.4f, 0.5f);
|
||||
glRotatef(42, 0, 1, 0);
|
||||
tileRenderer->renderTile(Tile::mushroom2, 0, 1);
|
||||
tileRenderer->renderTile(Tile::mushroom_red, 0, 1);
|
||||
glTranslatef(0.1f, 0, -0.6f);
|
||||
glRotatef(42, 0, 1, 0);
|
||||
tileRenderer->renderTile(Tile::mushroom2, 0, 1);
|
||||
tileRenderer->renderTile(Tile::mushroom_red, 0, 1);
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
|
|
@ -46,8 +50,13 @@ void MushroomCowRenderer::additionalRendering(std::shared_ptr<Mob> _mob,
|
|||
glScalef(1, -1, 1);
|
||||
glTranslatef(0, 0.75f, -0.2f);
|
||||
glRotatef(12, 0, 1, 0);
|
||||
tileRenderer->renderTile(Tile::mushroom2, 0, 1);
|
||||
tileRenderer->renderTile(Tile::mushroom_red, 0, 1);
|
||||
glPopMatrix();
|
||||
|
||||
glDisable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
ResourceLocation* MushroomCowRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &MOOSHROOM_LOCATION;
|
||||
}
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "MobRenderer.h"
|
||||
|
||||
class MushroomCowRenderer : public MobRenderer {
|
||||
private:
|
||||
static ResourceLocation MOOSHROOM_LOCATION;
|
||||
|
||||
public:
|
||||
MushroomCowRenderer(Model* model, float shadow);
|
||||
|
||||
|
|
@ -10,5 +12,7 @@ public:
|
|||
double z, float rot, float a);
|
||||
|
||||
protected:
|
||||
virtual void additionalRendering(std::shared_ptr<Mob> _mob, float a);
|
||||
virtual void additionalRendering(std::shared_ptr<LivingEntity> _mob,
|
||||
float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
};
|
||||
|
|
@ -1,20 +1,46 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.animal.h"
|
||||
#include "OcelotRenderer.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.animal.h"
|
||||
|
||||
OzelotRenderer::OzelotRenderer(Model* model, float shadow)
|
||||
ResourceLocation OcelotRenderer::CAT_BLACK_LOCATION =
|
||||
ResourceLocation(TN_MOB_CAT_BLACK);
|
||||
ResourceLocation OcelotRenderer::CAT_OCELOT_LOCATION =
|
||||
ResourceLocation(TN_MOB_OCELOT);
|
||||
ResourceLocation OcelotRenderer::CAT_RED_LOCATION =
|
||||
ResourceLocation(TN_MOB_CAT_RED);
|
||||
ResourceLocation OcelotRenderer::CAT_SIAMESE_LOCATION =
|
||||
ResourceLocation(TN_MOB_CAT_SIAMESE);
|
||||
|
||||
OcelotRenderer::OcelotRenderer(Model* model, float shadow)
|
||||
: MobRenderer(model, shadow) {}
|
||||
|
||||
void OzelotRenderer::render(std::shared_ptr<Entity> _mob, double x, double y,
|
||||
void OcelotRenderer::render(std::shared_ptr<Entity> _mob, double x, double y,
|
||||
double z, float rot, float a) {
|
||||
MobRenderer::render(_mob, x, y, z, rot, a);
|
||||
}
|
||||
|
||||
void OzelotRenderer::scale(std::shared_ptr<Mob> _mob, float a) {
|
||||
ResourceLocation* OcelotRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> entity) {
|
||||
std::shared_ptr<Ocelot> cat = std::dynamic_pointer_cast<Ocelot>(entity);
|
||||
|
||||
switch (cat->getCatType()) {
|
||||
default:
|
||||
case Ocelot::TYPE_OCELOT:
|
||||
return &CAT_OCELOT_LOCATION;
|
||||
case Ocelot::TYPE_BLACK:
|
||||
return &CAT_BLACK_LOCATION;
|
||||
case Ocelot::TYPE_RED:
|
||||
return &CAT_RED_LOCATION;
|
||||
case Ocelot::TYPE_SIAMESE:
|
||||
return &CAT_SIAMESE_LOCATION;
|
||||
}
|
||||
}
|
||||
|
||||
void OcelotRenderer::scale(std::shared_ptr<LivingEntity> _mob, float a) {
|
||||
// 4J - original version used generics and thus had an input parameter of
|
||||
// type Blaze rather than std::shared_ptr<Entity> we have here - do some
|
||||
// casting around instead
|
||||
std::shared_ptr<Ozelot> mob = std::dynamic_pointer_cast<Ozelot>(_mob);
|
||||
// type Blaze rather than shared_ptr<Entity> we have here - do some casting
|
||||
// around instead
|
||||
std::shared_ptr<Ocelot> mob = std::dynamic_pointer_cast<Ocelot>(_mob);
|
||||
MobRenderer::scale(mob, a);
|
||||
if (mob->isTame()) {
|
||||
glScalef(.8f, .8f, .8f);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include "MobRenderer.h"
|
||||
|
||||
class OzelotRenderer : public MobRenderer {
|
||||
public:
|
||||
OzelotRenderer(Model* model, float shadow);
|
||||
class OcelotRenderer : public MobRenderer {
|
||||
private:
|
||||
static ResourceLocation CAT_BLACK_LOCATION;
|
||||
static ResourceLocation CAT_OCELOT_LOCATION;
|
||||
static ResourceLocation CAT_RED_LOCATION;
|
||||
static ResourceLocation CAT_SIAMESE_LOCATION;
|
||||
|
||||
void render(std::shared_ptr<Entity> _mob, double x, double y, double z,
|
||||
float rot, float a);
|
||||
public:
|
||||
OcelotRenderer(Model* model, float shadow);
|
||||
virtual void render(std::shared_ptr<Entity> _mob, double x, double y,
|
||||
double z, float rot, float a);
|
||||
|
||||
protected:
|
||||
void scale(std::shared_ptr<Mob> _mob, float a);
|
||||
virtual ResourceLocation* getTextureLocation(
|
||||
std::shared_ptr<Entity> entity);
|
||||
virtual void scale(std::shared_ptr<LivingEntity> _mob, float a);
|
||||
};
|
||||
|
|
@ -6,6 +6,8 @@
|
|||
#include "../../../Minecraft.World/Util/Random.h"
|
||||
#include "../../../Minecraft.World/Util/Mth.h"
|
||||
|
||||
ResourceLocation PaintingRenderer::PAINTING_LOCATION(TN_ART_KZ);
|
||||
|
||||
PaintingRenderer::PaintingRenderer() { random = new Random(); }
|
||||
|
||||
void PaintingRenderer::render(std::shared_ptr<Entity> _painting, double x,
|
||||
|
|
@ -21,7 +23,7 @@ void PaintingRenderer::render(std::shared_ptr<Entity> _painting, double x,
|
|||
glTranslatef((float)x, (float)y, (float)z);
|
||||
glRotatef(rot, 0, 1, 0);
|
||||
glEnable(GL_RESCALE_NORMAL);
|
||||
bindTexture(TN_ART_KZ); // 4J was L"/art/kz.png"
|
||||
bindTexture(painting); // 4J was L"/art/kz.png"
|
||||
|
||||
Painting::Motive* motive = painting->motive;
|
||||
|
||||
|
|
@ -37,10 +39,27 @@ void PaintingRenderer::renderPainting(std::shared_ptr<Painting> painting, int w,
|
|||
float xx0 = -w / 2.0f;
|
||||
float yy0 = -h / 2.0f;
|
||||
|
||||
float z0 = -0.5f;
|
||||
float z1 = +0.5f;
|
||||
float edgeWidth = 0.5f;
|
||||
|
||||
for (int xs = 0; xs < w / 16; xs++)
|
||||
// Back
|
||||
float bu0 = (12 * 16) / 256.0f;
|
||||
float bu1 = (12 * 16 + 16) / 256.0f;
|
||||
float bv0 = (0) / 256.0f;
|
||||
float bv1 = (0 + 16) / 256.0f;
|
||||
|
||||
// Border
|
||||
float uu0 = (12 * 16) / 256.0f;
|
||||
float uu1 = (12 * 16 + 16) / 256.0f;
|
||||
float uv0 = (0.5f) / 256.0f;
|
||||
float uv1 = (0.5f) / 256.0f;
|
||||
|
||||
// Border
|
||||
float su0 = (12 * 16 + 0.5f) / 256.0f;
|
||||
float su1 = (12 * 16 + 0.5f) / 256.0f;
|
||||
float sv0 = (0) / 256.0f;
|
||||
float sv1 = (0 + 16) / 256.0f;
|
||||
|
||||
for (int xs = 0; xs < w / 16; xs++) {
|
||||
for (int ys = 0; ys < h / 16; ys++) {
|
||||
float x0 = xx0 + (xs + 1) * 16;
|
||||
float x1 = xx0 + (xs) * 16;
|
||||
|
|
@ -49,89 +68,52 @@ void PaintingRenderer::renderPainting(std::shared_ptr<Painting> painting, int w,
|
|||
|
||||
setBrightness(painting, (x0 + x1) / 2, (y0 + y1) / 2);
|
||||
|
||||
// Painting
|
||||
float fu0 = (uo + w - (xs) * 16) / 256.0f;
|
||||
float fu1 = (uo + w - (xs + 1) * 16) / 256.0f;
|
||||
float fv0 = (vo + h - (ys) * 16) / 256.0f;
|
||||
float fv1 = (vo + h - (ys + 1) * 16) / 256.0f;
|
||||
|
||||
float bu0 = (12 * 16) / 256.0f;
|
||||
float bu1 = (12 * 16 + 16) / 256.0f;
|
||||
float bv0 = (0) / 256.0f;
|
||||
float bv1 = (0 + 16) / 256.0f;
|
||||
|
||||
float uu0 = (12 * 16) / 256.0f;
|
||||
float uu1 = (12 * 16 + 16) / 256.0f;
|
||||
float uv0 = (0.5f) / 256.0f;
|
||||
float uv1 = (0.5f) / 256.0f;
|
||||
|
||||
float su0 = (12 * 16 + 0.5f) / 256.0f;
|
||||
float su1 = (12 * 16 + 0.5f) / 256.0f;
|
||||
float sv0 = (0) / 256.0f;
|
||||
float sv1 = (0 + 16) / 256.0f;
|
||||
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
t->begin();
|
||||
t->normal(0, 0, -1);
|
||||
t->vertexUV((float)(x0), (float)(y1), (float)(z0), (float)(fu1),
|
||||
(float)(fv0));
|
||||
t->vertexUV((float)(x1), (float)(y1), (float)(z0), (float)(fu0),
|
||||
(float)(fv0));
|
||||
t->vertexUV((float)(x1), (float)(y0), (float)(z0), (float)(fu0),
|
||||
(float)(fv1));
|
||||
t->vertexUV((float)(x0), (float)(y0), (float)(z0), (float)(fu1),
|
||||
(float)(fv1));
|
||||
t->vertexUV(x0, y1, -edgeWidth, fu1, fv0);
|
||||
t->vertexUV(x1, y1, -edgeWidth, fu0, fv0);
|
||||
t->vertexUV(x1, y0, -edgeWidth, fu0, fv1);
|
||||
t->vertexUV(x0, y0, -edgeWidth, fu1, fv1);
|
||||
|
||||
t->normal(0, 0, 1);
|
||||
t->vertexUV((float)(x0), (float)(y0), (float)(z1), (float)(bu0),
|
||||
(float)(bv0));
|
||||
t->vertexUV((float)(x1), (float)(y0), (float)(z1), (float)(bu1),
|
||||
(float)(bv0));
|
||||
t->vertexUV((float)(x1), (float)(y1), (float)(z1), (float)(bu1),
|
||||
(float)(bv1));
|
||||
t->vertexUV((float)(x0), (float)(y1), (float)(z1), (float)(bu0),
|
||||
(float)(bv1));
|
||||
t->vertexUV(x0, y0, edgeWidth, bu0, bv0);
|
||||
t->vertexUV(x1, y0, edgeWidth, bu1, bv0);
|
||||
t->vertexUV(x1, y1, edgeWidth, bu1, bv1);
|
||||
t->vertexUV(x0, y1, edgeWidth, bu0, bv1);
|
||||
|
||||
t->normal(0, 1, 0);
|
||||
t->vertexUV((float)(x0), (float)(y0), (float)(z0), (float)(uu0),
|
||||
(float)(uv0));
|
||||
t->vertexUV((float)(x1), (float)(y0), (float)(z0), (float)(uu1),
|
||||
(float)(uv0));
|
||||
t->vertexUV((float)(x1), (float)(y0), (float)(z1), (float)(uu1),
|
||||
(float)(uv1));
|
||||
t->vertexUV((float)(x0), (float)(y0), (float)(z1), (float)(uu0),
|
||||
(float)(uv1));
|
||||
t->vertexUV(x0, y0, -edgeWidth, uu0, uv0);
|
||||
t->vertexUV(x1, y0, -edgeWidth, uu1, uv0);
|
||||
t->vertexUV(x1, y0, edgeWidth, uu1, uv1);
|
||||
t->vertexUV(x0, y0, edgeWidth, uu0, uv1);
|
||||
|
||||
t->normal(0, -1, 0);
|
||||
t->vertexUV((float)(x0), (float)(y1), (float)(z1), (float)(uu0),
|
||||
(float)(uv0));
|
||||
t->vertexUV((float)(x1), (float)(y1), (float)(z1), (float)(uu1),
|
||||
(float)(uv0));
|
||||
t->vertexUV((float)(x1), (float)(y1), (float)(z0), (float)(uu1),
|
||||
(float)(uv1));
|
||||
t->vertexUV((float)(x0), (float)(y1), (float)(z0), (float)(uu0),
|
||||
(float)(uv1));
|
||||
t->vertexUV(x0, y1, edgeWidth, uu0, uv0);
|
||||
t->vertexUV(x1, y1, edgeWidth, uu1, uv0);
|
||||
t->vertexUV(x1, y1, -edgeWidth, uu1, uv1);
|
||||
t->vertexUV(x0, y1, -edgeWidth, uu0, uv1);
|
||||
|
||||
t->normal(-1, 0, 0);
|
||||
t->vertexUV((float)(x0), (float)(y0), (float)(z1), (float)(su1),
|
||||
(float)(sv0));
|
||||
t->vertexUV((float)(x0), (float)(y1), (float)(z1), (float)(su1),
|
||||
(float)(sv1));
|
||||
t->vertexUV((float)(x0), (float)(y1), (float)(z0), (float)(su0),
|
||||
(float)(sv1));
|
||||
t->vertexUV((float)(x0), (float)(y0), (float)(z0), (float)(su0),
|
||||
(float)(sv0));
|
||||
t->vertexUV(x0, y0, edgeWidth, su1, sv0);
|
||||
t->vertexUV(x0, y1, edgeWidth, su1, sv1);
|
||||
t->vertexUV(x0, y1, -edgeWidth, su0, sv1);
|
||||
t->vertexUV(x0, y0, -edgeWidth, su0, sv0);
|
||||
|
||||
t->normal(1, 0, 0);
|
||||
t->vertexUV((float)(x1), (float)(y0), (float)(z0), (float)(su1),
|
||||
(float)(sv0));
|
||||
t->vertexUV((float)(x1), (float)(y1), (float)(z0), (float)(su1),
|
||||
(float)(sv1));
|
||||
t->vertexUV((float)(x1), (float)(y1), (float)(z1), (float)(su0),
|
||||
(float)(sv1));
|
||||
t->vertexUV((float)(x1), (float)(y0), (float)(z1), (float)(su0),
|
||||
(float)(sv0));
|
||||
t->vertexUV(x1, y0, -edgeWidth, su1, sv0);
|
||||
t->vertexUV(x1, y1, -edgeWidth, su1, sv1);
|
||||
t->vertexUV(x1, y1, edgeWidth, su0, sv1);
|
||||
t->vertexUV(x1, y0, edgeWidth, su0, sv0);
|
||||
t->end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PaintingRenderer::setBrightness(std::shared_ptr<Painting> painting,
|
||||
|
|
@ -149,4 +131,9 @@ void PaintingRenderer::setBrightness(std::shared_ptr<Painting> painting,
|
|||
int v = col / 65536;
|
||||
glMultiTexCoord2f(0, u, v);
|
||||
glColor3f(1, 1, 1);
|
||||
}
|
||||
|
||||
ResourceLocation* PaintingRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &PAINTING_LOCATION;
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ class Random;
|
|||
class PaintingRenderer : public EntityRenderer {
|
||||
private:
|
||||
Random* random;
|
||||
static ResourceLocation PAINTING_LOCATION;
|
||||
|
||||
public:
|
||||
PaintingRenderer(); // 4J -added
|
||||
|
|
@ -17,4 +18,5 @@ private:
|
|||
void renderPainting(std::shared_ptr<Painting> painting, int w, int h,
|
||||
int uo, int vo);
|
||||
void setBrightness(std::shared_ptr<Painting> painting, float ss, float ya);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,23 +2,36 @@
|
|||
#include "PigRenderer.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.animal.h"
|
||||
|
||||
ResourceLocation PigRenderer::PIG_LOCATION = ResourceLocation(TN_MOB_PIG);
|
||||
ResourceLocation PigRenderer::SADDLE_LOCATION = ResourceLocation(TN_MOB_SADDLE);
|
||||
|
||||
PigRenderer::PigRenderer(Model* model, Model* armor, float shadow)
|
||||
: MobRenderer(model, shadow) {
|
||||
setArmor(armor);
|
||||
}
|
||||
|
||||
int PigRenderer::prepareArmor(std::shared_ptr<Mob> _pig, int layer, float a) {
|
||||
int PigRenderer::prepareArmor(std::shared_ptr<LivingEntity> _pig, int layer,
|
||||
float a) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
std::shared_ptr<Pig> pig = std::dynamic_pointer_cast<Pig>(_pig);
|
||||
|
||||
MemSect(31);
|
||||
bindTexture(TN_MOB_SADDLE); // 4J was L"/mob/saddle.png"
|
||||
MemSect(0);
|
||||
return (layer == 0 && pig->hasSaddle()) ? 1 : -1;
|
||||
if (layer == 0 && pig->hasSaddle()) {
|
||||
MemSect(31);
|
||||
bindTexture(&SADDLE_LOCATION);
|
||||
MemSect(0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void PigRenderer::render(std::shared_ptr<Entity> mob, double x, double y,
|
||||
double z, float rot, float a) {
|
||||
MobRenderer::render(mob, x, y, z, rot, a);
|
||||
}
|
||||
|
||||
ResourceLocation* PigRenderer::getTextureLocation(std::shared_ptr<Entity> mob) {
|
||||
return &PIG_LOCATION;
|
||||
}
|
||||
|
|
@ -2,13 +2,19 @@
|
|||
#include "MobRenderer.h"
|
||||
|
||||
class PigRenderer : public MobRenderer {
|
||||
private:
|
||||
static ResourceLocation PIG_LOCATION;
|
||||
static ResourceLocation SADDLE_LOCATION;
|
||||
|
||||
public:
|
||||
PigRenderer(Model* model, Model* armor, float shadow);
|
||||
|
||||
protected:
|
||||
virtual int prepareArmor(std::shared_ptr<Mob> _pig, int layer, float a);
|
||||
virtual int prepareArmor(std::shared_ptr<LivingEntity> _pig, int layer,
|
||||
float a);
|
||||
|
||||
public:
|
||||
virtual void render(std::shared_ptr<Entity> mob, double x, double y,
|
||||
double z, float rot, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
};
|
||||
|
|
@ -1,12 +1,16 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "PistonPieceRenderer.h"
|
||||
#include "../Tesselator.h"
|
||||
#include "../Lighting.h"
|
||||
#include "../Tesselator.h"
|
||||
#include "../../Textures/TextureAtlas.h"
|
||||
#include "TileRenderer.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
||||
#include "../../../Minecraft.World/Blocks/TileEntities/PistonPieceTileEntity.h"
|
||||
#include "../Minecraft.World/PistonPieceEntity.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.level.tile.h"
|
||||
|
||||
ResourceLocation PistonPieceRenderer::SIGN_LOCATION =
|
||||
ResourceLocation(TN_ITEM_SIGN);
|
||||
|
||||
PistonPieceRenderer::PistonPieceRenderer() { tileRenderer = NULL; }
|
||||
|
||||
void PistonPieceRenderer::render(std::shared_ptr<TileEntity> _entity, double x,
|
||||
|
|
@ -25,7 +29,7 @@ void PistonPieceRenderer::render(std::shared_ptr<TileEntity> _entity, double x,
|
|||
// progress of 1
|
||||
{
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
bindTexture(TN_TERRAIN);
|
||||
bindTexture(&TextureAtlas::LOCATION_BLOCKS);
|
||||
|
||||
Lighting::turnOff();
|
||||
glColor4f(1, 1, 1,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
#pragma once
|
||||
#include "TileEntityRenderer.h"
|
||||
|
||||
class PistonPieceEntity;
|
||||
class TileRenderer;
|
||||
|
||||
class PistonPieceRenderer : public TileEntityRenderer {
|
||||
private:
|
||||
static ResourceLocation SIGN_LOCATION;
|
||||
TileRenderer* tileRenderer;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "PlayerRenderer.h"
|
||||
#include "SkullTileRenderer.h"
|
||||
#include "HumanoidMobRenderer.h"
|
||||
#include "../Models/HumanoidModel.h"
|
||||
#include "../Models/ModelPart.h"
|
||||
#include "../../Player/LocalPlayer.h"
|
||||
|
|
@ -28,10 +29,11 @@ const unsigned int PlayerRenderer::s_nametagColors[MINECRAFT_NET_MAX_PLAYERS] =
|
|||
#endif
|
||||
};
|
||||
|
||||
const std::wstring PlayerRenderer::MATERIAL_NAMES[5] = {
|
||||
L"cloth", L"chain", L"iron", L"diamond", L"gold"};
|
||||
ResourceLocation PlayerRenderer::DEFAULT_LOCATION =
|
||||
ResourceLocation(TN_MOB_CHAR);
|
||||
|
||||
PlayerRenderer::PlayerRenderer() : MobRenderer(new HumanoidModel(0), 0.5f) {
|
||||
PlayerRenderer::PlayerRenderer()
|
||||
: LivingEntityRenderer(new HumanoidModel(0), 0.5f) {
|
||||
humanoidModel = (HumanoidModel*)model;
|
||||
|
||||
armorParts1 = new HumanoidModel(1.0f);
|
||||
|
|
@ -45,8 +47,8 @@ unsigned int PlayerRenderer::getNametagColour(int index) {
|
|||
return 0xFF000000;
|
||||
}
|
||||
|
||||
int PlayerRenderer::prepareArmor(std::shared_ptr<Mob> _player, int layer,
|
||||
float a) {
|
||||
int PlayerRenderer::prepareArmor(std::shared_ptr<LivingEntity> _player,
|
||||
int layer, float a) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(_player);
|
||||
|
|
@ -63,8 +65,8 @@ int PlayerRenderer::prepareArmor(std::shared_ptr<Mob> _player, int layer,
|
|||
Item* item = itemInstance->getItem();
|
||||
if (dynamic_cast<ArmorItem*>(item)) {
|
||||
ArmorItem* armorItem = dynamic_cast<ArmorItem*>(item);
|
||||
bindTexture(L"armor/" + MATERIAL_NAMES[armorItem->modelIndex] +
|
||||
L"_" + _toString<int>(layer == 2 ? 2 : 1) + L".png");
|
||||
bindTexture(
|
||||
HumanoidMobRenderer::getArmorLocation(armorItem, layer));
|
||||
|
||||
HumanoidModel* armor = layer == 2 ? armorParts2 : armorParts1;
|
||||
|
||||
|
|
@ -106,8 +108,8 @@ int PlayerRenderer::prepareArmor(std::shared_ptr<Mob> _player, int layer,
|
|||
return -1;
|
||||
}
|
||||
|
||||
void PlayerRenderer::prepareSecondPassArmor(std::shared_ptr<Mob> _player,
|
||||
int layer, float a) {
|
||||
void PlayerRenderer::prepareSecondPassArmor(
|
||||
std::shared_ptr<LivingEntity> _player, int layer, float a) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(_player);
|
||||
|
|
@ -117,8 +119,8 @@ void PlayerRenderer::prepareSecondPassArmor(std::shared_ptr<Mob> _player,
|
|||
Item* item = itemInstance->getItem();
|
||||
if (dynamic_cast<ArmorItem*>(item)) {
|
||||
ArmorItem* armorItem = dynamic_cast<ArmorItem*>(item);
|
||||
bindTexture(L"armor/" + MATERIAL_NAMES[armorItem->modelIndex] +
|
||||
L"_" + _toString<int>(layer == 2 ? 2 : 1) + L"_b.png");
|
||||
bindTexture(HumanoidMobRenderer::getArmorLocation((ArmorItem*)item,
|
||||
layer, true));
|
||||
|
||||
float brightness = SharedConstants::TEXTURE_LIGHTING
|
||||
? 1
|
||||
|
|
@ -173,8 +175,7 @@ void PlayerRenderer::render(std::shared_ptr<Entity> _mob, double x, double y,
|
|||
mob->isSneaking();
|
||||
|
||||
double yp = y - mob->heightOffset;
|
||||
if (mob->isSneaking() &&
|
||||
(std::dynamic_pointer_cast<LocalPlayer>(mob) == NULL)) {
|
||||
if (mob->isSneaking() && !mob->instanceof(eTYPE_LOCALPLAYER)) {
|
||||
yp -= 2 / 16.0f;
|
||||
}
|
||||
|
||||
|
|
@ -208,7 +209,7 @@ void PlayerRenderer::render(std::shared_ptr<Entity> _mob, double x, double y,
|
|||
}
|
||||
}
|
||||
|
||||
MobRenderer::render(mob, x, yp, z, rot, a);
|
||||
LivingEntityRenderer::render(mob, x, yp, z, rot, a);
|
||||
|
||||
// turn them off again
|
||||
if (pAdditionalModelParts && pAdditionalModelParts->size() != 0) {
|
||||
|
|
@ -227,91 +228,14 @@ void PlayerRenderer::render(std::shared_ptr<Entity> _mob, double x, double y,
|
|||
humanoidModel->holdingRightHand = 0;
|
||||
}
|
||||
|
||||
void PlayerRenderer::renderName(std::shared_ptr<Mob> _mob, double x, double y,
|
||||
double z) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
std::shared_ptr<Player> mob = std::dynamic_pointer_cast<Player>(_mob);
|
||||
void PlayerRenderer::additionalRendering(std::shared_ptr<LivingEntity> _mob,
|
||||
float a) {
|
||||
float brightness =
|
||||
SharedConstants::TEXTURE_LIGHTING ? 1 : _mob->getBrightness(a);
|
||||
glColor3f(brightness, brightness, brightness);
|
||||
|
||||
if (Minecraft::renderNames() &&
|
||||
mob != entityRenderDispatcher->cameraEntity &&
|
||||
!mob->isInvisibleTo(
|
||||
Minecraft::GetInstance()
|
||||
->player)) // 4J-JEV: Todo, move to LivingEntityRenderer.
|
||||
{
|
||||
float size = 1.60f;
|
||||
float s = 1 / 60.0f * size;
|
||||
double dist = mob->distanceToSqr(entityRenderDispatcher->cameraEntity);
|
||||
|
||||
float maxDist = mob->isSneaking() ? 32.0f : 64.0f;
|
||||
|
||||
if (dist < maxDist * maxDist) {
|
||||
// Truncate display names longer than 16 char
|
||||
std::wstring msg = mob->getDisplayName();
|
||||
if (msg.length() > 16) {
|
||||
msg.resize(16);
|
||||
msg += L"...";
|
||||
}
|
||||
|
||||
if (mob->isSneaking()) {
|
||||
if (app.GetGameSettings(eGameSetting_DisplayHUD) == 0) {
|
||||
// 4J-PB - turn off gamertag render
|
||||
return;
|
||||
}
|
||||
|
||||
if (app.GetGameHostOption(eGameHostOption_Gamertags) == 0) {
|
||||
// turn off gamertags if the host has set them off
|
||||
return;
|
||||
}
|
||||
|
||||
Font* font = getFont();
|
||||
glPushMatrix();
|
||||
glTranslatef((float)x + 0, (float)y + 2.3f, (float)z);
|
||||
glNormal3f(0, 1, 0);
|
||||
|
||||
glRotatef(-this->entityRenderDispatcher->playerRotY, 0, 1, 0);
|
||||
glRotatef(this->entityRenderDispatcher->playerRotX, 1, 0, 0);
|
||||
|
||||
glScalef(-s, -s, s);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
glTranslatef(0, (float)0.25f / s, 0);
|
||||
glDepthMask(false);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
Tesselator* t = Tesselator::getInstance();
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
t->begin();
|
||||
int w = font->width(msg) / 2;
|
||||
t->color(0.0f, 0.0f, 0.0f, 0.25f);
|
||||
t->vertex((float)(-w - 1), (float)(-1), (float)(0));
|
||||
t->vertex((float)(-w - 1), (float)(+8), (float)(0));
|
||||
t->vertex((float)(+w + 1), (float)(+8), (float)(0));
|
||||
t->vertex((float)(+w + 1), (float)(-1), (float)(0));
|
||||
t->end();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glDepthMask(true);
|
||||
font->draw(msg, -font->width(msg) / 2, 0, 0x20ffffff);
|
||||
glEnable(GL_LIGHTING);
|
||||
glDisable(GL_BLEND);
|
||||
glColor4f(1, 1, 1, 1);
|
||||
glPopMatrix();
|
||||
} else {
|
||||
if (mob->isSleeping()) {
|
||||
renderNameTag(mob, msg, x, y - 1.5f, z, 64,
|
||||
s_nametagColors[mob->getPlayerIndex()]);
|
||||
} else {
|
||||
renderNameTag(mob, msg, x, y, z, 64,
|
||||
s_nametagColors[mob->getPlayerIndex()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerRenderer::additionalRendering(std::shared_ptr<Mob> _mob, float a) {
|
||||
MobRenderer::additionalRendering(_mob, a);
|
||||
LivingEntityRenderer::additionalRendering(_mob, a);
|
||||
LivingEntityRenderer::renderArrows(_mob, a);
|
||||
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
|
|
@ -337,7 +261,7 @@ void PlayerRenderer::additionalRendering(std::shared_ptr<Mob> _mob, float a) {
|
|||
glScalef(s, -s, s);
|
||||
}
|
||||
|
||||
this->entityRenderDispatcher->itemInHandRenderer->renderItem(
|
||||
entityRenderDispatcher->itemInHandRenderer->renderItem(
|
||||
mob, headGear, 0);
|
||||
} else if (headGear->getItem()->id == Item::skull_Id) {
|
||||
float s = 17 / 16.0f;
|
||||
|
|
@ -378,8 +302,11 @@ void PlayerRenderer::additionalRendering(std::shared_ptr<Mob> _mob, float a) {
|
|||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
// 4J-PB
|
||||
// if (bindTexture(mob->cloakTexture, L"" ))
|
||||
|
||||
// 4J: removed
|
||||
/*boolean loaded = mob->getCloakTexture()->isLoaded();
|
||||
boolean b1 = !mob->isInvisible();
|
||||
boolean b2 = !mob->isCapeHidden();*/
|
||||
if (bindTexture(mob->customTextureUrl2, L"") && !mob->isInvisible()) {
|
||||
glPushMatrix();
|
||||
glTranslatef(0, 0, 2 / 16.0f);
|
||||
|
|
@ -448,7 +375,7 @@ void PlayerRenderer::additionalRendering(std::shared_ptr<Mob> _mob, float a) {
|
|||
s *= 0.75f;
|
||||
glRotatef(20, 1, 0, 0);
|
||||
glRotatef(45, 0, 1, 0);
|
||||
glScalef(s, -s, s);
|
||||
glScalef(-s, -s, s);
|
||||
} else if (item->id == Item::bow->id) {
|
||||
float s = 10 / 16.0f;
|
||||
glTranslatef(0 / 16.0f, 2 / 16.0f, 5 / 16.0f);
|
||||
|
|
@ -495,6 +422,12 @@ void PlayerRenderer::additionalRendering(std::shared_ptr<Mob> _mob, float a) {
|
|||
mob, item, layer, false);
|
||||
}
|
||||
} else {
|
||||
int col = item->getItem()->getColor(item, 0);
|
||||
float red = ((col >> 16) & 0xff) / 255.0f;
|
||||
float g = ((col >> 8) & 0xff) / 255.0f;
|
||||
float b = ((col) & 0xff) / 255.0f;
|
||||
|
||||
glColor4f(red, g, b, 1);
|
||||
this->entityRenderDispatcher->itemInHandRenderer->renderItem(
|
||||
mob, item, 0);
|
||||
}
|
||||
|
|
@ -503,18 +436,53 @@ void PlayerRenderer::additionalRendering(std::shared_ptr<Mob> _mob, float a) {
|
|||
}
|
||||
}
|
||||
|
||||
void PlayerRenderer::scale(std::shared_ptr<Mob> player, float a) {
|
||||
void PlayerRenderer::renderNameTags(std::shared_ptr<LivingEntity> player,
|
||||
double x, double y, double z,
|
||||
std::wstring msg, float scale,
|
||||
double dist) {
|
||||
#if 0
|
||||
if (dist < 10 * 10)
|
||||
{
|
||||
Scoreboard *scoreboard = player->getScoreboard();
|
||||
Objective *objective = scoreboard->getDisplayObjective(Scoreboard::DISPLAY_SLOT_BELOW_NAME);
|
||||
|
||||
if (objective != NULL)
|
||||
{
|
||||
Score *score = scoreboard->getPlayerScore(player->getAName(), objective);
|
||||
|
||||
if (player->isSleeping())
|
||||
{
|
||||
renderNameTag(player, score->getScore() + " " + objective->getDisplayName(), x, y - 1.5f, z, 64);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderNameTag(player, score->getScore() + " " + objective->getDisplayName(), x, y, z, 64);
|
||||
}
|
||||
|
||||
y += getFont()->lineHeight * 1.15f * scale;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
LivingEntityRenderer::renderNameTags(player, x, y, z, msg, scale, dist);
|
||||
}
|
||||
|
||||
void PlayerRenderer::scale(std::shared_ptr<LivingEntity> player, float a) {
|
||||
float s = 15 / 16.0f;
|
||||
glScalef(s, s, s);
|
||||
}
|
||||
|
||||
void PlayerRenderer::renderHand() {
|
||||
float brightness = 1;
|
||||
glColor3f(brightness, brightness, brightness);
|
||||
|
||||
humanoidModel->m_uiAnimOverrideBitmask =
|
||||
Minecraft::GetInstance()->player->getAnimOverrideBitmask();
|
||||
armorParts1->eating = armorParts2->eating = humanoidModel->eating =
|
||||
humanoidModel->idle = false;
|
||||
humanoidModel->attackTime = 0;
|
||||
humanoidModel->setupAnim(0, 0, 0, 0, 0, 1 / 16.0f);
|
||||
humanoidModel->setupAnim(0, 0, 0, 0, 0, 1 / 16.0f,
|
||||
Minecraft::GetInstance()->player);
|
||||
// 4J-PB - does this skin have its arm0 disabled? (Dalek, etc)
|
||||
if ((humanoidModel->m_uiAnimOverrideBitmask &
|
||||
(1 << HumanoidModel::eAnim_DisableRenderArm0)) == 0) {
|
||||
|
|
@ -522,23 +490,27 @@ void PlayerRenderer::renderHand() {
|
|||
}
|
||||
}
|
||||
|
||||
void PlayerRenderer::setupPosition(std::shared_ptr<Mob> _mob, double x,
|
||||
void PlayerRenderer::setupPosition(std::shared_ptr<LivingEntity> _mob, double x,
|
||||
double y, double z) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
std::shared_ptr<Player> mob = std::dynamic_pointer_cast<Player>(_mob);
|
||||
|
||||
if (mob->isAlive() && mob->isSleeping()) {
|
||||
MobRenderer::setupPosition(mob, x + mob->bedOffsetX,
|
||||
y + mob->bedOffsetY, z + mob->bedOffsetZ);
|
||||
LivingEntityRenderer::setupPosition(
|
||||
mob, x + mob->bedOffsetX, y + mob->bedOffsetY, z + mob->bedOffsetZ);
|
||||
|
||||
} else {
|
||||
MobRenderer::setupPosition(mob, x, y, z);
|
||||
if (mob->isRiding() && (mob->getAnimOverrideBitmask() &
|
||||
(1 << HumanoidModel::eAnim_SmallModel)) != 0) {
|
||||
y += 0.5f;
|
||||
}
|
||||
LivingEntityRenderer::setupPosition(mob, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerRenderer::setupRotations(std::shared_ptr<Mob> _mob, float bob,
|
||||
float bodyRot, float a) {
|
||||
void PlayerRenderer::setupRotations(std::shared_ptr<LivingEntity> _mob,
|
||||
float bob, float bodyRot, float a) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
std::shared_ptr<Player> mob = std::dynamic_pointer_cast<Player>(_mob);
|
||||
|
|
@ -548,7 +520,7 @@ void PlayerRenderer::setupRotations(std::shared_ptr<Mob> _mob, float bob,
|
|||
glRotatef(getFlipDegrees(mob), 0, 0, 1);
|
||||
glRotatef(270, 0, 1, 0);
|
||||
} else {
|
||||
MobRenderer::setupRotations(mob, bob, bodyRot, a);
|
||||
LivingEntityRenderer::setupRotations(mob, bob, bodyRot, a);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -561,3 +533,15 @@ void PlayerRenderer::renderShadow(std::shared_ptr<Entity> e, double x, double y,
|
|||
}
|
||||
EntityRenderer::renderShadow(e, x, y, z, pow, a);
|
||||
}
|
||||
|
||||
// 4J Added override
|
||||
void PlayerRenderer::bindTexture(std::shared_ptr<Entity> entity) {
|
||||
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(entity);
|
||||
bindTexture(player->customTextureUrl, player->getTexture());
|
||||
}
|
||||
|
||||
ResourceLocation* PlayerRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> entity) {
|
||||
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(entity);
|
||||
return new ResourceLocation((_TEXTURE_NAME)player->getTexture());
|
||||
}
|
||||
|
|
@ -1,9 +1,14 @@
|
|||
#pragma once
|
||||
#include "MobRenderer.h"
|
||||
#include "../../../Minecraft.World/Player/Player.h"
|
||||
|
||||
class HumanoidModel;
|
||||
|
||||
class PlayerRenderer : public MobRenderer {
|
||||
class PlayerRenderer : public LivingEntityRenderer {
|
||||
public:
|
||||
// 4J: Made public for use in skull renderer
|
||||
static ResourceLocation DEFAULT_LOCATION;
|
||||
|
||||
private:
|
||||
// 4J Added
|
||||
static const unsigned int s_nametagColors[MINECRAFT_NET_MAX_PLAYERS];
|
||||
|
|
@ -21,31 +26,43 @@ private:
|
|||
static const std::wstring MATERIAL_NAMES[5];
|
||||
|
||||
protected:
|
||||
virtual int prepareArmor(std::shared_ptr<Mob> _player, int layer, float a);
|
||||
virtual void prepareSecondPassArmor(std::shared_ptr<Mob> mob, int layer,
|
||||
float a);
|
||||
virtual int prepareArmor(std::shared_ptr<LivingEntity> _player, int layer,
|
||||
float a);
|
||||
virtual void prepareSecondPassArmor(std::shared_ptr<LivingEntity> mob,
|
||||
int layer, float a);
|
||||
|
||||
public:
|
||||
virtual void render(std::shared_ptr<Entity> _mob, double x, double y,
|
||||
double z, float rot, float a);
|
||||
|
||||
protected:
|
||||
virtual void renderName(std::shared_ptr<Mob> _mob, double x, double y,
|
||||
double z);
|
||||
virtual void additionalRendering(std::shared_ptr<Mob> _mob, float a);
|
||||
virtual void scale(std::shared_ptr<Mob> _player, float a);
|
||||
virtual void additionalRendering(std::shared_ptr<LivingEntity> _mob,
|
||||
float a);
|
||||
void renderNameTags(std::shared_ptr<LivingEntity> player, double x,
|
||||
double y, double z, std::wstring msg, float scale,
|
||||
double dist);
|
||||
|
||||
virtual void scale(std::shared_ptr<LivingEntity> _player, float a);
|
||||
|
||||
public:
|
||||
void renderHand();
|
||||
|
||||
protected:
|
||||
virtual void setupPosition(std::shared_ptr<Mob> _mob, double x, double y,
|
||||
double z);
|
||||
virtual void setupRotations(std::shared_ptr<Mob> _mob, float bob,
|
||||
virtual void setupPosition(std::shared_ptr<LivingEntity> _mob, double x,
|
||||
double y, double z);
|
||||
virtual void setupRotations(std::shared_ptr<LivingEntity> _mob, float bob,
|
||||
float bodyRot, float a);
|
||||
|
||||
private:
|
||||
virtual void renderShadow(std::shared_ptr<Entity> e, double x, double y,
|
||||
double z, float pow,
|
||||
float a); // 4J Added override
|
||||
|
||||
public:
|
||||
virtual ResourceLocation* getTextureLocation(
|
||||
std::shared_ptr<Entity> entity);
|
||||
|
||||
using LivingEntityRenderer::bindTexture;
|
||||
virtual void bindTexture(
|
||||
std::shared_ptr<Entity> entity); // 4J Added override
|
||||
};
|
||||
|
|
@ -81,7 +81,7 @@ void ProgressRenderer::progressStagePercentage(int i) {
|
|||
}
|
||||
|
||||
|
||||
__int64 now = System::currentTimeMillis();
|
||||
int64_t now = System::currentTimeMillis();
|
||||
if (now - lastTime < 20) return;
|
||||
lastTime = now;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ private:
|
|||
int status;
|
||||
Minecraft* minecraft;
|
||||
int title;
|
||||
__int64 lastTime;
|
||||
int64_t lastTime;
|
||||
bool noAbort;
|
||||
std::wstring m_wstrText;
|
||||
eProgressStringType m_eType;
|
||||
|
|
|
|||
|
|
@ -3,12 +3,16 @@
|
|||
#include "../../Player/MultiPlayerLocalPlayer.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.animal.h"
|
||||
|
||||
ResourceLocation SheepRenderer::SHEEP_LOCATION = ResourceLocation(TN_MOB_SHEEP);
|
||||
ResourceLocation SheepRenderer::SHEEP_FUR_LOCATION =
|
||||
ResourceLocation(TN_MOB_SHEEP_FUR);
|
||||
|
||||
SheepRenderer::SheepRenderer(Model* model, Model* armor, float shadow)
|
||||
: MobRenderer(model, shadow) {
|
||||
setArmor(armor);
|
||||
}
|
||||
|
||||
int SheepRenderer::prepareArmor(std::shared_ptr<Mob> _sheep, int layer,
|
||||
int SheepRenderer::prepareArmor(std::shared_ptr<LivingEntity> _sheep, int layer,
|
||||
float a) {
|
||||
// 4J - dynamic cast required because we aren't using templates/generics in
|
||||
// our version
|
||||
|
|
@ -21,8 +25,31 @@ int SheepRenderer::prepareArmor(std::shared_ptr<Mob> _sheep, int layer,
|
|||
// sheep armour) in '1.7.5'.
|
||||
{
|
||||
MemSect(31);
|
||||
bindTexture(TN_MOB_SHEEP_FUR); // 4J was L"/mob/sheep_fur.png"
|
||||
bindTexture(&SHEEP_FUR_LOCATION);
|
||||
MemSect(0);
|
||||
|
||||
if (sheep->hasCustomName() &&
|
||||
sheep->getCustomName().compare(L"jeb_") == 0) {
|
||||
// easter egg...
|
||||
int colorDuration = 25;
|
||||
int value = (sheep->tickCount / colorDuration) + sheep->entityId;
|
||||
int c1 = value % Sheep::COLOR_LENGTH;
|
||||
int c2 = (value + 1) % Sheep::COLOR_LENGTH;
|
||||
float subStep =
|
||||
((sheep->tickCount % colorDuration) + a) / (float)colorDuration;
|
||||
|
||||
glColor3f(Sheep::COLOR[c1][0] * (1.0f - subStep) +
|
||||
Sheep::COLOR[c2][0] * subStep,
|
||||
Sheep::COLOR[c1][1] * (1.0f - subStep) +
|
||||
Sheep::COLOR[c2][1] * subStep,
|
||||
Sheep::COLOR[c1][2] * (1.0f - subStep) +
|
||||
Sheep::COLOR[c2][2] * subStep);
|
||||
} else {
|
||||
int color = sheep->getColor();
|
||||
glColor3f(Sheep::COLOR[color][0], Sheep::COLOR[color][1],
|
||||
Sheep::COLOR[color][2]);
|
||||
}
|
||||
|
||||
// 4J - change brought forward from 1.8.2
|
||||
float brightness =
|
||||
SharedConstants::TEXTURE_LIGHTING ? 1.0f : sheep->getBrightness(a);
|
||||
|
|
@ -39,3 +66,8 @@ void SheepRenderer::render(std::shared_ptr<Entity> mob, double x, double y,
|
|||
double z, float rot, float a) {
|
||||
MobRenderer::render(mob, x, y, z, rot, a);
|
||||
}
|
||||
|
||||
ResourceLocation* SheepRenderer::getTextureLocation(
|
||||
std::shared_ptr<Entity> mob) {
|
||||
return &SHEEP_LOCATION;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,19 @@
|
|||
#include "MobRenderer.h"
|
||||
|
||||
class SheepRenderer : public MobRenderer {
|
||||
private:
|
||||
static ResourceLocation SHEEP_LOCATION;
|
||||
static ResourceLocation SHEEP_FUR_LOCATION;
|
||||
|
||||
public:
|
||||
SheepRenderer(Model* model, Model* armor, float shadow);
|
||||
|
||||
protected:
|
||||
virtual int prepareArmor(std::shared_ptr<Mob> _sheep, int layer, float a);
|
||||
virtual int prepareArmor(std::shared_ptr<LivingEntity> _sheep, int layer,
|
||||
float a);
|
||||
|
||||
public:
|
||||
virtual void render(std::shared_ptr<Entity> mob, double x, double y,
|
||||
double z, float rot, float a);
|
||||
virtual ResourceLocation* getTextureLocation(std::shared_ptr<Entity> mob);
|
||||
};
|
||||
|
|
@ -7,6 +7,8 @@
|
|||
#include "../../../Minecraft.World/Entities/Entity.h"
|
||||
#include "../../../Minecraft.World/Level/Level.h"
|
||||
|
||||
ResourceLocation SignRenderer::SIGN_LOCATION = ResourceLocation(TN_ITEM_SIGN);
|
||||
|
||||
SignRenderer::SignRenderer() { signModel = new SignModel(); }
|
||||
|
||||
void SignRenderer::render(std::shared_ptr<TileEntity> _sign, double x, double y,
|
||||
|
|
@ -41,7 +43,7 @@ void SignRenderer::render(std::shared_ptr<TileEntity> _sign, double x, double y,
|
|||
signModel->cube2->visible = false;
|
||||
}
|
||||
|
||||
bindTexture(TN_ITEM_SIGN); // 4J was L"/item/sign.png"
|
||||
bindTexture(&SIGN_LOCATION); // 4J was L"/item/sign.png"
|
||||
|
||||
glPushMatrix();
|
||||
glScalef(size, -size, -size);
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue