Hello to everyone :)
I'm trying to animate a human's rigged model for an Android Application ( Real-time Motion Capture ).
Is possible to do this using jPCT-AE and Bones ?
Something like this https://www.youtube.com/watch?v=NYT-nx533nM
I have the library that gives me the position of the sensor in a quaternion.
I thought to set the quaternion on the relative bones.
But I don't know which function I have to use to identify bones and joints of my rigged model and which function I have to use to set its position in quaternion format.
Have you any suggestion for me ?
Thanks all :)
yes, sure it's possible. you have to set position/rotation of joints of skeleton. that is done via SkeletonPose. as its name suggests it's a pose of Skeleton. later that pose is applied to target object's mesh via Animated3D.applySkeletonPose().
have a look at ProceduralAnimationSample which programatically changes SkeletonPose and applies it.
however, calculating poses based on some input is not trivial and to tell the truth i'm not fluent with writing equations for it.
Thank you so much :)
I'll download jpct-ae and bones and I'll look the proceduralanimationsample :)
Sorry,
I downloaded bones-android-ninja, I imported it in eclipse , but
5 errors appeared :
import raft.jpct.bones.Animated3D;
import raft.jpct.bones.AnimatedGroup;
import raft.jpct.bones.BonesIO;
import raft.jpct.bones.SkeletonPose;
import raft.jpct.bones.SkinClip;
(import raft cannot be resolved)
And I have another question :
bones is included in jpct-ae ?
or I have to import some library ? I ask that because I'm downloaded jpct and bone , but I don't find bones's libs :/
Bones is not included in ninja demo app. you should download it separately and import to Eclipse. by default, Ninja demo app looks for Bones project in its classpath.
for your own projects, either add Bones the same way to your classpath or add its jar, which is in Bones/build directory.
I don't find its jar :/
it is in Bones.zip/build directory
sorry i'm burned out :'(
(tired and stupid -.-")
Before to read your post I compiled and built all files included in Bone.zip ahahah
np ;)
can you suggest me a rigged model that is easy to export to bones ?
I downloaded this model http://www.blendswap.com/blends/view/21948 (http://www.blendswap.com/blends/view/21948) and I'm trying to follow this tutorial http://www.jpct.net/wiki/index.php/Exporting_from_Blender_to_Bones (http://www.jpct.net/wiki/index.php/Exporting_from_Blender_to_Bones) to export in bones format, but for now I'm failing :'(
not really, sorry :/ i've never exported from Blender myself. maybe contacting a Blender user may help?
Which extension of model do you usually use ?
in the past i've used 3dsMax + OgreMax exporter to export to Ogre3D format. it was quite stable and usable. AFAIK there is an OgreMax for Maya too.
I want to develop Android app but if I want to see if the conversion is done well can I import bones project in eclipse and use LoadBonesFormatSample ?
I did :
1- exported from blender to collada
2- used collada script exporter (in rotation what I have to put ? O.o )
3- I changed the LoadBonesFormatSample's code line from
FileInputStream fis = new FileInputStream("./samples/data/ninja/ninja.group.bones");
to
FileInputStream fis = new FileInputStream("./samples/data/ninja/scheletro.group.bones");
4- imported all the folder in eclipse and run LoadBonesFormatSample
But sadly It doesn't work, I see only one ninja's leg -.-" During the conversion the warning say me "WARNING : max of 4 joints .."
last question : when I export in ogree different files are being created , but how I have to use jmeOgre2Bones ?
For example in the last conversion I had this file :
- Sphere.000.mesh
- Sphere.000.mesh.xml
-Sphere.004.mesh
-Sphere.004.mesh.xml
-Sphere.004.skeleton
-Sphere.004.skeleton.xml
p.s : now I'm downloading 3dmax student version .. I have to find the way to import a rigged model in bones :(
Quote from: aeroxr1 on August 19, 2014, 08:01:26 PM
1- exported from blender to collada
why not export to Ogre format as mentioned in wiki page? i found Ogre a much usable format
Quote from: aeroxr1 on August 19, 2014, 08:01:26 PM
2- used collada script exporter (in rotation what I have to put ? O.o )
-rotation x180
Quote from: aeroxr1 on August 19, 2014, 08:01:26 PM
last question : when I export in ogree different files are being created , but how I have to use jmeOgre2Bones ?
jmeOgre2Bones -rotation x180 -out sphere.group.bones -in Sphere.000.mesh.xml
i'm trying to export this :
http://www.turbosquid.com/FullPreview/Index.cfm/ID/535459 (http://www.turbosquid.com/FullPreview/Index.cfm/ID/535459)
the export generated seems ok infact has generated stacy.group.bones.
After I put the generated file into C:\Bones\samples\data\ninja, I edit the line codes but the java compiler says me that he doesn't found Cube.group.bones -.-"
:o
is it the compiler or do you get an error at runtime? it's possibly caused by a typo
Exception in thread "main" java.io.FileNotFoundException: .\samples\data\ninja\stacy.group.bones (Impossibile trovare il file specificato)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at bones.samples.LoadBonesFormatSample.loadNinja(LoadBonesFormatSample.java:46)
at bones.samples.LoadBonesFormatSample.createAnimatedGroup(LoadBonesFormatSample.java:42)
at bones.samples.AbstractSkinSample.initialize(AbstractSkinSample.java:79)
at bones.samples.LoadBonesFormatSample.initialize(LoadBonesFormatSample.java:85)
at bones.samples.AbstractSample.loop(AbstractSample.java:91)
at bones.samples.LoadBonesFormatSample.main(LoadBonesFormatSample.java:97)
:)
In this rar file there are the ogre's resulting files :
https://mega.co.nz/#!Hc1GmLKB!xMFyrr3cenXpBsPxyy7oj_0uUrLqQG3QAlldN4mla-I (https://mega.co.nz/#!Hc1GmLKB!xMFyrr3cenXpBsPxyy7oj_0uUrLqQG3QAlldN4mla-I)
is it stacy.group.bones or Cube.group.bones? ;)
Stacy stacy :D
I tryed to use OgreSample but there is the same error :(
I tryed to use OgreMaxViewer and it correctly loads the model :o
Now I want to try to use 3dmax 2015. You have a model to suggest me that you know that it works ? :)
thanks to everythings :)
In this archive https://mega.co.nz/#!Hc1GmLKB!xMFyrr3cenXpBsPxyy7oj_0uUrLqQG3QAlldN4mla-I (https://mega.co.nz/#!Hc1GmLKB!xMFyrr3cenXpBsPxyy7oj_0uUrLqQG3QAlldN4mla-I) there are this files :
- ogre file
- bones file
as i said in your other post, the exception is clear, java io cannot find your file. double check file name and location.
Thanks :)
I have put the stacy.bones.group in the ninja's folder, but java finds ninja's files and not stacy's files ... ;) :)
maybe java cannaot read because of file permissions? btw java file names are case sensitive
I think that your problem is that you're not exporting XMLs. If you can open the file with the OgreMax Viewer, you're probably just exporting the binary version of the file. Go to OgreMax's scene settings and click on "Export XML".
To answer your PM, most rigged models work fine. When they don't, I usually complain here (I have found Derek, the creator of OgreMax, to be less than helpful). Hope this solves your problem.
THanks :)
For now I always used blender and for exporting use this : https://code.google.com/p/blender2ogre/ (https://code.google.com/p/blender2ogre/) .
If you tell me that also you (as raft) use 3dmax , I will try to use 3dmax :)
p.s : During the installation of ogreMaxSceneexporter the software ask me to select or ogre 1.8.x or ogre 1.7.x , I selected 1.8 . I did well ? ( I suppose yes :D )
EDIT :
http://www.ogremax.com/Documents/OgreMaxSceneExporter-3DSMax/scene-settings-dialog-page-meshes.html (http://www.ogremax.com/Documents/OgreMaxSceneExporter-3DSMax/scene-settings-dialog-page-meshes.html)
I have selected export xml files, are there any options that I have to select or to edit ?
Now jmeOgre2Bones give me this error :
C:\Bones\scripts>jmeOgre2Bones -rotation x180 -out vincent.bones.group -in vince
nt_Mesh.mesh.xml
C:\Bones\scripts>echo off
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
ago 21, 2014 6:19:46 PM com.jmex.model.ogrexml.anim.SkeletonLoader loadSkeleton
WARNING: Rotation axis not normalized
Exception in thread "main" java.lang.IllegalArgumentException: No controller fou
nd in OgreEntityNode. Means there is no skeleton or pose animation!
at raft.jpct.bones.BonesImporter.importOgre(BonesImporter.java:135)
at raft.jpct.bones.util.JMEOgreImporter.loadGroup(JMEOgreImporter.java:1
12)
at raft.jpct.bones.util.JMEOgreImporter.loadGroup(JMEOgreImporter.java:8
8)
at raft.jpct.bones.util.JMEOgreImporter.run(JMEOgreImporter.java:69)
at raft.jpct.bones.util.JMEOgreImporter.main(JMEOgreImporter.java:170)
-.-"
:'(
This is the model that I'm trying to export :)
https://mega.co.nz/#!LY1lSKaT!D5uHWcQunQcstXDhrZ1bgHkQycjjrXKOxZBW2RDLEWo (https://mega.co.nz/#!LY1lSKaT!D5uHWcQunQcstXDhrZ1bgHkQycjjrXKOxZBW2RDLEWo)
1.8 works. I've never seen a difference (although, since the Ogre format changed last year, there may well be one). Go with 1.8 to avoid confusion. And http://tf3dm.com/3d-model/robocop-52409.html is an example of a model that probably works. This site has a whole lot of free game models (though you won't be able to use them commercially because they tend to be stolen from existing games). I haven't tried the linked model because usually I only use Character Studio rigs (in order to be able to use the Mixer). But you can try the models on that site. I'm sure that most of them (get the .daes, not the OBJs, obviously) will be usable.
That's the only setting that you need to change for Scene. Now select your character and go to "Object Settings." Under "Mesh Animations," add your animations. Then, export scene (and be sure to select ".mesh"). Voilá.
AH ok,
now i'm trying to export this :
https://mega.co.nz/#!LY1lSKaT!D5uHWcQunQcstXDhrZ1bgHkQycjjrXKOxZBW2RDLEWo (https://mega.co.nz/#!LY1lSKaT!D5uHWcQunQcstXDhrZ1bgHkQycjjrXKOxZBW2RDLEWo)
And the jmeogre2bones give me some errors that I wrote in precedent post , but I think there were errors because I selected .scene file !
Now I'm retrying :D
Thanks :)
If you have no animations listed under "Object Settings>Mesh Animations" there won't be a skeleton (or there will, but it won't describe any animations) and Bones won't load your model.
Personally, I think that it should load any model with a .seleton.xml file, whether or not there are animations, so that you could animate your models programmatically...
In my project I want to animate programmatically my model .
But If I want to use my model in bones and animate it after by code programming what I have to do ?
Infact the model that I try to export has not animation :/ It's only rigged..
What I have to do to export it in bones and use it ???
I generated ogre files, but if I use jmeogre2bones gives me the posted error. Can I import the model in bones without the conversion ogre to bones ?
You have to put an animation in. You don't have to use it, though.
The conversion is done. Now I try to put it in LoadBonesFormatSample :)
THANKS TO EVERYONE :)
Now it work ;)
Skeleton is correctly loaded :)
I also have finded the errors that I did with blender -.-""" It's my fault and not exporter's fault ::)
I had added the .bones file in wrong folder because eclipse had copied all the bones folder in its workspace :-[
I'm very stupid .. sorry -.-"
I have an other question , my model has .tga texture. I try to import it by editing this following code lines :
Texture texture = new Texture("./samples/data/ninja/Vincent_new_UV.tga");
TextureManager.getInstance().addTexture("ninja", texture);
for (Animated3D o : skinnedGroup) {
o.setTexture("ninja");
o.build();
o.discardMeshData();
}
but it not works. There are some rules to set the texture ? dimension , extension ecc ecc ? :)
It will only open a format that Java opens. Export your texture as a PNG. That's the best format for it (and the file will be smaller, to boot).
THANKS !!!!
it works !!!!!!!! ;D
Quote from: AGP on August 21, 2014, 07:03:29 PM
If you have no animations listed under "Object Settings>Mesh Animations" there won't be a skeleton (or there will, but it won't describe any animations) and Bones won't load your model.
Personally, I think that it should load any model with a .seleton.xml file, whether or not there are animations, so that you could animate your models programmatically...
Hi it's me again :)
I correctly exported the 3ds rigged model to bones format , but now I want to programmatically animate it.
Which bones's functions do I have to look at ?
Which are the steps that I have to follow ?
( I have to move the leg of the human model )
have a look at ProceduralAnimationSample. it does something similar
yes but in procedural example it imports collada model while I have model in bones format .
If I import the file .bones, the bones and joints are automattically imported ?
If I want to refer to determinated joint or bone what do I have to do ?
either way they are converted into same java objects :)
you can find a joint by index (if you now) or by name (again if you now)
Skeleton.getJoint(int)
Skeleton.findJointByName(String)
I use this function to load my models :
private AnimatedGroup loadNinja() throws Exception {
FileInputStream fis = new FileInputStream("./samples/data/ninja/vincent.group.bones");
try {
AnimatedGroup skinnedGroup = BonesIO.loadGroup(fis);
Texture texture = new Texture("./samples/data/ninja/Vincent_new_UV.png");
TextureManager.getInstance().addTexture("ninja", texture);
for (Animated3D o : skinnedGroup) {
o.setTexture("ninja");
o.build();
o.discardMeshData();
}
return skinnedGroup;
} finally {
fis.close();
}
}
After I have imported it, do I have to use this following functions to refer to index ?
SkeletonPose currentPose=animatedGroup.get(0).getSkeletonPose();
currentPose.getSkeleton().getJoint(index);
yes, that's one way of accesing the skeleton. you can also access it by:
Animated3D.getSkeleton
thanks :D
Another question ;D
Where I have to put the .bones file in an Android project ?
In the asset folder right ? :)
i prefer putting them into /res/raw folder
and you refer to it using R.raw.yourfile . Perfect :)
yes, right :)
Where do you suggest to create the model ?
in the onSurfaceCreated function ? Or is better if I create the model in an other function ? :)
doesnt really matter at this stage of the project. you can load them in any thread and anytime
8)
Hi :)
why I have to put the bones file in the animatedgroup and not in animate3d ?
(i watched ninja bones android demo)
Quote
masterNinja = BonesIO.loadGroup(res.openRawResource(R.raw.ninja));
And why the texture is applicate in this for function ?
for (Animated3D a : masterNinja)
a.setTexture("ninja");
If I have only one bones file with only one 3d model , do I have to do same thing ?
yes, you should do the same thing.
if you will always have one object in your group, you can use BonesIO methods to save a single object. but personally I dont see any point in that
I set the camera in this way :
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
cam.lookAt(new SimpleVector(0, -box_h/2, box_h));
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 the result is :
(http://imagizer.imageshack.us/v2/150x100q90/910/LNhpJA.png) (http://imageshack.com/f/paLNhpJAp)
it isn't as I wanted :(
I would set the camera in front of the model :( Where did I wrong ?
And I have seen helloworld and other jpct-ae's examples and in all of those the world is created in onSurfaceChange; it works but how ? Does Onsurfacechange runs only when the display is rotated ?
And another things, is there a function to scale the model in landscape mode ? I mean when I rotate the display from portrait to landscape mode the human model has to become little :D
just move the camera to other part of model. or rotate the model.
you can move camera closer to make the model look bigger. or you can scale the model.
onSurfaceChanged is called every time the surface is created. just read the docs:)
Quote from: raft on September 06, 2014, 06:51:53 PM
just move the camera to other part of model. or rotate the model.
you can move camera closer to make the model look bigger. or you can scale the model.
onSurfaceChanged is called every time the surface is created. just read the docs:)
QuoteCalled when the surface changed size.
Called after the surface is created and whenever the OpenGL ES surface size changes.
Typically you will set your viewport here. If your camera is fixed then you could also set your projection matrix here
I didn't see this line -.-"""" sorry ::)
Another stupid question :
when I import a new model, in what position will be place ? 0,0,0 ? :D
I imagine is very stupid question, but I know little of 3d graphics -.-"
yes, it will be in origin (0,0,0) in world space.
but that does not necessarily means you will see your model in origin. that depends on the model position when it's exported
All the object after the inserting is positionated in 0,0,0 ?
For example when I use getcamera() the camera initially is in 0,0,0 ?
I try to ask :D :
Is there an example where the model is scaled when the smartphone is rotated from portrait to landscape view ? :D
Now I'm trying to experiment with direction,simplevector and rotation matrix ;D
yes everything is initially at origin until you move them to somewhere
Quote from: aeroxr1 on September 06, 2014, 09:45:21 PM
Is there an example where the model is scaled when the smartphone is rotated from portrait to landscape view ? :D
possibly there is somewhere in the forum. just try different scaling values.
it's also possible to make the model occupy same height of the screen by adjusting camera distance. have a look at
AbstractSkinSample.autoAdjustCamera method
off-topic : bones's website is down
yes, i know, thx. my hosting company says my server is DDOS attacked ???
Do Hacker wants to obtain your private images ? xD
Now I'm trying to understand the rotation matrix to applied it to the arms , I want they lies along the body :)
( I want to set the position of model's arms via programmatically )
I searched into the web, but I didn't found an explanation of the use of matrix bindpose , matrix inverse bind pose and the relation between them.
EDIT : I found this explanation http://www.gamedev.net/topic/571044-skeletal-animation-bonespace/ . It is wrong ?
But remain this doubts :
final Matrix jointInverseBindPose = pose.getSkeleton().getJoint(jointIndex).getInverseBindPose();
final Matrix jointBindPose = jointInverseBindPose.invert();
jointInverseBindPose ok, now , maybe I understand whats is it.
But why do we do this : jointBindPose = jointBindPose = jointInverseBindPose.invert();
?
in the precedent link this thing there isn't .. :(
Other parts of code that I don't really understand are :
// Get a vector representing forward direction in neck space, use inverse to take from world -> neck space.
SimpleVector forwardDirection = new SimpleVector(bindPoseDirection);
forwardDirection.rotate(jointInverseBindPose);
// Get a vector representing a direction to target point in neck space.
SimpleVector targetDirection = targetPos.calcSub(pose.getGlobal(jointIndex).getTranslation()).normalize();
targetDirection.rotate(jointInverseBindPose);
in particular why do we use jointinversebindpose to rotate the forwarDirection and the targetdirection ? to take from world to neck space don't we need to multiply vector to jointinversebindpose ?
And I don't understand this : pose.getGlobal(jointIndex).getTranslation()
Can you give me a hand ?
well, to tell the truth I'm not proficient in those calculations too :-[
a few points:
* each joint's transform is in its parent's space.
* as the name suggests invertBindPose is the invert of bindPose of joint. we use it in calculations, so instead of inverting bindPose each time, we keep a reference to its invert.
have a look at SkeletonPose updateTransforms and setToBindPose methods, they may give some clue.
private void targetJoint(SkeletonPose pose, int jointIndex, SimpleVector bindPoseDirection,
SimpleVector targetPos, final float targetStrength) {
final int parentIndex = pose.getSkeleton().getJoint(jointIndex).getParentIndex();
// neckBindGlobalTransform is the neck bone -> model space transform. essentially, it is the world transform of
// the neck bone in bind pose.
1- final Matrix jointInverseBindPose = pose.getSkeleton().getJoint(jointIndex).getInverseBindPose();
final Matrix jointBindPose = jointInverseBindPose.invert();
.........................
// now remove the global/world transform of the neck's parent bone, leaving us with just the local transform of
// neck + rotation.
subGlobal.matMul(jointBindPose);
2- subGlobal.matMul(pose.getSkeleton().getJoint(parentIndex).getInverseBindPose());
.........................
}
But the inverseBindPose matrix is not the same for all the bones ?
In 2 can I use the inverseBindPose calculated in 1 ? No ? why ?
Quote from: aeroxr1 on September 09, 2014, 04:03:05 PM
But the inverseBindPose matrix is not the same for all the bones ?
of course not, why should it be?
Boh, I thought I read this :-[
I'm trying to positionate the left arm close to the model's body but I can't :(
This is the code that I used :
Logger.log("rotazione");
Tpose = modello.get(0).getSkeletonPose();
Tpose.setToBindPose(); //setto la posa iniziale del modello
final Joint LUpperArm = Tpose.getSkeleton().getJoint(17);
final Joint parentJoint = Tpose.getSkeleton().getJoint(LUpperArm.getParentIndex());
skeletonDebugger=new SkeletonDebugger(Tpose);
skeletonDebugger.addToWorld(world);
rotation=new Matrix(LUpperArm.getBindPose());
rotation.rotateX(90); //ruoto il braccio dalla bindPose di 90gradi
rotation.matMul(parentJoint.getInverseBindPose());
Tpose.getLocal(17).setTo(rotation);
Tpose.updateTransforms();
skeletonDebugger.update(Tpose);
modello.applySkeletonPose();
modello.applyAnimation();
What did I do wrong ?
I have this problems because I don't know the math behind bind matrices,inverse bind matrices and local trasformation ecc ecc :( Could you suggest me some guides ?
well, not really sorry. as i said i'm not proficient in those calculations. i never did such kinnd of programatic positioning before.
thanks anyway :)
I'm not sure about this either, but this is obviously wrong:
rotation.rotateX(90);
All methods in jPCT that want an angle use radians, not degrees. I should make this more clear in the docs...
I edit the code from degree to radiant and I will try :)
In this post I attach the model's skeleton xml files.
I posted it, because I did in this way.
In public void onSurfaceChanged(GL10 gl, int width, int height) :
protected void rotazionebraccio()
{
Logger.log("rotazionebraccio");
final Joint LUpperArm = currentPose.getSkeleton().getJoint(17);
final Joint parentJoint = currentPose.getSkeleton().getJoint(LUpperArm.getParentIndex());
final Matrix global= new Matrix(LUpperArm.getBindPose());
float angle=(float)Math.toRadians(90);
global.rotateZ(angle);
global.matMul(parentJoint.getInverseBindPose());
currentPose.getLocal(17).setTo(global);
currentPose.updateTransforms();
skeletonDebugger.update(currentPose);
modello.applySkeletonPose();
modello.applyAnimation();
}
and
public void onDrawFrame(GL10 gl)
{
if (frameBuffer == null)
return;
frameBuffer.clear(back); //ripulisco il frameBuffer e lo setto con il colore di sfondo voluto
world.renderScene(frameBuffer);
world.draw(frameBuffer);
frameBuffer.display();
}
I want to rotate the left arm, that in skeleton xml file is :
<bone id="17" name="Vincent L UpperArm">
I run the application and the left foot rotated and not the arm... do you know what did I do wrong ?
I think that the ids present in skeleton.xml file are wrong. I think, because I have tried to move the left arm and it has moved but in wrong way -.-"
I try to move the model's Left Thigh and the result is :
(http://imagizer.imageshack.us/v2/280x200q90/902/WImtAY.png) (http://imageshack.com/f/p2WImtAYp)
>:(
The code that I have used is :
protected void rotazionebraccio()
{
Logger.log("rotazionebraccio");
final Joint LUpperArm = currentPose.getSkeleton().getJoint(3);
final Joint parentJoint = currentPose.getSkeleton().getJoint(LUpperArm.getParentIndex());
final Matrix global= new Matrix(LUpperArm.getBindPose());
float angle=(float)Math.toRadians(-90);
global.rotateX(angle);
global.matMul(parentJoint.getInverseBindPose());
currentPose.getLocal(3).setTo(global);
currentPose.updateTransforms();
skeletonDebugger.update(currentPose);
modello.applySkeletonPose();
modello.applyAnimation();
}
I have committed an error in the code or maybe is ogre's exporter fault ?
EDIT :now I have replaced in code but the right thigh has moved .. I take the id from this file :
<bone id="2" name="Vincent Spine">
<position x="4.90153" y="5.88984e-006" z="-0.624106"/>
<rotation angle="0">
<axis x="-0.82569" y="-0.0201387" z="0.563765"/>
</rotation>
</bone>
<bone id="3" name="Vincent L Thigh">
<position x="-4.90153" y="3.78952" z="0.624106"/>
<rotation angle="3.14159">
<axis x="0.0181571" y="1.91597e-007" z="0.999835"/>
</rotation>
</bone>
<bone id="4" name="Vincent L Calf">
<position x="18.4395" y="0" z="-1.19209e-007"/>
<rotation angle="0.00851348">
<axis x="-3.32428e-012" y="1" z="-4.37102e-008"/>
</rotation>
</bone>
<bone id="5" name="Vincent L Foot">
<position x="13.4731" y="0" z="-1.19209e-007"/>
<rotation angle="0.0277679">
<axis x="-2.55262e-005" y="1" z="-7.32838e-006"/>
</rotation>
</bone>
Did I do wrong ? :(
I hope you can help me :D
the index of joints in skeleton.xml file is not related to id's in Bones. indeed joints in Bones has no id's but zero based indices. such that first joint in skeleton is at index zero, the second one is at index one, and so on. the ordering may be totally different from skeleton.xml file.
but assuming joint names are unique, you can retrieve a joint by its name:
Skeleton.findJointByName(jointName)
once a joint is found you can later retrieve it by its index.
btw, i will suggest you making yout trials at desktop jPCT not on Android. it will be much easier to do so. and using Bones' samples as a starting point may also save you some time.
Quote from: raft on September 11, 2014, 11:04:39 AM
the index of joints in skeleton.xml file is not related to id's in Bones. indeed joints in Bones has no id's but zero based indices. such that first joint in skeleton is at index zero, the second one is at index one, and so on. the ordering may be totally different from skeleton.xml file.
but assuming joint names are unique, you can retrieve a joint by its name:
Skeleton.findJointByName(jointName)
once a joint is found you can later retrieve it by its index.
Thank you a lot !!!!!!!!!!!!!!!!!!!!!1 ;D
Quote from: raft on September 11, 2014, 11:04:39 AM
the ordering may be totally different from skeleton.xml file.
this is worth mentioning, the joints are ordered such that, parent of a joint always comes before the joint itself.
yes yes I had supposed this :D
ooooh :D
I have two last aspect to improve :
- camera : to handle smartphone rotate, zoom and pan
- undestand if we can to edit bone's weight
:)
Quote from: aeroxr1 on September 12, 2014, 11:05:45 PM
- undestand if we can to edit bone's weight
i guess you cannot do that at the moment without changing Bones's source code
ah ok :)
@AGP :
do you know why we do this ?
mulMatrixByInverse(getJoint(joint.getParentIndex()), bind);
pose.getLocal(getJointIndex(joint)).setTo(bind);
Author of skeletonhelper doesn't remember why he use this function XD
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 (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 :/
changing FOV for zoom is like looking through a telescope. you see a narrow region zoomed.
for landscape, you can try different FOV values
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 :/
i havent done it myself. did you have a look at AbstractSkinSample.autoAdjustCamera method?
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 ? :)
i guess not. jPCT does not draw wireframe per object, it draws the whole scene or none.
buy you can try a hybrid solution, render two worlds on top of each other, one wireframe and contains only the ghost, over the other original world. or you can try giving similar effect with a special texture.
Is there a rapid way to add the same model but with a different physical appearance ? (without using 3d graphics programs) ;D
apply a fancy effect to texture in a simple image editor program ;)
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 >:(
loading them in surfaceCreated or surfaceChanged methods doesnt help?
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 ?
not sure, it seems ok
thanks you for your time :)