internal unsafe void SetModelMatrix( ref btTransform m ) { btMatrix3x3 tmp; m.GetGLMatrix( out tmp ); float* matrix_ptr = &tmp.m_el0.x; //fixed ( float* matrix_ptr = &Display.worldview.m_el0.x ) { GL.UniformMatrix4( modelview_id, 1, false, matrix_ptr ); } }
internal Camera() { location = btTransform.Identity; }
public Display( VoxelGameEnvironment game ) { Exit = CannotExit; this.game = game; //string versionOpenGL = GL.GetString(StringName.Version); //GL.Get //display_width = Width;// = Settings.Read( "GL.Width", System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width ); //display_height = Height;// = Settings.Read( "GL.Height", System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height ); //mouse_x = display_width / 2; //mouse_y = display_height / 2; Width = 1080; Height = 1920; #if !USE_GLES2 System.Windows.Forms.Cursor.Position = new Point( display_x + ( display_width ) / 2, display_y + display_height / 2 ); #endif //GL.Viewport( 0, 0, Width, Height ); #if !USE_GLES2 GL.Enable( EnableCap.Multisample ); #endif Matrix4.CreatePerspectiveFieldOfView( (float)( System.Math.PI / 2 ), (float)Width / (float)Height, 0.01f, 10000, out projection ); //projection = Matrix4.Identity; // generic fly camera not attached to any object free_camera = new Voxels.UI.Camera(); active_camera = free_camera; // default to freecam; free_camera.MoveTo( 0, 4, 0 ); free_camera.MoveTo( 1799, 4, 0 ); debug_cube_transform = btTransform.Identity; }
// point fed to this is relative to the camera origin already. internal bool Is_PointVisible( ref btTransform TransformParam, ref btVector3 Point ) { btVector3 Cv; btVector3 Cv2; bool Visible; Point.Sub( ref TransformParam.m_origin, out Cv2); TransformParam.m_basis.Apply( ref Cv2, out Cv ); //Cv.Sub( // Projection if( Cv.z > 0 ) { Cv.x = Cv.x / Cv.z * FocusDistance; // Number replaced by FocusDistance was 50.0 Cv.y = Cv.y / Cv.z * FocusDistance; // Visibility test Visible = ( ( Cv.x < Frustum_CullingLimit && Cv.x > -Frustum_CullingLimit ) // Number replaced by Frustum_CullingLimit was 50.0 && ( Cv.y < Frustum_CullingLimit && Cv.y > -Frustum_CullingLimit ) // ); //Log.log( "visible: {0} {1} {2} {3}", Point.x, Point.y, Point.z, Visible ); return ( Visible ); } return false; }
/*@brief Copy constructor */ public btTransform( ref btTransform other ) { m_basis = other.m_basis; m_origin = other.m_origin; }
/*@brief Test if two transforms have all elements equal */ public static bool Equals( ref btTransform t1, ref btTransform t2 ) { return ( t1.m_basis.Equals( ref t2.m_basis ) && t1.m_origin.Equals( ref t2.m_origin ) ); }
public bool Equals( ref btTransform t2 ) { return Equals( this, t2 ); }
/*@brief Return the inverse of this transform */ public void inverse( out btTransform result ) { m_basis.transpose( out result.m_basis ); m_origin.Invert( out result.m_origin ); }
/*@brief Return the inverse of this transform times the other transform @param t The other transform return this.inverse() the other */ public void inverseTimes( ref btTransform t, out btTransform result ) { btVector3 v; t.m_origin.Sub( ref m_origin, out v ); m_basis.transposeTimes( ref t.m_basis, out result.m_basis ); m_basis.ApplyInverse( ref v, out result.m_origin ); }
/*@brief Return the transform of the btQuaternion */ public static void Apply( ref btTransform t, ref btQuaternion q, out btQuaternion result ) { btQuaternion tmp; t.getRotation( out tmp ); tmp.Mult( ref q, out result ); }
/*@brief Return the transform of the vector */ public static void Apply( ref btTransform t, ref btVector3 x, out btVector3 result ) { t.Apply( ref x, out result ); }
public void Apply( ref btTransform t2, out btTransform result ) { m_basis.Apply( ref t2.m_basis, out result.m_basis ); Apply( ref t2.m_origin, out result.m_origin ); }
/*@brief Set the current transform as the value of the product of two transforms @param t1 Transform 1 @param t2 Transform 2 This = Transform1 Transform2 */ public void mult( ref btTransform t1, ref btTransform t2 ) { t1.m_basis.Apply( ref t2.m_basis, out m_basis ); t1.Apply( ref t2.m_origin, out m_origin ); }
bool RayCast_Vector( ref btTransform Pos, ref btVector3 Vector, ref RayCast_in In, ref RayCast_out Out, bool InvertCollision ) { return RayCast_Vector( ref Pos.m_origin, ref Vector, ref In, ref Out, InvertCollision ); }