Egon,
I will do.
I'll try to post the code tonight, but I personally don't think you need to expose anything additional. I was working on some refactoring/code-clean-up last night, as I wanted to clean it up before posting, and now it really needs to reside in the namespace.
Originally to test the functionality, I was using a separate shader for each 3D model instance and updating the uniforms manually on every frame. Obviously this is not a good approach, but it was for quick testing of the shader and the passing of the data into shader.
Last night I tied it into the JPCT render pipeline, but in a sort of hacky-approach as I was attempting to add it without changing the JPCT library, which I'll describe below that requires the namespace. The way the code works is as such:
- com.threed.jpct.GPUAnimated3D extends Animated3D (which extends Object3D). In this class, I am overriding the void getInternalShader() call. It needs to be in the JPCT namespace to override the call. The getInternalShader() gets called once in the JPCT render pipeline on the render visList before it renders the object. This method shouldn't really be exposed as its meant to be internal (as the name describes ). Inside this overwritten method, it fetches the shader and checks the instance name of the shader attached to the object and if it extends the GPUAnimated3DShader class, it will cast it and call a new shader method passing the GPUAnimated3D. The class constructor fetches the attached mesh and appends skin vertex attributes if they don't already exist (cloning using same mesh)
- com.threed.jpct.GPUAnimated3DShader extends GLSLShader. Kept in the namespace for uniformity. This class constructor sets up handlers for the skin vertex attributes. It also contains a method for setting the skeleton pose matrices as a couple of uniforms from a passed in GPUAnimated3D (called by the GPUAnimated3D).
This ties it into the render pipeline, where if the object added to the world is a GPUAnimated3D, it will update/override the shader uniforms, per Object, of its SkeletalPose before its rendered. Now you can use 1 shader for all GPUAnimated3D objects and different meshes.
I just have a little refactoring to do tonight of moving the setAnimation() into the GPUAnimated3D (which excludes the code for applying the SkeletalPose to the vertices on the software-side), so that it only updates/creates the bone matrices.
It will be easier to see when I post the code. Hopefully I will get some time tonight.
NOTE: I only checked the regular render pipeline. It may not animate in wireframe rendering.