GitBrincie212 / Apel-Mod

Apel is a library that brings particle animations to the table with flexible behaviour and a clean developer interface. It promises also lots of predefined shapes & paths to help the developer on their particle scene
Other
2 stars 1 forks source link

Abstract ServerWorld behind ApelRenderer #13

Closed DarthSharkie closed 2 months ago

DarthSharkie commented 3 months ago

By inserting a renderer, the developer can now control how and where particles are rendered. Right now, the only option is still via ServerWorld, so this seems simple. Future options will include the ability to "bake" an animation, send the rendering instructions to the client, and potentially more destinations.

ApelRenderer is an interface that all renderers should satisfy, and it is currently used as a factory for producing instances. This may change, but that will evolve as more renderers come along and have one or more options to configure them.

Once an animation is baked (perhaps via ApelBakingRenderer), loading that file to a (future) ReplayAnimator would then be able to use the existing ApelServerWorldRenderer to display it. Once packets are ready, it could use a ApelPacketRenderer.

Super simple example code:

void animate(ServerWorld world, PlayerEntity user) {
    // Setup a line
    Vector3f start = new Vector3f(-3, 1, 1);
    Vector3f end = new Vector3f(3, 1, 1);
    ParticleLine line1 = new ParticleLine(ParticleTypes.COMPOSTER, start, end, 5);

    // Setup an Animator
    Vector3f origin = user.getPos().toVector3f().add(0, 1, 4);
    PointAnimator animator = new PointAnimator(1, line1, origin, 100);.

    // Perform the animation
    animator.beginAnimation(ApelRenderer.create(world));
}
DarthSharkie commented 2 months ago

Updated for the BezierPathAnimator.