Login
Username:

Password:

Remember me



Lost Password?

Register now!
Main Menu
H3D.org Feeds

Forum Index


Board index » All Posts




Running H3D window on second screen
#1
Not too shy to talk
Not too shy to talk


Hello,

I am trying to run an H3D process on my second screen under Ubuntu. Previously, I was using python to handle this in Windows through the win32process library. This library does not exist under Linux, and the subprocess library in python doesn't seem to have this functionality, at least not under Linux.

Basically, what I need is for H3D to always run in fullscreen on my second monitor when it's called.

In my x3d file, I currently have:
<H3DWindowNode fullscreen='1' />


This gets called in python through:
subprocess.Popen(['H3DLoad'process_name], stdout=PIPEstderr=PIPE)

where process_name is the path to the x3d file.

From my understanding of the H3DWindowNode documentation, there doesn't seem to be an option to 'select a screen' or to set the pixel position of one of the window corners, unless it's a field/option I'm not seeing. What is the way to achieve this under Linux?

Thanks,
-Yaz

Posted on: Ystrday 20:16
Top


Re: RuntimeError: UnableToCreatePythonField: fieldAsPythonObject()
#2
Webmaster
Webmaster


It looks like you are mixing concepts a bit.

traverseSG is using the update function of the class Trial which kind of looks like an class that should inherit from the field types in H3DInterface and should be using the routing system.

Whichever system you are using ( traverseSG or the other setup with fields and routes) does not really matter but it was a bit confusing to me at first.

If this code is correct, then the first time traverseSG will be called the cylinder will change to the new color. Which color are you actually seeing when you start the program (maybe it changes so fast that you do not notice).

And finally, this really looks like some kind of recursive issue.
If your x3d file is called Trials.x3d then you can see that it includes the python script file Trials.py which then loads Trials.x3d which then loads Trials.py and I really do not know what to expect in this case (the module should only load once, but it is still quite weird).
You can either use the references field to give the node you are interested in to python or use getNamedNode() function in python.

Posted on: 5/14 9:10
Top


RuntimeError: UnableToCreatePythonField: fieldAsPythonObject()
#3
Not too shy to talk
Not too shy to talk


I am trying to work out the setValue() ' routing' approach, but this error keeps coming up.
Also, when I try updating the color of an object with self.dn["MAT"].diffuseColor.setValue(RGB(1,0,0)) for instance, the object does not change color.
I suspect that this error is the reason, but I can't figure out how to solve it. Here's the X3D:

<X3D
   <
Scene
      <!--
OBJECT--> 
      <
Shape
         <
Appearance
            <
Material DEF="MAT" diffuseColor="1 0 0"/> 
         </
Appearance
         <
Cylinder/> 
      </
Shape

      <
PythonScript DEF="PS" url="Trials.py"/>
   </
Scene>
</
X3D>


And the Python:

from H3DInterface import *

class 
Trial():
   
def __init__(self):
      
self.nodeself.dn createX3DNodeFromURL("Trials.x3d")
      
self.new_color RGB(010)
   
def update(self):
      
self.dn["MAT"].diffuseColor.setValue(self.changeColor())

   
def changeColor(self):
      return 
self.new_color

trial 
Trial()

def traverseSG():
   
trial.update()

Posted on: 5/10 11:27
Top


Re: How can I update SmoothSurface stiffness with python?
#4
Webmaster
Webmaster


UpdateStiffness is a wrapper name. Look at the base class for this particular field and you can see that it inherits from SFFloat. The field itself is inputOutput so you can treat it as an SFFloat field just fine.

The purpose of this particular field is to properly transfer the value it is set to into the haptic loop at some point.

Posted on: 5/2 8:15
Top


Re: HDEV proxyPosition not generating events
#5
Webmaster
Webmaster


Sounds like you might have already figured out the reason.

Due to lazy evaluation the update function will only be run if getValue is done on the field somewhere in the chain. Such as being done directly on the field or if it is routed to a field which someone is trying to get the value of. If you use the decorators AutoUpdate or PeriodicUpdate you have a different behaviour though as you have noticed. For most cases I would recommend PeriodicUpdate over AutoUpdate but it does depend a bit on what the field is supposed to be used for.

Posted on: 5/2 8:12
Top


How can I update SmoothSurface stiffness with python?
#6
Not too shy to talk
Not too shy to talk


Hi,

I am trying to update the stiffness of a surface with a python field.
However, the stiffness field is defined as the type UpdateStiffness which is not supported in H3DInterface, correct?

How can I solve this?

Posted on: 4/30 11:56
Top


Re: HDEV proxyPosition not generating events
#7
Not too shy to talk
Not too shy to talk


AutoUpdate(SFVec3f), people. Is it safe, though? Like, only get the proxyPosition when isTouched is true, for instance. Therefore, not having to use AutoUpdate?

Posted on: 4/27 13:43
Top


HDEV proxyPosition not generating events
#8
Not too shy to talk
Not too shy to talk


Previously it worked just fine, but when I started over, and simply wanted to calculate a linear force just like in dynamic.py, proxyPosition doesn't generate an event at all.
I might be looking over something super obvious, but I've been stuck for an hour now.

Here's the Python code:

from H3DInterface import 

class 
LinearForce(TypedField(SFBoolSFVec3f)): 
    
def __init__(self): 
        
TypedField(SFBoolSFVec3f).__init__(self

    
def update(selfevent): 
        
height event.getValue().
        
return height .03 

linearForce 
LinearForce()


And X3D:

<IMPORT inlineDEF="H3D_EXPORTS" exportedDEF="HDEV" AS="HDEV" />

<!--
Cylinder-->
<
DynamicTransform DEF="DYN" position="-.19 0 -.035" orientation="1 0 0 1.570796326" mass=".2">
    <
Shape>
        <
Appearance>
            <
Material DEF="MAT" diffuseColor="1 0 0"/>
            <
SmoothSurface/>
        </
Appearance>
            <
Cylinder DEF="CYL" height=".03" radius=".03"/>
    </
Shape>
</
DynamicTransform>

<
PythonScript DEF="PS" url="PosForce.py"/>

<
ROUTE fromNode="HDEV" fromField="proxyPosition" toNode="PS" toField="linearForce"/>


Posted on: 4/27 13:06
Top


Re: getValueByIndex() not compatible with MFVec3f ?
#9
Not too shy to talk
Not too shy to talk


I solved it by doing:
forces routes_in[0].getValueAsString()
z_force forces.rpartition(" ")[2]

Posted on: 4/20 11:32
Top


Re: getValueByIndex() not compatible with MFVec3f ?
#10
Webmaster
Webmaster


You nailed it. It is about the documentation.

There are two sets of class documenation for H3D. One for C++ and one for the python level.

Please refer to this one for python for 2.3 release:
http://www.h3dapi.org/uploads/api/H3D ... b/doc/html/annotated.html


Or this one if you use trunk:
http://www.h3dapi.org/uploads/api/Tru ... I/lib/doc/html/index.html

If I remember correctly there is no version for it in python. You have to do yourfield.getValue()[your_index]

Posted on: 4/20 10:23
Top



TopTop
(1) 2 3 4 ... 962 »






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