Storing data in the file format

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Say you have a check box that is alternately checked and unchecked as the timeline plays. The data that the layer script is reading is changing, but could the tool reflect these changes. Even if the tool reads in the same data for the check box status, can tools update when they're not being used?
Yes tools can update "on the fly" (watch the bone lock check box when you have a bone selected that is locked and unlocked in the time line).

You're right about the key frames though. I forgot about that. All those keys on one layer. Dagnabbit. Darn darn darn... <sigh>. All the keys would be jammed up on one layer in the time line.

What about using a group or bone layer as the "data storage" layer? You could have a bunch of layers and then at least you can "hide" them.

-vern
User avatar
synthsin75
Posts: 10280
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

Yes tools can update "on the fly" (watch the bone lock check box when you have a bone selected that is locked and unlocked in the time line).
Well that's the first one I thought of, but I thought this updating may be due to having actual keyframes for it. And there's always those mysterious internal interactions that seem to only be linked to specific LM script names. I'll have to test it out when I get the chance.
What about using a group or bone layer as the "data storage" layer? You could have a bunch of layers and then at least you can "hide" them.
That might work, but the group/bone layer would only be a container layer, since there's no point groups to use. Using one layer, it's easy enough to give it a single name and find that name, but multiple layers requires multiple unique layer names that the scripts must find.

So maybe have the group layer named 'Do Not Delete!! -GRP', the pure data storage layer named 'Do Not Delete!!', and the individual layer script control/indicator layers (one for each layer script used in that file) named 'Do Not Delete!! -layerscript name'? Or do you think that the 'Do Not Delete!!' name on the group layer would be enough warning?

Damn, it's too bad we can't assign layer scripts by script. If we could, then I'd just assign a layer script to the group layer that would keep it collapsed, and have a tool that enables/disables it. Granted we could ask the user for the path to their tool folder and just write the assignment to the file format, but I really don't like the idea of doing that since there's trouble reopening it in Windows.

I'd like to try to keep this as user friendly as possible. Just asking the user to assign this certain layer script to this certain layer might scare people off, since the benefit, and reason, may not be obvious to everyone.

Is there some good middle ground I'm missing here?



:wink:
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

I think we may not be on the same page... but we are very close. ;)

First off I am nearly 100% certain that values changed that might effect a tools options will be updated immediately. Changing the name of a point group should also be immediately available to the script. this will of course require the script to "read" the changes if a tool is used to add keys stored in the name of a point group. I don't see the custom tools for these scripts to be used "all the time" but only to change values. This should be fine even if you have to "rewind" to frame 0. (For example my physics script can only work starting from frame 0.)

My other thought is that the layer script is on the layer that you want it to work on as usual. The same way we do it now. I wasn't thinking that any layer scripts would be on the data storage layer at all.

There would be no need at all for the user to have to create the data storage layer/s or import any scripts other than the one they need for the layer they want to use the script just as we do it now.

In the group "data layer" it is named "Do not delete" or "Data Storage" and that's all. The layers INSIDE would then be created by the layer script that uses the utility script to save and retrieve data.

It would only need to do this once since it would look for the "do not delete" layer first, create it if it doesn't exist and create the layer script data storage layer inside it. If the "Do not Delete" bone layer already exists then it checks the layers inside it for a layer that matches the script. If the layer exists then it stores the data. If it doesn't exist it creates the layer.

Now onto the confusion about the key frames on the vector storage layers. When I say confusion it's that I haven't explained it well or maybe I'm not clear how you see this working. I just want to make sure you see my idea clearly (so you can show me where I'm wrong which I could be of course ;) ).

The "real" key frames on the storage layer do not contain actual data. The key frames on the data storage vector layers are ONLY so the user can see where the key frames are that are written in the name of a point group when they use a custom tool that writes data to the group name.

For example (I'm just making this up. It's overly simplified for example purposes). The following text could be stored in the name of a point group. I've included a header to show what the values represent:

Code: Select all

-------------------------------------------------------------------------------------------------------------------------------
Author   script name   variable   frame   value   frame   value   frame   value   frame   value   frame   value   frame   value
-------------------------------------------------------------------------------------------------------------------------------
heyvern   hv_physics    gravity     20     1.0     110    -1.0     230     1.0     300     1.0     479     1.0     567     1.0


(Another point group name for another key framed variable)

heyvern   hv_physics   collision    15     true     35    false    123     true    267    false    785     true
So the key frames are not stored in the "keys" at all. all the info is only stored in the point group name. The script would check a group name and look for keys. This will obviously mean we need individual points for groups so the key frames don't "overlap". This won't work with the idea of reusing the same points for multiple group names since the keys would overlap. You would need unique point/s to create groups. I don't see this as a problem since you only need one point for a group. You could have dozens of variables assigned to groups and not create that many points.

The script would "select" the key frames of the points. The user would use the "selected point" channel to see those key frames distinctly from other point group keys.

The actual "real" key frames on the points are only for visual reference and would contain no data at all.

All of this of course could be total nonsense until we actually test it. ;)

-vern
User avatar
synthsin75
Posts: 10280
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

Yeah, that sounds good. I already understood about the keys only being indicators of the data stored for each frame, but I hadn't thought about separating the keys of different scripts by using the selected point channel. That a good idea. Especially since a script can select this point group using the same method as it does to find its data.

May not even need a bone layer, just the single vector layer, to do it this way. Very nice. I'd just need to change the 'SelectAll' in the above code to a variable to be passed to the function for the point groups name. Then a layer script would look for its point group and if not found append a new point and create it. The general data storage could still just do a 'SelectAll' since these wouldn't need any key-indicator manipulation.

Like you said, still a lot of testing needed, but this is sounding better all the time.

:wink:
User avatar
synthsin75
Posts: 10280
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

Okay, I've written the utility to handle this stuff, but I still need to test it thoroughly and figure out a few things. So far I've got these functions:
-Build a table of layer object to cycle through to find the storage layer
-Make storage layer if one doesn't exist
-Get data from storage layer point group name
-Store data to storage layer point group name

Most of these ended up with a few more arguments that need to be passed than I had intended. The worst is to store data. It needs the passed to it:
-keyed - boolean for whether you need to write keyframes with the data you are storing
-keytbl - a table of frames you want keyframed (I had thought of getting this from the string you use for the point group name, but then I though that might restrict how people construct the data they're storing. )
-dataid - the identifying beginning of the string you're storing, used to find the group you may be changing
-data - the string of the data you are storing

The only thing I don't have much practice with is all the keyframing functions. I'm not real sure how you select the animation channel for things like Clear(), and what the best way is of writing the keys to the selected point channel.

Any pointers or suggestions welcomed.

:wink:
User avatar
synthsin75
Posts: 10280
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

http://www.mediafire.com/?dig5mzzym2m

Here's the utility. So far it works for creating the storage layer, storing, and retrieving data. I included an example tool that shows how it can be used. But I still haven't figured out the keyframe writing yet, so if you provide the 'keytbl' argument it will give errors.

Oh, and some of those functions and arguments are for some of my other stuff.

:wink:
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Sorry I haven't been participating more. I got another bout of some miserable bug that is going around. Just getting back on my feet.

I was working on a another project... in bed... on my back... with my laptop... tapping on the keys... not very productive... my strength is returning though.

;)

-vern
User avatar
synthsin75
Posts: 10280
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

No problem. I thought you'd been conspicuously absent. Good to hear you're up and about again. :wink:
Post Reply