Author Topic: Move a Cube (just a Primitives.getCube(...) Cube)  (Read 1061 times)

Offline SteveRaphaellos

  • byte
  • *
  • Posts: 6
    • View Profile
Move a Cube (just a Primitives.getCube(...) Cube)
« on: December 11, 2013, 05:49:08 pm »
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 <<

Offline SteveRaphaellos

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Move a Cube (just a Primitives.getCube(...) Cube)
« Reply #1 on: December 11, 2013, 05:53:10 pm »
I found the topic now :/.
Here the link :
http://www.jpct.net/forum2/index.php/topic,3631.0.html

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11744
    • View Profile
    • http://www.jpct.net
Re: Move a Cube (just a Primitives.getCube(...) Cube)
« Reply #2 on: December 11, 2013, 08:37:47 pm »
Not sure if that thread describes your problem...to move an object, just call http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Object3D.html#translate(float, float, float).

Offline SteveRaphaellos

  • byte
  • *
  • Posts: 6
    • View Profile
Re: Move a Cube (just a Primitives.getCube(...) Cube)
« Reply #3 on: December 11, 2013, 10:23:53 pm »
That works fine. :p
I didn't try the other topic's method yet, but cause this one works it's all right, thx ;)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11744
    • View Profile
    • http://www.jpct.net
Re: Move a Cube (just a Primitives.getCube(...) Cube)
« Reply #4 on: December 11, 2013, 10:39:52 pm »
That other thread was more about moving an object to the location of a touch event. Not so much about the translation itself.