Community
VRED Forum
Welcome to Autodesk’s VRED Forums. Share your knowledge, ask questions, and explore popular VRED topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

getting the hand touch detect collision with nodes

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
vredeye
239 Views, 4 Replies

getting the hand touch detect collision with nodes

Hi

 

I am trying to add additional interaction in addition to getPinchStrength , which works but still bit difficult for user to use this for holding objects or nodes

 

So i was looking for a collision detection , i.e when a user ( blue hands ) collides or touches an object , should detect it and trigger a function

 

This i found with vrDeviceService.getLeftTrackedHand() and vrDeviceService.deviceCollisionStarted

 

But the trigger doesnt seem to work as expected , any tips ? 

 

 

4 REPLIES 4
Message 2 of 5

Hello,

 

Here is a basic example of how I configured it based on the animated gif from the related post.

https://forums.autodesk.com/t5/vred-forum/grab-and-move-objects-with-vrhands/td-p/11224050

  • Note it's for the RH only.
  • Uses collision detection from APIv1
# Pick up objects using the Pinch gesture
# 1 - Execute while viewing Varjo Tracked Hands
# 2 - Open VR Menu and select this Variant Set
# 3 - Pinch the cube with the right hand to grab, unpinch to release

def rh_check_if_colliding():
    if rh_collider.isColliding():
        rh_box_constraint.setActive(True)
        
def check_pinch_strength():
    if rh_tracked.getPinchStrength() < 1.0: # Release cube
        rh_box_constraint.setActive(False)
    elif rh_tracked.getPinchStrength() == 1.0: # Pick up cube
        rh_check_if_colliding()
                  
rh_tracked = vrDeviceService.getRightTrackedHand()
rh_index = vrNodeService.findNode("R_index_collision_geo", root=getInternalRootNode())

test_node = vrNodeService.findNode('PinchBox')
if not test_node.isValid():
    
    # Create box near RH index finger location
    box_initial_pos = rh_index.getWorldTranslation()

    box = createNode("Transform3D", "PinchBox", False)
    box.addChild(createBox(45, 45, 45, 1, 1, 1, 0.0, 1.0, 0.0, 0.0))
    box.setTranslation(box_initial_pos.x(), box_initial_pos.y(), box_initial_pos.z() + 100)

    # Create Constraints    
    rh_box_constraint = vrConstraintService.createParentConstraint([rh_index.getParent()], box, False)

    # Create Collisions
    rh_collider = vrCollision([box], [rh_index])
    rh_collider.connect(rh_check_if_colliding)
    
# Create timer to monitor pinch strength
timer = vrTimer()
timer.connect(check_pinch_strength)
timer.setActive(True)

Regards,

Dan

Message 3 of 5

thanks for the response

 

    box_initial_pos = rh_index.getWorldTranslation()

here i get an error

 

and reading docu, i see that this ( findNode ) returns vrNode and not vrdTransformNode.

And getWorldTranslation is a function of vrdTransformNode

 

I am Trying to resolve this...

Message 4 of 5

Ok, the script needs to be executed while in Varjo HMD mode and hands are visible.

Message 5 of 5
vredeye
in reply to: vredeye

Hi , i tried it in varjo , yes it works thanks

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report