WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-28-2005, 02:06 PM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
locate a certain point in the scene 3D

Is it possible to locate a certain point in the scene by clicking on it with the mouse?

I would like to use this to position my objects (e.g. I click on a certain position with my mouse and get the position printed) then I cann translate my object there...

Code:
def mouse...

	if button == viz.MOUSEBUTTON_RIGHT:
		line = viz.screentoworld(viz.mousepos())
		begin = line[:3]
		end = line[3:]
		viz.startlayer(viz.LINE_LOOP)
		viz.vertex(begin)
		viz.vertex(end)
		cube = viz.endlayer()
		print end
Johannes

P.S. out of certain reasons I don't want to use the stage.
Reply With Quote
  #2  
Old 02-28-2005, 02:09 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
The code you supplied pretty much does what you want. All you have to do is pick a point on the line and translate the object there. Let me know if I misunderstood your question.
Reply With Quote
  #3  
Old 02-28-2005, 02:29 PM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
Well, maybe I'm just not good enough to pick a point on the line (because the line is so small....).
I just want to use this to get the position of a certain point in the scene...

Code:
def mouseclick(button):
	global beginPos0502, line0503
	pos = viz.mousepos()
	print 'mouse is currently at',pos
	if button == viz.MOUSEBUTTON_RIGHT:
		line = viz.screentoworld(viz.mousepos())
		begin = line[:3]
		end = line[3:]
		viz.startlayer(viz.LINE_LOOP)
		viz.vertex(begin)
		viz.vertex(end)
		line0503 = viz.endlayer()
		print end
	if button == viz.MOUSEBUTTON_LEFT:
		object = viz.pick()
		#if object.valid() and object != arrow:
		if (object.valid() and object ==airtrack.slider):
			pos = object.get(viz.POSITION)
			beginPos0502=pos[0]
			viz.mousedata(viz.ABSOLUTE,viz.ABSOLUTE)
			viz.callback(viz.MOUSEMOVE_EVENT, mymousemove)
			viz.mouse(viz.OFF)
	if button == viz.MOUSEBUTTON_MIDDLE:
		print 'middle'
		object = viz.pick()
		if (object.valid()and object ==line0503):
			print object.get(viz.POSITION)
Reply With Quote
  #4  
Old 02-28-2005, 02:46 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Clicking on the screen can correspond to an infinite number of points. Do you want a point that is a certain distance from the user? Do you want a point that intersects with an object?
Reply With Quote
  #5  
Old 03-01-2005, 08:09 AM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
Thank you, I found a way to do it. Your suggestions (I used the intersect-approach) helped!
Johannes

P.S. is there a way to bring self illumination (from 3ds) to vizard?
Did not find anything in the help-file

viz.TEXGEN
Automatically generate texture coordinates to simulate sphere mapping (reflective surface).

viz.TEXMIPMAP
Linear and mipmap filtering for texture magnification and minification.

viz.TEXNEAREST
Do not perform mipmapping of the texture.

viz.MODULATE
Force modulation of texture with any scene lights and the surfaces underlying material color properties.

viz.DECAL
Display the exact bitmap as the surface texture.

viz.ENVIRONMENT_MAP
Automatically generate texture coordinates to reflect an environment map (aka cube mapping).
Reply With Quote
  #6  
Old 03-01-2005, 08:12 AM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
Just thought I poste the code of the "point-finder" in case somebody else likes to use it:
Code:
def mouseclick(button):
	if button == viz.MOUSEBUTTON_MIDDLE:
		print 'middle'
		line = viz.screentoworld(viz.mousepos())
		begin = line[:3]
		end = line[3:]
		#viz.startlayer(viz.LINE_LOOP)
		#viz.vertex(begin)
		#viz.vertex(end)
		#line0503 = viz.endlayer()
		
		info = table.intersect(begin,end)
		if info.intersected:
			print 'p1:',info.intersectPoint
Reply With Quote
  #7  
Old 03-01-2005, 10:16 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
To find the intersect point you can also use the pick command.
Code:
info = viz.pick(1)
if info.intersected:
	print 'p1:',info.intersectPoint
Have you tried disabling lighting on the object?
Code:
object.disable(viz.LIGHTING)
This will prevent lighting calculations from being performed on the object, which will make it brighter.
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


All times are GMT -7. The time now is 08:37 AM.


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