I've modified the r3subdiv.js but no luck. Matthias
----- Original Message ----- From: <[email protected]> To: <[email protected]> Sent: Saturday, December 12, 2009 8:03 PM Subject: Javascript - SDS SETFACEMATERIALUV > Hi, now that v.7 is out I will try to raise an old question. > > I have been trying to assign face materials to an SDS object from > Javascript. In the C-SDK, this is done by calling SETFACEMATERIALUV, > sending a face index, material name string and a pointer to an array > of vectors, one three dimensional vector for each point in the face. > When trying to replicate this in Javascript I get strange results. > Since I could not find an example on how to do this, I tried sending > different arrays for the uv parameter. > > > I have faces with three points and tried the most obvious first: > (Actually, the first thing I tried was to create three r3Vect via > "new" and putting the objects in the array - that didn't work either) > > var uv = [[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]]; > sds.SETFACEMATERIALUV (0, "Material", uv); > > This gives me only one point in the UV Editor, the first two > coordinate components are zero but the third is astromonical - a clear > indication that the data I am sending is interpreted as something > other than desired. All attempts I made with nested arrays gave > similar results. > > > Then I tried the second most obvious format: > > var uv = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]; > sds.SETFACEMATERIALUV (0, "Material", uv); > > This gives me two points in the UV Editor, one point has the > coordinates (0.0, 1.0, 2.0)! The second, however is (0.0, 0.0, > -8040241274831737). > > > I tried various other sequences of values, including this one: > > var uv = [0.0, 1.0, 2.0, 3.0]; > sds.SETFACEMATERIALUV (0, "Material", uv); > > This gives me three points making up a triangle in the UV Editor. One > point at (0.0, 1.0, 2.0) and the other two at (0.0, 0.0, 0.0). Moving > one of the latter and rendering shows that these are the actual uv > coordinates for this face material. > > > Does RS javascript not support this method? > > > ***************** > > An interesting thing is that, in r3subdiv.js, the parameter type for > the UV list is specified as a single vector and not an array! Compare > this: > > R3SUBDIVM_SETFACE = 1235105; > function mR3SUBDIVM_SETFACE(p1, p2, p3) { > if(arguments.length < 3) { > error("SETFACE() needs 3 parameters"); > } > return DoA3(this.r3obj, 1235105, p1, R3TID_INTEGER, 0, p2, > R3TID_INTEGER, 0, p3, R3TID_INTEGER, R3TNF_ARRAY); > } > > with this: > > R3SUBDIVM_SETFACEMATERIALUV = 1235093; > function mR3SUBDIVM_SETFACEMATERIALUV(p1, p2, p3) { > if(arguments.length < 3) { > error("SETFACEMATERIALUV() needs 3 parameters"); > } > DoA3(this.r3obj, 1235093, p1, R3TID_INTEGER, 0, p2, R3TID_STRING, 0, > p3, R3TID_VECTOR, 0); > } > > The former takes an array of integers as parameter three but the > latter takes only one vector. Odd? > > Best regards, > Fredrik >
