Updating an object in real-time?

Updating an object in real-time?

Anonymous
Not applicable
2,296 Views
12 Replies
Message 1 of 13

Updating an object in real-time?

Anonymous
Not applicable

I am planning to create a plugin for Maya, and I want to be sure it can be made in the first place.

 

Mainly, I want to know if I could update the attributes (e.g. position / rotation) of an object in real time, with values given by the plugin, regardless of whether Maya is idle, or the timeline is currently running.

 

I started looking at the API docs, and I didn't see anywhere the notion of an ever-present plugin that is loaded when Maya is loaded, but rather that it's all node-based plugins.

Again, my main concern is working in real-time, so if I am forced to use a node, would setting it to always be dirty fit my goal?

 

Thanks for any help or suggestions.

0 Likes
2,297 Views
12 Replies
Replies (12)
Message 2 of 13

RFlannery1
Collaborator
Collaborator

I'm a bit confused as to what you are trying to do.  What would be driving/updating the values for the plugin?

 

Are you wanting something that moves objects around when not advancing the timeline?  Kind of like the way updaitng the translate value moves the object around the viewport, even though the time is not changing?

0 Likes
Message 3 of 13

Anonymous
Not applicable

The plugin will get values from an external source, and I want to update an actual object in the scene with these values.

I want this to work both when the timeline is paused, and when it is advancing (basically all the time).

 

I am mostly confused as to when plugins get updated - do you register some callbacks that gets called repeatedly? something else?

0 Likes
Message 4 of 13

RFlannery1
Collaborator
Collaborator

Based on that information, I'm not sure you even need a plugin.  You could just call the "setAttr" command on your object's attributes whenever the value changes.  The bigger question in this case would be how you get the values from the external source.  (I'm not too familiar with that side of things.  I've heard you can do things like use sockets to send Maya commands from an external program to Maya.)

0 Likes
Message 5 of 13

Anonymous
Not applicable

Well, it would do all sort of other plugin-y things, but the real-time side is my main concern. The other things will probably all work when the user clicks a button or other GUI stuff, so I assume they will be easy.

 

Getting the values will be a part of the update code of the plugin, so the real question is when and how are plugins updated by Maya, and do they get updated at all times (or, for example, do they act differently when the timeline is idle or running).

0 Likes
Message 6 of 13

Anonymous
Not applicable

No answer? 😞

 

Just to reiterate - is there a way to make a plugin which gets updated in real-time, also when the timeline isn't running, and which can move an object in the scene on every update?

0 Likes
Message 7 of 13

Anonymous
Not applicable

"The plugin will get values from an external source, and I want to update an actual object in the scene with these values."

How did you get signal from extrenal source? Did you recieve some kind of event or get data read from the socket? Baciscally you can hook global event filter using qApp::installEventFilter(...), catch your custom events there then do what ever you want: find your plug-in nodes, update postition plugs etc.

0 Likes
Message 8 of 13

Anonymous
Not applicable

The plugin will need to call C++ functions of an external (albeit statically linked) library every time it updates, there isn't anything external actually running.

0 Likes
Message 9 of 13

RFlannery1
Collaborator
Collaborator

So it sounds like you want to pull the data from the Maya side, rather than pushing the data from the external source.  There's a couple of things I can think of that might work.

  • You can look into the MTimerMessage class from the OpenMaya api.  That looks like it should allow you to set up a callback to fire at fixed intervals.
  • If you are making a Qt GUI as part of the plugin, you could perhaps use the QTimer class to make something fire at fixed intervals.
0 Likes
Message 10 of 13

Anonymous
Not applicable
You who have to use the Python language to help , and Qt Creator
0 Likes
Message 11 of 13

Anonymous
Not applicable

why not the woodoo magic 🙂 ?

0 Likes
Message 12 of 13

Anonymous
Not applicable

It's actually the opposite - the external library is queried for updated values, and the plugin then needs to set the properties of an object with these values.

MTimerMessage does seem to handle the periodic part.

0 Likes
Message 13 of 13

RFlannery1
Collaborator
Collaborator

That is what I was saying.  Basically, you need to get data from the external source to Maya.  There are two ways to do this:

  1. - The external source can "push" the data to Maya.  In this case, the external source decides when the data is updated and sends out a signal whenever that happens.  Maya listens for the signal.
  2. - Maya can "pull" the data from the external source.  In this case, Maya decides when it wants to get the data and queries the external source at that time.

It sounded like you wanted to do the second way.  That is what I meant when I said "you want to pull the data from the Maya side, rather than pushing the data from the external source."

0 Likes