WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-07-2006, 06:41 PM
k_iwan k_iwan is offline
Member
 
Join Date: May 2006
Posts: 115
Trafffic ideas.. anyone?

While I'm still figuring out character animation, I'm facing another questions.
Perhaps someone can give me an idea how would I proceed??

This is a separate project which I'm *kind of* responsible for.

I'm trying to create a futuristic city-scape with traffic, flying vehicle in many different direction. The city is going to have 5 layers of traffics and 1 subway train.
Followings are my polygons budget;
1) max 100 polys for buildings, there will be at least 15-20 buildings. Tex res would be 512 - 1024.
2) max 100 polys for cars/taxis/buses/common vehicle, there will be at least 20 can be seen at a time (out of 40). Texture resolution would be at most 256. Detail are not necesarry because they would be moving quite fast anyway.
3) max 100 polys for the Train. Max Teture res 256.
4) other things, like street light, clothlines, neon signs, water tank, spaceport, would be at most also 100 polys, with max texture size
5)I'd like to hide more details by using Fog and Smoke, this way we could get away with lots of details and we could use even more lower texture.

The question; How would I simulate the traffic/flying vehicles in Vizard?
I did try to create moving box on a path and I did export it out in OSG format with the animation (with loop option) from Blender, but vizard only imported the model.
This could be a mistake from my end, I'm still investigating this.

Current Solution;I created at least 45 control points for path animation (for one box) in Vizard then I use the loop option and cubic bezier (to replicate exact animation in blender). Well it worked!!! All right!!!.
But how would I do say 20 boxes to follow each other like in traffic? If I need to have 4 layers of traffic, 20 cars, do I need to create at least 45 x 20 x 4 = 3600 control points for the paths?

I would be happy to hear if anyone has got a better idea how to accomplish this.

Kind Regards,
Iwan
Reply With Quote
  #2  
Old 08-08-2006, 10:45 AM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
Having the cars be controled on the Vizard level sounds like a good solution because it would it easer to make them interactive. You could define a list of control points for each layer of traffic and have each car start at different points in the paths. That is just 4 * 45 control points.
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #3  
Old 08-09-2006, 01:06 AM
k_iwan k_iwan is offline
Member
 
Join Date: May 2006
Posts: 115
Opinion Noted!!! 4 x 45 definitely sounds better than 4 x 45 x 20. I'll look into this. Thank you


Regards,
Iwan
Reply With Quote
  #4  
Old 08-09-2006, 02:22 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
How do you create the path's that the car's fly around? Are you using the ControlPoint objects? Do you have some workflow that allows you to define the points in your modeling package?
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #5  
Old 08-10-2006, 01:08 AM
k_iwan k_iwan is offline
Member
 
Join Date: May 2006
Posts: 115
Plan for flying path

Hi,

here are my preliminary options;

[1]
define all the control point object manually in Vizard. By setting camera to be in 3d-fps mode and display the coordinates every 1 sec. Write down all the required coordinates and later on translates them into control point objects. I did this method and it works! Took quite a while to get it running smoothly (I had to tweak the entire points aga in and again to make it smooth with viz.BEZIER_CUBIC option), but it works

[2] alternatively, I'm not quite sure how to do this in vizard. In blender I'll be crating a bezier path. I'll be putting say; 40-50 boxes in a path. I will later on export them all out as OSG format. These boxes (hopefully) will be recognised as Child object from main OSG file. I will use these boxes position as control points (again, I'm not sure how this can be done in vizard).
So, in short; Boxes (blender) -> Hide Boxes (in vizard) -> use boxes coordinates as Control point object... then attach the car/hovercraft/flying boats on these control points -> viz.LOOP and viz.BEZIER_CUBIC them all.

[3]
...using an array? I don't know if managing control point would be easier by using an array?


Regards,
Iwan

Last edited by k_iwan; 08-10-2006 at 01:11 AM.
Reply With Quote
  #6  
Old 08-10-2006, 09: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
  #7  
Old 08-13-2006, 04: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, 1259 views)
Reply With Quote
  #8  
Old 08-13-2006, 06: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, 1273 views)
Reply With Quote
  #9  
Old 08-14-2006, 09: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, 1253 views)
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #10  
Old 08-15-2006, 05: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
  #11  
Old 11-09-2006, 10: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
  #12  
Old 12-06-2006, 11:57 PM
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
  #13  
Old 12-07-2006, 10:18 AM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
Interesting idea to have the view look at a preceding model. A quick and dirty way to get some additional smoothing.

Of course, a smoother view can certenly be acheaved by tweeking the control points. When the view is jumpy, increase the time difference between the two points. If you want to keep the same time between points, you could also add a few more control points in the problem area.

Bellow is a simple script which has the setup for an animation path that a view could use.

Code:
import viz
viz.go()

viz.add('court.ive')

path = viz.add(viz.ANIMATION_PATH)

#Initialize an array of control points
positions = [ [0,1.8,-3], [-3,1.6,1], [3,1,-0.1], [0,0.3,0] ]

for x in range(0,len(positions)):
	#Add a ball at each control point and make it
	#semi-transparent, so the user can see where the
	#control points are
	b = viz.add('ball.wrl')
	b.setPosition(positions[x])
	b.alpha(0.2)
	#Add the control point to the animation path
	#at the new time
	cp = viz.add(viz.CONTROL_POINT)
	cp.setPosition(positions[x])
	path.add(cp,x*5 + 5)

path.translatemode(viz.CUBIC_BEZIER)
path.loop(viz.CIRCULAR)
path.computetangents()
path.autorotate(viz.ON)
path.play()

view = viz.addView()
view.eyeheight(0)
viz.link(path,view)

viz.MainWindow.viewpoint( view )
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #14  
Old 12-10-2006, 03:13 PM
k_iwan k_iwan is offline
Member
 
Join Date: May 2006
Posts: 115
Talking Smooth!!!

Nice!!! this one is somewhat smoother then our "look-at-the-quad/polygon" trick, I will try this one with more control points
Thank you for your explanation.

-e1-
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 02:50 PM.


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