I'm a bit desperate here... I'm trying to access one parameter of a light in Softimage.
First, when we do this:
light.GetParameterValue(L"LightExponent")
it works!
But when we try:
light.GetParameterValue(L"soft_light.atten")
it fails completely!
I tried to find documentation, but the only code that I could find is in Python and no indication for the equivalent in C++. In python, they manage to do something like:
xsi = Application
test = xsi.GetValue("LightName.point.soft_light.atten")
But I cannot figure out what is Application, and it's not the same as XSI::Application in the API.
So, any idea how to access this value ? Also, if I could found the equivalent to Application.GetValue (in the script, you can see Application.SetValue... so I imagine that GetValue exists in some form!) in C++, that would be nice... I could simply use the name of the light and then add the information that I need to access that value like:
SomeUnknownClassForNow::GetValue(light.GetName() + ".point.soft_light.atten");
Any idea ?
With the help of a client of ours, I finally managed to find a proper solution to this.
First, there's some direct parameters, like "LightExponent". But there's other parameters associated with an object, like a light, in other categories called Shaders.
With a light, or a least a point light, there's only one Shader, called "soft_light". It's possible to access it by:
light.GetShaders()[0]
It's possible to verify its name to with GetName(). Which, in this case, would be "LightName.point.soft_light".
Finally, to access the "soft_light.atten" parameter:
light.GetShaders()[0].GetParameterValue("atten")
So, in Softimage, there's sort of Hierarchy in objects and all these a separated as shaders. For more complex object, just find the right shader and extract its parameter.
Related
I have made a LazyRow that i now want to be able to get the scrollposition from. What i understand Scrollablerow has been deprecated. (correct me if im wrong) The thing is that i cant make a scrollablerow so i thought lets make a lazy one then. but i have no clue how to get scrollposition from the lazyrow. i know how to get index but not position if that eaven exists. here is what i have tried.
val scrollState = rememberScrollState()
LazyRow(scrollState = scrollstate){
}
For LazyScrollers, there are separate LazyStates.
I think there's just one, in fact, i.e. rememberLazyListState()
Pass that as the scroll state to the row and then you can access all kinds of info. For example, you could get the index of the first visible item, as well as its offset. There are direct properties for this stuff in the object returned by the above initialisation. You can also perform some more complex operations using the lazyListState.layoutInfo property that you get.
Also, ScrollableRow may be deprecated as a #Composable, but it is just refactored, a bit. Now, you can use the horozontalScroll() and verticalScroll() Modifiers, both of which accept a scrollState parameter, which expects the same object as the one you've created in the question.
Usually, you'd use LazyScrollers since they're not tough to implement and also are super-performant, but the general idea is that they are used with large datasets whereas non-lazy scrollers are okay for small sized lists and stuff. This is because the lazy ones cache only a small fraction of the entire list, making your UI peformant, which is not something regular scrollers do, and not a problem for small datasets.
They're like equivalents of RecyclerView from the View System
I am fairly new to UE4 development so apologies if I am missing something obvious.
I am trying to convert a system from blueprints to C++. In an attempt to convert the SpawnActor node, I found that I am unable to provide input parameters like in the image below where ‘Index’ is a custom input.
In other places, to resolve this issue, I have used BeginDeferredActorSpawnFromClass, used an initialise function to provide parameters, then call FinishSpawningActor. This has worked where I am calling a C++ class.
In this case however, the actor I want to spawn is a blueprint class which is a child based on a C++ class. I am unable to implement BeginDeferredActorSpawnFromClass for this, and therefore am not sure how to pass my parameter to this.
For extra context, in the project there can be multiple characters spawned in the world. I want to pass the index of the character in order to set the material colour of each individual character using the nodes shown below.
I am able to achieve this by spawning the BP character using:
Character = GetWorld()->SpawnActor(...)
Character->Index = Index
And then using EventTick instead of EventBeginPlay but feel this is a bad solution. I would appreciate if someone could advise how to initialise the spawned actor with the required parameter.
Thanks in advance.
I was being stupid. SpawnActorDeferred is the function which serves the purpose required.
I build program, when in one part I have some ranking, and I would like to give users option to customize it.
In my code I have a function that gets objects and returnes them packed with points and position in ranking (for now it calculates the arithmetic mean of some object's values).
My question is is it possible to give e.g. admin chance to write this function via admin panel and use it, so if he would like to one day use harmonic mean he could without changing source code?
Yes, you could just store a string in the database and exec() it with suitable arguments...
However, you'll have to be careful – Python code can practically never be sandboxed perfectly. In the event that you accept any arbitrary Python code for this, and someone with nefarious intents gets to your admin panel to change the expression, they can do practically anything.
In other words, don't use raw Python for the code you store.
I'm trying to use the write_graphml function from the Boost Graph Library. The relevant things to know are that this function takes in a dynamic property map composed of property maps for each vertex and edge property, and assumes that all properties on the vertices and edges can be resolved to character types for writing to the file. This makes sense and works for most of my properties. However, I have 1 edge property that is an enum, and so it refuses to compile.
I think what I need is to create a custom PropertyMap that basically acts as a wrapper around the one for that edge property, intercepts the accesses, and returns a character representation in place of the enum values.
Is this the right way to solve this, and if so where can I look for how to define my own custom PropertyMap? I've been digging through the docs and code and so far I'm lost.
Got some help from someone else looking closer at the error messages, and it turns out defining << for std::ostream and >> for std::istream for my custom type enabled boost to write everything properly.
I am using openpyxl to read an excel file that will have changing values over time. The following function will take string inputs from the excel sheets to make frames for Tkinter.
def make_new_frame(strng, frame_location, frame_name, frame_list):
if not(frame_name in frame_list):
frame_list.append(frame_name)
exec("global %s" %(frame_name)) in globals()
exec("%s = Frame(%s)"%(frame_name, frame_location))
.... etc.
The code itself is quite long but I think this is enough of a snapshot to address my problem.
Now this results in the following error while parsing:
SyntaxError: function 'make_new_frame' uses import * and bare exec, which are illegal because it is a nested function
Everything in the code I included parsed and executed just fine several times, but after I added a few more lines in later versions in this function, it keeps spitting out the above error before executing the code. The error references the third line in the function, (which, I repeat, has been cleared in the past).
I added "in globals()" as recommended in another SO post, so that solution is not working.
There is a solution online here that uses setattr, which I have no idea how to use to create a widget without eventually using exec.
I would really appreciate if someone could tell me how to bypass the error while parsing or provide an alternative means for a dynamically changing set of frame names.
Quick Note:
I am aware that setting a variable as global in python is generally warned against, but I am quite certain that it will serve useful for my code
Edit 1: I have no idea why this was downvoted. If I have done something incorrectly, please let me know what it is so I can avoid doing so in the future.
I think this is an X/Y problem. You are asking for help with solution Y instead of asking for help on problem X.
If your goal is to create an unknown number of Frame objects based on external data, you can store references to the frame in a list or dictionary without having to resort to using exec and dynamically created variable names.
exec is a perfectly fine function, but is one of those things that you should never use until you fully understand why you should never use it.
Here's how to solve your actual problem without using exec:
frames = {}
def make_new_frame(strng, frame_location, frame_name, frames):
if not(frame_name in frames):
frames[frame_name] = Frame(frame_location)
return frames[frame_name]
With that, you now have a dictionary (frames) that includes a reference for every new frame by name. If you had a frame named "foo", for example, you could configure and pack it like this:
frames["foo"].configure(background="red", ...)
frames["foo"].pack(...)
If preserving the order of the frames is important you can use an OrderedDict.