WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-30-2010, 01:58 PM
Salvar Salvar is offline
Member
 
Join Date: Nov 2010
Posts: 20
Trouble picking text3d objects

Hello.

I am currently working on a Vizard project where a bunch of text3d objects are floating around in space, and the user can navigate forwards and backwards through the space. When a valid object is picked with the mouse, viz.window.displayHTML is called with a particular value.

The problem is, picking objects seems to be incredibly finicky. I'm not sure if it's just because it's text3d objects or if picking 3d objects is always like this, but I need to click the same object something like 1-20 times in different places to register a valid object pick.

Are text3d objects like swiss cheese?
Reply With Quote
  #2  
Old 12-01-2010, 12:32 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Each letter and the bounding box area around each letter can be picked. If you are outside that bounding box or between letters the pick won't register.

If you want to be able to pick in between letters you could create a quad, place it near the text, and hide it. Then you could check if that get's picked:
Code:
import viz
import vizact

viz.go()

viz.clearcolor(viz.SKYBLUE)

text = viz.addText('Pick Me',pos = [-1.5,1.5,5])

size = text.getBoundingBox(viz.REL_LOCAL).size

quad = viz.addTexQuad(parent=text)
quad.setPosition(size[0]/2,size[1]/2,-.01)
quad.setScale(size[0],size[1])
quad.alpha(0.2)

vizact.onpick(quad,viz.logNotice,'You picked the text')

viz.mouse(viz.OFF)
Reply With Quote
  #3  
Old 12-01-2010, 01:52 PM
Salvar Salvar is offline
Member
 
Join Date: Nov 2010
Posts: 20
Quote:
Originally Posted by Jeff View Post
Each letter and the bounding box area around each letter can be picked. If you are outside that bounding box or between letters the pick won't register.

If you want to be able to pick in between letters you could create a quad, place it near the text, and hide it. Then you could check if that get's picked:
Code:
import viz
import vizact

viz.go()

viz.clearcolor(viz.SKYBLUE)

text = viz.addText('Pick Me',pos = [-1.5,1.5,5])

size = text.getBoundingBox(viz.REL_LOCAL).size

quad = viz.addTexQuad(parent=text)
quad.setPosition(size[0]/2,size[1]/2,-.01)
quad.setScale(size[0],size[1])
quad.alpha(0.2)

vizact.onpick(quad,viz.logNotice,'You picked the text')

viz.mouse(viz.OFF)
Thanks for the reply.

I had that idea myself actually, but that created another problem. As clicking on the text object runs a function that parses the text, finds a URL, and loads it on the screen, I had the problem of referencing the parent text object when I click not the text object, but the quad "underneath".

Say in your example, how could you access the getMessage() method of the parent? I've tried a lot of things but I'm probably just missing the right one.
Reply With Quote
  #4  
Old 12-01-2010, 02:47 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You could modify the code with the following:
Code:
def onQuadPick():
	textParent = quad.getParents()[0]
	viz.logNotice(textParent.getMessage())
	
vizact.onpick(quad,onQuadPick)
Reply With Quote
  #5  
Old 12-01-2010, 04:07 PM
Salvar Salvar is offline
Member
 
Join Date: Nov 2010
Posts: 20
Quote:
Originally Posted by Jeff View Post
You could modify the code with the following:
Code:
def onQuadPick():
	textParent = quad.getParents()[0]
	viz.logNotice(textParent.getMessage())
	
vizact.onpick(quad,onQuadPick)
Thank you very much sir, my problem is solved. It was the getparents()[0] and addTexQuad(parent=text) that I was looking for.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Semi-circle array containing target and distractor objects ptjt255 Vizard 3 08-04-2009 04:09 AM
Lightwave objects rotation problem hosier Vizard 6 02-13-2009 01:04 PM
picking problem... k_iwan Vizard 2 07-27-2007 08:57 PM
Picking on-the-fly objects Jerry Vizard 1 01-19-2007 01:29 PM
Could not find plugin to load objects... halley Vizard 1 05-30-2006 12:01 PM


All times are GMT -7. The time now is 10:44 AM.


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