H3D.org Forum Index Programming Issues
CDATA suport in H3D 2.2? | Register To Post |
| Threaded | Newest First | Previous Topic | Next Topic | Bottom |
| Poster | Thread |
|---|---|
| karlsvec | Posted on: 2012/5/10 0:02 |
Quite a regular ![]() ![]() Joined: 2008/7/1 From: Posts: 41 |
CDATA suport in H3D 2.2? Hello all,
I didn't see a forum for the H3D 2.2 beta branch, so I'm posting here (this seems to be the next most relevant forum to me). I'd like to submit a feature request to the SenseGraphics devs: CDATA support for H3D's X3D parser. I'm writing a H3D-based application with Qt, and I'd like to embed a handful of useful X3D prototypes in my application using Qt's resource system. However, many of these prototypes will have embedded PythonScript nodes, which presents a problem: where to put the Python scripts? Obviously, H3D knows nothing about Qt, so I can't just directly fetch the Python scripts out of the resource file embedded in the application binary. I forsee the following possible approaches: 1) When the application starts, write the embedded Python scripts out to some temporary directory and generate the 'url' field for the PythonScript node programmatically. This would work, but it's pretty ugly. 2) Install the prototypes and Python scripts to a standard location for application data (I want to keep my Qt application cross-platform). I like this approach better, but how do I then tell the X3D parser where to find the prototypes? There doesn't seem to be a way to set a search path for the X3D parser in H3D. This brings us to CDATA support in H3D. If I had that, I could just inline my Python code with the X3D prototype code. Neat and clean! Then, if I'm using approach (1) above, I just convert the embedded prototype to a std::string and load it up in my application. But my use case is just one of a few. With CDATA support, one could also use inlined JavaScript (with 2.2's upcoming SpiderMonkey support) or even inlined GLSL shader code in ShaderPart nodes! I look forward to anyone's thoughts on the matter. Thanks, Karl Svec Graduate Research Assistant Virtual Reality Applications Center Iowa State University |
| Markus | Posted on: 2012/5/10 9:45 |
Webmaster ![]() ![]() Joined: 2006/3/27 From: SenseGraphics Posts: 1902 |
Re: CDATA suport in H3D 2.2? As with all feature requests, please add it as a "feature" in the Bug Tracker.
Possible hints to solution to your problem. 2. Python always look in the PYTHONPATH environment variable, this one is (I think) mentioned in the H3D manual, but it is actually an environment variable defined by python. See http://docs.python.org/tutorial/modules.html If you want to tell the python interpreter where to find python modules not imported by the H3D PythonScript node then just use PYTHONPATH. Secondly, you can use the limited URN feature of H3D to tell your application where to find prototypes and scripts. H3D. I hoped this was documented in the wiki but it is not apparently. Anyways, what you do is: 1. Create a file (name it for example index.urn) on your system. In that file you have the following statement:
urn:whateveryouwanttocallit.fun: C:\Path_to_install_location_of_your_program
2. Set an environment variable named H3D_URN_CONFIG_FILE to point to the location of the index.urn. 3. Write all urls in your system as
"urn:whateveryouwanttocallit.fun:\x3d\afiletoload.x3d"
4. The things above are enough, but here is one extra tip, if you want to make it less likely that some other system overwrites H3D_URN_CONFIG_FILE then simply check out how this environment variable is used in H3DApi.cpp and copy that code to your QT program and use some other environment_variable_name, for example MyH3DAPPLICATION_URN_CONFIG_FILE. Another approach would be to write your code in vrml. I think that H3Ds vrml reader parsers inlined python code properly. e.g.
DEF PS PythonScript {
You would have to test that a bit since it was a while since I used vrml. |
| Threaded | Newest First | Previous Topic | Next Topic | Top |
| Register To Post | |



