Matrix Script

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  05 May 2006
Matrix Script

I am working on a short animation movie for class which has to be done in 5 weeks. I had an idea to make a small script to have all the objects in the scene scroll down with green 1's and 0's.

Basically the script would have to be as time increases, all materials in the scene would move down along the Y axis. Apply everything in the scene with a transparent material of green binary.

I haven't used Xpresso or C.O.F.F.E.E. before but I heard the language resembles visual basic and C++. Anyways, I came up with something rough like this;

main(doc,op)
{

var Xmap = 0;

var Tval = 0;

Xmap = $.uvmapingstuff.posx

Tval = "time"

for i = Tval - 1 then

Xmap = Xmap + 1


}

It obviously doesn't work because some of the syntax isn't recognized in this program.

Can anyone point me in the right direction? I would normally try to learn from scratch but this assignment has to be done in 5 weeks, and scripting is just 5% of my project.

Last edited by Rathma : 05 May 2006 at 12:25 AM.
 
  05 May 2006
Well you're not that far off from what you want to do.

i'd recommend downloading the COFFEE SDK docs to help you get started form www.plugincafe.com

in the meanwhile here's a few pointers:

when you predeclare your variables in coffee you dont' need to assign them at that time, so you can drop the =0 on those vars to begin with.

the line :

Xmap = $.uvmapingstuff.posx

you can do the following way

first it's a parameter of an object you want. so you need to get the object. as it's a tag you can do


  var tag = op->GetFirstTag(); //get the first tag on the object
  while (tag)// loop through the tags till we find a texture tag
  {
    if (tag->IsInstanceOf(Ttexture)) { //add your code here }
  
    tag = tag->GetNext();
  }
  


that will loop through the tags on the object and you can do something to each tag that's a texture tag.

so we'll use your line : Xmap = $.uvmapingstuff.posx and just change it a bit so it suits coffee (which is very easy).

as we want a parameter of the "tag" object start out by typing the line thus far:

Xmap = tag

then drag and dropping the element you want to modify (in this case the texture tags y parameter) into there, so grab the name from the Attributes manager and drop it into the coffee editor, you should then get something like


  Xmap = tag#TEXTURETAG_OFFSETY
  


add a ; at the end and we've now got the parameter. it's worth noting though that this isn't a pointer you must always re-set the data back again after you've finished with it here.

so after you got Xmap you just do

  Xmap++; //increment the value, you could alternatively write this as Xmap = Xmap + 1;
  
  tag#TEXTURETAG_OFFSETY = Xmap; //set the value in the dialog!
  

and that's it, you're done.

now if you wanted it to not be constantly incrementing but linked to actual scene time you'd instead of that just do


  var time = doc->GetTime(); //get the document time, this is returned in a "BaseTime" structure
  var second = time.GetSecond();
  
  Xmap = Xmap + 2.0 * second; // could be written Xmap += 2.0 * second; multiplier could be whatever youwant, however fast you want the stuff to move
  
 tag#TEXTURETAG_OFFSETY = Xmap;
  


i apologize if i got a few bits wrong (it may be doc.GetTime() or time->GetSecond() instead) i've not tested this, and i'm going from memory. but that should get you going.

Now that's the way to do it with COFFEE. with Xpresso it's easier as it's just working with nodes, plug the parameters you want, where you want, but it's a little slower to run. i'd recommend trying them both out as neither are all that complex at the end of the day.
__________________
The Third Party | Homepage | My Reel
"You need to know what you're doing before you start, and to start because you need what you're doing."
 
  05 May 2006
Thanks very much for the help!

I'll start reading the document to see if I can get a better idea on how to use this.
 
  05 May 2006
Originally Posted by Rathma: I heard the language resembles visual basic and C++.
I don't see much VB in it. It's more like the procedural parts of JavaScript with an object model that's closer to C++'s. (OO in JS is just plain weird...)
 
  05 May 2006
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



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 03:03 AM.


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