com.supermap.ar.areffect.excavator

类 PitObject

  • java.lang.Object
    • com.supermap.ar.areffect.excavator.PitObject


  • public class PitObject
    extends java.lang.Object
    坑洞对象

    用于渲染开挖的结果

         SampleCode:
    //遮挡设置 occlusionHelper = arView.getOcclusionHelper(); occlusionHelper.init(0.36f) .setRenderMode(OcclusionHelper.RenderMode.NORMAL); //采用ARGeoPrism,构建“检测墙” List roomBounds = Arrays.asList( new Point3D(-1, -1, -2), new Point3D(-1, 6, -2), new Point3D(6, 6, -2), new Point3D(6, -1, -2), new Point3D(-1, -1, -2) ); ARGeoPrism geoVerticalRegion = new ARGeoPrism(); geoVerticalRegion.setParentNode(arView); geoVerticalRegion.setRenderable(false);//不渲染出来,仅用作射线检测 geoVerticalRegion.addPart(roomBounds,6.0f); //创建开挖工具,在这之前,需确认AREffectView开启了遮挡设置 //Excavator所有子类使用方法一致 excavatorWall = new WallExcavator(geoVerticalRegion); //坑洞纹理 Bitmap bitmap=null; Bitmap bitmap2=null; try { InputStream is = getApplicationContext().getAssets() .open("brown_mud_dry2.png"); bitmap= BitmapFactory.decodeStream(is); InputStream is2 = getApplicationContext().getAssets() .open("wall_texture.png"); bitmap2= BitmapFactory.decodeStream(is2); is.close(); is2.close(); } catch (IOException e) { } //创建坑洞渲染对象 pitWall = new PitObject(excavatorWall) .setTexture(bitmap,bitmap2); //在每一帧刷新时调用 (通常使用 EffectView.addOnUpdateListener(EffectView.OnUpdateListener) 添加帧监听事件) arView.addOnUpdateListener(()->{ if (occlusionHelper.isEnabled()){ //desc-执行画面裁剪 ArrayList screenPoint = null; if (excavatorWall !=null){ //计算屏幕坐标 screenPoint = excavatorWall.getScreenPoint(null); if (screenPoint!=null){ //根据屏幕坐标刷新裁剪范围 occlusionHelper.setUniquePointList(screenPoint).refresh(); dynamicView.updateLine(screenPoint); } } } }) //开挖计算墙面碰撞点 arView为AREffectView、screenPointX/Y为对应的屏幕坐标 //若要实时以屏幕中心计算碰撞点,则将下列代码放入EffectView.OnUpdateListener中 Point3D hitPoint = excavatorWall .generateHitPoint(arView, screenPointX, screenPointY; if (hitPoint!=null){ //desc-执行开挖的顶点计算(开挖参数) excavatorWall.calculate(ExcavationParameter.builder() .setRadius(radius) .setOffset(offset) .setInnerMargin(0) .setCenterPoint(hitPoint) .build()); } //渲染坑洞结果 pitWall.updateMesh();
    • 方法概要

      所有方法 实例方法 具体方法 
      限定符和类型 方法和说明
      void destroy()
      销毁渲染的对象
      android.graphics.Bitmap[] getTexture()
      获取纹理
      void setEnabled(boolean enabled)
      设置启用状态
      PitObject setTexture(android.graphics.Bitmap textureBm)
      设置纹理
      PitObject setTexture(android.graphics.Bitmap bottomTexture, android.graphics.Bitmap sideTexture)
      设置纹理
      PitObject setTexture(android.graphics.Bitmap bottomTexture, android.graphics.Bitmap sideTexture, android.graphics.Bitmap outLineTexture)
      设置纹理
      boolean updateMesh()
      更新网格 在开挖计算后调用
      • 从类继承的方法 java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • PitObject

        public PitObject(Excavator excavator)
        构造方法
    • 方法详细资料

      • getTexture

        public android.graphics.Bitmap[] getTexture()
        获取纹理
        返回:
        纹理,返回一个数组。第一个值为侧面纹理,第二个值为底部纹理
      • setTexture

        public PitObject setTexture(android.graphics.Bitmap bottomTexture,
                                    android.graphics.Bitmap sideTexture,
                                    android.graphics.Bitmap outLineTexture)
        设置纹理
        参数:
        bottomTexture - 底部纹理
        sideTexture - 侧面纹理
        outLineTexture - 边缘轮廓纹理
        返回:
        坑洞对象
      • setTexture

        public PitObject setTexture(android.graphics.Bitmap bottomTexture,
                                    android.graphics.Bitmap sideTexture)
        设置纹理
        参数:
        bottomTexture - 底部纹理
        sideTexture - 侧面纹理
        返回:
        坑洞对象
      • setTexture

        public PitObject setTexture(android.graphics.Bitmap textureBm)
        设置纹理
        参数:
        textureBm -
        返回:
      • destroy

        public void destroy()
        销毁渲染的对象
      • updateMesh

        public boolean updateMesh()
        更新网格

        在开挖计算后调用

        返回:
        无碰撞墙面,则返回false
      • setEnabled

        public void setEnabled(boolean enabled)
        设置启用状态
        参数:
        enabled - 状态