Move a Cube (just a Primitives.getCube(...) Cube)

Started by SteveRaphaellos, December 11, 2013, 05:49:08 PM

Previous topic - Next topic

SteveRaphaellos

Hello Community.
Im new here and i didn't find my topic (I'm a bad Googler or it's not existing ? :p) yet.
So I ask you : How to move a cube which just needs to be a Primitives cube ?
What do I need to change in the following to move the cube?

Peace of code :

int SIZE = 64;
Context mastercontext = null;
FrameBuffer fb = null;
World world = null;
RGBColor back = new RGBColor(50, 50, 100);
Light sun = null;
Object3D cube = null;

@Override
   public void onSurfaceChanged(GL10 gl, int width, int height) {
      if(fb != null)
         fb.dispose();
      
      fb = new FrameBuffer(gl, width, height);
      
      if(masteractivity == null) {
         world = new World();
         world.setAmbientLight(120, 120, 120);
         sun = new Light(world);
         sun.setIntensity(250, 250, 250);
         
         Texture tex = new Texture(BitmapHelper.rescale(BitmapHelper.
               convert(mastercontext.getResources().getDrawable(R.drawable.test)), SIZE, SIZE));
         
         TextureManager.getInstance().addTexture("tex", tex);
         cube = Primitives.getCube(10);
         cube.calcTextureWrapSpherical();
         cube.setTexture("tex");
         cube.strip();
         cube.build();
         
         world.addObject(cube);
         
         Camera cam = world.getCamera();
         cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
         cam.lookAt(cube.getTransformedCenter());
         
         SimpleVector sv = new SimpleVector();
         sv.set(cube.getTransformedCenter());
         sv.y = -100;
         sv.x = -100;
         sun.setPosition(sv);
         MemoryHelper.compact();
      }
   }

Thanks for reading until this line, hope you can help. ;)
>> SteveRaphaellos <<


EgonOlsen


SteveRaphaellos

That works fine. :p
I didn't try the other topic's method yet, but cause this one works it's all right, thx ;)

EgonOlsen

That other thread was more about moving an object to the location of a touch event. Not so much about the translation itself.