Anonymous avatar Anonymous committed e7a9770

wrapped timer, file-mgr, camera, scene-mgr, script ...
Quat added

Comments (0)

Files changed (5)

SharpHammer/DisposableBase.cs

 using System;
 
-namespace Hmr
+namespace SharpHammer
 {
 	public abstract class DisposableBase : IDisposable
 	{

SharpHammer/Quat.cs

 
 namespace SharpHammer
 {
+	[StructLayout(LayoutKind.Sequential)]
 	public struct Quat
 	{
+		public float X;
+		public float Y;
+		public float Z;
+		public float W;
 	}
 }

SharpHammer/SharpHammer.csproj

   <PropertyGroup>
     <StartupObject />
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+    <PlatformTarget>x86</PlatformTarget>
+    <OutputPath>bin\x86\Debug\</OutputPath>
+    <DefineConstants>TRACE;DEBUG</DefineConstants>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+    <PlatformTarget>x86</PlatformTarget>
+    <OutputPath>bin\x86\Release\</OutputPath>
+    <Optimize>true</Optimize>
+    <DefineConstants>TRACE</DefineConstants>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="System.Drawing" />
   </ItemGroup>
   <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PreBuildEvent>
+    </PreBuildEvent>
+  </PropertyGroup>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">

SharpHammer/core.cs

 	}
 	#endregion
 
+	#region timer
+	[StructLayout(LayoutKind.Sequential)]
+	public struct timer
+	{
+		public float t;
+		public float dt;
+		public float rate;
+		public linked_list node;
+	}
+	#endregion
+
+	#region linked_list
+	[StructLayout(LayoutKind.Sequential)]
+	public struct linked_list
+	{
+		IntPtr next;
+		IntPtr prev;
+		IntPtr data;
+	}
+	#endregion
+
+	#region file-mgr
+	enum seek_mode
+	{
+		SEEK_MODE_START,
+		SEEK_MODE_END,
+		SEEK_MODE_CUR
+	}
+	enum file_type
+	{
+		FILE_TYPE_MEM,
+		FILE_TYPE_DSK
+	}
+	enum file_mode
+	{
+		FILE_MODE_WRITE,
+		FILE_MODE_READ
+	}
+	#endregion
+
 	[SuppressUnmanagedCodeSecurity]
 	public class core
 	{
 		public static extern void Release();
 		#endregion
 
+		#region timer
+		// timer_initmgr
+		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern result_t timer_initmgr();
+		// timer_releasemgr
+		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void timer_releasemgr();
+		// timer_add
+		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern IntPtr timer_add(
+			[MarshalAs(UnmanagedType.Bool)] bool start);
+		// timer_remove
+		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void timer_remove(IntPtr tm);
+		// timer_update
+		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void timer_update(UInt64 tick);
+		// timer_querytick
+		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern UInt64 timer_querytick();
+		// timer_queryfreq
+		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern UInt64 timer_queryfreq();
+		// timer_calctm
+		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern Double timer_calctm(UInt64 tick1, UInt64 tick2);
+		// timer_pauseall
+		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void timer_pauseall();
+		// timer_resumeall
+		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void timer_resumeall();
+		#endregion
+
+		#region file-mgr
+		// io_addvdir
+		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void io_addvdir(
+			[MarshalAs(UnmanagedType.LPStr)] string directory, bool monitor);
+		// io_clearvdirs
+		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void io_clearvdirs();
+		// io_addpak
+		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void io_addpak(IntPtr pak);
+		// io_clearpaks
+		[DllImport(core.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void io_clearpaks();
+		// io_file_createmem
+		// io_file_openmem
+		// io_file_attachmem
+		// io_file_detachmem
+		// io_file_createdisk
+		// io_file_opendisk
+		// io_file_close
+		// io_file_seek
+		// io_file_read
+		// io_file_write
+		// io_file_getsize
+		// io_file_getpos
+		// io_file_getpath
+		// io_file_isopen
+		// io_file_gettype
+		// io_file_getmode
+		// io_mon_reg
+		// io_mon_unreg
+		// io_mon_update
+		#endregion
 	}
 }

SharpHammer/engine.cs

 	[StructLayout(LayoutKind.Sequential)]
 	public struct phx_params
 	{
-		UInt32 flags; 
-		UInt32 mem_sz;
-		UInt32 substeps_max;
-		UInt32 scratch_sz;
+		uint flags;
+		uint mem_sz;
+		uint substeps_max;
+		uint scratch_sz;
 	}
 
 	[StructLayout(LayoutKind.Sequential)]
 	public struct sct_params
 	{
-		UInt32 mem_sz;
+		uint mem_sz;
 	}
 
 	[StructLayout(LayoutKind.Sequential)]
 		public dev_params dev;
 		public phx_params phx;
 		public sct_params sct;
-		[MarshalAs(UnmanagedType.LPStr)]
-		public string console_cmds;
-		UInt32 console_cmds_cnt;
-		[MarshalAs(UnmanagedType.LPStr)]
-		public string data_dir;
+		//[MarshalAs(UnmanagedType.LPStr)]
+		//public string console_cmds;
+		public IntPtr console_cmds;
+		uint console_cmds_cnt;
+		//[MarshalAs(UnmanagedType.LPStr)]
+		//public string data_dir;
+		public IntPtr data_dir;
 	}
 	#endregion
 
 	[In] [MarshalAs(UnmanagedType.LPStr)] string wnd_name, uint width, uint height);
 	// pfn_app_active
 	public delegate void pfn_app_active(
-	[In] [MarshalAs(UnmanagedType.LPStr)] string wnd_name, 
+	[In] [MarshalAs(UnmanagedType.LPStr)] string wnd_name,
 	[MarshalAs(UnmanagedType.Bool)] bool active);
 	// pfn_app_keypress
 	public delegate void pfn_app_keypress(
 	}
 	#endregion
 
-	#region engine
+	#region camera
+	[StructLayout(LayoutKind.Sequential)]
+	public struct camera
+	{
+		Quat rot;
+		Vec4 look;
+		Vec4 right;
+		Vec4 up;
+		Vec4 pos;
 
+		float fnear;
+		float ffar;
+		float fov;
+		float aspect;
+
+		float pitch_cur;
+		float yaw_cur;
+
+		[MarshalAs(UnmanagedType.Bool)]
+		bool const_pitch;
+		float pitch_max;
+		float pitch_min;
+	}
+	#endregion
+
+	#region scene-mgr
+	[StructLayout(LayoutKind.Sequential)]
+	public struct scn_render_model
+	{
+		UInt64 model_hdl;
+		[MarshalAs(UnmanagedType.Bool)]
+		bool sun_shadows;
+		IntPtr gmodel;
+		IntPtr inst;
+
+		uint mat_idx;
+		uint bounds_idx;
+		uint node_idx;
+	}
+	[StructLayout(LayoutKind.Sequential)]
+	public struct scn_render_light
+	{
+		UInt64 light_hdl;
+		uint bounds_idx;
+		uint mat_idx;
+		float intensity_mul;
+	}
+	[StructLayout(LayoutKind.Sequential)]
+	public struct scn_render_query
+	{
+		uint obj_cnt;
+		uint model_cnt;
+		uint mat_cnt;
+		uint light_cnt;
+
+		IntPtr mats;
+		IntPtr bounds;
+		IntPtr models;
+		IntPtr lights;
+		IntPtr alloc;
+	}
+	#endregion
+
+	#region cmp-types
+	public enum cmp_obj_type
+	{
+		CMP_OBJTYPE_UNKNOWN = 0,
+		CMP_OBJTYPE_MODEL = (1<<0),
+		CMP_OBJTYPE_PARTICLE = (1<<1),
+		CMP_OBJTYPE_LIGHT = (1<<2),
+		CMP_OBJTYPE_DECAL = (1<<3),
+		CMP_OBJTYPE_CAMERA = (1<<4),
+		CMP_OBJTYPE_TRIGGER = (1<<5)
+	}
+	#endregion
+
+	#region script
+	[StructLayout(LayoutKind.Sequential)]
+	public struct sct_memstats
+	{
+		uint buff_max;
+		uint buff_alloc;
+	}
 	#endregion
 
 	[SuppressUnmanagedCodeSecurity]
 		#region engine
 		// eng_init
 		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
-		public static extern result_t eng_init(IntPtr @params);
+		public static extern result_t eng_init([In] IntPtr @params);
 		// eng_release
 		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
 		public static extern void eng_release();
 		// app_init
 		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
 		public static extern result_t app_init(
-			[In] [MarshalAs(UnmanagedType.LPStr)] string name, [In] IntPtr @params, 
+			[In] [MarshalAs(UnmanagedType.LPStr)] string name, [In] IntPtr @params,
 			IntPtr wnd_override);
 		// app_release
 		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
 		// app_resize_window
 		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
 		public static extern result_t app_resize_window(
-			[In] [MarshalAs(UnmanagedType.LPStr)] string name, 
-			uint width , uint height);
+			[In] [MarshalAs(UnmanagedType.LPStr)] string name,
+			uint width, uint height);
 		#endregion
 
 		#region input
 		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
 		public static extern input_key input_translate_key(uint vkey);
 		#endregion
+
+		#region camera
+		// cam_init
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void cam_init(ref camera cam, ref Vec4 pos,
+			ref Vec4 lookat, float fnear, float ffar, float fov);
+		// cam_set_pitchconst
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void cam_set_pitchconst(ref camera cam,
+			[MarshalAs(UnmanagedType.Bool)] bool enable,
+			float pitch_min, float pitch_max);
+		// cam_set_viewsize
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void cam_set_viewsize(ref camera cam,
+			float width, float height);
+		// cam_update
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void cam_update(ref camera cam);
+		// cam_get_perspective
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern IntPtr cam_get_perspective(ref Matrix4 r, ref camera cam);
+		// cam_get_view
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern IntPtr cam_get_view(ref Matrix4 r, ref camera cam);
+		// cam_pitch
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void cam_pitch(ref camera cam, float pitch);
+		// cam_yaw
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void cam_yaw(ref camera cam, float yaw);
+		// cam_roll
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void cam_roll(ref camera cam, float roll);
+		// cam_fwd
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void cam_fwd(ref camera cam, float dz);
+		// cam_strafe
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void cam_strafe(ref camera cam, float dx);
+
+		#endregion
+
+		#region scene-mgr
+		// scn_create_scene
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern uint scn_create_scene(
+			[In] [MarshalAs(UnmanagedType.LPStr)] string name);
+		// scn_destroy_scene
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void scn_destroy_scene(UInt32 scene_id);
+		// scn_findscene
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern uint scn_findscene(
+			[In] [MarshalAs(UnmanagedType.LPStr)] string name);
+		// scn_create_obj
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern IntPtr scn_create_obj(uint scene_id, 
+			[In] [MarshalAs(UnmanagedType.LPStr)] string name, cmp_obj_type type);
+		// scn_destroy_obj
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void scn_destroy_obj(IntPtr obj);
+		// scn_world_setvarf
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void scn_world_setvarf(
+			[In] [MarshalAs(UnmanagedType.LPStr)] string name, float f);
+		// scn_world_setvar2f
+		// scn_world_setvar3f
+		// scn_world_setvar4f
+		// scn_world_setvarb
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void scn_world_setvarb(
+			[In] [MarshalAs(UnmanagedType.LPStr)] string name,
+			[MarshalAs(UnmanagedType.Bool)] bool b);
+		// scn_world_setvari
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void scn_world_setvari(
+			[In] [MarshalAs(UnmanagedType.LPStr)] string name, int i);
+		// scn_world_setchangefunc
+		// scn_world_getvarb
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		[return: MarshalAs(UnmanagedType.Bool)]
+		public static extern bool scn_world_getvarb(
+			[In] [MarshalAs(UnmanagedType.LPStr)] string name);
+		// scn_world_getvari
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern int scn_world_getvari(
+			[In] [MarshalAs(UnmanagedType.LPStr)] string name);
+		// scn_world_getvarf
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern float scn_world_getvarf(
+			[In] [MarshalAs(UnmanagedType.LPStr)] string name);
+		// scn_world_getvarfv
+		// scn_setsize
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void scn_setsize(uint scene_id, [In] ref Vec3 minpt, 
+			[In] ref Vec3 maxpt);
+		// scn_getsize
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void scn_getsize(uint scene_id, ref Vec3 minpt, 
+			ref Vec3 maxpt);
+		// scn_setcam
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void scn_setcam(ref camera cam);
+		// scn_getcam
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern IntPtr scn_getcam();
+		// scn_setactive
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void scn_setactive(uint scene_id);
+		// scn_getactive
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern uint scn_setactive();
+		// scn_setcellsize
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void scn_setcellsize(uint scene_id, float cell_size);
+		// scn_setgellsize
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern float scn_setgellsize(uint scene_id);
+		#endregion
+
+		#region script
+		// sct_runfile
+		[DllImport(engine.NativeDll, CallingConvention = CallingConvention.Cdecl)]
+		public static extern void sct_runfile(
+			[In] [MarshalAs(UnmanagedType.LPStr)] string lua_filepath);
+		#endregion
 	}
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.