WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-10-2006, 10:35 AM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
I like the workflow of your second alternative, defining the positions of the control points in the modeling software. You could create a naming convention for the child objects in Blender, get their positions with the <VizNode>.getChild() fucntion in a loop and automaticly generate the paths.

Code:
CP_COUNT = 50
CONTROLPOINT_PREFEX = 'control_point'

controlPointList = []
def generateControlPoints():
	for cpNumber in range( CP_COUNT ):
		pointNode = bigMap.getChild( CONTROLPOINT_PREFEX + str( cpNumber ) )
		if pointNode != None:
			cp = viz.addControlPoint()
			cp.translate( pointNode.getPosition() )
			cp.rotatequat( pointNode.getQuat() )
			controlPointList.append( cp )
		else:
			print 'Missing control point node: ' + CONTROLPOINT_PREFEX + str( cpNumber )

Does anyone else have a solution to this common task?
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #2  
Old 08-13-2006, 05:58 AM
k_iwan k_iwan is offline
Member
 
Join Date: May 2006
Posts: 115
It doesn't work?

Hi,

I created a small scene with boxes as control pounts the name os the boxes are layera1 ... layera17. I did implement you code snippet given earlier and apparently for some reason it couldn't find the object(boxes).
When I printed out controlPointList it gave me only [].

I don't think it is necessary to name object layera1 as 'layera'1 in blender?

I attached the vizard file for anyone who wants to have a go at it. Use Mouse to look around and up/down key to accelerate or moving back.

I will have another go and will try a different approach. I will try to find the unit relation between blender and vizard; eg. 1unit blender = 1unit Vizard, then find all the location manually. Then perhaps, for the control point do something like

cp1 = viz.addControlPoint()
cp1.translate(value x1 * scalingRatio, value y1 * scalingRatio,value z1 * scalingRatio)
cp1.translatemode(viz.LINEAR)
...
cp17 = viz.addControlPoint()
cp17.translate(value x17 * scalingRatio, value y17 * scalingRatio,value z17 * scalingRatio)
cp17.translatemode(viz.LINEAR)

Usually I always scale up my scene 10 times bigger, so by having scalingRatio = 10, it would change the position of the control points as well.
Attached Files
File Type: zip traffic_demo.zip (129.7 KB, 2604 views)
Reply With Quote
  #3  
Old 08-13-2006, 07:02 AM
k_iwan k_iwan is offline
Member
 
Join Date: May 2006
Posts: 115
Smile Additional Information on Vizard unit vs Blender Unit

Hi (again),


in Blender;
I created a monkey head at (0,0,0) and a box at (3,3,3)
Monkey and cube have scaling ratio of 1.

In Vizard;
Vizard 3d preview has different grid size, so It's hard for me to justify based on grid size.
But, when I position the camera at (3,3,3) I find myself at the centre of the Cube!!! I attached the files, use the wireframe mode (F3) to see yourself in the centre of the Cube!!!

Hence, from my short experiment, I can conclude (for now) that;
1 unit in Blender == 1 Unit in Vizard!!!!!!!

(the reason why I did this because different 3d engine sometime has different unit ratio eg. 32 unit in Quark map editor = 1 unit in Torque Game Engine)
Attached Files
File Type: zip unit_test.zip (58.1 KB, 2703 views)
Reply With Quote
  #4  
Old 08-14-2006, 10:12 AM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
I made a couple of changes in the traffic.py file. I marked them with 'xxx', so you can search for them. Also, check out the camera handler tutorial for some useful viewpoint control code.
Attached Files
File Type: zip traffic.zip (132.8 KB, 2712 views)
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #5  
Old 08-15-2006, 06:16 AM
k_iwan k_iwan is offline
Member
 
Join Date: May 2006
Posts: 115
Hi,

I had look into it.. and now I know why it didn't work in the first place. I was missing a funtion to generate the control point also I didn't specify time, that's why Vizard was complaining about missing arguments.

I will look into viewpoint tutorial later. Thanks for pointing out where I went
wrong!


Regards,
Iwan
Reply With Quote
  #6  
Old 11-09-2006, 11:04 PM
k_iwan k_iwan is offline
Member
 
Join Date: May 2006
Posts: 115
Question Path animation with lots of control points.....

Hi,

I got the script working with lots of tweaking. The value of x, y, z in Blender translates as x, z, y in Vizard. With my control points in OSG format I have to make it as x, -z, y in vizard, with other format.... different xyz coordinates.

It runs. It works fine. Now in my huge environment, I have 1200 control points that the camera will have to go though. I used viz.CUBIC_BEZIER and viz.BEZIER but none of them give me smooth curve results. It seems like at every single control points the camera tends to jerk a little bit before moving to the next control point.

i.e between point 1 to point 2 the animation is smooth, but by the time it hits point 2 the camera angle move quickly to the direction of point 3. This quick movement doesn't blend from the previous camera orientation smoothly.

Is there another method to get a smoother result? perhaps cubic_bezier on top of cubic_bezier?



Thank you,
k_Iwan
Reply With Quote
  #7  
Old 12-07-2006, 12:57 AM
k_iwan k_iwan is offline
Member
 
Join Date: May 2006
Posts: 115
Talking smoothing out "<path>.autorotate" animation

Okay, we did something to smooth out our path animation with "<path>.autorotate" enabled.

It was like this, create a path that composed of lots and lots of nodes (as required), attach camera and a quad/polygon (make this invisible later) on the same path. Then, during animation play, get the quad to run about 1-3 nodes/control points in advance before the camera animation starts. and set the camera to "lookat" the quad.

the only drawback is... after 1st or 2nd lap, somehow the quad is behind the camera therefore, going backwards. A coding problem from our end, I'm sure.

anyway... hope this helps anyone who's working out with path animation.

Regards,
Iwan
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:17 PM.


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