Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology
Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered
You are not logged in.
Pages: 1
I am attempting to change a material color within a addsourcecode script and am having some trouble
getting the handle of a material. What follows is my test code.
fun TestColor(string)=
let (V3DgetSessionView c3dXsession) -> viewstr in
let V3DgetDefaultSession viewstr -> sessionstr in
let SO3SceneGetMaterial (V3DgetSession sessionstr) "V3DdefaultResources" "BaseWhite" -> mat in
if mat == nil then nil else
(
SO3MaterialSetAmbient mat (make_rgba 0 0 255 0);
SO3MaterialSetDiffuse mat (make_rgba 0 0 255 0);
SO3MaterialSetSelfIllumination mat (make_rgba 0 0 255 0);
);
0;;
I have been trying to figure out the OS3D structure for this kind of access and have not made a lot of progress.
Offline
I have modified the function:
fun TestColor(string)=
_showconsole;
let (V3DgetSessionView c3dXsession) -> viewstr in
let V3DgetDefaultSession viewstr -> sessionstr in
let SO3SceneGetMaterial (V3DgetSession sessionstr) "V3DdefaultResources" "BaseWhite" -> mat in
if mat == nil then
(
_fooS "material not found";
0;
)
else
(
_fooS "action";
SO3MaterialSetAmbient mat (make_rgba 0 0 255 0);
SO3MaterialSetDiffuse mat (make_rgba 0 0 255 0);
SO3MaterialSetSelfIllumination mat (make_rgba 0 0 255 0);
0;
);;
The log shows
> Action : Scene.Test Color.Run with param : abc and reply param : Scene.Key_3
The console shows:
loading tmp/tmp3891288.pkg ...
typechecking
fun TestColor : fun [u0] I
Generating bytescodes for 'TestColor' ...
167 bytes generated (for a total of 15632)
Loading Complete
> exec: TestColor "abc"
material not found
Offline
loading tmp/tmp3891288.pkg ... typechecking fun TestColor : fun [u0] I Generating bytescodes for 'TestColor' ... 167 bytes generated (for a total of 15632) Loading Complete > exec: TestColor "abc" material not found
The material is not found ... So, the variable 'mat' is at nil when you execute this function.
A material named "BaseWhite" already exists in the loaded 3d scene at this moment ? It seems that not.
What is "abc" ? If it is the name of the material, you should put it in SO3SceneGetMaterial like that :
let SO3SceneGetMaterial (V3DgetSession sessionstr) "V3DdefaultResources" string -> mat in
Offline
Hello,
first you can directly use (V3DgetSession c3dXsession)
then BaseWhite is not part of the "V3DdefaultResources" group.
and this material is not supposed to be changed.
try with a material from a scene, you can see how on material color plugIT
\os3dplugins\material\matcolor\cmatcolor.pkg
Offline
I am not using the "abc" parameter at the moment.
As a test I changed the color of "BaseWhite" using a "material color inst" plugIt and have seen the expected color change
Offline
I changed the group to "Scene" and that worked.
Thank You
Offline
Pages: 1