Login  Register

How to duplicate a cube and control each one independently?

Posted by Ususuus on Aug 12, 2017; 6:31am
URL: https://forum.jogamp.org/How-to-duplicate-a-cube-and-control-each-one-independently-tp4038114.html

i want to duplicate a number of copies of an module which is from an .obj file,  and i wish:

1. don't want to read them all through file, i suspect this would result in slow loading and extra memory.
2. control them indepently, like location and angle
3. can "hide" (disapear) any of them.

current code is as below, my problem is that:

1. can put the to somewhere and in certain angle, but the location and angle is based on the prior location or angle.
2. can't identify each of them ,so can't hide a particular one.( can't identify so sure can't hide...)

do i have to create them all through reading obj files?  i tested and the CPU load was very low but cost lot more memory. with the code below, the cpu and memory is neary same with one obj.

in display:
for (int i=0;i<10;i++){
        chairModel.mRotate();
        chairModel.mDraw();
}

class func:
public void mRotate(){
        gl.glRotatef((float)Math.random()*360, 0f, 1f, 0f);
        gl.glTranslatef(1, 10-(float)Math.random(), -1);
}
public void mDraw() {
        gl.glCallList(objectlist);
        gl.glDisable(GL2.GL_COLOR_MATERIAL);
}