Well you cant get dynamic atributes in expressions. Or you can but then youd skip the entire expression acceleration eingene.
you can call
float $x=sphere1.translateX
but you cant call
float $x=$var.translateX
even if the $var would contain sphere1.
This is becaus the notation means a very different thing.
sphere1.translateX is a direct connection to trenslateX part of sphere 1 visible in the hypergtaph as any connection. while visualy very close it is a TOTALY different thing altogether. Yo could use that only inside an expression node. Not in mel.
you could do this however! But i advice you to not do it! because it denies maya certain optimisation algorithms and is the expression is big enough this will slow maya down considderably. Its fine to ask maya this maybe 10 times but doing so 50 to 100 tmes is painfull to say the least.
Also getAttr runs out of context and can slow things down even more bcause it forces maya to evaluate the graphs differently than a node connection would! You can call mel in expressions but it sint very smart in most cases!
I was hoping to be able to use dynamic attributes, because my only (for me visible) other solution would be to use mel cmds in expressions. and that would not be very fast either.
i woul like to write a function that returns the coordinates of an object, something like that :
Mayabe it would be possible to write something like a (html) template for expressions ? If i could write a template that forms my expression proc after the user input is set, i could just direct link the expression attributes, like you said ... but there is no way to write a template in maya, or ????
Sorry, for my bad explanation, i think i am sitting to long at this problem trying to solve it. probably there is an easy answer to it. So i will try to explain the whole problem. I am trying to make some kind of battle script for maya. there are two groups and the user can choose how many warriors each group can have. the script shall do the following : every warrior has to search for an enemy thats close to him ( this is the reason for the getPos function) and kill him. of course there is more detail in it, but that should do the trick. if not i am just toooo sleepy right now...
that`s right, that's exactly what i try to do ! i am very interested in crowd systems, so i try to write my own small one for study reasons. what you described is my "basic" setup. afterwards i will try to give them some intelligence as well. i tried to speed it up, but i could not figure out how to use the "right" expression integration. right now, i am just trying to get the code done - quite slow, but none the less interesting
Xorand, how far have you gotten with your project (as per the basic steps of my previous post)?
Do you have the UI requesting group numbers working?
Have you finished the duplication (or import) procedure? Is it working?
How far along are you on the expression part? Where does it work or fail?
Also, have you checked out the DVD on Melbot Wars? (www.melbotwars.com) It contains some good techniques for battle-driven expressions and AI, such as attraction to opponent nodes, etc.
Well, I started messing with it over the summer for a time between other projects (its the whole reason I'm using maya, as other packages didn't give me this depth to play with). So far its just a rough working, characters are generated as simple spheres, given health and a position. I've got them running at each other, attacking, winning/losing, searching for a new enemy, and so forth.
Really only the guts of it to show off to my lecturers. I've got a year to spend on it, so I'll be introducing dynamic terrain (imported as geometry or as a displacement bitmap), with dynamic character traits such as fear, courage, etc. Once I've built up some characters to work with (most likely some knights, archers and demons) and a set of animation sets (typical running, fighting, death cycles) I quite fancy the idea of having the routine work out the camera movements too.
Of course everything is uniquely seeded, so each fight will hopefully be different.
Woah, that sounds awesome, Giragast! Imagine starting the scene with an extreme longshot camera, epic LOTR style, and having an expression that checks each character's health, and when one's about to die the camera switches to some powerful underview shot. Other triggers could switch views when something cool is happening (two or more vs. one, etc.) You could create an entirely computer generated battle movie! Sounds like a cool Siggraph paper!
Well, to be honest, the epic scale of characters at the beginning of the first LOTR movie was the principal inspiration for the project. I'm just glad that now as a student I get the chance to test my ideas.
As for the content of the simulation...it's pretty much limitless. All going according to plan, I'll build a UI for a potential user to import their own rigged characters, and set up a appropriate list of motion sets for each and which 'reply motion' it's enemy would respond with. Focusing on a particular battle and see the same set being played out behind them? Then simply change a variable and a battle set of the same length can take its place.
At this stage there are many options, like clumping selected motions together, and having the actual damage to health worked out separate from the visual blows dealt. Well...anything. Should be fun when it comes to testing one guy with a gattling gun vs. 1000 tribesmen with spears.
Tis a very exciting project for me, and I'm glad to see someone else here is about to go through the same set of pains I've been subjecting myself to
I am doing this for my bachelor, so i can not spend much time for this project ( but it is too big for a bachelor ). Because of that fact, i will implement only "basics". so far i have : a roman model, a working rig, working basic code for : ui, army setup, seek&destroy. everything is working tooo slow but fine right now i am working at implementing the animations, blending clips and stuff. i hope am done in 1 or 2 month...
@giragast: what do you mean by "[...] damage to health worked out separate from visual blows[...]" ? are you implementing some sort of "body damage zones" ?
@sboy: i saw the melbot cd, but i think the technique that was used there can not be used for the style of combat i want to have....
Well you will definitely want tod o this with the api and sckip expressions alltogether. Because the speed implications for all the tests is realy way out there. If you dont mind waiting 20 minutes per frame!
well, you are probably right, but i am more a designer than a programmer - and i do not have the time right now to go one level deeper mayabe for my master degree
I've no illusions about making it work out the battle in realtime, as expressions are simply too weak to handle the job. However I'm a scripter, not a programmer, so API is out of the question for me
I'll have enough trouble making terrain and models to learn C++, maybe over next summer
Yes well oviously, but thats not a solution, you could also bake the curves.
I mean its fine if it takes 10-20 seconds per frame. But if its starts taking longer than that then the entire stuff becomes painfull to say the least. This is very probable if you start putting 100 lines of mel in expressions that run 100 times during each frame.
Since you would need to do many many cycles of sims to obtain good values and to test that everything works properly. Now if it takes too long then your entire job will suffer and get to standstill. Wich will mean that the final development will take forever.
Now you would need to start thinking of innovative methods for acceleration!
Api is the ovious solution, for things like finding closet enemy. Or you could use particle data for this in wich case your iteration might be slightly faster but youd still be stuck with certain things.
Id dont mean everuhing should come from api just some of the critical ones.
The same problem arises with melbotwars too but its so simplistic that it deosent matter much!
right now, everything works fine, but slow. i think, i will have to get a closer lock at the c++ api of maya. if i encounter some problems again, i will for sure ask !