Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - msp-1

Pages: [1]
1
Support / setVertexOptimization
« on: June 27, 2011, 05:27:24 pm »
Hello,
I have a question about setVertexOptimization.


This cube is separated into 6 faces in blender.
I tried to load this cube without vertexoptimization. (setVertexOptimization(false))

In my expectation, it become like a FLAT SHADING.
Which has sharp edges.
But shading result is not.
(Maybe shading result is not change by using vertexoptimization.)

How should I use setVertexOptimization?

2
Support / load3ds example
« on: May 21, 2011, 09:40:05 pm »
Hello,
I have started learning about jpct-ae.
At first I try to load 3ds model which does not have any texture.
I have modified jpct example code.
But it doesn't work...
My code is follow
Code: [Select]
package com.threed.jpct.example;

import java.io.*;

import java.lang.reflect.Field;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.opengles.GL10;

import com.threed.jpct.*;

import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.view.MotionEvent;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.opengl.GLSurfaceView.EGLConfigChooser;
import android.opengl.GLSurfaceView.Renderer;
import android.util.Log;

public class HelloWorld extends Activity {
    private String thingName = "temp";
    private int thingScale = 1;//end
private static HelloWorld master = null;

private GLSurfaceView mGLView;
private MyRenderer renderer = null;
private FrameBuffer buffer = null;

private World world = null;
private RGBColor back = new RGBColor(50, 50, 100);

private float touchTurn = 0;
private float touchTurnUp = 0;

private float xpos = -1;
private float ypos = -1;

private Object3D thing = null;
private int fps = 0;

private Light sun = null;
private Camera cam = null;

AssetManager assMan;
InputStream is;
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
mGLView = new GLSurfaceView(getApplication());
renderer = new MyRenderer();
mGLView.setRenderer(renderer);
setContentView(mGLView);
}

@Override
protected void onPause() {
super.onPause();
mGLView.onPause();
}

@Override
protected void onResume() {
super.onResume();
mGLView.onResume();
}

protected void onStop() {
super.onStop();
}

public boolean onTouchEvent(MotionEvent me) {

if (me.getAction() == MotionEvent.ACTION_DOWN) {
xpos = me.getX();
ypos = me.getY();
return true;
}

if (me.getAction() == MotionEvent.ACTION_UP) {
xpos = -1;
ypos = -1;
touchTurn = 0;
touchTurnUp = 0;
return true;
}

if (me.getAction() == MotionEvent.ACTION_MOVE) {
float xd = me.getX() - xpos;
float yd = me.getY() - ypos;

xpos = me.getX();
ypos = me.getY();

touchTurn = xd / -100f;
touchTurnUp = yd / -100f;
return true;
}

try {
Thread.sleep(15);
} catch (Exception e) {
// No need for this...
}

return super.onTouchEvent(me);
}

protected boolean isFullscreenOpaque() {
return true;
}

class MyRenderer implements GLSurfaceView.Renderer {

private long time = System.currentTimeMillis();
private boolean stop = false;

public MyRenderer() {
}

public void stop() {
stop = true;
}

public void onSurfaceChanged(GL10 gl, int w, int h) {
if (buffer != null) {
buffer.dispose();
}
buffer = new FrameBuffer(gl, w, h);

if (master == null) {

world = new World();
        world.setAmbientLight(150, 150, 150);

sun = new Light(world);
sun.setIntensity(250, 250, 250);

thing = loadModel("res/" + thingName + ".3ds", thingScale);
        thing.build();

world.addObject(thing);

cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
cam.lookAt(thing.getTransformedCenter());

SimpleVector sv = new SimpleVector();
sv.set(thing.getTransformedCenter());
sv.y -= 100;
sv.z -= 100;
sun.setPosition(sv);
//MemoryHelper.compact();

if (master == null) {
Logger.log("Saving master Activity!");
master = HelloWorld.this;
}
}
}

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
}

public void onDrawFrame(GL10 gl) {

try {
if (!stop) {
if (touchTurn != 0) {
thing.rotateY(touchTurn);
touchTurn = 0;
}

if (touchTurnUp != 0) {
thing.rotateX(touchTurnUp);
touchTurnUp = 0;
}

buffer.clear(back);
world.renderScene(buffer);
world.draw(buffer);
buffer.display();

if (System.currentTimeMillis() - time >= 1000) {
Logger.log(fps + "fps");
fps = 0;
time = System.currentTimeMillis();
}
fps++;
} else {
if (buffer != null) {
buffer.dispose();
buffer = null;
}
}
} catch (Exception e) {
Logger.log(e, Logger.MESSAGE);
}
}

    private Object3D loadModel(String filename, float scale) {
assMan = getResources().getAssets();
is= new InputStream() {
@Override
public int read() throws IOException {
return 0;
}
};
        Object3D[] model = Loader.load3DS(is,scale);
        Object3D o3d = new Object3D(0);
        Object3D temp = null;
        for (int i = 0; i < model.length; i++) {
            temp = model[i];
            temp.setCenter(SimpleVector.ORIGIN);
            temp.rotateX((float)( -.5*Math.PI));
            temp.rotateMesh();
            temp.setRotationMatrix(new Matrix());
            o3d = Object3D.mergeObjects(o3d, temp);
            o3d.build();
        }
        return o3d;
    }
}
}

Could you tell me that what is my mistake?
Or is there simple load3ds example for android?

Thank you.

Pages: [1]