WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Models showing up (https://forum.worldviz.com/showthread.php?t=712)

Elizabeth S 08-30-2006 03:36 PM

Models showing up
 
I am importing a model of a car and each of its wheels separately into my script. I have created animation paths for both the car body and its wheels. When I run the script, some of the wheels may or may not appear in the scene. Running the script another time (without changing it at all) yields different results - either it may have randomly worked this time or a different wheel(s) may not appear. Any ideas what could be wrong? I'd greatly appreciate any suggestions to clear up this frustrating problem. Thanks.

k_iwan 08-31-2006 03:52 AM

Hi,

I do apologise, I'm not quite following your problem.
So, you created 5 animation paths? 1 animation path for the body and another 4 for the wheels? ... or only 2 paths? 1 for body and another one for the wheels?

Is it possible to make the wheels as children of the car, and use getchild command to spin the wheels? this way, you only need to create 1 path, for the car body. The wheels will follow wherever the car goes.

well, just an opinion.

Regards,
Iwan

farshizzo 08-31-2006 11:22 AM

Which version of Vizard are you running? Could you provide a simple script that recreates the problem?

Gladsomebeast 08-31-2006 11:26 AM

Like k_iwan, I am not sure why you can not see the wheels.

As suggested, you should probably make the wheels children of the car. You can do this in a modeling program or call the vizard .parent() fucntion.

Elizabeth S 08-31-2006 12:22 PM

Re: Models not showing up
 
Thanks for all your responses.
When I initially had the wheels as children of the car body, I could not get them to spin around the right pivot point. This is the reason I import them separately into my Vizard script. Is there a way to easily fix this problem.
Also, here is a trimmed-down script that I'm running....sorry for the length.

import viz
import math

viz.go()

def playAnimations():

#Add car and its wheels
Car = viz.add('Car.obj')
Car.scale(0.305,0.305,0.305)
Car.visible(viz.OFF)
CarwheelRF = viz.add('Carwheel2.obj')
CarwheelRF.scale(0.305,0.305,0.305)
CarwheelRF.translate(-0.92,0.35,1.09)
CarwheelRF.visible(viz.OFF)
CarwheelLF = viz.add('Carwheel2.obj')
CarwheelLF.scale(0.305,0.305,0.305)
CarwheelLF.translate(-2.379,0.35,1.09)
CarwheelLF.rotate(0,-1,0,180)
CarwheelLF.visible(viz.OFF)
CarwheelRB = viz.add('Carwheel2.obj')
CarwheelRB.scale(0.305,0.305,0.305)
CarwheelRB.translate(-0.92,0.35,3.45)
CarwheelRB.visible(viz.OFF)
CarwheelLB = viz.add('Carwheel2.obj')
CarwheelLB.scale(0.305,0.305,0.305)
CarwheelLB.translate(-2.379,0.35,3.45)
CarwheelLB.rotate(0,-1,0,180)
CarwheelLB.visible(viz.OFF)

#Initialize animation paths
CarpathBody = viz.add(viz.ANIMATION_PATH)
CarpathRWF = viz.add(viz.ANIMATION_PATH)
CarpathLWF = viz.add(viz.ANIMATION_PATH)
CarpathRWB = viz.add(viz.ANIMATION_PATH)
CarpathLWB = viz.add(viz.ANIMATION_PATH)
Paths = [CarpathBody,CarpathRWF,CarpathLWF,CarpathRWB,Carpa thLWB]

#Initializing velocity and ttc arrays and using them to find distances
velocity = [10,15,20,25,30]
ttc = [2,2.25,2.5,2.75,3,3.25,3.5,3.75,4,4.25,4.5,4.75,5, 5.25,5.5,5.75,6,6.25,6.5,
6.75,7,7.25,7.5,7.75,8,8.25,8.5,8.75,9,9.25,9.5,9. 75,10]
ttc1 = 5
velocity1 = 4
distance = velocity[velocity1-1]*ttc[ttc1-1]*0.44704
distance2 = 0

#Setting positions of car and its wheels for the animation paths -
#Alternating starting and ending distances for each model in this order:
#Car body, Right wheel front, Left wheel front, Right wheel back,
#Left wheel back
Positions = [ [0,0,distance],[0,0,distance2],
[-0.92,0.35,1.09+distance],[-0.92,0.35,1.09+distance2],
[-2.379,0.35,1.09+distance],[-2.379,0.35,1.09+distance2],
[-0.92,0.35,3.45+distance], [-0.92,0.35,3.45+distance2],
[-2.379,0.35,3.45+distance],[-2.379,0.35,3.45+distance2] ]

#Add the control points to the animation path
for x in range(0,len(Paths)):
cp = viz.add(viz.CONTROL_POINT)
cp.translate(Positions[2*x])
Paths[x].add(cp,0)
cp2 = viz.add(viz.CONTROL_POINT)
cp2.translate(Positions[2*x+1])
Paths[x].add(cp2,ttc[ttc1])

#Set the wheels spinning
Carrotations = (distance - distance2)/2.011
Carfullrotations = math.floor(Carrotations)
Cardegreesrotations = Carfullrotations*360 + (Carrotations - Carfullrotations)*360
Carrotatespeed = Cardegreesrotations/ttc1
CarwheelRF.spin(1,0,0,-Carrotatespeed)
CarwheelLF.spin(1,0,0,Carrotatespeed)
CarwheelRB.spin(1,0,0,-Carrotatespeed)
CarwheelLB.spin(1,0,0,Carrotatespeed)

#Link the car and its wheels to the path; play the paths
Car.link(Paths[0])
CarwheelRF.link(Paths[1])
CarwheelLF.link(Paths[2])
CarwheelRB.link(Paths[3])
CarwheelLB.link(Paths[4])
Car.visible(viz.ON)
CarwheelRF.visible(viz.ON)
CarwheelLF.visible(viz.ON)
CarwheelRB.visible(viz.ON)
CarwheelLB.visible(viz.ON)
Paths[0].play()
Paths[1].play()
Paths[2].play()
Paths[3].play()
Paths[4].play()
Paths[0].loop(viz.LOOP)
Paths[1].loop(viz.LOOP)
Paths[2].loop(viz.LOOP)
Paths[3].loop(viz.LOOP)
Paths[4].loop(viz.LOOP)

def mykeyboard(whichKey):
#to quit the script
if whichKey == viz.KEY_ESCAPE:
print 'Esc key pressed'
viz.quit();
#to play the set of animations
elif whichKey == viz.KEY_RETURN:
playAnimations();
#otherwise do nothing
else:
print 'Incorrect key pressed'


viz.callback(viz.KEYDOWN_EVENT, mykeyboard)

Gladsomebeast 08-31-2006 12:56 PM

When I replace the Car.obj with logo.wrl and the Carwheel2.obj with ball.wrl things work well. This suggests that there is something going on with your models.

You can still set the parent of the seperate wheel objects in Vizard. This will solve the pivot point problem so that they will spin around their centers.

k_iwan 08-31-2006 06:49 PM

@ Elizabeth S

If you'd like, I could have a look into your model. Send them to me/post the zip file in this thread, also It would be great if you could send the objects in OBJ format.

Regards,
k_iwan

Elizabeth S 09-06-2006 11:17 AM

Here are the models
 
1 Attachment(s)
Attached are my models.

Thanks!

Elizabeth S 09-06-2006 12:49 PM

Got it!
 
So far, it seems that the problem was solved by parenting the wheels to the car. Thanks to all for the help!

k_iwan 09-06-2006 06:11 PM

Great!
 
@Elizabeth;

Nice Car! :) you solved the problem? Cool!
I had a look into your model, everything seems fine, no inverted normals or anything that would make your object dissapears.

Have a great day, all the best in your project!!!


Regards,
Iwan


All times are GMT -7. The time now is 02:12 PM.

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