Class ObjLoaderDemo
ObjLoader).
Two city models are bundled as classpath resources under
/obj_loader_demo/, both generated by the "3D Synthezier" QBasic
program (qbasicapps: 3D GFX/3D Synthezier), which composes scenes from
cached sub-objects and emits Wavefront OBJ plus a shared material
library (result.mtl). main(String[]) asks which city
to load — a dialog with one button per city, or --city=1|2 on
the command line; the golden-image path loads the default city
deterministically via buildScene(ShapeCollection, LightingManager, Camera).
Concepts demonstrated:
- Loading OBJ geometry + MTL materials into an
ObjModel - Per-face material colors (and translucency via MTL
d) - Resizing a loaded model with the transform's uniform scale
(
Transform.setScale(double)) - Self-framing scene setup: the model's bounding box is recentered on the world origin via the transform's translation, and the camera and sun are placed relative to the model's bounding radius — so any bundled city is framed and lit the same way without per-model magic numbers
- Flat shading of a loaded model with a sun-like light source
- Per-city hero light: one strong omnidirectional source (position chosen per city) with a scaled marker glow, so its side of the city blazes while the far sides fall into shadow for the global illumination to bounce
- Progressive global illumination: the city renders as lightmapped
triangles (
ObjModelis aLightmappedCompositeShape), so per-texel shadows and bounced light refine over the first seconds (mainenables lightmapping and GI; golden images stay lightmapping- and GI-free for determinism)
Run this demo:
java -cp target/aukio-3d-demos.jar eu.svjatoslav.aukio.e3d.examples.obj_loader_demo.ObjLoaderDemo
java -cp target/aukio-3d-demos.jar eu.svjatoslav.aukio.e3d.examples.obj_loader_demo.ObjLoaderDemo --city=2
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumA bundled city model that the demo can load. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidbuildScene(eu.svjatoslav.aukio.e3d.renderer.raster.ShapeCollection shapes, eu.svjatoslav.aukio.e3d.renderer.raster.lighting.LightingManager lighting, eu.svjatoslav.aukio.e3d.geometry.Camera camera) Builds the demo scene deterministically (golden-image contract): loads the default bundled city model, one sun light, camera at an aerial three-quarter view of the block.static voidbuildScene(eu.svjatoslav.aukio.e3d.renderer.raster.ShapeCollection shapes, eu.svjatoslav.aukio.e3d.renderer.raster.lighting.LightingManager lighting, eu.svjatoslav.aukio.e3d.geometry.Camera camera, ObjLoaderDemo.City city) Builds the demo scene with the chosen city: loads the model, one sun light, camera at an aerial three-quarter view of the block.static voidbuildScene(eu.svjatoslav.aukio.e3d.renderer.raster.ShapeCollection shapes, eu.svjatoslav.aukio.e3d.renderer.raster.lighting.LightingManager lighting, eu.svjatoslav.aukio.e3d.geometry.Camera camera, ObjLoaderDemo.City city, boolean lightmapping) Builds the demo scene with the chosen city.static voidEntry point for the OBJ loader demo.
-
Constructor Details
-
ObjLoaderDemo
public ObjLoaderDemo()
-
-
Method Details
-
buildScene
public static void buildScene(eu.svjatoslav.aukio.e3d.renderer.raster.ShapeCollection shapes, eu.svjatoslav.aukio.e3d.renderer.raster.lighting.LightingManager lighting, eu.svjatoslav.aukio.e3d.geometry.Camera camera) Builds the demo scene deterministically (golden-image contract): loads the default bundled city model, one sun light, camera at an aerial three-quarter view of the block. -
buildScene
public static void buildScene(eu.svjatoslav.aukio.e3d.renderer.raster.ShapeCollection shapes, eu.svjatoslav.aukio.e3d.renderer.raster.lighting.LightingManager lighting, eu.svjatoslav.aukio.e3d.geometry.Camera camera, ObjLoaderDemo.City city) Builds the demo scene with the chosen city: loads the model, one sun light, camera at an aerial three-quarter view of the block.The scene is self-framing: the model's bounding box is centered on the world origin, and the camera and sun are placed relative to its bounding radius, so either city (or a future replacement model) fills the frame the same way.
Lightmapping is left disabled: this overload serves headless renderers (goldens) that must stay deterministic without the global illumination system that converges the lightmaps.
-
buildScene
public static void buildScene(eu.svjatoslav.aukio.e3d.renderer.raster.ShapeCollection shapes, eu.svjatoslav.aukio.e3d.renderer.raster.lighting.LightingManager lighting, eu.svjatoslav.aukio.e3d.geometry.Camera camera, ObjLoaderDemo.City city, boolean lightmapping) Builds the demo scene with the chosen city.- Parameters:
lightmapping- when true, the city's polygons render as lightmapped triangles so global illumination can paint per-texel shadows and bounced light across them. Enable together withViewPanel.enableGlobalIllumination; without GI the lightmaps never converge past their flat initial value.
-
main
Entry point for the OBJ loader demo.
-