www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: SteveRaphaellos on December 11, 2013, 05:49:08 pm

Title: Move a Cube (just a Primitives.getCube(...) Cube)
Post by: SteveRaphaellos 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 <<
Title: Re: Move a Cube (just a Primitives.getCube(...) Cube)
Post by: SteveRaphaellos 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 (http://www.jpct.net/forum2/index.php/topic,3631.0.html)
Title: Re: Move a Cube (just a Primitives.getCube(...) Cube)
Post by: EgonOlsen 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) (http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Object3D.html#translate(float, float, float)).
Title: Re: Move a Cube (just a Primitives.getCube(...) Cube)
Post by: SteveRaphaellos 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 ;)
Title: Re: Move a Cube (just a Primitives.getCube(...) Cube)
Post by: EgonOlsen 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.