Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - sergey

Pages: [1]
1
Thank you for your reply. Your example will be useful. Waiting forward to your sources. :)

2
hi

I have a plane
Code: [Select]
for (int iz = 1; iz < 11; iz++) {
                int z = iz * 12;

                for (int i = 0; i < 10; i++) {
                    int x = i * 12;

                    addHPolygon(box2, x, x + 12, 0, z, z - 12, 1,
                            tm.getTextureID("floor2"));

                }
            }
            box2.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);


addHPolygon (create 2 triangles)

and  a some box on that plane
Code: [Select]

box = Loader.load3DS(res.openRawResource(R.raw.crate), 0.095f)[0];
box.setTexture("box1");
box.translate(4, -10, 0);
box.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);


Camera
Code: [Select]
Camera cam = world.getCamera();
cam.setPosition(0, -40, 0);
cam.lookAt(new SimpleVector(0, 0, 0));

I want that  "box" is moved in the plane of "box2".  Move to some point, specified by touch.
I fount thread http://www.jpct.net/forum2/index.php/topic,791.0.html where, as i think, what I need.

i try use that,

on touch event:

Code: [Select]
SimpleVector ray=Interact2D.reproject2D3DWS(world.getCamera(), fb, (int)xpos, (int)ypos);
             
             distance = world.calcMinDistance(world.getCamera().getPosition(), ray, 10000F);
             if (distance!=Object3D.COLLISION_NONE) {
                 SimpleVector offset=new SimpleVector(ray);
              ray.scalarMul(distance);
             
              ray=ray.calcSub(offset);
             
              world.getObjectByName("box").translate(world.getCamera().getPosition());
             
              world.getObjectByName("box").translate(ray);
             }

But it does not work for me. Maybe you could help me by giving advice or an example of such a problem.

thank you.



3
Support / How to add and display a triangle with texture
« on: September 17, 2010, 11:16:17 pm »
I try create a triangle

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
   TextureManager.getInstance().flush();
   world = new World();
   Resources res = getResources();

   TextureManager tm = TextureManager.getInstance();
   
        Texture grass_f = new Texture(res.openRawResource(R.raw.grass));
   
   font = new Texture(res.openRawResource(R.raw.numbers));
         
   tm.addTexture("grass", grass_f);
   
   s1.set(0.0f, 0.0f, 120.0f);
   s2.set(120.0f, 0.0f, 120.0f);
   s3.set(120.0f, 0.0f, 0.0f);                                    
   //box2 = new Object3d(2);         
box2.addTriangle(s1, 0, 1, s2, 1, 1, s3, 1, 0, tm.getTextureID("grass"));
            
            s2.set(0, 0, 0);
            
            box2.addTriangle(s3, 1, 0, s2, 0, 0, s1, 0, 1, tm.getTextureID("grass"));
            
         box2.setName("box2");
         world.addObject(box2);
         world.buildAllObjects();

         sun = new Light(world);

         Camera cam = world.getCamera();

         cam.moveCamera(Camera.CAMERA_MOVEUP, 20);
         cam.lookAt(box2.getTransformedCenter());

         cam.setFOV(1.5f);
         sun.setIntensity(250, 250, 250);

         SimpleVector sv = new SimpleVector();
         sv.set(box2.getTransformedCenter());
         sv.y -= 300;
         sv.x -= 100;
         sv.z += 200;
         sun.setPosition(sv);
      }

It's not working for me :(

Pages: [1]