Add mjr_sceneParams for creating Scene objects.
PiperOrigin-RevId: 907589621 Change-Id: If7537cf6fbac6d6418ac2bf8315714ada969511d
This commit is contained in:
committed by
Copybara-Service
parent
52e90bf55d
commit
7e848e9406
@@ -37,10 +37,12 @@ using filament::math::float3;
|
||||
using filament::math::mat3f;
|
||||
|
||||
ImguiBridge::ImguiBridge(FilamentContext* ctx) : ctx_(ctx) {
|
||||
scene_view_ = std::make_unique<SceneView>(ctx_);
|
||||
scene_view_->DisableShadows();
|
||||
scene_view_->DisableReflections();
|
||||
scene_view_->DisablePostProcessing();
|
||||
mjrSceneParams params;
|
||||
mjr_defaultSceneParams(¶ms);
|
||||
params.enable_post_processing = false;
|
||||
params.enable_reflections = false;
|
||||
params.enable_shadows = false;
|
||||
scene_view_ = std::make_unique<SceneView>(ctx_, params);
|
||||
}
|
||||
|
||||
ImguiBridge::~ImguiBridge() {
|
||||
|
||||
@@ -83,7 +83,9 @@ static std::unique_ptr<Texture> CreateFallbackIndirectLightTexture(
|
||||
|
||||
SceneBridge::SceneBridge(FilamentContext* ctx, const mjModel* model)
|
||||
: ctx_(ctx) {
|
||||
scene_view_ = std::make_unique<SceneView>(ctx_);
|
||||
mjrSceneParams params;
|
||||
mjr_defaultSceneParams(¶ms);
|
||||
scene_view_ = std::make_unique<SceneView>(ctx_, params);
|
||||
model_objects_ = std::make_unique<ModelObjects>(model, ctx_);
|
||||
|
||||
// Configure options for the normal view.
|
||||
|
||||
@@ -121,7 +121,8 @@ static void SetupReflectionCamera(const mat4& surface_xform,
|
||||
reflection_camera->setCustomProjection(oblique, near, far);
|
||||
}
|
||||
|
||||
SceneView::SceneView(FilamentContext* ctx) : ctx_(ctx) {
|
||||
SceneView::SceneView(FilamentContext* ctx, const mjrSceneParams& params)
|
||||
: ctx_(ctx) {
|
||||
filament::Engine* engine = ctx_->GetEngine();
|
||||
scene_ = engine->createScene();
|
||||
camera_ = engine->createCamera(utils::EntityManager::get().create());
|
||||
@@ -152,6 +153,16 @@ SceneView::SceneView(FilamentContext* ctx) : ctx_(ctx) {
|
||||
tm.create(fog);
|
||||
tm.setTransform(tm.getInstance(fog),
|
||||
mat4::rotation(filament::math::f::PI / 2, float3{-1, 0, 0}));
|
||||
|
||||
if (!params.enable_post_processing) {
|
||||
DisablePostProcessing();
|
||||
}
|
||||
if (!params.enable_reflections) {
|
||||
DisableReflections();
|
||||
}
|
||||
if (!params.enable_shadows) {
|
||||
DisableShadows();
|
||||
}
|
||||
}
|
||||
|
||||
SceneView::~SceneView() {
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace mujoco {
|
||||
// (e.g. normal, depth, segmentation, etc.) as well as reflective surfaces.
|
||||
class SceneView : public mjrScene {
|
||||
public:
|
||||
explicit SceneView(FilamentContext* ctx);
|
||||
SceneView(FilamentContext* ctx, const mjrSceneParams& params);
|
||||
~SceneView();
|
||||
|
||||
SceneView(const SceneView&) = delete;
|
||||
|
||||
@@ -63,6 +63,12 @@ void mjr_defaultMeshData(mjrMeshData* data) {
|
||||
std::memset(data, 0, sizeof(mjrMeshData));
|
||||
}
|
||||
|
||||
void mjr_defaultSceneParams(mjrSceneParams* params) {
|
||||
params->enable_post_processing = true;
|
||||
params->enable_reflections = true;
|
||||
params->enable_shadows = true;
|
||||
}
|
||||
|
||||
void mjr_defaultLightParams(mjrLightParams* params) {
|
||||
params->type = mjLIGHT_POINT;
|
||||
params->texture = nullptr;
|
||||
|
||||
@@ -284,6 +284,19 @@ struct mjrMeshData {
|
||||
// Initializes the mjrMeshData to default values.
|
||||
void mjr_defaultMeshData(mjrMeshData* data);
|
||||
|
||||
// Configuration parameters for a Scene.
|
||||
struct mjrSceneParams {
|
||||
// Whether or not to enable post processing; enabled by default.
|
||||
mjtByte enable_post_processing;
|
||||
// Whether or not to enable reflections; enabled by default.
|
||||
mjtByte enable_reflections;
|
||||
// Whether or not to enable shadows; enabled by default.
|
||||
mjtByte enable_shadows;
|
||||
};
|
||||
|
||||
// Initializes the mjrSceneParams to default values.
|
||||
void mjr_defaultSceneParams(mjrSceneParams* params);
|
||||
|
||||
// Configuration parameters for a light.
|
||||
struct mjrLightParams {
|
||||
// The type of light (e.g. spot, point, directional, etc.)
|
||||
|
||||
Reference in New Issue
Block a user