Main Menu
Menu

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.

Show posts Menu

Messages - aeroxr1

#1
Support / Re: jPCT-AE wiki
October 29, 2014, 12:34:13 AM
I have gone in the wiki page and it is empty... is normal ?  :'(
#2
thanks you for your time :)
#3
I have imported the model in onSurfaceChanged in this way :


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
}


In on SurfaceCreated I have done nothing :)

Did I do something wrong ?
#4
thanks :D

A last question :

is there some kind of tricks to pre-load  3d models and the relative textures? because in the ninja-bones-demo the model is loaded immediatelly, instead in mine app it's load after 5-8 seconds   >:(
#5
For the placebo effect with my code I felt like it was smooth  :-[  ;D
#6
HI :)
If I want to improve the performance of my application on tegra devices, I have read that I should use  NVDepthConfigChooser(GLSurfaceView view).
But if I now use also AAConfigChooser, can I use both ?

I have done in this way :

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


Is it the right way ?
#7
Is there a rapid way to add the same model but with a different physical appearance ? (without using 3d graphics programs)  ;D
#8
Hi :)

I have an 3d model and I want to set my camera to fit all the object in screen height.

I did in this way .

I have calculated bounding box :
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;
}


and after :

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


}


With the -100 offset the 3d model correctly fits in both the portrait mode than landscape mode. But I didn't understand why I have to pur the negative offset -100..

Where did I do wrong ?
#9
raft another question :
I would implement a ghost of my first model, I want it in the same position of first model but it have to move in different way.  Then I want they will be in different color, for example draw the ghost with drawWireframe .

Is it possible ? Any suggestion ? :)

#10
Support / Re: MultiTouch android control sample code
September 23, 2014, 03:19:47 PM
Because I have used Mr_Chaos's code and it doesn't auto-adjust the fov and distance when the smartphone rotate from portrait to landscape ;)
But sadly I can't to edit the Mr_chaos's code because I can't see where he sets the camera distance ..
But I want to use his code  because is wonderfull ;) infact it handles the android multitouch , pinch-to-zoom and camera's rotation !

It's not easy for me to edit the code's of someonelse

edit : maybe I understand where I have to put the new code.. :D
#11
I'm trying but the results is wrong :(

I have searched in the web and the result is that I have to do in this way :

cameraDistance = ( modelHeight / 2 ) / tan( fovy / 2 )
Then place your camera:
cameraPos.z = modelPos.z - cameraDistance


I try to merge this math function in http://www.jpct.net/wiki/index.php/MultiTouch_camera_controls but it isn't simple because the camera's code isn't mine :/
#12
Support / Re: MultiTouch android control sample code
September 23, 2014, 10:36:00 AM
This is what I have to do :

cameraDistance = ( modelHeight / 2 ) / tan( fovy / 2 )
Then place your camera:
cameraPos.z = modelPos.z - cameraDistance


but in Mr_Chaos code I don't find something like that.. And I don't know how have to do to merge this math function with Mr_Chaos's code..

Mr_chaos's can you help me ? :)
#13
Support / Re: MultiTouch android control sample code
September 22, 2014, 08:52:57 PM
On my scene I have an animated3d object and I would to set my camera so my object is all in the display .
Now the situation is :



How can I adapt the horizontal fov to obtain a correctly object view in landscape ?

Which are the other options ? Scale Object and moveout the camera ? But I would adapt the camera depending from the display resolution ..
#14
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.

Is the Fov angle the setting we have to change to obtain a correctly zoom ?

I would want a camera that rotate around my model then I have used this camera :
http://www.jpct.net/wiki/index.php/MultiTouch_camera_controls

In vertical it correctly works, but when I rotate to landscape it's too zoomed. I have to set the fov depending of resolution but I don't know how :/
#15
Support / Re: MultiTouch android control sample code
September 22, 2014, 06:51:46 PM
Hi.
I'm using this jpct camera system but I have a problem : when I rotate the display from portrait to landscape the camera is too much zoomed. Then I use android.view.Display.getRotation() to get the orientation of the device, but which are the values to change inside the MovementHandler for a correct camera position ?

I suppose that I have to set FOV, right ?