Did you get anywhere with this zoombapup?
I'm a little stuck on a similar task, I want to change a model's current texture or add a texture where there was not one previously.
This is the code I'm using (C# bindings):
Code:
var resId = h3d.createTexture(name, width, height, (int)h3d.H3DFormats.TEX_BGRA8, 0);
var ptr = h3d.mapResStream(resId, (int)h3d.H3DTexRes.ImageElem, 0, (int)h3d.H3DTexRes.ImgPixelStream, false, true);
Marshal.Copy(bytes, 0, ptr, bytes.Length);
h3d.unmapResStream(resId);
h3d.setResParamI(materialID, (int)h3d.H3DMatRes.SamplerElem, 0, (int)h3d.H3DMatRes.SampTexResI, resId);
My byte array in this case is a JPG image.
Some questions:
1. For the case where the material doesn't already reference a texture, it looks like I need to create a sampler or create an entire new material?
It hits this condition in egMaterial.cpp
Code:
if( (unsigned)elemIdx < _samplers.size() )
2. Updating an existing texture results in corruption, I suppose there is something wrong with my code?
Attachment:
overwrite-existing-texture.PNG [ 112.15 KiB | Viewed 23384 times ]