Показать сообщение отдельно
Старый 17.03.2011, 12:19   #17
ІГРОГРАЙКО
ПроЭктировщик
 
Аватар для ІГРОГРАЙКО
 
Регистрация: 20.06.2009
Адрес: Україна
Сообщений: 152
Написано 10 полезных сообщений
(для 24 пользователей)
Радость Ответ: Volume Rendering на XNA (Texture3D)

Сделал я то что думал.
И вот как оно виглядит:

Нажмите на изображение для увеличения
Название: capture1.jpg
Просмотров: 1066
Размер:	32.1 Кб
ID:	12993

У клас Volume.cs дописал:
VertexBuffer vertexBufferNX;
VertexBuffer vertexBufferNY;
VertexBuffer vertexBufferNZ;

VertexPositionColor[] pointListNX;
VertexPositionColor[] pointListNY;
VertexPositionColor[] pointListNZ;

int pointsNX;
int pointsNY;
int pointsNZ;

short[] triangleStripIndicesNXtriangleStripIndicesNYtriangleStripIndicesNZ;

...

protected 
override void LoadContent()
{
            
base.LoadContent();

            
pointsNX mHeight;
            
pointsNY mWidth;
            
pointsNZ mDepth;

            
pointListNX = new VertexPositionColor[pointsNX];
            
pointListNY = new VertexPositionColor[pointsNY];
            
pointListNZ = new VertexPositionColor[pointsNZ];

            for (
int ny 0ny mHeightny++)
            {
                for (
int nx 0nx 2nx++)
                {
                    for (
int nz 0nz 2nz++)
                    {
                        
pointListNX[(ny 4) + (nx 2) + nz] = new VertexPositionColor(new Vector3((float)nx, (float)(1.0f mHeight) * ny, (float)nz),Color.White);
                    }
                }
            }

            for (
int nx 0nx mWidthnx++)
            {
                for (
int ny 0ny 2ny++)
                {
                    for (
int nz 0nz 2nz++)
                    {
                        
pointListNY[(nx 4) + (ny 2) + nz] = new VertexPositionColor(new Vector3((float)(1.0f mWidth) * nx, (float)ny, (float)nz),Color.White);
                    }
                }
            }

            for (
int nz 0nz mDepthnz++)
            {
                for (
int nx 0nx 2nx++)
                {
                    for (
int ny 0ny 2ny++)
                    {
                        
pointListNZ[(nz 4) + (nx 2) + ny] = new VertexPositionColor(new Vector3((float)nx, (float)ny, (float)(1.0f mDepth) * nz),Color.White);
                    }
                }
            }

            
vertexBufferNX = new VertexBuffer(Game.GraphicsDeviceVertexPositionTexture.SizeInBytes pointListNX.LengthBufferUsage.None);
            
vertexBufferNX.SetData<VertexPositionColor>(pointListNX);

            
vertexBufferNY = new VertexBuffer(Game.GraphicsDeviceVertexPositionTexture.SizeInBytes pointListNY.LengthBufferUsage.None);
            
vertexBufferNY.SetData<VertexPositionColor>(pointListNY);

            
vertexBufferNZ = new VertexBuffer(Game.GraphicsDeviceVertexPositionTexture.SizeInBytes pointListNZ.LengthBufferUsage.None);
            
vertexBufferNZ.SetData<VertexPositionColor>(pointListNZ);

            
triangleStripIndicesNX = new short[pointsNX];
            
triangleStripIndicesNY = new short[pointsNY];
            
triangleStripIndicesNZ = new short[pointsNZ];

            for (
int y 0mHeighty++)
            {
                for (
int i 04i++)
                {
                    
triangleStripIndicesNX[(4) + i] = (short)((4) + i);
                }
            }

            for (
int x 0mWidthx++)
            {
                for (
int i 04i++)
                {
                    
triangleStripIndicesNY[(4) + i] = (short)((4) + i);
                }
            }

            for (
int z 0mDepthz++)
            {
                for (
int i 04i++)
                {
                    
triangleStripIndicesNZ[(4) + i] = (short)((4) + i);
                }
            }

И метод отрисовки полигонов:
private void DrawTriangleStrip()
        {
            for (
int i 0pointListNX.Lengthi++)pointListNX[i].Color = new Color(1f,1f,1f,0.01f);

            for (
int nx 0nx mHeightnx++)
            {
                
GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
                    
PrimitiveType.TriangleStrip,
                    
pointListNX,
                    
nx*4,  // vertex buffer offset to add to each element of the index buffer
                    
4,  // number of vertices to draw
                    
triangleStripIndicesNX,
                    
nx*4,  // first index element to read
                    
2   // number of primitives to draw
                
);
            }

            for (
int i 0pointListNY.Lengthi++)pointListNY[i].Color = new Color(1f1f1f0.01f);
            for (
int ny 0ny mWidthny++)
            {
                
GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
                    
PrimitiveType.TriangleStrip,
                    
pointListNY,
                    
ny*4,  // vertex buffer offset to add to each element of the index buffer
                    
4,  // number of vertices to draw
                    
triangleStripIndicesNY,
                    
ny*4,  // first index element to read
                    
2   // number of primitives to draw
                
);
            }

            for (
int i 0pointListNZ.Lengthi++)pointListNZ[i].Color = new Color(1f1f1f0.01f);
            for (
int nz 0nz mDepthnz++)
            {
                
GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
                    
PrimitiveType.TriangleStrip,
                    
pointListNZ,
                    
nz*4,  // vertex buffer offset to add to each element of the index buffer
                    
4,  // number of vertices to draw
                    
triangleStripIndicesNZ,
                    
nz*4,  // first index element to read
                    
2   // number of primitives to draw
                
);
            }
        } 
Подскажите только как убрать ети светла (R,G,B )???

VolumeRayCasting_101.rar
__________________
Blitz3D, XNA, WebGL, OpenGL, Unity3D
PC: ASUS A55VM Core i3 (2.4Ghz), 6 Gb RAM, Nvidia GF 630M GT 2Gb
(Offline)
 
Ответить с цитированием