use of com.chrisali.javaflightsim.lwjgl.models.TexturedModel in project j6dof-flight-sim by chris-ali.
the class LWJGLWorld method loadAssets.
/**
* Initializes and generates all assets needed to render lights, entities, particles terrain and text
*/
private void loadAssets() {
// ==================================== Sun ===========================================================
logger.debug("Generating sun...");
lights = new ArrayList<>();
lights.add(new Light(new Vector3f(20000, 40000, 20000), new Vector3f(0.95f, 0.95f, 0.95f)));
// ================================= Entities ==========================================================
logger.debug("Generating collections of entities...");
entities = new EntityCollections(lights, loader);
// ================================= Ownship ===========================================================
logger.debug("Creating ownship...");
TexturedModel airplane = new TexturedModel(OBJLoader.loadObjModel("airplane", OTWDirectories.ENTITIES.toString(), loader), new ModelTexture(loader.loadTexture("airplane", OTWDirectories.ENTITIES.toString())));
ownship = new Ownship(airplane, configuration.getInitialConditions(), 1.25f);
logger.debug("Setting up camera...");
// Camera tied to ownship as first person view
camera = new Camera(ownship);
camera.setChaseView(true);
ownship.setScale(camera.isChaseView() ? 1.25f : 0f);
entities.addToStaticEntities(ownship);
// ================================= Terrain ==========================================================
logger.debug("Generating terrain...");
terrainCollection = new TerrainCollection(10, loader, ownship);
entities.setTerrainTree(terrainCollection.getTerrainTree());
// =============================== Particles ==========================================================
logger.debug("Generating clouds...");
ParticleTexture clouds = new ParticleTexture(loader.loadTexture("clouds", OTWDirectories.PARTICLES.toString()), 4, true);
// Generates clouds at random positions along terrain map
Random random = new Random();
for (int i = -1000; i < 1000; i++) new Cloud(clouds, new Vector3f(random.nextInt(800 * 10), 300, i * 10), new Vector3f(0, 0, 0), 0, 200);
// =============================== Interface ==========================================================
logger.debug("Generating on-screen text and panel...");
// On-screen text
simTexts = new SimulationTexts(new FontType(loader, "ubuntu"));
// Instrument Panel and Gauges
interfaceTextures = new ArrayList<>();
panel = FileUtilities.readInstrumentPanelConfiguration(configuration.getSelectedAircraft());
if (configuration.getSimulationOptions().contains(Options.INSTRUMENT_PANEL)) {
interfaceTextures = panel.loadAndGetTextures(loader, configuration.getSelectedAircraft());
camera.setPilotPosition(new Vector3f(0, 5, 0));
camera.setPitchOffset(25);
}
// ==================================== Audio =========================================================
logger.debug("Generating sound collection...");
soundCollection = new SoundCollection(configuration);
}
use of com.chrisali.javaflightsim.lwjgl.models.TexturedModel in project j6dof-flight-sim by chris-ali.
the class MasterRenderer method processEntity.
private void processEntity(Entity entity) {
TexturedModel entityModel = entity.getModel();
List<Entity> batch = entityMap.get(entityModel);
if (batch != null) {
batch.add(entity);
} else {
List<Entity> newBatch = new ArrayList<>();
newBatch.add(entity);
entityMap.put(entityModel, newBatch);
}
}
use of com.chrisali.javaflightsim.lwjgl.models.TexturedModel in project j6dof-flight-sim by chris-ali.
the class EntityCollections method createLitEntity.
/**
* <p>Creates a single lit entity based on the X and Z coordinates specified; the Y coordinate is the height of the terrain
* at the given X and Z coordinates; </p>
*<p>lightPosOffset refers to the position offset
* from the entity's position that the light is centered at (e.g. a lamp post whose light is far above the post's position);
* attenuation is the brightness of the light </p>
*
* @param entityName
* @param xPos
* @param zPos
* @param yRot
* @param scale
* @param color
* @param attenuation
* @param lightPosOffset
*/
public void createLitEntity(String entityName, float xPos, float zPos, float yRot, float scale, Vector3f color, Vector3f attenuation, Vector3f lightPosOffset) {
TexturedModel litEntity = new TexturedModel(OBJLoader.loadObjModel(entityName, OTWDirectories.ENTITIES.toString(), loader), new ModelTexture(loader.loadTexture(entityName, OTWDirectories.ENTITIES.toString())));
float yPos = Terrain.getCurrentTerrain(terrainTree, xPos, zPos).getTerrainHeight(xPos, zPos);
Vector3f position = new Vector3f(xPos, yPos, zPos);
logger.debug("Generating a(n)" + entityName + " at: (" + xPos + ", " + yPos + ", " + zPos + ")...");
miscLitEntities.add(new Entity(litEntity, position, 0, yRot, 0, scale));
Light light = new Light(Vector3f.add(position, lightPosOffset, position), color, attenuation);
lights.add(light);
}
use of com.chrisali.javaflightsim.lwjgl.models.TexturedModel in project j6dof-flight-sim by chris-ali.
the class EntityCollections method initializeEntities.
/**
* Initializes all {@link TexturedModel} objects for in methods, which create entities
*/
private void initializeEntities() {
// Create models
// Static
planatusForest = new TexturedModel(OBJLoader.loadObjModel("grassModel", OTWDirectories.ENTITIES.toString(), loader), new ModelTexture(loader.loadTexture("platanusforest", OTWDirectories.ENTITIES.toString())));
pineForest = new TexturedModel(OBJLoader.loadObjModel("grassModel", OTWDirectories.ENTITIES.toString(), loader), new ModelTexture(loader.loadTexture("pineforest", OTWDirectories.ENTITIES.toString())));
oakForest = new TexturedModel(OBJLoader.loadObjModel("grassModel", OTWDirectories.ENTITIES.toString(), loader), new ModelTexture(loader.loadTexture("oakforest", OTWDirectories.ENTITIES.toString())));
// Lit
lamp = new TexturedModel(OBJLoader.loadObjModel("lamp", OTWDirectories.ENTITIES.toString(), loader), new ModelTexture(loader.loadTexture("lamp", OTWDirectories.ENTITIES.toString())));
// Model settings
// Static
planatusForest.getTexture().setHasTransparency(true);
planatusForest.getTexture().setUseFakeLighting(true);
pineForest.getTexture().setHasTransparency(true);
pineForest.getTexture().setUseFakeLighting(true);
oakForest.getTexture().setHasTransparency(true);
oakForest.getTexture().setUseFakeLighting(true);
// Lit
lamp.getTexture().setUseFakeLighting(true);
}
use of com.chrisali.javaflightsim.lwjgl.models.TexturedModel in project j6dof-flight-sim by chris-ali.
the class EntityCollections method createLitEntity.
/**
* <p>Creates a single static entity based on the player's position</p>
* <p>lightPosOffset refers to the position offset
* from the entity's position that the light is centered at (e.g. a lamp post whose light is far above the post's position);
* attenuation is the brightness of the light </p>
*
* @param entityName
* @param player
* @param scale
* @param color
* @param attenuation
* @param lightPosOffset
*/
public void createLitEntity(String entityName, Player player, float scale, Vector3f color, Vector3f attenuation, Vector3f lightPosOffset) {
logger.debug("Generating a(n)" + entityName + " at the ownship's postion: (" + player.getPosition().x + ", " + player.getPosition().y + ", " + player.getPosition().z + ")...");
TexturedModel litEntity = new TexturedModel(OBJLoader.loadObjModel(entityName, OTWDirectories.ENTITIES.toString(), loader), new ModelTexture(loader.loadTexture(entityName, OTWDirectories.ENTITIES.toString())));
Vector3f position = player.getPosition();
miscLitEntities.add(new Entity(litEntity, position, player.getRotX(), player.getRotY(), player.getRotZ(), scale));
Light light = new Light(Vector3f.add(position, lightPosOffset, position), color, attenuation);
lights.add(light);
}
Aggregations