473,327 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

How to construct a surface in VC# with the help of DirectX?

look up your timezome settings... you have future posted.
Nov 16 '05 #1
4 2158
I have not understood your answer. Explain, please, your answer more in
detail.

Dr. Zharkov V.A., Moscow, Russia.
Nov 16 '05 #2

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**************@TK2MSFTNGP15.phx.gbl...
I have not understood your answer. Explain, please, your answer more in
detail.

Dr. Zharkov V.A., Moscow, Russia.

Nov 16 '05 #3
You need to
1. Set up a device

internal void initGraphics()
{
// Set our presentation parameters, set up the Direct3D device
presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.DeviceWindow = this.portalPanel; //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.EnableAutoDepthStencil = true;
presentParams.AutoDepthStencilFormat = DepthFormat.D16;
// Store the default adapter
int adapterOrdinal = Manager.Adapters.Default.Adapter;
CreateFlags flags = CreateFlags.SoftwareVertexProcessing;
Caps caps = Manager.GetDeviceCaps(adapterOrdinal, DeviceType.Hardware);
// Do we support hardware vertex processing?
if (caps.DeviceCaps.SupportsHardwareTransformAndLight )
// Replace the software vertex processing
flags = CreateFlags.HardwareVertexProcessing;
// Do we support a pure device?
if (caps.DeviceCaps.SupportsPureDevice)
flags |= CreateFlags.PureDevice;
flags = CreateFlags.HardwareVertexProcessing; //better be there...

try
{
// Create our device
device = new Device(adapterOrdinal, DeviceType.Hardware,
this.portalPanel, flags, presentParams);
}
catch
{
if (device != null)
device.Dispose();
MessageBox.Show("unable to create device");
clearFlags = ClearFlags.Target;
presentParams.EnableAutoDepthStencil = false;
presentParams.AutoDepthStencilFormat = 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.BetginScene();
device.DrawUserPrimitives(PrimitiveType.TriangleLi st, 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.RenderState.Ambient = Color.DarkBlue;device.RenderState.CullMode =
Cull.CounterClockwise;

device.RenderState.Lighting = true;

device.Lights[0].Type = LightType.Directional;

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.Transform.World = worldTransform;

device.Transform.Projection =

Matrix.PerspectiveFovLH(camera.fieldOfView, camera.aspectRatio,

camera.nearPlane, camera.farPlane);

device.Transform.View =

Matrix.LookAtLH(camera.positionV, camera.targetPosition,

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**************@TK2MSFTNGP10.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**************@TK2MSFTNGP15.phx.gbl...
I have not understood your answer. Explain, please, your answer more in
detail.

Dr. Zharkov V.A., Moscow, Russia.


Nov 16 '05 #4
Dear Mr. Fred Mellender.

Many thanks for your answer.

In projects Visual C#, Windows Application (from Visual Studio 2005) on the
Form1 I have constructed all six examples from Tutorial 1-6 (DirectX 9.0 SDK
Update - Summer 2004, Direct3D). On the Form1 with the help of Tutorial 4 I
have constructed the rotating cylinder.

Inform, please, as it is necessary to change the program in Tutorial 4, that
instead of the cylinder the sphere rotated?

Beforehand many thanks for your answer.

Dr. Zharkov V.A., Moscow, Russia.
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dr. Zharkov | last post by:
Hello. I have installed on my computer Visual Studio 2005 Beta and DirectX 9.0 SDK Update - (Summer 2004). I have developed projects Visual Basic, Visual C# and Visual C++ for construction of...
7
by: kastillo | last post by:
Im trying to install directx 9.0 c , but i simply cant . When i run the installer it just says " The installed components are ready to use". This is the report on directx.log : 09/10/05...
0
by: Dr. Zharkov | last post by:
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# for construction of 3-Dimensional geometrical bodies,...
9
by: Mike P | last post by:
Problems, problems... Im trying to create DirectX Projects within C# and to also look at the latest DirectX C# Samples. I have just installed MS Visual C# .net Standard Edition on my Windows...
0
by: Harvey Cohen | last post by:
Hello all, I have some C# code that implements calls to DirectX.DirectSound. It compiles under both VS .NET 2003 and VS 2005 and runs under VS .NET 2003 and VS 2005 on a Compaq laptop (Windows...
14
by: Jessica Weiner | last post by:
I am writing an application in C# which need to plot graphs and simple shapes (polygons, circles, squares etc). Which library is better for this purpose and why? Thanks.
1
Nasenbaer
by: Nasenbaer | last post by:
Hi I read some articles about my problem. But in most cases no code is attached. My question is how to put my Bitmap into a DirectX Surface using Vb.Net. I want to put it in DirectX and stretch...
0
by: Jameson | last post by:
ok... This isn't working, and I dont know why, when I pass the resulting surface to StretchRectangle I get the awsome "error in application" haha... anyway. Is this not the right way (using...
7
by: Jameson | last post by:
ok... This isn't working, and I dont know why, when I pass the resulting surface to StretchRectangle I get the awsome "error in application" haha... anyway. Is this not the right way (using...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.