Groups > Design > Autodesk MotionBuilder Open Reality SDK > FBTexture




FBTexture

FBTexture
Sun, 2 Sep 2007 09:32:03 +0000
I have a byte array containing an image.
I would like to set it as a texture in Motion Builder, allowing me to change it
if necessary.
I would like to do something similar to the topic of this thread
http://discussion1.autodesk.com/thread.jspa?threadID=497747

 I have tried many possible ways, included the one suggested int he thread
above.
The one that seems working is the following:

//start code

//get the image and put in image

videoTexture = new FBTexture(NULL,NULL);

videoTexture->OGLInit();

//MMVIdeoMemory just extends FBVideoMemory
//The constructors changes FBVideoMemory::TexturelD and the //image
size(128x128)
 media = new MMVideoMemory(1);

videoTexture->Video = media;

glBindTexture(GL_TEXTURE_2D,1);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128, 0, GL_RGB,
GL_UNSIGNED_BYTE,image );

//create the FBMesh VideoPlane
//set the texture coordinates via VertexUVSet

videoPlane->TextureAdd(videoTexture);

//end code

I tried creating new textures and putting the id in glTexImage, after binding,
but it doesn't do anything at all.

Then I supposed that somehow oglinit call glgenTexture and so I tried to guess
the current textureid: actually if i set this as 1 it seems working, while it
doesn't if i put an other number.

This way i'm able to set the texture, but even if i set the correct texture
coordinates int the FBMesh I'm using (a simple plane), the image is just
replicated on the surface.

Besides if i change the image A , that is if i call the code above with a
different image B and set the new texture to the mesh, nothing happens, that is
the texture doesn't seem to change.

At this point I also tried to set a texture with an image C via the GUI, not by
code.
Then I replaced with my texture, with  still present in the scene.
If i do that the result is that the texture is just the previous image (B)
replicated.

Post Reply
about | contact