, Visual C#


- 2


public void OnResetDevice(object sender, EventArgs e)

{

Device myDev = (Device)sender;

// CullMode,

// :

myDevice.RenderState.CullMode = Cull.None;

// Z - :

myDevice.RenderState.ZBufferEnable = true;

// :

myDevice.RenderState.Lighting = true;

}

// :

public void OnCreateVertexBuffer(object sender, EventArgs e)

{

VertexBuffer myVB = (VertexBuffer)sender;

// PositionNormal

// 100 :

CustomVertex.PositionNormal[] Vertex =

(CustomVertex.PositionNormal[])myVB.Lock(0, 0);

for (int i = 0; i < 50; i++)

{

// :

float theta = (float)(2 * Math.PI * i) / 49;

 

// .

// :

Vertex[2 * i].Position =

new Vector3((float)Math.Sin(theta), -1,

(float)Math.Cos(theta));

 

// :

Vertex[2 * i + 1].Normal =

new Vector3((float)Math.Sin(theta), -1,

(float)Math.Cos(theta));

}

// :

myVB.Unlock();

}

// :

private void SetupMatrices()

{

// (world matrix),

// y:

myDevice.Transform.World = Matrix.RotationAxis(

new Vector3(

(float)Math.Cos(Environment.TickCount / 250.0f), 1,

(float)Math.Sin(Environment.TickCount / 250.0f)),

Environment.TickCount / 3000.0f);

 

//

// (view matrix):

myDevice.Transform.View = Matrix.LookAtLH(

new Vector3(0.0f, 3.0f, -5.0f),

new Vector3(0.0f, 0.0f, 0.0f),

new Vector3(0.0f, 1.0f, 0.0f));