WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Stand-alone executables, etc. (https://forum.worldviz.com/showthread.php?t=140)

JRichizzle 04-15-2004 02:11 PM

Stand-alone executables, etc.
 
We have a unique application in which subjects are going to have to select programs to run during an experiment. The programs will be simulations of continuous motion through various virtual environments (VRMLs) without head-tracking. The subject will have an LCD display directly in front of them while on a treadmill. This display will be driven by a Windows XP-based PC operating system. We envision the subjects selecting simulations via some graphical user interface in which icons represent links to any one of the aforementioned motion simulations (i.e. Vizard scripts).

Can one create stand-alone programs in Vizard?

We thought we might have to create the master GUI with 3rd-party program to act as a middle-man between the subject and the programs in Vizard. If so, we need to figure out how to communicate between this master GUI and Vizard.

I expect to have to answer questions to clarify this question, but I thought I would get the conversation rolling with this much for now.

Thanks!

farshizzo 04-15-2004 02:29 PM

Hi,

It is possible to run a vizard script from within another program. All you have to do is execute the following command:

"C:\Program Files\Vizard20\bin\winviz.exe" 0

Use the following piece of code in your program to call this command:
Code:

ShellExecute(NULL, "open", "C:\\Program Files\\Vizard20\\bin\\winviz", "C:\\somescript.py 0", NULL, SW_SHOW);
I'm not sure if this is related to what you want, but Vizard comes with a program that allows you to create an html page with links to vizard scripts. When a user clicks on a script link it will launch that script. This way you can design some fancy looking page with links to your scripts. Let me know if you are interested in this and I'll give you some more detail about using it.

JRichizzle 04-15-2004 02:31 PM

html info
 
Yes, I would like to learn more about how to create this html page with links to programs. Please send more info when you can. Thanks!

farshizzo 04-15-2004 03:12 PM

Hi,

There is a zip file on our webpage that contains this program and an example. Click on the following link to download it:

http://www.worldviz.com/download/files/quickworld.zip

The main program is Quickstart.exe. When you run this program it will load the html page demo.html. There are no restrictions on how your html page should be layed out. To create a link to a script just insert the following html code at the appropriate location in your html page:
Code:

Run Script
The id field of the SPAN tag should be the path to any Vizard script. You can change Run Script to any text you want. Let me know if you need any more help.

Good luck!

JRichizzle 07-28-2004 01:08 PM

Launching Vizard from Visual Basic
 
So, is the "ShellExecute..." command in the post above a C or C++ command?

farshizzo 07-28-2004 01:33 PM

Hi,

The above code sample will only work with C/C++. It should work in Visual Basic with very little modification. There should be an example in the Visual Basic documentation. I've never used Visual Basic before, so I don't know the exact syntax.

JRichizzle 07-30-2004 07:36 AM

Calling scripts from within a script
 
Howdy,

Is it possible to run other .py scripts with a command within a .py script?

E.g., a keyboard callback within a program that, when one presses the spacebar, launches a second program.

E.g.2, an if/then statement that launches a second program.

Better yet, can I develop a my own custom GUI using Vizard?

farshizzo 07-30-2004 11:08 AM

Hi,

You can run a vizard script from any programming environment. All you need to do is execute the following in the command line:

"C:\Program Files\Vizard20\bin\winviz.exe" "script.py" 0

The way to do this is different for each programming language, so you will have to look at the documentation for it. Here's an example of how to do it in python, however I don't recommend launching a vizard script within another vizard script.
Code:

import viz
import win32process

def startscript(filename):
        execCommand = viz._BIN_PRIMARY + ' "' + filename + '" 0'
        win32process.CreateProcess(None, execCommand,
                                                                  None, None, 1, 0, None,
                                                                  None, win32process.STARTUPINFO())

startscript('myscript.py')


JRichizzle 07-30-2004 11:42 AM

Sweet, thanks!! I didn't really want to call scripts with a script, but was curious about the possibilities. We're going to call scripts with a GUI program written in Visual Basic.

Far-shizzle mah nizzle,
JRichizzle.

p.s. do you know anything about the timeline for the release of a version in which stand-alone executables can be created?

sjroorda 04-27-2005 07:19 AM

Sorry for kicking this topic, but I'm curious for the answer on the last question of the topic starter:
Quote:

we need to figure out how to communicate between this master GUI and Vizard
Is this possible in a certain way?

My application is a little more complex than 'just' selecting a world from a menu: I want to send commands to my wordt from within the (Delphi) user interface. These commands are for example 'lights on/off', 'play sound', 'open door', etc.. Should I use a specific port for sending data to? I don't get any data in the mynetwork-function.

I have another additional question: is it possible to remove the title bar and borders from the Vizard window without going fullscreen? I only want the rendered image, nothing more. (goal: I want to include two different viewpoints into my Delphi UI).

Thanks in advance,

Siemen

farshizzo 04-27-2005 01:42 PM

Hi,

The Vizard network commands use a datagram socket on port 4950 to communicate. Sending the string "hello" will result in the following character sequence being sent:

"\x00\x00\x00\x00,s\x00\x00hello\x00\x00\x00"

Note that "\x00" is the hex value 0x00. I have never tried communicating with Vizard from another application using this method. However, if you follow the above protocol I don't see why it would not work. Let me know if you are having any problems with this.

If you have not already invested a lot of effort in your Delphi UI, you might want to consider directly embedding Vizard within a GUI application made with python. We have a few samples of embedding the Vizard render window inside of a wxPython GUI.

Currently there is no built-in method of removing the border of the render window. I'll look into a work around for this in the meantime.

sjroorda 04-28-2005 01:28 AM

Thanks for this information, I managed to get data from one computer running a Delphi UI to my Vizard-program. However, with a 'print message', I get an array of two elements, each (!) containing the string I've sent, so no real datagram package as you describe. I guess a miscommunication between Delphi and Vizard is the cause, but I get the data, and that's the point :). I even get a Vizard-msg 'Oops, typetag lacks the magic ,' in response!

farshizzo 04-28-2005 09:57 AM

Hi,

The message structure passed to python should be an array of 3+ elements. The first element should be the address of the user that sent the message. The second element should by the type information of what they sent. The rest of the data should be the actual content of the message, in your case it should be a string. I'll do some tests here to make sure sending the data over a socket works.

farshizzo 04-28-2005 10:26 AM

Hi,

I did some tests here and got it working. Here is the C++ code I used to generate the packet:
Code:

std::string packString(const char *message)
{
        std::string pack = message;
        int stringLen = ceil( (pack.size() + 1) / 4.0 ) * 4;
        for(int i = pack.size(); i < stringLen; i++)

                pack += '\0';
        return pack;
}

std::string createPacket(const char *message)
{
        return packString("master") + packString(",s") + packString(message);
}

The createPacket function uses the packString function to generate 3 string packets. The first string packet is the address of the computer you are sending from. You can set this to whatever you want. The second string packet is the type of the data. If you will only be sending one string then you don't need to change this. The last string packet is the message you want to send. The packString function simply pads the string with some NULL characters. After this, simply send the string returned by createPacket over the socket. Let me know if you can't get this working.

sjroorda 05-03-2005 03:02 AM

Thank you for the code; I ported it to Delphi and everything works fine! However, I tested somewhat, and I got a curious case regarding the way of sending commands like these. The general structure of a network package to be sent is as follows:

{sender}{type of information}{information itself}

all fields added with 0-bytes up to a multiple of 4 bytes. Example (seperated by newlines for readability):

sender#0#0
,ss#0
test1#0#0#0
test2#0#0#0

Type of information is, for example, ,ss if 2 strings are sent, ,ii if two integers are send and ,lii if an array of 2 integers is sent. However, consider these two cases:

myNetwork.send([1,2,3,'s','test']);
myNetwork.send([1,2,3,'s'],'test');

Both send ,liiiss as type! How do I know, if I want to process information sent by Vizard, which data really was sent? Vizard understands, regarding a 'print msg'.

Despite my continuing flow of maybe far too technical questions: thanks for the good and quick support :)

farshizzo 05-03-2005 10:06 AM

Hi,

When you get the data you can check the size of the list using the len function. This way you know how many elements are in it.

JRichizzle 07-13-2005 09:15 AM

Winviz title bar and borders
 
Again, bringing this thread back to life...

Is there a known work-around for removing the title bar and borders from the winviz render window? (other than setting window position and size manually such that they are invisible to the user)

farshizzo 07-13-2005 11:11 AM

Are you wanting to do this without going into fullscreen mode? Going into fullscreen mode should remove the titlebar and border. The latest beta version of Vizard has a function to remove the border without going into fullscreen mode, but I don't believe it is available for download yet. Let me know if you would like to try out the beta version.

JRichizzle 07-13-2005 11:15 AM

I would like to remove borders and title bar in normal screen mode (not fullscreen). Unfortunately, I need to be able to do this in v2.51. This is because the project I am working on is a NASA flight experiment with tight constraints on software.

Is there a way you could share the function with me without having to install the beta version?

farshizzo 07-14-2005 12:48 PM

1 Attachment(s)
I've attached a zip file which contains a script that will remove the border around the window. The zip file also contains the file "win32gui.pyd". You will need to place this file in the same directory as your script. If you use the code in a different script be sure to modify the variable scriptName to the name of your script. Let me know if it doesn't work.

JRichizzle 07-14-2005 01:40 PM

How do I call the function? Should there be a line with the following code:

NextWindow(hwnd, obj)

What numbers should take the places of hwnd and obj ?

farshizzo 07-14-2005 03:23 PM

1 Attachment(s)
You don't need to call any function, the code should automatically remove the border. I've made a small fix so you should download the attached file. It creates a function called RemoveBorder which accepts the name of a window. This name should be the name of your script.

JRichizzle 07-14-2005 03:27 PM

Works like a champion!!! Thanks so much for all your help!

sjroorda 08-30-2005 03:11 AM

Quote:

Originally posted by farshizzo
The Vizard network commands use a datagram socket on port 4950 to communicate.

[...]
Again a subtile kick! I need to send this data to two different Vizard-instances on the same computer. Creating a UDP-socket works great for one of them, but the other never receives any data. I guess this has to do with the fact that at the moment the first instance catches the data, this UDP-packet is gone.

A trivial solution for this would be connecting a second socket to a different port, but I can nowhere find a way to specify the port number!

Is this possible, is there another way, or should I look for a completely different workaround?

farshizzo 08-31-2005 08:54 AM

Hi,

The option to specify a port to communicate over is not available in the current version. In the meantime you can create your own sockets using python. There is a post in the following thread which contains sample python code for creating sockets manually.
http://www.worldviz.com/forum/showth...=&threadid=370

sjroorda 09-01-2005 07:13 AM

Great, it's working!

cr5 09-13-2005 08:44 AM

sending network messages to vizard
 
i managed to get messages into vizard over a network as shown earlier in this thread. they appear in the right format but everytime vizard receives a message, it freezes rendering for about 4 seconds. which sums up fast if i send tracking data from another machine about 25 times a second...

it's v.2.53, win xp. tested on two machines, same effect. any help?

farshizzo 09-13-2005 09:43 AM

Hi,

I just created a test script here that sends tracking data from an intersense to another script. The data is being sent every frame, so 60 times a second. I tried receiving the data on two separate machines, and on both of them the latency for receiving data was around 1 millisecond. These tests were also done on winxp.

Are you sending the data over a local network? Is Windows XP firewall enabled? We've had problems with that before. Are you using Vizard's built-in networking functionality to receive the messages?

cr5 09-14-2005 04:10 AM

i use a local network and get the same result if i connect only the two machines with fixed ip's, firewalls disabled. the latency in receiving data seems very low, as when i click on send on one machine the rendering in vizard freezes immediately (for some seconds). i use the built in network thingy, like this:

Code:

def mynetwork(msg):
        euler = view.get(viz.HEAD_EULER)
        euler[0] += msg[2]
        euler[1] += msg[3]
        euler[1] = viz.clamp(euler[1],-90.0,90.0)
        view.rotate(euler,viz.HEAD_ORI)

viz.callback(viz.NETWORK_EVENT, mynetwork)

the incoming messages look like this:

Code:

['MaxJitter', ',ff', 0.32187500596046448, -0.70416665077209473]
again, except for the freezes, everything basically works. could setting up the machine anew help in any way? (i usually work on OS X and other unixes and tried to ignore messy windows for the last years...)

farshizzo 09-14-2005 05:58 PM

Hi,

After some testing I found the problem. When a message is received by Vizard it attempts to lookup the name of the sender. On some networks this may take a long time due to slow DNS servers. I modified Vizard to not perform this lookup and it definitely speeds up receives. This will most likely solve your problem too. I will try to get a patch by the end of the week, let me know if you need it sooner. Sorry for all the trouble.


All times are GMT -7. The time now is 05:29 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC