World|Camera|Projection

igotjunk

Newcomer
Joined
Jan 5, 2004
Messages
24
Location
Melbourne
Hi,

I have just started programming DirextX in C#. I have a question about the basics.

I have created a simplke cube mesh in Max 6 then exported the mesh with texture into a file named cube.x

Tutorial Here

Then I loaded the mesh into my app. I have rotated and zoomed around the object no problem. Also using standard mesh objects I have created other cubes etc. in myproject.

I have been having a blast.

World ... location for placing objects.
View ( or camera ) ... location of you viewing
projection ... Field of View, aspect of ratio, start view point on z axis, end view point z axis

One Question though is that after the end view point of the projection goes out of range, it cuts my mesh off into blue space .... anyone know anything about envoirnment mapping or volume fog?

:D
 

Attachments

Fogging is supposed to be really simple to set up, you just configure:
FOGENABLE - Set to True to turn fog on
FOGTABLEMODE - Do you want table fog?
FOGVERTEXMODE - Fog method, usually Linear
RANGEFOGENABLE - Higher quality fog, hw dependent
FOGSTART - I'm not sure how these values work, you'll need to work it out
FOGEND -
FOGCOLOR - Specify the color of the fog
 
You need to set cull mode off

And you need to set the near and far clipping planes

Matrix.PerspectiveFOVLH(fov, aspect ratio, near plane, far plane)

The far plane determines when vertices are no longer vivsble.
 
PORTAL MAPS

Turning off CULL MODE not nessasarily a good idea. CULL is also responsible for back face culling, or not drawing the stuff you don't see, and would slow down a gaming engine using alot of models, from what I have read.

I have set the near and far planes ( that's the projection mentioned in the first post ). The titled cube mesh I created is huge in unit size, without a large far plane it is only part visable.

I believe that PORTAL MAPS and FOG are the ones for me.

There are 2 types of FOG in Directx Vertex and Pixel. Vertex done by Directx in CPU space and Pixel by the Graphics Card. So I choose pixel.

So I have to set the render state for fog. Something like this ...

Device.SetRenderState(D3DRS_FOGENABLE, bTRUE);
Device.SetRenderState(D3DRS_FOGCOLOR, Color);

But there lies my problem ...

(85): 'Microsoft.DirectX.Direct3D.Device.SetRenderState(int, float)' is inaccessible due to its protection level

:-\
 
PIXEL FOG

:eek:

Using C# you can't call SetRenderState, you have to address the properties instead ... silly me. This code worked.

device.RenderState.FogEnable = true;
device.RenderState.FogTableMode = Direct3D.FogMode.Linear;
device.RenderState.FogStart = 60.0f;
device.RenderState.FogEnd = 150.0f;
device.RenderState.FogDensity = 0.0001f;
device.RenderState.FogColor = System.Drawing.Color.Blue;
 

Attachments

Sometimes turning cullmode off for individual objects is necessary(If you're doing AlphaBlending on the cube, culling will still take off the back faces so it'll look strange when you can see through the cube) but generally it's always left on unless there is a reason not to.
 
Back
Top