Profile Picture

How to control sub-item of an 'Object'

Posted By TonyDPrime 5 Years Ago
You don't have permission to rate!
Author
Message
TonyDPrime
TonyDPrime
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3.4K, Visits: 12.4K
Hello, I am able to successfully direct function to an object in scene, in this case an avatar, by command as follows:

"XYZ" = RLPy.RScene.FindObject(RLPy.EObjectType_Avatar, "CC3_Avatar1",)

"XYZ" - the title I am applying function to
RLPy.RScene.FindObject - function
(RLPy.EObjectType_Avatar - instruction to have function appled to the object type "Avatar"
"CC3_Avatar1" actual avatar in scene I am applying script to

My script is thus directed to affect the entire "CC3_Avatar1"

But what I would like to do is have the script apply to specifically just a *part* of the avatar, ie the hair, eyes, clothing, teeth, or attached prop part....as opposed to, the entire avatar.
I imagined it might work if I put another comma after "CC3_Avatar1", followed by the prop name -"Prop1"- as listed in the Scene menu:

"XYZ" = RLPy.RScene.FindObject(RLPy.EObjectType_Avatar, "CC3_Avatar1", "Prop1")

However this did not do anything.   So far I can only affect the entire avatar in one broad shot, I cannot drill down such that the script is applied to only the avatar's parts, at least with what I am doing.
Is there a known protocol to link script functions to only the sub-parts of a master object in a scene, such as a prop's sub-props, or avatar's sub-parts (hair, eyes, clothing, teeth, prop), based on the command I have above?

THX! 

Edited
5 Years Ago by TonyDPrime
videodv
videodv
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)

Group: Forum Members
Last Active: Last Year
Posts: 342, Visits: 12.0K
Hi Tony

If you have not worked this out yet here is a piece of sample code for you to tryout and modify as you see fit, just put Zane on screen and make sure he is selected then run the script.

import RLPy

# Get the selected Avatar
avatar_list = RLPy.RScene.GetSelectedObjects()
avatar = avatar_list[0]
material_component = avatar.GetMaterialComponent()
mesh_list = avatar.GetMeshNames()
mesh_name = mesh_list[0]
material_list = material_component.GetMaterialNames(mesh_name)

for mesh in mesh_list:
    # The Following gets the materials of the Avatar
    material_list = material_component.GetMaterialNames(mesh)    
    for mat in material_list:
        if "Eyelash" in mat:          
            print("Found Eye Lash")
        if "Head" in mat:          
            print("Found Head")
        if "Teeth" in mat:          
            print("Found Teeth")

print("-----------------------------")

# This gets the mesh data from the Avatar         
for mesh in mesh_list:
    #print(mesh) # Un-comment if you do not see any mesh names
    if mesh == "CC_Base_Body":
        print("You have a body")
    if mesh == "CC_Base_Teeth":
        print("You have a some teeth")
       
# This is a example of Zane Avatar
# CC_Base_Body
# CC_Base_Tongue
# RL_HairMesh
# CC_Base_Eye
# CC_Base_Teeth
# Biker_Jeans
# Plaid_Punk_Shirt
# Loose_Biker_Boots
# Biker_Vest

# This is an example of Heidi Avatar Names
# RL_G6Beta_Tongue
# RL_G6Beta_DownTeeth
# RL_G6Beta_UpperTeeth
# RL_G6Beta_EyeBall_R
# RL_G6Beta_EyeBall_L
# RL_G6Beta_Eyelash_L
# RL_G6Beta_Eyelash_R
# Long Hair
# RL_G6Beta_Base
# RL_G6Beta_Dress
# RL_G6Beta_Shoes

Regards
Chris.
SeanMac
SeanMac
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (5.0K reputation)Distinguished Member (5.0K reputation)Distinguished Member (5.0K reputation)Distinguished Member (5.0K reputation)Distinguished Member (5.0K reputation)Distinguished Member (5.0K reputation)Distinguished Member (5.0K reputation)Distinguished Member (5.0K reputation)Distinguished Member (5.0K reputation)

Group: Forum Members
Last Active: Last Year
Posts: 416, Visits: 3.4K
Thanks for the heavily commented script.

Always a good idea.
Regards
SeanMac

Home Built in Coolermaster ATX case with GigabyteGA-Z170X-GAMING 7 MoBo, Intel i7-6700 @ 3.4 Ghz, Asus GeForce GTX 1080 TiGraphics Card, 32Gb DDR4 RAM, an Acer CB241HQK  & a Samsung S24D300 monitor, XP-PEN Artist15.6 Pro Graphics Tablet, Kinect v2, Logitech C920 Webcam, Win 10 64 Bit OS OS

TonyDPrime
TonyDPrime
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3.4K, Visits: 12.4K
Hello
Thank you very much, 

Let me drill down now here - in my case, the teeth are called "Custom_Teeth", the avatar is called "CC3_Avatar1" 

So - this ratio is unsolved:
Custom_Teeth : CC3_Avatar1
EObjectType_??? : EObjectType_Avatar

If I use the command 
"XYZ"=RLPy.RScene.FindObject(RLPy.EObjectType_Avatar, "CC3_Avatar1")
XYZ speaks to the avatar CC3_Avatar1.  This works to make the script speak to the entire avatar.

So, how does XYZ speak to the teeth only.  What kind of object type is it, because if I use
(1) EObjectType_Avatar,
(2) EObjectType_Teeth, 
(3) EObjectType_Mesh,
It does not work

Or, is the teeth even an object in the first place...should it be Mesh, instead of Object, Like EMeshType_Teeth, or EMeshType_Avatar, because any configuration combination of this does not work either.

See, I can know the names of all the parts I would like, but there is no way to route the script to just the part, only the entire avatar it seems.
Like, I am wondering now if Python can only name parts of an avatar, but after that cannot do anything to them via a function.  Like, it can only search for them and then name them.

These are a few examples I tried that do not work

"XYZ"=RLPy.RScene.FindObject(RLPy.EObjectType_Avatar, "Custom_Teeth")
"XYZ"=RLPy.RScene.FindObject(RLPy.EObjectType_Mesh, "Custom_Teeth")
"XYZ"=RLPy.RScene.FindObject(RLPy.EObjectType_Teeth, "Custom_Teeth")
"XYZ"=RLPy.RScene.FindMesh(RLPy.EObjectType_Avatar, "Custom_Teeth")
"XYZ"=RLPy.RScene.FindMesh(RLPy.EMeshType_Avatar, "Custom_Teeth")
"XYZ"=RLPy.RScene.FindMesh(RLPy.EMeshType_Teeth, "Custom_Teeth")
"XYZ"=RLPy.RScene.FindMesh(RLPy.EMeshType_Mesh, "Custom_Teeth")
etc....

THX for anyone that can help!


Edited
5 Years Ago by TonyDPrime
videodv
videodv
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)

Group: Forum Members
Last Active: Last Year
Posts: 342, Visits: 12.0K
TonyDPrime (10/13/2019)
Hello

Or, is the teeth even an object in the first place...should it be Mesh, instead of Object, Like EMeshType_Teeth, or EMeshType_Avatar, because any configuration combination of this does not work either.

See, I can know the names of all the parts I would like, but there is no way to route the script to just the part, only the entire avatar it seems.
Like, I am wondering now if Python can only name parts of an avatar, but after that cannot do anything to them via a function.  Like, it can only search for them and then name them.


Hi Tony

What is it you are trying to do?

If you look at this part of the above script

# This gets the mesh data from the Avatar         
for mesh in mesh_list:
    #print(mesh) # Un-comment if you do not see any mesh names
    if mesh == "CC_Base_Body":
        print("You have a body")
    if mesh == "Custom_Teeth":
        #change this print
        #print("You have a some teeth")
        # for this to get to the teeth mesh
       do_somthing_with_teeth() # Function to do you what you wish to the teeth mesh.

There is no way to get to the teeth mesh in the way you are trying to do, you have to loop through the avatar to get to the part of the mest or material or bones that you wish to change.

Hope this helps.

Chris.
Edited
5 Years Ago by videodv
videodv
videodv
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)

Group: Forum Members
Last Active: Last Year
Posts: 342, Visits: 12.0K
Hi Tony

Just had a thought if you have imported the teeth and attached then to the head then the teeth will be a prop and not part of the avatar you can then find it with,

prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Custom_Teeth")

Hope this helps.
Chris.
TonyDPrime
TonyDPrime
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)Distinguished Member (12.7K reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3.4K, Visits: 12.4K
Hi Chris, I appreciate your thoughts and feedback.
Can I ask, when you say you have to “loop through the avatar”, what does that mean.

But, I am guessing it could mean using an alternative. If I am directing movement of the teeth, I would have the script talk to the teeth bones themselves, not the mesh itself “Custom_Teeth”.

Hmmmm....!
videodv
videodv
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)

Group: Forum Members
Last Active: Last Year
Posts: 342, Visits: 12.0K
TonyDPrime (10/13/2019)
Hi Chris, I appreciate your thoughts and feedback.
Can I ask, when you say you have to “loop through the avatar”, what does that mean.

But, I am guessing it could mean using an alternative. If I am directing movement of the teeth, I would have the script talk to the teeth bones themselves, not the mesh itself “Custom_Teeth”.

Hmmmm....!


Hi Tony

If you follow this link API Docs you will find many examples to help get started and explanations for how these work, if you click the link on the left that says "Animate your character" you will find what you are asking for regarding moving an avatar bones.

At this time I am not aware of a way to use the mesh data but I think RL may release somthing at a later date regarding this.

When I was talking of looping its just another way of finding what items/sections/bones you need in an avatar or prop, you should be able to follow the examples in the above link for a better explanation.

Hope this is helpfull
Chris.
Edited
5 Years Ago by videodv
Chuck (RL)
Chuck (RL)
Posted 5 Years Ago
View Quick Profile
Trainer

Trainer (1.2K reputation)Trainer (1.2K reputation)Trainer (1.2K reputation)Trainer (1.2K reputation)Trainer (1.2K reputation)Trainer (1.2K reputation)Trainer (1.2K reputation)Trainer (1.2K reputation)Trainer (1.2K reputation)

Group: Administrators
Last Active: 2 Years Ago
Posts: 227, Visits: 2.1K
Hi Tony,

If your goal is to animate the jaw bone that the teeth are attached to then you should look into the Viseme APIs:

https://wiki.reallusion.com/IC_Python_API:RLPy_RIVisemeComponent
https://wiki.reallusion.com/IC_Python_API:RLPy_RVisemeSmoothOption



Reading This Topic