Here's something that seems to work as long as the rotation pivots are at the origin in object space. If they are not, you somehow have to compensate for that, but i didn't have the time to figure it out. Anyway, maybe it helps:
import java.awt.Color;
import org.lwjgl.opengl.Display;
import com.threed.jpct.*;
import com.threed.jpct.util.Light;
public class ChildTest
{
/**
* @param args
*/
public static void main(String[] args)
throws Exception
{
FrameBuffer buffer = new FrameBuffer(640, 480, FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY);
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
buffer.enableRenderer(IRenderer.RENDERER_OPENGL);
World world = new World();
Light light = new Light(world);
light.setPosition(new SimpleVector(0, -100, -100));
light.setAttenuation(-1);
light.setIntensity(255, 100, 199);
Object3D obj = Primitives.getEllipsoid(10, 2);
obj.compile();
world.addObject(obj);
obj.rotateZ(1.2f);
obj.rotateX(-0.62f);
obj.rotateY(-0.1f);
obj.translate(20, -10, 10);
Object3D cone = Primitives.getCone(5);
cone.compile();
world.addObject(cone);
cone.rotateZ(-0.2f);
cone.rotateY(-0.2f);
cone.rotateX(0.25f);
world.buildAllObjects();
cone.setRotationPivot(SimpleVector.ORIGIN);
world.getCamera().moveCamera(Camera.CAMERA_MOVEOUT, 100);
world.getCamera().moveCamera(Camera.CAMERA_MOVEUP, 100);
world.getCamera().lookAt(obj.getTransformedCenter());
long start = System.currentTimeMillis();
while (!Display.isCloseRequested())
{
if (start != 0 && System.currentTimeMillis() - start > 1000)
{
start = 0;
Matrix m = obj.getRotationMatrix();
m = m.invert();
cone.getRotationMatrix().matMul(m);
SimpleVector offset = cone.getTranslation().calcSub(obj.getTranslation());
offset.matMul(m);
cone.clearTranslation();
cone.translate(offset);
obj.addChild(cone);
}
if (start == 0)
{
obj.translate(-0.25f, 0.25f, -0.25f);
}
else
{
cone.translate(0.5f, 0, 0);
}
buffer.clear(Color.BLUE);
world.renderScene(buffer);
world.draw(buffer);
buffer.update();
buffer.displayGLOnly();
Thread.sleep(10);
}
System.exit(0);
}
}