Конверсия Instancer’а в геометрию
Type: Python Script (py) Name: sag_instancerToGeometry Version: 1.1 Released: 2010.06.11 Download
Практически каждый раз когда использую instancer для размножения геометрии по частицам, в итоге неминуемо хочется перевести полученный результат в обычные объекты с ключевой анимацией, дабы подправить отдельные из них или удалить вовсе.
Вот наконец-то собрался и написал утилиту для решения этой задачи.

Использование:
- файл sag_instancerToGeometry.py надо положить в любую папку, откуда Maya читает скрипты;
- запустить python-скрипт:
from sag_instancerToGeometry import *
sag_instancerToGeometry()
- выделить instancer‘ы, которые нужно сконвертировать и нажать Convert в окне утилиты. Будет произведена конвертация, удаление static channels и применен euler filter.
Опции:
Make Duplicates/Instances – в первом случае созданные объекты будут независимыми дубликатами, во втором – инстансами от исходного объекта (который воткнут в instancer);
Start from Current Frame – если включено, вне зависимости от таймлайна или выставленного вручную диапазона фреймов, начнет конвертацию с текущего фрейма;
Playback/Custom Range – в первом случае диапазон фреймов будет взят из таймлайна, во втором – можно ввести значения начального и конечного фрейма;
Convert – [...описание оказалось столь длинным и замороченным, что было удалено редактором...]
Help – линк на эту страницу.
Примечания:
Разумеется, есть ряд ограничений и попросту недоработок… Из тех что могу сейчас отметить:
- вращения конвертятся только из канала Rotation instancer‘а, всякие Aim я пока не учитывал и пока даже не знаю буду ли вообще, потому как в принципе наиболее используемую ориентацию объектов по velocity можно легко написать экспрешеном в тот же Rotation, к примеру:
float $vel[] = velocity;
float $ang[] = `angleBetween -euler -v1 1 0 0 -v2 $vel[0] $vel[1] $vel[2]`;
rotPP = <<$ang[0], $ang[1], $ang[2]>>;
- если на какой-то из каналов instancer‘а назначен “необычный” атрибут, который не получится прочитать – скрипт работать не будет. На данный момент я не могу себе представить зачем кто-то будет такое делать, хотя в ходе тестов столкнулся с тем, что некто поставил на Scale атрибут Ramp Velocity и тот не читался утилитой. Вероятно могут быть проблемы с какими-то полезными атрибутами, так что тут как раз возможность для апдейтов.
- для правильной передачи вращений с учетом разных rotationOrder приходится фризить rotate каналы воткнутых в instancer объектов. Соответственно, если они проанимированы ключами или экспрешеном, или попросту залочены – скрипт завалится. Смысла крутить исходный объект вместо того чтобы крутить как полагается партикловыми экспрешенами лично я не вижу, поэтому этот нюанс тоже не решался.
В общем, пробуйте, пользуйтесь и пишите багРепорты/пожелания – я постараюсь их исправить/добавить.


21 Responses to “Конверсия Instancer’а в геометрию”
hello,friend,can you send python script to me
mail:yuyu8401936@hotmail.com
Отличная утилита!!!
I’m getting a “Bad Magic Number” error when trying to import.
Can you send me the script please? dans@floathybrid.com
Thanks.
I’ve put original .py instead of compiled .pyc, so there should be no issues anymore.
Положил исходный .py вместо скомпилированного .pyc, поэтому проблем больше не должно быть.
this is awesome man. thanks a lot.
Возможно вас заинтересует http://somesanctus.blogspot.com/2010/08/smartrotation.html
и вы пересмотрите свое отношение к каналам Aim и Up
это – пожелание включить их в утилитую.
Да, спасибо. Я в курсе что это нужно и важно, просто пока не успел обдумать как это все конвертить во вращения.
Whenever i try to source this script I keep getting a // Error: invalid directive // I’ve tried putting the script in every script folder there is in maya. What am i doing wrong? I use maya 2010 btw.
Have you tried the latest .py version? I heard old .pyc caused problems on different OSes, so I’ve put .py eventually.
Hey thanks for the quick reply, i figured out the problem, In the script editor i forgot to choose the Python menu before loading the script.
Now I have loaded the script with no errors, it seems to have loaded just fine, now my question is… Shouldn’t there apear a GUI box whenever i load this script? cause nothing happens.
Am i missing a step or something? Pardon my noobness, I’ve never loaded a python script before.
Oh I forgot to mention that after i loaded the script I ran the “from sag_instancerToGeometry import *
sag_instancerToGeometry()” lines, and a GUI box apears, but it only contains “Start from Current Frame” button.
We are running linux here at the company, perhaps thats the reason, rest of the GUI is missing?
well I guess you could just delete my posts, I got it to work now for some odd reason. = /
Thanks for the help btw.
This tool is really neat at creating objects that translates along with the instanced objects, my question now is… it is possible for it to simulate the rotation of each instanced object/particle as well?
Good that everything is working eventually.
Script bakes rotations, but from ‘Rotation’ channel only – no aims. There’s a mention about that in notes above. So, if you have it mapped – everything should be fine, if you use aims – you should try to convert them into rotations for baking or rotate baked objects afterward.
Alright thanks alot for the tip Sagroth, very appreciated.
Love the script. Thanks for putting it out there!
Your script works beautifully. Thank you so much for making it available. I very often have to create instances on a surface which is the goal of the particles. The instances Aim Direction is connected to Goal World Normal 0 PP so that they get oriented along the surface normal. Is there a way to transfer the instances orientation to the Rotation channel so that your script evaluates it?
Thank you!
Yeap, you just need to use your goalWorldNormal0PP instead of velocity in the angleBetween formula I wrote above. And I think goalWorldNormal0PP won’t get generated at birth, so put this script into runtime expression instead of creation.
Thanks so much Sagroth. It works great!!
Thanks a lot, It saved me quite a lot of time today
you are a great person!!!
Leave a Reply