Jump to content
  • Advertisement
Sign in to follow this  
muku

[Solved]Load the data of a volume texture iteratively

This topic is 3044 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!