|
|
naming convention in scripts
About Truespace Archives
These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.
They are retained here for archive purposes only.
naming convention in scripts // Archive: Tech Forum
Post by stan // Sep 4, 2006, 7:01am
|
stan
Total Posts: 1240
|
in the dev guide some class members have examples as to the proper way to write the code
example ->
Activity.Create('Space 3D Package/New Scene Command', '/Project')
so for "IRdRenderAttributes" what is it? {I've tried many things to no avail ..}
RenderAttributes.SetForceAttribs (file:///E:/devguide/DataObjects/structIRdRenderAttributes.html#a1) (true)
or
Render.SetForceAttribs (file:///E:/devguide/DataObjects/structIRdRenderAttributes.html#a1) (true)
or
nope, they don't work..what is it? |
Post by stan // Sep 5, 2006, 5:17am
|
stan
Total Posts: 1240
|
Norm..or..Tomasb..please help..
in the devguide\DataObjects\structIRdRenderAttributes.htm l
how do you get them to work.. I can find any example as to the proper syntax..they don't seem to work the same as the ScriptObjects or do they??..:confused: :confused:
does the class go in front _____ .SetForceAttribs ( bMode ) = true |
Post by frootee // Sep 5, 2006, 4:31pm
|
frootee
Total Posts: 2667
|
Hi stan. I have not looked into the dev guide yet but if these are typical C++ class members, or perhaps even java / javascript type classes, the class name should come first.
Also, check to see if you may be using a pointer to a class object. In that case, you may have to do this:
ClassName->ClassMethod(parameters)
instead of:
ClassName.ClassMethod(parameters)
Another person to try may be Matthew Collins, the author of the procedural animation course.
HTH!
Frootee |
Post by stan // Sep 5, 2006, 5:17pm
|
stan
Total Posts: 1240
|
thanks Frootee,
the class name just gives errors..I've tried different abbrevaited attempts too..
in the "script object s documentation" there are a few class names shown in examples..they are not consistant either, but they work ..here are a few
IRiRecorder = RsRec.AttachPreviewFile('c:\\test.avi')
IRiSpaceCommand = Space.Torus(2.0, 10, 10)
IRiScriptObject = ScriptObject.RunCmd("script object package/defaultlibscanner")
IRiNetwork = Net.SetPrivileges(Node.FirstSelected(), true, 0, 'Visitor', 1)
"Data Objects Documentation"
there are no examples and every thing I try gives errors
:confused: :confused: :confused: |
Post by frootee // Sep 5, 2006, 6:46pm
|
frootee
Total Posts: 2667
|
Hey Stan. I think I am still trying to get a handle on your situation. I think I understand so I will take a crack.
Classes are defined just like other variables: int x, float y.
Truespace has a class called IRdRenderAttributes. This class has functions, and data. What we need to do is create an OBJECT of that class.
So, I think in order to get this to work, you need to create an object of that class, much like you create an object of type int (integer), in your script:
IRdRenderAttributes Stans_render_attributes;
This is similar to this:
int x;
At this point, you have an instance of the
IRdRenderAttributes class, called Stans_render_attributes.
To use this instance, you call its member functions:
Stans_render_attributes.SetInvisible(TRUE)
This would call the SetInvisible function of the variable, Stans_render_attributes class.
In the examples that you have displayed here, check back in those examples to see if the variables (Space , ScriptObject, etc. ) were declared/defined prior to their usage in the example. If not, they may very well be default/predefined variables used by truespace. |
Post by frootee // Sep 5, 2006, 7:20pm
|
frootee
Total Posts: 2667
|
OK. Looks like:
Activity, Net, Node, ScriptObject, etc. are:
Root-level name in the scripting engine's name space
It looks like these are high-level classes/functions which you can use to build your own programs from the truespace SDK, so you don't have to write the low level code yourself. There may not be a need to have more than one instance of these in your application, so they have a root level name (instance of the class) already created for us. Of course, it also appears you have the option to create your own if you want.
For classes which do not have a root-level name:
you have to create an instance of that class, or acquire the desired instance of that class. It depends on whether you want to create a new instance, or modify an existing one.
This is my best shot at this, based on a few quick glances through the interface/function descriptions.
HTH,
Frootee |
Post by peterma // Sep 6, 2006, 6:07am
|
peterma
Total Posts: 48
|
Yes, exactly like frootee discovered - you need to refer to any instance when want to use IRdRenderAttributes methods. Instance in this case is any existing attribute (connector) of RdRenderAttributes type.
So typical example is : you define new script object with (output) attribute of RdRenderAttribute type, and then construct the attribute in your script body - here you can use SetForceAttribs(true) method.
Let us know if you need more assistance with it, we can create simple demo ... |
Post by stan // Sep 6, 2006, 6:10am
|
stan
Total Posts: 1240
|
thanks Frootee
thanks Peterma..yes a demo would be very helpful..:banana: |
Post by Norm // Sep 6, 2006, 6:55am
|
Norm
Total Posts: 862
|
Hopefully I don't trample on Peter here but I sort of have a solution I believe:
See attached image.
I brought into model window a simple cube object.
I went to player window and manually set its render attributes via stack view.
Then I created a test script command object and set a couple of attribs; inTime and outGetForce.
In the Execute function, I began by first testing correct way/method to check for existence. I set up variables to hold location (owner), the cube object (daCube) and finally actual Object Render Attributes "node" (RA). RA not really necessary, but I left it to help you see how to dig deeper into the LE if required. Bonus is if you wish to set values on that particular node then you can do so easily.
I removed a few System.Alert() I used to make sure I was successfull in calling nodes proper.
Once I called nodes properly, was a matter of implimenting a few "Get" calls. In theory if you can "get" a value, you can "set" a value.
I figured if this makes sense to you in current form, you should be able to play with setting values.
Hope is helpful |
Post by stan // Sep 6, 2006, 7:05am
|
stan
Total Posts: 1240
|
Thanks Norm..a bit more complex than I hoped..:D
I never would have gotten that..:confused: but without examples it's hard to learn..I managed to teach myself some c++ and hope to do the same with java..
Norm..RA is rendering attributes? I don't see it in use or is it?
thanks again guys..
it still would be great to see Peterma's example too it will help others like myself:banana: :banana: |
Post by frootee // Sep 6, 2006, 8:19am
|
frootee
Total Posts: 2667
|
Hi Stan. Let's take this apart.
RA = daCube + '/Object Render Attributes'
two lines lower, we have:
if( Node.Exists(daCube + '/Object Render Attributes') )
//NOTE: OBSERVE: RA = daCube + '/Object Render Attributes'
this can/should be replaced by:
if(Node.Exists(RA) )
or something similar. I have not tried using jscript or vbscript yet, so you may or may not have to do something like this instead:
if(Node.Exists('/RA) )
Thanks Norm! That provides insight into how we should implement the truespace SDK. COOL! :D
Thanks also to Peter. :D
Frootee
Frootee |
Post by stan // Sep 6, 2006, 9:25am
|
stan
Total Posts: 1240
|
thanks Frootee..
so
RA [IT'S A VARIABLE?] and has a value of = daCube + '/Object Render Attributes'
it makes more sense to me when I see -> if(Node.Exists(RA) ) in the code after that, but can you just use-> (daCube + '/Object Render Attributes') if you can why even use RA at all?
in c++ RA would belong to something..i.e. string , float
I know I'm missing something ..think I heard it fly over my head :D
thanks again Gord :cool: |
Post by Norm // Sep 6, 2006, 10:28am
|
Norm
Total Posts: 862
|
Norm..RA is rendering attributes? I don't see it in use or is it?
Yes is just a variable I declare. Not used but I show how to set up several items for testing. There may be other ways to do it. You can rip the code apart and use items in your script. I had to tinker with it all myself. I never went after that particular node before. I like to use locations stored in variables to reference a given node: owner/daCube/Object Render Attributes.
It replaces connectors when you do it this way. So no wires required and less clutter (if you understand the way the code works).
If you use this general method to test if you are talking to the node and connector values of that node, you can move ahead with working them.
As I understand, you can try this:
1. bring a cube, 2 sphere and cylinder into scene.
2. encapsulate one sphere and the cube and call the encapsulated object "a".
3. encapsulate one sphere and the cylinder and call the encapsulated object "b".
4. encapsulate a and b together and call that encapsulated object "c".
5. from the stack view, set render attributes for the "c" object. The idea is when you set at top level of "c", it filters down through all sub objects.
You can now go inside "c" and you find (the only one btw) Object Render Attributes node. The output connector "RenderAttribues" is connected to the sub-objects "a" and "b". Both "a" and "b" have input connectors called "Input Attributes". When you enter into either "a" or "b", you see for instance the sphere and cube inside "a". Now each of these objects has an "Input Attributes" input connector that if you look carefully at, find is connected/exported to the Input Attributes.
Now if you enter the cube object you see a RenderAttributes node. It is being passed value all the way from original (and only existing) Object Render Attributes up in the top-level "c" object.
My point would be that you need not contact a RenderAttributes "node" as it is fed values from some ObjectRenderAttributes node. If you know how to access the Object Render Attributes node and its settings/values, you access it and if required, any RenderAttribute nodes that exists as I demo'd, they are populated with values from Object Render Attributes.
Not sure if this will help or not ... |
Post by frootee // Sep 6, 2006, 10:43am
|
frootee
Total Posts: 2667
|
Hey Norm and Stan. Ah, I see Norm. Now I understand this use of the slashes. At first I wondered. Looks like the use of slashes is a way to drill down into the object structure hierarchy (man, I REALLY need to read up on scripting!).
Stan:
the use of RA instead of something like: System.whatever/Object Script/Render Attribute is to make writing/debugging/understanding the code more simple and easier to manage. It's easier to read and minimize typos with 2 characters: RA, as opposed to a very long string.
Frootee |
Post by stan // Sep 6, 2006, 10:44am
|
stan
Total Posts: 1240
|
thanks Norm..every bit helps..
what I was trying to do is re-make the render option buttons for wireframe, transparent wire, etc that Emmanual created using the macros as I showed him earlier this week..but see if it's possible to make them work in all layouts..because the macro uses a path which changes with the different layouts..
doing this I know I will learn alot..I have to say I am as confused as I was when I started learning c++ :D my brain hurts..:rolleyes:
thank again Gord :cool:
Thanks..just read your post Frootee..
must been posting at the same time..
yes it is a shorter form..I have no problem with that..I guess I've learned to read c++ somewhat and know what it means..this is quite different ..
having visual studio to work with helped a great deal..
the little ts7 compiler doesn't have the f1 help feature..that's so great to learn from.. |
Post by Alien // Sep 6, 2006, 6:48pm
|
Alien
Total Posts: 1231
|
Hey Norm and Stan. Ah, I see Norm. Now I understand this use of the slashes. At first I wondered. Looks like the use of slashes is a way to drill down into the object structure hierarchy (man, I REALLY need to read up on scripting!).
Most of the stuff in this thread is a bit over-my-head, but that thing about the "paths" [I vote that term be officially adopted, if it hasn't been already :)] makes sense to me. It's kinda like folders on a [hard drive] filing system, or directories on a web/ftp server.
what I was trying to do is re-make the render option buttons for wireframe, transparent wire, etc that Emmanual created using the macros as I showed him earlier this week..but see if it's possible to make them work in all layouts..because the macro uses a path which changes with the different layouts..
As previously stated, I'm somewhat out of my depth here, so this might not work:
Instead of dealing in absolute paths, starting from the root [System], how about seeing where stuff is in different layouts, & see if what you want is in the same position relative to <something> in each of the layouts. As you've already noticed stuff varies in its position relative to the root of the path tree [ System / ], but it might still be in the same relative position to <something>.
Layout 1:
System /thing1 /thing2 /foo /baa /sheep
Layout 2:
System wotsit /thing1 /thingumy /foo /baa /sheep
If there were some way to store what they have in common in a variable or whatever, e.g.:
Uncle=/foo
you could then get to /sheep with:
Uncle /baa /sheep
in either layout. I'm probably way off course on this 1, but thought I'd just add my 2c worth. |
Post by peterma // Sep 6, 2006, 11:40pm
|
peterma
Total Posts: 48
|
Thanks Norm, I like your sample, it is a correct way how to inspect render attributes from remote object. You can also edit this code to change render attributes insted of just reading them, but alas it will not work properly because the underlaing Render Attributes Object will override your changes during the nearest refresh (e.g. after reload).
The preffered way to generate / change render attributes is to create script object, similar to existing Render Attributes object, that will produce Render Attributes output connector. Or, just a small filter object that will take output from Render Attributes Object, will change something in there and export it out of the object - does it make sense for you ? |
Post by peterma // Sep 7, 2006, 12:00am
|
peterma
Total Posts: 48
|
Image to ilustrate previous idea - My Attribute filter is the script object that can change render attrubites producet by regular Object Render Attributes object |
Post by stan // Sep 7, 2006, 10:47am
|
stan
Total Posts: 1240
|
Alien, don't think that is possible ..remember the path issue with the player view toolbar.[my path was different that yours] .if you move the stack the path moves, and you cannot move the "player rendering" panel it always opens in the stack..I was hoping that the methods in "IRdRenderAttributes Struct Reference" would allow me to reach the panel where ever it resides..
Peterma..my idea was to make a set of icon buttons, which would allow you to have presets like in ts6.6 or model side..one click and you are in solid mode or transparent wire..there is no point creating a node or filter node because the whole concept is to NOT have to go into the LE or the stack. by creating a script [triggered by an icon] that will change the settings and that works universally in all layouts....[if possible] because a macro recording is path dependent..
Norm..you called "system" first in you code..is there a "dependency graph" [not sure what it would be called??]..I don't recall see anything like that in the dev literature..then "node" ..guess just about everything is considered a node ?
also is the script you showed done in a "jscript command" node [looks like it is]..that would be the way I see it being built..then the icon button command
could be Activity.Run("/Preferences/Wire" ) "Wire" being the jscript command node located in preferences..aka the path to the jscript command node..:D
thanks again Gord :cool: .. |
Post by Alien // Sep 7, 2006, 9:04pm
|
Alien
Total Posts: 1231
|
Alien, don't think that is possible ..remember the path issue with the player view toolbar.[my path was different that yours] .if you move the stack the path moves, and you cannot move the "player rendering" panel it always opens in the stack..I was hoping that the methods in "IRdRenderAttributes Struct Reference" would allow me to reach the panel where ever it resides..
I know, that's what I was trying to explain. With the way the path changes you can't use the root [System / ] of the tree as a reference point, BUT, if there were something else in the tree somewhere closer to what you wanted to get to that didn't change its position relative to your intended target & was already set as a variable that tS recognised [you'd have to ask the Devs about that 1 I guess], then perhaps you could use that as a reference point.
Did you see what I posted in another thread about using %vlight_root%\..\ instead of [for example] C:\trueSpace7\tS\ as a reference point when referring to files? In that instance \tS\ could be anywhere if the user didn't install to the default path, whereas the alternative with the variable would always hit the mark. What I'm suggesting [if possible] is some sort of LE path equivalent to that method. |
Post by frootee // Sep 8, 2006, 3:48am
|
frootee
Total Posts: 2667
|
hmm... sounds like a job for an environment variable. Is it possible to set/get an environment variable with truepsace scripting? I need to look more into all this system / script stuff to get a better understanding of the problem and potential solutions.
Frootee |
Post by peterma // Sep 8, 2006, 3:55am
|
peterma
Total Posts: 48
|
Peterma..my idea was to make a set of icon buttons, which would allow you to have presets like in ts6.6 or model side..one click and you are in solid mode or transparent wire..there is no point creating a node or filter node because the whole concept is to NOT have to go into the LE or the stack. by creating a script [triggered by an icon] that will change the settings and that works universally in all layouts....[if possible] because a macro recording is path dependent..
OK, thanks for clarify this :) Just one more question - do you want these presets for scene render attributes, or particular object render attributes ? |
Post by frootee // Sep 8, 2006, 4:27am
|
frootee
Total Posts: 2667
|
You want fries with that? :D |
Post by Norm // Sep 8, 2006, 4:53am
|
Norm
Total Posts: 862
|
OK, thanks for clarify this :) Just one more question - do you want these presets for scene render attributes, or particular object render attributes ?
psst Stan: ... ask him about both :) |
Post by stan // Sep 8, 2006, 2:03pm
|
stan
Total Posts: 1240
|
OK, thanks for clarify this :) Just one more question - do you want these presets for scene render attributes, or particular object render attributes ?
thanks Peterma..initially the presets for "scene render attributes"..and if I can then "object render"..I have already figured out how to get an icon to run a script :) , but the macro recording is path dependent so that is not useful if a person wants to change layouts..as you pointed out Norm's code is on the right track ..so if you can enlighten the rest of us on how a pro would do it..:D it would go along way in the learning process
many thanks ..the coding greenhorn, Gord :cool:
and thanks to Norm and Frootee :banana: too bad you missed the chat last night Frootee ..it's great being able ask Norm about things in realtime..and I got to see Dele's latest scripting handywork and chat a bit about it with him..you sure can learn alot that way..:D |
Post by frootee // Sep 8, 2006, 4:20pm
|
frootee
Total Posts: 2667
|
Hey Stan. Yeah, I really wanted to hook up with everyone last night. But I was totally wiped; Steinie pointed me in the right direction though. I was under the impression that in order to connect to shared space, we had to use trueplay. Apparently not. I will tryout his suggestions this weekend. (Lots going on... friend's wedding, work stuff, etc. )
hopefully I will be able to connect next Thursday night. :)
Frootee |
Post by peterma // Sep 10, 2006, 12:49am
|
peterma
Total Posts: 48
|
thanks Peterma..initially the presets for "scene render attributes"..and if I can then "object render"..I have already figured out how to get an icon to run a script :) , but the macro recording is path dependent so that is not useful if a person wants to change layouts..
It seems the crucial part of the task is to find the scene render attr object, buried somewhere in the controlling parts of the graph. As for the macro record, it tries to be path independend in one of its modes (see tutorials in the docs), but it cannot perform deep search for specified object ... |
Post by stan // Sep 11, 2006, 5:04pm
|
stan
Total Posts: 1240
|
frustration..I was working on my script, created a new attribute to create a [in]connector name..in Node.Value..press commit..a window pops up, tells me the script no longer exists and do I want to save it as .xml..I canceled that and went back to find the node had completely vanished..:( :( :( :(
how can that happen??..it should not..if a person makes a mistake the script shouldn't vanish into oblivion.. |
Post by Norm // Sep 12, 2006, 5:13am
|
Norm
Total Posts: 862
|
frustration..I was working on my script, created a new attribute to create a [in]connector name..in Node.Value..press commit..a window pops up, tells me the script no longer exists and do I want to save it as .xml..I canceled that and went back to find the node had completely vanished..:( :( :( :(
how can that happen??..it should not..if a person makes a mistake the script shouldn't vanish into oblivion..
I found this happens when I have deleted the script from the le. You may have made a copy of the script and thought you were working on copy, but the original is still showing in the SE (script editor). I do not believe the script would disappear on its own though Stan.
Let me know if this continues and I could try duplicating if you provide steps.
Please advise. |
Post by stan // Sep 12, 2006, 5:51am
|
stan
Total Posts: 1240
|
Thanks Norm..I didn't even save any backup copies in the library:( ..I was in the SE when it happened..the script vanished and after closing the save .xml window , the script window vanished and I was sent back into the LE ..even the jscript command node itself vanished..:rolleyes:
the trials and tribulations of being a scripting newbie :D |
|