Network Inventor 1.0

 

NetIV is an extended inventor viewer. With NetIV it is possible to animate inventor nodes from clients per udp packets. So the user can use his favorite programming language. It is possible to send state changes for a node and it is also possible to send a request packet to became the actual state of the node back.

Operating systems

Time behavior

To implement a network server with less then 1 percent cpu load in the sleep mode (no udp packets comes from the client), we have used an one thread, udp select (with timeout), SoOneShotSensor C++ program.
To implement this, we have designed a typical inventor SoOneShotSensor program. This sensor allows the programmer to render the inventor scene after polling for udp packets.
For the socket polling we use a select function with a timeout of 50 milli seconds (it is possible to set an other timeout with command line parameter). If there arrives a udp packet from a client we execute the command and polling in a loop for more packets (select with no timeout). If there are no packets we call the render function to view the new scene graph.
So we have a minimum of 20 frames per second when the CPU and graphic port load is less then 100 percent. If the client sends more than 20 packets per second the fps increase.

The protocol

To manipulate the values of a node, the node must have a name. It is possible to set a name in the inventor file with the DEF statement. If there are more nodes with the same name the first node in the tree will be manipulated. For this case the client should use the base field. With this field a base can be set (for example: to change the rotation of the right knee, set the base to the left leg and manipluate the rotation of the knee node).

In the command field the client must send the field and the new values to manipluate. More about the format is described in the inventor manual - see SoNode::set(char *);

All values must be send in network byte order!

Set node values

The client must send a udp packet with this format to change the values of a node:

packet type (4bytes=integer): IVSETVALUES = 101
transaction number (4bytes=integer)
base string length (4bytes=integer) without last \0
new inventor subtree base
node string length (4bytes=integer) without last \0
the node to manipulate
command string length (4bytes=integer) without last \0
command for SoNode::set(char *);

Server sends nothing back!

Get node values

The client must send a udp packet with this format to get all values of a node:

packet type (4bytes=integer): IVSETVALUES
transaction number (4bytes=integer)
base string length (4bytes=integer) without last \0
new inventor subtree base
node string length (4bytes=integer) without last \0
the node to manipulate

Server sends back:

packet type (4bytes=integer): IVSUCCESS
the received transaction number (4bytes=integer)
result string length (4bytes=integer) without last \0
result string

Test transaction

To check the connection between the client and the server, the client can send a test packet:

packet type (4bytes=integer): IVTEST
transaction number (4bytes=integer)

Server sends:

packet type (4bytes=integer): IVSUCCESS
the received transaction number (4bytes=integer)

Load an inventor file - server side

To insert the contents of an inventor file, the client must send this packet.

packet type (4bytes=integer): IVSETVALUES
transaction number (4bytes=integer)
base string length (4bytes=integer) without last \0
new inventor subtree base
node string length (4bytes=integer) without last \0
the parent node
node name string length (4bytes=integer) without last \0
the name for the new node
filename string length (4bytes=integer) without last \0
the name of the inventor file

Server sends on success

packet type (4bytes=integer): IVSUCCESS
the received transaction number (4bytes=integer)

Server sends on error

packet type (4bytes=integer): IVERROR
the received transaction number (4bytes=integer)
result string length (4bytes=integer) without last \0
result string with error description

Load an inventor file - client side

To insert the contents of an inventor file, the client must send this packet.

packet type (4bytes=integer): IVSETVALUES
transaction number (4bytes=integer)
base string length (4bytes=integer) without last \0
new inventor subtree base
node string length (4bytes=integer) without last \0
the node to manipulate
node name string length (4bytes=integer) without last \0
the name for the new node
string length (4bytes=integer) without last \0
string for functions SoInput::setBuffer(); and SoDB::readAll();

Server sends on success

packet type (4bytes=integer): IVSUCCESS
the received transaction number (4bytes=integer)
Server sends on error
packet type (4bytes=integer): IVERROR
the received transaction number (4bytes=integer)
result string length (4bytes=integer) without last \0
result string with error description

Delete a node

To remove a node from the inventor tree, send this:

packet type (4bytes=integer): IVSETVALUES
transaction number (4bytes=integer)
base string length (4bytes=integer) without last \0
new inventor subtree base
node string length (4bytes=integer) without last \0
the node (subtree) to remove

Server sends on success

packet type (4bytes=integer): IVSUCCESS
the received transaction number (4bytes=integer)

Server sends on error

packet type (4bytes=integer): IVERROR
the received transaction number (4bytes=integer)
result string length (4bytes=integer) without last \0
result string with error description

play an audio file

To play a wav file, send this:

packet type (4bytes=integer): IVSETVALUES
transaction number (4bytes=integer)
audio filename string length (4bytes=integer) without last \0
audio filename

Server sends nothing back!