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;
|
using filament::math::mat3f;
|
||||||
|
|
||||||
ImguiBridge::ImguiBridge(FilamentContext* ctx) : ctx_(ctx) {
|
ImguiBridge::ImguiBridge(FilamentContext* ctx) : ctx_(ctx) {
|
||||||
scene_view_ = std::make_unique<SceneView>(ctx_);
|
mjrSceneParams params;
|
||||||
scene_view_->DisableShadows();
|
mjr_defaultSceneParams(¶ms);
|
||||||
scene_view_->DisableReflections();
|
params.enable_post_processing = false;
|
||||||
scene_view_->DisablePostProcessing();
|
params.enable_reflections = false;
|
||||||
|
params.enable_shadows = false;
|
||||||
|
scene_view_ = std::make_unique<SceneView>(ctx_, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImguiBridge::~ImguiBridge() {
|
ImguiBridge::~ImguiBridge() {
|
||||||
|
|||||||
@@ -83,7 +83,9 @@ static std::unique_ptr<Texture> CreateFallbackIndirectLightTexture(
|
|||||||
|
|
||||||
SceneBridge::SceneBridge(FilamentContext* ctx, const mjModel* model)
|
SceneBridge::SceneBridge(FilamentContext* ctx, const mjModel* model)
|
||||||
: ctx_(ctx) {
|
: 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_);
|
model_objects_ = std::make_unique<ModelObjects>(model, ctx_);
|
||||||
|
|
||||||
// Configure options for the normal view.
|
// Configure options for the normal view.
|
||||||
|
|||||||
@@ -121,7 +121,8 @@ static void SetupReflectionCamera(const mat4& surface_xform,
|
|||||||
reflection_camera->setCustomProjection(oblique, near, far);
|
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();
|
filament::Engine* engine = ctx_->GetEngine();
|
||||||
scene_ = engine->createScene();
|
scene_ = engine->createScene();
|
||||||
camera_ = engine->createCamera(utils::EntityManager::get().create());
|
camera_ = engine->createCamera(utils::EntityManager::get().create());
|
||||||
@@ -152,6 +153,16 @@ SceneView::SceneView(FilamentContext* ctx) : ctx_(ctx) {
|
|||||||
tm.create(fog);
|
tm.create(fog);
|
||||||
tm.setTransform(tm.getInstance(fog),
|
tm.setTransform(tm.getInstance(fog),
|
||||||
mat4::rotation(filament::math::f::PI / 2, float3{-1, 0, 0}));
|
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() {
|
SceneView::~SceneView() {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace mujoco {
|
|||||||
// (e.g. normal, depth, segmentation, etc.) as well as reflective surfaces.
|
// (e.g. normal, depth, segmentation, etc.) as well as reflective surfaces.
|
||||||
class SceneView : public mjrScene {
|
class SceneView : public mjrScene {
|
||||||
public:
|
public:
|
||||||
explicit SceneView(FilamentContext* ctx);
|
SceneView(FilamentContext* ctx, const mjrSceneParams& params);
|
||||||
~SceneView();
|
~SceneView();
|
||||||
|
|
||||||
SceneView(const SceneView&) = delete;
|
SceneView(const SceneView&) = delete;
|
||||||
|
|||||||
@@ -63,6 +63,12 @@ void mjr_defaultMeshData(mjrMeshData* data) {
|
|||||||
std::memset(data, 0, sizeof(mjrMeshData));
|
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) {
|
void mjr_defaultLightParams(mjrLightParams* params) {
|
||||||
params->type = mjLIGHT_POINT;
|
params->type = mjLIGHT_POINT;
|
||||||
params->texture = nullptr;
|
params->texture = nullptr;
|
||||||
|
|||||||
@@ -284,6 +284,19 @@ struct mjrMeshData {
|
|||||||
// Initializes the mjrMeshData to default values.
|
// Initializes the mjrMeshData to default values.
|
||||||
void mjr_defaultMeshData(mjrMeshData* data);
|
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.
|
// Configuration parameters for a light.
|
||||||
struct mjrLightParams {
|
struct mjrLightParams {
|
||||||
// The type of light (e.g. spot, point, directional, etc.)
|
// The type of light (e.g. spot, point, directional, etc.)
|
||||||
|
|||||||
Reference in New Issue
Block a user