merge moveCameraToAsset changes
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include "Log.hpp"
|
||||
#include "AssetManager.hpp"
|
||||
|
||||
#include "material/UnlitMaterialProvider.hpp"
|
||||
#include "material/FileMaterialProvider.hpp"
|
||||
// #include "gltfio/materials/uberarchive.h"
|
||||
|
||||
|
||||
@@ -908,9 +908,23 @@ void FilamentViewer::setCameraPosition(float x, float y, float z) {
|
||||
cam.setModelMatrix(_cameraPosition * _cameraRotation);
|
||||
}
|
||||
|
||||
void FilamentViewer::moveCameraToAsset(EntityId entityId) {
|
||||
|
||||
auto asset = _assetManager->getAssetByEntityId(entityId);
|
||||
if(!asset) {
|
||||
Log("Failed to find asset attached to specified entity id.");
|
||||
return;
|
||||
}
|
||||
|
||||
const filament::Aabb bb = asset->mAsset->getBoundingBox();
|
||||
Camera& cam =_view->getCamera();
|
||||
_cameraPosition = math::mat4f::translation(bb.getCorners());
|
||||
_cameraRotation = math::mat4f();
|
||||
cam.setModelMatrix(_cameraPosition * _cameraRotation);
|
||||
}
|
||||
|
||||
void FilamentViewer::setCameraRotation(float rads, float x, float y, float z) {
|
||||
Camera& cam =_view->getCamera();
|
||||
|
||||
_cameraRotation = math::mat4f::rotation(rads, math::float3(x,y,z));
|
||||
cam.setModelMatrix(_cameraPosition * _cameraRotation);
|
||||
}
|
||||
|
||||
@@ -96,6 +96,10 @@ extern "C" {
|
||||
return ((FilamentViewer*)viewer)->setCamera(asset, nodeName);
|
||||
}
|
||||
|
||||
void move_camera_to_asset(const void* const viewer, EntityId asset) {
|
||||
((FilamentViewer*)viewer)->moveCameraToAsset(asset, asset);
|
||||
}
|
||||
|
||||
void set_camera_focus_distance(const void* const viewer, float distance) {
|
||||
((FilamentViewer*)viewer)->setCameraFocusDistance(distance);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user