New MilkShape loader feedback

I’m currently swapping over to use the new jar with the MilkShape Animation loader & am having problems with the static stuff I already have. The following is an example from my code:




       e3 = new Entity(3);
       MilkshapeModel ms1 = new MilkshapeModel(false);
       ms1.load("box1.ms3d");
       //ms1.setScale(new Vector(0.15F, 0.15F, 0.15F));
       ms1.setColor(0.0F, 0.0F, 1.0F, 0.5F);
       e3.setGeometry(ms1);
                    e3.setPosition(new Vector(700, rhm.getScaledHeightAtPoint(350, 350), 700) );
       world.addEntity(e3);



this will not work & generates the following errors:


TestApp34.java:386: cannot resolve symbol
symbol : method setColor (float,float,float,float)
location: class jme.geometry.model.ms.MilkshapeModel
ms1.setColor(0.0F, 0.0F, 1.0F, 0.5F);
^
TestApp34.java:387: setGeometry(jme.geometry.Geometry) in jme.entity.Entity cann
ot be applied to (jme.geometry.model.ms.MilkshapeModel)
e3.setGeometry(ms1);
^


I've looked in the javadocs & the setColor() method seems to have disappeared from the MilkShape class.

When I comment out the setColor() call the compiler still throws the error for setGeometry() which is in the Entity class.

I've checked my import statements.

Any ideas what I'm doing wrong?

:?

You’re absolutely right. I fixed that in CVS but forgot to generate the new jar. Generating right now…



ok, it’s updated. This is the latest jar, so you’ll have your getVersion method in the DisplaySystem class as well.

Thanks I thought I was going a bit mad.



:slight_smile:

Thanks for the new jar.



I’ve got it to compile, but I can’t see my static MilkShape objects (I haven’t tried the animated ones yet).



Below is an example of the code:




      e3 = new Entity(3);
       MilkshapeModel ms1 = new MilkshapeModel("box1.ms3d");
      ms1.setColor(0.0F, 0.0F, 1.0F, 0.5F);
      e3.setGeometry(ms1);
      e3.setPosition(new Vector(700, rhm.getScaledHeightAtPoint(350, 350), 700) );
      world.addEntity(e3);



As I said it compiles but I can't see anything, this code did work with the old MilkShapeModel class.

The only thing I can think of is I haven't used setScale(), but my object is pretty big & I assume the default is 1.0f, 1.0f, 1.0f?

The new Milkshape Model loader is an ASCII model loader. No longer loads ms3d files. This means you need to export your models to ASCII: File → Export → Milkshape 3D ASCII.



I will alter the loader to accept the MS3D file format soon.

That’s OK. I’ve got Milkshape so it won’t be a problem.





Thanks.

The concept for Geometry in jME is that it has no concept of position, all vertices that make up a piece of geometry are based around (0,0,0) of it’s local coordinate system. So, to move that coordinate system, you need to attach the geometry to an entity.


MilkshapeModel model = new MilkshapeModel("my/object.txt", true);
Entity e = new Entity(id); //id is a unique number to identify this entiy.
e.setPosition(new Vector(0.0f,10.0f,0.0f); //10 units in the air
e.setGeometry(model); //the Geometry object previously made



See the threads regarding entitys.
"mojomonk" wrote:
The concept for Geometry in jME is that it has no concept of position, all vertices that make up a piece of geometry are based around (0,0,0) of it's local coordinate system. So, to move that coordinate system, you need to attach the geometry to an entity.

that's cool... one of these days i am going to start playing with jme :)

actually i like writing frameworks... is there a list of to-dos or wish-i-had-ems planned for jme? i'm not sure what i can contribute right now, but i may need a break from my current projects and feel like coding something else for a bit.
is there a list of to-dos or wish-i-had-ems planned for jme?


There are TONS of to-dos and wish lists for jme. If jME where a human, it'd still be trying to crawl. I have a pretty open policy as well, if there is something you'd think we be cool in it and it fits nicely, by all means hack away.

My personal goals for the short term are getting a scenegraph and collision detection system going. It's slow for me, because I'm learning as I'm going. Some complex math involved.

But after that, I have all sorts of pipe dreams. AI, Physics, Networking you name it heheh.
Mojomonkey wrote



MilkshapeModel model = new MilkshapeModel("my/object.txt", true);
Entity e = new Entity(id); //id is a unique number to identify this entiy.
e.setPosition(new Vector(0.0f,10.0f,0.0f); //10 units in the air
e.setGeometry(model); //the Geometry object previously made 



Not sure if this is correct. MilkshapeModel implements Model instead of Geometry so you can not pass it as Geometry to Entity. You need to write a wrapper class and implement Geomtery for your model. Furthermore to see the animation you need to call the update method and tell it how after many frames you need to update the model.

Apart from this, it works. ;)
tomcat

Hmmm it should work as Model extends Geometry. So you should be able to pass a model into the entity the same as anything else. I’ll look into it soon to make sure it works that way, and if it doesn’t fix it. You can do it that way now with MD3 models.



during the update phase you should call update(time) on the entity itself. The entity will then update anything it needs to (models, physics, etc). Usually, it’s best just to remember to call update on the highest level object. So, when you start adding the entities to the world, all you call is world.update(time) which will update the entities which will update the model.



I’ll look into adding MilkshapeModels and make sure that works correctly.

Ok, just realized. Model extends Geometry in the CVS but not in the jar. I thought I got that fixed before creating the jar, but I guess not. Oops. Next release will have that fixed.

No worries :slight_smile: , Can I add a boundingVolume to the new MilkshapeModel or is it hardcoded in the class?



I like to do more tests with collision detection and the model and like to know if I got to add a BoundingVolume for the model.



tomcat

You now add BoundingVolumes to entities themselves. I believe the hooks are in the jar, but now I’m not so sure. One thing that I do know is there are some broken ones in the jar. I have fixed all the bounding volumes and that’s in CVS. I’ll get a new jar up this week. I was hoping to hold off until I got the distances done, but that will have to wait.



So what you will have is the following:


MilkshapeModel model = new MilkshapeModel("model.txt", true);
Entity e = new Entity(1);
BoundingSphere sphere = new BoundingSphere();
sphere.containAABB(model.getPoints());
e.addGeometry(model);
e.addBoundingVolume(sphere);



the distance and hasCollision methods are not working yet however.

I'll get the new jar up tomorrow.[/code]

thanks, for this. I’ll try it later tonight. It would be great when updating the jar, you increment the version number.

tomcat.

t would be great when updating the jar, you increment the version number.


Will do.

New jar is up. Version 0.1.1