Class Info |
|---|
public class ARView extends GLSurfaceView implements Renderer, OnFrameAvailableListener 提供一般AR场景渲染能力。 |
Qualifier and Type | Method Name and Description |
|---|---|
void | 清除场景中加载的素材。 |
void | destroy() 释放所有已加载的资源。 |
void | enablePlaneDisplay(boolean enable) 设置用于辅助显示的平面是否显示。 |
int | loadAsset(String resourceName) 加载渲染素材。 |
void | onDrawFrame(GL10 gl) 当前帧被绘制时该方法被调用。 |
void | onFrameAvailable(SurfaceTexture surfaceTexture) 用于通知数据流中新的帧可用的回调方法。 |
void | onPause() 暂停渲染线程。 |
void | onResume() 恢复渲染线程。 |
void | onSurfaceChanged(GL10 gl, int width, int height) 当Surface的大小发生改变时该方法被调用。 |
void | onSurfaceCreated(GL10 gl, EGLConfig config) 当Surface被创建时该方法被调用。 |
boolean | onTouchEvent(MotionEvent event) 响应触摸事件时该方法被调用。 |
void | setInitialPose(float[] scale, float[] rotation) 设置素材的初始姿态。 |
void | surfaceDestroyed(SurfaceHolder holder) 生命周期方法,当Surface被销毁时该方法被调用。 |
Constructor |
|---|
public ARView(Context context) 使用new方法创建一个ARView对象。 |
Parameters
Name | Description |
|---|---|
context | Activity上下文。 |
Constructor |
|---|
public ARView(Context context, AttributeSet attributeSet) 使用注册Layout XML的方法创建一个ARView对象。 |
Parameters
Name | Description |
|---|---|
context | Activity上下文。 |
attributeSet | Layout XML属性集。 |
Method |
|---|
public void destroy() 释放所有已加载的资源。 通常情况下,如果不需要进行资源管理,则该函数不需要显式调用。ARView生命周期结束时,会自动释放所有已加载素材。 |
Method |
|---|
public void enablePlaneDisplay(boolean enable) 设置是否显示辅助平面。 |
Parameters
Name | Description |
|---|---|
enable | 是否显示辅助平面。
|
Method |
|---|
public int loadAsset(String resourceName) 加载渲染素材。 |
Parameters
Name | Description |
|---|---|
resourceName | 渲染素材文件路径名称。 |
Returns
Type | Description |
|---|---|
int | 返回值为负数时,表示素材加载失败;返回值为0时,表示加载成功。 |
Method |
|---|
public void onDrawFrame(GL10 gl) 当前帧被绘制时该方法被调用。 |
Parameters
Name | Description |
|---|---|
gl | gl接口。 |
Method |
|---|
public void onFrameAvailable(SurfaceTexture surfaceTexture) 用于通知数据流中新的帧可用的回调方法。 |
Parameters
Name | Description |
|---|---|
surfaceTexture | surfaceTexture对象。 |
Method |
|---|
public void onSurfaceChanged(GL10 gl, int width, int height) 当Surface的大小被改变时该方法被调用。 |
Parameters
Name | Description |
|---|---|
gl | gl接口。 |
width | Surface的宽度,单位pixel。 |
height | Surface的高度,单位pixel。 |
Method |
|---|
public void onSurfaceCreated(GL10 gl, EGLConfig config) 当Surface被创建时该方法被调用。 |
Parameters
Name | Description |
|---|---|
gl | gl接口。 |
config | EGLConfig对象。 |
Method |
|---|
public boolean onTouchEvent(MotionEvent event) 响应触摸事件时该方法被调用。 |
Parameters
Name | Description |
|---|---|
event | 触摸事件。 |
Returns
Type | Description |
|---|---|
boolean | 事件是否向下传递。
|