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

Topics - cefengxu

#1
Bones / [resolved] changing animation via interaction
December 10, 2015, 10:11:00 AM
hi raft :

i want to implement a feature .
when i touch the object with loop animation-1 , the object must have some respond ( do  another animation-2 ) , and then come back to the original animation-1 after the animation-2 is finished.

how to do that ? i know how to change the animation with model using :
group.animateSkin(index, animationID);

but i do not know how to handle the time of the animation, or does Bones have some simple ways to deal with it ??
#2
Support / [ resolved ] picking of Object3D
December 02, 2015, 10:36:00 AM
Hi master :

i want to know the model do some reply when i touch it on the screen, so i use the Picking of jpct-ae  to realized it.
example
i add a cube with six diff. faces  and add setCollisionMode respectively :

     // Front
        front = new Object3D(2); 
        front.addTriangle(upperLeftFront,0,0, lowerLeftFront,0,1, upperRightFront,1,0, TextureManager.getInstance().getTextureID("frontt")); 
        front.addTriangle(upperRightFront,1,0, lowerLeftFront,0,1, lowerRightFront,1,1,TextureManager.getInstance().getTextureID("frontt")); 
        cube.addChild(front); 
        world.addObject(front);     
        front.setCollisionMode( Object3D.COLLISION_CHECK_SELF); 
         
     // Back...
 
     // Upper...
       
     // Lower...

     // Left...
         
     // Right ...

        cube.strip(); 
        cube.build(); 
        world.addObject(cube); 
        cube.setCulling(false); 
        cube.scale( 0.05f);     
        cube.setCollisionMode( Object3D.COLLISION_CHECK_SELF);


and then , i use the touch event to know which face was triggered when i touched the screen :

public int Pickint( int fX, int fY){ 
     
        //fY = fb.getHeight() - fY;
SimpleVector dir = Interact2D.reproject2D3DWS( cam, fb, fX, fY).normalize();
Object[] res=world.calcMinDistanceAndObject3D(cam.getPosition(), dir, 10000 );
         
        Object3D picked = (Object3D)res[1];   
         
        Object3D picked = (Object3D)res[1]; 
   
        if( picked == null){
       
            return -1; 
       }
       
       
        if( picked.getID() == front.getID()) 
        Log.i("jpctae", "touch front");
        else  if( picked.getID() == back.getID()) 
        Log.i("jpctae", "touch back"); 
        else  if( picked.getID() == upper.getID()) 
        Log.i("jpctae", "touch upper"); 
        else  if( picked.getID() == lower.getID()) 
        Log.i("jpctae", "touch lower");   
        else  if( picked.getID() == left.getID()) 
        Log.i("jpctae", "touch left");   
        else  if( picked.getID() == right.getID()) 
        Log.i("jpctae", "touch right");
         
        return 1; 
    }


However, the questions is :
1- the picked.getID() output only have some respond when i touch the top left corner of every face of cube.
2- or some time the picked always = null
#3
hi  raft :

now i can create some simple model ( teapot , cube and et al ..  ), add some bones and animated  and export to .bones , and then render via bones successfully.

however, when i render some complex model ( or download from the internet  ), the result is : the screen shows nothing.
oppositely , i can export this model into obj and render via jPCT-AE successfully.

i am sure the "Steps of .Bones Export" is correctly and the code is ran  certainly according the logcat


so , do you meet such bug ??? or may be the Bones could no render some complex model with animation ?

Rgs

Cefengxu
#4
hi master:

i have import the obj via JPCT basic on ARTookit, however, the model has a peculiar distortion between two differnet model(landscape & portrait) , such like the cut picture shown.

i have refered the artical " Integrating JPCT-AE with Vuforia - Additional corrections " ,
but it seem not a reason to cause such distortion.

do you have another idea ?

Thanks..
#5
hi raft :
now i uses the blender to make a model with animation and export to body.skeleton.xml and body.mesh.xml.

body.skeleton.xml just including only one animation :
<animations >
<animation name="my_animation" length="1.0833333333333333" >

      <tracks >

        <track bone="root" >

          <keyframes >

            <keyframe time="0.0" >

              <translate z="0.000000" x="0.000000" y="0.000000" />
      ......
      ...
      .
</animation>
</animations >


and then transfer to body.bones via cmd and load it via Bones , as the code shown belown.

   animation =  1;
     
   if (animation > 0 && masterNinja.getSkinClipSequence().getSize() >= animation) {
      float clipTime = masterNinja.getSkinClipSequence().getClip(animation-1).getTime();
      if (animateSeconds > clipTime) {
         animateSeconds = 0;
      }
      float index = animateSeconds / clipTime;
      if (false) {
         for (AnimatedGroup group : ninjas) {
            for (Animated3D a : group)
               a.animate(index, animation);
         }
      } else {
         for (AnimatedGroup group : ninjas) {
            group.animateSkin(index, animation);

         }
      }
         
   } else {
      animateSeconds = 0f;
   }


however, when i loading  such model and the demo crash and the error output:

11-11 17:41:20.559: E/AndroidRuntime(12906): FATAL EXCEPTION: GLThread 727
11-11 17:41:20.559: E/AndroidRuntime(12906): Process: com.airhockey.android, PID: 12906
11-11 17:41:20.559: E/AndroidRuntime(12906): java.lang.ArrayIndexOutOfBoundsException: length=333; index=-1
11-11 17:41:20.559: E/AndroidRuntime(12906): at raft.jpct.bones.Animated3D.applySkeletonPose(Animated3D.java:511)
11-11 17:41:20.559: E/AndroidRuntime(12906): at raft.jpct.bones.AnimatedGroup.animateSkin(AnimatedGroup.java:178)
11-11 17:41:20.559: E/AndroidRuntime(12906): at com.airhockey.android.AirHockeyRenderer.onDrawFrame(AirHockeyRenderer.java:209)
11-11 17:41:20.559: E/AndroidRuntime(12906): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1522)
11-11 17:41:20.559: E/AndroidRuntime(12906): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)
#6
Hi, raft:

Thanks for your help ~
now i need to deal with the pipeline about model making~ according to the reference links , i have done :
1- download ogreMax and install base on 3ds-Max-2013;
2- download the model including :
      ninja.3ds
     ninja.b3d
     ninja.cfx
     ninja.ms3d
     nskinbl.jpg


so , my question is , how to export it in Max ? do you have some  "tutorial of step by step" for this ?

thanks ~~
#7
hi raft:

Question1:

       
  • [size=78%]what is the format of nijia.group.bones ?[/size]
  • [/size][size=78%]how to open it ?[/size]
  • [/size][size=78%]how to make the model and export to such file ?[/size]

Question2:
i try to copy the cylinder.group.bone & stone.jpg from "Bones/res/raw/" to" Bones-Android-Ninjia/res/raw/"
but the error was outputed as follown:
11-05 15:31:03.730: E/AndroidRuntime(7988): FATAL EXCEPTION: GLThread 402
11-05 15:31:03.730: E/AndroidRuntime(7988): Process: com.airhockey.android, PID: 7988
11-05 15:31:03.730: E/AndroidRuntime(7988): java.lang.RuntimeException: java.io.IOException: Version mismatch. Current version: 4, stream version: 2
11-05 15:31:03.730: E/AndroidRuntime(7988):    at com.airhockey.android.AirHockeyRenderer.onSurfaceCreated(AirHockeyRenderer.java:126)
11-05 15:31:03.730: E/AndroidRuntime(7988):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1500)
11-05 15:31:03.730: E/AndroidRuntime(7988):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)
11-05 15:31:03.730: E/AndroidRuntime(7988): Caused by: java.io.IOException: Version mismatch. Current version: 4, stream version: 2
11-05 15:31:03.730: E/AndroidRuntime(7988):    at raft.jpct.bones.BonesIO.readHeader(BonesIO.java:104)
11-05 15:31:03.730: E/AndroidRuntime(7988):    at raft.jpct.bones.BonesIO.loadGroup(BonesIO.java:85)
11-05 15:31:03.730: E/AndroidRuntime(7988):    at com.airhockey.android.AirHockeyRenderer.onSurfaceCreated(AirHockeyRenderer.java:120)
11-05 15:31:03.730: E/AndroidRuntime(7988):    ... 2 more





#8

hi master:


for the issue " the model rendered by JPCT always lied on the mark and can not be rotate basic the matrix output from ARToolkit "

actually, the matrix output from the ARToolkit::ARNativeActivity.getTransformationMatrix() is correctly and the result of matrix  be such like this:

  0.9592849       0.042872142   -0.27916315   0.0
0.161977        -0.8932123         0.41944835    0.0
-0.23136866   -0.44758964      -0.86379063    0.0
-58.357327     38.013783            381.9324        1.0

<< Orange Color : the rotation info[/size]  [/size]Green  Color: the translation info>>

so i think i just set the translation and  rotation for the model and the result should be right. and then i set up to  jpct-matrix and set into the model like this:

Matrix dump = new Matrix();
dump.setDump(ARNativeActivity.getTransformationM());
dump.transformToGL();
                 
a.clearTranslation();
a.translate(dump.getTranslation());      //   the translation could be sure that it's right because the model can translate through the mark on the screen
                 
a.clearRotation();

a.setRotationMatrix(dump);   // and then the model lied on the mark


dump.rotateX/Y/Z((float)Math.PI/2);    i try to use matrix rotation to rotate the model before process  a.setRotationMatrix(dump) , but no work , the model some time will missing

so , i think i can not handle it now , i have spend server day to deal with this issue but no work.
#9
Hi raft :

the model can be rendering according to you support .

However , the model can not be rendered in correct position ( the rotation is no right , as shown as attached)

case 1 : using the function : model.rotateXYZ(float r) : result : the model could no be in correct angle , some time the model  even missing ;
case 2 : the matrix output from ARToolkit is correct Definitely , because i have verified via rendering a cube through OpenGL ES ;
case 3 : such bug still exists in JPCT-AE;

but i still do not know how to do. so  do you have some idea about it ?

the code was shown as belown:


public void onDrawFrame(GL10 unused) {
//...
Matrix projMatrix = new Matrix();
projMatrix.setDump(ARNativeActivity.getProjectM());
projMatrix.transformToGL();
SimpleVector translation = projMatrix.getTranslation();
SimpleVector dir = projMatrix.getZAxis();
SimpleVector up = projMatrix.getYAxis();
cameraController.setPosition(translation);
cameraController.setOrientation(dir, up);
//...
for (Animated3D a : group) {
a.animate(index, animation);
Matrix dump = new Matrix();
dump.setDump(ARNativeActivity.getTransformationM());
dump.transformToGL();
a.clearTranslation();
a.translate(dump.getTranslation());
a.setRotationMatrix(dump);
Log.i("jpct_test", "runing in loop 2");
}
//...
world.renderScene(frameBuffer);
world.draw(frameBuffer);
frameBuffer.display();
}
#10
Purpose:
rendering a animating model via JPCT-Bones basic on ARToolkit Porject for Augmented Reality Application.


According  for the demo you support(Bones-Android-Ninja) , I have injected the code another project about ARToolkit and the model can be rendered on the screen in front of preview data ,  as shown on fig1.


Question:
If I  want to render  the model witch stand on the mark in real-time, how to change the camera position , camera direction and the model position/rotation.

Actually, I can realize it with md2 model using JPCE-AE ( as shown in figure2 , the code was shown as bellow) : But , for JPCT-Bones, how to do ?

[size=12pt]public void onDrawFrame(GL10 unused) {
float[] projection = ARNativeActivity.getProjectM();

Matrix projMatrix = new Matrix();
projMatrix.setDump(projection);
projMatrix.transformToGL();
SimpleVector translation = projMatrix.getTranslation();
SimpleVector dir = projMatrix.getZAxis();
SimpleVector up = projMatrix.getYAxis();
cam.setPosition(translation);
cam.setOrientation(dir, up);

float[] transformation = ARNativeActivity.getTransformationM();

Matrix dump = new Matrix();
dump.setDump(transformation);
dump.transformToGL();
cube.clearTranslation();
cube.translate(dump.getTranslation());
cube.setRotationMatrix(dump);

cube.setState(stat);
cube.animate(ticks);

world.renderScene(fb);
world.draw(fb);
fb.display();
}[/size]



#11
Bones / [resovled] some error when inject the Bones
October 30, 2015, 03:19:38 AM
Hi raft :

i got some error when inject the Bones Project into my Project but some error was shown as below:

10-30 10:07:47.388: E/AndroidRuntime(8944): FATAL EXCEPTION: GLThread 887
10-30 10:07:47.388: E/AndroidRuntime(8944): Process: com.airhockey.android, PID: 8944
10-30 10:07:47.388: E/AndroidRuntime(8944): java.lang.NoClassDefFoundError: Failed resolution of: Lraft/jpct/bones/BonesIO;
10-30 10:07:47.388: E/AndroidRuntime(8944):    at com.airhockey.android.AirHockeyRenderer.onSurfaceCreated(AirHockeyRenderer.java:133)
10-30 10:07:47.388: E/AndroidRuntime(8944):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1500)
10-30 10:07:47.388: E/AndroidRuntime(8944):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)

i think it should be the Problem  of Import , but  i have set the Java Build Project to Bones already, so what't i need to do ??
#12
i have fix this issue , i will post a tutorial later.

Question: and then , the model could not be change ( always be laid on the mark ,as shown as the attached ) even i use the function rotationMatirx ;

my code as belown:


    public void onDrawFrame(GL10 unused) {
float[] projection = ARNativeActivity.getProjectM();
Matrix projMatrix = new Matrix();
projMatrix.setDump(projection);
projMatrix.transformToGL();
SimpleVector translation = projMatrix.getTranslation();
SimpleVector dir = projMatrix.getZAxis();
SimpleVector up = projMatrix.getYAxis();
cam.setPosition(translation);
cam.setOrientation(dir, up);

float[] transformation = ARNativeActivity.getTransformationM();
Matrix dump = new Matrix();
dump.setDump(transformation);
dump.transformToGL();
alita.clearTranslation();
alita.translate(dump.getTranslation());
alita.setRotationMatrix(dump);

alita.setState(stat);
alita.animate(ticks);
}
#13
Dear Master :

Purpose :
i need to set a  [ real-time matrix ] for the obj to realize the AR ;

as the normally, i can use the "fucntion GLES20.glUniformMatrix4fv" to set a matrix to the shader , and then calculate the right position of the model on the screen;

i can get the translate matrix output by ARToolkit in real-time ;
but  i do not know how to set the matrix when i use the jpct-ae to rendering.

i have tried to use the "jpct-ae-fucniton model.setTranslationMatrix(mat);" , but all the result  for scale , position and direction  are wrong.


question : how to use the translationmatrix in jpct as will as GLES20function::GLES20.glUniformMatrix4fv??
#14
Bones / [ resolved ] how to exp the Ogre3D's format
October 22, 2015, 11:50:14 AM
Dear raft:

my question is :
1- how to exp the Ogre3D's format. or which plugging i need to download?
2- what is the format name of the Ogre3D's format ???

#15
follow the help from EgonOlsen , i have loading a md2 model on the preview data.

However, the texture of the model have been changed and overwrited by the preview buffer texture grab of camera. Pls find  the attached , shown such case
so , how can i change the textureID manually or have another way to fix such issue .
#16
Dear master:

i have got a problem and i still could not fix it :

Purpose : using JPCT to render 3D Model for AR basic on ARToolkit;
Platform: Eclipse , ARToolkit Example: ARNative;
jpct: i using the JPCTdemo (helloworld) to add the jpct's code into my code for rendering a cube on the preview image;

However :
the error will be shown as follown when run the function "renderScene(fb)"

10-21 16:44:00.737: E/AndroidRuntime(20351): FATAL EXCEPTION: GLThread 545
10-21 16:44:00.737: E/AndroidRuntime(20351): Process: org.artoolkit.ar.samples.ARNative, PID: 20351
10-21 16:44:00.737: E/AndroidRuntime(20351): java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
10-21 16:44:00.737: E/AndroidRuntime(20351): at com.threed.jpct.CompiledInstance._fill(CompiledInstance.java:1223)
10-21 16:44:00.737: E/AndroidRuntime(20351): at com.threed.jpct.CompiledInstance.fill(CompiledInstance.java:844)
10-21 16:44:00.737: E/AndroidRuntime(20351): at com.threed.jpct.Object3DCompiler.compile(Object3DCompiler.java:168)
10-21 16:44:00.737: E/AndroidRuntime(20351): at com.threed.jpct.World.compile(World.java:2091)
10-21 16:44:00.737: E/AndroidRuntime(20351): at com.threed.jpct.World.renderScene(World.java:1061)
10-21 16:44:00.737: E/AndroidRuntime(20351): at org.artoolkit.ar.samples.ARNative.Renderer.onDrawFrame(Renderer.java:210)
10-21 16:44:00.737: E/AndroidRuntime(20351): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1522)
10-21 16:44:00.737: E/AndroidRuntime(20351): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)
#17
Hello:

i have download the Demo( :Bones-Android-Ninja) and the "Bones",  and then finish the Setup on Eclipse, there are no error of the project now.
However, when i click " Run as -  Android Application ",  some error log will be shown as follow:

[2015-10-19 16:46:23 - Bones-Android-Ninja] Dx
trouble writing output: already prepared
[2015-10-19 16:46:24 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/threed/jpct/Animation;
[2015-10-19 16:46:24 - Bones-Android-Ninja] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/threed/jpct/Animation;

what's wrong with the code or the setup of the project ?
Thanks ~~!!!!