I have gone in the wiki page and it is empty... is normal ?
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.
Show posts Menu
public MyGLRenderer(Context context,MovementHandler gestore) {
//impostiamo i settaggi del render
Config.maxPolysVisible = 500;
Config.farPlane = 1000;
ActivityContext=context;
this.gestore=gestore;
}
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
// TODO Auto-generated method stub
Logger.log("onSurfaceCreated");
}
@Override
public void onDrawFrame(GL10 gl)
{
if (frameBuffer == null)
return;
........
}
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
// TODO Auto-generated method stub
Logger.log("onSurfaceChanged");
if (frameBuffer != null) {
frameBuffer.dispose();
}
frameBuffer = new FrameBuffer(width, height);
this.width=width;
this.height=height;
//in teoria .. potrebbe funzionare ..
if (world != null)
return;
world = new World(); //creiamo il mondo
//inseriamo il nostro modello nel mondo
Resources res = ActivityContext.getResources();
try {
modello = BonesIO.loadGroup(res.openRawResource(R.raw.vincent));
modello.addToWorld(world);
}
catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
world.setAmbientLight(127, 127, 127);
world.buildAllObjects();
helper=new JointRotation(modello);
TextureManager.getInstance().flush();
Texture texture = new Texture(res.openRawResource(R.raw.vincent_texture));
texture.keepPixelData(true);
TextureManager.getInstance().addTexture("vincent", texture);
for (Animated3D a : modello)
{
a.setTexture("vincent");
a.discardMeshData();
}
//calcoliamo le grandezze del boundingbox del nostro modello
float[] bb = calcBoundingBox();
box_h = (bb[3] - bb[2]); // model height
Camera camera = world.getCamera();
if(width < height)
{
camera.setPosition(0,-box_h/2,0);
camera.moveCamera(Camera.CAMERA_MOVEOUT, 70); //la sposto indietro
camera.lookAt(new SimpleVector(0, -box_h/2, 0));
}
else
{
float fovy=camera.getYFOV();
double cameraDistance = ( box_h / 2 ) / Math.tan( fovy / 2 );
camera.setPosition(0,-box_h/2,(float)cameraDistance-100);
camera.lookAt(new SimpleVector(0, -box_h/2, 0));
}
//ora si crea un vettore per indirizzare il sole
new Light(world).setPosition(new SimpleVector(0, -box_h/2, box_h));
currentPose = modello.get(0).getSkeletonPose();
MemoryHelper.compact(); // dovrebbe liberare un pò di memoria
}
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import android.view.MotionEvent;
import com.threed.jpct.util.AAConfigChooser;
import com.threed.jpct.util.NVDepthConfigChooser;
public class MyGLSurfaceView extends GLSurfaceView {
MyGLRenderer renderer;
Context activitycontext;
public MovementHandler gestore= new MovementHandler();
public boolean rendercontinuo=false; //se true renderizza in continuazione, se false renderizza su richiesta
public MyGLSurfaceView (Context context)
{
super(context);
activitycontext=context; //prendo il context dell'activity
// Create an OpenGL ES 2.0 context.
setEGLContextClientVersion(2);
setEGLConfigChooser(new AAConfigChooser(this));
setEGLConfigChooser(new NVDepthConfigChooser(this));
// Set the Renderer for drawing on the GLSurfaceView
renderer = new MyGLRenderer(activitycontext,gestore);
setRenderer(renderer);
if(rendercontinuo==false)
setRenderMode(RENDERMODE_WHEN_DIRTY);
}
public MyGLSurfaceView (Context context, AttributeSet attrs)
{
super(context, attrs);
activitycontext=context; //prendo il context dell'activity
// Create an OpenGL ES 2.0 context.
setEGLContextClientVersion(2);
setEGLConfigChooser(new AAConfigChooser(this));
setEGLConfigChooser(new NVDepthConfigChooser(this));
// Set the Renderer for drawing on the GLSurfaceView
renderer = new MyGLRenderer(activitycontext,gestore);
setRenderer(renderer);
if(rendercontinuo==false)
setRenderMode(RENDERMODE_WHEN_DIRTY);
}
protected float[] calcBoundingBox() {
float[] box = null;
for (Animated3D skin : modello) {
float[] skinBB = skin.getMesh().getBoundingBox();
if (box == null) {
box = skinBB;
} else {
// x
box[0] = Math.min(box[0], skinBB[0]);
box[1] = Math.max(box[1], skinBB[1]);
// y
box[2] = Math.min(box[2], skinBB[2]);
box[3] = Math.max(box[3], skinBB[3]);
// z
box[4] = Math.min(box[4], skinBB[4]);
box[5] = Math.max(box[5], skinBB[5]);
}
}
return box;
}
float[] bb = calcBoundingBox();
box_h = (bb[3] - bb[2]); // model height
Camera camera = world.getCamera();
if(width < height)
{
camera.setPosition(0,-box_h/2,0);
camera.moveCamera(Camera.CAMERA_MOVEOUT, 70); //la sposto indietro
camera.lookAt(new SimpleVector(0, -box_h/2, 0));
}
else
{
float fovy=camera.getYFOV();
double cameraDistance = ( box_h / 2 ) / Math.tan( fovy / 2 );
camera.setPosition(0,-box_h/2,(float)cameraDistance-100);
camera.lookAt(new SimpleVector(0, -box_h/2, 0));
}
cameraDistance = ( modelHeight / 2 ) / tan( fovy / 2 )
Then place your camera:
cameraPos.z = modelPos.z - cameraDistance
cameraDistance = ( modelHeight / 2 ) / tan( fovy / 2 )
Then place your camera:
cameraPos.z = modelPos.z - cameraDistance
Quote from: raft on September 06, 2014, 06:51:53 PM
you can move camera closer to make the model look bigger. or you can scale the model.
Page created in 0.080 seconds with 13 queries.