代码拉取完成,页面将自动刷新
Rajawali 是一个3D引擎, 基于 OpenGL ES 1.X/2.0/3.0
[原库WIKI](Home · Rajawali/Rajawali Wiki (github.com))
dependencies {
implementation "com.gitee.archermind-ti:rajawali:1.0.0"
}
简单举例使用方式,详情请参考DEMO和官方使用向导。
package com.clintonmedbery.rajawalibasicproject;
import ohos.multimodalinput.event.TouchEvent;
import org.rajawali3d.renderer.Renderer;
public class CustomRenderer extends Renderer {
// 初始化场景
@Override
public void initScene() {
}
//处理Touch事件
@Override
public void onTouchEvent(TouchEvent event){
}
}
// 创建一个不带光源的颜色材质
Material material = new Material();
material.setColor(Color.GREEN);
//创建一个带光源的颜色材质
Material material = new Material();
material.setColor(0xff009900);
material.enableLighting(true);
material.setDiffuseMethod(new DiffuseMethod.Lambert());
// 创建一个带光源的颜色材质并高亮
Material material = new Material();
material.setColor(0xff009900);
material.enableLighting(true);
material.setDiffuseMethod(new DiffuseMethod.Lambert());
material.setSpecularMethod(new SpecularMethod.Phong());
//使用不同的纹理
Material material = new Material();
// -- The first parameter is compulsory and needs to be unique and
// has the same restrictions as any Java variable.
material.addTexture(new Texture("earth", R.drawable.earth_diffuse));
// -- set up a rotation animation that rotates 90 degrees around the x axis,
// 180 degrees around the y axis, 270 degrees around the z axis
Animation3D anim = new RotateAnimation3D(new Vector3(90, 180, 270));
// -- set the duration to 2 seconds
anim.setDuration(2000);
// -- pass in the 3D object that should be animated. This could also be the camera or a lamp.
anim.setTransformable3D(mMonkey);
// -- set the repeat count. This is ignored if the repeat mode is a variant of infinite.
anim.setRepeatCount(10);
// -- set the repeat mode. Animation3D.REVERSE reverses the animation, Animation3D.RESTART
// restarts the animation from its original values. Each reversal counts as a repeat so
// here we will have 5 complete cycles.
anim.setRepeatMode(Animation3D.RepeatMode.REVERSE);
// -- set the interpolation mode.
anim.setInterpolator(new BounceInterpolator());
// -- start the animation.
anim.play();
private final class LoadModelRenderer extends AExampleRenderer implements IAsyncLoaderCallback {
protected void initScene() {
//Begin loading
ResourceManager resManager = mContext.getResourceManager();
RawFileEntry rawFileEntry = resManager.getRawFileEntry("resources/rawfile/multiobjects_obj.obj");
final LoaderOBJ loaderOBJ = new LoaderOBJ(mContext.getResourceManager(),
mTextureManager, rawFileEntry);
loadModel(loaderOBJ, this, rawFileEntry);
}
@Override
public void onModelLoadComplete(ALoader aLoader) {
RajLog.d(this, "Model load complete: " + aLoader);
final LoaderOBJ obj = (LoaderOBJ) aLoader;
final Object3D parsedObject = obj.getParsedObject();
parsedObject.setPosition(Vector3.ZERO);
getCurrentScene().addChild(parsedObject);
}
@Override
public void onModelLoadFailed(ALoader aLoader) {
RajLog.e(this, "Model load failed: " + aLoader);
}
}
Licensed under the Apache License, Version 2.0. LICENSE
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。