2 Star 3 Fork 1

Archermind-TI / Rajawali

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Rajawali

Rajawali 是一个3D引擎, 基于 OpenGL ES 1.X/2.0/3.0

原库说明

[原库WIKI](Home · Rajawali/Rajawali Wiki (github.com))

功能及使用向导

  1. Basic Setup & Sphere (Maven) 1. Basic Setup & a Sphere (Out of date)
  2. Creating a Live Wallpaper and Importing a Model
  3. Materials
  4. Optimization
  5. [Skybox] (https://github.com/MasDennis/Rajawali/wiki/Tutorial-05-Skybox)
  6. [Screenshots] (https://github.com/MasDennis/Rajawali/wiki/Tutorial-06-Screenshots)
  7. [Plugins] (https://github.com/MasDennis/Rajawali/wiki/Tutorial-07-Plugins)
  8. [User Interface Elements] (https://github.com/MasDennis/Rajawali/wiki/Tutorial-08-Adding-User-Interface-Elements)
  9. Creating a Custom Material GLSL Shader
  10. 2D Renderer
  11. Particles
  12. Object Picking
  13. Animation Classes
  14. Bump Normal Mapping
  15. MD2 Animation
  16. Collision Detection
  17. Importing .Obj Files
  18. Drawing Lines
  19. Catmull Rom Splines
  20. Animated Sprites
  21. Fog
  22. More Optimisation
  23. Custom Vertex Shader
  24. Using Geometry Data To Position And Rotate Objects
  25. Video Material
  26. Orthographic Camera
  27. Texture Compression
  28. Transparent Textures
  29. Skeletal Animation
  30. Creating a Day Dream
  31. [Using RajawaliScene] (https://github.com/MasDennis/Rajawali/wiki/Tutorial-31-Using-RajawaliScene)

效果展示

集成方式

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);
    }
}

License

Licensed under the Apache License, Version 2.0. LICENSE

空文件

简介

OpenGL ES 2.0/3.0 Engine 展开 收起
Java 等 5 种语言
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/archermind-ti/rajawali.git
git@gitee.com:archermind-ti/rajawali.git
archermind-ti
rajawali
Rajawali
master

搜索帮助