dtEntityNet

15 views
Skip to first unread message

Julien Ryard (ENSAM)

unread,
Oct 22, 2012, 8:26:44 AM10/22/12
to dtenti...@googlegroups.com
Hi.

I use dtEntity in a multi threaded application.

I want to use dtEntityNet in order to synchronize my entities positions and orientation.
But I have 2 problems :

- I use the FPW DeadReckoningAlgorithm , and when I have a rotation with an angle negative, messages are'nt sended.
The problem is when we check the max deviation, we only check for positive angle.

- For my second problem, I want to spawn entities from script. But when we spawn our entity, a message is sended with the EntityType and UniqueId. And those values could not be setted in script, and could not be setted in the editor too. The problem is that only DeadReckoningAlgorithm is a property dynamic.

Thanks
Julien.

Martin Scheffler

unread,
Oct 23, 2012, 9:06:35 AM10/23/12
to dtenti...@googlegroups.com
Hi Julien!


2012/10/22 Julien Ryard (ENSAM) <julien...@ensam.eu>:
> Hi.
>
> I use dtEntity in a multi threaded application.
>
> I want to use dtEntityNet in order to synchronize my entities positions and
> orientation.
> But I have 2 problems :
>
> - I use the FPW DeadReckoningAlgorithm , and when I have a rotation with an
> angle negative, messages are'nt sended.
> The problem is when we check the max deviation, we only check for positive
> angle.
OK, this is certainly possible. I barely got the dtEntityNet stuff
running, it is not really tested through yet. I just posted a fix to
SVN that may or may not fix your issue. You are also welcome to poke
around the source for bugs - especially the rotation handling is a bit
dodgy. One thing I will definitely have to change at some point: the
angular velocity is stored in the dynamics component as a quaternion.
This seems to be a bad idea as quaternions are not good for storing
that, I will have to change to HPR values at some point.


>
> - For my second problem, I want to spawn entities from script. But when we
> spawn our entity, a message is sended with the EntityType and UniqueId. And
> those values could not be setted in script, and could not be setted in the
> editor too. The problem is that only DeadReckoningAlgorithm is a property
> dynamic.

The JoinMessage is sent when you call MapSystem::AddToScene(entityid).
You can set the UniqueId and EntityType properties of the
DeadReckoningSenderComponent before adding the entity to the scene.

Cheers,
Martin

Julien Ryard (ENSAM)

unread,
Oct 23, 2012, 10:41:16 AM10/23/12
to dtenti...@googlegroups.com
Hi Martin,

-Thank you for update, that fix my rotation bug perfectly.
And for changing quaternion to HPR for velocity will be clearer.

-For my second problem, I want to allow a user to spawn an entity from script.

For example spawning an entity bu triggering a button. When my button is triggered, I do this (In script):

var mapSystem = EntityManager.getEntitySystem("Map");
entityIdSpawned = EntityManager.createEntity();
mapSystem.spawn("spawnerName",entityIdSpawned);
EntityManager.addToScene(entityIdSpawned);

But if I only do that, the entityType is'nt setted. And I don't have access to the property if it is not dynamic. (Or is there a method to access to a property dynamicly in script only with his name like in c++ ? )

Maybe I could create a new component for spawning with options I need.

-I have an other problem I think.
in DeadReckoningReceiverSystem::OnJoin function
When we spawn, we always try to create receiver and dynamic component, and after we set a value of uniqueid for receiver. But when receiver is a component of spawner, we could not create it, and we try to set a null pointer. Maybe we should use a getOrCreate function, or put a simple check before.
And we never add our entity spawned to the scene, so we never see it.
I tested it on my side, and it works well. I can provide you my patch if you want.

Julien.

Martin Scheffler

unread,
Oct 23, 2012, 11:33:14 AM10/23/12
to dtenti...@googlegroups.com
2012/10/23 Julien Ryard (ENSAM) <julien...@ensam.eu>:
> Hi Martin,
>
> -Thank you for update, that fix my rotation bug perfectly.
> And for changing quaternion to HPR for velocity will be clearer.
>
> -For my second problem, I want to allow a user to spawn an entity from
> script.
>
> For example spawning an entity bu triggering a button. When my button is
> triggered, I do this (In script):
>
> var mapSystem = EntityManager.getEntitySystem("Map");
> entityIdSpawned = EntityManager.createEntity();
> mapSystem.spawn("spawnerName",entityIdSpawned);
> EntityManager.addToScene(entityIdSpawned);
>
> But if I only do that, the entityType is'nt setted. And I don't have access
> to the property if it is not dynamic. (Or is there a method to access to a
> property dynamicly in script only with his name like in c++ ? )
>
Hi,

you can simply do
EntityManager.getEntitySystem("Dynamics").getComponent(entityIdSpawned).EntityType
= "1 2 3 4 5 6 7";
Component properties are directly accessible as JavaScript properties.

>
> -I have an other problem I think.
> in DeadReckoningReceiverSystem::OnJoin function
> When we spawn, we always try to create receiver and dynamic component, and
> after we set a value of uniqueid for receiver. But when receiver is a
> component of spawner, we could not create it, and we try to set a null
> pointer. Maybe we should use a getOrCreate function, or put a simple check
> before.
> And we never add our entity spawned to the scene, so we never see it.
> I tested it on my side, and it works well. I can provide you my patch if you
> want.

Sure, please send full files, not patches. Submissions are always welcome!

Cheers,
Martin

Julien Ryard (ENSAM)

unread,
Oct 24, 2012, 3:37:51 AM10/24/12
to dtenti...@googlegroups.com

you can simply do
EntityManager.getEntitySystem("Dynamics").getComponent(entityIdSpawned).EntityType
= "1 2 3 4 5 6 7";
Component properties are directly accessible as JavaScript properties.

Ok, but if our propeties is'nt registered as dynamic, it won't be updated, is'nt it ?
For example, I want to do that :

EntityManager.getEntitySystem("DeadReckoningSender").getComponent(entityIdSpawned).EntityType = "nameOfSpawner";

But if in my class DeadReckoningSenderComponent, I don't register a DynamicStringProperty, with SetValueCB and GetValueCB functions, my values are'nt updated.


Sure, please send full files, not patches. Submissions are always welcome!

 
Ok, I attach a file with my update in order to avoid null pointer crash, and fixing adding to scene spawner problem.
deadreckoningreceivercomponent.cpp

Martin Scheffler

unread,
Oct 24, 2012, 3:54:10 AM10/24/12
to dtenti...@googlegroups.com
Hi Julien,
non-dynamic properties will be changed by JavaScript, too - you just
don't have a callback function that is called when it is changed.

2012/10/24 Julien Ryard (ENSAM) <julien...@ensam.eu>:
OK, just committed to svn.

Cheers,
Martin

Julien Ryard (ENSAM)

unread,
Oct 24, 2012, 5:23:15 AM10/24/12
to dtenti...@googlegroups.com
Hi,

non-dynamic properties will be changed by JavaScript, too - you just
don't have a callback function that is called when it is changed.

I try to access to the property via script :
 EntityManager.getEntitySystem("DeadReckoningSender").getComponent(entityIdSpawned).mEntityType = "spawnerName" ;
But my value isn't updated in my application.
Maybe because it is not a property but a simple string.
Maybe because it is a private value.

 
OK, just committed to svn.

 Perfect, thank you.

Julien.

Martin Scheffler

unread,
Oct 24, 2012, 5:42:41 AM10/24/12
to dtenti...@googlegroups.com
You have to use the SID the property is registered with in the
constructor of the message:

const dtEntity::StringId JoinMessage::EntityTypeId(dtEntity::SID("EntityType"));

JoinMessage::JoinMessage() : Message(TYPE)
{
Register(EntityTypeId, &mEntityType);
}

So try
EntityManager.getEntitySystem("DeadReckoningSender").getComponent(entityIdSpawned).EntityType

Cheers,
Martin


2012/10/24 Julien Ryard (ENSAM) <julien...@ensam.eu>:

Julien Ryard (ENSAM)

unread,
Oct 24, 2012, 6:36:41 AM10/24/12
to dtenti...@googlegroups.com

You have to use the SID the property is registered with in the
constructor of the message:

const dtEntity::StringId JoinMessage::EntityTypeId(dtEntity::SID("EntityType"));

JoinMessage::JoinMessage() : Message(TYPE)
 {
      Register(EntityTypeId, &mEntityType);
 }

So try
EntityManager.getEntitySystem("DeadReckoningSender").getComponent(entityIdSpawned).EntityType

I just try and it doesn't work.
The message is created in the  DeadReckoningSenderSystem::OnAddedToScene function, and we force the values like this :
msg.SetUniqueId(comp->GetUniqueId());
msg.SetEntityType(comp->GetEntityType());

And my comp->GetEntityType() is null. Cause the value mEntityType isn't registered like the mEntityType of the join message.

The only way I see, is to declare a dynamic property and attach callback, like for DeadReckoningAlgorithm property.
Cause I don't understand how the registering in the joinMessage constructor could impact my DeadReckoningSenderComponent.
Reply all
Reply to author
Forward
0 new messages