// H to Pas Converter Ver.0.17.0.20
//     Date : 26 9 1999
//   Source : d3drmdef.h

unit d3drmdef;

{$X+}{$Z2}

interface

uses Windows, d3dtypes;

(*==========================================================================;
 *
 *  Copyright (C) 1995-1997 Microsoft Corporation.  All Rights Reserved.
 *
 *  File:       d3drm.h
 *  Content:    Direct3DRM include file
 *
 ***************************************************************************)


type
  LPD3DRMVECTOR4D	= ^D3DRMVECTOR4D;
  D3DRMVECTOR4D = record
	x, y, z, w	: D3DVALUE;
  end;

  D3DRMMATRIX4D	= array[0..3,0..3] of D3DVALUE;
  LPD3DRMMATRIX4D = ^D3DRMMATRIX4D;

  LPD3DRMQUATERNION	= ^D3DRMQUATERNION;
  D3DRMQUATERNION = record
	s	: D3DVALUE;
	v	: D3DVECTOR;
  end;

  LPD3DRMRAY	= ^D3DRMRAY;
  D3DRMRAY = record
	dvDir	: D3DVECTOR;
	dvPos	: D3DVECTOR;
  end;

  LPD3DRMBOX	= ^D3DRMBOX;
  D3DRMBOX = record
	min, max	: D3DVECTOR;
  end;

  D3DRMWRAPCALLBACK =   function (Para0: LPD3DVECTOR; u: PInteger; v: PInteger;
	 a: LPD3DVECTOR; b: LPD3DVECTOR; Para1: Pointer): Pointer; stdcall;

  D3DRMLIGHTTYPE = (
	D3DRMLIGHT_AMBIENT,
	D3DRMLIGHT_POINT,
	D3DRMLIGHT_SPOT,
	D3DRMLIGHT_DIRECTIONAL,
	D3DRMLIGHT_PARALLELPOINT
  );
  LPD3DRMLIGHTTYPE	= ^D3DRMLIGHTTYPE;


type
  D3DRMSHADEMODE    = DWord;
  LPD3DRMSHADEMODE	= ^D3DRMSHADEMODE;
  D3DRMLIGHTMODE    = DWord;
  LPD3DRMLIGHTMODE  = ^D3DRMLIGHTMODE;
  D3DRMFILLMODE     = DWord;
  LPD3DRMFILLMODE   = ^D3DRMFILLMODE;

const
	D3DRMSHADE_FLAT   :D3DRMSHADEMODE = 0;
	D3DRMSHADE_GOURAUD:D3DRMSHADEMODE = 1;
	D3DRMSHADE_PHONG  :D3DRMSHADEMODE = 2;
	D3DRMSHADE_MASK   :D3DRMSHADEMODE = 7;
	D3DRMSHADE_MAX    :D3DRMSHADEMODE = 8;

  D3DRMLIGHT_OFF    :D3DRMLIGHTMODE = 0 * 8;
  D3DRMLIGHT_ON     :D3DRMLIGHTMODE = 1 * 8;
  D3DRMLIGHT_MASK   :D3DRMLIGHTMODE = 7 * 8;
  D3DRMLIGHT_MAX    :D3DRMLIGHTMODE = 8 * 8;

  D3DRMFILL_POINTS    :D3DRMFILLMODE= 0 * 8 * 8;
  D3DRMFILL_WIREFRAME :D3DRMFILLMODE= 1 * 8 * 8;
  D3DRMFILL_SOLID     :D3DRMFILLMODE= 2 * 8 * 8;
  D3DRMFILL_MASK      :D3DRMFILLMODE= 7 * 8 * 8;
  D3DRMFILL_MAX       :D3DRMFILLMODE= 8 * 8 * 8;



type

  D3DRMRENDERQUALITY	= DWORD;
  LPD3DRMRENDERQUALITY	= ^DWORD;

const
  D3DRMRENDER_WIREFRAME	= ( 0 + 0*8 + 1*64 );
  D3DRMRENDER_UNLITFLAT	= ( 0 + 0*8 + 2*64 );
  D3DRMRENDER_FLAT	=     ( 0 + 1*8 + 2*64 );
  D3DRMRENDER_GOURAUD	=   ( 1 + 1*8 + 2*64 );
  D3DRMRENDER_PHONG	=     ( 2 + 1*8 + 2*64 );

  D3DRMRENDERMODE_BLENDEDTRANSPARENCY	= 1;
  D3DRMRENDERMODE_SORTEDTRANSPARENCY	= 2;
  D3DRMRENDERMODE_LIGHTINMODELSPACE	= 8;
  D3DRMRENDERMODE_VIEWDEPENDENTSPECULAR	= 16;
  D3DRMRENDERMODE_DISABLESORTEDALPHAZWRITE	= 32;

type
  D3DRMTEXTUREQUALITY = (
	D3DRMTEXTURE_NEAREST,
	D3DRMTEXTURE_LINEAR,
	D3DRMTEXTURE_MIPNEAREST,
	D3DRMTEXTURE_MIPLINEAR,
	D3DRMTEXTURE_LINEARMIPNEAREST,
	D3DRMTEXTURE_LINEARMIPLINEAR
  );
  LPD3DRMTEXTUREQUALITY	= ^D3DRMTEXTUREQUALITY;

(*
 * Texture flags
 *)
const
  D3DRMTEXTURE_FORCERESIDENT	= $00000001;	(* texture should be kept in video memory *)
  D3DRMTEXTURE_STATIC	= $00000002;	(* texture will not change *)
  D3DRMTEXTURE_DOWNSAMPLEPOINT	= $00000004;	(* point filtering should be used when downsampling *)
  D3DRMTEXTURE_DOWNSAMPLEBILINEAR	= $00000008;	(* bilinear filtering should be used when downsampling *)
  D3DRMTEXTURE_DOWNSAMPLEREDUCEDEPTH	= $00000010;	(* reduce bit depth when downsampling *)
  D3DRMTEXTURE_DOWNSAMPLENONE	= $00000020;	(* texture should never be downsampled *)
  D3DRMTEXTURE_CHANGEDPIXELS	= $00000040;	(* pixels have changed *)
  D3DRMTEXTURE_CHANGEDPALETTE	= $00000080;	(* palette has changed *)
  D3DRMTEXTURE_INVALIDATEONLY	= $00000100;	(* dirty regions are invalid *)

(*
 * Shadow flags
 *)
  D3DRMSHADOW_TRUEALPHA	= $00000001;	(* shadow should render without artifacts when true alpha is on *)

type
  D3DRMCOMBINETYPE = (
	D3DRMCOMBINE_REPLACE,
	D3DRMCOMBINE_BEFORE,
	D3DRMCOMBINE_AFTER
  );
  LPD3DRMCOMBINETYPE	= ^D3DRMCOMBINETYPE;

  D3DRMCOLORMODEL	= D3DCOLORMODEL;
  LPD3DRMCOLORMODEL	= ^D3DCOLORMODEL;

  D3DRMPALETTEFLAGS = (
	D3DRMPALETTE_FREE,
	D3DRMPALETTE_READONLY,
	D3DRMPALETTE_RESERVED
  );
  LPD3DRMPALETTEFLAGS	= ^D3DRMPALETTEFLAGS;

  LPD3DRMPALETTEENTRY	= ^D3DRMPALETTEENTRY;
  D3DRMPALETTEENTRY = record
	red	: UCHAR;	(* 0 .. 255 *)
	green	: UCHAR;	(* 0 .. 255 *)
	blue	: UCHAR;	(* 0 .. 255 *)
	flags	: UCHAR;	(* one of D3DRMPALETTEFLAGS *)
  end;

  LPD3DRMIMAGE	= ^D3DRMIMAGE;
  D3DRMIMAGE = record
	width, height	: Integer;	(* width and height in pixels *)
	aspectx, aspecty	: Integer;	(* aspect ratio for non-square pixels *)
	depth	: Integer;	(* bits per pixel *)
	rgb	: Integer;	(* if false, pixels are indices into a
                                   palette otherwise, pixels encode
                                   RGB values. *)
	bytes_per_line	: Integer;	(* number of bytes of memory for a
                                   scanline. This must be a multiple
                                   of 4. *)
	buffer1	: Pointer;	(* memory to render into (first buffer). *)
	buffer2	: Pointer;	(* second rendering buffer for double
                                   buffering, set to NULL for single
                                   buffering. *)
	red_mask	: ULONG;
	green_mask	: ULONG;
	blue_mask	: ULONG;
	alpha_mask	: ULONG;	(* if rgb is true, these are masks for
                                   the red, green and blue parts of a
                                   pixel.  Otherwise, these are masks
                                   for the significant bits of the
                                   red, green and blue elements in the
                                   palette.  For instance, most SVGA
                                   displays use 64 intensities of red,
                                   green and blue, so the masks should
                                   all be set to 0xfc. *)
	palette_size	: Integer;	(* number of entries in palette *)
	palette	: LPD3DRMPALETTEENTRY;	(* description of the palette (only if
                                   rgb is false).  Must be (1<<depth)
                                   elements. *)
  end;

  D3DRMWRAPTYPE = (
	D3DRMWRAP_FLAT,
	D3DRMWRAP_CYLINDER,
	D3DRMWRAP_SPHERE,
	D3DRMWRAP_CHROME,
	D3DRMWRAP_SHEET,
	D3DRMWRAP_BOX
  );
  LPD3DRMWRAPTYPE	= ^D3DRMWRAPTYPE;

const
  D3DRMWIREFRAME_CULL	= 1;	(* cull backfaces *)
  D3DRMWIREFRAME_HIDDENLINE	= 2;	(* lines are obscured by closer objects *)

(*
 * Do not use righthanded perspective in Viewport2::SetProjection().
 * Set up righthanded mode by using IDirect3DRM3::SetOptions().
 *)
type
  D3DRMPROJECTIONTYPE = (
	D3DRMPROJECT_PERSPECTIVE,
	D3DRMPROJECT_ORTHOGRAPHIC,
	D3DRMPROJECT_RIGHTHANDPERSPECTIVE,
	D3DRMPROJECT_RIGHTHANDORTHOGRAPHIC
  );
  LPD3DRMPROJECTIONTYPE	= ^D3DRMPROJECTIONTYPE;

const
  D3DRMOPTIONS_LEFTHANDED	= $00000001;	(* Default *)
  D3DRMOPTIONS_RIGHTHANDED	= $00000002;

type
  D3DRMXOFFORMAT = (
	D3DRMXOF_BINARY,
	D3DRMXOF_COMPRESSED,
	D3DRMXOF_TEXT
  );
  LPD3DRMXOFFORMAT	= ^D3DRMXOFFORMAT;

  D3DRMSAVEOPTIONS	= DWORD;
const
  D3DRMXOFSAVE_NORMALS	= 1;
  D3DRMXOFSAVE_TEXTURECOORDINATES	= 2;
  D3DRMXOFSAVE_MATERIALS	= 4;
  D3DRMXOFSAVE_TEXTURENAMES	= 8;
  D3DRMXOFSAVE_ALL	= 15;
  D3DRMXOFSAVE_TEMPLATES	= 16;
  D3DRMXOFSAVE_TEXTURETOPOLOGY	= 32;

type
  D3DRMCOLORSOURCE = (
	D3DRMCOLOR_FROMFACE,
	D3DRMCOLOR_FROMVERTEX
  );
  LPD3DRMCOLORSOURCE	= ^D3DRMCOLORSOURCE;

  D3DRMFRAMECONSTRAINT = (
	D3DRMCONSTRAIN_Z,
	D3DRMCONSTRAIN_Y,
	D3DRMCONSTRAIN_X
  );
  LPD3DRMFRAMECONSTRAINT	= ^D3DRMFRAMECONSTRAINT;

  D3DRMMATERIALMODE = (
	D3DRMMATERIAL_FROMMESH,
	D3DRMMATERIAL_FROMPARENT,
	D3DRMMATERIAL_FROMFRAME
  );
  LPD3DRMMATERIALMODE	= ^D3DRMMATERIALMODE;

  D3DRMFOGMODE = (
	D3DRMFOG_LINEAR,
	D3DRMFOG_EXPONENTIAL,
	D3DRMFOG_EXPONENTIALSQUARED
  );
  LPD3DRMFOGMODE	= ^D3DRMFOGMODE;

  D3DRMZBUFFERMODE = (
	D3DRMZBUFFER_FROMPARENT,
	D3DRMZBUFFER_ENABLE,
	D3DRMZBUFFER_DISABLE
  );
  LPD3DRMZBUFFERMODE	= ^D3DRMZBUFFERMODE;

  D3DRMSORTMODE = (
	D3DRMSORT_FROMPARENT,
	D3DRMSORT_NONE,
	D3DRMSORT_FRONTTOBACK,
	D3DRMSORT_BACKTOFRONT
  );
  LPD3DRMSORTMODE	= ^D3DRMSORTMODE;

  LPD3DRMMATERIALOVERRIDE	= ^D3DRMMATERIALOVERRIDE;
  D3DRMMATERIALOVERRIDE = record
	dwSize	: DWORD;	(* Size of this structure *)
	dwFlags	: DWORD;	(* Indicate which fields are valid *)
	dcDiffuse	: D3DCOLORVALUE;	(* RGBA *)
	dcAmbient	: D3DCOLORVALUE;	(* RGB *)
	dcEmissive	: D3DCOLORVALUE;	(* RGB *)
	dcSpecular	: D3DCOLORVALUE;	(* RGB *)
	dvPower	: D3DVALUE;
	lpD3DRMTex	: IUNKNOWN;
  end;

const
  D3DRMMATERIALOVERRIDE_DIFFUSE_ALPHAONLY	= $00000001;
  D3DRMMATERIALOVERRIDE_DIFFUSE_RGBONLY	= $00000002;
  D3DRMMATERIALOVERRIDE_DIFFUSE	= $00000003;
  D3DRMMATERIALOVERRIDE_AMBIENT	= $00000004;
  D3DRMMATERIALOVERRIDE_EMISSIVE	= $00000008;
  D3DRMMATERIALOVERRIDE_SPECULAR	= $00000010;
  D3DRMMATERIALOVERRIDE_POWER	= $00000020;
  D3DRMMATERIALOVERRIDE_TEXTURE	= $00000040;
  D3DRMMATERIALOVERRIDE_DIFFUSE_ALPHAMULTIPLY	= $00000080;
  D3DRMMATERIALOVERRIDE_ALL	= $000000FF;

  D3DRMFPTF_ALPHA	= $00000001;
  D3DRMFPTF_NOALPHA	= $00000002;
  D3DRMFPTF_PALETTIZED	= $00000004;
  D3DRMFPTF_NOTPALETTIZED	= $00000008;

  D3DRMSTATECHANGE_UPDATEONLY	= $000000001;
  D3DRMSTATECHANGE_VOLATILE	= $000000002;
  D3DRMSTATECHANGE_NONVOLATILE	= $000000004;
  D3DRMSTATECHANGE_RENDER	= $000000020;
  D3DRMSTATECHANGE_LIGHT	= $000000040;

(*
 * Values for flags in RM3::CreateDeviceFromSurface
 *)
  D3DRMDEVICE_NOZBUFFER	= $00000001;

(*
 * Values for flags in Object2::SetClientData
 *)
  D3DRMCLIENTDATA_NONE	= $00000001;
  D3DRMCLIENTDATA_LOCALFREE	= $00000002;
  D3DRMCLIENTDATA_IUNKNOWN	= $00000004;

(*
 * Values for flags in Frame2::AddMoveCallback.
 *)
  D3DRMCALLBACK_PREORDER	= 0;
  D3DRMCALLBACK_POSTORDER	= 1;

(*
 * Values for flags in MeshBuilder2::RayPick.
 *)
  D3DRMRAYPICK_ONLYBOUNDINGBOXES	= 1;
  D3DRMRAYPICK_IGNOREFURTHERPRIMITIVES	= 2;
  D3DRMRAYPICK_INTERPOLATEUV	= 4;
  D3DRMRAYPICK_INTERPOLATECOLOR	= 8;
  D3DRMRAYPICK_INTERPOLATENORMAL	= $10;

(*
 * Values for flags in MeshBuilder3::AddFacesIndexed.
 *)
  D3DRMADDFACES_VERTICESONLY	= 1;

(*
 * Values for flags in MeshBuilder2::GenerateNormals.
 *)
  D3DRMGENERATENORMALS_PRECOMPACT	= 1;
  D3DRMGENERATENORMALS_USECREASEANGLE	= 2;

(*
 * Values for MeshBuilder3::GetParentMesh
 *)
  D3DRMMESHBUILDER_DIRECTPARENT	= 1;
  D3DRMMESHBUILDER_ROOTMESH	= 2;

(*
 * Flags for MeshBuilder3::Enable
 *)
  D3DRMMESHBUILDER_RENDERENABLE	= $00000001;
  D3DRMMESHBUILDER_PICKENABLE	= $00000002;

(*
 * Flags for MeshBuilder3::AddMeshBuilder
 *)
  D3DRMADDMESHBUILDER_DONTCOPYAPPDATA	= 1;
  D3DRMADDMESHBUILDER_FLATTENSUBMESHES	= 2;
  D3DRMADDMESHBUILDER_NOSUBMESHES	= 4;

(*
 * Flags for Object2::GetAge when used with MeshBuilders
 *)
  D3DRMMESHBUILDERAGE_GEOMETRY	= $00000001;
  D3DRMMESHBUILDERAGE_MATERIALS	= $00000002;
  D3DRMMESHBUILDERAGE_TEXTURES	= $00000004;

(*
 * Format flags for MeshBuilder3::AddTriangles.
 *)
  D3DRMFVF_TYPE	= $00000001;
  D3DRMFVF_NORMAL	= $00000002;
  D3DRMFVF_COLOR	= $00000004;
  D3DRMFVF_TEXTURECOORDS	= $00000008;

  D3DRMVERTEX_STRIP	= $00000001;
  D3DRMVERTEX_FAN	= $00000002;
  D3DRMVERTEX_LIST	= $00000004;

(*
 * Values for flags in Viewport2::Clear2
 *)
  D3DRMCLEAR_TARGET	= $00000001;
  D3DRMCLEAR_ZBUFFER	= $00000002;
  D3DRMCLEAR_DIRTYRECTS	= $00000004;
  D3DRMCLEAR_ALL	= ( D3DRMCLEAR_TARGET or D3DRMCLEAR_ZBUFFER or D3DRMCLEAR_DIRTYRECTS
         );

(*
 * Values for flags in Frame3::SetSceneFogMethod
 *)
  D3DRMFOGMETHOD_VERTEX	= $00000001;
  D3DRMFOGMETHOD_TABLE	= $00000002;
  D3DRMFOGMETHOD_ANY	= $00000004;

(*
 * Values for flags in Frame3::SetTraversalOptions
 *)
  D3DRMFRAME_RENDERENABLE	= $00000001;
  D3DRMFRAME_PICKENABLE	= $00000002;

type
  D3DRMANIMATIONOPTIONS	= DWORD;
const
  D3DRMANIMATION_OPEN	= $01;
  D3DRMANIMATION_CLOSED	= $02;
  D3DRMANIMATION_LINEARPOSITION	= $04;
  D3DRMANIMATION_SPLINEPOSITION	= $08;
  D3DRMANIMATION_SCALEANDROTATION	= $00000010;
  D3DRMANIMATION_POSITION	= $00000020;

type
  D3DRMINTERPOLATIONOPTIONS	= DWORD;
const
  D3DRMINTERPOLATION_OPEN	= $01;
  D3DRMINTERPOLATION_CLOSED	= $02;
  D3DRMINTERPOLATION_NEAREST	= $0100;
  D3DRMINTERPOLATION_LINEAR	= $04;
  D3DRMINTERPOLATION_SPLINE	= $08;
  D3DRMINTERPOLATION_VERTEXCOLOR	= $40;
  D3DRMINTERPOLATION_SLERPNORMALS	= $80;

type
  D3DRMLOADOPTIONS	= DWORD;

const
  D3DRMLOAD_FROMFILE	= $00;
  D3DRMLOAD_FROMRESOURCE	= $01;
  D3DRMLOAD_FROMMEMORY	= $02;
  D3DRMLOAD_FROMSTREAM	= $04;
  D3DRMLOAD_FROMURL	= $08;

  D3DRMLOAD_BYNAME	= $10;
  D3DRMLOAD_BYPOSITION	= $20;
  D3DRMLOAD_BYGUID	= $40;
  D3DRMLOAD_FIRST	= $80;

  D3DRMLOAD_INSTANCEBYREFERENCE	= $100;
  D3DRMLOAD_INSTANCEBYCOPYING	= $200;

  D3DRMLOAD_ASYNCHRONOUS	= $400;

type
  LPD3DRMLOADRESOURCE	= ^D3DRMLOADRESOURCE;
  D3DRMLOADRESOURCE = record
	hModule	: HMODULE;
	lpName	: PChar;
	lpType	: PChar;
  end;

  LPD3DRMLOADMEMORY	= ^D3DRMLOADMEMORY;
  D3DRMLOADMEMORY = record
	lpMemory	: Pointer;
	dSize	: DWORD;
  end;

const
  D3DRMPMESHSTATUS_VALID	= $01;
  D3DRMPMESHSTATUS_INTERRUPTED	= $02;
  D3DRMPMESHSTATUS_BASEMESHCOMPLETE	= $04;
  D3DRMPMESHSTATUS_COMPLETE	= $08;
  D3DRMPMESHSTATUS_RENDERABLE	= $10;

  D3DRMPMESHEVENT_BASEMESH	= $01;
  D3DRMPMESHEVENT_COMPLETE	= $02;

type
  LPD3DRMPMESHLOADSTATUS	= ^D3DRMPMESHLOADSTATUS;
  D3DRMPMESHLOADSTATUS = record
	dwSize	: DWORD;	// Size of this structure
	dwPMeshSize	: DWORD;	// Total Size (bytes)
	dwBaseMeshSize	: DWORD;	// Total Size of the Base Mesh
	dwBytesLoaded	: DWORD;	// Total bytes loaded
	dwVerticesLoaded	: DWORD;	// Number of vertices loaded
	dwFacesLoaded	: DWORD;	// Number of faces loaded
	dwLoadResult	: HRESULT;	// Result of the load operation
	dwFlags	: DWORD;
  end;

  D3DRMUSERVISUALREASON = (
	D3DRMUSERVISUAL_CANSEE,
	D3DRMUSERVISUAL_RENDER
  );
  LPD3DRMUSERVISUALREASON	= ^D3DRMUSERVISUALREASON;


  D3DRMANIMATIONKEY = record
	dwSize	: DWORD;
	dwKeyType	: DWORD;
	dvTime	: D3DVALUE;
	dwID	: DWORD;
	case Integer of
	0: (
	  dqRotateKey	: D3DRMQUATERNION;
	  dvK	: array[0..3] of D3DVALUE;
	);
	1: (
	  dvScaleKey	: D3DVECTOR;
	);
	2: (
	  dvPositionKey	: D3DVECTOR;
	);
  end;
  LPD3DRMANIMATIONKEY	= ^D3DRMANIMATIONKEY;


(*
procedure D3DRMAnimationGetRotateKey( & rmKey , D3DRMQUATERNION & rmQuat )  {
    rmQuat.s = rmKey.dvK[0];
    rmQuat.v = D3DVECTOR(rmKey.dvK[1], rmKey.dvK[2], rmKey.dvK[3]);
} *)

(*
procedure D3DRMAnimationGetScaleKey( & rmKey , TD3DVECTOR & dvVec )  {
    dvVec = D3DVECTOR(rmKey.dvK[0], rmKey.dvK[1], rmKey.dvK[2]);
} *)

(*
procedure D3DRMAnimationGetPositionKey( & rmKey , TD3DVECTOR & dvVec )  {
    dvVec = D3DVECTOR(rmKey.dvK[0], rmKey.dvK[1], rmKey.dvK[2]);
} *)

(*
procedure D3DRMAnimationSetRotateKey( & rmKey , const D3DRMQUATERNION & rmQuat )  {
    rmKey.dvK[0] = rmQuat.s;
    rmKey.dvK[1] = rmQuat.v.x;
    rmKey.dvK[2] = rmQuat.v.y;
    rmKey.dvK[3] = rmQuat.v.z;
} *)

(*
procedure D3DRMAnimationSetScaleKey( & rmKey , const TD3DVECTOR & dvVec )  {
    rmKey.dvK[0] = dvVec.x;
    rmKey.dvK[1] = dvVec.y;
    rmKey.dvK[2] = dvVec.z;
} *)

(*
procedure D3DRMAnimationSetPositionKey( & rmKey , const TD3DVECTOR & dvVec )  {
    rmKey.dvK[0] = dvVec.x;
    rmKey.dvK[1] = dvVec.y;
    rmKey.dvK[2] = dvVec.z;
} *)


const
  D3DRMANIMATION_ROTATEKEY	= $01;
  D3DRMANIMATION_SCALEKEY	= $02;
  D3DRMANIMATION_POSITIONKEY	= $03;


type
  D3DRMMAPPING	= DWORD;
  D3DRMMAPPINGFLAG	= DWORD;
  LPD3DRMMAPPING	= ^DWORD;
const
  D3DRMMAP_WRAPU	: D3DRMMAPPINGFLAG	= 1;
  D3DRMMAP_WRAPV	: D3DRMMAPPINGFLAG	= 2;
  D3DRMMAP_PERSPCORRECT	: D3DRMMAPPINGFLAG	= 4;

type
  LPD3DRMVERTEX	= ^D3DRMVERTEX;
  D3DRMVERTEX = record
	position	: D3DVECTOR;
	normal	: D3DVECTOR;
	tu, tv	: D3DVALUE;
	color	: D3DCOLOR;
  end;

  D3DRMGROUPINDEX	= LongInt;	(* group indexes begin a 0 *)
const
  D3DRMGROUP_ALLGROUPS:D3DRMGROUPINDEX = -1;

(*
 * Create a color from three components in the range 0-1 inclusive.
 *)
  function D3DRMCreateColorRGB(red: D3DVALUE; green: D3DVALUE; blue: D3DVALUE): D3DCOLOR; stdcall;

(*
 * Create a color from four components in the range 0-1 inclusive.
 *)
  function D3DRMCreateColorRGBA(red: D3DVALUE; green: D3DVALUE; blue: D3DVALUE; 
	 alpha: D3DVALUE): D3DCOLOR; stdcall;

(*
 * Get the red component of a color.
 *)
  function D3DRMColorGetRed(Para0: D3DCOLOR): D3DVALUE; stdcall;

(*
 * Get the green component of a color.
 *)
  function D3DRMColorGetGreen(Para0: D3DCOLOR): D3DVALUE; stdcall;

(*
 * Get the blue component of a color.
 *)
  function D3DRMColorGetBlue(Para0: D3DCOLOR): D3DVALUE; stdcall;

(*
 * Get the alpha component of a color.
 *)
  function D3DRMColorGetAlpha(Para0: D3DCOLOR): D3DVALUE; stdcall;

(*
 * Add two vectors.  Returns its first argument.
 *)
  function D3DRMVectorAdd(d: LPD3DVECTOR; s1: LPD3DVECTOR; s2: LPD3DVECTOR): LPD3DVECTOR; stdcall;

(*
 * Subtract two vectors.  Returns its first argument.
 *)
  function D3DRMVectorSubtract(d: LPD3DVECTOR; s1: LPD3DVECTOR; s2: LPD3DVECTOR): LPD3DVECTOR; stdcall;
(*
 * Reflect a ray about a given normal.  Returns its first argument.
 *)
  function D3DRMVectorReflect(d: LPD3DVECTOR; ray: LPD3DVECTOR; norm: LPD3DVECTOR): LPD3DVECTOR; stdcall;

(*
 * Calculate the vector cross product.  Returns its first argument.
 *)
  function D3DRMVectorCrossProduct(d: LPD3DVECTOR; s1: LPD3DVECTOR; s2: LPD3DVECTOR): LPD3DVECTOR; stdcall;
(*
 * Return the vector dot product.
 *)
  function D3DRMVectorDotProduct(s1: LPD3DVECTOR; s2: LPD3DVECTOR): D3DVALUE; stdcall;

(*
 * Scale a vector so that its modulus is 1.  Returns its argument or
 * NULL if there was an error (e.g. a zero vector was passed).
 *)
  function D3DRMVectorNormalize(Para0: LPD3DVECTOR): LPD3DVECTOR; stdcall;

 (*
 const
  D3DRMVectorNormalise	= D3DRMVectorNormalize;
 *)

(*
 * Return the length of a vector (e.g. sqrt(x*x + y*y + z*z)).
 *)
  function D3DRMVectorModulus(v: LPD3DVECTOR): D3DVALUE; stdcall;

(*
 * Set the rotation part of a matrix to be a rotation of theta radians
 * around the given axis.
 *)

  function D3DRMVectorRotate(r: LPD3DVECTOR; v: LPD3DVECTOR; axis: LPD3DVECTOR; theta: D3DVALUE): LPD3DVECTOR; stdcall;

(*
 * Scale a vector uniformly in all three axes
 *)
  function D3DRMVectorScale(d: LPD3DVECTOR; s: LPD3DVECTOR; factor: D3DVALUE): LPD3DVECTOR; stdcall;

(*
 * Return a random unit vector
 *)
  function D3DRMVectorRandom(d: LPD3DVECTOR): LPD3DVECTOR; stdcall;

(*
 * Returns a unit quaternion that represents a rotation of theta radians
 * around the given axis.
 *)

  function D3DRMQuaternionFromRotation(quat: LPD3DRMQUATERNION; v: LPD3DVECTOR;
	 theta: D3DVALUE): LPD3DRMQUATERNION; stdcall;

(*
 * Calculate the product of two quaternions
 *)
  function D3DRMQuaternionMultiply(q: LPD3DRMQUATERNION; a: LPD3DRMQUATERNION; 
	 b: LPD3DRMQUATERNION): LPD3DRMQUATERNION; stdcall;

(*
 * Interpolate between two quaternions
 *)
  function D3DRMQuaternionSlerp(q: LPD3DRMQUATERNION; a: LPD3DRMQUATERNION; b: LPD3DRMQUATERNION; 
	 alpha: D3DVALUE): LPD3DRMQUATERNION; stdcall;

(*
 * Calculate the matrix for the rotation that a unit quaternion represents
 *)
  procedure D3DRMMatrixFromQuaternion(dmMat: D3DRMMATRIX4D; lpDqQuat: LPD3DRMQUATERNION); stdcall;

(*
 * Calculate the quaternion that corresponds to a rotation matrix
 *)
  function D3DRMQuaternionFromMatrix(Para0: LPD3DRMQUATERNION; Para1: D3DRMMATRIX4D): LPD3DRMQUATERNION; stdcall;




implementation

const
  d3drm = 'd3drm.dll';

  function D3DRMCreateColorRGB; external d3drm name 'D3DRMCreateColorRGB';
  function D3DRMCreateColorRGBA; external d3drm name 'D3DRMCreateColorRGBA';
  function D3DRMColorGetRed; external d3drm name 'D3DRMColorGetRed';
  function D3DRMColorGetGreen; external d3drm name 'D3DRMColorGetGreen';
  function D3DRMColorGetBlue; external d3drm name 'D3DRMColorGetBlue';
  function D3DRMColorGetAlpha; external d3drm name 'D3DRMColorGetAlpha';
  function D3DRMVectorAdd; external d3drm name 'D3DRMVectorAdd';
  function D3DRMVectorSubtract; external d3drm name 'D3DRMVectorSubtract';
  function D3DRMVectorReflect; external d3drm name 'D3DRMVectorReflect';
  function D3DRMVectorCrossProduct; external d3drm name 'D3DRMVectorCrossProduct';
  function D3DRMVectorDotProduct; external d3drm name 'D3DRMVectorDotProduct';
  function D3DRMVectorNormalize; external d3drm name 'D3DRMVectorNormalize';
  function D3DRMVectorModulus; external d3drm name 'D3DRMVectorModulus';
  function D3DRMVectorRotate; external d3drm name 'D3DRMVectorRotate';
  function D3DRMVectorScale; external d3drm name 'D3DRMVectorScale';
  function D3DRMVectorRandom; external d3drm name 'D3DRMVectorRandom';
  function D3DRMQuaternionFromRotation; external d3drm name 'D3DRMQuaternionFromRotation';
  function D3DRMQuaternionMultiply; external d3drm name 'D3DRMQuaternionMultiply';
  function D3DRMQuaternionSlerp; external d3drm name 'D3DRMQuaternionSlerp';
  procedure D3DRMMatrixFromQuaternion; external d3drm name 'D3DRMMatrixFromQuaternion';
  function D3DRMQuaternionFromMatrix; external d3drm name 'D3DRMQuaternionFromMatrix';

end.
