Programming & Scripting

View unanswered posts | View active topics


Post a new topicPost a reply
Previous topic | Next topic 

  Beginner BeginnerMember since: 24.03.2012, 00:08Posts: 2 Likes: 0
 

 Post Topic: How to handle Entities by data from external source
PostPosted 08.04.2012, 21:50 
Hi all,

I have a problem with programming in CryEngine3.
I want to create game depending on data from external source.
I have channel with external data (TCP server/client or File IO /it doesn't matter/).

Assume that, we have 2 types of objects. Sphere and cube.
Goal is to programmaticly create and place 3D object (sphere or cube) in CryEngine level by data from external source.

Data in external source are:
- type of object (sphere or cube)
- ID of object (unique. By this ID will be updated place of new/existing object in level)
- coordination (x,y,z)

My questions:

1. Where is good place to create reader of external data? How can i create it?
- in my opinion good place to create reader could be "IGameRef CGameStartup::Init(SSystemInitParams &startupParams)". What do you think?
- maybe creating this reader as CryExtension could be good solution http://freesdk.crydev.net/display/SDKDOC4/CryExtension
2. How can I create new instance of 3D object?
- i tried create new object by http://freesdk.crydev.net/display/SDKDO ... tity+Class . But I don't know how/where (in code) create new instance of my EntityClass.
4. How can I place new Entity in level?
- I tried place entity by my own coordinates as it is implemented in CAnimatedCharacterSample in method UpdateMovement(). But I don't know syntax of placing object on new position. In sample is showed only moving in some direction (it is not useful for me).
- I think that in this method "UpdateMovement()" could be good place for getting Reader extension. My Reader extension could provide new coordinates of this Entity.
5. Does exist some reference guide of CryEngine source codes?

Let me now if you have some answer only for part of my questions.
Thank you.

User avatar   Crytek Staff Member Crytek Staff MemberMember since: 11.07.2008, 20:25Posts: 11637Location: Frankfurt am MainStatus: Online Likes: 10
 

 Post Topic: Re: How to handle Entities by data from external source
PostPosted 09.04.2012, 02:29 
To spawn an entity:
Code:
gEnv->pEntitySystem->SpawnEntity(SEntitySpawnParams params, bool autoInit)

See this thread for an example: viewtopic.php?f=314&t=83037


Anti-flowgraph campaigner, professional server destroyer.
  Trainee TraineeMember since: 03.09.2011, 02:57Posts: 119Location: Chapel Hill, North Carolina Likes: 0
 

 Post Topic: Re: How to handle Entities by data from external source
PostPosted 11.04.2012, 01:29 
I am doing roughly the same thing, including data over a network (from a VRPN server, specifically).

The thread pointed out by Cry-Ruan is roughly how I generate new entities.

For moving entities, I have a separate manager class that checks for new data and updates the position of my entities. You can use entity->setPos() and entity->setRotation() to set the properties you want.

I am not sure of the best place/time to update the external reader, since putting it in the wrong place seems to cause frame synchronization issues. Right now I am just handling in the CGame::OnPostUpdate method. Suggestions on this would be appreciated.

I'm not sure it matters where you put your external reader (I'm using CGame::init for now), but one of the issues I discovered was resetting everything when you reload a level.

Creating a new subclass of IEntity that checks for the external data itself, rather then a controller class moving it, would probably be a better solution, but I have not had time to try that yet.


Graduate student at the UNC-Chapel Hill Department of Computer Science. All views expressed are my own.
User avatar   Trainee TraineeMember since: 27.10.2008, 12:02Posts: 155Location: CHINA Likes: 0
 

 Post Topic: Re: How to handle Entities by data from external source
PostPosted 24.04.2012, 05:44 
Thx kwaegel, I will glad to see everything about transfer of external data. :cheesy: