Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control of individual sliders (Parameter) #91

Open
JekSun97 opened this issue Jul 12, 2024 · 5 comments
Open

Control of individual sliders (Parameter) #91

JekSun97 opened this issue Jul 12, 2024 · 5 comments
Assignees

Comments

@JekSun97
Copy link

JekSun97 commented Jul 12, 2024

In Live2D Cubism Editor I have a slider (Parameter) that hides a certain type of clothing and another slider for the appearance of other clothes, how can this be used in a plugin without including a certain animation, will I really have to redo all the animations with one clothing and then the same animation with different clothes? to somehow have customization

123

In short: @MizunagiKB how can I control certain parameters?

@JekSun97 JekSun97 changed the title Control of individual sliders Control of individual sliders (Parmeter) Jul 19, 2024
@JekSun97 JekSun97 changed the title Control of individual sliders (Parmeter) Control of individual sliders (Parameter) Jul 19, 2024
@JekSun97

This comment was marked as outdated.

@JekSun97
Copy link
Author

JekSun97 commented Jul 19, 2024

@MizunagiKB
I found the way:
cubism_model.get_parameters()[id].set_value(value)

only immediately after changing the value it is returned by default, perhaps in the source code you need to do _model->SaveParameters(), as specified in the Cubism SDK, so that the parameter is saved

I am using code like this to change values:

func _process():
  var id=4
  if Input.is_key_pressed(KEY_A):
      value-=0.01
      cubism_model.get_parameters()[id].set_value(value)
  if Input.is_key_pressed(KEY_D):
      value+=0.01
      cubism_model.get_parameters()[id].set_value(value)

but when I release the keys my eyes open again:
https://github.com/user-attachments/assets/5dd2dd1b-7bf8-4860-b9cb-56778823296a

This happens even without animation, and with animations in which this parameter is not involved (I tested it on others)

@MizunagiKB MizunagiKB self-assigned this Jul 27, 2024
@MizunagiKB
Copy link
Owner

@JekSun97

The reason the value doesn’t change when you try to modify the parameter is because the applied Motion is constantly overwriting the information.

By setting the ParameterMode of GDCubismUserModel to NONE_PARAMETER, you can freely manipulate all parameters.
However, this is intended for control by the AnimationPlayer on the Godot Engine side rather than free manipulation of parameters, so it may not align with your purpose.

The inability to manipulate parameters is partly due to SaveParameter, but it is largely due to the circumstances of the Cubism Native Framework that GDCubism depends on.

It is processed at the timing of _process, but in GDCubism, we have prepared a node called GDCubismEffectCustom so that only such processing can be performed.

By placing this node as a child element of GDCubismUserModel, you can receive signals before and after the update of Motion.

For example, you can change the parameter by receiving a signal called cubism_process.

The method of change is the same as what you are doing in _process, but the user_model itself is set in the argument of the received signal, so you don’t need to pass or save the user_model itself in advance.

Although it is not a complete solution, this method allows you to separate the work related to Motion from the _proccess processing, so it is recommended.

@JekSun97
Copy link
Author

JekSun97 commented Aug 1, 2024

@MizunagiKB Thanks, I'll try this in a few days.
It would be useful to have a small example of this, if I hadn't looked at the source code, I would hardly have figured out how to use it and find the parameters

@MizunagiKB
Copy link
Owner

@JekSun97

Documentation on parameter control and GDCubsimEffectCustom has been added.

https://mizunagikb.github.io/gd_cubism/gd_cubism/0.6/en/custom/motion.html

The following usage examples are provided:

  • demo_effect_custom_01.tscn
  • demo_effect_custom_02.tscn
  • demo_effect_custom_03.tscn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants