Repository navigation
World themes: model buildings and trees in the generated world, with LOD - #1582
Merged
Merged
Conversation
A generated world can now build textured model buildings and plant model trees, chosen by a world theme (generated_world_params::theme, the node's `theme:`), and draw every placed copy with level of detail. - cvc/world/model_assets.h: model assets read from <name>.asset.json (schema cvc-model-asset/1: kind, tags, bounds, a LOD ladder with each rung's world_error_m), turned into the world frame, and the app's catalog of them (model_catalog_of), scanned from the cvcpkg prefixes' share/cvc-scenes/shared, the nav bundle's shared/ and CVC_MODEL_PATH. - cvc/world/world_theme.h: themes as data. Building archetypes (asset, weight, urbanity band, scale range, lots spanned) and tree archetypes (asset, weight, scale range, a biome rule: height over the water, slope, distance to water); registered per app, read and written as JSON; built-ins temperate_town, coastal_town and tropical. Every draw is keyed on its spot (a new lsys::stream::theme, appended). - generated_world: a themed city fits building archetypes to lots (two lots for the office), fronts on the setback line, a plinth on slopes; the scatter's trees become tree archetypes where their biome holds. The world records model_assets and models; the model buildings collide as boxes; bundles carry them in models.json. No theme: the world as before, and its params JSON and bundle bytes unchanged. - cvc/gl/ariadne/world_models.h: each asset read once into a mesh pyramid of its LOD glbs (cached by file, off the frame thread); every copy a LodGraphicsNode posed by its transform whose rungs share the first copy's arrays and texture, choosing its rung by its own distance. world_nodes installs, swaps and retires them with the world. - pycvc: geometry.triangle_indices() (what the asset LOD baker reads rungs back out with), generated_world.models(), generate_world's theme. - Tests: world_theme_test (assets, catalog, glb reading, themes, the draws, biomes, a themed world, bundles) and cvcgl_world_models (the frames, loading a ladder, shared instances choosing their rungs).
The singleton scan refuses function-local statics. The built-in theme list is now built per call (builtin_world_themes returns by value), and the model-mesh cache lives on the app (slot cvc.gl.ariadne.model_meshes), like the model catalog. Formatting follows CI's clang-format 18.1.8.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generated worlds can now build textured model buildings and plant model trees, chosen by world themes, and draw every placed copy with level of detail. The models come from the new cy-pca asset packages in cy-pca/graphics-assets#22.
World side (GL-free, deterministic)
cvc/world/model_assets.h).model_assetis parsed from<name>.asset.json(schemacvc-model-asset/1). It holds the kind, tags, extents turned from glTF's +Y-up / front +Z into the world's +Z-up / front +Y, and a LOD ladder: file, triangles andworld_error_mper rung.model_catalogscans directories for those sidecars.model_catalog_of(app)is filled from the same placesfind_vehicle_modellooks (cvcpkg prefixes'share/cvc-scenes/shared, the nav bundle'sshared/), plusCVC_MODEL_PATH.cvc/world/world_theme.h). A theme is data, not code:span(how many street lots it may take).biome_rule(height over water, slope, distance to water).temperate_town,coastal_town(palms on the coast, oaks inland) andtropical.pick_buildingandpick_treeare exposed for tests and other generators. Every draw is keyed on the spot, using a newlsys::stream::themeappended at the end of the enum, so existing salts don't move.generated_world_params::theme. Empty is the old world, unchanged; the params JSON leaves the key out, so existing bundles keep their bytes.model_assetsandmodels(asset, x, y, z, yaw, scale).model_buildings, collide + navigate); the trees are drawn only.models.json, andworld_from_bundlereads them back..arinode takestheme:(live asworld.theme), and pycvc'sgenerate_worldtakes athemekey.Render side: LOD
cvc/gl/ariadne/world_models.{h,cpp}:cvc::lod::mesh_pyramidwhose rungs are the asset's LOD glbs, with their base-colour textures and the sidecar's errors. It is cached by file.LodGraphicsNodeposed by its instance transform, with its errors scaled by its scale. Its rungs draw from the first copy's arrays and texture (shareArraysFrom,shareTexture), so a hundred palms hold one palm's buffers. Each copy picks its rung from its own distance, the samecvc::lod::select_rungpath the props and terrain use.world_nodes.cpp:<id>_models.build_mesh_pyramid/simplifythrough pycvc, which needed one binding addition:geometry.triangle_indices(), a read-only (T,3) copy. pycvc'sgenerated_worldalso gainsmodels().Tests
world_theme_test(17 tests), covering:read_model;themeappearing in the params JSON only when set;cvcgl_world_models(headless):.depsprefix:world_theme_test17/17 andcvcgl_world_modelspass;ctest -R "World|Bundle|Lsys|lsys|Theme|Scatter|Sites|generated|world_|cvcgl_lod|ariadne_scene": 652/652 pass (world, bundle, lsys, scatter, sites, generated-world, scene-world, cvcGL LOD and world tests, pycvc world tests).Renders
Before and after, from the same build and camera: seed 5, half 450, the urban preset, amp 15, a shore edge. "Before" is
theme: ""; "after" istheme: coastal_townwith the packages' files onCVC_MODEL_PATH. Out of 99 buildings, 50 are model buildings (27 corner shops, 22 brownstones, 1 office). The 121 model trees are 87 palms on the coast and 34 oaks inland. The renders were sent to Joe directly.Not done
publishdispatch, on Joe's OK). Until then,CVC_MODEL_PATHpoints at the baked files.