princeton-vl / infinigen

Infinite Photorealistic Worlds using Procedural Generation
https://infinigen.org
BSD 3-Clause "New" or "Revised" License
5.31k stars 455 forks source link

DIfferences of create_asset and create_placeholder? #319

Open GCChen97 opened 1 week ago

GCChen97 commented 1 week ago

Hi, I am trying to make my own object factory. I've managed to add some simple primitives like cube and cylinder and etc.

Currently, I just use butil.spawn_XXX to override create_asset and create_pholder of AssetFactory. Before adding rotation to the object, I want to know more about the methods of AssetFactory like create_placeholder,create_asset, spawn_asset and spawn_placeholder. I have a few questions: 1) What are the differences of these functions? Are the placeholders used for collision detection? 2) Can I directly apply rotation on the assets 3) Are there any suggestions on overriding these functions? (Such use simple meshes for holders)

Thanks!!!

araistrick commented 15 hours ago

What are the differences of these functions? Are the placeholders used for collision detection?

the result of create_placeholder is generally used for layout, simulations and motion planning, e.g. indoors solver collision checking, camera collision checking, fluid simulation, particle sims. Anything expensive like this uses a low poly proxy if available.

We also place scatters (moss, mushrooms, etc) ontop of the placeholder, rather than the asset mesh, because in some settings of the project we used to let the asset mesh be swapped out between different detail levels as the camera moved.

in the current nature code, placeholders are placed globally, wheras create_asset is only called for visible areas of the scene. So there may be many hundred placeholders generated but only a couple of visible trees.

Create asset is intended to convert a placeholder into an asset that is suitable to be rendered and shown to the user.

Can I directly apply rotation on the assets

Could you clarify what you want to achieve? By default the API expects you to specify rotation either by passing in the rot=(eulerx, y,z) argument, or by recieving the obj then assigning obj.rotation_euler.

Are there any suggestions on overriding these functions? (Such use simple meshes for holders)

RE overriding, you can return any bpy.types.Object you think is appropriate. There are some additional requirements we assume of the object returned, which you can check via adding it to the tests/assets/list_nature_meshes.txt unit test list, then running pytest -k MyAsset, or by reading the corresponding test file.