![]() |
|
|
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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) |
|
#4
|
|||
|
|||
|
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.
__________________
Paul Elliott WorldViz LLC |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
|||
|
|||
|
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 |
|
#7
|
|||
|
|||
|
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 |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|