Login
Username:

Password:

Remember me



Lost Password?

Register now!
Main Menu
H3D.org Feeds

Forum Index


Board index » All Posts (Gazoo)




Custom VHTK Rendering Node
#1
Not too shy to talk
Not too shy to talk


Hey forum,

I want to leverage the features of the VHTK in my own program. Thanks to the kind tutaledge of Markus and KJ, I've established that the easiest way of making this work is to create my own render node in H3DAPI. The following milestones must be achieved:

1. Compile and execute a simple Node.

2. Get the node to exhibit some form of functionality.

3. Exhibit Render functionality

4. Combine the rendered data with some VHTK functionality

5. Profit!

However - Nothing is ever that simple. Right now I cannot even get to my first milestone. I've stolen some code from the Wiki which gives a simple example of creating a node.

Header file:

#ifndef __MYRENDERERNODE_H__
#define __MYRENDERERNODE_H__
 
// Include needed files here
#include <H3D/X3D.h>
 
namespace H3D {
  class 
myRendererNode: public BaseClass{
  public:
    
myRendererNodeInstFieldType >  _myFieldName 0);
 
    
// public virtual functions goes here
 
    // Fields are specified like this. Where FieldType is one of the types for fields.
    // these are all defined in the files which names start wit "SF" or "MF"
    
auto_ptrFieldType >  myFieldName;
 
    
/// The H3DNodeDatabase for this node.
    
static H3DNodeDatabase database;
 
  protected:
    
// protected virtual functions goes here.
  
};
}

#endif


CPP file:

#include "myRendererNode.h"
#include <H3D/X3D.h>
#include <H3D/X3DNode.h>

using namespace H3D;
 
// The second argument is NULL if this class is abstract.
H3DNodeDatabase X3DNode::database"myRendererNode",
                                   &(
newInstance<NodeTemplate>),
                                   
typeidNodeTemplate),
                                   &
BaseClass::database );
 
namespace 
X3DNodeInternals {
  
// The third argument is one of INPUT_OUTPUT, OUTPUT_ONLY or INPUT_ONLY.
  
FIELDDB_ELEMENTNodeTemplatemyFieldNameINPUT_OUTPUT );
}
 
myRendererNode::myRendererNode
                 
InstFieldType >  _myFieldName):
  
myFieldName_myFieldName) {
 
  
type_name "NodeTemplate";
  
database.initFieldsthis );
}
 
// other functions


As far as I can tell "BaseClass" doesn't exist and should be replaced by the best fit parent class. I want to build a class that renders volumetric data. Does anyone know which class would be well suited to inherit from? I assume it would be one within the VHTK.

Regards,
Lasse

Posted on: 2011/2/28 13:04
Top


Re: A leg up (on the pile) on VHTK
#2
Not too shy to talk
Not too shy to talk


I've made sure the H3D_ROOT variable points to the folder containing the settings folder. No chance in the rendering. But I suppose as long as it at least renders properly, that's something and can allow me to move on and try to create my own render node...

Something else troubles me though. I debug mode, the executable crashes. I have yet to spot the difference as to why the Release version would work and the Debug version would not. I get the following printed errors when running in debug mode:

[WWARNINGCould not create "VolumeHaptics" nodeIt does not exist in the H3DNodeDatabase (C:/H3D/VHTK/x3d/setup_sphere.x3d line 36)
[
WWARNINGCould not create "LocalInfo" nodeIt does not exist in the H3DNodeDatabase (C:/H3D/VHTK/x3d/setup_sphere.x3d line 40)
[
WWARNINGCould not create "VolumeRenderer" nodeIt does not exist in the H3DNodeDatabase (C:/H3D/VHTK/x3d/setup_sphere.x3d line 49)
[
WWARNINGCould not create "ScalarSurfaceFrictionMode" nodeIt does not exist in the H3DNodeDatabase (C:/H3D/VHTK/x3d/setup_sphere.x3d line 97)
[
WWarningH3D API compiled without 3DxwareSpaceWareSensor node will be unusable.


It's as if the debug version cannot find VHTK, which I cannot understand. CMake creates the proper links when creating the sln file that eventually compiles the H3DAPI. Any ideas of what could be the cause?

Posted on: 2011/2/28 10:49
Top


Re: A leg up (on the pile) on VHTK
#3
Not too shy to talk
Not too shy to talk


We have lift off. That is, the whole thing now compiles with only a few (and I hope) unimportant errors:

[W] Warning: H3D API compiled without 3Dxware. SpaceWareSensor node will be unusable.
[W] Warning: No device exists in DeviceInfo when trying to IMPORT from HDEV from H3D_EXPORTS. Using dummy device instead.

But... All I see is a grey screen with what could either be a very small sphere, or (more likely) a small aiming reticule.

Shouldn't I be seeing a big ball or something? I've also tried out most of the keyboard as well as mouse/haptic device without any response...? As far as I can tell from the X3D file there is no defined interaction...

Posted on: 2011/2/24 14:19
Top


Re: A leg up (on the pile) on VHTK
#4
Not too shy to talk
Not too shy to talk


Ok. I added the following line:

<ImportLibrary library="C:H3DVHTKbinVHTK.dll" />


and all that remains are the following errors:

[WWarningH3D API compiled without 3DxwareSpaceWareSensor node will be unus
able
.
[
WWarningNo device exists in DeviceInfo when trying to IMPORT from HDEV from H3D_EXPORTSUsing dummy device instead.
[
WWarning in ScalarVolume:
[
WNone of the urls in ScalarVolume with url "data/sphere_256x256x256_u8.raw"could be loadedEither they don't exist or none of the specified ImageLoaders
 is able to load them.


I cannot find the raw volume... Isn't it supposed to be part of the VHTK zip?

Posted on: 2011/2/23 22:09
Top


Re: A leg up (on the pile) on VHTK
#5
Not too shy to talk
Not too shy to talk


Replacing following text:
python/candy/AutoLoadSO.py

with
urn:candy:python/AutoLoadSO.py


did unfortunately not help. Still the same errors as before. Instead I replaced all the URLs with hardcoded values pointing directly to all the necessary files (except this file "data/sphere_256x256x256_u8.raw" which I cannot find - perhaps it's created?).

This brought about a slew of new errors. Of course. Nothing is easy...

[WPython error in file "C:H3DVHTKpythoncandyAutoLoadSO.py":
[
WTraceback (most recent call last):
[
W]   File "<string>"line 90in <module>
[
WAttributeError[W] : [W'module' object has no attribute 'argv'[W]
[
WWARNINGCould not create "VolumeHaptics" nodeIt does not exist in the H3DNodeDatabase (C:/H3D/VHTK/x3d/setup_sphere.x3d line 35)
[
WWARNINGCould not create "LocalInfo" nodeIt does not exist in the H3DNodeDatabase (C:/H3D/VHTK/x3d/setup_sphere.x3d line 39)
[
WWARNINGCould not create "VolumeRenderer" nodeIt does not exist in the H3DNodeDatabase (C:/H3D/VHTK/x3d/setup_sphere.x3d line 48)
[
WWARNINGCould not create "ScalarSurfaceFrictionMode" nodeIt does not exist in the H3DNodeDatabase (C:/H3D/VHTK/x3d/setup_sphere.x3d line 96)
[
WWarningH3D API compiled without 3DxwareSpaceWareSensor node will be unusable.


I'm not sure what to make of the error. It's expecting a variable I'm not giving it? Shouldn't the example just work? I hope you guys don't mind me skipping ahead - I mean hardcoding the urls in the x3d file - but I've spent almost two weeks on just getting VHTK to work and it'd be nice to see if I'm just digging myself deeper into a hole I cannot get out of :(

Posted on: 2011/2/23 9:47
Top


Re: A leg up (on the pile) on VHTK
#6
Not too shy to talk
Not too shy to talk


Hey Markus,

I tracked the error message to the following code block contained in the URNResolver.cpp (Line 37-42):

ifstream isconfig_file.c_str() );
  if( !
is.good() ) {
    
Console(4) << "Warning: Could not open file URN resolver config file "" 
               << config_file << """ 
<< endl
    return;
  }


I also figured out that the issue was that my environment variable (H3D_URN_CONFIG_FILE) was pointing at the directory my URN file was in, but not the actual file. This has been fixed. Note to others: Visual Studio 2010 must be restarted in order for it to notice changes in environmental variables.

Unfortunately, the program still throws errors at me:

[WWarningNone of the urls in the PythonScript node "PythonScript_000000000247DB90" with url ["python/candy/AutoLoadSO.py"could be found.
[
WWARNINGCould not create "VolumeHaptics" nodeIt does not exist in the H3DNodeDatabase (C:/H3D/VHTK/x3d/setup_sphere.x3d line 35)
[
WWARNINGCould not create "LocalInfo" nodeIt does not exist in the H3DNodeDatabase (C:/H3D/VHTK/x3d/setup_sphere.x3d line 39)
[
WWARNINGCould not create "VolumeRenderer" nodeIt does not exist in the H3DNodeDatabase (C:/H3D/VHTK/x3d/setup_sphere.x3d line 48)
[
WWARNINGCould not create "ScalarSurfaceFrictionMode" nodeIt does not exist in the H3DNodeDatabase (C:/H3D/VHTK/x3d/setup_sphere.x3d line 96)
[
WWarningNone of the urls in the PythonScript node "ROTATOR" with url "python/candy/Rotator.py"could be found.
[
WWARNINGRoute errorCould not find field named "rotation" in "ROTATOR" Node (C:/H3D/VHTK/x3d/setup_sphere.x3d line 127)


I can see that the AutoLoadSO.py exists in the VHTK sub folders. My URN file looks as follows and I assume it is now being read, but something must still be off:

urn:h3dapiC:/H3D/H3DAPI/
urn:vhtkC:/H3D/VHTK
urn
:candy:python C:/H3D/VHTK/python/candy


Sigh... Why is this such an uphill battle? :/ I must prevail!

Posted on: 2011/2/22 15:46
Top


Re: A leg up (on the pile) on VHTK
#7
Not too shy to talk
Not too shy to talk


Hello,

I thought I'd note that I've discovered this additional error. Perhaps something janked windows into working after a restart:

[WWarningCould not open file URN resolver config file "C:H3DH3DAPI"


I've looked at the URN file, unable to discern what might be missing. It's called index.urn and has the following content:

urn:h3dapiC:/H3D/H3DAPI/
urn:vhtkC:/H3D/VHTK
urn
:candy:python C:/H3D/VHTK/python/candy


Any ideas?

Gazoo

Posted on: 2011/2/21 16:08
Top


Re: A leg up (on the pile) on VHTK
#8
Not too shy to talk
Not too shy to talk


Hey,

Just wanted to add a thanks here off the bat for the continued help. I hope I get this stuff working soon.

I'm not directly using H3DLoad. From the wiki I learned that there we're a couple of examples of using the H3DAPI directly from C++ in this relative dir-structure:

C:\H3D\H3DAPI\examples\manualExamples\C++

So I've basically just copied the code into my own VS2010 project and compiled it and ran it. That seemed to work well enough. Then I replaced the X3D code in the project with the code from the setup_sphere.x3d example contained in VHTK. I am assuming that this is causing me to sidestep some critical setup steps which I hope can be accomplished in C++.

I don't mind using H3DLoad as such, but I eventually need to run things primarily in C++. So I thought my best bet was to try to get that working.

Setting the URN environment variable didn't help unfortunately, I assume then that H3D_ROOT should point at "C:\H3D\" for me?

Regards,
Gazoo

Posted on: 2011/2/18 16:06
Top


Re: A leg up (on the pile) on VHTK
#9
Not too shy to talk
Not too shy to talk


Hey,

My H3DAPI installation has absolutely no index.urn file. So I've tried to create one containing the following information:

urn:vhtkC:H3DVHTK
urn
:candy:python C:H3DVHTKpythoncandy


I put it both in the root (C:\H3D\) and in the folder containing the settings folder (C:\H3D\H3DAPI\). No luck. Perhaps I'm missing a path or something? I've looked through the documentation which mentions "H3D_ROOT", which I then added pointing to "C:\H3D".

Still no luck... What could I be missing?

Posted on: 2011/2/17 13:21
Top


Re: A leg up (on the pile) on VHTK
#10
Not too shy to talk
Not too shy to talk


Heys,

Markus I believe you sent me a link to the libraries in question. There was no python 64-bit included, so I've since then manually fetched the latest version 2.7 in 64-bits and linked that with H3DAPI.

I now get these errors:

[W] Warning: None of the urls in the PythonScript node "PythonScript_00000000026DD8A0" with url [ "python/candy/AutoLoadSO.py"] could be found.
[W] WARNING: Could not create "VolumeHaptics" node. It does not exist in the H3DNodeDatabase (C:/H3D/VHTK/x3d/setup_sphere.x3d line 35)
[W] WARNING: Could not create "LocalInfo" node. It does not exist in the H3DNodeDatabase (C:/H3D/VHTK/x3d/setup_sphere.x3d line 39)
[W] WARNING: Could not create "VolumeRenderer" node. It does not exist in the H3DNodeDatabase (C:/H3D/VHTK/x3d/setup_sphere.x3d line 48)
[W] WARNING: Could not create "ScalarSurfaceFrictionMode" node. It does not exist in the H3DNodeDatabase (C:/H3D/VHTK/x3d/setup_sphere.x3d line 96)
[W] Warning: None of the urls in the PythonScript node "ROTATOR" with url [ "python/candy/Rotator.py"] could be found.
[W] WARNING: Route error. Could not find field named "rotation" in "ROTATOR" Node (C:/H3D/VHTK/x3d/setup_sphere.x3d line 127)

I found an associated post from karlu regarding a similar error, stating that - and I quote - "You have to CD to that folder and start using H3DLoad x3d/setup_sphere.x3d".

Is there any way to handle this in C++. That is, force H3DAPI to look in other directories?

Regards,

Gazoo

Posted on: 2011/2/16 15:08
Top



TopTop
(1) 2 »






(C) 2012 SenseGraphics AB    ---    Powered by XOOPS