Community
VRED Forum
Welcome to Autodesk’s VRED Forums. Share your knowledge, ask questions, and explore popular VRED topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VRED Material Switch using separate Touch Sensors?

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
Anonymous
1185 Views, 8 Replies

VRED Material Switch using separate Touch Sensors?

Hello!

 

I'm wondering how best to go about using separate pieces of geometry (e.g a collection of spheres) which acts as a paint sample and changes the car into that material. 

This is my set-up at the minute (See attached) and I was experimenting with Touch Sensors and Variants to no avail!

 

Any ideas on the best way to do this? Or if I'm on the right track at all!

 

Total newbie at VRED by the way!

 

Thanks in advance!

 

 

8 REPLIES 8
Message 2 of 9
sinje_thiedemann
in reply to: Anonymous

Hi,

have you already seen this short tutorial on touch sensors and variant sets?

http://help.autodesk.com/view/VREDPRODUCTS/2018/ENU/?guid=GUID-5C5422D3-19A3-4BE1-802F-DADCF2E1622F

It's made with an older version of VRED but the workflow is still the same.

The material on the car needs to be a switch material containing the carpaints. I see some switch materials in your screenshot, not sure if it is already assigned to the car exterior.

Now you only need to create one touch sensor per sample geo, and one variant set per touch sensor, as shown in the video. Instead of setting the state to "Next (Loop)" as in the video, just set it to the desired carpaint.

 

Regards

Sinje

Message 3 of 9
Anonymous
in reply to: sinje_thiedemann

That was it!! Thank you so much!

Message 4 of 9
extern.Sanju.Mathew
in reply to: Anonymous

Hello,

 

I have couple of queries regarding material..

1) Current_Material = vrNodeService.findNode("X Object").getMaterial().getName()

 

I have assigned a switch material to an X object. When I run the above code I get the name of the Material Switch. Is there way to get the name of the material currently assigned within that Material Switch to that X Object? For Eg if Mat is the name of material switch and it has materials Mat_1 and Mat_2. How do I know if Mat_1 or Mat_2 is currently assigned using codes? Basically I have an image sequence inside a material in the material switch (Mat_2). I want to animate that clip when Mat_2 is active and stop the animation when the material is switched to Mat_1

 

2) Is there way to get the Material Incandescence Intensity and set it later using python codes for a particular material?

 

Regards,

 

Sanju Mathew

 

Message 5 of 9

Hi @extern.Sanju.Mathew 

I recommend to start a new thread for new questions.

But to answer:

1) Getting the active material of a switch material:

 

switch_mat = vrNodeService.findNode("X Object").getMaterial()
if switch_mat.isType(vrdSwitchMaterial):
    choice = switch_mat.getChoice()
    active_mat = switch_mat.materials[choice]
    print("choice:", active_mat.getName())

 

 

2) Getting and setting the incandescence intensity of a material:

 

print(plastic.getIncandescence().getIntensity())
plastic.getIncandescence().setIntensity(10.0)
plastic.getIncandescence().setColor(QVector3D(1,1,1))

 

 

Message 6 of 9
extern.Sanju.Mathew
in reply to: Anonymous

Thank you for the quick response. I will start a new thread from next time.

Message 7 of 9

Hi Sinje,

It seems the RGB value that I am providing in the code is not the same that is reflecting in the material. May I know how I can fix this? Value is a conversion on 0-1 scale from 1-255 scale. It is capturing the intensity correctly.

 

externSanjuMathew_0-1732646592863.png

 

Message 8 of 9

Hi @extern.Sanju.Mathew ,

 

RGB colors in 0-255 range are commonly non-linear SRGB values.

VRED internally uses linear RGB color values. The colors set via Python API are expected to be linear.

Here are some functions to do the conversion. Please adjust as needed.

 

import math

# convert non-linear SRGB to linear RGB value
def srgbToLinear(value):
    if value <= 0.04045:
        return value / 12.92
    else:
        return math.pow((value + 0.055) / 1.055, 2.4)

# convert from 0-255 sRGB to linear 0-1
def RGB255ToLinear(r,g,b):
    return QVector3D(srgbToLinear(r/255), srgbToLinear(g/255), srgbToLinear(b/255))
    
plastic = vrMaterialService.findMaterial("Plastic")
plastic.getIncandescence().setIntensity(10.0)
plastic.getIncandescence().setColor(RGB255ToLinear(70, 100, 200))

 

 

Message 9 of 9

Thank you!! This provides much better result!!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report