You need to
1. Set up a device
internal void initGraphics()
{
// Set our presentation parameters, set up the Direct3D device
presentParams = new PresentParamete rs();
presentParams.W indowed = true;
presentParams.S wapEffect = SwapEffect.Disc ard;
presentParams.D eviceWindow = this.portalPane l; //the subclass of Form you
are drawing on .
//set up z buffer so that near objects obscure far objects.
//If graphics card does not support we are in trouble here.
presentParams.E nableAutoDepthS tencil = true;
presentParams.A utoDepthStencil Format = DepthFormat.D16 ;
// Store the default adapter
int adapterOrdinal = Manager.Adapter s.Default.Adapt er;
CreateFlags flags = CreateFlags.Sof twareVertexProc essing;
Caps caps = Manager.GetDevi ceCaps(adapterO rdinal, DeviceType.Hard ware);
// Do we support hardware vertex processing?
if (caps.DeviceCap s.SupportsHardw areTransformAnd Light)
// Replace the software vertex processing
flags = CreateFlags.Har dwareVertexProc essing;
// Do we support a pure device?
if (caps.DeviceCap s.SupportsPureD evice)
flags |= CreateFlags.Pur eDevice;
flags = CreateFlags.Har dwareVertexProc essing; //better be there...
try
{
// Create our device
device = new Device(adapterO rdinal, DeviceType.Hard ware,
this.portalPane l, flags, presentParams);
}
catch
{
if (device != null)
device.Dispose( );
MessageBox.Show ("unable to create device");
clearFlags = ClearFlags.Targ et;
presentParams.E nableAutoDepthS tencil = false;
presentParams.A utoDepthStencil Format = DepthFormat.D16 ;
}
}
2. Set up a buffer that contains triangles whose vertices are on the
surface. If the triangles are small enough you get a reasonable
approximation to the surface. Alternatively, you can just render points on
the surface (but this will not give you lighting effects). You can render a
list of lines as well.
device.BetginSc ene();
device.DrawUser Primitives(Prim itiveType.Trian gleList, triangleCount,
renderBuffer);
device.EndScene ();
device.Present( );
where renderBuffer contains your list of triangles.
You also need code to set the position of the camera, the position of the
lights, and to set up matrices for transforming from object space to model
space to world coordinates. All in all in might be 30-40 lines of code.
Something like:
device.RenderSt ate.Ambient = Color.DarkBlue; device.RenderSt ate.CullMode =
Cull.CounterClo ckwise;
device.RenderSt ate.Lighting = true;
device.Lights[0].Type = LightType.Direc tional;
device.Lights[0].Diffuse = Color.LightBlue ;
device.Lights[0].Direction = new Vector3(0, 0, -1);
device.Lights[0].Commit();
device.Lights[0].Enabled = true;
device.Transfor m.World = worldTransform;
device.Transfor m.Projection =
Matrix.Perspect iveFovLH(camera .fieldOfView, camera.aspectRa tio,
camera.nearPlan e, camera.farPlane );
device.Transfor m.View =
Matrix.LookAtLH (camera.positio nV, camera.targetPo sition,
camera.up);
I recommend the book "Managed DirectX 9", byTom Miller which has many
examples. Reading the documentation for the above mentioned functions (in
the DirectX 9 SDK) will help as well.
"Dr. Zharkov" <va************ @mtu-net.ru> wrote in message
news:eV******** ******@TK2MSFTN GP10.phx.gbl...
Hello. I have installed on my computer Visual Studio 2005 Beta and DirectX
9.0 SDK Update - (Summer 2004). I have developed projects Visual C#,
Visual
Basic and Visual C++ for construction of 3-Dimensional geometrical
bodies,
surfaces and lines of a level of these surfaces without use of DirectX,
and
now I want to make the same with use of DirectX.
Inform, please, where it is possible to find an example of construction of
a
geometrical body or a surface z = f(x, y), for example, part of sphere on
Form1 in project Visual C# or Visual Basic, or Visual C++, Windows
Application
from Visual Studio of version (.NET) 2002 or (.NET) 2003, or 2004, or 2005
with the help of DirectX 9.0?
Beforehand many thanks for your answer.
Dr. Zharkov V.A., Moscow, Russia.
"Dr. Zharkov" <va************ @mtu-net.ru> wrote in message
news:ut******** ******@TK2MSFTN GP15.phx.gbl... I have not understood your answer. Explain, please, your answer more in
detail.
Dr. Zharkov V.A., Moscow, Russia.