利用java组件接口生成三维场景缓存,获取进度接口返回的值一直是100,请问如何获取正确的值?
builder.addSteppedListener(new SteppedListener() { public void stepped(SteppedEvent event) { cacheSrv.progress = event.getPercent(); } });
这个进度事件监听,我是写在build之前的,然后用一个全局静态变量存储事件处理程序返回的进度值。然后我用一个定时器在实时打印这个全局静态变量,一直是100.
builder = new SceneCacheBuilder(scene, output.toString()); builder.setCompressedTextureType(CompressedTextureType.DDS);//压缩方式,PC builder.setProcessThreadsCount(8);//处理线程 builder.setStorageType(StorageType.Original);//存储方式,原始 builder.setIsCalNormal(false); builder.setIsInstance(true); //2.1 设置需要生成缓存的普通图层和地形图层 String[] layerNameArr = layerNames.toArray(new String[] {}); builder.setOutputLayerNames(layerNameArr);//三维自定义图层 builder.setOutputTerrainLayerNames(null);//地形图层不生成 //2.2 场景和工作空间输出参数 builder.setOutputSceneName("Scene");//设置新生成的场景名称 Path path = Paths.get(output.toString(),workspaceName+ ".smwu");//*工作空间路径 connInfo.setServer(path.toString()); builder.setOutputWorkspaceConnectionInfo(connInfo); //2.3 开始生成缓存 builder.addSteppedListener(new SteppedListener() { public void stepped(SteppedEvent event) { cacheSrv.progress = event.getPercent(); //VectoringAndSignifying.step=event.getMessage(); } }); flag = builder.build();