I did a little bit of work on the object animation feature today. Objects (resp. Spatials) are animated using the same keyframes text as morph target animation, which in my opinion allows for greater flexibility, because the artist won’t have to care about which ways of animating objects in blender will produce what kind of movement in jme (blender’s IPOs, for example, are a feature no game engine I know of has an equivalent for).
Unfortunately, this will delay Object hierarchy exporting, because I haven’t yet found an appealing way to spare the parent’s transformation from what gets applied to the child Spatial. One solution I am thinking of is to
get the world space transform for my Object
and
walk up the hierarchy tree, inverse applying all parent’s transformations along the way…
Can anybody tell me if I am roughly on the right way, or if there might be a simpler solution to this?
I wish I could help. I don’t really know blender’s format too well. If you want to move a child and parent seperatly, maybe they should be siblings instead of children?
Thanks, Cep, for offering your help once again. The point of my planned hierarchy exporter is to maintain the object hierarchy assigned in blender. Let me clarify: I get the Object’s (Blender’s equivalent to jME’s Spatial) world transform from blender, which has all parent’s transforms already applied. Now, if I would just parent the resulting jME Node to it’s old parent’s again, their transforms would be applied once more. Which I don’t want. Right now, a simpler approach than the one stated above comes to my mind, however: I just have to inverse apply the direct parent’s world transform, instead of walking up the entire hierarchy. I’ll try that, first.
So lets say you have two nodes A and B with world transform matrix AWorld and BWorld. A is suppose to be the parent of B. What you really want is the local transforms for A and B, called Alocal and Blocal.
AWorld = ALocal * Identity = ALocal (beacuse A is the parent)
Now the only problem is to calculate [InverseOfAWorld]. If you set the matrix up as a 4x4 translation/rotation/scale matrix, you could calculate that with some matrix math. I haven’t looked, but I bet there’s tons of formulas for matrix inversions on google.
I was trying to use this but it doesn’t seem to be working for me, when I choose JME exporter from the scripts list it returns instantly, no errors or any kind of indication of anything happening, I couldn’t find any files either. I don’t know python and I’m not that familiar with blender but shouldn’t something visible have occured (looking at the py file it looks like maybe a file dialog should come up or something). If this is normal, where did the files go?
OK, I figured it out… my window with the script buttons in it wasn’t big enough so I didn’t see the buttons… man the blender interface is weird (I really hate the lack of windows style dialogs too).
Hi there, I’m quite new to JME so, please, be patient
I have exported a cube from blender to make the xml file. Into my code I have put this:
XMLDecoder d = new XMLDecoder(
new BufferedInputStream(
new FileInputStream("scene.xml")));
Object result = d.readObject();
d.close();
rootNode = (Node)result;
but when I run it I got a huge output of errors loading the data...
can you please post the stack trace. If its either a URL malformed exception, or a Nullpointer refering to your FileInputStream, then it can’t find the file…
err… I saw that there is a chapter about model loading in Starter.pdf. I think I’ve found the “solution”: I need to export from xml to .jme and follow what the example code does…
Yep, I’ve tried both with .xml and .jme but my knowledge about IO in Java is quite bad and I don’t understand how to open the .jme
I imagine the algo, in pseudo-code should be something like:
JmeBinaryReader jbr= new JmeBinaryReader();
Node ciccio=jbr.loadBinaryFormat( pointer to .jme file );
but I don’t knoe how to point to the .jme file… I’m confused about InputStream, FileInputStream, BufferedInputStream and all of the other 1000 classes to read a file :?
public class Rttd extends SimpleGame {
public static void main(String[] args) {
Rttd app = new Rttd();
app.setDialogBehaviour(SimpleGame.ALWAYS_SHOW_PROPS_DIALOG);
app.start();
}
protected void simpleInitGame() {
Node model = null;
JmeBinaryReader jbr = new JmeBinaryReader();
try {
URL modelURL= Rttd.class.getClassLoader().getResource("c:\rttd\cube.jme");
model = jbr.loadBinaryFormat(modelURL.openStream());
jbr.setProperty("bound", "box");
} catch(Exception e) {
System.out.println("Model could not be loaded:" +
e.getMessage());
}
rootNode.attachChild(model);
}
}
it compares a black window without the usual information about FPS, number of vertex, ecc...
and this output into the shell:
[darko]#>java -cp c:lwjgljme.jar;c:lwjgllwjgl.jar;. -Djava.library.path=c:l
wjgl Rttd
13-mag-2005 10.53.35 com.jme.app.BaseGame start
INFO: Application started.
13-mag-2005 10.53.35 com.jme.system.PropertiesIO <init>
INFO: PropertiesIO created
13-mag-2005 10.53.35 com.jme.system.PropertiesIO load
INFO: Read properties
13-mag-2005 10.54.01 com.jme.system.lwjgl.LWJGLDisplaySystem <init>
INFO: LWJGL Display System created.
13-mag-2005 10.54.02 com.jme.system.PropertiesIO save
INFO: Saved properties
13-mag-2005 10.54.02 com.jme.system.lwjgl.LWJGLDisplaySystem <init>
INFO: LWJGL Display System created.
13-mag-2005 10.54.07 com.jme.renderer.lwjgl.LWJGLRenderer <init>
INFO: LWJGLRenderer created. W: 640H: 480
13-mag-2005 10.54.07 com.jme.renderer.AbstractCamera <init>
INFO: Camera created.
13-mag-2005 10.54.12 com.jme.util.lwjgl.LWJGLTimer <init>
INFO: Timer resolution: 3579545 ticks per second
13-mag-2005 10.54.13 com.jme.scene.Node <init>
INFO: Node created.
13-mag-2005 10.54.42 com.jme.scene.Node <init>
INFO: Node created.
13-mag-2005 10.54.42 com.jme.scene.Node attachChild
INFO: Child (FPS label) attached to this node (FPS node)
Model could not be loaded:null
(Naturally those file are, respectivelly, in xml and jme format.
But the output is always the same:
....
13-mag-2005 11.53.54 com.jme.scene.Node attachChild
INFO: Child (FPS label) attached to this node (FPS node)
Model could not be loaded:null
13-mag-2005 11.53.56 com.jme.app.SimpleGame cleanup
INFO: Cleaning up resources.
13-mag-2005 11.53.56 com.jme.app.BaseGame start
INFO: Application ending.
INFO: Node created.
Model could not be loaded:3772338
13-mag-2005 15.10.20 com.jme.app.SimpleGame cleanup
INFO: Cleaning up resources.
13-mag-2005 15.10.20 com.jme.app.BaseGame start
INFO: Application ending.
Then I've tried to export a simple cube in obj format. This time it works, but it doesn't load the material and the cube from the JME window is terrifying.. it seems like some faces are missing, even if I've put all normals out. may the exporter of blender 2.26 don't work very well?
I’ve exported in obj format and yessss… now it works. guess what was the matter?? As usually I never set the Mir color (never needed to change it from 0xFFFFFF). I’ve noticed that importing the Maggie model of the example loading class… uff… well… I’m happy now
I would make a sticky thread for this… to avoid others this pain.