1. Mohamad Amin Valinejad
  2. SharpHammer

Source

SharpHammer / SharpHammer / Camera.cs

using System;
using System.Runtime.InteropServices;

namespace SharpHammer
{
	public class Camera : DisposableBase
	{
		internal IntPtr _cam;

		public Camera()
			: this(new Vec3(0, 10, -10), new Vec3(0, 0, 0))
		{ }

		public Camera(Vec3 pos, Vec3 target) :
			this(pos, target, (float)Math.PI * .3f)
		{ }

		public Camera(Vec3 pos, Vec3 target, float fov)
		{
			//_cam = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(cam)));

			Vec4 cpos = new Vec4(pos, 1);
			Vec4 ctarget = new Vec4(target, 1);
			_cam = NativeCalls.cam_create(ref cpos, ref ctarget, 0.1f, 1000f, fov);
		}

		protected override void OnDisposeUnmanaged()
		{
			NativeCalls.cam_destroy(_cam);
		}
	}
}