Click here to Skip to main content
15,906,094 members
Home / Discussions / C#
   

C#

 
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();
}
}
}
GeneralRe: texturing by a bmp file Pin
Anthony Mushrow23-Dec-07 23:01
professionalAnthony Mushrow23-Dec-07 23:01 
GeneralRe: texturing by a bmp file Pin
GuyThiebaut23-Dec-07 23:14
professionalGuyThiebaut23-Dec-07 23:14 
Questionhow can i get the real IPAddress of a client that use a share internet Pin
amin_ramin888623-Dec-07 20:55
amin_ramin888623-Dec-07 20:55 
GeneralRe: how can i get the real IPAddress of a client that use a share internet Pin
Michael Sync23-Dec-07 21:13
Michael Sync23-Dec-07 21:13 
GeneralRe: how can i get the real IPAddress of a client that use a share internet Pin
amin_ramin888624-Dec-07 20:11
amin_ramin888624-Dec-07 20:11 
GeneralNew Activex Control Pin
Thaer Hamael23-Dec-07 19:49
Thaer Hamael23-Dec-07 19:49 
Generalcatching browser action Pin
balakpn23-Dec-07 19:18
balakpn23-Dec-07 19:18 
GeneralRe: catching browser action Pin
Michael Sync23-Dec-07 21:14
Michael Sync23-Dec-07 21:14 
GeneralRe: catching browser action Pin
balakpn23-Dec-07 22:03
balakpn23-Dec-07 22:03 
QuestionHow i can show the data in the Crystal Report Horizantly Pin
wasimsharp23-Dec-07 19:14
wasimsharp23-Dec-07 19:14 
GeneralDrawing 2D lines using c# Pin
ramyanaidu23-Dec-07 18:56
ramyanaidu23-Dec-07 18:56 
GeneralRe: Drawing 2D lines using c# Pin
Anthony Mushrow23-Dec-07 21:25
professionalAnthony Mushrow23-Dec-07 21:25 
GeneralRe: Drawing 2D lines using c# Pin
GuyThiebaut23-Dec-07 23:21
professionalGuyThiebaut23-Dec-07 23:21 
QuestionRegarding Deployment Pin
sindhutiwari23-Dec-07 18:24
sindhutiwari23-Dec-07 18:24 
GeneralRe: Regarding Deployment Pin
Michael Sync23-Dec-07 21:16
Michael Sync23-Dec-07 21:16 
GeneralRe: Regarding Deployment Pin
sindhutiwari23-Dec-07 21:37
sindhutiwari23-Dec-07 21:37 
GeneralRe: Regarding Deployment Pin
Michael Sync23-Dec-07 21:43
Michael Sync23-Dec-07 21:43 

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.