refactoring
This commit is contained in:
@@ -47,6 +47,16 @@ namespace thermion
|
||||
camera->setCustomProjection(convert_double4x4_to_mat4(projectionMatrix), near, far);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE double Camera_getFocusDistance(TCamera *camera) {
|
||||
auto *camera = reinterpret_cast<Camera *>(tCamera);
|
||||
return camera->getFocusDistance();
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void Camera_setFocusDistance(TCamera *camera, float distance) {
|
||||
auto *camera = reinterpret_cast<Camera *>(tCamera);
|
||||
return camera->setFocusDistance(distance);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE double4x4 Camera_getModelMatrix(TCamera *tCamera)
|
||||
{
|
||||
auto *camera = reinterpret_cast<Camera *>(tCamera);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <math/vec2.h>
|
||||
|
||||
#include "Log.hpp"
|
||||
#include "materials/image.h"
|
||||
#include "c_api/TMaterialInstance.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -23,6 +24,26 @@ namespace thermion
|
||||
return reinterpret_cast<TMaterialInstance *>(instance);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE TMaterial *Material_createImageMaterial(TEngine *tEngine) {
|
||||
auto *engine = reinterpret_cast<filament::Engine *>(tEngine);
|
||||
auto *material = Material::Builder()
|
||||
.package(IMAGE_IMAGE_DATA, IMAGE_IMAGE_SIZE)
|
||||
.build(*engine);
|
||||
|
||||
return reinterpret_cast<TMaterial *>(material);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE TMaterial *Material_createGridMaterial(TEngine *tEngine) {
|
||||
auto *engine = reinterpret_cast<filament::Engine *>(tEngine);
|
||||
auto *material = Material::Builder()
|
||||
.package(GRID_GRID_DATA, GRID_GRID_SIZE)
|
||||
.build(*engine);
|
||||
|
||||
return reinterpret_cast<TMaterial *>(material);
|
||||
}
|
||||
|
||||
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE bool Material_hasParameter(TMaterial *tMaterial, const char *propertyName) {
|
||||
auto *material = reinterpret_cast<filament::Material *>(tMaterial);
|
||||
return material->hasParameter(propertyName);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "c_api/TGltfAssetLoader.h"
|
||||
#include "c_api/TSceneAsset.h"
|
||||
#include "scene/GridOverlay.hpp"
|
||||
#include "scene/SceneAsset.hpp"
|
||||
#include "scene/GltfSceneAsset.hpp"
|
||||
#include "scene/GeometrySceneAssetBuilder.hpp"
|
||||
@@ -89,6 +90,13 @@ extern "C"
|
||||
return reinterpret_cast<TSceneAsset *>(sceneAsset);
|
||||
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE TSceneAsset *SceneAsset_createGrid(TEngine *tEngine, TMaterial* tMaterial) {
|
||||
auto *engine = reinterpret_cast<filament::Engine *>(tEngine);
|
||||
auto *material = reinterpret_cast<filament::Material *>(tMaterial);
|
||||
auto *asset = new GridOverlay(*engine, material);
|
||||
return reinterpret_cast<TSceneAsset *>(asset);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void SceneAsset_destroy(TSceneAsset *tSceneAsset) {
|
||||
auto *asset = reinterpret_cast<SceneAsset*>(tSceneAsset);
|
||||
|
||||
@@ -67,8 +67,8 @@ extern "C"
|
||||
return;
|
||||
}
|
||||
|
||||
auto center = aabb.center();
|
||||
auto halfExtent = aabb.extent();
|
||||
auto center = filament::math::float3 { boundingBox.centerX, boundingBox.centerY, boundingBox.centerZ };
|
||||
auto halfExtent = filament::math::float3 { boundingBox.halfExtentX, boundingBox.halfExtentY, boundingBox.halfExtentZ };
|
||||
auto maxExtent = max(halfExtent) * 2;
|
||||
auto scaleFactor = 2.0f / maxExtent;
|
||||
auto transform = math::mat4f::scaling(scaleFactor) * math::mat4f::translation(-center);
|
||||
|
||||
Reference in New Issue
Block a user