Click here to Skip to main content
15,923,083 members
Home / Discussions / C#
   

C#

 
AnswerRe: What is Reflection emit and assembly evidence? Pin
Paul Conrad24-Dec-07 10:18
professionalPaul Conrad24-Dec-07 10:18 
QuestionWhat is guid and uvid? Pin
Firdous24-Dec-07 0:05
Firdous24-Dec-07 0:05 
GeneralRe: What is guid and uvid? Pin
Colin Angus Mackay24-Dec-07 5:09
Colin Angus Mackay24-Dec-07 5:09 
Question[Message Deleted] Pin
Firdous24-Dec-07 0:01
Firdous24-Dec-07 0:01 
AnswerRe: What is Object Pinning? Pin
Arjan Einbu24-Dec-07 0:19
Arjan Einbu24-Dec-07 0:19 
GeneralRe: Don't delete messages Pin
Paul Conrad24-Dec-07 5:56
professionalPaul Conrad24-Dec-07 5:56 
Question[Message Deleted] Pin
Firdous24-Dec-07 0:00
Firdous24-Dec-07 0:00 
AnswerRe: How to add attributes to return type? Pin
Arjan Einbu24-Dec-07 0:15
Arjan Einbu24-Dec-07 0:15 
GeneralRe: [Message Deleted] Pin
Colin Angus Mackay24-Dec-07 5:05
Colin Angus Mackay24-Dec-07 5:05 
GeneralWhy clr allows private to access Main Method Pin
Firdous23-Dec-07 23:54
Firdous23-Dec-07 23:54 
GeneralRe: Why clr allows private to access Main Method Pin
Colin Angus Mackay24-Dec-07 5:04
Colin Angus Mackay24-Dec-07 5:04 
Questionqns in asp.net with csharp Pin
dhans23-Dec-07 23:23
dhans23-Dec-07 23:23 
GeneralRe: qns in asp.net with csharp Pin
Paul Conrad24-Dec-07 6:07
professionalPaul Conrad24-Dec-07 6:07 
GeneralRe: qns in asp.net with csharp Pin
dhans25-Dec-07 19:06
dhans25-Dec-07 19:06 
GeneralRe: qns in asp.net with csharp Pin
Paul Conrad26-Dec-07 4:45
professionalPaul Conrad26-Dec-07 4:45 
GeneralRe: qns in asp.net with csharp Pin
dhans30-Dec-07 19:09
dhans30-Dec-07 19:09 
GeneralRe: qns in asp.net with csharp Pin
dhans30-Dec-07 19:20
dhans30-Dec-07 19:20 
Generalthe PC current Calender Pin
Ahmad Adnan23-Dec-07 21:49
Ahmad Adnan23-Dec-07 21:49 
Generalautopostback property Pin
chithra.r23-Dec-07 21:39
chithra.r23-Dec-07 21:39 
GeneralRe: autopostback property Pin
Kristian Sixhøj23-Dec-07 22:01
Kristian Sixhøj23-Dec-07 22:01 
GeneralRe: autopostback property Pin
rah_sin23-Dec-07 22:17
professionalrah_sin23-Dec-07 22:17 
GeneralRe: autopostback property [modified] Pin
dhans30-Dec-07 20:59
dhans30-Dec-07 20:59 
QuestionHow to get the linked url from a document? Pin
sduhd23-Dec-07 21:30
sduhd23-Dec-07 21:30 
AnswerRe: How to get the linked url from a document? Pin
That's Aragon24-Dec-07 0:21
That's Aragon24-Dec-07 0:21 
Generaltexturing by a bmp file Pin
Member 470189823-Dec-07 21:29
Member 470189823-Dec-07 21:29 
hi.
i have creat a flat earth by below code.
but it s withe.
i wan t to texture it by a bmp file.
i don t khow how i can do it.
please help me.
thanks.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using System.Drawing;
namespace Directx1

{//in this class we creat a 100*100 flat earth .
class GameEngine
{
private GraphicInitiator graphicInit;
private Device device3d;
private Form1 form;
private VertexBuffer vb;
private short[] indices
private IndexBuffer ib;
private int WIDTH = 100;
private int HEIGHT = 100;
private int[,] heightData;//we set the heightdata to 0 bc we want a flat surface
private CustomVertex.PositionColored[] vertices;


private void IndicesDeclaration()
{//in index buffer we set the indecses
//by this code we diclear a 100*100 earth
ib = new IndexBuffer(typeof(short), (WIDTH - 1) * (HEIGHT - 1) * 6, device3d, Usage.WriteOnly, Pool.Default);
indices = new short[(WIDTH - 1) * (HEIGHT - 1) * 6];

for (int x = 0; x < WIDTH - 1; x++)
{

for (int y = 0; y < HEIGHT - 1; y++)
{
indices[(x + y * (WIDTH - 1)) * 6] = (short)((x + 1) + (y + 1) * WIDTH);
indices[(x + y * (WIDTH - 1)) * 6 + 1] = (short)((x + 1) + y * WIDTH);
indices[(x + y * (WIDTH - 1)) * 6 + 2] = (short)(x + y * WIDTH);

indices[(x + y * (WIDTH - 1)) * 6 + 3] = (short)((x + 1) + (y + 1) * WIDTH);
indices[(x + y * (WIDTH - 1)) * 6 + 4] = (short)(x + y * WIDTH);
indices[(x + y * (WIDTH - 1)) * 6 + 5] = (short)(x + (y + 1) * WIDTH);
}
}
ib.SetData(indices, 0, LockFlags.None);
}







private void LoadHeightData()
//
{we want a flat surface and we set the the heiatdata =0
heightData = new int[WIDTH, HEIGHT];
for (int x = 0; x < WIDTH; x++)
{
for (int y = 0; y < HEIGHT; y++)
{
heightData[x ,y]=0;
heightData[x ,y]=0;
heightData[x, y] = 0;
}
}

}







public GameEngine(Form1 Frm)
{
form = Frm;
graphicInit = new GraphicInitiator();//creat a grafic card
graphicInit.initDevice(ref device3d, form);
LoadHeightData();//hamashon sefran
VertexDeclaration();
IndicesDeclaration();
CameraPositioning();
}

public void clear()
{

device3d.Clear(ClearFlags.Target, Color.DarkSlateBlue, 1.0f, 0);

}
private void CameraPositioning()
{
device3d.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, form.Width / form.Height, 1f, 300f);
device3d.Transform.View = Matrix.LookAtLH(new Vector3(0, -50, 15), new Vector3(0, 0, 0), new Vector3(0, 0, 1));
device3d.RenderState.Lighting = false;
device3d.RenderState.CullMode = Cull.None;

}

private void VertexDeclaration()
{
vb = new VertexBuffer(typeof(CustomVertex.PositionColored), WIDTH*HEIGHT, device3d, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Default);
vertices = new CustomVertex.PositionColored[WIDTH*HEIGHT];

for (int x=0;x< WIDTH;x++)
{
for (int y=0; y< HEIGHT;y++)
{
vertices[x+y*WIDTH].Position = new Vector3(x, y, 0);
vertices[x+y*WIDTH].Color = Color.White.ToArgb();
vertices[x + y * WIDTH].Position = new Vector3(x, y, heightData[x, y]);
}
}

vb.SetData(vertices, 0 ,LockFlags.None);
}


public void drawWorld()
{
CameraPositioning();
device3d.BeginScene();
device3d.Transform.World=Matrix.Translation(new Vector3(-50,5,-20));
device3d.VertexFormat = CustomVertex.PositionColored.Format;
device3d.SetStreamSource(0, vb, 0);
device3d.Indices = ib;
device3d.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, WIDTH * HEIGHT, 0, indices.Length / 3);
device3d.EndScene();
device3d.Present();
}
}
}

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.