Main Menu
Menu

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.

Show posts Menu

Messages - aklenka

#1
Dear Sir,

I have changed the code as per your comments, but I am not getting any change on the rendered object. Still the objects are destruction. Depending on touch point location I am getting the particular object selectmodel in getWorldPosition.

I have attached my whole code whatever I am doing in loadModel, onSurfaceChanged and onDrawFrame function.

Please check my attached file. Is there some wrong I did in these code?

Thanks & regards
Anil


[attachment deleted by admin]
#2
Dear Sir,

Many thanks for your reply.

I tried to change the code like below attached without merging the Object3D[], I rendered, now I am able to pick each parts of the object but the objects are destructing. I have attached the original object and destruction object for your reference. Is there any scope without merge we can render the object without any destruction? I need your valuable guidance.

public void onSurfaceChanged(GL10 gl, int w, int h) {
if (buffer != null) {
buffer.dispose();
}
buffer = new FrameBuffer(gl, w, h);
// if (master == null)
{
world = new World();
world.setAmbientLight(150, 150, 150);
sun = new Light(world);
sun.setIntensity(250, 250, 250);
int rID = R.raw.car;
try {
//model = Object3D.mergeAll(loadModel(rID, modelScale));
thing = loadModel(rID, modelScale);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//model.build();
                 
for (int i = 0; i < thing.length; i++) { thing[i].setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
thing[i].setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
thing[i].build();
}

//world.addObject(model);
for (int i = 0; i < thing.length; i++) {
world.addObject(thing[i]);
}

cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
//cam.lookAt(model.getTransformedCenter());
for(int i=0;i<thing.length;i++){
cam.lookAt(thing[i].getTransformedCenter());
}
SimpleVector sv = new SimpleVector();
//sv.set(model.getTransformedCenter());
for(int i=0;i<thing.length;i++){
sv.set(thing[i].getTransformedCenter());
}
sv.y -= 100;
sv.z -= 100;
sun.setPosition(sv);
if(bInitObjectPos){
initObjectSetting();
bInitObjectPos = false;
}
}
}


private SimpleVector getWorldPosition(float X, float Y)
  {
  String keyValue = "";
SimpleVector pos = null;
SimpleVector ray = Interact2D.reproject2D3DWS(world.getCamera(),
buffer, (int) X, (int) Y);
if (ray != null) {
SimpleVector norm = ray.normalize();
Object[] slectedModel = world.calcMinDistanceAndObject3D(world.getCamera().getPosition(), norm, 1000);
if (slectedModel[1] != null) {

Object3D selectmodel = (Object3D)slectedModel[1];

keyValue = objHashTable.get(selectmodel.toString());}
}
return pos;
  }


Thanks & regards
Anil


[attachment deleted by admin]
#3
I am new user of JPCT-AE. It may be silly question, but I tried too much I am not getting any such result.

My problem is, I have a car object which having 7-8 mess or 30-40 array of Object3D but the file is single and the format is car.3ds. I have loaded the car and displaying in the screen, when the user will pick any part of the car(i.e. tire, light, body etc.) only that part or mesh should be identified. I have tried but I am not getting whole car. Please suggest me how can I get identify individual parts or mess/part of the car. I have attached the code for your verification, whatever way I tried.

public void onSurfaceChanged(GL10 gl, int w, int h) {
         if (buffer != null) {
            buffer.dispose();
         }
         buffer = new FrameBuffer(gl, w, h);
         // if (master == null)
         {
            world = new World();
            world.setAmbientLight(150, 150, 150);
            sun = new Light(world);
            sun.setIntensity(250, 250, 250);
            int rID = R.raw.car;
            try {
               model = Object3D.mergeAll(loadModel(rID, modelScale));            } catch (IOException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
            }
            model.build();
            world.addObject(model);
            cam = world.getCamera();
            cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
            cam.lookAt(model.getTransformedCenter());
            SimpleVector sv = new SimpleVector();
            sv.set(model.getTransformedCenter());
            sv.y -= 100;
            sv.z -= 100;
            sun.setPosition(sv);
            if(bInitObjectPos){
               initObjectSetting();
               bInitObjectPos = false;
            }
         }
      }

private SimpleVector getWorldPosition(float X, float Y)
     {
      SimpleVector pos = null;
      model.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS|Object3D.COLLISION_CHECK_SELF);
      model.setCollisionOptimization(true);
      
      SimpleVector ray = Interact2D.reproject2D3DWS(world.getCamera(),
            buffer, (int) X, (int) Y);
      if (ray != null) {
         SimpleVector norm = ray.normalize();          
         Object[] slectedModel = world.calcMinDistanceAndObject3D(world.getCamera().getPosition(), norm, 1000);                  
                                                               if (slectedModel[1] != null) {
            
            Object3D selectmodel = (Object3D)slectedModel[1];            }
      }
      return pos;
     }

Here I am getting selectmodel is same as model, but I need individual parts of the same object. model consists array of Object3D, I need by touch whatever parts selected then that should return as selectmodel. Is there any API available in JPCT-AE. please share me your suggestion/opinion.