CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 02-01-2013, 02:45 PM   #1
elay
Frequenter
portfolio
elay
freelancer
ecuador, Egypt
 
Join Date: Jun 2005
Posts: 138
Export Animation Data in a xml File

Hi does anybody have a idea how to export the velocity data of my animated object wich is animated via attach to moition path in a XML File.

What i need is an xml File with the following information.

I have a komplex Path animation with a lot of straight and kurve parts like a road.
And know i need all the Position and the Velocity values on my Pathlenght.

Lets say:
frame 0-50 = x mph ( this is a Straight Part )
frame 50-120 = x mph ( this is a Kurve Part )
frame 120-170 = x mph ( this is a Straight Part )
frame 170-220 = x mph ( this is a Kurve Part )

.. and so on.

Maybe someone have a idea of to export this information to a XML File.

The reason why i need this is that i need to synchronisize the Movement of my object along the path with some other animated Grafik stuff.And i dont want to do it manually, because when i have a xml with all these data it can be do automatically.

thanks in advance
 
Old 02-01-2013, 02:58 PM   #2
uiron
neglostyti
 
uiron's Avatar
portfolio
Viktoras Makauskas
Lithuania
 
Join Date: Jun 2005
Posts: 608
well, to my understanding, if you don't need to have very complex rules of calculating average velocity, you could sample position in intervals, and calculate sampled velocities first (velocity(now) = position(now)-position(before)/time(between now and before)).

When you have those velocities sample, say, at the start of each frame, calculating average in a given time range is really not that hard
__________________
Victor
ngskintools.com - skinning plugin for Autodesk Maya
 
Old 02-01-2013, 05:30 PM   #3
elay
Frequenter
portfolio
elay
freelancer
ecuador, Egypt
 
Join Date: Jun 2005
Posts: 138
Maybe this works but i am not a programmer.
Mybe you or someone can help me, or is ther a script wich can do this ??

thanks in advance.
 
Old 02-01-2013, 07:40 PM   #4
uiron
neglostyti
 
uiron's Avatar
portfolio
Viktoras Makauskas
Lithuania
 
Join Date: Jun 2005
Posts: 608
well you posted in programming section, so I naturally assumed responded like programmer to programmer.
I don't know if there are tools that do that. I guess you'll have to find someone to code that for you.
__________________
Victor
ngskintools.com - skinning plugin for Autodesk Maya
 
Old 02-02-2013, 12:06 AM   #5
Nyro
Lurking
 
Nyro's Avatar
portfolio
A. D.
Vertex Slinger
Munich, Germany
 
Join Date: Dec 2006
Posts: 1,436
not that hard to do, at least if I understood your request correctly.

Select your animated object(s) for which you want to read out the velocity data, edit the animation start and end times for which you want the readout, then run this code:

Code:
$selection = `ls -sl`; if(size($selection)) { int $startTime = `playbackOptions -q -ast`; int $endTime = `playbackOptions -q -aet`; // set file here string $fileName = "C:/velocity_Readout.xml"; int $f = `fopen $fileName "w"`; if($f) { for($object in $selection) { // open <object> element fprint $f ("<object name=\"" + $object + "\">\n"); for($i = $startTime; $i <= $endTime; $i++) { // open <frame> element fprint $f ("\t<frame time=\"" + $i + "\">\n"); currentTime ($i - 1); float $posB[] = `xform -q -ws -t $object`; currentTime $i; float $posN[] = `xform -q -ws -t $object`; float $dX = abs($posN[0] - $posB[0]); float $dY = abs($posN[1] - $posB[1]); float $dZ = abs($posN[2] - $posB[2]); float $sqrX = `pow $dX 2.0`; float $sqrY = `pow $dY 2.0`; float $sqrZ = `pow $dZ 2.0`; float $velocity = sqrt( $sqrX + $sqrY + $sqrZ ); // add <velocity> element fprint $f ("\t\t<velocity>" + $velocity + "</velocity>\n"); // add <vX>, <vY>, <vZ> elements fprint $f ("\t\t<vX>" + $dX + "</vX>\n"); fprint $f ("\t\t<vY>" + $dY + "</vY>\n"); fprint $f ("\t\t<vZ>" + $dY + "</vZ>\n"); // close <frame> element fprint $f ("\t</frame>\n"); fflush $f; } // close <object> element fprint $f ("</object>\n"); } } fclose $f; } else { print("Select an object first!\n"); }


Would create a file "velocity_Readout.xml" that looks something like this:
Code:
<object name="pSphere1"> <frame time="1"> <velocity>0</velocity> <vX>0</vX> <vY>0</vY> <vZ>0</vZ> </frame> <frame time="2"> <velocity>4.293893631</velocity> <vX>0.4498593883</vX> <vY>0.2650591258</vY> <vZ>0.2650591258</vZ> </frame> <frame time="3"> <velocity>8.718324661</velocity> <vX>3.149014485</vX> <vY>1.855413374</vY> <vZ>1.855413374</vZ> </frame> <frame time="4"> <velocity>10.79741718</velocity> <vX>8.547326234</vX> <vY>5.036122897</vY> <vZ>5.036122897</vZ> </frame> <frame time="5"> <velocity>36.11181577</velocity> <vX>18.93799437</vX> <vY>18.26306014</vY> <vZ>18.26306014</vZ> </frame> <frame time="6"> <velocity>61.45925345</velocity> <vX>26.53348449</vX> <vY>31.0300431</vY> <vZ>31.0300431</vZ> </frame> <frame time="7"> <velocity>46.06580738</velocity> <vX>25.14678085</vX> <vY>29.62805733</vY> <vZ>29.62805733</vZ> </frame> <frame time="8"> <velocity>83.58976132</velocity> <vX>23.70417233</vX> <vY>27.10068841</vY> <vZ>27.10068841</vZ> </frame> <frame time="9"> <velocity>78.00125813</velocity> <vX>12.97446499</vX> <vY>14.99862128</vY> <vZ>14.99862128</vZ> </frame> </object>


Disclaimer: though I think my math is correct, I'm notoriously bad at such things, so you may want to double check the results.

Feel free to modify the xml structure to your needs.
 
Old 02-02-2013, 02:31 AM   #6
Chrisgibbs
Veteran
portfolio
Chris Gibbs
Palmetto bay, USA
 
Join Date: May 2012
Posts: 32
Quote:
Originally Posted by Nyro
...I think my math is correct, I'm notoriously bad at such things, so you may want to double check the results.


"I concur. Your logic is sound." said Spock with a bashful giigle.
 
Old 02-02-2013, 02:31 AM   #7
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:25 PM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.