ArSceneView extends SceneView 》 SceneView extends SurfaceView implements Choreographer.FrameCallback
A SurfaceView that integrates with ARCore and renders a scene.
ASceneform SurfaceView that manages rendering and interaction with the scene.
渲染类 Renderable
Baseclass for rendering in 3D space by attaching to a com.google.ar.sceneform.Nodewith com.google.ar.sceneform.Node.setRenderable(Renderable).
ModelRenderable 3d模型渲染器
Rendersa 3D Model by attaching it to a com.google.ar.sceneform.Node withcom.google.ar.sceneform.Node.setRenderable(Renderable).
用法:ModelRenderable.builder().setSource(this,Uri.parse("models/triger.glb"))
.setIsFilamentGltf(true).setAsyncLoadEnabled(true).build() //Filament 实时渲染引擎
.thenAccept(model->{
ArModelViewActivityactivity=weakActivity.get();
if(activity!=null){
activity.model=model;
}
})
.exceptionally(throwable->{
Toast.makeText(this,"Unabletoloadmodel",Toast.LENGTH_LONG).show();return null;
});
ViewRenderable 2d Android view 渲染器
描述:Renders a 2DAndroid view in 3D space by attaching it to a com.google.ar.sceneform.Nodewithcom.google.ar.sceneform.Node.setRenderable(Renderable).
用法:ViewRenderable.builder().setView(this,R.layout.view_model_title).build()
.thenAccept(viewRenderable->{
ArModelViewActivityactivity=weakActivity.get();
if(activity!=null){
activity.viewRenderable=viewRenderable;
}
})
.exceptionally(throwable->{
Toast.makeText(this,"Unabletoloadmodel",Toast.LENGTH_LONG).show();return null;
});
Texture
Representsa reference to a texture.
Texture.builder().setSampler(Texture.Sampler.builder()
.setMinFilter(Texture.Sampler.MinFilter.LINEAR_MIPMAP_LINEAR)
.setMagFilter(Texture.Sampler.MagFilter.LINEAR)
.setWrapMode(Texture.Sampler.WrapMode.REPEAT).build())
.setSource(this,Uri.parse("textures/parquet1.jpeg"))
.setUsage(Texture.Usage.COLOR_MAP)
.build()
.thenAccept(texture->{
ImageTexturesActivityimageTexturesActivity=weakActivity.get();
if(imageTexturesActivity!=null){
imageTexturesActivity.texture=texture;
}
}).exceptionally(throwable->{
Toast.makeText(this,"Unabletoloadtexture",Toast.LENGTH_LONG).show();
returnnull;
});
Anchor com.google.ar.core
Describesa fixed location and orientation in the real world. To stay at a fixed locationin physical space, the numerical description of this position will update asARCore's understanding of the space improves.
Node extends NodeParent implements TransformProvider com.google.ar.sceneform
A Noderepresents a transformation within the scene graph's hierarchy. It can containa renderable for the rendering engine to render.
Eachnode can have an arbitrary number of child nodes and one parent. The parent maybe another node, or the scene.
AnchorNode extends Node com.google.ar.sceneform
Nodethat is automatically positioned in world space based on an ARCore Anchor.Whenthe Anchor isn't tracking, all children of this node are disabled.
Anchor anchor=hitResult.createAnchor();
AnchorNode anchorNode=new AnchorNode(anchor);
anchorNode.setParent(arFragment.getArSceneView().getScene());
VideoNode extends Node
Nodethat can show a video by passing a MediaPlayer instance. Note that VideoNodedoes not manage video playback by itself (e.g. starting the video).
Filteringout a specific color in the video is also supported by defining a chroma keycolor.
Optionallyan ExternalTexture can be passed if multiple VideoNode instances need to renderthe exact same instance of a video. This will also improve performancedramatically instead of rendering each instance separately.
Scene extends NodeParent 场景 也是一种node
TheSceneform Scene maintains the scene graph, a hierarchical organization of ascene's content. A scene can have zero or more child nodes and each node canhave zero or more child nodes.
TheScene also provides hit testing, a way to detect which node is touched by aMotionEvent or Ray.
TransformableNode extends BaseTransformableNode 》 BaseTransformableNode extends Node implements Node.OnTapListener
Nodethat can be selected, translated, rotated, and scaled using gestures fromTransformationSystem.
TransformableNode transformableNode=new TransformableNode(arFragment.getTransformationSystem());
transformableNode.setParent(anchorNode);
RenderableInstance renderableInstance=transformableNode.setRenderable(this.model);
renderableInstance.getMaterial().setInt("baseColorIndex",0);
renderableInstance.getMaterial().setTexture("baseColorMap",this.texture);
transformableNode.select();
RenderableInstance
Controlshow a Renderable is displayed. There can be multiple RenderableInstancesdisplaying a single Renderable.
ObjectAnimator
Constructsand returns an ObjectAnimator for all ModelAnimation of this object.
modelAnimator=renderableInstance.animate(true);
modelAnimator.addListener(newAnimator.AnimatorListener(){
@Override
publicvoidonAnimationStart(Animatoranimation){}
@Override
publicvoidonAnimationEnd(Animatoranimation){}
@Override
publicvoidonAnimationCancel(Animatoranimation){}
@Override
publicvoidonAnimationRepeat(Animatoranimation){}
});
CameraStream
Displaysthe Camera stream using Filament.
===================================常用配置===================================
Session session,Config config
//启用深度API
arSceneView.getCameraStream().setDepthOcclusionMode(CameraStream.DepthOcclusionMode.DEPTH_OCCLUSION_ENABLED);
if(session.isDepthModeSupported(Config.DepthMode.AUTOMATIC)){
config.setDepthMode(Config.DepthMode.AUTOMATIC);
}
config.setUpdateMode(Config.UpdateMode.LATEST_CAMERA_IMAGE);