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 - tinhtinhcd

#1
Support / how to lazyload
August 14, 2017, 06:06:50 AM
Hi,
I have problem with performance when try to load a big file size in the screen.
I have 2 screen,
screen 1 have a button, when i click this button it will go to screen 2 to load object but it take 2-3 second to go next screen.
is there any way that i can go to the 2nd screen first and load the render for surfaceView later.
#2
Support / Re: multi object in one sigle file.
August 08, 2017, 06:50:37 AM
Thanks EgonOlsen,

yesterday i saw the method megerAll(), i call this and treat all as one object, i see it work fine for me now.
#3
Support / Re: multi object in one sigle file.
August 07, 2017, 04:55:51 AM
but the are many object, which object should i call.
#4
Support / multi object in one sigle file.
August 04, 2017, 12:56:41 PM
Hi,

I have an obj file with many object inside (about 67 object).
currently, when load from obj i made the fist object as parent and add the other as child to rotate and zoom.
the problem is when i set parent as center camera and rotate, it will rotate around the parent object, not the middle of them.
how can I rotate around the middle of them because I don't know which object is in the center of all object.

#5
Support / Re: glPushMatrix() & glPopMatrix()
June 09, 2017, 08:09:03 AM
Finally it work as expectation.
But a strange thing that I must switch z<=>y and x=-x.
I have no idea why it work on that way.
#6
Support / Re: glPushMatrix() & glPopMatrix()
June 09, 2017, 06:15:40 AM
Hi,
after check again,
I see my matrix is not correct, so I update it and use transformToGL();

Matrix matrix = new Matrix();

        float x = mPquart[1];
        float y = mPquart[2];
        float z = mPquart[3];
        float w = mPquart[0];

        float[] dump = new float[16];

        final float xx = x * x;
        final float xy = x * y;
        final float xz = x * z;
        final float xw = x * w;
        final float yy = y * y;
        final float yz = y * z;
        final float yw = y * w;
        final float zz = z * z;
        final float zw = z * w;

        dump[0] = 1 - 2 * (yy + zz);
        dump[4] = 2 * (xy - zw);
        dump[8] = 2 * (xz + yw);
        dump[12] = 0;
        dump[1] = 2 * (xy + zw);
        dump[5] = 1 - 2 * (xx + zz);
        dump[9] = 2 * (yz - xw);
        dump[13] = 0;
        dump[2] = 2 * (xz - yw);
        dump[6] = 2 * (yz + xw);
        dump[10] = 1 - 2 * (xx + yy);
        dump[14] = 0;
        dump[3] = 0;
        dump[7] = 0;
        dump[11] = 0;
        dump[15] = 1;

        matrix.setDump(dump);

       matrix.transformToGL();


I saw the object rotate different, but I still have a problem.
When I rotate my device on xAxis, it will rotate y or z, it only rotate properly when i put the device and my phone same direction.
Is there anything that I miss.

Thanks so much for support. 
#7
Support / Re: glPushMatrix() & glPopMatrix()
June 08, 2017, 05:56:45 AM
Hi, the above code work but it is not what i need for my project.

My app connect with a real device and receive quaternion data from that.
What I need is when my device rotate in real world, the object must rotate the same way.
Currently, it only work when i put the these XAxis in same direction.

thanks.
#8
Support / Re: glPushMatrix() & glPopMatrix()
June 06, 2017, 09:48:34 AM
Hi,
I'm not good at Math. Base on what I understand. Is this what I need.

private Matrix convertMatrix(){
        Matrix matrix = new Matrix();

       float angle = (float)  Math.acos(mPquart[0]);
        float c = (float) Math.cos(angle);
        float s = (float) Math.sin(angle);
        float x = mPquart[1];
        float y = mPquart[2];
        float z = mPquart[3];

        float[] dump = new float[16];

        dump[0] = x*x*(1-c)+c;
        dump[1] = x*y*(1-c)-z*s;
        dump[2] = x*z*(1-c)+y*s;
        dump[3] = 0f;
        dump[4] = y*x*(1-c)+z*s;
        dump[5] = y*2*(1-c)+c;
        dump[6] = y*z*(1-c)-x*s;
        dump[7] = 0f;
        dump[8] = x*z*(1-c)-y*s;
        dump[9] = y*z*(1-c)+x*s;
        dump[10] = z*2*(1-c)+c;
        dump[11] = 0f;
        dump[12] = 0f;
        dump[13] = 0f;
        dump[14] = 0f;
        dump[15] = 1f;

        matrix.fillDump(dump);

        return matrix;
    }

and
obj.setRotationMatrix(convertMatrix());
#9
Support / glPushMatrix() & glPopMatrix()
May 26, 2017, 09:08:44 AM
I have to rotate object around the axis


public void onDrawFrame(GL10 gl) {
....
parentObj.rotateAxis(new SimpleVector(mPquart[1],mPquart[2],mPquart[3]),mPquart[0]);
...
}


The problem is mPquart is Quaternion and get from SensorManager.
So, I need something like glPushMatrix() & glPopMatrix() to make the object stable when I don't rotate the phone.
How can I do it.

I try gl.glPushMatrix(); and gl.glPopMatrix(); but nothing happen.
#10
Thanks EgonOlsen,

It is first time I work with 3D object, so I don't know it.

#11
Hi,

I don't get it, in that example need to create a texture from a png file.
Texture skinTex=new Texture("textures/dogtex.png");
But I don't have that .png file, I only have the .obj.
#12
Support / How to load texture inside file .obj.
May 19, 2017, 10:57:40 AM
Hi,

My app load object from file .obj.
Inside the .obj also contain texture


vt  1.000000 0.011329 0.000000
vt  1.000000 0.011329 0.000000
vt  1.000000 0.024390 0.000000
vt  1.000000 0.024390 0.000000
vt  1.000000 0.024390 0.000000
vt  1.000000 0.975610 0.000000
vt  1.000000 0.975610 0.000000


how can i load that texture.
#13
Hi EgonOlsen,

i finally find a work around for my application.

^^ thanks for your help .
#14
Hi, it have some common with my issue.
But the answer not work for my case.

SimpleVector trsl=new SimpleVector(1,2,0);
trsl.matMul(p1.getWorldTransformation());
p2.translate(trsl);

or

p2.translate(p1.getXAxis());

that code make my child moving on the world space, i don't want it happen, my child should move on it's parent space.

#15
Hi, my app have 2 object.
The object2 is a child of object1.

At the first time run app. I click on child and call translate, it go on the correct direction that i that my finger move.
After I rotate the parent, it go on the opposite way with my finger.

I only want the child move along with it out Axis, not in work Axis.

in pic1 it correct, in pic2 it wrong direction.

here is my code:


public void onDrawFrame(GL10 gl) {
SimpleVector dir = Interact2D.reproject2D3DWS(cam, fragment3D.fb, (int) fragment3D.xPos, (int)fragment3D.yPos).normalize();
world.calcMinDistanceAndObject3D(world.getCamera().getPosition(), dir, 10000F);

if (this.hasToCreateBuffer) {
hasToCreateBuffer = false;
fb = new FrameBuffer(w, h);
}
if (object2.wasTargetOfLastCollision()){
SimpleVector direction = new SimpleVector(dis*scale,0,0);
object1.translate(direction);
}else{
if (touchTurn != 0) {
object1.rotateY(touchTurn);
touchTurn = 0;
}
if (touchTurnUp != 0) {
object1.rotateX(touchTurnUp);
touchTurnUp = 0;
}
}
updateFrame();
}