My ES in contrib: Zay-ES

@mifth said: I mean the ES which all Engines have. I would like to have an ES with the engine and with SDK. Just like in all other pro engines. I don't want to write my own ES. I just want to Open SDK and write a game just like in Unity/Unreal. Without digging into complex things. But it seems there will be never the official ES, as was mentioned by core devs.

In my humble opinion… the engine becomes less casual… and less people get involved into the JME… and they prefer to take the SDK with all tools… like Unity…
I don’t want to hurt anyone… i just said my opinion.

/facepalm

Seriously? You can only compare jME since v3 to Unity at all. And I think you haven’t used UDK or Unity yet else you wouldn’t talk as if they were silver bullets. Also what do you mean less people get involved? I see more people getting to make games instead of trying to fix the engine or rewrite some library of it.

Well that could very well be a community supported plugin. But there can be several…so no official ES.

1 Like
@normen said: /facepalm

Seriously? You can only compare jME since v3 to Unity at all. And I think you haven’t used UDK or Unity yet else you wouldn’t talk as if they were silver bullets. Also what do you mean less people get involved? I see more people getting to make games instead of trying to fix the engine or rewrite some library of it.

I played both. And they have much more indie projects… Only in Russia i saw about 200 indie projects (desktop/mobile) developed on Unity… on vk.com… And i don’t talk abot the world… So, no comparison yet.

Yeah, it will be cool to have ES plugin as was mentioned above… I hope the future will become soon. :slight_smile:

@mifth said: I played both. And they have much more indie projects... Only in Russia i saw about 200 indie projects (desktop/mobile) developed on Unity... on vk.com... And i don't talk abot the world... So, no comparison yet.

Yeah, it will be cool to have ES plugin as was mentioned above… I hope the future will become soon. :slight_smile:

Dude, you are the one who did the comparison and now you even compare the success of a commercially advertised engine vs jME :roll:

And also what do you mean “you played both” I never saw you announce any game in any engine yet. You also seemingly didn’t use jME2 where you had to spend 2 months of research to even run anything, not to speak of getting a UI or physics or animations in. The complaints about e.g. Nifty, asset import and “missing features” that “need to be in the engine” are bloody first world problems, really.

Ive used Irrlicht, Ogre, UDK, Mogre and JME. And for me JME is by far the best. Yeah UDK is great if you want to make
“the next FPS shooter” but when you want something more, things get complicated really fast. Irrlicht and Ogre are solid
engines, but I cant stand to use C/C++ anymore - just so much utility coding. And with Mogre you’re always at least one
step behind the Ogre releases, not all features are supported, strange and hard to locate exceptions, …

JME is just fun - nearly everything is working with the first try and even when there are problems, they are really easy to
locate/provide a fix (I mean in comparison with the above technologies). Of course there are some features missing, but
nothing essential(at least for me) and it just feels so efficient because you can really concentrate on the game.

I am using ruby for my content, so the Zay-ES contribution is of no real use for me. Nevertheless I think its a great
contribution!

Btw - sorry for a little bit of thread-hijacking xD

3 Likes
@normen said: Dude, you are the one who did the comparison and now you even compare the success of a commercially advertised engine vs jME :roll:

And also what do you mean “you played both” I never saw you announce any game in any engine yet. You also seemingly didn’t use jME2 where you had to spend 2 months of research to even run anything, not to speak of getting a UI or physics or animations in. The complaints about e.g. Nifty, asset import and “missing features” that “need to be in the engine” are bloody first world problems, really.

I tried them… i meant. :slight_smile:
JME is my prefered engine too. That’s why no Unity./Unreal in my life. :slight_smile:

3 Likes

Hi @pspeed

I am implementing a little test game using Zay-ES, I created an AppState for entity loading and two Controls, first one for Animation and second for player movement with BetterCharacterControl. All is working fine, but i have a doubts. In my PlayerControl i have player entity and EntitySet i query player Entity to set a Move component but i can’t clear via Entity, just using EntityData. I don’t understand why is necessary another reference to EntityData if DefaultEntity returned by EntitySet already has internally. May be my design isn’t right? Follow the code from my current PlayerControl update.

[java]
Entity e = this.entitySet.getEntity(this.entityId);

            Vector3f modelForwardDir = getSpatial().getWorldRotation().mult(Vector3f.UNIT_Z);

            walkDirection.set(0, 0, 0);
            viewDirection.set(modelForwardDir.normalize().clone());
            
            if (forward) {
                walkDirection.addLocal(modelForwardDir.mult(8));
            } else if (backward) {
                walkDirection.addLocal(modelForwardDir.negate().multLocal(8));
            }

            playerControl.setWalkDirection(walkDirection);

            // ViewDirection is local to characters physics system!
            // The final world rotation depends on the gravity and on the state of
            // setApplyPhysicsLocal()
            if (turnLeft) {
                Quaternion rotateL = new Quaternion().fromAngleAxis(FastMath.PI * tpf, Vector3f.UNIT_Y);
                rotateL.multLocal(viewDirection);
            } else if (turnRight) {
                Quaternion rotateR = new Quaternion().fromAngleAxis(-FastMath.PI * tpf, Vector3f.UNIT_Y);
                rotateR.multLocal(viewDirection);
            }
            playerControl.setViewDirection(viewDirection);
            
            e.set(new Movement(walkDirection.getX(),walkDirection.getY(),walkDirection.getZ(),viewDirection.getX(),viewDirection.getY(),viewDirection.getZ()));
            e.set(new Position(getSpatial().getWorldTranslation().getX(),getSpatial().getWorldTranslation().getY(),getSpatial().getWorldTranslation().getZ()));
            [/java] 

Here my code from my AnimationControl

[java]
Entity e = this.entitySet.getEntity(this.entityId);
Movement mov = e.get(Movement.class);
String animationName = “Idle”;
int i = 0;

        if (mov.IsMoving()) {
            animationName = "Run";
        }

        if (this.currentAnimations.contains(animationName)) {
            return;
        }

        if(this.animControl == null){
            this.animControl = this.getSpatial().getControl(AnimControl.class);
        }
        
        this.animControl.clearChannels(); // checck possible cleanup of unused channels
        this.currentAnimations.clear();

        List<Pair> anis = this.animations.get(animationName);
        while (i < anis.size()) {
            if ((animControl.getNumChannels() < anis.size())) {
                animControl.createChannel();
            }

            Pair ani = anis.get(i);
            animControl.getChannel(i).setAnim(ani.first);
            animControl.getChannel(i).setLoopMode(ani.second);
            i++;
        }

        this.currentAnimations.add(animationName);

[/java]

@drr00t said: Hi @pspeed

I am implementing a little test game using Zay-ES, I created an AppState for entity loading and two Controls, first one for Animation and second for player movement with BetterCharacterControl. All is working fine, but i have a doubts. In my PlayerControl i have player entity and EntitySet i query player Entity to set a Move component but i can’t clear via Entity, just using EntityData. I don’t understand why is necessary another reference to EntityData if DefaultEntity returned by EntitySet already has internally. May be my design isn’t right? Follow the code from my current PlayerControl update.

"but i can’t clear via Entity, just using EntityData. "
…I didn’t see this in the code posted so maybe I missed it.

Anyway, conceptually, an Entity is a view of a subset of an entity’s components. You can’t remove a component because then it wouldn’t be that view anymore. The view is defined by the component types.

@pspeed said: Heheh. That's ok. I've been wrapped around day-job related fires anyway.

I do plan a few more changes. I’m going to move the filters to their own package and then add a Filters utility interface (Guava style) to make it easier to create filters and compose them.

I think for most users it is hard enough for them to understand what is going on with app states and threading. However, for people like you who understand it then that can be a pretty powerful idiom.

In my case, the entity processors were like Runnables that could be run in a worker pool. Since the ES is multithreaded then there was no problem letting things run in a pool. But it occurs to me that this thing is better split out into its own class and could potentially get some other things built in to manage various types of concurrent processing in an abstract way. I have a few articles I’ve read recently that are still bubbling in my head regarding this so it’s better to remove it and come back at it again when I need it.

I’ve removed the EntityProcessor stuff. I will bring it back in a different form later if at all. My new Mythruna engine doesn’t use it yet and may not ever… we’ll see.

I also removed TransientComponent since it’s name is odd without context and there are no classes implementing networking anyway… so no reason to have it around in the core stuff.

And finally, I moved all of the filters to a separate package. The API-level now has just ComponentFilter (the interface) and a new Filters class with utility methods for creating the different filters (Guava style). This insulates the call from future design changes and if a game’s filter chains ever get complicated then they can more easily static-import the methods directly and do things like:
[java]
or( Foo.class, fieldEquals( Foo.class, “bar”, “Baz” ),
fieldEquals( Foo.class, “bar”, "Bing ) );
[/java]
…without a lot of boilerplate.

Those are all of the public-facing/API changes that are on my personal to-do list until I hear further suggestions. I think most changes now will be in implementations, though.

First of all, thanks for sharing this. I went trough the code today. Just one question since i did not find any implementations.

Can the system handle something like:
[java]
public class Inventory implements EntityComponent, PersistentComponent{
HashMap (EntityId,Integer) inventoryContent;
}
[/java]

Or how would you implement an invetory with the entity system

@zzuegg said: First of all, thanks for sharing this. I went trough the code today. Just one question since i did not find any implementations.

Can the system handle something like:
[java]
public class Inventory implements EntityComponent, PersistentComponent{
HashMap (EntityId,Integer) inventoryContent;
}
[/java]

Or how would you implement an invetory with the entity system

No, it won’t handle that… because as you’ve suspected it isn’t the proper way to do it.

Go the other way… you’d have an InInventory component that points to the parent. You put one on the entities that are in another entity’s inventory.

1 Like

I perfectly understand that, i hoped that i can add some kind of ‘Prototype Entity’ to multiple inventories.

@pspeed:

Are the EntitySets limiting access to other Components than the spezified?
For example:

[java]
EntitySet entities = entityPool.getEntities(Class1.class, Class2.class);
for(Entity e:entities){
entityPool.setComponent(e.getId(),new Class3());
}
entitied.applyChanges();
for(Entity e:entities){
System.out.println(e.get(Class3.class)); // returns null
}
[/java]

@zzuegg said: @pspeed:

Are the EntitySets limiting access to other Components than the spezified?
For example:

[java]
EntitySet entities = entityPool.getEntities(Class1.class, Class2.class);
for(Entity e:entities){
entityPool.setComponent(e.getId(),new Class3());
}
entitied.applyChanges();
for(Entity e:entities){
System.out.println(e.get(Class3.class)); // returns null
}
[/java]

Yes. As a convenience, I allow setting components that are not in the Entity but you can only get what was queried. Kind of like a JDBC result set.

If you want to get components not in the original query then you can go directly to EntityData and just ask for them.

There is a reason for this. When you query an EntitySet then you are asking for a snapshot in time. The values in that snapshot only update when you refresh the EntitySet. If you were able to pull other components directly from the entity then they might be inconsistent with the view the entity represents. I felt it was best to make you go back to EntityData in this case so that you are fully aware you are querying live data instead of the snapshot. It will also catch accidental bugs caused by changing your EntitySet components later but still asking for a component you used to query for.

2 Likes

Ah, i understand. If i only would have known/tested this a few hours ago :frowning:
All perfect again.

@zzuegg said: Ah, i understand. If i only would have known/tested this a few hours ago :( All perfect again.

It would probably help if I wrote some documentation… any documentation, really. :slight_smile:

Mah, i looks realy straightforward. Maybe a short paragraph with the do’s and don’t would be enought.

Once i figured out a nice way to implement n:m relationships i can switch over to this system.

I really like the workflow. I have made a reflection based guibuilder to edit components. No more building basic gui building :slight_smile:
Just writing annotated pojo’s

@pspeed, a cool extension would be to pass the owing entity in the ComponentFilter.evaluate() method. It would allow filters such as:

[java]
EntityInCollectionFilter(Collection(Entity),SomeAdditionalComponents);
[/java]

I have already implemented it in my local copy, since you know the design of the ES better i wanted to ask you if some concurrency thing speaks against this

@zzuegg said: @pspeed, a cool extension would be to pass the owing entity in the ComponentFilter.evaluate() method. It would allow filters such as:

[java]
EntityInCollectionFilter(Collection(Entity),SomeAdditionalComponents);
[/java]

I have already implemented it in my local copy, since you know the design of the ES better i wanted to ask you if some concurrency thing speaks against this

Well, they are component filters and not entity filters.

What is your use-case? Maybe there is a different way to handle the meta-problem.

I want to keep track of all owners of an item. As said previously i am kind of bound to n:m relationships and this addition allows easy implementation of such queries.
For this i have created a component
[java]
class Owern{
EntityId item;
EntityId owern;

Date since;
}
[/java]

Then i can use:
[java]
EntitId someItem= some entitiy
//returns all entities with component UserInformation.class related trough Entities with Ower.class component.
EntitySet history = Database.findRelated(someItem,Owern.class,UserInformation.class);
history = All historical owerns of the item
[/java]

And it works also the other way:
[java]
EntitId user= some entitiy
//returns all entities with component Armor.class related trough Entities with Ower.class component.
EntitySet history = Database.findRelated(user,Owern.class,Armor.class);
history=All armors which ‘user’ ever had.
[/java]