Assign a surface's Normal Vector Map?

Kjasi

DESTROYER OF SANITY!
I've been working on an importer plugin for a while now, and I need to assign a vector normal map to the surface, but I can't seem to figure out how to make it work.

I've build the normal vectors, and when I manually assign the vector map to the surface in the surface editor, it works perfectly, but now I need to know how to assign the vector map while importing.

This doesn't work:
Code:
int vectormapID = 1;
surff->setInt(ids[0], SURF_NORM, vectormapID);

There's a getNormalVMap function, but no setNormalVMap. setInt doesn't seem to do anything, nor does any of the other "set" functions (as far as I can tell), so I'm wondering, how DO you assign the SURF_NORM a value that will select the Normal Vector Map?

Any help would be greatly appreciated, as there is no documentation about this ANYWHERE!

Really wish that we had access to the source code for the OBJ importer plugin...
 

Kjasi

DESTROYER OF SANITY!
Anyone at all?

According to the file format, I need to set the Normal VMap to a text string, but I'm unaware of how to do that using the LWSurfaceFuncs.
 
Last edited:

Kjasi

DESTROYER OF SANITY!
Figured out a work-around!

Well, until LW3D Group adds a setNormalVMap to the LWSurfaceFuncs (HINT HINT!!) here's how I discovered how to set a normal VMap to your surface when using ObjectImporter:

You need to create the following code:
Code:
[COLOR="#00FF00"]unsigned char surfcnk[] = {
	0x4E,0x4F,0x52,0x4D,0x00,0x0A,0x4E,0x6F,0x72,0x6D,0x61,0x6C,0x4D,0x61,0x70,0x00
};

// Poly Surface Data
local->surface(local->data, "Landscape", NULL, 41, surfcnk);
LWSurfaceID *ids = surff->byName("Landscape", local->filename);[/COLOR]

The surfcnk is hex-code for "NORM", 2 bytes of size, then the Normal VMap's name in Hex, with a 0 at the end. Translated it becomes NORM06NormalMap0.

Afterwards, you can apply code such as
Code:
[COLOR="#00FF00"]surff->setFlt(ids[0], SURF_SMAN, &smoothing);[/COLOR]
and it will affect the surface you created earlier as normal.

This gives you the best of both worlds in terms of surface creation.
 
Top Bottom