Expression fever

hi there,

i bet they are just more beginner questions, but i can't get my fingers on it :

  1. i need to get a list of certain objects inside an expression, that means i can't use the ls command (to slow)... are ther other possibilities ?

  2. just a syntax question, how is the correct syntax for this code :
    float $x = $name.tranxlateX;

where $name is a string ... ??
of course inside an expression as well !
Thx for your time,

xorand

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!

float $x=

Thanks for your quick replay !

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 :

proc float[] getPos (string $object)
{
[...]
return $pos[];
}

xform would be a solution, but it would slow down everything right ?

But i need a highly flexible construct ... dynamic attributes...

thanks anyways,

xorand

I have another thought about that problem :

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 ????

greetings,

xorand

OK either im having a low iq day or then everyone else is lets asume i am!

Explain What and why you are doing what! What you expect and why you think it must be so. Exactly leave nothing out...

Its not very productive tring to explain solutions to users who have no clue on how they should go about and then they still insist they do.

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...

thx so far,

xorand

Hey Xorand....Your script (expression) sounds really cool! Let me see if I understand what you need, so I can brainstorm with you. Are you trying to:

First have a UI requester pop up asking the user how many warriors he wants in each group?

Then you have a procedure which generates (duplicates or loads in) the number of warriors, randomly generating their initial position?

Then you press play and each warrior in each group seeks out the closest warrior in the "enemy" group and begins it's AI sequence (attack, etc.)?

Or am I way off base?

Hey Sboy,

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

haha, of all the things....

I'm doing this warrior thing for my uni degree

automated character generation, attack cycles, deaths, etc, etc until one man is left standing

good luck with yours

Cool Xorand, and Giragast!

Xorand, how far have you gotten with your project (as per the basic steps of my previous post)?

  1. Do you have the UI requesting group numbers working?

  2. Have you finished the duplication (or import) procedure? Is it working?

  3. 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.

Giragast, how far along are you?

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.

Should be nice for a resume at least

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

Hehe, i was inspired from weta's massive as well

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

Unfortunately, API seems to be the way to go.

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

well, you can always render it (with the cool camera angle idea) and play it back real-time! Or else it's battling cubes for you guys!

Xorand, is there any particular part of the code you're stuck on, or is it working okay but too slow?

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!

Hey Sboy,

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 !