Sign in to follow this  
muku

[Solved]Load the data of a volume texture iteratively

Recommended Posts

muku    122
Is it possible to load the data of a volume texture into a loop? I try to do something like the code below but it seems it's not the right way to do it :) I want to read the bytes from a number of files from the hdd, file by file. After each read operation I want to append them to the data already loaded into the volume texture.
byte[] buffer = new byte[512 * 512 * 4];
GraphicsStream gs = null;
for (int i = 0; i < mRenderer.ImageCount; i++)
{
     buffer = mRenderer.fileLoader_.ReadAFile(i);
     gs = mRenderer.VolumeTexture.LockBox(0, LockFlags.None);
     gs.Write(buffer);
     mRenderer.VolumeTexture.UnlockBox(0);
}           
gs.Dispose();


P.S One more question. How do I tag a thread as Solved? [Edited by - muku on February 19, 2010 4:52:55 AM]

Share this post


Link to post
Share on other sites
Pyrogame    106
For your first question I do not have an answer. Maybe the 0 in LockBox/UnlockBox should be the variable i? Like said, I can't help you, because I have nothing done yet with volume textures ^^.

Your second question: Just edit your first post's topic and add [Solved] as prefix. ^^

Share this post


Link to post
Share on other sites
muku    122
Thanks for your answer to my second question :) I'm working on the first part myself. I read that method LockBox() of the volumetexture class has several overloads and some of them take a Box parameter which locks a given region of the volume instead of the whole volume which i lock with the code above. I believe this is what I'm looking for, I'm trying to make it work that way.

Share this post


Link to post
Share on other sites
muku    122
I figured out how to do it, the code i give below should be correct for anyone having the same problem in the future :)


byte[] buffer = new byte[512 * 512 * 4];
GraphicsStream gs = null;
Box box = new Box();
box.Left = 0;
box.Right = 512;
box.Top = 0;
box.Bottom = 512;

for (int i = 0; i < mRenderer.ImageCount; i++)
{
buffer = mRenderer.fileLoader_.ReadAFile(i);
box.Front = i;
box.Back = i + 1;
gs = mRenderer.VolumeTexture.LockBox(0, box, LockFlags.None);
gs.Write(buffer);
mRenderer.VolumeTexture.UnlockBox(0);
}
gs.Dispose();

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this