Skip to content

Commit

Permalink
Cleaning up the examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
kanawish committed Aug 2, 2016
1 parent 49670d0 commit 3342908
Show file tree
Hide file tree
Showing 32 changed files with 195 additions and 368 deletions.
8 changes: 4 additions & 4 deletions commonLib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ dependencies {
compile "io.reactivex:rxjava:$project.rxJavaVersion"
// Android Extensions - https://github.com/ReactiveX/RxAndroid/wiki
compile "io.reactivex:rxandroid:$project.rxAndroidVersion"
compile "com.jakewharton.rxrelay:rxrelay:1.1.0"
compile "com.jakewharton.rxrelay:rxrelay:1.1.0" // https://github.com/JakeWharton/RxRelay/blob/master/CHANGELOG.md
compile "com.jakewharton.rxbinding:rxbinding:$project.rxBindingVersion"
compile "com.jakewharton.rxbinding:rxbinding-support-v4:$project.rxBindingVersion"
compile "com.jakewharton.rxbinding:rxbinding-appcompat-v7:$project.rxBindingVersion"
// compile 'com.jakewharton.rxbinding:rxbinding-design:0.4.0'
// compile 'com.jakewharton.rxbinding:rxbinding-recyclerview-v7:0.4.0'
compile 'com.jakewharton.rxbinding:rxbinding-design:0.4.0'
compile 'com.jakewharton.rxbinding:rxbinding-recyclerview-v7:0.4.0'

// Square Networking
compile "com.squareup.okhttp3:okhttp:$project.okhttpVersion"
compile "com.squareup.okhttp3:logging-interceptor:$project.okhttpVersion"
compile "com.squareup.okhttp3:okhttp-urlconnection:$project.okhttpVersion"
// compile "com.squareup.picasso:picasso:$project.picassoVersion"
compile "com.squareup.picasso:picasso:$project.picassoVersion"
compile "com.jakewharton.picasso:picasso2-okhttp3-downloader:$project.picassoOkHttpDownloaderVersion"
compile "com.squareup.retrofit2:retrofit:$project.retrofitVersion"
compile "com.squareup.retrofit2:adapter-rxjava:$project.retrofitVersion"
Expand Down
35 changes: 7 additions & 28 deletions rajaDemo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.kanawish.tangotalk.rajademo"
applicationId "com.kanawish.raja"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
Expand All @@ -35,32 +33,13 @@ android {
}
}

def external_lib_prefix = "../tangoLibs"
repositories {
flatDir {
dirs external_lib_prefix + '/aar'
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

compile fileTree(dir: external_lib_prefix + '/jar', include: ['**/*.jar'])
compile (name: 'TangoSupport_Qianru_Java', ext: 'aar')

compile project(':rajaTangoLib')

compile 'com.android.support:appcompat-v7:24.0.0'
compile "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:design:$rootProject.supportLibraryVersion"
compile "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:support-v4:$rootProject.supportLibraryVersion"
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha3'
compile project(':commonLib')

// APT/Plugin based goodness
apt "com.jakewharton:butterknife-compiler:$project.butterKnifeVersion"
compile "com.jakewharton:butterknife:$project.butterKnifeVersion"
apt "com.google.auto.value:auto-value:$project.autoValueVersion"
apt "com.ryanharter.auto.value:auto-value-gson:$project.autoValueGsonVersion"
// compile 'org.rajawali3d:rajawali:1.0.325@aar'

// Latest version of Rajawali
// see https://github.com/Rajawali/Rajawali
// and https://travis-ci.org/Rajawali/Rajawali/builds
compile 'org.rajawali3d:rajawali:1.1.517-SNAPSHOT@aar'
}
4 changes: 2 additions & 2 deletions rajaDemo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.kanawish.tangotalk.rajademo" xmlns:android="http://schemas.android.com/apk/res/android">
<manifest package="com.kanawish.raja.rajademo" xmlns:android="http://schemas.android.com/apk/res/android">

<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:name="com.kanawish.raja.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package com.kanawish.raja;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.CallSuper;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.kanawish.raja.rajademo.R;

import org.rajawali3d.renderer.ISurfaceRenderer;
import org.rajawali3d.renderer.Renderer;
import org.rajawali3d.view.IDisplay;
import org.rajawali3d.view.ISurface;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

public abstract class BaselineRenderingFragment extends Fragment implements IDisplay, View.OnClickListener {

protected FrameLayout layout;

protected ISurface surface;
protected ISurfaceRenderer renderer;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);

// Inflate the view
layout = (FrameLayout) inflater.inflate(R.layout.rajawali_textureview_fragment, container, false);

// Find the TextureView
surface = (ISurface) layout.findViewById(R.id.rajwali_surface);

// Create the renderer
renderer = createRenderer();
onBeforeApplyRenderer();
applyRenderer();
return layout;
}

protected void onBeforeApplyRenderer() {
}

@CallSuper
protected void applyRenderer() {
surface.setSurfaceRenderer(renderer);
}

@Override
public void onClick(View v) {
switch (v.getId()) {
}
}

@Override
public void onDestroyView() {
super.onDestroyView();

if (layout != null)
layout.removeView((View) surface);
}

protected static abstract class BaselineRenderer extends Renderer {

final BaselineRenderingFragment exampleFragment;

public BaselineRenderer(Context context, @Nullable BaselineRenderingFragment fragment) {
super(context);
exampleFragment = fragment;
}

@Override
public void onRenderSurfaceCreated(EGLConfig config, GL10 gl, int width, int height) {
super.onRenderSurfaceCreated(config, gl, width, height);
}

@Override
public void onOffsetsChanged(float xOffset, float yOffset, float xOffsetStep, float yOffsetStep, int xPixelOffset, int yPixelOffset) {
}

@Override
public void onTouchEvent(MotionEvent event) {
}

}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.kanawish.tangotalk.rajademo;
package com.kanawish.raja;

import android.content.Context;
import android.os.Bundle;
Expand All @@ -9,7 +9,8 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.kanawish.raja.rajademo.R;

import org.rajawali3d.Object3D;
import org.rajawali3d.animation.Animation;
Expand All @@ -28,47 +29,37 @@
import org.rajawali3d.postprocessing.PostProcessingManager;
import org.rajawali3d.postprocessing.effects.BloomEffect;
import org.rajawali3d.postprocessing.passes.BlendPass;
import org.rajawali3d.postprocessing.passes.RenderPass;

public class DemoFragment extends AExampleFragment {
public class DemoFragment extends BaselineRenderingFragment {

private PostProcessingManager effectsManager;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);

LinearLayout ll = new LinearLayout(getActivity());
ll.setOrientation(LinearLayout.VERTICAL);
ll.setGravity(Gravity.BOTTOM);

TextView label = new TextView(getActivity());
label.setText(R.string.fbx_fragment_button_model_by);
label.setTextSize(20);
label.setGravity(Gravity.CENTER);
label.setHeight(100);
ll.addView(label);
LinearLayout uiOverlay = new LinearLayout(getActivity());
uiOverlay.setOrientation(LinearLayout.VERTICAL);
uiOverlay.setGravity(Gravity.BOTTOM);

mLayout.addView(ll);
// TODO: Add ui elements here.
layout.addView(uiOverlay);

return mLayout;
return layout;
}

@Override
public AExampleRenderer createRenderer() {
public BaselineRenderer createRenderer() {
return new FBXRenderer(getActivity(), this);
}

public static DemoFragment buildInstance() {
return new DemoFragment();
}

private final class FBXRenderer extends AExampleRenderer {

private DirectionalLight mDirectionalLight;
private final class FBXRenderer extends BaselineRenderer {

public FBXRenderer(Context context, @Nullable AExampleFragment fragment) {
public FBXRenderer(Context context, @Nullable BaselineRenderingFragment fragment) {
super(context, fragment);
}

Expand All @@ -81,6 +72,7 @@ protected void initScene() {

// For skybox below.
getCurrentCamera().setFarPlane(1000);

// Skybox images by Emil Persson, aka Humus. http://www.humus.name humus@comhem.se
try {
getCurrentScene().setSkybox(R.drawable.posx, R.drawable.negx,
Expand All @@ -91,38 +83,36 @@ protected void initScene() {

getCurrentScene().addChild(buildLandscape());

getCurrentCamera().setPosition(0,2,4);
getCurrentCamera().setPosition(0,2,8);
getCurrentCamera().setLookAt(0,1,-40);

getCurrentScene().setFog(new FogMaterialPlugin.FogParams(FogMaterialPlugin.FogType.LINEAR, 0xCCCCCC, 1, 150));

Material planeMaterial = new Material();
planeMaterial.enableLighting(true);
planeMaterial.setDiffuseMethod(new DiffuseMethod.Lambert());

Material sphereMaterial = new Material();
sphereMaterial.enableLighting(true);
sphereMaterial.setDiffuseMethod(new DiffuseMethod.Lambert());

//
// -- Create a post processing manager. We can add multiple passes to this.
//

/*
effectsManager = new PostProcessingManager(this);
RenderPass renderPass = new RenderPass(getCurrentScene(), getCurrentCamera(), 0);
effectsManager.addPass(renderPass);

BloomEffect bloomEffect = new BloomEffect(getCurrentScene(), getCurrentCamera(), getViewportWidth(), getViewportHeight(), 0x111111, 0xffffff, BlendPass.BlendMode.SCREEN);
BloomEffect bloomEffect = new BloomEffect(
getCurrentScene(), getCurrentCamera(), getViewportWidth(),
getViewportHeight(), 0x111111, 0xffffff, BlendPass.BlendMode.SCREEN);
effectsManager.addEffect(bloomEffect);
bloomEffect.setRenderToScreen(true);

ShadowEffect shadowEffect = new ShadowEffect(getCurrentScene(), getCurrentCamera(), light, 2048);
shadowEffect.setShadowInfluence(.5f);
effectsManager.addEffect(shadowEffect);
shadowEffect.setRenderToScreen(true);
*/

}

/*
public void onRender(final long ellapsedTime, final double deltaTime) {
effectsManager.render(ellapsedTime, deltaTime);
}
*/

private Object3D buildLandscape() {
LoaderOBJ objParser = new LoaderOBJ(mContext.getResources(), mTextureManager, R.raw.minecart_scene_obj);
Expand Down Expand Up @@ -157,12 +147,11 @@ private Object3D buildTree() {
return o;
}


@NonNull
private DirectionalLight buildDirectionalLight() {
final DirectionalLight directionalLight = new DirectionalLight();
directionalLight.setPosition(0.20, 1.0, 0.6);
directionalLight.setPower(1.75f);
directionalLight.setPosition(0.20, 5.0, 0.6);
directionalLight.setPower(0.95f);
directionalLight.setLookAt(Vector3.ZERO);
directionalLight.enableLookAt();
return directionalLight;
Expand All @@ -174,7 +163,6 @@ private Material buildMaterial(int color) {
material.enableLighting(true);
material.setColor(color);
material.setDiffuseMethod(new DiffuseMethod.Lambert());
// material.setSpecularMethod(new SpecularMethod.Phong());
return material;
}

Expand All @@ -193,8 +181,6 @@ private Material buildTextureMaterial(int color) {
}
material.setColorInfluence(0);
texture.setInfluence(1.0f);
// material.setColor(color);
// material.setColorInfluence(.5f);

return material;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
package com.kanawish.tangotalk.rajademo;
package com.kanawish.raja;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.kanawish.raja.rajademo.R;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

/*
BasicFragment fragment = BasicFragment.buildInstance();
String name = BasicFragment.class.getName();
*/
DemoFragment fragment = DemoFragment.buildInstance();
String name = DemoFragment.class.getName();

getSupportFragmentManager().beginTransaction()
.replace(R.id.content_frame, fragment, name)
.commit();

/*
Fragment fragment = (Fragment) aClass.newInstance();
fragment.setArguments(bundle);
*/
}
}
Loading

0 comments on commit 3342908

Please sign in to comment.