Jump to content
• Advertisement

# aeroxr1

Member

23

137 Neutral

• Rank
Member
1. ## position camera for object to fit in screen height

fovy is calculated automatically from the 3d engine depending from fovx. But I can get the value of fovy with this function :  float fovy=camera.getYFOV(); My model is in position : 0,0,0   Today I will give you the accurate values   edit : fov_y = -1 box_h= 69,6417   Moreover the author of jpct answer me: "I'm not sure...might be caused by the near clipping plane. Maybe your calculation assumes it to be a z=0 but it's actually at z=1 by default"
2. ## position camera for object to fit in screen height

If I set negative cameraDistance without subtracting 100 in this way : camera.setPosition(0,-box_h/2,-(float)cameraDistance); I see the back of the model, and it still remains too zoomed like in attached figure :(
3. ## position camera for object to fit in screen height

Thanks for your time You are special ! Thanks ! ! !  (my english is much bad and I don't know many positive adjectives to describe a good person )    I do in this way :   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)); } Without -100 the model didn't correctly fit in the display, but it was too zoomed..  Why ? If I want regolate the camera also depending from resolution and model height ?   The coordinate system are :      I have calculated The bounding box of my model in this way : 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; }
4. ## position camera for object to fit in screen height

Hi to everyone :)   I have an 3d model and I want to set my camera to fit all the object in screen height.   How Can I do ? I know the object width and the height, but I don't know how do I do to calculate the fov and camera position in according to screen resolution .   On portrait mode it is all  ok , but in landscape the camera is too zoomed :( I'm attached two screenshot :)
5. ## glsurfaceview in android layout xml

thanks for  the advice :)
6. ## glsurfaceview in android layout xml

Hi :D   Finally !    I divided myglsurfaceview , myrender and activity in three different class. Now the xml layout see the myglsurfaceview :D   Now I have a doubt :   I want this layout : ------------------------------------- MyGLSurfaceView          ------------------------------------- textview - button  -------------------------------------     How Can I do it ? :D
7. ## glsurfaceview in android layout xml

Yes I have done in this way, but the result is the same ... :/ //versione che permetterebbe l'inflate non funzionante setContentView(R.layout.animationlayout); mGLView = (MyGLSurfaceView)findViewById(R.id.myglsurfaceView); And I try to invert code line above in : //versione che permetterebbe l'inflate non funzionante mGLView = (MyGLSurfaceView)findViewById(R.id.myglsurfaceView); setContentView(R.layout.animationlayout);
8. ## glsurfaceview in android layout xml

this is error log :       I have updated the code in first post .
9. ## glsurfaceview in android layout xml

I found the error.. But I don't know why there is this error..     MyGlSurfaceView is inside the my activity class . But If I change to  my.package.AnimationActivity.MyGLSurfaceView the error msg is :     because :
10. ## glsurfaceview in android layout xml

Before to post the msg I have tryed to comment the line code : setContentView(R.layout.animationlayout); and mGLView = (MyGLSurfaceView)findViewById(R.id.provaanim);   and the app doesn't crash. But If I comment only second line : mGLView = (MyGLSurfaceView)findViewById(R.id.provaanim); the app has crashed.   Now I will read the link that you have posted and I will post the correctly information
11. ## glsurfaceview in android layout xml

Hi I want to put the glsurfaceview in an normal Android Layout xml, but I don't know how can I do it.   This is my activity class :   package rugani.tesi.animazione3d; ...... public class AnimationActivity extends Activity { .... public GLSurfaceView mGLView;  .... public MyGLRenderer renderer; MovementHandler gestore= new MovementHandler(); @Override protected void onCreate(Bundle savedInstanceState) { Logger.log("onCreate"); super.onCreate(savedInstanceState); getActionBar().setDisplayHomeAsUpEnabled(true); /* mGLView = new GLSurfaceView(getApplication()); mGLView.setEGLContextClientVersion(2); mGLView.setEGLConfigChooser(new AAConfigChooser(mGLView)); mGLView.setRenderer(renderer);  setContentView(mGLView); */ //mGLView = new MyGLSurfaceView(getApplication()); //setContentView(mGLView); setContentView(R.layout.animationlayout); mGLView = (GLSurfaceView)findViewById(R.id.provaanim); } @Override     protected void onPause() {         super.onPause();         mGLView.onPause();     }     @Override     protected void onResume() {         super.onResume();         mGLView.onResume();     }      public class MyGLSurfaceView extends GLSurfaceView {  public MyGLSurfaceView (Context context, AttributeSet attrs)  {         super(context, attrs);                  // Create an OpenGL ES 2.0 context.        setEGLContextClientVersion(2);        setEGLConfigChooser(new AAConfigChooser(this));        // Set the Renderer for drawing on the GLSurfaceView        renderer = new MyGLRenderer();        setRenderer(renderer);          }     } public class MyGLRenderer implements GLSurfaceView.Renderer { .... boolean direction=true; public MyGLRenderer() { .... }   and this is layout xml :   but I don't know the right TAG for the glsurfaceview in xml layout .   With the above code, on start the activity crash .   This is my log error :
12. ## Rotate a bone, mathematical issues :(

The problem is that "mulMatrixByInverse" function does this : private void mulMatrixByInverse(Joint ref, Matrix mat) { if (ref != null) { mat.matMul(ref.getInverseBindPose()); } } Thus the result is matrix = bind * parent-inverse-bind  and not matrix = parent-inverse-bind * bind . We have tried to invert the matrices inside the function above and the result is wrong, the model's leg moves in the wrong way.
13. ## Rotate a bone, mathematical issues :(

Thanks ! You have been crystal clear   p.s : I want see If I really understand : the result would be the same if I multiplied inverse bind pose * "bind" before applying translation and rotation right ?
14. ## Rotate a bone, mathematical issues :(

Thanks for your time :)    I have two question :     I don't understand why before of the rotation do we have to traslate the ball into the origin. Is not the same thing ? If the ball is 3 feet far away from the origin, and after the rotation the ball will be rotated and 3 feet far away from the origin, is not what we want to do ?       I don't understand the meaning of the last equation . The multiplication with parent-inverse-bind brings the bind matrix into the space of joints parent, right ? But was not matrix bind already in joints parente space ?   Sorry for my bad english. I'm also trying to learn english =P
15. ## Rotate a bone, mathematical issues :(

Hi Thanks to the answer ;) I have found a code's working, but I would understand what the author do ;) This is the code :   public void transformJointOnPivot(Joint joint, Matrix mat) { Matrix bind = getJointBindMatrix(joint); SimpleVector pos = bind.getTranslation(); // set the matrix to the origin pos.scalarMul(-1); bind.translate(pos); // apply the transformation (this may translate it as well of course) bind.matMul(mat); // place it back where it was pos.scalarMul(-1); bind.translate(pos); // TODO see if we need to do anything if the parent is not in its bind // position mulMatrixByInverse(getJoint(joint.getParentIndex()), bind); pose.getLocal(getJointIndex(joint)).setTo(bind); } mulMatricByInverse do bind=bind * joint inverse bind pose matrix.   pose.getlocal(joint),setTo(bind) se te location trasform matrix relative of joint's parent to bind.     But I don't understand why we have to do in this mode for moving the joints ..   1- Why we have to applicate the rotation after we set the matrix to the origin ?  2- why we multiply this created matrix for the joint's parent's inverse bind pose matrix and not for the joint's inverse bind pose ? 3- why we set the local trasformation matrix to the created matrix ?   I think that I don't understand the math behind this trasformation :/
• Advertisement
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!