how to define a anim layer blueprint interface with code in UE4/5? - unreal-blueprint

As we know, we can create a blueprint interface asset in editor, but how can we define an anim layer blueprint interface by code in UE4/5?
I just read all relevent doc but I cant find the answers. Hope someone`s answer.

Related

How to control NPC animation from GUI button click (Unreal)

I have a number of animation sequences connected to an ENUM Blend Pose node. I can manually switch this enum value in the Anim Preview panel.
Now I wish to control this enum value from a bunch of buttons added to a User Widget. The widget is instantiated within the Level BP.
When I edit the onClick events on the buttons, I do not know how to get a reference to my enum variable (which I have exposed as Public in the Anim Blueprint's settings).
Essentially, each button is designed to change this variable to a unique value, which then should cause the appropriate animation to play within the Blend Pose.
How do I let the Widget have access to that variable? Or vice versa, how could I create a variable on the blueprint that can be used to set the Enum value on the Blend Pose?
Please note that I am using the visual blueprint editor, not C++ at this time.
I am coming from a 100% C++ background, so I may have some options on my mind that are not entirely working in BP, but we'll get to that.
I would not use the level blueprint at all for anything. Instead use your GameMode or GameState for spawning the UserWiget. The GameMode and GameState are accessible via the GetGameMode node. Keep in mind that in multiplayer scenarios, only the GameState is available to all while the GameMode can only be accessed by the host or dedicated server, but that is probably irrelevant for you.
After spawning the widget assign it to a public variable of its type, so you can get it from the outside.
In your actor (not animation blueprint) you can access the GameMode easily using the GetGameMode node. You have to cast it to your specific GameMode to get to the variable of the widget. For the GameState use GetGameState.
Now you have multiple options to connect everything together. You could for example pass your actor to the UI and store it as a variable there. The UI can then simply call a custom function like "SetAnimationState" that you create on the actor for each button. Your actor can pass the enum value down to the animation blueprint. Using your skeletal meshes GetAnimInstance node.
This is one simple way I can think of. You could also work with an event dispatcher that broadcasts whenever a button is pressed and your actor is subscribed to it to get notified.
I hope any of this helps.
Building on #MaxPlay's answer, here's my final (possibly sub-optimal) solution with images for posterity. I'll probably stumble upon this answer in a few years like I do with some of my other SO posts from years ago ;)
First, the Anim BP on my Actor (note that this is not the player's pawn but just another mesh in the world) which just sets up the Blend Poses, using an Enum.
It's really vitally important here to make sure the variable that holds the Enum is made public. You do that by clicking the eye icon next to the variable name. If you don't do this, no external class (blueprint) gets to read or set the value of that variable.
This is a screen grab of the variables portion of the Anim BP's properties panel.
And here's that Enum, which you can create as a blueprint. I've used it to have a nice textual reference that has semantic meaning. Also makes it easier to link to the buttons later.
Now we get into the heart of the matter - the Actor Blueprint. I just wrapped this blueprint around my Skeletal Mesh Asset by selecting it in the viewport and then using the Blueprint menu to convert it.
In the image below you can see the Details panel of that Actor Blueprint, showing how it composes the Anim BP
Next is the magic step!
I created a function on the Actor Blueprint that other blueprints can call with 1 parameter - the ENUM that I defined earlier. The goal of this function is as a public setter on the Anim BP's public variable. I wasn't able to expose this public variable outside the hierarchy, so this gets around that visibility issue by delegating the responsibility for setting the Anim BP's variable to its Actor BP.
Since the Actor Blueprint has a reference internally to its Skeletal Mesh's currently assigned animation blueprint, and that Anim BP's variable has been made public, it gets to set it directly.
The goal is to pass a reference to this Actor BP to the Widget so the Widget's buttons can call this method (function) at a later time.
Over on the Widget side, I'm exposing a variable, cast as that specific animation blueprint (so that the Widget knows about the SetAnimFromEnum method). I'll be setting that variable in a moment.
Before I do, here's how the Widget Blueprint is set up - very simply, each button calls the same SetAnimFromEnum() method and just passes a different value from the enum.
If you had a million buttons, this would not be efficient and you might want to invest in a bit more complex blueprinting (I'm not yet at that level) - ideas here are to somehow parse the name / label of the button and derive the appropriate enum from it, or revert to an integer-based Blend Pose node and add a property to each button, etc.
And finally, the glue that holds it all together: the Actor Blueprint that instantiates the widget. This is the part I don't like in my solution - in my mind, the widget shouldn't be so tightly coupled (composed) with the Actor BP. But I would have had to jump through more hoops if using the Global GameMode or GameState Blueprints, and this is just a proof-of-concept so I'm keeping it simple, if slightly messy.
The Animation Blueprint below shows me instantiating the Widget and using the return value to both add it to the Viewport, as well as then accessing the widget's public variable designed to hold a reference to this Actor Blueprint and setting it. That creates the link between these two blueprints allowing the Widget to then call a method on the Actor.

Cloning a viewer material

I want to override the color of a component in the viewer, in order to conserve the same rendering effect than other components I would like to clone an existing material and simply modify the color of the clone.
I can change the color of an existing material as follow:
var renderProxy =
viewer.impl.getRenderProxy(
model, fragIds[0])
renderProxy.material.setHex(0xFF0000)
This affects all other components in the model which are using that material, which is not the desired result.
For that purpose I would like to clone material, modify it and affect the new material to a specific component. Invoking the material.clone() method is working:
var newMat = renderProxy.material.clone()
newMat.setHex(0xFF0000)
But the new material will loose all the specific properties that makes it look nice by the renderer.
So my question "is there a way to -easily- clone a viewer material without writing the cloning code for each property"?
You will need to clone the 'prism' material, rather than the 3js phong-material.
Start with this repo: https://github.com/wallabyway/fusion-chair-configurator
as an example, to create a 'metal' material, use these two lines of code (and copy the initPaint() function).
https://github.com/wallabyway/fusion-chair-configurator/blob/c6d5bd575cdf40194c9fbdd1c5f9bb27c70b356e/docs/js/app.js#L107-L108
The szPrism json string, contains lots of parameters. Prism materials are rather complex, but you can find out more about what these parameters do by understanding this article for the Autodesk Cloud Render ART help page (the real-time renderer built inside Revit2019, Fusion360, etc)...
http://help.autodesk.com/view/ARENDERING/ENU/?guid=GUID-49345267-CE6A-4006-BB58-5BEAFD8B0D0E
Try experimenting with Fusion360's 'render' mode. Start by opening 'appearance' and creating some custom materials. You can modify their parameters in real-time to better understand what they do and get the effect you are looking for.
Here is a tutorial video on Fusion360 custom materials: https://www.youtube.com/watch?v=D9AS5rQhtPo
Let me know if that helps.

Binding a Backbone Collection to DOM element using rivets without extending backbone view

I'm new to html5. I want to bind backbone collection to DOM element using rivets without extending backbone view. I got code snippets like extending adapter, using rivets.bind but i dont know how to organize everything. Can someone explain me how to achieve this in steps?
Thanks in Advance
Update: We can do this if we follow the example provided in the link of the accepted answer.
what you want to bind is the View, not the collection. The Collection is just data, an array of models if you wish. The View is what responds to user interaction, and that's where your rivets binding will be handled.
Check out Backbone.Marionette framework as its specialized CollectionView simplifies this even further, although you may go with a standard Backbone.View too.

Flex 4.5 / Apache Flex UI Framework Architecture

Is there any framework for UI development in Flex 4.5 ? Better standard for creating UI view layers using Action script. Also how to create states and state transitions in Action script?
Is there any framework for UI development in Flex 4.5 ?
Flex is a framework for UI Development. You can read up on the Flex Component Lifecycle for more information on how it works.
Better standard for creating UI view layers using Action script.
I don't understand what you're asking for here. You want a better standard than what?
Also how to create states and state transitions in Action script?
You can create states and state transitions in ActionScript similar to how you do it in MXML. Every component has a states array; and each entry in the state array will be an instance of the State class which will have a bunch of 'commands' to add or remove children or change properties. The full list is in the state class API documentation under the related API elements header.
Setting up states in ActionScript is tedious, though.

How to use robotlegs and signals without flex ie. pure as3

I'm try to put together a bare bones robotlegs-signals project but all the samples I've seen are flex ie
Index.mxml
<context:SignalCafeContext contextView="{this}"/>
SignalCafeContext.as
public class SignalCafeContext extends SignalContext
{
override public function startup():void
{
injector.mapSingleton.... etc etc
}
}
Is this possible to replace the mxml with another .as file - normally I would pass from the main class
context = new MyContext(this); // where this is DisplayObjectContainer
however super() takes no parameters in SignalContext so I might be missing something.
More Info:
libs:
as3-signals-v0.5.swc
robotlegs-framework-v1.03.swc
signals-extensions-SignalsCommandMap.swc
What you're trying would work in the current RobotLegs v.1 release (v.1.5.2). Context and its subclass SignalContext take optional params. The first param is your context view:
contextView:DisplayObjectContainer = null
Here's the SignalContext class extending Context.
Note, Context in Robotlegs 2 does not take parameters (source).
I imagine you need to start with a actionscript project instead of a flex project in FlashBuilder first.
Yes, your right, you just extend the Context class, as you can see in the basic HelloFlash robotlegs demo
mxml tags are just shorthand for actionscript classes. So I'd imagine you could start by taking a look at the auto-generated actionscript code. There is a flash builder compiler option that will let you see this. Using that as a template, you probably can't go too far wrong.