streaming creature templates over network
This commit is contained in:
parent
db8024232f
commit
2c42b51907
@ -61,11 +61,11 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name" : "realLocationX",
|
"name" : "realLocationX",
|
||||||
"type" : "FIXED_FLOAT"
|
"type" : "FIXED_DOUBLE"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name" : "realLocationY",
|
"name" : "realLocationY",
|
||||||
"type" : "FIXED_FLOAT"
|
"type" : "FIXED_DOUBLE"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -250,7 +250,9 @@ public class LoadingThread extends Thread {
|
|||||||
//initialize the basic graphical entities of the world (skybox, camera)
|
//initialize the basic graphical entities of the world (skybox, camera)
|
||||||
initWorldBaseGraphicalEntities();
|
initWorldBaseGraphicalEntities();
|
||||||
//init arena specific stuff (ie different skybox colors)
|
//init arena specific stuff (ie different skybox colors)
|
||||||
initArenaGraphicalEntities();
|
if(!Globals.RUN_SERVER){
|
||||||
|
initArenaGraphicalEntities();
|
||||||
|
}
|
||||||
//sets micro and macro sims to ready if they exist
|
//sets micro and macro sims to ready if they exist
|
||||||
if(!Globals.RUN_SERVER){
|
if(!Globals.RUN_SERVER){
|
||||||
setSimulationsToReady();
|
setSimulationsToReady();
|
||||||
@ -356,7 +358,7 @@ public class LoadingThread extends Thread {
|
|||||||
|
|
||||||
static void initServerArenaWorldData(){
|
static void initServerArenaWorldData(){
|
||||||
Globals.serverWorldData = ServerWorldData.createArenaWorld();
|
Globals.serverWorldData = ServerWorldData.createArenaWorld();
|
||||||
Globals.spawnPoint = new Vector3f(1,0.1f,1);
|
Globals.spawnPoint = new Vector3d(1,2.0,1);
|
||||||
// Globals.serverTerrainManager.getChunk(0, 0).addModification(new TerrainModification(0,0,5,5,5));
|
// Globals.serverTerrainManager.getChunk(0, 0).addModification(new TerrainModification(0,0,5,5,5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -174,11 +174,11 @@ public class CollisionObjUtils {
|
|||||||
return (CollisionObject)e.getData(EntityDataStrings.PHYSICS_COLLISION_BODY);
|
return (CollisionObject)e.getData(EntityDataStrings.PHYSICS_COLLISION_BODY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void positionCharacter(Entity e, Vector3f position){
|
public static void positionCharacter(Entity e, Vector3d position){
|
||||||
EntityUtils.getPosition(e).set(position);
|
EntityUtils.getPosition(e).set(position);
|
||||||
Quaternionf rotation = EntityUtils.getRotation(e);
|
Quaternionf rotation = EntityUtils.getRotation(e);
|
||||||
CollisionObject body = getCollisionBody(e);
|
CollisionObject body = getCollisionBody(e);
|
||||||
PhysicsUtils.setRigidBodyTransform(position, rotation, body);
|
PhysicsUtils.setRigidBodyTransform(new Vector3f((float)position.x,(float)position.y,(float)position.z), rotation, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collidable getCollidable(Entity e){
|
public static Collidable getCollidable(Entity e){
|
||||||
|
|||||||
@ -517,7 +517,8 @@ public class CreatureUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//reposition entity
|
//reposition entity
|
||||||
CollisionObjUtils.positionCharacter(creature, new Vector3f(Globals.spawnPoint.x,Globals.spawnPoint.y,Globals.spawnPoint.z));
|
// CreatureUtils.repositionCreature(creature, Globals.spawnPoint);
|
||||||
|
CollisionObjUtils.positionCharacter(creature, Globals.spawnPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,8 @@ import electrosphere.entity.types.collision.CollisionObjUtils;
|
|||||||
import electrosphere.entity.types.creature.CreatureUtils;
|
import electrosphere.entity.types.creature.CreatureUtils;
|
||||||
import electrosphere.entity.types.item.ItemUtils;
|
import electrosphere.entity.types.item.ItemUtils;
|
||||||
import electrosphere.game.server.ai.creature.MillAbout;
|
import electrosphere.game.server.ai.creature.MillAbout;
|
||||||
|
|
||||||
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,7 +19,7 @@ public class UnitUtils {
|
|||||||
|
|
||||||
public static void spawnTextGoblin(float posX, float posY, float posZ){
|
public static void spawnTextGoblin(float posX, float posY, float posZ){
|
||||||
Entity goblin = CreatureUtils.spawnBasicCreature("Goblin",null);
|
Entity goblin = CreatureUtils.spawnBasicCreature("Goblin",null);
|
||||||
CollisionObjUtils.positionCharacter(goblin, new Vector3f(posX, posY, posZ));
|
CollisionObjUtils.positionCharacter(goblin, new Vector3d(posX, posY, posZ));
|
||||||
EntityUtils.getScale(goblin).set(0.005f);
|
EntityUtils.getScale(goblin).set(0.005f);
|
||||||
//give evil goblin sword
|
//give evil goblin sword
|
||||||
Entity goblinSword = ItemUtils.spawnBasicItem("Katana");
|
Entity goblinSword = ItemUtils.spawnBasicItem("Katana");
|
||||||
|
|||||||
@ -70,6 +70,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
import electrosphere.util.ModelLoader;
|
import electrosphere.util.ModelLoader;
|
||||||
import electrosphere.util.Utilities;
|
import electrosphere.util.Utilities;
|
||||||
@ -249,7 +250,7 @@ public class Globals {
|
|||||||
//terrain manager
|
//terrain manager
|
||||||
// public static boolean LOAD_TERRAIN = true;
|
// public static boolean LOAD_TERRAIN = true;
|
||||||
public static ServerTerrainManager serverTerrainManager;
|
public static ServerTerrainManager serverTerrainManager;
|
||||||
public static Vector3f spawnPoint = new Vector3f(0,0,0);
|
public static Vector3d spawnPoint = new Vector3d(0,0,0);
|
||||||
|
|
||||||
//manages all models loaded into memory
|
//manages all models loaded into memory
|
||||||
public static AssetManager assetManager;
|
public static AssetManager assetManager;
|
||||||
|
|||||||
@ -104,8 +104,6 @@ public class MenuGeneratorsMultiplayer {
|
|||||||
ActorPanel actorPanel = new ActorPanel(1200, 100, 500, 500, characterActor);
|
ActorPanel actorPanel = new ActorPanel(1200, 100, 500, 500, characterActor);
|
||||||
actorPanel.setAnimation(Animation.ANIMATION_IDLE_1);
|
actorPanel.setAnimation(Animation.ANIMATION_IDLE_1);
|
||||||
actorPanel.setPosition(new Vector3f(0,-1,-0.5f));
|
actorPanel.setPosition(new Vector3f(0,-1,-0.5f));
|
||||||
RenderingEngine.setFOV(50);
|
|
||||||
RenderingEngine.setAspectRatio(1.0f);
|
|
||||||
// actorPanel.setRotation(new Quaternionf().rotateLocalY(0));
|
// actorPanel.setRotation(new Quaternionf().rotateLocalY(0));
|
||||||
actorPanel.setScale(new Vector3f(0.01f,0.01f,0.01f));
|
actorPanel.setScale(new Vector3f(0.01f,0.01f,0.01f));
|
||||||
|
|
||||||
|
|||||||
@ -11,8 +11,8 @@ public class CharacterProtocol {
|
|||||||
switch(message.getMessageSubtype()){
|
switch(message.getMessageSubtype()){
|
||||||
case RESPONSECREATECHARACTERSUCCESS:
|
case RESPONSECREATECHARACTERSUCCESS:
|
||||||
//trigger request to spawn character
|
//trigger request to spawn character
|
||||||
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage());
|
|
||||||
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestSpawnCharacterMessage());
|
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestSpawnCharacterMessage());
|
||||||
|
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage());
|
||||||
LoadingThread clientThread = new LoadingThread(LoadingThread.LOAD_CLIENT_WORLD);
|
LoadingThread clientThread = new LoadingThread(LoadingThread.LOAD_CLIENT_WORLD);
|
||||||
Globals.loadingThreadsList.add(clientThread);
|
Globals.loadingThreadsList.add(clientThread);
|
||||||
clientThread.start();
|
clientThread.start();
|
||||||
|
|||||||
@ -36,7 +36,7 @@ public class EntityProtocol {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SPAWNCREATURE:
|
case SPAWNCREATURE:
|
||||||
LoggerInterface.loggerNetworking.DEBUG("Spawn ID " + message.getentityID() + " of type " + message.getentityCategory() + " subtype " + message.getentitySubtype());
|
LoggerInterface.loggerNetworking.DEBUG("Spawn Creature " + message.getentityID() + " at " + message.getpositionX() + " " + message.getpositionY() + " " + message.getpositionZ());
|
||||||
CreatureTemplate template = Utilities.deserialize(message.getcreatureTemplate(), CreatureTemplate.class);
|
CreatureTemplate template = Utilities.deserialize(message.getcreatureTemplate(), CreatureTemplate.class);
|
||||||
newlySpawnedEntity = CreatureUtils.spawnBasicCreature(template.getCreatureType(),template);
|
newlySpawnedEntity = CreatureUtils.spawnBasicCreature(template.getCreatureType(),template);
|
||||||
EntityUtils.getScale(newlySpawnedEntity).set(0.005f);
|
EntityUtils.getScale(newlySpawnedEntity).set(0.005f);
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package electrosphere.net.client.protocol;
|
package electrosphere.net.client.protocol;
|
||||||
|
|
||||||
|
import javax.vecmath.Vector3d;
|
||||||
|
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
import electrosphere.game.client.world.ClientWorldData;
|
import electrosphere.game.client.world.ClientWorldData;
|
||||||
@ -26,7 +28,7 @@ public class TerrainProtocol {
|
|||||||
Globals.clientTerrainManager.attachTerrainMessage(message);
|
Globals.clientTerrainManager.attachTerrainMessage(message);
|
||||||
break;
|
break;
|
||||||
case SPAWNPOSITION:
|
case SPAWNPOSITION:
|
||||||
Globals.spawnPoint.set(new Vector3f(message.getrealLocationX(),0.25f,message.getrealLocationY()));
|
Globals.spawnPoint.set(message.getrealLocationX(),0.25,message.getrealLocationY());
|
||||||
break;
|
break;
|
||||||
case CHUNKLOADSTART:
|
case CHUNKLOADSTART:
|
||||||
Globals.clientTerrainManager.attachTerrainMessage(message);
|
Globals.clientTerrainManager.attachTerrainMessage(message);
|
||||||
|
|||||||
@ -30,8 +30,8 @@ public class TerrainMessage extends NetworkMessage {
|
|||||||
float value;
|
float value;
|
||||||
int locationX;
|
int locationX;
|
||||||
int locationY;
|
int locationY;
|
||||||
float realLocationX;
|
double realLocationX;
|
||||||
float realLocationY;
|
double realLocationY;
|
||||||
float macroValue00;
|
float macroValue00;
|
||||||
float macroValue01;
|
float macroValue01;
|
||||||
float macroValue02;
|
float macroValue02;
|
||||||
@ -188,19 +188,19 @@ public class TerrainMessage extends NetworkMessage {
|
|||||||
this.locationY = locationY;
|
this.locationY = locationY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getrealLocationX() {
|
public double getrealLocationX() {
|
||||||
return realLocationX;
|
return realLocationX;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setrealLocationX(float realLocationX) {
|
public void setrealLocationX(double realLocationX) {
|
||||||
this.realLocationX = realLocationX;
|
this.realLocationX = realLocationX;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getrealLocationY() {
|
public double getrealLocationY() {
|
||||||
return realLocationY;
|
return realLocationY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setrealLocationY(float realLocationY) {
|
public void setrealLocationY(double realLocationY) {
|
||||||
this.realLocationY = realLocationY;
|
this.realLocationY = realLocationY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -892,12 +892,12 @@ public class TerrainMessage extends NetworkMessage {
|
|||||||
public static TerrainMessage parseSpawnPositionMessage(List<Byte> byteStream){
|
public static TerrainMessage parseSpawnPositionMessage(List<Byte> byteStream){
|
||||||
TerrainMessage rVal = new TerrainMessage(TerrainMessageType.SPAWNPOSITION);
|
TerrainMessage rVal = new TerrainMessage(TerrainMessageType.SPAWNPOSITION);
|
||||||
stripPacketHeader(byteStream);
|
stripPacketHeader(byteStream);
|
||||||
rVal.setrealLocationX(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setrealLocationX(ByteStreamUtils.popDoubleFromByteQueue(byteStream));
|
||||||
rVal.setrealLocationY(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setrealLocationY(ByteStreamUtils.popDoubleFromByteQueue(byteStream));
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TerrainMessage constructSpawnPositionMessage(float realLocationX,float realLocationY){
|
public static TerrainMessage constructSpawnPositionMessage(double realLocationX,double realLocationY){
|
||||||
TerrainMessage rVal = new TerrainMessage(TerrainMessageType.SPAWNPOSITION);
|
TerrainMessage rVal = new TerrainMessage(TerrainMessageType.SPAWNPOSITION);
|
||||||
rVal.setrealLocationX(realLocationX);
|
rVal.setrealLocationX(realLocationX);
|
||||||
rVal.setrealLocationY(realLocationY);
|
rVal.setrealLocationY(realLocationY);
|
||||||
@ -1216,18 +1216,20 @@ public class TerrainMessage extends NetworkMessage {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SPAWNPOSITION:
|
case SPAWNPOSITION:
|
||||||
rawBytes = new byte[2+4+4];
|
rawBytes = new byte[2+8+8];
|
||||||
//message header
|
//message header
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_TERRAIN;
|
rawBytes[0] = TypeBytes.MESSAGE_TYPE_TERRAIN;
|
||||||
//entity messaage header
|
//entity messaage header
|
||||||
rawBytes[1] = TypeBytes.TERRAIN_MESSAGE_TYPE_SPAWNPOSITION;
|
rawBytes[1] = TypeBytes.TERRAIN_MESSAGE_TYPE_SPAWNPOSITION;
|
||||||
intValues = ByteStreamUtils.serializeFloatToBytes(realLocationX);
|
intValues = ByteStreamUtils.serializeDoubleToBytes(realLocationX);
|
||||||
for(int i = 0; i < 4; i++){
|
for(int i = 0; i < 8; i++){
|
||||||
rawBytes[2+i] = intValues[i];
|
rawBytes[2+i] = intValues[i];
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(realLocationY);
|
}
|
||||||
for(int i = 0; i < 4; i++){
|
intValues = ByteStreamUtils.serializeDoubleToBytes(realLocationY);
|
||||||
rawBytes[6+i] = intValues[i];
|
for(int i = 0; i < 8; i++){
|
||||||
} break;
|
rawBytes[10+i] = intValues[i];
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
serialized = true;
|
serialized = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,7 +84,7 @@ Message categories
|
|||||||
public static final byte TERRAIN_MESSAGE_TYPE_CHUNKLOADSTART_SIZE = 14;
|
public static final byte TERRAIN_MESSAGE_TYPE_CHUNKLOADSTART_SIZE = 14;
|
||||||
public static final short TERRAIN_MESSAGE_TYPE_MACROVALUE_SIZE = 310;
|
public static final short TERRAIN_MESSAGE_TYPE_MACROVALUE_SIZE = 310;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_HEIGHTMAPMODIFICATION_SIZE = 22;
|
public static final byte TERRAIN_MESSAGE_TYPE_HEIGHTMAPMODIFICATION_SIZE = 22;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_SPAWNPOSITION_SIZE = 10;
|
public static final byte TERRAIN_MESSAGE_TYPE_SPAWNPOSITION_SIZE = 18;
|
||||||
/*
|
/*
|
||||||
Server subcategories
|
Server subcategories
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -167,6 +167,8 @@ public class ServerConnectionHandler implements Runnable {
|
|||||||
networkParser.addOutgoingMessage(message);
|
networkParser.addOutgoingMessage(message);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case SPAWNCREATURE:
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
networkParser.addOutgoingMessage(message);
|
networkParser.addOutgoingMessage(message);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -17,10 +17,6 @@ public class EntityProtocol {
|
|||||||
protected static void handleEntityMessage(ServerConnectionHandler connectionHandler, EntityMessage message){
|
protected static void handleEntityMessage(ServerConnectionHandler connectionHandler, EntityMessage message){
|
||||||
Entity targetEntity;
|
Entity targetEntity;
|
||||||
switch(message.getMessageSubtype()){
|
switch(message.getMessageSubtype()){
|
||||||
case CREATE:
|
|
||||||
break;
|
|
||||||
case DESTROY:
|
|
||||||
break;
|
|
||||||
case MOVE:
|
case MOVE:
|
||||||
targetEntity = Globals.entityManager.getEntityFromId(message.getentityID());
|
targetEntity = Globals.entityManager.getEntityFromId(message.getentityID());
|
||||||
if(targetEntity != null){
|
if(targetEntity != null){
|
||||||
@ -42,6 +38,10 @@ public class EntityProtocol {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//ignore stack
|
//ignore stack
|
||||||
|
case KILL:
|
||||||
|
case SPAWNCREATURE:
|
||||||
|
case DESTROY:
|
||||||
|
case CREATE:
|
||||||
case ATTACHENTITYTOENTITY:
|
case ATTACHENTITYTOENTITY:
|
||||||
case SETFACING:
|
case SETFACING:
|
||||||
case SETPOSITION:
|
case SETPOSITION:
|
||||||
|
|||||||
@ -198,6 +198,10 @@ public class RenderingEngine {
|
|||||||
ShaderProgram activeProgram;
|
ShaderProgram activeProgram;
|
||||||
|
|
||||||
static int outputFramebuffer = 0;
|
static int outputFramebuffer = 0;
|
||||||
|
|
||||||
|
//used in calculating projection matrix
|
||||||
|
static float aspectRatio = 1.0f;
|
||||||
|
static float verticalFOV = 90.0f;
|
||||||
|
|
||||||
|
|
||||||
public void createOpenglContext(){
|
public void createOpenglContext(){
|
||||||
@ -388,10 +392,11 @@ public class RenderingEngine {
|
|||||||
//
|
//
|
||||||
Globals.projectionMatrix = new Matrix4f();
|
Globals.projectionMatrix = new Matrix4f();
|
||||||
Globals.viewMatrix = new Matrix4f();
|
Globals.viewMatrix = new Matrix4f();
|
||||||
float verticalFOV = (float)(Globals.verticalFOV * Math.PI /180.0f);
|
verticalFOV = (float)(Globals.verticalFOV * Math.PI /180.0f);
|
||||||
float aspectRatio = (float)Globals.WINDOW_WIDTH / (float)Globals.WINDOW_HEIGHT;
|
//set local aspect ratio and global aspect ratio at the same time
|
||||||
|
aspectRatio = Globals.aspectRatio = Globals.WINDOW_WIDTH / (float)Globals.WINDOW_HEIGHT;
|
||||||
float nearClip = 0.001f;
|
float nearClip = 0.001f;
|
||||||
Globals.projectionMatrix.setPerspective(verticalFOV, aspectRatio, nearClip, Globals.userSettings.getGraphicsViewDistance());
|
Globals.projectionMatrix.setPerspective(verticalFOV, Globals.aspectRatio, nearClip, Globals.userSettings.getGraphicsViewDistance());
|
||||||
Globals.viewMatrix.translation(new Vector3f(0.0f,0.0f,-3.0f));
|
Globals.viewMatrix.translation(new Vector3f(0.0f,0.0f,-3.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1314,19 +1319,19 @@ public class RenderingEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setFOV(float verticalFOV){
|
public static void setFOV(float verticalFOV){
|
||||||
Globals.verticalFOV = verticalFOV;
|
RenderingEngine.verticalFOV = verticalFOV;
|
||||||
calculateProjectionMatrix();
|
calculateProjectionMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setAspectRatio(float aspectRatio){
|
public static void setAspectRatio(float aspectRatio){
|
||||||
Globals.aspectRatio = aspectRatio;
|
RenderingEngine.aspectRatio = aspectRatio;
|
||||||
calculateProjectionMatrix();
|
calculateProjectionMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void calculateProjectionMatrix(){
|
static void calculateProjectionMatrix(){
|
||||||
float radVerticalFOV = (float)(Globals.verticalFOV * Math.PI /180.0f);
|
float radVerticalFOV = (float)(RenderingEngine.verticalFOV * Math.PI /180.0f);
|
||||||
float nearClip = 0.001f;
|
float nearClip = 0.001f;
|
||||||
Globals.projectionMatrix.setPerspective(radVerticalFOV, Globals.aspectRatio, nearClip, Globals.userSettings.getGraphicsViewDistance());
|
Globals.projectionMatrix.setPerspective(radVerticalFOV, RenderingEngine.aspectRatio, nearClip, Globals.userSettings.getGraphicsViewDistance());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import electrosphere.main.Globals;
|
|||||||
import electrosphere.main.Main;
|
import electrosphere.main.Main;
|
||||||
import electrosphere.renderer.Material;
|
import electrosphere.renderer.Material;
|
||||||
import electrosphere.renderer.Model;
|
import electrosphere.renderer.Model;
|
||||||
|
import electrosphere.renderer.RenderingEngine;
|
||||||
import electrosphere.renderer.actor.Actor;
|
import electrosphere.renderer.actor.Actor;
|
||||||
import electrosphere.renderer.framebuffer.Framebuffer;
|
import electrosphere.renderer.framebuffer.Framebuffer;
|
||||||
import electrosphere.renderer.framebuffer.FramebufferUtils;
|
import electrosphere.renderer.framebuffer.FramebufferUtils;
|
||||||
@ -43,6 +44,8 @@ public class ActorPanel implements DrawableElement, DraggableElement {
|
|||||||
Vector3f actorPosition = new Vector3f(0,0,0);
|
Vector3f actorPosition = new Vector3f(0,0,0);
|
||||||
Quaternionf actorRotation = new Quaternionf();
|
Quaternionf actorRotation = new Quaternionf();
|
||||||
Vector3f actorScale = new Vector3f(1,1,1);
|
Vector3f actorScale = new Vector3f(1,1,1);
|
||||||
|
float FOV = 50.0f;
|
||||||
|
float aspectRatio = 1.9f;
|
||||||
|
|
||||||
|
|
||||||
Vector3f texPosition = new Vector3f(0,0,0);
|
Vector3f texPosition = new Vector3f(0,0,0);
|
||||||
@ -60,6 +63,7 @@ public class ActorPanel implements DrawableElement, DraggableElement {
|
|||||||
this.positionY = y;
|
this.positionY = y;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
this.aspectRatio = (float)width / (float)height;
|
||||||
recalculateModelMatrix();
|
recalculateModelMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +74,9 @@ public class ActorPanel implements DrawableElement, DraggableElement {
|
|||||||
|
|
||||||
elementBuffer.bind();
|
elementBuffer.bind();
|
||||||
// Globals.renderingEngine.setViewportSize(width, height);
|
// Globals.renderingEngine.setViewportSize(width, height);
|
||||||
|
|
||||||
|
RenderingEngine.setFOV(FOV);
|
||||||
|
RenderingEngine.setAspectRatio(aspectRatio);
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDepthFunc(GL_LESS);
|
glDepthFunc(GL_LESS);
|
||||||
@ -89,6 +96,9 @@ public class ActorPanel implements DrawableElement, DraggableElement {
|
|||||||
actor.applyModelMatrix(modelMatrix);
|
actor.applyModelMatrix(modelMatrix);
|
||||||
actor.draw(true);
|
actor.draw(true);
|
||||||
|
|
||||||
|
RenderingEngine.setFOV(Globals.verticalFOV);
|
||||||
|
RenderingEngine.setAspectRatio(Globals.aspectRatio);
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
//this call binds the screen as the "texture" we're rendering to
|
//this call binds the screen as the "texture" we're rendering to
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user