当前位置: 首页 > 工具软件 > jPCT-AE > 使用案例 >

jpct-ae 选中3d对象代码

舒嘉德
2023-12-01
private int selectAnyObjectAt( int mouseX, int mouseY){
        //Camera cam = world.getCamera();
        SimpleVector ray=Interact2D.reproject2D3DWS(cam, fb, mouseX, mouseY).normalize(); 
        Object[] res = world.calcMinDistanceAndObject3D(cam.getPosition(), ray, 10000F);
        if (res==null || res[1] == null || res[0] == (Object)Object3D.RAY_MISSES_BOX) { 
            //Log.d("SELECTION", "You missed! x="+mouseX+" y="+mouseY);    
            selectedObject = null;
            return -1;
        }
        Object3D obj = (Object3D)res[1];
        Log.d("SELECTION", "x="+mouseX+" y="+mouseY+" id2="+obj.getID()+" name="+obj.getName());
        selectedObject = obj;    
        
        
        
        if(obj.getID()==4){    
            if(ramp.getVisibility()==true){
                ramp.setVisibility(false);
                
               
            }else{
                //SoundManager.getInstance().play(SoundManager.COLLECTED);    
                 ramp.setVisibility(true);
                 
            }
          
        }
        
        
        return obj.getID();
    }

这段代码足以帮助你了,获取点击的对象
 类似资料: