you used to call me on your cell phone
This commit is contained in:
parent
f212c6f3d8
commit
9281706d53
4 changed files with 106 additions and 42 deletions
Binary file not shown.
|
|
@ -15,10 +15,7 @@ import net.halbear.Terrain4J.EngineCore.Input.KeyboardInput;
|
||||||
import net.halbear.Terrain4J.EngineCore.Input.MouseListener;
|
import net.halbear.Terrain4J.EngineCore.Input.MouseListener;
|
||||||
import net.halbear.Terrain4J.EngineCore.Logic.*;
|
import net.halbear.Terrain4J.EngineCore.Logic.*;
|
||||||
import net.halbear.Terrain4J.EngineCore.Logic.Rendering.ModelLoader;
|
import net.halbear.Terrain4J.EngineCore.Logic.Rendering.ModelLoader;
|
||||||
import net.halbear.Terrain4J.EngineCore.Main.Scene.Actor;
|
import net.halbear.Terrain4J.EngineCore.Main.Scene.*;
|
||||||
import net.halbear.Terrain4J.EngineCore.Main.Scene.Camera;
|
|
||||||
import net.halbear.Terrain4J.EngineCore.Main.Scene.ParticleActor;
|
|
||||||
import net.halbear.Terrain4J.EngineCore.Main.Scene.Scene;
|
|
||||||
import net.halbear.Terrain4J.EngineCore.Profiling.CPUMonitor;
|
import net.halbear.Terrain4J.EngineCore.Profiling.CPUMonitor;
|
||||||
import net.halbear.Terrain4J.EngineCore.Profiling.GPUProfiler;
|
import net.halbear.Terrain4J.EngineCore.Profiling.GPUProfiler;
|
||||||
import net.halbear.Terrain4J.EngineCore.Vulkan.GUI.GuiTexture;
|
import net.halbear.Terrain4J.EngineCore.Vulkan.GUI.GuiTexture;
|
||||||
|
|
@ -52,6 +49,7 @@ public class GameCore implements GameLogic {
|
||||||
private List<Vector3f> Velocities = new ArrayList<>();
|
private List<Vector3f> Velocities = new ArrayList<>();
|
||||||
private Actor CubeActor;
|
private Actor CubeActor;
|
||||||
private List<Actor> CubeActors = new ArrayList<>();
|
private List<Actor> CubeActors = new ArrayList<>();
|
||||||
|
private List<JackOfAllTradesActor> entities = new ArrayList<>();
|
||||||
private List<ParticleActor> particleActors = new ArrayList<>();
|
private List<ParticleActor> particleActors = new ArrayList<>();
|
||||||
private Vector2f LastMousePos = new Vector2f(0,0);
|
private Vector2f LastMousePos = new Vector2f(0,0);
|
||||||
private int Ticks = 0;
|
private int Ticks = 0;
|
||||||
|
|
@ -65,6 +63,7 @@ public class GameCore implements GameLogic {
|
||||||
private long LastFrameTime = 0;
|
private long LastFrameTime = 0;
|
||||||
private long CoolDown = 1000;
|
private long CoolDown = 1000;
|
||||||
private ModelData MusicParticle;
|
private ModelData MusicParticle;
|
||||||
|
private ModelData radio;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
|
|
@ -79,14 +78,16 @@ public class GameCore implements GameLogic {
|
||||||
List<MaterialData> MusicParticleMat = ModelLoader.LoadMaterials("resources/models/MusicParticle/MusicParticle_mat.json");
|
List<MaterialData> MusicParticleMat = ModelLoader.LoadMaterials("resources/models/MusicParticle/MusicParticle_mat.json");
|
||||||
ModelData SponzaData = ModelLoader.LoadModel("resources/models/Forest/forest.json");
|
ModelData SponzaData = ModelLoader.LoadModel("resources/models/Forest/forest.json");
|
||||||
List<MaterialData> SponzaMaterial = ModelLoader.LoadMaterials("resources/models/Forest/forest_mat.json");
|
List<MaterialData> SponzaMaterial = ModelLoader.LoadMaterials("resources/models/Forest/forest_mat.json");
|
||||||
ModelData SponzaData1 = ModelLoader.LoadModel("resources/models/radio/radio.json");
|
radio = ModelLoader.LoadModel("resources/models/radio/radio.json");
|
||||||
List<MaterialData> SponzaMaterial1 = ModelLoader.LoadMaterials("resources/models/radio/radio_mat.json");
|
List<MaterialData> SponzaMaterial1 = ModelLoader.LoadMaterials("resources/models/radio/radio_mat.json");
|
||||||
//ModelData SponzaData = ModelLoader.LoadModel("resources/models/Cafe/exterior.json");
|
//ModelData SponzaData = ModelLoader.LoadModel("resources/models/Cafe/exterior.json");
|
||||||
//List<MaterialData> SponzaMaterial = ModelLoader.LoadMaterials("resources/models/Cafe/exterior_mat.json");
|
//List<MaterialData> SponzaMaterial = ModelLoader.LoadMaterials("resources/models/Cafe/exterior_mat.json");
|
||||||
//ModelData SponzaData1 = ModelLoader.LoadModel("resources/models/Cafe/interior.json");
|
//ModelData SponzaData1 = ModelLoader.LoadModel("resources/models/Cafe/interior.json");
|
||||||
//List<MaterialData> SponzaMaterial1= ModelLoader.LoadMaterials("resources/models/Cafe/interior_mat.json");
|
//List<MaterialData> SponzaMaterial1= ModelLoader.LoadMaterials("resources/models/Cafe/interior_mat.json");
|
||||||
scene.AddActor(new Actor("Sponza1", SponzaData.ID(), new Vector3f(0,0f,-5f)));
|
scene.AddActor(new Actor("Sponza1", SponzaData.ID(), new Vector3f(0,0f,-5f)));
|
||||||
scene.AddActor(new Actor("Sponza2", SponzaData1.ID(), new Vector3f(40.0f, 155.0f, -42.0f)).SetScale(0.01f));
|
JackOfAllTradesActor newJackentity = new JackOfAllTradesActor("Sponza2", radio.ID(), new Vector3f(40.0f, 155.0f, -42.0f),MusicParticle).SetAudio(engineInstance, "resources/EngineResources/audio/sounds/youusedtocallmeonyourcellphone.ogg").SetScale(0.01f);
|
||||||
|
entities.add(newJackentity);
|
||||||
|
scene.AddActor(newJackentity);
|
||||||
|
|
||||||
models.add(ModelLoader.LoadModel("resources/models/Metro/OBJ/MetroLeadCar.json"));
|
models.add(ModelLoader.LoadModel("resources/models/Metro/OBJ/MetroLeadCar.json"));
|
||||||
models.add(ModelLoader.LoadModel("resources/models/melona/melona.json"));
|
models.add(ModelLoader.LoadModel("resources/models/melona/melona.json"));
|
||||||
|
|
@ -112,7 +113,7 @@ public class GameCore implements GameLogic {
|
||||||
materials.addAll(SponzaMaterial1);
|
materials.addAll(SponzaMaterial1);
|
||||||
models.add(SponzaData);
|
models.add(SponzaData);
|
||||||
models.add(MusicParticle);
|
models.add(MusicParticle);
|
||||||
models.add(SponzaData1);
|
models.add(radio);
|
||||||
Camera camera = scene.GetCamera();
|
Camera camera = scene.GetCamera();
|
||||||
camera.SetPosition(40.0f, 155.0f, -42.0f);
|
camera.SetPosition(40.0f, 155.0f, -42.0f);
|
||||||
//camera.SetPosition(0,0,0);
|
//camera.SetPosition(0,0,0);
|
||||||
|
|
@ -134,13 +135,13 @@ public class GameCore implements GameLogic {
|
||||||
audioManager.SetAttenuationModel(AL11.AL_EXPONENT_DISTANCE);
|
audioManager.SetAttenuationModel(AL11.AL_EXPONENT_DISTANCE);
|
||||||
audioManager.SetListener(new SoundListener(camera.GetPosition()));
|
audioManager.SetListener(new SoundListener(camera.GetPosition()));
|
||||||
|
|
||||||
SoundBuffer buffer = new SoundBuffer("resources/EngineResources/audio/sounds/LaidBackLobby.ogg");
|
SoundBuffer buffer = new SoundBuffer("resources/EngineResources/audio/sounds/youusedtocallmeonyourcellphone.ogg");
|
||||||
audioManager.AddSoundBuffer(SOUND_BUFFER_PLAYER, buffer);
|
audioManager.AddSoundBuffer(SOUND_BUFFER_PLAYER, buffer);
|
||||||
AudioSource playerAudioSource = new AudioSource(true,false);
|
AudioSource playerAudioSource = new AudioSource(true,false);
|
||||||
playerAudioSource.SetPosition(new Vector3f(40.0f, 155.0f, -42.0f));
|
playerAudioSource.SetPosition(new Vector3f(40.0f, 155.0f, -42.0f));
|
||||||
playerAudioSource.SetBuffer(buffer.GetBufferID());
|
playerAudioSource.SetBuffer(buffer.GetBufferID());
|
||||||
audioManager.AddSoundSource(SOUND_SOURCE_PLAYER,playerAudioSource);
|
audioManager.AddSoundSource(SOUND_SOURCE_PLAYER,playerAudioSource);
|
||||||
playerAudioSource.Play();
|
//playerAudioSource.Play();
|
||||||
buffer = new SoundBuffer("resources/EngineResources/audio/music/chimken_wing.ogg");
|
buffer = new SoundBuffer("resources/EngineResources/audio/music/chimken_wing.ogg");
|
||||||
audioManager.AddSoundBuffer(SOUND_BUFFER_MUSIC,buffer);
|
audioManager.AddSoundBuffer(SOUND_BUFFER_MUSIC,buffer);
|
||||||
AudioSource source = new AudioSource(true, true);
|
AudioSource source = new AudioSource(true, true);
|
||||||
|
|
@ -316,6 +317,11 @@ public class GameCore implements GameLogic {
|
||||||
EngineConfig.getInstance().SetAlphaToCoverage(true);
|
EngineConfig.getInstance().SetAlphaToCoverage(true);
|
||||||
PrimaryRuntime.GetRenderThread().GetRenderer().GetSceneRender().RebuildPipelines(PrimaryRuntime.GetRenderThread().GetRenderer().GetVulkanContext());
|
PrimaryRuntime.GetRenderThread().GetRenderer().GetSceneRender().RebuildPipelines(PrimaryRuntime.GetRenderThread().GetRenderer().GetVulkanContext());
|
||||||
}
|
}
|
||||||
|
if(ImGui.button("Spawn Radio")){
|
||||||
|
JackOfAllTradesActor newJackentity = new JackOfAllTradesActor("Radio" + entities.size(), radio.ID(), new Vector3f(engineInstance.scene().GetCamera().GetPosition()),MusicParticle).SetAudio(engineInstance, "resources/EngineResources/audio/sounds/youusedtocallmeonyourcellphone.ogg").SetScale(0.01f);
|
||||||
|
entities.add(newJackentity);
|
||||||
|
engineInstance.scene().AddActor(newJackentity);
|
||||||
|
}
|
||||||
if(PerformanceMetrics.size() > 0) {
|
if(PerformanceMetrics.size() > 0) {
|
||||||
ImGui.text(" ");
|
ImGui.text(" ");
|
||||||
ImGui.separator();
|
ImGui.separator();
|
||||||
|
|
@ -369,27 +375,15 @@ public class GameCore implements GameLogic {
|
||||||
@Override
|
@Override
|
||||||
public void UpdateFastThread(EngineInstance engineInstance, long FrameDiffNanoSeconds) {
|
public void UpdateFastThread(EngineInstance engineInstance, long FrameDiffNanoSeconds) {
|
||||||
float DeltaTime = (float)(FrameDiffNanoSeconds/16000000.0);
|
float DeltaTime = (float)(FrameDiffNanoSeconds/16000000.0);
|
||||||
List<Integer> ParticlesToDelete = new ArrayList<>();
|
|
||||||
if((int)(Math.random() * 60) == 0){
|
|
||||||
ParticleActor particle = new ParticleActor("particle" + particleActors.size(), MusicParticle.ID(), new Vector3f(40.0f, 155.0f, -42.0f),new Vector3f(1,1,1),0,new Vector3f(-1f + (float)Math.random() * 2,-1f + (float)Math.random() * 2,-1f + (float)Math.random() * 2),0.0005f,1000);
|
|
||||||
particleActors.add(particle);
|
|
||||||
engineInstance.scene().AddActor(particle);
|
|
||||||
}
|
|
||||||
for(int i = 0; i < angles.size(); i++) {
|
for(int i = 0; i < angles.size(); i++) {
|
||||||
angles.set(i, (angles.get(i) + 1.0f* DeltaTime) % 360);
|
angles.set(i, (angles.get(i) + 1.0f* DeltaTime) % 360);
|
||||||
CubeActors.get(i).GetRotation().identity().rotateAxis((float) EngineConfig.DegToRad * angles.get(i), rotatingAngles.get(i));
|
CubeActors.get(i).GetRotation().identity().rotateAxis((float) EngineConfig.DegToRad * angles.get(i), rotatingAngles.get(i));
|
||||||
CubeActors.get(i).GetPosition().add((Velocities.get(i).x/100.0f) * DeltaTime,(Velocities.get(i).y/100.0f) * DeltaTime,(Velocities.get(i).z/100.0f) * DeltaTime);
|
CubeActors.get(i).GetPosition().add((Velocities.get(i).x/100.0f) * DeltaTime,(Velocities.get(i).y/100.0f) * DeltaTime,(Velocities.get(i).z/100.0f) * DeltaTime);
|
||||||
CubeActors.get(i).UpdateModelMatrix();
|
CubeActors.get(i).UpdateModelMatrix();
|
||||||
}
|
}
|
||||||
for(int i = 0; i < particleActors.size(); i++){
|
for(int i = 0; i < entities.size(); i++){
|
||||||
particleActors.get(i).TickUpdate();
|
JackOfAllTradesActor entity = entities.get(i);
|
||||||
if(particleActors.get(i).TicksLeft() <= 0){
|
entity.tick(engineInstance.scene());
|
||||||
engineInstance.scene().RemoveActor(particleActors.get(i));
|
|
||||||
ParticlesToDelete.add(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(int i = ParticlesToDelete.size() - 1; i >= 0; i--){
|
|
||||||
particleActors.remove((int)ParticlesToDelete.get(i));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
package net.halbear.Terrain4J.EngineCore.Main.Scene;
|
||||||
|
|
||||||
|
import net.halbear.Terrain4J.EngineCore.Audio.AudioManager;
|
||||||
|
import net.halbear.Terrain4J.EngineCore.Audio.AudioSource;
|
||||||
|
import net.halbear.Terrain4J.EngineCore.Audio.SoundBuffer;
|
||||||
|
import net.halbear.Terrain4J.EngineCore.Logic.EngineInstance;
|
||||||
|
import net.halbear.Terrain4J.EngineCore.Vulkan.Rendering.VkModel.ModelData;
|
||||||
|
import org.joml.Matrix4f;
|
||||||
|
import org.joml.Quaternionf;
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class JackOfAllTradesActor extends Actor {
|
||||||
|
|
||||||
|
private ModelData Particle;
|
||||||
|
private List<ParticleActor> particleActors = new ArrayList<>();
|
||||||
|
private String SOUND_ID_BUFFER;
|
||||||
|
private String SOUND_ID_PLAYER;
|
||||||
|
private AudioSource playerAudioSource;
|
||||||
|
|
||||||
|
public JackOfAllTradesActor(String ID, String ModelID, Vector3f Position, ModelData Particle){
|
||||||
|
super(ID,ModelID,Position);
|
||||||
|
SOUND_ID_BUFFER = ID + "_AUDIO_BUFFER";
|
||||||
|
SOUND_ID_PLAYER = ID+"_AUDIO_PLAYER";
|
||||||
|
this.Particle = Particle;
|
||||||
|
}
|
||||||
|
public JackOfAllTradesActor SetScale(float scale){
|
||||||
|
super.SetScale(scale);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public JackOfAllTradesActor SetAudio(EngineInstance engineInstance, String AudioFile){
|
||||||
|
AudioManager audioManager = engineInstance.audioManager();
|
||||||
|
SoundBuffer buffer = new SoundBuffer(AudioFile);
|
||||||
|
audioManager.AddSoundBuffer(SOUND_ID_BUFFER, buffer);
|
||||||
|
playerAudioSource = new AudioSource(true,false);
|
||||||
|
playerAudioSource.SetPosition(new Vector3f(GetPosition()));
|
||||||
|
playerAudioSource.SetBuffer(buffer.GetBufferID());
|
||||||
|
audioManager.AddSoundSource(SOUND_ID_PLAYER,playerAudioSource);
|
||||||
|
PlayAudio();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public JackOfAllTradesActor PlayAudio(){
|
||||||
|
playerAudioSource.Play();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tick(Scene scene){
|
||||||
|
List<Integer> ParticlesToDelete = new ArrayList<>();
|
||||||
|
if((int)(Math.random() * 20) == 0){
|
||||||
|
ParticleActor particle = new ParticleActor("particle" + particleActors.size(), Particle.ID(), new Vector3f(GetPosition()),new Vector3f(1,1,1),0,new Vector3f(-1f + (float)Math.random() * 2,-1f + (float)Math.random() * 2,-1f + (float)Math.random() * 2),0.0005f,5000);
|
||||||
|
particleActors.add(particle);
|
||||||
|
scene.AddActor(particle);
|
||||||
|
}
|
||||||
|
for(int i = 0; i < particleActors.size(); i++){
|
||||||
|
particleActors.get(i).TickUpdate();
|
||||||
|
if(particleActors.get(i).TicksLeft() <= 0){
|
||||||
|
scene.RemoveActor(particleActors.get(i));
|
||||||
|
ParticlesToDelete.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int i = ParticlesToDelete.size() - 1; i >= 0; i--){
|
||||||
|
particleActors.remove((int)ParticlesToDelete.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -314,6 +314,7 @@ public class SceneRender implements SceneRenderer {//dynamic rendering
|
||||||
for(int i = 0; i < ActorCount; i++){
|
for(int i = 0; i < ActorCount; i++){
|
||||||
if(i < Actors.size()) {
|
if(i < Actors.size()) {
|
||||||
var Actor = Actors.get(i);
|
var Actor = Actors.get(i);
|
||||||
|
if(Actor != null) {
|
||||||
VulkanModel model = modelsCache.GetModel(Actor.GetModelID());
|
VulkanModel model = modelsCache.GetModel(Actor.GetModelID());
|
||||||
List<VulkanMesh> VkMeshList = model.GetVkMeshList();
|
List<VulkanMesh> VkMeshList = model.GetVkMeshList();
|
||||||
int MeshCount = VkMeshList.size();
|
int MeshCount = VkMeshList.size();
|
||||||
|
|
@ -338,6 +339,7 @@ public class SceneRender implements SceneRenderer {//dynamic rendering
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SetPushConstants(VkCommandBuffer CmdHandle, Matrix4f ModelMatrix, int MaterialIndex){
|
private void SetPushConstants(VkCommandBuffer CmdHandle, Matrix4f ModelMatrix, int MaterialIndex){
|
||||||
ModelMatrix.get(0,PushConstBuffer);
|
ModelMatrix.get(0,PushConstBuffer);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue