PDA

View Full Version : Assign Texture Layer to Surface



Auran
04-13-2007, 03:59 PM
Hello,

So I'm looking around in the SDK docs and I don't see a way to assign a texture layer to a surface without using commands (Surf_SetInt) or am I wrong? Is there any way around this in a mesh edit tool?

If using a command is the only way......
That seems very limiting, and would it be very difficult to add a "setInt" method in the surface global? It's kind of a bummer making a mesh edit tool, being able to create a surface, assign that surface to geometry, create a texture layer, and yet NOT able to add a texture layer to the surface :(

Thanks is advance for any input,
~Auran

Jabba
04-29-2007, 02:46 PM
I'm new to LW SDK but it seems that there are lots of things like this everywhere in the sdk ;( I was forced to do something in the MAX and MAYA SDKs and deeper I'm in the LWSDK more I understand why there's so much good plugins for every other than 3D app but LW.
You're working on something and on almost every step you just find out that you'll need more code for simple operation ;(

Lightwolf
04-29-2007, 03:42 PM
LWTextureFuncs (lwtxtr.h) has all the functions you need to add layers to a surface, including setting individual values.
infiniMap uses that the create a texture layer for the openGL viewports.
Mind you, the open texture layer panel will not refresh if it is open while you add a new layer.

However, I'm _not_ sure if that is possible in Modeler or within a MeshEdit plugin. It should be but I've never tried it.

Cheers,
Mike

Auran
05-24-2007, 11:09 AM
Unfortunately, I don't think it can be done in a MeshEdit plug-in. Simpy because it requires commands. The problem more involves surfaces than texture layers.

For example, say I wanted to add a single texture layer to the BaseColor channel of a surface:

// create the surface
LWSurfaceID new_surface = surf_funcs->create (obj_name, surf_name);

// Problem #1
// Set some surface properties using Surf_SetSurf, Surf_SetColor, etc.
// Uh oh -- can't be done in a mesh edit tool because it requires commands

// assign surface to geometry
MeshEditOp* edit = local->editBegin (0, 0, OPSEL_GLOBAL);
........I think this part can be done without commands (if I remember correctly)

// Problem #2
// ok, now add a texture layer to the surface's BaseColor channel
// only way I know of doing this is using Surf_SetInt with SURF_COLR and the value (ex. 2 - texture, no envelope)
// otherwise, this will return null:
LWTextureID tex_id = surf_funcs->getTex (surf_id, SURF_COLR);

So really, the only way that I am aware of to associate a texture layer in a surface channel is to create one using Surf_SetInt....otherwise, one can create surfaces and texture layers to their heart's content, but none of the texture layers and surfaces will but associated with eachother unless you use that surf_funcs->getTex(..), mentioned above, and use the texture id it returns....and that function will only return a valid value if Surf_SetInt has been used on the texture layer's respective channel (SURF_COLR in my case).

This gets confusing, I had to go back to a modeler plug-in I made just to remember specifically what the problem was...

Sorry for such a long description.

@Jaba
I haven't messed around much with other 3D application's SDKs, but at a glance, they do appear to be more flexible (dare I say powerful)...but you have to work with what you got ;)