ExecuteMAXScriptScript issue.

ExecuteMAXScriptScript issue.

klvnk
Collaborator Collaborator
1,383 Views
7 Replies
Message 1 of 8

ExecuteMAXScriptScript issue.

klvnk
Collaborator
Collaborator

when the a script is run that returns a Color with an alpha the  return FPValue of

 

 

Color 255 255 255 254

 

 

is of  TYPE_FRGBA_BV,  all well and good.  the resultant aclr of the FPValue is 1.0,1.0,1.0 0.99607849.

though if it returns something like 

 

 

Color 255 255 255 255

 

 

the resultant aclr is 1.0,1.0,1.0,0.0

 

any alpha value of 255 results in zero being returned

 

😕

 

 

0 Likes
1,384 Views
7 Replies
Replies (7)
Message 2 of 8

klvnk
Collaborator
Collaborator

though

c = Color 123 111 96 255
c as Point4

and

c = Color 123 111 96 255
b = Color 4 56 192 255
#(c,b)

both work as expected :?

0 Likes
Message 3 of 8

denisT.MaxDoctor
Advisor
Advisor

I can't reproduce the issue. I try to execute the string in different ways and try to compile the string, and each time I get the expected result where the alpha is 255.0 as was passed.

0 Likes
Message 4 of 8

klvnk
Collaborator
Collaborator

should be 1.0 as it's passed as the AColor* FPValue::aclr; 

 

 

0 Likes
Message 5 of 8

klvnk
Collaborator
Collaborator

this should reproduce it

 

 

def_visible_primitive(runscript, "runscript");
Value* runscript_cf(Value** arg_list, int count)
{
	enum args { kscript, kquiet, knum_args };

	check_arg_count(runscript, knum_args, count);
	FPValue  result;  
	ExecuteMAXScriptScript(arg_list[kscript]->to_string(), arg_list[kquiet]->to_int(), &result);


	return new Point4Value(result.aclr->r, result.aclr->g, result.aclr->b, result.aclr->a);
}

 

 

then try....

 

runscript "c = color 128 128 128 255;\nc;" true

 

in the listener, followed by...

 

runscript "c = color 128 128 128 254;\nc;" true

 

 

 

0 Likes
Message 6 of 8

klvnk
Collaborator
Collaborator

I think i know what's happening now when it sees the 255 as the alpha it changes it from a "AColor" to a "Color" so therefore passed in the  FPValue::clr. I wasn't paying enough attention to the FPValue::type field and the crazy nature of c/cpp unions 🙂

0 Likes
Message 7 of 8

denisT.MaxDoctor
Advisor
Advisor

check InterfaceFunction::FPValue_to_val

 
0 Likes
Message 8 of 8

klvnk
Collaborator
Collaborator

I already use  it for the mxs function, this issue came up in a com server implementation which returns variants and or safearrays...

 

the fix was one line...

case TYPE_FRGBA_BV:
case TYPE_COLOR_BV:
{
        if (ret.type == TYPE_COLOR_BV) ret.aclr->a = 1.0f;
	var_safearray_from_val<float>(4, (float *)ret.aclr, result);
	break;
}

 

0 Likes