Oh yes, my fail - I had to clear zbuffer because I wanted it to work at least on things I draw. When I didn't clear zbuffer everything I drew appeared behind game world. Anyway I have no idea what is wrong. I tried to do same things as you:
Code:
device.SetVertexShader( null );
device.SetPixelShader( null );
// TODO: create wrapper for camera
float* pActiveCamera = Pointers.ActiveCamera;
Vector3 camera = new Vector3( pActiveCamera + 2 );
float zNearPlane = *( pActiveCamera + 14 );
float zFarPlane = *( pActiveCamera + 15 );
float fieldOfView = *( pActiveCamera + 16 );
float aspect = *( pActiveCamera + 17 );
lookAt = lookAt + new Vector3( 0, 0, *( pActiveCamera + 74 ) );
Matrix view = Matrix.LookAtRH( camera, lookAt, new Vector3( 0, 0, 1f ) );
Matrix projection = Matrix.PerspectiveFovRH( fieldOfView * 0.6f, aspect, zNearPlane, zFarPlane );
device.SetTransform( D3DTransformStateType.VIEW, &view );
device.SetTransform( D3DTransformStateType.PROJECTION, &projection );
Code:
public unsafe void SetTarget( Vector3 vector, float yaw = 0, float pitch = 0, float roll = 0 ) {
Matrix worldMatrix = Matrix.Translation( vector ) * Matrix.RotationYawPitchRoll( yaw, pitch, roll );
device.SetTransform( ( D3DTransformStateType )256, &worldMatrix );
}
public unsafe void DrawTriangles( params Triangle[] triangles ) {
device.SetFVF( D3DFVF.XYZ /*| D3DFVF.NORMAL*/ | D3DFVF.DIFFUSE );
device.SetTexture( 0, null );
fixed ( Triangle* pBuffer = triangles )
device.DrawPrimitiveUP( D3DPrimitiveType.TRIANGLESTRIP, ( uint )triangles.Length, pBuffer, ( uint )sizeof( Vertex ) );
}
Code:
[Name( "Triangle test" )]
class TriangleTest( IScript ):
def constructor():
self._triangles = (
Triangle( Vector3( 0.0f, 0.0f, 5.0f ), Colors.Green, Vector3( 0.0f, 0.0f, 0.0f ), Colors.Blue, Vector3( -5.0f, 0.0f, 0.0f ), Colors.Red ),
);
private _triangles as (Triangle)
def Tick():
graphics = Direct3D.Graphics;
//graphics.SetTarget( ObjectManager.Player.Target.Position, 0, 0, 0 );
graphics.SetTarget( Vector3( -6225.297f, 332.9926f, 383.205f ), 0, 0, 0 );
graphics.DrawTriangles( *self._triangles );
And result: http://dl.dropbox.com/u/1799304/Mmow...510_170241.jpg
And with lightning
Code:
device.SetRenderState( D3DRenderStateType.AMBIENT, 0xff7f7f7f );
device.SetRenderState( D3DRenderStateType.LIGHTING, 1 );
http://dl.dropbox.com/u/1799304/Mmow...510_170349.jpg