Coder Social home page Coder Social logo

gframeae's Introduction

gframeAE

A Java 3D engine for Android applications. Uses a pure software renderer instead of an OpenGL implementation for broader availability. Original Java sources can be found at the gframe repository.

Features include:

  • pixel-perfect perspective correct texture mapping
  • sub-pixel & sub-texel accuracy
  • light attenuation
  • flat & phong shading
  • normal & specular mapping
  • shadow mapping
  • physics support & particles

As a first hands-on, here is an example Android View-Class that shows a single rotating cube:

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.View;
import gframe.ae.engine.Engine3D;
import gframe.ae.engine.Lightsource;
import gframe.ae.engine.Material;
import gframe.ae.engine.Model3D;
import gframe.ae.engine.NormalMappedMaterialShader;
import gframe.ae.engine.Shader;
import gframe.ae.engine.camera.Camera;
import gframe.ae.engine.camera.TripodCamera;
import gframe.ae.engine.generator.Model3DGenerator;
import gframe.ae.engine.generator.TextureGenerator;
import gframe.ae.engine.timing.Rotate;
import gframe.ae.engine.timing.Timer;

public class MyView extends View {

    private Engine3D engine;

    public MyView(Context context) {
        super(context);
    }

    public MyView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    private void setupEngineAndWorld() {
        if (engine != null) {
            engine.clear();
        }

        engine = new Engine3D(getWidth(), getHeight());

        Lightsource lightsource = new Lightsource(0, 0, 0, gframe.ae.engine.Color.white, Lightsource.MAX_INTENSITY);
        engine.setLightsource(lightsource);

        Shader shader = new NormalMappedMaterialShader(lightsource, TextureGenerator.generateTileTextureNormalMap(256, 256, 32));
        engine.setDefaultShader(shader);

        // add something to the world..
        Model3D model = Model3DGenerator.buildBlock(80, 80, 80, gframe.ae.engine.Color.white);
        model = Model3DGenerator.facify(model);
        model.rotate(-45, -45, 45);  
        model.setMaterial(Material.GOLD);
        
        engine.register(model);

        // let object rotate
        Timer timer = Timer.getInstance();
        Rotate rotate = new Rotate(model, 100000000, 0.01f, Rotate.AXIS_Z);
        timer.registerTimedObject(rotate);

        // light and camera settings
        lightsource.setCoordinates(0, 0, -100);

        Camera camera = new TripodCamera();
        camera.move(0, 0, -200);
        engine.setCamera(camera);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        if (engine == null) {
            setupEngineAndWorld();
        }

        engine.drawScene(canvas);

        invalidate();
    }

}

Should look like so:

alt text alt text

gframeae's People

Contributors

conradplake avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.