- 151
- 0
Вопрос такой: какой класс отвечает за камеру игрока?(хочу вращать прост)
Хмм, но как-то же это у других реализовано, я смотрел код во флансе, и чет меня запутал этот весь ихний API, суровый, мне как новичку не особо все и понятно.может кто что-нибудь предложит, как реализоватьMrCreppo написал(а):Делал костылем диким. Но идея - хрень, отказался от нее. Направление взгляда привязано к энтитю - такой вид неправильно работает из-за этого.
Ну шейдеры есть на 180 что ли градусов или на 360.ElectroDans написал(а):Вопрос такой: какой класс отвечает за камеру игрока?(хочу вращать прост)
public void cacheActiveRenderInfo(World p_147938_1_, TextureManager p_147938_2_, FontRenderer p_147938_3_, EntityLivingBase p_147938_4_, Entity p_147938_5_, GameSettings p_147938_6_, float p_147938_7_)
{
this.worldObj = p_147938_1_;
this.renderEngine = p_147938_2_;
this.options = p_147938_6_;
this.livingPlayer = p_147938_4_;
this.field_147941_i = p_147938_5_;
this.fontRenderer = p_147938_3_;
if (p_147938_4_.isPlayerSleeping())
{
Block block = p_147938_1_.getBlock(MathHelper.floor_double(p_147938_4_.posX), MathHelper.floor_double(p_147938_4_.posY), MathHelper.floor_double(p_147938_4_.posZ));
int x = MathHelper.floor_double(p_147938_4_.posX);
int y = MathHelper.floor_double(p_147938_4_.posY);
int z = MathHelper.floor_double(p_147938_4_.posZ);
if (block.isBed(p_147938_1_, x, y, z, p_147938_4_))
{
int j = block.getBedDirection(p_147938_1_, x, y, z);
this.playerViewY = (float)(j * 90 + 180);
this.playerViewX = 0.0F;
}
}
else
{
this.playerViewY = p_147938_4_.prevRotationYaw + (p_147938_4_.rotationYaw - p_147938_4_.prevRotationYaw) * p_147938_7_;
this.playerViewX = p_147938_4_.prevRotationPitch + (p_147938_4_.rotationPitch - p_147938_4_.prevRotationPitch) * p_147938_7_;
}
if (p_147938_6_.thirdPersonView == 2)
{
this.playerViewY += 180.0F;
}
this.viewerPosX = p_147938_4_.lastTickPosX + (p_147938_4_.posX - p_147938_4_.lastTickPosX) * (double)p_147938_7_;
this.viewerPosY = p_147938_4_.lastTickPosY + (p_147938_4_.posY - p_147938_4_.lastTickPosY) * (double)p_147938_7_;
this.viewerPosZ = p_147938_4_.lastTickPosZ + (p_147938_4_.posZ - p_147938_4_.lastTickPosZ) * (double)p_147938_7_;
}
public void renderEntities(EntityLivingBase p_147589_1_, ICamera p_147589_2_, float p_147589_3_)
{
int pass = MinecraftForgeClient.getRenderPass();
if (this.renderEntitiesStartupCounter > 0)
{
if (pass > 0) return;
--this.renderEntitiesStartupCounter;
}
else
{
double d0 = p_147589_1_.prevPosX + (p_147589_1_.posX - p_147589_1_.prevPosX) * (double)p_147589_3_;
double d1 = p_147589_1_.prevPosY + (p_147589_1_.posY - p_147589_1_.prevPosY) * (double)p_147589_3_;
double d2 = p_147589_1_.prevPosZ + (p_147589_1_.posZ - p_147589_1_.prevPosZ) * (double)p_147589_3_;
this.theWorld.theProfiler.startSection("prepare");
TileEntityRendererDispatcher.instance.cacheActiveRenderInfo(this.theWorld, this.mc.getTextureManager(), this.mc.fontRenderer, this.mc.renderViewEntity, p_147589_3_);
RenderManager.instance.cacheActiveRenderInfo(this.theWorld, this.mc.getTextureManager(), this.mc.fontRenderer, this.mc.renderViewEntity, this.mc.pointedEntity, this.mc.gameSettings, p_147589_3_);
if (pass == 0) // no indentation to shrink patch
{
this.countEntitiesTotal = 0;
this.countEntitiesRendered = 0;
this.countEntitiesHidden = 0;
}
EntityLivingBase entitylivingbase1 = this.mc.renderViewEntity;
double d3 = entitylivingbase1.lastTickPosX + (entitylivingbase1.posX - entitylivingbase1.lastTickPosX) * (double)p_147589_3_;
double d4 = entitylivingbase1.lastTickPosY + (entitylivingbase1.posY - entitylivingbase1.lastTickPosY) * (double)p_147589_3_;
double d5 = entitylivingbase1.lastTickPosZ + (entitylivingbase1.posZ - entitylivingbase1.lastTickPosZ) * (double)p_147589_3_;
TileEntityRendererDispatcher.staticPlayerX = d3;
TileEntityRendererDispatcher.staticPlayerY = d4;
TileEntityRendererDispatcher.staticPlayerZ = d5;
this.theWorld.theProfiler.endStartSection("staticentities");
if (this.displayListEntitiesDirty)
{
RenderManager.renderPosX = 0.0D;
RenderManager.renderPosY = 0.0D;
RenderManager.renderPosZ = 0.0D;
this.rebuildDisplayListEntities();
}
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glPushMatrix();
GL11.glTranslated(-d3, -d4, -d5);
GL11.glCallList(this.displayListEntities);
GL11.glPopMatrix();
RenderManager.renderPosX = d3;
RenderManager.renderPosY = d4;
RenderManager.renderPosZ = d5;
this.mc.entityRenderer.enableLightmap((double)p_147589_3_);
this.theWorld.theProfiler.endStartSection("global");
List list = this.theWorld.getLoadedEntityList();
if (pass == 0) // no indentation for smaller patch size
{
this.countEntitiesTotal = list.size();
}
int i;
Entity entity;
for (i = 0; i < this.theWorld.weatherEffects.size(); ++i)
{
entity = (Entity)this.theWorld.weatherEffects.get(i);
if (!entity.shouldRenderInPass(pass)) continue;
++this.countEntitiesRendered;
if (entity.isInRangeToRender3d(d0, d1, d2))
{
RenderManager.instance.renderEntitySimple(entity, p_147589_3_);
}
}
this.theWorld.theProfiler.endStartSection("entities");
for (i = 0; i < list.size(); ++i)
{
entity = (Entity)list.get(i);
if (!entity.shouldRenderInPass(pass)) continue;
boolean flag = entity.isInRangeToRender3d(d0, d1, d2) && (entity.ignoreFrustumCheck || p_147589_2_.isBoundingBoxInFrustum(entity.boundingBox) || entity.riddenByEntity == this.mc.thePlayer);
if (!flag && entity instanceof EntityLiving)
{
EntityLiving entityliving = (EntityLiving)entity;
if (entityliving.getLeashed() && entityliving.getLeashedToEntity() != null)
{
Entity entity1 = entityliving.getLeashedToEntity();
flag = p_147589_2_.isBoundingBoxInFrustum(entity1.boundingBox);
}
}
if (flag && (entity != this.mc.renderViewEntity || this.mc.gameSettings.thirdPersonView != 0 || this.mc.renderViewEntity.isPlayerSleeping()) && this.theWorld.blockExists(MathHelper.floor_double(entity.posX), 0, MathHelper.floor_double(entity.posZ)))
{
++this.countEntitiesRendered;
RenderManager.instance.renderEntitySimple(entity, p_147589_3_);
}
}
this.theWorld.theProfiler.endStartSection("blockentities");
RenderHelper.enableStandardItemLighting();
for (i = 0; i < this.tileEntities.size(); ++i)
{
TileEntity tile = (TileEntity)this.tileEntities.get(i);
if (tile.shouldRenderInPass(pass) && p_147589_2_.isBoundingBoxInFrustum(tile.getRenderBoundingBox()))
{
TileEntityRendererDispatcher.instance.renderTileEntity(tile, p_147589_3_);
}
}
this.mc.entityRenderer.disableLightmap((double)p_147589_3_);
this.theWorld.theProfiler.endSection();
}
}