PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Suche Direct X Gegenstück zu OpenGL Funktion glOrtho


Lord Nikon
2004-04-18, 19:40:03
Hi,
ich suche gerade das Gegenstück zu der OpenGL Funktion

void glOrtho( GLdouble left,
GLdouble right,
GLdouble bottom,
GLdouble top,
GLdouble zNear,
GLdouble zFar )

die den Sichtbereich einstellt.Ich möchte den Weltsichtbereich auf- 2,-2,2,2,-38,38) einstellen.
Es wäre nett wenn irgendjemand drauf antwortet :)

Einfachkrank
2004-04-18, 20:27:24
mhh, ist das bei DirectX nicht getrennt von einander? also in Direct3D und DirectDraw? nur so ne vermutung, bin mir aber nicht sicher

Brillus
2004-04-19, 03:05:05
Also ich kenne mich nicht mir OpenGl Programmierung aus, aber es sieht mir so aus als würde man mit dieser Funktion das View Frustum erschaffen, Sollte dies nicht stimmen ist der Folgende Abschnitt Gegenstandslos.

Also bei Direct3D definiter man das ViewFrustum indem man eine Projektionsmatrix setzt. Hier mein Code dafür.



bool nj_D3D_Projektions_Matrix(D3DMATRIX *mat, // Speicheradresse
float fFOV, // SichtWinkel in Rad
float fAspect, // Bildschirmverhältnis(Höhe/Breite)
float fNearPlane,// Sichtweite von
float fFarPlane) // Sichtweite bis
{
if (fabs(fFarPlane-fNearPlane) < 0.01f)
return false;
if (fabs(sin(fFOV/2)) < 0.01f)
return false;

float w = fAspect * ( cosf(fFOV/2)/sinf(fFOV/2) );
float h = 1.0f * ( cosf(fFOV/2)/sinf(fFOV/2) );
float Q = fFarPlane / ( fFarPlane - fNearPlane );

ZeroMemory(mat, sizeof(D3DMATRIX));
(*mat)._11 = w;
(*mat)._22 = h;
(*mat)._33 = Q;
(*mat)._34 = 1.0f;
(*mat)._43 = -Q*fNearPlane;

return true;
};

und damm mit
lpD3DDevice->SetTransform(D3DTS_PROJECTION, &matProj);
setzen wobei lpD3DDevice das 3DDevice darstellt und matProj die Projektionsmatrix die oben berechnet wurde.

2. Möglichkeit die mir einfällt was du vielleicht gemeint haben könntest wäre der Viewport dabeit Füllt man als erste eine D3DVIEWPORT9 Structure welche wie folgt definiert ist
typedef struct _D3DVIEWPORT9 {
DWORD X;
DWORD Y;
DWORD Width;
DWORD Height;
float MinZ;
float MaxZ;
} D3DVIEWPORT9;
X:
Pixel coordinate of the upper-left corner of the viewport on the render-target surface. Unless you want to render to a subset of the surface, this member can be set to 0.
Y:
Pixel coordinate of the upper-left corner of the viewport on the render-target surface. Unless you want to render to a subset of the surface, this member can be set to 0.
Width:
Width dimension of the clip volume, in pixels. Unless you are rendering only to a subset of the surface, this member should be set to the width dimension of the render-target surface.
Height:
Height dimension of the clip volume, in pixels. Unless you are rendering only to a subset of the surface, this member should be set to the height dimension of the render-target surface.
MinZ:
Together with MaxZ, value describing the range of depth values into which a scene is to be rendered, the minimum and maximum values of the clip volume. Most applications set this value to 0.0. Clipping is performed after applying the projection matrix.
MaxZ:
Together with MinZ, value describing the range of depth values into which a scene is to be rendered, the minimum and maximum values of the clip volume. Most applications set this value to 1.0. Clipping is performed after applying the projection matrix.

^^Aus DirctX SDK Kopiert

und setzt sie dann mit

lpD3DDevice->SetViewport(&D3DViewport);

Hoffe mein Post hilft dir

Lord Nikon
2004-04-19, 13:43:02
Danke dein Post hat mich schon weiter gebracht. Ich hab die entsprechende Methode für Managed Direct X schnell gefunden:)