public override void Update(ApplicationTime time) { IOxRenderPluginAvatar avatar = (IOxRenderPluginAvatar)Ox.Service.Get(typeof(IOxRenderPluginAvatar)); SceneNode sn = avatar.GetAvatarScneNode(Ox.DataStore.World.Agent.ID); if (sn == null || node == null) return; node.Target = sn.Position + Render.RenderData.AgentHeadPosition; Matrix4 rot = new Matrix4(); //rot.RotationDegrees = Util.ToRotationRH(new float[] { // 0, // 0, // (float)(Ox.DataStore.World.Agent.Head * NewMath.RADTODEG) + Util.ROTATION_AND_3DS_OFFSET.Z }); Quaternion q0 = new Quaternion(); Quaternion q1 = new Quaternion(); q0.fromAngleAxis(Ox.DataStore.Camera.Angle[0] + NewMath.DEGTORAD * Util.ROTATION_AND_3DS_OFFSET.Z, new Vector3D(0, 0, 1)); q1.fromAngleAxis(Ox.DataStore.Camera.Angle[1], new Vector3D(1, 0, 0)); q1 = q1 * q0; Vector3D vec = new Vector3D(0, -Ox.DataStore.Camera.Distance, 0); node.Position = node.Target + q1.Matrix.RotateVect(ref vec); if (Ox.DataStore.Camera.Angle[1] < -MathHelper.PIOver2 || MathHelper.PIOver2 < Ox.DataStore.Camera.Angle[1]) node.UpVector = new Vector3D(0, 0, -1); else node.UpVector = new Vector3D(0, 0, 1); base.Update(time); }
public override void Startup() { //Create a New Irrlicht Device //device.Timer.Stop(); Device.Timer.Speed = 1; Device.WindowCaption = "IdealistViewer 0.001"; // viewerRenderPlane.Device = Device; // viewerRenderPlane.Renderer = this; // Device.Resizeable = true; // Sets directory to load assets from Device.FileSystem.WorkingDirectory = m_viewer.StartupDirectory + "/" + Util.MakePath("media", "materials", "textures", ""); //We set Irrlicht's current directory to %application directory%/media Driver = Device.VideoDriver; SceneManager = Device.SceneManager; GuiEnvironment = Device.GUIEnvironment; // Compose Coordinate space converter quaternion IrrlichtNETCP.Matrix4 m4 = new IrrlichtNETCP.Matrix4(); m4.SetM(0, 0, 1); m4.SetM(1, 0, 0); m4.SetM(2, 0, 0); m4.SetM(3, 0, 0); m4.SetM(0, 1, 0); m4.SetM(1, 1, 0); m4.SetM(2, 1, 1); m4.SetM(3, 1, 0); m4.SetM(0, 2, 0); m4.SetM(1, 2, 1); m4.SetM(2, 2, 0); m4.SetM(3, 2, 0); m4.SetM(0, 3, 0); m4.SetM(1, 3, 0); m4.SetM(2, 3, 0); m4.SetM(3, 3, 1); CoordinateConversion_XYZ_XZY = new IrrlichtNETCP.Quaternion(m4); CoordinateConversion_XYZ_XZY.makeInverse(); }
public static void CreateBox3DFromNode(SceneNode node, out Box3D box) { float minX = float.MaxValue; float minY = float.MaxValue; float minZ = float.MaxValue; float maxX = float.MinValue; float maxY = float.MinValue; float maxZ = float.MinValue; Vector3D[] edges; node.BoundingBox.GetEdges(out edges); Matrix4 m = new Matrix4(); m.RotationDegrees = node.Rotation; m.Translation = node.Position; for (int i = 0; i < edges.Length; i++) { Vector3D v = edges[i] * node.Scale; v = m.TransformVect(ref v); if (v.X < minX) minX = v.X; if (v.Y < minY) minY = v.Y; if (v.Z < minZ) minZ = v.Z; if (v.X > maxX) maxX = v.X; if (v.Y > maxY) maxY = v.Y; if (v.Z > maxZ) maxZ = v.Z; } box = new Box3D(minX, minY, minZ, maxX, maxY, maxZ); }
public bool GetInverse(out Matrix4 outM) { outM = new Matrix4(); float d = (GetMInsecure(0, 0) * GetMInsecure(1, 1) - GetMInsecure(1, 0) * GetMInsecure(0, 1)) * (GetMInsecure(2, 2) * GetMInsecure(3, 3) - GetMInsecure(3, 2) * GetMInsecure(2, 3)) - (GetMInsecure(0, 0) * GetMInsecure(2, 1) - GetMInsecure(2, 0) * GetMInsecure(0, 1)) * (GetMInsecure(1, 2) * GetMInsecure(3, 3) - GetMInsecure(3, 2) * GetMInsecure(1, 3)) + (GetMInsecure(0, 0) * GetMInsecure(3, 1) - GetMInsecure(3, 0) * GetMInsecure(0, 1)) * (GetMInsecure(1, 2) * GetMInsecure(2, 3) - GetMInsecure(2, 2) * GetMInsecure(1, 3)) + (GetMInsecure(1, 0) * GetMInsecure(2, 1) - GetMInsecure(2, 0) * GetMInsecure(1, 1)) * (GetMInsecure(0, 2) * GetMInsecure(3, 3) - GetMInsecure(3, 2) * GetMInsecure(0, 3)) - (GetMInsecure(1, 0) * GetMInsecure(3, 1) - GetMInsecure(3, 0) * GetMInsecure(1, 1)) * (GetMInsecure(0, 2) * GetMInsecure(2, 3) - GetMInsecure(2, 2) * GetMInsecure(0, 3)) + (GetMInsecure(2, 0) * GetMInsecure(3, 1) - GetMInsecure(3, 0) * GetMInsecure(2, 1)) * (GetMInsecure(0, 2) * GetMInsecure(1, 3) - GetMInsecure(1, 2) * GetMInsecure(0, 3)); if (d == 0f) return false; d = 1f / d; outM.SetMInsecure(0, 0, d * (GetMInsecure(1, 1) * (GetMInsecure(2, 2) * GetMInsecure(3, 3) - GetMInsecure(3, 2) * GetMInsecure(2, 3)) + GetMInsecure(2, 1) * (GetMInsecure(3, 2) * GetMInsecure(1, 3) - GetMInsecure(1, 2) * GetMInsecure(3, 3)) + GetMInsecure(3, 1) * (GetMInsecure(1, 2) * GetMInsecure(2, 3) - GetMInsecure(2, 2) * GetMInsecure(1, 3)))); outM.SetMInsecure(1, 0, d * (GetMInsecure(1, 2) * (GetMInsecure(2, 0) * GetMInsecure(3, 3) - GetMInsecure(3, 0) * GetMInsecure(2, 3)) + GetMInsecure(2, 2) * (GetMInsecure(3, 0) * GetMInsecure(1, 3) - GetMInsecure(1, 0) * GetMInsecure(3, 3)) + GetMInsecure(3, 2) * (GetMInsecure(1, 0) * GetMInsecure(2, 3) - GetMInsecure(2, 0) * GetMInsecure(1, 3)))); outM.SetMInsecure(2, 0, d * (GetMInsecure(1, 3) * (GetMInsecure(2, 0) * GetMInsecure(3, 1) - GetMInsecure(3, 0) * GetMInsecure(2, 1)) + GetMInsecure(2, 3) * (GetMInsecure(3, 0) * GetMInsecure(1, 1) - GetMInsecure(1, 0) * GetMInsecure(3, 1)) + GetMInsecure(3, 3) * (GetMInsecure(1, 0) * GetMInsecure(2, 1) - GetMInsecure(2, 0) * GetMInsecure(1, 1)))); outM.SetMInsecure(3, 0, d * (GetMInsecure(1, 0) * (GetMInsecure(3, 1) * GetMInsecure(2, 2) - GetMInsecure(2, 1) * GetMInsecure(3, 2)) + GetMInsecure(2, 0) * (GetMInsecure(1, 1) * GetMInsecure(3, 2) - GetMInsecure(3, 1) * GetMInsecure(1, 2)) + GetMInsecure(3, 0) * (GetMInsecure(2, 1) * GetMInsecure(1, 2) - GetMInsecure(1, 1) * GetMInsecure(2, 2)))); outM.SetMInsecure(0, 1, d * (GetMInsecure(2, 1) * (GetMInsecure(0, 2) * GetMInsecure(3, 3) - GetMInsecure(3, 2) * GetMInsecure(0, 3)) + GetMInsecure(3, 1) * (GetMInsecure(2, 2) * GetMInsecure(0, 3) - GetMInsecure(0, 2) * GetMInsecure(2, 3)) + GetMInsecure(0, 1) * (GetMInsecure(3, 2) * GetMInsecure(2, 3) - GetMInsecure(2, 2) * GetMInsecure(3, 3)))); outM.SetMInsecure(1, 1, d * (GetMInsecure(2, 2) * (GetMInsecure(0, 0) * GetMInsecure(3, 3) - GetMInsecure(3, 0) * GetMInsecure(0, 3)) + GetMInsecure(3, 2) * (GetMInsecure(2, 0) * GetMInsecure(0, 3) - GetMInsecure(0, 0) * GetMInsecure(2, 3)) + GetMInsecure(0, 2) * (GetMInsecure(3, 0) * GetMInsecure(2, 3) - GetMInsecure(2, 0) * GetMInsecure(3, 3)))); outM.SetMInsecure(2, 1, d * (GetMInsecure(2, 3) * (GetMInsecure(0, 0) * GetMInsecure(3, 1) - GetMInsecure(3, 0) * GetMInsecure(0, 1)) + GetMInsecure(3, 3) * (GetMInsecure(2, 0) * GetMInsecure(0, 1) - GetMInsecure(0, 0) * GetMInsecure(2, 1)) + GetMInsecure(0, 3) * (GetMInsecure(3, 0) * GetMInsecure(2, 1) - GetMInsecure(2, 0) * GetMInsecure(3, 1)))); outM.SetMInsecure(3, 1, d * (GetMInsecure(2, 0) * (GetMInsecure(3, 1) * GetMInsecure(0, 2) - GetMInsecure(0, 1) * GetMInsecure(3, 2)) + GetMInsecure(3, 0) * (GetMInsecure(0, 1) * GetMInsecure(2, 2) - GetMInsecure(2, 1) * GetMInsecure(0, 2)) + GetMInsecure(0, 0) * (GetMInsecure(2, 1) * GetMInsecure(3, 2) - GetMInsecure(3, 1) * GetMInsecure(2, 2)))); outM.SetMInsecure(0, 2, d * (GetMInsecure(3, 1) * (GetMInsecure(0, 2) * GetMInsecure(1, 3) - GetMInsecure(1, 2) * GetMInsecure(0, 3)) + GetMInsecure(0, 1) * (GetMInsecure(1, 2) * GetMInsecure(3, 3) - GetMInsecure(3, 2) * GetMInsecure(1, 3)) + GetMInsecure(1, 1) * (GetMInsecure(3, 2) * GetMInsecure(0, 3) - GetMInsecure(0, 2) * GetMInsecure(3, 3)))); outM.SetMInsecure(1, 2, d * (GetMInsecure(3, 2) * (GetMInsecure(0, 0) * GetMInsecure(1, 3) - GetMInsecure(1, 0) * GetMInsecure(0, 3)) + GetMInsecure(0, 2) * (GetMInsecure(1, 0) * GetMInsecure(3, 3) - GetMInsecure(3, 0) * GetMInsecure(1, 3)) + GetMInsecure(1, 2) * (GetMInsecure(3, 0) * GetMInsecure(0, 3) - GetMInsecure(0, 0) * GetMInsecure(3, 3)))); outM.SetMInsecure(2, 2, d * (GetMInsecure(3, 3) * (GetMInsecure(0, 0) * GetMInsecure(1, 1) - GetMInsecure(1, 0) * GetMInsecure(0, 1)) + GetMInsecure(0, 3) * (GetMInsecure(1, 0) * GetMInsecure(3, 1) - GetMInsecure(3, 0) * GetMInsecure(1, 1)) + GetMInsecure(1, 3) * (GetMInsecure(3, 0) * GetMInsecure(0, 1) - GetMInsecure(0, 0) * GetMInsecure(3, 1)))); outM.SetMInsecure(3, 2, d * (GetMInsecure(3, 0) * (GetMInsecure(1, 1) * GetMInsecure(0, 2) - GetMInsecure(0, 1) * GetMInsecure(1, 2)) + GetMInsecure(0, 0) * (GetMInsecure(3, 1) * GetMInsecure(1, 2) - GetMInsecure(1, 1) * GetMInsecure(3, 2)) + GetMInsecure(1, 0) * (GetMInsecure(0, 1) * GetMInsecure(3, 2) - GetMInsecure(3, 1) * GetMInsecure(0, 2)))); outM.SetMInsecure(0, 3, d * (GetMInsecure(0, 1) * (GetMInsecure(2, 2) * GetMInsecure(1, 3) - GetMInsecure(1, 2) * GetMInsecure(2, 3)) + GetMInsecure(1, 1) * (GetMInsecure(0, 2) * GetMInsecure(2, 3) - GetMInsecure(2, 2) * GetMInsecure(0, 3)) + GetMInsecure(2, 1) * (GetMInsecure(1, 2) * GetMInsecure(0, 3) - GetMInsecure(0, 2) * GetMInsecure(1, 3)))); outM.SetMInsecure(1, 3, d * (GetMInsecure(0, 2) * (GetMInsecure(2, 0) * GetMInsecure(1, 3) - GetMInsecure(1, 0) * GetMInsecure(2, 3)) + GetMInsecure(1, 2) * (GetMInsecure(0, 0) * GetMInsecure(2, 3) - GetMInsecure(2, 0) * GetMInsecure(0, 3)) + GetMInsecure(2, 2) * (GetMInsecure(1, 0) * GetMInsecure(0, 3) - GetMInsecure(0, 0) * GetMInsecure(1, 3)))); outM.SetMInsecure(2, 3, d * (GetMInsecure(0, 3) * (GetMInsecure(2, 0) * GetMInsecure(1, 1) - GetMInsecure(1, 0) * GetMInsecure(2, 1)) + GetMInsecure(1, 3) * (GetMInsecure(0, 0) * GetMInsecure(2, 1) - GetMInsecure(2, 0) * GetMInsecure(0, 1)) + GetMInsecure(2, 3) * (GetMInsecure(1, 0) * GetMInsecure(0, 1) - GetMInsecure(0, 0) * GetMInsecure(1, 1)))); outM.SetMInsecure(3, 3, d * (GetMInsecure(0, 0) * (GetMInsecure(1, 1) * GetMInsecure(2, 2) - GetMInsecure(2, 1) * GetMInsecure(1, 2)) + GetMInsecure(1, 0) * (GetMInsecure(2, 1) * GetMInsecure(0, 2) - GetMInsecure(0, 1) * GetMInsecure(2, 2)) + GetMInsecure(2, 0) * (GetMInsecure(0, 1) * GetMInsecure(1, 2) - GetMInsecure(1, 1) * GetMInsecure(0, 2)))); return true; }
public static Matrix4 operator *(Matrix4 a, Matrix4 b) { Matrix4 tmtrx = new Matrix4(); tmtrx.M[0] = a.M[0]*b.M[0] + a.M[4]*b.M[1] + a.M[8]*b.M[2] + a.M[12]*b.M[3]; tmtrx.M[1] = a.M[1]*b.M[0] + a.M[5]*b.M[1] + a.M[9]*b.M[2] + a.M[13]*b.M[3]; tmtrx.M[2] = a.M[2]*b.M[0] + a.M[6]*b.M[1] + a.M[10]*b.M[2] + a.M[14]*b.M[3]; tmtrx.M[3] = a.M[3]*b.M[0] + a.M[7]*b.M[1] + a.M[11]*b.M[2] + a.M[15]*b.M[3]; tmtrx.M[4] = a.M[0]*b.M[4] + a.M[4]*b.M[5] + a.M[8]*b.M[6] + a.M[12]*b.M[7]; tmtrx.M[5] = a.M[1]*b.M[4] + a.M[5]*b.M[5] + a.M[9]*b.M[6] + a.M[13]*b.M[7]; tmtrx.M[6] = a.M[2]*b.M[4] + a.M[6]*b.M[5] + a.M[10]*b.M[6] + a.M[14]*b.M[7]; tmtrx.M[7] = a.M[3]*b.M[4] + a.M[7]*b.M[5] + a.M[11]*b.M[6] + a.M[15]*b.M[7]; tmtrx.M[8] = a.M[0]*b.M[8] + a.M[4]*b.M[9] + a.M[8]*b.M[10] + a.M[12]*b.M[11]; tmtrx.M[9] = a.M[1]*b.M[8] + a.M[5]*b.M[9] + a.M[9]*b.M[10] + a.M[13]*b.M[11]; tmtrx.M[10] = a.M[2]*b.M[8] + a.M[6]*b.M[9] + a.M[10]*b.M[10] + a.M[14]*b.M[11]; tmtrx.M[11] = a.M[3]*b.M[8] + a.M[7]*b.M[9] + a.M[11]*b.M[10] + a.M[15]*b.M[11]; tmtrx.M[12] = a.M[0]*b.M[12] + a.M[4]*b.M[13] + a.M[8]*b.M[14] + a.M[12]*b.M[15]; tmtrx.M[13] = a.M[1]*b.M[12] + a.M[5]*b.M[13] + a.M[9]*b.M[14] + a.M[13]*b.M[15]; tmtrx.M[14] = a.M[2]*b.M[12] + a.M[6]*b.M[13] + a.M[10]*b.M[14] + a.M[14]*b.M[15]; tmtrx.M[15] = a.M[3]*b.M[12] + a.M[7]*b.M[13] + a.M[11]*b.M[14] + a.M[15]*b.M[15]; return tmtrx; }
public void Transform(Matrix4 mat) { VF_Transform(_raw, mat.ToUnmanaged()); }
public void SetTransform(TransformationState state, Matrix4 mat) { VideoDriver_SetTransform(_raw, state, mat.ToUnmanaged()); }
//! Constructor which converts a matrix to a Quaternion public Quaternion(Matrix4 mat) { this.FromMatrix(mat); }
//! Quaternion creation from matrix public Quaternion FromMatrix(Matrix4 m) { float diag = m.GetM(0,0) + m.GetM(1,1) + m.GetM(2,2) + 1; float scale = 0.0f; if (diag > 0.0f) { scale = (float)Math.Sqrt(diag) * 2.0f; // get scale from diagonal // TODO: speed this up m_x = (m.GetM(2,1) - m.GetM(1,2)) / scale; m_y = (m.GetM(0,2) - m.GetM(2,0)) / scale; m_z = (m.GetM(1,0) - m.GetM(0,1)) / scale; m_w = 0.25f * scale; } else { if (m.GetM(0,0) > m.GetM(1,1) && m.GetM(0,0) > m.GetM(2,2)) { // 1st element of diag is greatest value // find scale according to 1st element, and double it scale = (float)Math.Sqrt(1.0f + m.GetM(0,0) - m.GetM(1,1) - m.GetM(2,2)) * 2.0f; // TODO: speed this up m_x = 0.25f * scale; m_y = (m.GetM(0,1) + m.GetM(1,0)) / scale; m_z = (m.GetM(2,0) + m.GetM(0,2)) / scale; m_w = (m.GetM(2,1) - m.GetM(1,2)) / scale; } else if (m.GetM(1,1) > m.GetM(2,2)) { // 2nd element of diag is greatest value // find scale according to 2nd element, and double it scale = (float)Math.Sqrt(1.0f + m.GetM(1,1) - m.GetM(0,0) - m.GetM(2,2)) * 2.0f; // TODO: speed this up m_x = (m.GetM(0,1) + m.GetM(1,0)) / scale; m_y = 0.25f * scale; m_z = (m.GetM(1,2) + m.GetM(2,1)) / scale; m_w = (m.GetM(0,2) - m.GetM(2,0)) / scale; } else { // 3rd element of diag is greatest value // find scale according to 3rd element, and double it scale = (float)Math.Sqrt(1.0f + m.GetM(2,2) - m.GetM(0,0) - m.GetM(1,1)) * 2.0f; // TODO: speed this up m_x = (m.GetM(0,2) + m.GetM(2,0)) / scale; m_y = (m.GetM(1,2) + m.GetM(2,1)) / scale; m_z = 0.25f * scale; m_w = (m.GetM(1,0) - m.GetM(0,1)) / scale; } } Normalize(); return this; }
public override void Render() { VideoDriver driver = smgr.VideoDriver; CameraSceneNode camera = smgr.ActiveCamera; if (driver.Raw == IntPtr.Zero || camera.Raw == IntPtr.Zero) return; Matrix4 mat = new Matrix4(); mat.Translation = camera.AbsolutePosition; driver.SetTransform(TransformationState.World, mat); driver.SetMaterial(material); for (int i = 1; i < face + 1; i++) { (vertices[i] as Vertex3D).TCoords = Vector2D.From(uvX, 0.98f); } vertices[0].TCoords = Vector2D.From(uvX, 0.01f); driver.DrawIndexedTriangleList(vertices, vert + 1, indices, face); }
public void prep_interpolation(double Jdate, double time) { Matrix4 mat = new Matrix4(); Vector3D kampas = new Vector3D(); saule(52.0f, -5.0f, Jdate); kampas.X = (float)-sun_angle[1];//heigh kampas.Y = (float)sun_angle[0];//0.0f;- kampas.Z = 0.0f; mat.RotationDegrees = kampas; vieta[0] = 0.0f; vieta[1] = 0.0f; vieta[2] = 1000.0f; vieta[3] = 0.0f; double[] temp = new double[4]; temp[0] = vieta[0]; temp[1] = vieta[1]; temp[2] = vieta[2]; temp[3] = vieta[3]; vieta[0] = mat.M[0] * temp[0] + mat.M[4] * temp[1] + mat.M[8] * temp[2] + mat.M[12] * temp[3]; vieta[1] = mat.M[1] * temp[0] + mat.M[5] * temp[1] + mat.M[9] * temp[2] + mat.M[13] * temp[3]; vieta[2] = mat.M[2] * temp[0] + mat.M[6] * temp[1] + mat.M[10] * temp[2] + mat.M[14] * temp[3]; vieta[3] = mat.M[3] * temp[0] + mat.M[7] * temp[1] + mat.M[11] * temp[2] + mat.M[15] * temp[3]; sun_pos_from.X = (float)vieta[0]; sun_pos_from.Y = (float)vieta[1]; sun_pos_from.Z = (float)vieta[2]; sun_angle_from = sun_angle[1]; saule(52.0f, -5.0f, Jdate + time);//52.0 -5.0 kaunas 54.54 -23.54 kampas.X = (float)-sun_angle[1];//heigh kampas.Y = (float)sun_angle[0];//0.0f;- kampas.Z = 0.0f; Matrix4 mat2 = new Matrix4(); mat2.RotationDegrees = kampas; vieta[0] = 0.0f; vieta[1] = 0.0f; vieta[2] = 1000.0f; vieta[3] = 0.0f; sun_angle_to = sun_angle[1]; temp[0] = vieta[0]; temp[1] = vieta[1]; temp[2] = vieta[2]; temp[3] = vieta[3]; vieta[0] = mat2.M[0] * temp[0] + mat2.M[4] * temp[1] + mat2.M[8] * temp[2] + mat2.M[12] * temp[3]; vieta[1] = mat2.M[1] * temp[0] + mat2.M[5] * temp[1] + mat2.M[9] * temp[2] + mat2.M[13] * temp[3]; vieta[2] = mat2.M[2] * temp[0] + mat2.M[6] * temp[1] + mat2.M[10] * temp[2] + mat2.M[14] * temp[3]; vieta[3] = mat2.M[3] * temp[0] + mat2.M[7] * temp[1] + mat2.M[11] * temp[2] + mat2.M[15] * temp[3]; sun_pos_to.X = (float)vieta[0]; sun_pos_to.Y = (float)vieta[1]; sun_pos_to.Z = (float)vieta[2]; }
public override void Render() { driver.SetTransform(TransformationState.World, AbsoluteTransformation); // Figure out quads based on start/end points. Matrix4 m = new Matrix4(); m.RotationDegrees = getTargetAngle(vStart, vEnd); Vector3D vUp = new Vector3D(0, 1, 0); Vector3D vRight = new Vector3D(-1, 0, 0); m.TransformVect(ref vRight); m.TransformVect(ref vUp); // Draw the first cross IrrQuad beam = new IrrQuad(); beam.verts[0] = new Vertex3D(vStart + vUp * flScale, new Vector3D(1, 1, 0), beamColor, new Vector2D(0, 1)); beam.verts[1] = new Vertex3D(vStart + vUp * -flScale, new Vector3D(1, 0, 0), beamColor, new Vector2D(1, 1)); beam.verts[2] = new Vertex3D(vEnd + vUp * -flScale, new Vector3D(0, 1, 1), beamColor, new Vector2D(1, 0)); beam.verts[3] = new Vertex3D(vEnd + vUp * flScale, new Vector3D(0, 0, 1), beamColor, new Vector2D(0, 0)); DrawQuad(beam); // Draw the second cross. beam.verts[0] = new Vertex3D(vStart + vRight * flScale, new Vector3D(1, 1, 0), beamColor, new Vector2D(0, 1)); beam.verts[1] = new Vertex3D(vStart + vRight * -flScale, new Vector3D(1, 0, 0), beamColor, new Vector2D(1, 1)); beam.verts[2] = new Vertex3D(vEnd + vRight * -flScale, new Vector3D(0, 1, 1), beamColor, new Vector2D(1, 0)); beam.verts[3] = new Vertex3D(vEnd + vRight * flScale, new Vector3D(0, 0, 1), beamColor, new Vector2D(0, 0)); DrawQuad(beam); if (DebugDataVisible == DebugSceneType.BoundingBox) driver.Draw3DBox(BoundingBox, Color.White); }
public void RecalculateBoundingBox() { Matrix4 m = new Matrix4(); m.RotationDegrees = getTargetAngle(vStart, vEnd); Vector3D vUp = new Vector3D(0, 1, 0); Vector3D vRight = new Vector3D(-1, 0, 0); m.TransformVect(ref vRight); m.TransformVect(ref vUp); Box.MinEdge = (vStart + vUp * flScale); Box.MaxEdge = (vEnd + vRight * -flScale); Box.AddInternalPoint(vStart + vUp * flScale); Box.AddInternalPoint(vStart + vUp * -flScale); Box.AddInternalPoint(vEnd + vUp * -flScale); Box.AddInternalPoint(vEnd + vUp * flScale); Box.AddInternalPoint(vStart + vRight * flScale); Box.AddInternalPoint(vStart + vRight * -flScale); Box.AddInternalPoint(vEnd + vRight * -flScale); Box.AddInternalPoint(vEnd + vRight * flScale); }
/// <summary> /// Applies a transformation. /// </summary> /// <param name="mesh"> /// A mesh to be transformed <see cref="Mesh"/> /// </param> /// <param name="mat"> /// A transform matrix <see cref="Matrix4"/> /// </param> public void TransformMesh(Mesh mesh, Matrix4 mat) { MeshManipulator_TransformMesh(_raw, mesh.Raw, mat.ToUnmanaged()); }