Programming & Scripting

View unanswered posts | View active topics


Post a new topicPost a reply
Previous topic | Next topic 

User avatar   Beginner BeginnerMember since: 20.01.2012, 17:29Posts: 32Location: Antwerp, Belgium Likes: 0
 

 Post Topic: Re: creating a new FlowNode with C++
PostPosted 22.04.2012, 17:49 
Hi Kimba,

I'm glad my documentation was useful for you.
OSC uses a specific kind of formatting for the messages you send (see http://opensoundcontrol.org/introduction-osc ) it looks a little like this:
/address/ ,f 10.9 (but "10.9" would be binary..)

The messages I'm sending are formatted much simpler. I do this because I want to have something that is working and stable first. Afterwards I can always add more complexity & parsing. It's also lazier :-)
This is how I commented the formatting in the message parser flownode:
Code:
/*
       the structure of the messages I'm sending over UDP is super simple:
       "x y z\n"
       example:
       "0.568 1.234 8.439\n"
       so the end of a message is always the newline character, the rest are floats separated by spaces. */

see here: http://www.crydev.net/viewtopic.php?p=952957#p952957
you should look at the function
Code:
void parseMessage(string inString, SActivationInfo* pActInfo)
in the CFlowNode_MessageParser class.

Does this answer your question?

best,
tim.

  Trainee TraineeMember since: 21.11.2007, 23:13Posts: 183 Likes: 19
 

 Post Topic: Re: creating a new FlowNode with C++
PostPosted 22.04.2012, 18:17 
Thanks Tim

Does that mean I also should compile the parser?

I actually tried and i got these errors

Code:
c:\program files (x86)\electronic arts\crytek\fresh3_4\code\game\gamedll\nodes\cflownode_messageparser.cpp(143): error C2220: warning treated as error - no 'object' file generated
3>c:\program files (x86)\electronic arts\crytek\fresh3_4\code\game\gamedll\nodes\cflownode_messageparser.cpp(143): warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
3>c:\program files (x86)\electronic arts\crytek\fresh3_4\code\game\gamedll\nodes\cflownode_messageparser.cpp(150): warning C4244: '=' : conversion from 'double' to 'float', possible loss of data


I
I was also able to compile the TCP example on the same thread without any problems...
I am a newbie with programming, I just started with openframeworks, and also trying to learn the cryengine so I am a bit slow.
I will look at the code and see if i can work it out.
if i understand correctly, I should make my own node/parser?

Thanks again
User avatar   Beginner BeginnerMember since: 20.01.2012, 17:29Posts: 32Location: Antwerp, Belgium Likes: 0
 

 Post Topic: Re: creating a new FlowNode with C++
PostPosted 22.04.2012, 19:31 
ooops!

that's what I get for posting code without checking for stupidity.
Your compiler is getting angry because it's treating warnings as errors.
The casting warning appears because of this line:
Code:
   vec[coordcount] = atof(mssgBuf);


atof() returns a double (see:http://www.cplusplus.com/reference/clibrary/cstdlib/atof/ )
and I have vec[] defined as an array of floats.
I'll edit my original post, but you can just change every occurence of atof(...); to (float)atof(...);
"(float)" casts the double that atof returns into a float.
(more about casting: http://www.cplusplus.com/doc/tutorial/typecasting/)

like this:
Code:
if(coordcount < 3){
                  vec[coordcount] = (float)atof(mssgBuf);
               }


Your other question: yes, you should make an OSC parser node. I've built two flownodes so far. A UDP client node that can send and receive messages and a message parser node that converts received messages into meaningful data (3D vectors).

You can just re-use the UDP client flownode if you only want to receive. If you want to make it send OSC, you'll have to change that too.
If I would want to create an OSC parser flownode I'd start by searching the web for an existing C++ OSC parser and then try to make a flownode with it. I'm pretty sure there must be an OF implementation flying around in cyberspace :-)

good luck with learning this stuff! OpenFrameworks is a great library to learn C++.

best,
tim.
User avatar   Beginner BeginnerMember since: 20.01.2012, 17:29Posts: 32Location: Antwerp, Belgium Likes: 0
 

 Post Topic: Re: creating a new FlowNode with C++
PostPosted 22.04.2012, 19:39 
User avatar   Trained Modder Trained ModderMember since: 03.04.2012, 14:33Posts: 211 Likes: 0
 

 Post Topic: Re: creating a new FlowNode with C++
PostPosted 23.04.2012, 15:46 
This is exactly what i was lookin for very much thanks


Game Designer
  Trainee TraineeMember since: 21.11.2007, 23:13Posts: 183 Likes: 19
 

 Post Topic: Re: creating a new FlowNode with C++
PostPosted 23.04.2012, 16:16 
Great Tim
Got it to work, I will try to figure out how to make the osc parser.
Thanks you so much for all your help,

cheers
User avatar   Beginner BeginnerMember since: 20.01.2012, 17:29Posts: 32Location: Antwerp, Belgium Likes: 0
 

 Post Topic: Re: creating a new FlowNode with C++
PostPosted 23.04.2012, 17:22 
I think I will reconstruct the UDP flownode.
Right now it's only usefull for sending specifically formatted messages.
I will rewrite it so it can send any message as a string. This way the formatting can stay separated from the sending/receiving.

I will put it up on github when it's done.

best,
tim.
User avatar   Beginner BeginnerMember since: 20.01.2012, 17:29Posts: 32Location: Antwerp, Belgium Likes: 0
 

 Post Topic: Re: creating a new FlowNode with C++
PostPosted 23.04.2012, 23:57 
Hi all,

I've put my flownode code online at https://github.com/timknapen/CryEngine-FlowNodes for everyone to take.
I will update it there instead of in this thread.

best,
tim.
  Beginner BeginnerMember since: 21.06.2013, 02:32Posts: 12 Likes: 0
 

 Post Topic: Re: creating a new FlowNode with C++
PostPosted 13.04.2014, 05:05 
Hello,I've copied the code you put at the very bottom,but I still found nothing in my flow graph.I am waiting here for your answer.Thank you!