PDA

View Full Version : surfaces, textures, layers and everything...



Jabba
11-27-2003, 07:15 PM
Hi there.

Is there any way to add FIRST layer to color channel in surface by Lscript in modeler, and if yes is there any way how to specify what image it will be?


surfObj = Surface(surfName);
I have a surfName so I've got a surfobj pointer.

texObj = surfObj.getTexture(SURFCOLR);
now I have a color channel .... but because the addlayer() is a method of TEXTURELAYER OBJECT instead of TEXTURE OBJECT, I can't use it on surface where is NO LAYER created yet. So this is first problem - how to create the FIRST LAYER on some channel.

Lets say that I create one empty texture layer by hand. Then I can use texLayerObj = texObj.addLayer(); and it works fine ;(

anyway - if I create that empty layer on color channel by hand, I can then write:
texLayerObj = texObj.firstLayer();

if I use imageObj = texLayerObj.getValue(TXLRIMAGE); it returns 'nil' because there is no IMAGE used on that layer. So i load one ...
Image = LoadImage("c:/gogo.tga");
Then when I try this:
imageObj = texLayerObj.setValue(TXLRIMAGE,Image);
modeler crashed...

I've got imageObj agent on texture layer, loaded image and its handler and averything looks fine till i use that 'setValue' method.

Any solution? Any suggestion how to create a first layer and how to assign an loaded image to it?

thnx.

Jabba
12-04-2003, 02:19 AM
Ok ;) Maybe little complicated question - here is the simple one:

Is there any way how to change an image on the surface's color channel from generic layout script?

thnx.

fxnut
12-07-2003, 01:34 PM
Hi Jabba,

If you look in the LScript reference manual on page 166 (that's using the PDF page numbering, or p158 with the manual's page numbering), then it shows how to add a new texture layer. You said that the Texture Object doesn't have an "addLayer" command, but if you look in the reference docs, you'll see that it does (and it's documented on the page referred to above).

As far as the setValue() crash goes, maybe try loading the image, and then creating a new Image Object Agent using one of the other techniques described in the manual, i.e.

img = Image();
img = Image(2);
img = Image("grass.bmp")
etc.

and seeing if that makes any difference.

I must admit, I've had quite a few problems with getting LScript to do anything useful with textures. In fact, I've had problems with the SDK as well! It's really not very nice to try to interface with, cause it seems like they really don't want you to mess with it!

I hope you have more luck than I did :)

Andy

Jabba
12-07-2003, 11:52 PM
Originally posted by fxnut
Hi Jabba,
...You said that the Texture Object doesn't have an "addLayer" command, but if you look in the reference docs, you'll see that it does (and it's documented on the page referred to above).

No. All that I said was that you can't ADD FIRST LAYER. You can add layers but just in time when there is min. first layer previously created by hand.



I must admit, I've had quite a few problems with getting LScript to do anything useful with textures. In fact, I've had problems with the SDK as well! It's really not very nice to try to interface with, cause it seems like they really don't want you to mess with it!

Same here. With all those update.html pages and different versions of pdf, nobody should never know that if he can't find some feature if it's because it doesn't exist in LScript or just because he have one of the zilions help files missing ;)

Blochi
01-04-2004, 04:54 PM
This is a tricky thing I stumbled over, too. But in Layout, don't know if the workarounds also do in Modeler...

So, to create a new texture Layer, you will have to issue a Command that checks the "T" button.
Example:
// simulate a surface selection by user clicks:
CommandInput("Surf_SetSurf \"" + surfNames[1] + "\" \"" +
meshName + "\"");
// now simulate the click on the T
CommandInput("Surf_SetInt BaseColor 2");

And setting the right Image is not really working because of a bug in LScript. setValue() always tries to set the NEXT image in list, instead of the specified one. If your Image OA is made from the last loaded image, this will make the crash.
here is a workaround: http://interialabs.de/lw/lscript/junk/ImgSeqRemapper.ls

hope it helps,
Blochi

Jabba
01-10-2004, 07:45 AM
Originally posted by Blochi
This is a tricky thing I stumbled over, too. But in Layout, don't know if the workarounds also do in Modeler...

....[CUT]...

And setting the right Image is not really working because of a bug in LScript. setValue() always tries to set the NEXT image in list, instead of the specified one. If your Image OA is made from the last loaded image, this will make the crash.
here is a workaround: http://interialabs.de/lw/lscript/junk/ImgSeqRemapper.ls

hope it helps,
Blochi

Thank you! I'll try that once I will have a time