fix and improve camera system
This commit is contained in:
parent
a76c0c66e1
commit
72dc4a1305
15 changed files with 180 additions and 108 deletions
|
@ -111,9 +111,10 @@ import common.effect.StatusEffect;
|
|||
import common.entity.Entity;
|
||||
import common.entity.animal.EntityHorse;
|
||||
import common.entity.item.EntityCamera;
|
||||
import common.entity.item.EntityCamera.CameraType;
|
||||
import common.entity.item.EntityCart;
|
||||
import common.entity.npc.Energy;
|
||||
import common.entity.npc.EntityCpu;
|
||||
import common.entity.npc.EntityCameraHolder;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.npc.EntityWaterNPC;
|
||||
import common.entity.npc.PlayerCharacter;
|
||||
|
@ -431,6 +432,7 @@ public class Client implements IThreadListener {
|
|||
public boolean charEditor;
|
||||
public boolean fullscreen;
|
||||
public boolean interrupted;
|
||||
public boolean freecam;
|
||||
|
||||
private int leftClickCounter;
|
||||
private int rightClickTimer;
|
||||
|
@ -717,7 +719,7 @@ public class Client implements IThreadListener {
|
|||
this.dimensionName = "debug";
|
||||
Space.INSTANCE.setDisplay("Debug-Welt");
|
||||
this.controller = new PlayerController(this, player);
|
||||
this.loadWorld(Space.INSTANCE, EntityRegistry.getEntityID(EntityCpu.class));
|
||||
this.loadWorld(Space.INSTANCE, EntityRegistry.getEntityID(EntityCameraHolder.class));
|
||||
this.player.setId(0);
|
||||
this.show(null);
|
||||
this.player.flying = true;
|
||||
|
@ -737,6 +739,7 @@ public class Client implements IThreadListener {
|
|||
this.debugWorld = false;
|
||||
this.charEditor = false;
|
||||
this.viewEntity = null;
|
||||
this.freecam = false;
|
||||
this.connection = null;
|
||||
this.world = null;
|
||||
this.resetWorld();
|
||||
|
@ -1644,6 +1647,7 @@ public class Client implements IThreadListener {
|
|||
{
|
||||
this.resetWorld();
|
||||
this.viewEntity = null;
|
||||
this.freecam = false;
|
||||
this.connection = null;
|
||||
this.soundManager.stopSounds();
|
||||
this.world = new WorldClient(dim);
|
||||
|
@ -1691,6 +1695,7 @@ public class Client implements IThreadListener {
|
|||
this.player = this.controller.createPlayerEntity(this.world, type);
|
||||
this.player.getDataWatcher().updateWatchedObjectsFromList(entityplayersp.getDataWatcher().getAllWatched());
|
||||
this.viewEntity = this.player;
|
||||
this.freecam = false;
|
||||
this.player.preparePlayerToSpawn();
|
||||
this.spawnEntity(this.player);
|
||||
this.player.rotYaw = -180.0F;
|
||||
|
@ -1750,6 +1755,7 @@ public class Client implements IThreadListener {
|
|||
public void setRenderViewEntity(Entity viewingEntity)
|
||||
{
|
||||
this.viewEntity = viewingEntity;
|
||||
this.freecam = false;
|
||||
}
|
||||
|
||||
public void schedule(Runnable task) {
|
||||
|
@ -1838,8 +1844,12 @@ public class Client implements IThreadListener {
|
|||
if(this.viewEntity instanceof EntityCamera camera) {
|
||||
camera.onUpdate();
|
||||
camera.setMovement(this.moveStrafe, this.moveForward, this.jump, this.sneak);
|
||||
this.getNetHandler().addToSendQueue(new CPacketInput(this.moveStrafe, this.moveForward, this.jump, this.sneak, true));
|
||||
this.getNetHandler().addToSendQueue(new CPacketPlayerPosLook(camera.posX, camera.posY, camera.posZ, camera.rotYaw, camera.rotPitch, this.sprint).setCamera());
|
||||
if(!this.freecam) {
|
||||
this.getNetHandler().addToSendQueue(new CPacketInput(this.moveStrafe, this.moveForward, this.jump, this.sneak, true));
|
||||
this.getNetHandler().addToSendQueue(new CPacketPlayerPosLook(camera.posX, camera.posY, camera.posZ, camera.rotYaw, camera.rotPitch, this.sprint).setCamera());
|
||||
if(this.player != null)
|
||||
this.player.setPositionAndRotation(camera.posX, camera.posY, camera.posZ, camera.rotYaw, camera.rotPitch);
|
||||
}
|
||||
// if(!camera.fixed && this.sprint)
|
||||
// this.viewEntity = this.player;
|
||||
}
|
||||
|
@ -2723,6 +2733,16 @@ public class Client implements IThreadListener {
|
|||
}
|
||||
}
|
||||
});
|
||||
if(Util.DEVMODE)
|
||||
this.registerDebug(Keysym.SPACE, "Kamera umschalten", new DebugRunner() {
|
||||
public void execute(Keysym key) {
|
||||
if(Client.this.world != null && Client.this.player != null) {
|
||||
Client.this.viewEntity = Client.this.viewEntity == Client.this.player ? new EntityCamera(Client.this.world,
|
||||
Client.this.player.posX, Client.this.player.posY, Client.this.player.posZ, Client.this.player.rotYaw, Client.this.player.rotPitch, 256, 2.5f, CameraType.FREE, false) : Client.this.player;
|
||||
Client.this.freecam = Client.this.viewEntity != Client.this.player;
|
||||
}
|
||||
}
|
||||
});
|
||||
if(Util.DEVMODE)
|
||||
this.registerDebug(Keysym.AE, "Programm sofort beenden und server beenden", new DebugRunner() {
|
||||
public void execute(Keysym key) {
|
||||
|
|
|
@ -11,6 +11,7 @@ import client.gui.element.PressType;
|
|||
import client.gui.options.GuiOptions;
|
||||
import client.renderer.Drawing;
|
||||
import client.window.Keysym;
|
||||
import common.entity.npc.EntityCameraHolder;
|
||||
import common.rng.Random;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Color;
|
||||
|
@ -112,7 +113,7 @@ public class GuiMenu extends Gui {
|
|||
this.add(new NavButton(0, 0, 180, 0, this.gm.charEditor ? GuiChar.INSTANCE : null, this.gm.charEditor ? "Zurück zum Editor" : "Zurück zum Spiel"));
|
||||
this.add(new NavButton(0, 20, 180, 0, GuiOptions.getPage(), "Einstellungen"));
|
||||
if(!this.gm.charEditor)
|
||||
this.add(new NavButton(0, 40, 180, 0, GuiCharacters.INSTANCE, "Charakter"));
|
||||
this.add(new NavButton(0, 40, 180, 0, GuiCharacters.INSTANCE, "Charakter")).enabled = !(this.gm.player instanceof EntityCameraHolder);
|
||||
this.add(new ActButton(0, this.gm.charEditor ? 50 : 70, 180, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType action) {
|
||||
GuiMenu.this.gm.unload(true);
|
||||
|
|
|
@ -9,6 +9,7 @@ import client.renderer.entity.RenderBat;
|
|||
import client.renderer.entity.RenderBlockEntity;
|
||||
import client.renderer.entity.RenderBoat;
|
||||
import client.renderer.entity.RenderBullet;
|
||||
import client.renderer.entity.RenderCamera;
|
||||
import client.renderer.entity.RenderChicken;
|
||||
import client.renderer.entity.RenderCow;
|
||||
import client.renderer.entity.RenderCrystal;
|
||||
|
@ -85,6 +86,7 @@ import common.entity.item.EntityOrb;
|
|||
import common.entity.item.EntityTnt;
|
||||
import common.entity.item.EntityTntCart;
|
||||
import common.entity.item.EntityXp;
|
||||
import common.entity.npc.EntityCameraHolder;
|
||||
import common.entity.npc.SpeciesInfo;
|
||||
import common.entity.projectile.EntityArrow;
|
||||
import common.entity.projectile.EntityBox;
|
||||
|
@ -150,6 +152,7 @@ public abstract class RenderRegistry {
|
|||
models.put(ModelType.DWARF, new RenderHumanoid(mgr, 10, 10, "textures/npc/dwarf.png"));
|
||||
models.put(ModelType.HALFLING, new RenderHumanoid(mgr, 8, 8, "textures/npc/goblin.png"));
|
||||
models.put(ModelType.SPACE_MARINE, new RenderSpaceMarine(mgr));
|
||||
map.put(EntityCameraHolder.class, new RenderCamera(mgr));
|
||||
for(int z = 0; z < SpeciesRegistry.SPECIMEN.size(); z++) {
|
||||
SpeciesInfo info = SpeciesRegistry.SPECIMEN.get(z);
|
||||
map.put(info.clazz, models.get(info.renderer));
|
||||
|
|
|
@ -48,6 +48,7 @@ import common.collect.Sets;
|
|||
import common.dimension.DimType;
|
||||
import common.effect.Effect;
|
||||
import common.entity.Entity;
|
||||
import common.entity.npc.EntityCameraHolder;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.types.EntityAnimal;
|
||||
import common.entity.types.EntityLiving;
|
||||
|
@ -1280,7 +1281,7 @@ public class Renderer {
|
|||
this.renderCloudsCheck(partialTicks);
|
||||
}
|
||||
|
||||
if (entity == this.gm.player)
|
||||
if (entity == this.gm.player && !(this.gm.player instanceof EntityCameraHolder))
|
||||
{
|
||||
GL11.glClear(256);
|
||||
this.renderHand(partialTicks);
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package client.renderer.entity;
|
||||
|
||||
import common.entity.npc.EntityNPC;
|
||||
|
||||
public class RenderCamera extends RenderNpc {
|
||||
public RenderCamera(RenderManager renderManagerIn) {
|
||||
super(renderManagerIn, null);
|
||||
}
|
||||
|
||||
public void doRender(EntityNPC entity, double x, double y, double z, float partialTicks) {
|
||||
}
|
||||
|
||||
public String getDefaultTexture() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void getSegments(TexList opaque, TexList alpha) {
|
||||
}
|
||||
|
||||
public void getHeadUVs(CoordList list) {
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue