WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 03-18-2010, 02:01 PM
imperialkat imperialkat is offline
Join Date: Jan 2010
Posts: 9
Why does tut_cone move on its own?

I'm trying to make a simulation of light coming from a laser diode (it's generally a cone shape). I figured I could use the tut_cone model and change its domensions. But when I change the cone's scale the cone will move somewhere else. Why won't it stay still?

Below is a program that illustrates my problem. The cone is supposed to be in front of the on-the-fly object there. The slider is only supposed to change the scale of the bottom of the cone (the circle).

import viz
import vizmenu
import math



viz.clearcolor(0.5, 0.5, 1)

#on-the-fly diode model
diode = viz.add( 'cylinder.wrl')
diode.color(0.5, 0.5, 0)
diode.scale(2, 0.1, 2)
diode.rotate(0, 0, 90)

diode1 = diode.add( 'cylinder.wrl')
diode1.color(0.5, 0, 0)
diode1.scale(.6, 1.5, .6)
diode1.setPosition(0, -.75, 0)

leg1 = diode.add('cylinder.wrl')
leg1.color(1, 0.3, 0.2)
leg1.scale(0.1, 7, 0.1)
leg1.setPosition(0.03, 0.5, 0)
leg2 = diode.add('cylinder.wrl')
leg2.color(1, 0.3, 0.2)
leg2.scale(0.1, 7, 0.1)
leg2.setPosition(-0.03, 0.5, 0)
leg3 = diode.add('cylinder.wrl')
leg3.color(1, 0.3, 0.2)
leg3.scale(0.1, 7, 0.1)
leg3.setPosition(0, 0.5, 0.03)
leg4 = diode.add('cylinder.wrl') 
leg4.color(1, 0.3, 0.2)
leg4.scale(0.1, 7, 0.1)
leg4.setPosition(0, 0.5, -0.03)

#Here's the problem area
cone = diode.add('tut_cone.wrl')
cone.translate(0, 0, 0)
cone.scale(1, 1, 1)

slider = viz.add(viz.SLIDER, parent=viz.SCREEN)
slider.setPosition(.5, .85)

def onSlider(obj,pos):
	if obj == slider:
		cone.setScale(pos, 1, pos)

Reply With Quote
Old 03-18-2010, 02:10 PM
farshizzo farshizzo is offline
WorldViz Team Member
Join Date: Mar 2003
Posts: 2,849
The geometry in that model is not centered about the origin, therefore applying a scale will inherently affect its position.

I suggest using the vizshape module to create a cone. Example:
import vizshape
cone = vizshape.addCone(radius=0.5,height=1)
Reply With Quote

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
how to move front and back nasr Vizard 2 05-11-2009 02:00 AM
how to move seperately? nasr Vizard 2 05-11-2009 01:57 AM
move animated camera around corner question nlfrnassimi Vizard 1 02-23-2009 09:45 AM
node3d.visible(viz.OFF) Problem Sandro Holzer Vizard 6 02-10-2009 06:20 AM
Move Objects Johannes Vizard 8 01-19-2005 10:15 AM

All times are GMT -7. The time now is 10:52 PM.

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