add animation fading and revert to platform channel handler
This commit is contained in:
@@ -17,7 +17,7 @@ namespace polyvox {
|
||||
|
||||
class AssetManager {
|
||||
public:
|
||||
AssetManager(ResourceLoaderWrapper* loader,
|
||||
AssetManager(const ResourceLoaderWrapper* const loader,
|
||||
NameComponentManager *ncm,
|
||||
Engine *engine,
|
||||
Scene *scene);
|
||||
@@ -40,7 +40,6 @@ namespace polyvox {
|
||||
size_t getLightEntityCount(EntityId e) const noexcept;
|
||||
void updateAnimations();
|
||||
|
||||
|
||||
bool setMorphAnimationBuffer(
|
||||
EntityId entityId,
|
||||
const char* entityName,
|
||||
@@ -59,7 +58,7 @@ namespace polyvox {
|
||||
const char** const meshName,
|
||||
int numMeshTargets,
|
||||
float frameLengthInMs);
|
||||
void playAnimation(EntityId e, int index, bool loop, bool reverse);
|
||||
void playAnimation(EntityId e, int index, bool loop, bool reverse, float crossfade = 0.3f);
|
||||
void stopAnimation(EntityId e, int index);
|
||||
void setMorphTargetWeights(const char* const entityName, float *weights, int count);
|
||||
void loadTexture(EntityId entity, const char* resourcePath, int renderableIndex);
|
||||
@@ -69,7 +68,7 @@ namespace polyvox {
|
||||
|
||||
private:
|
||||
AssetLoader* _assetLoader = nullptr;
|
||||
ResourceLoaderWrapper* _resourceLoaderWrapper;
|
||||
const ResourceLoaderWrapper* const _resourceLoaderWrapper;
|
||||
NameComponentManager* _ncm = nullptr;
|
||||
Engine* _engine;
|
||||
Scene* _scene;
|
||||
|
||||
@@ -44,8 +44,7 @@ typedef int32_t EntityId;
|
||||
namespace polyvox {
|
||||
class FilamentViewer {
|
||||
public:
|
||||
// FilamentViewer(void* layer, LoadResource loadResource, FreeResource freeResource);
|
||||
FilamentViewer(void* context, ResourceLoaderWrapper* resourceLoaderWrapper);
|
||||
FilamentViewer(const void* context, const ResourceLoaderWrapper* const resourceLoaderWrapper);
|
||||
~FilamentViewer();
|
||||
|
||||
void loadSkybox(const char* const skyboxUri);
|
||||
@@ -64,7 +63,7 @@ namespace polyvox {
|
||||
|
||||
bool setCamera(EntityId asset, const char* nodeName);
|
||||
|
||||
void createSwapChain(void* surface, uint32_t width, uint32_t height);
|
||||
void createSwapChain(const void* surface, uint32_t width, uint32_t height);
|
||||
void destroySwapChain();
|
||||
|
||||
void createRenderTarget(uint32_t glTextureId, uint32_t width,uint32_t height);
|
||||
@@ -108,7 +107,7 @@ namespace polyvox {
|
||||
math::mat4f _cameraPosition;
|
||||
math::mat4f _cameraRotation;
|
||||
|
||||
ResourceLoaderWrapper* _resourceLoaderWrapper;
|
||||
const ResourceLoaderWrapper* const _resourceLoaderWrapper;
|
||||
|
||||
Scene* _scene;
|
||||
View* _view;
|
||||
|
||||
@@ -3,43 +3,38 @@
|
||||
|
||||
#include "ResourceBuffer.hpp"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef int32_t EntityId;
|
||||
|
||||
void* create_filament_viewer(void *context, ResourceLoaderWrapper* loader);
|
||||
const void* create_filament_viewer(const void* const context, const ResourceLoaderWrapper* const loader);
|
||||
ResourceLoaderWrapper* make_resource_loader(LoadResourceFromOwner loadFn, FreeResourceFromOwner freeFn, void* owner);
|
||||
void delete_filament_viewer(void *viewer);
|
||||
void* get_asset_manager(void* viewer);
|
||||
void create_render_target(void *viewer, uint32_t textureId, uint32_t width, uint32_t height);
|
||||
void clear_background_image(void *viewer);
|
||||
void set_background_image(void *viewer, const char *path);
|
||||
void set_background_image_position(void *viewer, float x, float y, bool clamp);
|
||||
void set_background_color(void *viewer, const float r, const float g, const float b, const float a);
|
||||
void load_skybox(void *viewer, const char *skyboxPath);
|
||||
void load_ibl(void *viewer, const char *iblPath, float intensity);
|
||||
void remove_skybox(void *viewer);
|
||||
void remove_ibl(void *viewer);
|
||||
EntityId add_light(void *viewer, uint8_t type, float colour, float intensity, float posX, float posY, float posZ, float dirX, float dirY, float dirZ, bool shadows);
|
||||
void remove_light(void *viewer, EntityId entityId);
|
||||
void clear_lights(void *viewer);
|
||||
void delete_filament_viewer(const void* const viewer);
|
||||
void* get_asset_manager(const void* const viewer);
|
||||
void create_render_target(const void* const viewer, uint32_t textureId, uint32_t width, uint32_t height);
|
||||
void clear_background_image(const void* const viewer);
|
||||
void set_background_image(const void* const viewer, const char *path);
|
||||
void set_background_image_position(const void* const viewer, float x, float y, bool clamp);
|
||||
void set_background_color(const void* const viewer, const float r, const float g, const float b, const float a);
|
||||
void load_skybox(const void* const viewer, const char *skyboxPath);
|
||||
void load_ibl(const void* const viewer, const char *iblPath, float intensity);
|
||||
void remove_skybox(const void* const viewer);
|
||||
void remove_ibl(const void* const viewer);
|
||||
EntityId add_light(const void* const viewer, uint8_t type, float colour, float intensity, float posX, float posY, float posZ, float dirX, float dirY, float dirZ, bool shadows);
|
||||
void remove_light(const void* const viewer, EntityId entityId);
|
||||
void clear_lights(const void* const viewer);
|
||||
EntityId load_glb(void *assetManager, const char *assetPath, bool unlit);
|
||||
EntityId load_gltf(void *assetManager, const char *assetPath, const char *relativePath);
|
||||
bool set_camera(void *viewer, EntityId asset, const char *nodeName);
|
||||
void render(void *viewer, uint64_t frameTimeInNanos);
|
||||
void create_swap_chain(void *viewer, void *surface, uint32_t width, uint32_t height);
|
||||
void destroy_swap_chain(void *viewer);
|
||||
void set_frame_interval(void *viewer, float interval);
|
||||
void* get_renderer(void *viewer);
|
||||
void update_viewport_and_camera_projection(void *viewer, int width, int height, float scaleFactor);
|
||||
void scroll_begin(void *viewer);
|
||||
void scroll_update(void *viewer, float x, float y, float z);
|
||||
void scroll_end(void *viewer);
|
||||
|
||||
void grab_begin(void *viewer, float x, float y, bool pan);
|
||||
void grab_update(void *viewer, float x, float y);
|
||||
void grab_end(void *viewer);
|
||||
|
||||
bool set_camera(const void* const viewer, EntityId asset, const char *nodeName);
|
||||
void render(const void* const viewer, uint64_t frameTimeInNanos);
|
||||
void create_swap_chain(const void* const viewer, const void* const surface, uint32_t width, uint32_t height);
|
||||
void destroy_swap_chain(const void* const viewer);
|
||||
void set_frame_interval(const void* const viewer, float interval);
|
||||
void update_viewport_and_camera_projection(const void* const viewer, int width, int height, float scaleFactor);
|
||||
void scroll_begin(const void* const viewer);
|
||||
void scroll_update(const void* const viewer, float x, float y, float z);
|
||||
void scroll_end(const void* const viewer);
|
||||
void grab_begin(const void* const viewer, float x, float y, bool pan);
|
||||
void grab_update(const void* const viewer, float x, float y);
|
||||
void grab_end(const void* const viewer);
|
||||
void apply_weights(
|
||||
void* assetManager,
|
||||
EntityId asset,
|
||||
@@ -47,7 +42,6 @@ void apply_weights(
|
||||
float *const weights,
|
||||
int count
|
||||
);
|
||||
|
||||
void set_morph_target_weights(
|
||||
void* assetManager,
|
||||
EntityId asset,
|
||||
@@ -55,7 +49,6 @@ void set_morph_target_weights(
|
||||
const float *const morphData,
|
||||
int numWeights
|
||||
);
|
||||
|
||||
bool set_morph_animation(
|
||||
void* assetManager,
|
||||
EntityId asset,
|
||||
@@ -64,7 +57,6 @@ bool set_morph_animation(
|
||||
int numMorphWeights,
|
||||
int numFrames,
|
||||
float frameLengthInMs);
|
||||
|
||||
void set_bone_animation(
|
||||
void* assetManager,
|
||||
EntityId asset,
|
||||
@@ -76,29 +68,30 @@ void set_bone_animation(
|
||||
int numMeshTargets,
|
||||
float frameLengthInMs);
|
||||
|
||||
void play_animation(void* assetManager, EntityId asset, int index, bool loop, bool reverse);
|
||||
void play_animation(void* assetManager, EntityId asset, int index, bool loop, bool reverse, float crossfade);
|
||||
void set_animation_frame(void* assetManager, EntityId asset, int animationIndex, int animationFrame);
|
||||
void stop_animation(void* assetManager, EntityId asset, int index);
|
||||
int get_animation_count(void* assetManager, EntityId asset);
|
||||
void get_animation_name(void* assetManager, EntityId asset, char *const outPtr, int index);
|
||||
void get_morph_target_name(void* assetManager, EntityId asset, const char *meshName, char *const outPtr, int index);
|
||||
int get_morph_target_name_count(void* assetManager, EntityId asset, const char *meshName);
|
||||
void remove_asset(void *viewer, EntityId asset);
|
||||
void clear_assets(void *viewer);
|
||||
void remove_asset(const void* const viewer, EntityId asset);
|
||||
void clear_assets(const void* const viewer);
|
||||
void load_texture(void* assetManager, EntityId asset, const char *assetPath, int renderableIndex);
|
||||
void set_texture(void* assetManager, EntityId asset);
|
||||
void transform_to_unit_cube(void* assetManager, EntityId asset);
|
||||
void set_position(void* assetManager, EntityId asset, float x, float y, float z);
|
||||
void set_rotation(void* assetManager, EntityId asset, float rads, float x, float y, float z);
|
||||
void set_scale(void* assetManager, EntityId asset, float scale);
|
||||
void set_camera_exposure(void *viewer, float aperture, float shutterSpeed, float sensitivity);
|
||||
void set_camera_position(void *viewer, float x, float y, float z);
|
||||
void set_camera_rotation(void *viewer, float rads, float x, float y, float z);
|
||||
void set_camera_model_matrix(void *viewer, const float *const matrix);
|
||||
void set_camera_focal_length(void *viewer, float focalLength);
|
||||
void set_camera_focus_distance(void *viewer, float focusDistance);
|
||||
void set_camera_exposure(const void* const viewer, float aperture, float shutterSpeed, float sensitivity);
|
||||
void set_camera_position(const void* const viewer, float x, float y, float z);
|
||||
void set_camera_rotation(const void* const viewer, float rads, float x, float y, float z);
|
||||
void set_camera_model_matrix(const void* const viewer, const float *const matrix);
|
||||
void set_camera_focal_length(const void* const viewer, float focalLength);
|
||||
void set_camera_focus_distance(const void* const viewer, float focusDistance);
|
||||
int hide_mesh(void* assetManager, EntityId asset, const char* meshName);
|
||||
int reveal_mesh(void* assetManager, EntityId asset, const char* meshName);
|
||||
void ios_dummy();
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -51,14 +51,14 @@ extern "C" {
|
||||
|
||||
};
|
||||
|
||||
ResourceBuffer load(const char* uri) {
|
||||
ResourceBuffer load(const char* uri) const {
|
||||
if(mLoadResourceFromOwner) {
|
||||
return mLoadResourceFromOwner(uri, mOwner);
|
||||
}
|
||||
return mLoadResource(uri);
|
||||
}
|
||||
|
||||
void free(ResourceBuffer rb) {
|
||||
void free(ResourceBuffer rb) const {
|
||||
if(mFreeResourceFromOwner) {
|
||||
mFreeResourceFromOwner(rb, mOwner);
|
||||
} else {
|
||||
|
||||
@@ -35,8 +35,8 @@ namespace polyvox {
|
||||
time_point_t mStart = time_point_t::max();
|
||||
bool mLoop = false;
|
||||
bool mReverse = false;
|
||||
float mDuration = 0;
|
||||
bool mAnimating = false;
|
||||
float mDuration = 0;
|
||||
bool mActive = false;
|
||||
};
|
||||
|
||||
//
|
||||
@@ -73,10 +73,16 @@ namespace polyvox {
|
||||
FilamentAsset* mAsset = nullptr;
|
||||
Animator* mAnimator = nullptr;
|
||||
|
||||
// fixed-sized vector containing the status of the morph, bone and GLTF animations.
|
||||
// entries 0 and 1 are the morph/bone animations.
|
||||
// subsequent entries are the GLTF animations.
|
||||
vector<AnimationStatus> mAnimations;
|
||||
// fixed-sized array containing pointers to the active morph, bone and GLTF animations.
|
||||
AnimationStatus mAnimations[3];
|
||||
// the index of the active glTF animation in the Filament Asset animations array
|
||||
// if no glTF animation is active, this is -1
|
||||
int gltfAnimationIndex = -1;
|
||||
// the index of the last active glTF animation,
|
||||
// used to cross-fade
|
||||
int fadeGltfAnimationIndex = -1;
|
||||
float fadeDuration = 0.0f;
|
||||
float fadeOutAnimationStart = 0.0f;
|
||||
|
||||
MorphAnimationBuffer mMorphAnimationBuffer;
|
||||
BoneAnimationBuffer mBoneAnimationBuffer;
|
||||
@@ -96,12 +102,6 @@ namespace polyvox {
|
||||
FilamentAsset* asset
|
||||
) : mAsset(asset) {
|
||||
mAnimator = mAsset->getInstance()->getAnimator();
|
||||
|
||||
mAnimations.resize(2 + mAnimator->getAnimationCount());
|
||||
|
||||
for(int i=0; i < mAnimations.size() - 2; i++) {
|
||||
mAnimations[i].mDuration = mAnimator->getAnimationDuration(i);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user