Assign UVmap to Texture

iain_r

New member
I'm writing an object importer and I can create textures and uvmaps, assign images to the texture and set the projection. However I can't assing the vmap to the UVname in the texture editor. Has anyone managed to do this. Attached my sample code, don't know how to get the vmapID for the last parameter in the setParam. My importer does assign uv points to the corrrect maps and when I manually assign the map to the texture it does display correctly.

Regards

Iain

Code:
if ((type == SUMaterialType_Textured) || (type == SUMaterialType_ColorizedTexture)){
	surff->setInt(surfid[0], SURF_COLR, 2);  // enable T in the texture editor
	local->vmap(local->data, LWVMAP_TXUV, 2, "LWSketchUV");  
	texid = surff->getTex(surfid[0], SURF_COLR);
	if (texid){
		txfunc->layerAdd(texid, TLT_IMAGE);
	        imageid = image->load(filedest); // filename and full path previously assigned
					
		tlayer = txfunc->firstLayer(texid);
		txresult = txfunc->setParam(tlayer, TXTAG_IMAGE, &imageid);

		int proj = 5; // For UV projection
					
		txresult = txfunc->setParam(tlayer, TXTAG_PROJ, &proj );
//		txresult = txfunc->setParam(tlayer, TXTAG_VMAP, void );  // where void is the vmapID according to the docs.
	}
}
 

creacon

creacon
in this code mymesh is a LWMeshInfo:

void *vmappointer;
vmappointer = mymesh->pntVLookup(mymesh, LWVMAP_WGHT, vmapname);

creacon
 

iain_r

New member
Thanks unfortunately LWObjectImport doesn't support meshinfo functions. I've raised this with support as UV maps get assigned when importing 3DS files.

Iain
 

iain_r

New member
Assign uvmap

With the help of support I can now assign uvmaps to the texture.

Regards

Iain

Code:
texid = surff->getTex(surfid[0], SURF_COLR);
if (texid){
	tlayer = txfunc->firstLayer(texid);
	local->vmap(local->data, LWVMAP_TXUV, 2, uvname.c_str());
	void* vmapid = local->curVmap(local->data);
	txfunc->setParam(tlayer, TXTAG_VMAP, &vmapid);
}
 

iain_r

New member
Still working on it, I needed to be able to create textures with UV maps otherwise it's not going to be much use.

regards

Iain
 

JohnMarchant

Active member
I totally understand. For me personally i never use the textures in SU, im just happy to get a clean mesh from SU then import and do my own UV and texture setup.
 

iain_r

New member
Unfortunately the UVs that are imported aren't always the best. It depends a great deal on how the model was built. I've got three different models from the sketchup warehouse all by the same company, 2 have uvs that are probably okay. The 3rd I've had to redo for some of the surfaces as when I have tried a test rended all I got was a default grey on the surfaces. The SDK doesn't seem to supply information on how the UV is projected, as I've had to change some to atlas, from planar to get a good uv map. I'll have a look at discontinuous uvs when I get a bit more time.

Regards

Iain
 
Top Bottom