Search code examples
javaopengl-esthree.jsrajawali

Apply matrix to sphere/Object3D


I have a 360° panorama picture (texture) that I map around a sphere and I place my camera inside the sphere to have a spherical projection. Now the texture is projected on the outside of the sphere. I want to 'turn the texture inside-out' and i read it could be done by applying a matrix.

I'd like to apply a matrix to a sphere (Object3D) in Rajawali/OpenGL.

This can be done in ThreeJS like this:

var sphere = new THREE.SphereGeometry(100, 100, 40);
sphere.applyMatrix(new THREE.Matrix4().makeScale(-1, 1, 1));

three.js documentation for applyMatrix:

this updates the position, rotation and scale with the matrix.

and I'd like to do this in Rajawali:

mSphere = new Sphere(100, 100, 40);
//Apply the matrix here

Documentation for Matrix/Object3D can be found here Matrix4 Object3D

Or is there any other way it could be done?


Solution

  • This has been fixed!

    mSphere = new Sphere(100, 100, 40);
    mSphere.setScaleX(-1);
    mSphere.setScaleY(1);
    mSphere.setScaleZ(1);