public Vertex(DX.Vector3 position, DX.Vector2 texCoord, DX.Vector3 n, float a) { this.position = position; this.texCoord = texCoord; n.Normalize(); this.normal = new DX.Vector4(n.X, n.Y, n.Z, a); }
public RadiosityIntersection Intersection(Microsoft.DirectX.Vector3 origin, Microsoft.DirectX.Vector3 direction) { Vector3 newDir = AngleTransform(transform.Pitch, transform.Yaw, transform.Roll, direction); direction = new Vector3(-direction.X, direction.Y, direction.Z); Vector3 closeVector = new Vector3(origin.X - transform.X, origin.Y - transform.Y, origin.Z - transform.Z); origin = new Vector3(-origin.X, origin.Y, origin.Z); Vector4 vector4 = Vector3.Transform(direction, transform.matrix); direction = new Vector3(vector4.X - transform.X, vector4.Y - transform.Y, vector4.Z - transform.Z); //direction.Normalize(); //direction = newDir; vector4 = Vector3.Transform(origin, transform.matrix); origin = new Vector3(vector4.X, vector4.Y, vector4.Z); RadiosityIntersection m = @base.Intersection(direction, origin); //if (!m.NoIntersection) // System.Diagnostics.Debugger.Break(); vector4 = Vector3.Transform(m.Position, Inverse); m.Position = new Vector3(-vector4.X, vector4.Y, vector4.Z); vector4 = Vector3.Transform(m.NewDirection, Inverse); m.NewDirection = new Vector3(-vector4.X, vector4.Y, vector4.Z); return(m); }
public Explosion(Direct3D.Device NewDevice, DirectX.Vector3 NewPosition) { this.CurrDevice = NewDevice; this.ExplosionTexture = Direct3D.TextureLoader.FromFile(CurrDevice, GameConfig.Files.ExplosionPoint); this.LightTexture = Direct3D.TextureLoader.FromFile(CurrDevice, GameConfig.Files.ExplosionLight); this.ExplosionPosition = NewPosition; this.Rand = new Random(); this.UniversalGravity = .50f; this.ParticleCount = 100; this.NeedsDelete = false; this.Particles = new ArrayList(); for (int i = 0; i < this.ParticleCount; i++) { Particles.Add(new Particle(this.UniversalGravity, ExplosionPosition, new DirectX.Vector3((float)(Rand.NextDouble() * 0.75f - 0.375f), (float)(Rand.NextDouble() * 0.5f - 0.1f), 0.0f), DXUtil.Timer(DirectXTimer.GetApplicationTime))); } ExplosionFlash = new Flash(ExplosionPosition, DXUtil.Timer(DirectXTimer.GetApplicationTime)); this.LastUpdateTime = DXUtil.Timer(DirectXTimer.GetApplicationTime); }
/// <summary> /// human player do some action /// </summary> /// <param name="action">action from input</param> /// <param name="dir">direction where is player looking</param> internal void Spell(Input.Action action, Microsoft.DirectX.Vector3 dir) { switch (action) { case Input.Action.Action1: //at action button send fireball this.fireballInfo.startPosition = this.camera.GetVector3Position(); this.fireballInfo.targetPosition = this.camera.GetVector3Position() + dir; CharacterNPC playerChar = this.ai.GetPlayerInfo().Character; ActionInfo info = this.fireballInfo; info.action.enemyHpTaken += playerChar.level * playerChar.power; if (ai.AcceptPlayerAction(info)) { CreateFireball(info); } break; case Input.Action.Action2: break; case Input.Action.Action3: break; case Input.Action.Wheel: break; default: break; } }
public AreaMagnet(Vector3 position, Vector3 normal) : base(position) { this.normal = normal; screenNormal[0] = new Vector3(0, 0, 0); screenNormal[1] = new Vector3(0, 0, 1); }
public void RecalcPrimaryDependant(Canguro.View.GraphicView activeView, PointMagnet primaryPoint, LineMagnet[] globalAxes) { if (primaryPoint != null) { // Move area to lay on the primaryPoint and to set its direction any canonic // plane (X=x, Y=y or Z=z) which is the most paralell to the screen plane position = primaryPoint.Position; // Get screen plane normal Vector3 s0 = screenNormal[0], s1 = screenNormal[1], sNormal; activeView.Unproject(ref s0); activeView.Unproject(ref s1); sNormal = s0 - s1; // Assign the area normal to the most paralell canonical plane // (giving priority to the Z plane) int maxCosIndex = 2; float cosX, cosY, cosZ; cosX = Vector3.Dot(sNormal, globalAxes[0].Direction); cosY = Vector3.Dot(sNormal, globalAxes[1].Direction); cosZ = Vector3.Dot(sNormal, globalAxes[2].Direction); if (Math.Abs(cosZ) < minZPlaneAngle) { maxCosIndex = (cosX >= cosY) ? ((cosX > cosZ) ? 0 : 2) : ((cosY > cosZ) ? 1 : 2); } normal = globalAxes[maxCosIndex].Direction; } else { position = Vector3.Empty; normal = globalAxes[2].Direction; } }
public Flash(DirectX.Vector3 newPositions, float newTimeCreated) { this.TimeCreated = newTimeCreated; this.Positions = newPositions; this.Verticies = new Direct3D.CustomVertex.PositionTextured[4]; GenerateVerticies(); }
/// <summary> /// linear interpolation between two vectors3 /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <param name="delta"></param> /// <returns></returns> public static Vector3 Interpolate3D(Vector3 start, Vector3 end, float delta) { Microsoft.DirectX.Vector3 result = new Microsoft.DirectX.Vector3(); result.X = (1 - delta) * start.X + delta * end.X; result.Y = (1 - delta) * start.Y + delta * end.Y; result.Z = (1 - delta) * start.Z + delta * end.Z; return(result); }
public static void GetBoundingBox(D3D.Mesh mesh, float scale, out DX.Vector3 min, out DX.Vector3 max) { D3D.VertexBuffer verts = mesh.VertexBuffer; DX.GraphicsStream stream = verts.Lock(0, 0, D3D.LockFlags.None); D3D.Geometry.ComputeBoundingBox(stream, mesh.NumberVertices, mesh.VertexFormat, out min, out max); verts.Unlock(); stream = null; verts = null; }
public DX.Vector3[] GetVertexPositions() { DX.Vector3[] output = new DX.Vector3[vertices.Length]; for (int i = 0; i < output.Length; i++) { output[i] = vertices[i].position; } return(output); }
public Intersection IntersectRay(Microsoft.DirectX.Vector3 origin, Microsoft.DirectX.Vector3 direction) { Vector4 vector4 = Vector3.Transform(direction, transform.matrix); direction = new Vector3(vector4.X, vector4.Y, vector4.Z); vector4 = Vector3.Transform(origin, transform.matrix); origin = new Vector3(vector4.X, vector4.Y, vector4.Z); return(Model.IntersectRay(origin, direction)); }
public Particle(float newGravity, DirectX.Vector3 newPositions, DirectX.Vector3 newVelocities, float newTimeCreated) { this.TimeCreated = newTimeCreated; this.Gravity = newGravity; this.Positions = newPositions; this.Velocities = newVelocities; this.Verticies = new Direct3D.CustomVertex.PositionTextured[4]; GenerateVerticies(); }
//*************************************************************************** // Public Methods // /// <summary> /// Releases all resources in use by this object and prepares the object for garbage collection. /// </summary> public void Dispose() { this._mesh.Dispose(); Array.Clear(this._materials, 0, this._materials.Length); this._materials = new D3D.Material[0]; Array.Clear(this._textures, 0, this._textures.Length); this._textures = new D3D.Texture[0]; this._angle = DX.Vector3.Empty; this._position = DX.Vector3.Empty; }
private static bool equals(Joint j, Joint i) { float delta = Properties.Settings.Default.JoinTolerance; Microsoft.DirectX.Vector3 d = j.Position - i.Position; if (d.LengthSq() < delta) { return(true); } return(false); }
public override void Play(SoundVector pos, bool loop, int volume, ref AutoResetEvent completedEvent) { // Set up two notification events, one at halfway, and one at the end of the buffer Microsoft.DirectX.DirectSound.BufferPositionNotify[] notifyCompleteEvent = new Microsoft.DirectX.DirectSound.BufferPositionNotify[1]; notifyCompleteEvent[0].Offset = m_description3d.BufferBytes - 1; notifyCompleteEvent[0].EventNotifyHandle = completedEvent.SafeWaitHandle.DangerousGetHandle(); m_notify.SetNotificationPositions(notifyCompleteEvent); Play(pos, loop, volume); }
public static void MoveForward(ref DX.Vector3 position, ref DX.Vector3 angles, float speed) { DX.Vector3 v = new DX.Vector3(); v.X += (float)System.Math.Sin(angles.X); v.Y += (float)System.Math.Cos(angles.Z); v.Z -= (float)System.Math.Tan(angles.Y); v.Normalize(); position += v * speed; v = DX.Vector3.Empty; }
public override void Play(SoundVector pos, bool loop, int volume) { Microsoft.DirectX.DirectSound.BufferPlayFlags flags = Microsoft.DirectX.DirectSound.BufferPlayFlags.Default; if (loop) { flags = Microsoft.DirectX.DirectSound.BufferPlayFlags.Looping; } UpdatePosition(pos); SetVolume(volume); m_secondaryBuffer.Play(0, flags); }
public void UpdateSoundPosition(string file, SoundVector pos) { lock (m_soundlist) { if (m_soundlist.ContainsKey(file)) { if (m_soundlist[file].IsPlaying()) { ((Sound3d)m_soundlist[file]).UpdatePosition(pos); } } } }
/// <summary> /// Play a mono sound in 3d /// </summary> /// <param name="file">file to be played</param> /// <param name="loop">loop file</param> public bool PlaySound3D(string file, SoundVector pos, bool loop, int volume) { bool retval = false; lock (m_soundlist) { if (m_soundlist.ContainsKey(file)) { m_soundlist[file].Play(pos, loop, volume); retval = true; } } return(retval); }
public void Render() { if (!running || !needsRefresh) { return; } DX.Vector3 low, high; if (current != null && current.GetBounds(out low, out high)) { DX.Vector3 center = (low + high) * 0.5f; DX.Vector3 size = high - low; float max = Math.Max(size.X, Math.Max(size.Y, size.Z)); renderer.view = DX.Matrix.LookAtRH(center + new DX.Vector3(0, max * 1.5f, -max * 2), center, new DX.Vector3(0, 1, 0)); } needsRefresh = false; renderer.clearColor = System.Drawing.Color.FromArgb(0, 15, 45); renderer.RenderFrame(); device.device.Present(this); }
public override void Run(Canguro.Controller.CommandServices services) { Canguro.Model.UnitSystem.UnitSystemsManager.Instance.Enabled = false; try { Microsoft.DirectX.Vector3[] pivots = new Microsoft.DirectX.Vector3[3]; // Get 3 Points Joint j1 = services.GetJoint((IList <LineElement>)null); services.TrackingService = Canguro.Controller.Tracking.LineTrackingService.Instance; services.TrackingService.SetPoint(j1.Position); services.Model.ChangeModel(); Joint j2 = services.GetJoint((IList <LineElement>)null); services.TrackingService.SetPoint(j2.Position); services.Model.ChangeModel(); Joint j3 = services.GetJoint((IList <LineElement>)null); services.TrackingService = null; services.Model.ChangeModel(); pivots[0] = j1.Position; pivots[1] = j2.Position; pivots[2] = j3.Position; Vector3 v1 = pivots[0] - pivots[1]; Vector3 v2 = pivots[1] - pivots[2]; Vector3 N = Vector3.Cross(v1, v2); if (N.LengthSq() < 0.0001) // If Colinear, take perpendicular to the active view. { System.Windows.Forms.MessageBox.Show(Culture.Get("ColinearPoints"), Culture.Get("error"), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); } else { int segments = (int)services.GetSingle(Culture.Get("getSplitParts") + " [2-100]"); Vector3 C = calcCenter(pivots[0], pivots[1], pivots[2]); MakeArc(services.Model, C, N, j1, j3, j2, segments); } } finally { Canguro.Model.UnitSystem.UnitSystemsManager.Instance.Enabled = true; } }
/// <summary> /// Executes the command. /// Gets the parameters and calls createCylinder to add a Cylinder to the model /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { if (section == null) { section = Canguro.Model.Section.SectionManager.Instance.DefaultFrameSection as Canguro.Model.Section.FrameSection; } services.GetProperties(Culture.Get("cylinderCmdTitle"), this); Controller.Snap.Magnet m = services.GetPoint(Culture.Get("selectCylinderCenter")); if (m == null) { return; } Microsoft.DirectX.Vector3 o = m.SnapPosition; StraightFrameProps props = new StraightFrameProps(); props.Section = section; createCylinder(services.Model, o, r, c, h, s + 1, props); }
public override void Run(Canguro.Controller.CommandServices services) { Canguro.Model.UnitSystem.UnitSystemsManager.Instance.Enabled = false; try { Microsoft.DirectX.Vector3[] pivots = new Microsoft.DirectX.Vector3[3]; // Get 3 Points Joint j1 = services.GetJoint((IList<LineElement>)null); services.TrackingService = Canguro.Controller.Tracking.LineTrackingService.Instance; services.TrackingService.SetPoint(j1.Position); services.Model.ChangeModel(); Joint j2 = services.GetJoint((IList<LineElement>)null); services.TrackingService.SetPoint(j2.Position); services.Model.ChangeModel(); Joint j3 = services.GetJoint((IList<LineElement>)null); services.TrackingService = null; services.Model.ChangeModel(); pivots[0] = j1.Position; pivots[1] = j2.Position; pivots[2] = j3.Position; Vector3 v1 = pivots[0] - pivots[1]; Vector3 v2 = pivots[1] - pivots[2]; Vector3 N = Vector3.Cross(v1, v2); if (N.LengthSq() < 0.0001) // If Colinear, take perpendicular to the active view. System.Windows.Forms.MessageBox.Show(Culture.Get("ColinearPoints"), Culture.Get("error"), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); else { int segments = (int)services.GetSingle(Culture.Get("getSplitParts") + " [2-100]"); Vector3 C = calcCenter(pivots[0], pivots[1], pivots[2]); MakeArc(services.Model, C, N, j1, j3, j2, segments); } } finally { Canguro.Model.UnitSystem.UnitSystemsManager.Instance.Enabled = true; } }
public bool GetBounds(ref Microsoft.DirectX.Vector3 low, ref Microsoft.DirectX.Vector3 high) { bool result = false; foreach (Node n in children) { result |= n.GetBounds(ref low, ref high); } foreach (var dl in dls) { Microsoft.DirectX.Vector3[] vertices = dl.dl.GetVertexPositions(); foreach (Microsoft.DirectX.Vector3 vertex in vertices) { low.X = Math.Min(vertex.X, low.X); low.Y = Math.Min(vertex.Y, low.Y); low.Z = Math.Min(vertex.Z, low.Z); high.X = Math.Max(vertex.X, high.X); high.Y = Math.Max(vertex.Y, high.Y); high.Z = Math.Max(vertex.Z, high.Z); } result = true; } return(result); }
public override void LoadData(ref AnimatTools.DataObjects.Simulation dsSim, ref AnimatTools.DataObjects.Physical.PhysicalStructure doStructure, ref AnimatTools.Interfaces.StdXml oXml) { base.LoadData (ref dsSim, ref doStructure, ref oXml); oXml.IntoElem(); //get the color of the body if(oXml.FindChildElement("Color")) { System.Drawing.Color oColor = Util.LoadColor(ref oXml, "Color"); this.Alpha = oColor.A; this.Color = oColor; } if(oXml.FindChildElement("Direction",false)) { this.m_v3Direction = new Vector3(); Vec3d vDirection = Util.LoadVec3d(ref oXml, "Direction", this); m_v3Direction.X = (float)vDirection.X; m_v3Direction.Y = (float)vDirection.Y; m_v3Direction.Z = (float)vDirection.Z; } if(oXml.FindChildElement("OrientationMatrix", false)) { m_mtxOrientation = Util_DX.LoadMatrix(ref oXml, "OrientationMatrix"); m_v3Rotation = Util_DX.DecomposeXYZRotationMatrix(Orientation); } if(oXml.FindChildElement("TranslationMatrix",false)) m_mtxTranslation = Util_DX.LoadMatrix(ref oXml,"TranslationMatrix"); oXml.OutOfElem(); }
public void OnCreateVBMinimap(object sender, EventArgs e) { var buffer = sender as VertexBuffer; CustomVertex.PositionNormalTextured[] texturedArray = (CustomVertex.PositionNormalTextured[])buffer.Lock(0, LockFlags.None); Microsoft.DirectX.Vector3 vector = new Microsoft.DirectX.Vector3(-(this.tileSize / 2f), -(this.tileSize / 2f), 0f); Microsoft.DirectX.Vector3 vector2 = new Microsoft.DirectX.Vector3(this.tileSize / 2f, -(this.tileSize / 2f), 0f); Microsoft.DirectX.Vector3 vector3 = new Microsoft.DirectX.Vector3(-(this.tileSize / 2f), this.tileSize / 2f, 0f); Microsoft.DirectX.Vector3 nor = this.ComputeNormal(vector, vector2, vector3); texturedArray[0] = new CustomVertex.PositionNormalTextured(vector, nor, 0f, 0f); texturedArray[1] = new CustomVertex.PositionNormalTextured(vector2, nor, 1f, 0f); texturedArray[2] = new CustomVertex.PositionNormalTextured(vector3, nor, 0f, 1f); vector = new Microsoft.DirectX.Vector3(this.tileSize / 2f, this.tileSize / 2f, 0f); vector2 = new Microsoft.DirectX.Vector3(-(this.tileSize / 2f), this.tileSize / 2f, 0f); vector3 = new Microsoft.DirectX.Vector3(this.tileSize / 2f, -(this.tileSize / 2f), 0f); nor = this.ComputeNormal(vector, vector2, vector3); texturedArray[3] = new CustomVertex.PositionNormalTextured(vector, nor, 1f, 1f); texturedArray[4] = new CustomVertex.PositionNormalTextured(vector2, nor, 0f, 1f); texturedArray[5] = new CustomVertex.PositionNormalTextured(vector3, nor, 1f, 0f); buffer.Unlock(); }
public virtual void Render2(DrawArgs drawArgs) { if (this.m_Visible) { if ((this.dblLatitude != double.MinValue) && ((drawArgs.WorldCamera.Altitude > 100.0) || (World.Settings.VerticalExaggeration >= 1f))) { try { drawArgs.device.RenderState.ZBufferEnable = true; Cull cullMode = drawArgs.device.RenderState.CullMode; drawArgs.device.RenderState.CullMode = Cull.None; drawArgs.device.VertexFormat = VertexFormats.Diffuse | VertexFormats.Position; drawArgs.device.TextureState[0].ColorOperation = TextureOperation.Disable; Microsoft.DirectX.Matrix matrix = Microsoft.DirectX.Matrix.Translation((float)-drawArgs.WorldCamera.ReferenceCenter.X, (float)-drawArgs.WorldCamera.ReferenceCenter.Y, (float)-drawArgs.WorldCamera.ReferenceCenter.Z); drawArgs.device.Transform.World = matrix; Microsoft.DirectX.Vector3 vector = MathEngine.SphericalToCartesian((double)this.dblLatitude, (double)this.dblLongitude, (this.ww.CurrentWorld.EquatorialRadius + (this.ww.CurrentWorld.TerrainAccessor.GetElevationAt((double)this.dblLatitude, (double)this.dblLongitude, 100.0) * World.Settings.VerticalExaggeration)) + this.dblAltitude); Microsoft.DirectX.Vector3 vector2 = new Microsoft.DirectX.Vector3(); Microsoft.DirectX.Vector3 vector3 = new Microsoft.DirectX.Vector3(); vector2.X = this.m_Location.X + (((float)this.m_Size.Width) / 3f); vector2.Y = (this.m_Location.Y + this.m_Size.Height) - 5; vector2.Z = 0f; vector2.Unproject(drawArgs.device.Viewport, drawArgs.WorldCamera.ProjectionMatrix, drawArgs.WorldCamera.ViewMatrix, drawArgs.device.Transform.World); vector3.X = this.m_Location.X + (2f * (((float)this.m_Size.Width) / 3f)); vector3.Y = (this.m_Location.Y + this.m_Size.Height) - 5; vector3.Z = 0f; vector3.Unproject(drawArgs.device.Viewport, drawArgs.WorldCamera.ProjectionMatrix, drawArgs.WorldCamera.ViewMatrix, drawArgs.device.Transform.World); CustomVertex.PositionColored[] vertexStreamZeroData = new CustomVertex.PositionColored[3]; vertexStreamZeroData[0].X = vector.X; vertexStreamZeroData[0].Y = vector.Y; vertexStreamZeroData[0].Z = vector.Z; vertexStreamZeroData[0].Color = this.m_BackgroundColor.ToArgb(); vertexStreamZeroData[1].X = vector2.X; vertexStreamZeroData[1].Y = vector2.Y; vertexStreamZeroData[1].Z = vector2.Z; vertexStreamZeroData[1].Color = this.m_BackgroundColor.ToArgb(); vertexStreamZeroData[2].X = vector3.X; vertexStreamZeroData[2].Y = vector3.Y; vertexStreamZeroData[2].Z = vector3.Z; vertexStreamZeroData[2].Color = this.m_BackgroundColor.ToArgb(); drawArgs.device.DrawUserPrimitives(PrimitiveType.TriangleStrip, vertexStreamZeroData.Length - 2, vertexStreamZeroData); drawArgs.device.Transform.World = drawArgs.WorldCamera.WorldMatrix; drawArgs.device.RenderState.CullMode = cullMode; drawArgs.device.TextureState[0].ColorOperation = TextureOperation.Disable; } catch (Exception exception) { MessageBox.Show(exception.Message); } } if (this.m_TextFont == null) { System.Drawing.Font font = new System.Drawing.Font("Arial", 12f, FontStyle.Italic | FontStyle.Bold); this.m_TextFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, font); } if (this.m_WorldWindDingsFont == null) { AddFontResource(Path.Combine(Application.StartupPath, "World Wind Dings 1.04.ttf")); PrivateFontCollection fonts = new PrivateFontCollection(); fonts.AddFontFile(Path.Combine(Application.StartupPath, "World Wind Dings 1.04.ttf")); System.Drawing.Font font2 = new System.Drawing.Font(fonts.Families[0], 12f); this.m_WorldWindDingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, font2); } if (this.m_Resizeble) { if (((DrawArgs.LastMousePosition.X > (this.AbsoluteLocation.X - this.resizeBuffer)) && (DrawArgs.LastMousePosition.X < (this.AbsoluteLocation.X + this.resizeBuffer))) && ((DrawArgs.LastMousePosition.Y > (this.AbsoluteLocation.Y - this.resizeBuffer)) && (DrawArgs.LastMousePosition.Y < (this.AbsoluteLocation.Y + this.resizeBuffer)))) { DrawArgs.MouseCursor = CursorType.SizeNWSE; } else if (((DrawArgs.LastMousePosition.X > ((this.AbsoluteLocation.X - this.resizeBuffer) + this.ClientSize.Width)) && (DrawArgs.LastMousePosition.X < ((this.AbsoluteLocation.X + this.resizeBuffer) + this.ClientSize.Width))) && ((DrawArgs.LastMousePosition.Y > (this.AbsoluteLocation.Y - this.resizeBuffer)) && (DrawArgs.LastMousePosition.Y < (this.AbsoluteLocation.Y + this.resizeBuffer)))) { DrawArgs.MouseCursor = CursorType.SizeNESW; } else if (((DrawArgs.LastMousePosition.X > (this.AbsoluteLocation.X - this.resizeBuffer)) && (DrawArgs.LastMousePosition.X < (this.AbsoluteLocation.X + this.resizeBuffer))) && ((DrawArgs.LastMousePosition.Y > ((this.AbsoluteLocation.Y - this.resizeBuffer) + this.ClientSize.Height)) && (DrawArgs.LastMousePosition.Y < ((this.AbsoluteLocation.Y + this.resizeBuffer) + this.ClientSize.Height)))) { DrawArgs.MouseCursor = CursorType.SizeNESW; } else if (((DrawArgs.LastMousePosition.X > ((this.AbsoluteLocation.X - this.resizeBuffer) + this.ClientSize.Width)) && (DrawArgs.LastMousePosition.X < ((this.AbsoluteLocation.X + this.resizeBuffer) + this.ClientSize.Width))) && ((DrawArgs.LastMousePosition.Y > ((this.AbsoluteLocation.Y - this.resizeBuffer) + this.ClientSize.Height)) && (DrawArgs.LastMousePosition.Y < ((this.AbsoluteLocation.Y + this.resizeBuffer) + this.ClientSize.Height)))) { DrawArgs.MouseCursor = CursorType.SizeNWSE; } else if ((((DrawArgs.LastMousePosition.X > (this.AbsoluteLocation.X - this.resizeBuffer)) && (DrawArgs.LastMousePosition.X < (this.AbsoluteLocation.X + this.resizeBuffer))) && ((DrawArgs.LastMousePosition.Y > (this.AbsoluteLocation.Y - this.resizeBuffer)) && (DrawArgs.LastMousePosition.Y < ((this.AbsoluteLocation.Y + this.resizeBuffer) + this.ClientSize.Height)))) || (((DrawArgs.LastMousePosition.X > ((this.AbsoluteLocation.X - this.resizeBuffer) + this.ClientSize.Width)) && (DrawArgs.LastMousePosition.X < ((this.AbsoluteLocation.X + this.resizeBuffer) + this.ClientSize.Width))) && ((DrawArgs.LastMousePosition.Y > (this.AbsoluteLocation.Y - this.resizeBuffer)) && (DrawArgs.LastMousePosition.Y < ((this.AbsoluteLocation.Y + this.resizeBuffer) + this.ClientSize.Height))))) { DrawArgs.MouseCursor = CursorType.SizeWE; } else if ((((DrawArgs.LastMousePosition.X > (this.AbsoluteLocation.X - this.resizeBuffer)) && (DrawArgs.LastMousePosition.X < ((this.AbsoluteLocation.X + this.resizeBuffer) + this.ClientSize.Width))) && ((DrawArgs.LastMousePosition.Y > (this.AbsoluteLocation.Y - this.resizeBuffer)) && (DrawArgs.LastMousePosition.Y < (this.AbsoluteLocation.Y + this.resizeBuffer)))) || (((DrawArgs.LastMousePosition.X > (this.AbsoluteLocation.X - this.resizeBuffer)) && (DrawArgs.LastMousePosition.X < ((this.AbsoluteLocation.X + this.resizeBuffer) + this.ClientSize.Width))) && ((DrawArgs.LastMousePosition.Y > ((this.AbsoluteLocation.Y - this.resizeBuffer) + this.ClientSize.Height)) && (DrawArgs.LastMousePosition.Y < ((this.AbsoluteLocation.Y + this.resizeBuffer) + this.ClientSize.Height))))) { DrawArgs.MouseCursor = CursorType.SizeNS; } } if (this.ClientSize.Height > drawArgs.parentControl.Height) { this.ClientSize = new Size(this.ClientSize.Width, drawArgs.parentControl.Height); } if (this.ClientSize.Width > drawArgs.parentControl.Width) { this.ClientSize = new Size(drawArgs.parentControl.Width, this.ClientSize.Height); } if (!this.m_AutoHideHeader || (((DrawArgs.LastMousePosition.X >= this.m_Location.X) && (DrawArgs.LastMousePosition.X <= (this.m_Location.X + this.m_Size.Width))) && ((DrawArgs.LastMousePosition.Y >= this.m_Location.Y) && (DrawArgs.LastMousePosition.Y <= (this.m_Location.Y + this.m_Size.Height))))) { Utilities.DrawBox(this.m_Location.X, this.m_Location.Y, this.m_Size.Width, this.m_HeaderHeight, 0f, this.m_HeaderColor.ToArgb(), drawArgs.device); this.m_WorldWindDingsFont.DrawText(null, "E", new Rectangle((this.m_Location.X + this.m_Size.Width) - 15, this.m_Location.Y + 2, this.m_Size.Width, this.m_Size.Height), DrawTextFormat.NoClip, Color.White.ToArgb()); this.m_OutlineVertsHeader[0].X = this.AbsoluteLocation.X; this.m_OutlineVertsHeader[0].Y = this.AbsoluteLocation.Y + this.m_HeaderHeight; this.m_OutlineVertsHeader[1].X = this.AbsoluteLocation.X; this.m_OutlineVertsHeader[1].Y = this.AbsoluteLocation.Y; this.m_OutlineVertsHeader[2].X = this.AbsoluteLocation.X + this.ClientSize.Width; this.m_OutlineVertsHeader[2].Y = this.AbsoluteLocation.Y; this.m_OutlineVertsHeader[3].X = this.AbsoluteLocation.X + this.ClientSize.Width; this.m_OutlineVertsHeader[3].Y = this.AbsoluteLocation.Y + this.m_HeaderHeight; if (!this.m_HideBorder) { Utilities.DrawLine(this.m_OutlineVertsHeader, this.m_BorderColor.ToArgb(), drawArgs.device); } } Utilities.DrawBox(this.m_Location.X, this.m_Location.Y + this.m_HeaderHeight, this.m_Size.Width, this.m_Size.Height - this.m_HeaderHeight, 0f, this.m_BackgroundColor.ToArgb(), drawArgs.device); for (int i = this.m_ChildWidgets.Count - 1; i >= 0; i--) { IWidget widget = this.m_ChildWidgets[i]; if (widget != null) { if ((widget.ParentWidget == null) || (widget.ParentWidget != this)) { widget.ParentWidget = this; } widget.Render(drawArgs); } } this.m_OutlineVerts[0].X = this.AbsoluteLocation.X + this.ClientSize.Width; this.m_OutlineVerts[0].Y = this.AbsoluteLocation.Y + this.m_HeaderHeight; this.m_OutlineVerts[1].X = this.AbsoluteLocation.X + this.ClientSize.Width; this.m_OutlineVerts[1].Y = this.AbsoluteLocation.Y + this.ClientSize.Height; this.m_OutlineVerts[2].X = this.AbsoluteLocation.X; this.m_OutlineVerts[2].Y = this.AbsoluteLocation.Y + this.ClientSize.Height; this.m_OutlineVerts[3].X = this.AbsoluteLocation.X; this.m_OutlineVerts[3].Y = this.AbsoluteLocation.Y + this.m_HeaderHeight; if (!this.m_HideBorder) { Utilities.DrawLine(this.m_OutlineVerts, this.m_BorderColor.ToArgb(), drawArgs.device); } } }
public virtual void Play(SoundVector pos, bool loop, int volume, ref AutoResetEvent completedEvent) { }
public void AddExplosion(DirectX.Vector3 ExplosionPosition) { this.ExplosionEffects.Add(new Explosion(CurrDevice, ExplosionPosition)); }
public override void UpdateWithMouse(AnimatTools.Framework.MouseEventArgs AnimatMouseArgs) { IntersectInformation iiInfo = new IntersectInformation(); //matrix transormation of the world Vector3 tmp = new Vector3(); tmp.TransformCoordinate(CombinedTransformationMatrix * this.Device.Transform.World1); Matrix mWorld = this.Device.Transform.View; mWorld.Invert(); mWorld.M41 = tmp.X; mWorld.M42 = tmp.Y; mWorld.M43 = tmp.Z; if(AnimatMouseArgs.Button == System.Windows.Forms.MouseButtons.None) { m_bUBSelected = false; m_bLBSelected = false; m_bSelectionBoxSelected = false; return; } //Did we click on the middle selection box? if(m_mshCB != null && Util_DX.TestIntersectWithMouse(m_mshCB,Device.Viewport, Device.Transform.Projection, Device.Transform.View, mWorld,AnimatMouseArgs.X, AnimatMouseArgs.Y, out iiInfo)) m_bUBSelected = true; mWorld.M41 = m_v3LB.X; mWorld.M42 = m_v3LB.Y; mWorld.M43 = m_v3LB.Z; //Did we click on the lower selection box? if(m_mshLB != null && Util_DX.TestIntersectWithMouse(m_mshLB,Device.Viewport, Device.Transform.Projection, Device.Transform.View, mWorld,AnimatMouseArgs.X, AnimatMouseArgs.Y, out iiInfo)) m_bLBSelected = true; if(m_bUBSelected && !m_bSelectionBoxSelected) ProcessCenterSquare(AnimatMouseArgs); else if(m_bLBSelected && !m_bSelectionBoxSelected) ProcessLowerSquare(AnimatMouseArgs); else { mWorld = CombinedTransformationMatrix * this.Device.Transform.World1; if(!m_bSelectionBoxSelected && this.m_mshSelectedBoundingBox != null && Util_DX.TestIntersectWithMouse(this.m_mshSelectedBoundingBox,Device.Viewport, Device.Transform.Projection, Device.Transform.View, mWorld,AnimatMouseArgs.X, AnimatMouseArgs.Y, out iiInfo)) { m_bSelectionBoxSelected = true; Vector3[] vertsFace = Util_DX.FindIntersectionFace(this.m_mshSelectedBoundingBox, iiInfo); //the normal of the selected face this.m_v3SBBN = Util_DX.CalculateNormal(vertsFace); } if(m_bSelectionBoxSelected) ProcessSelectedBoundingBox(AnimatMouseArgs, this.m_v3SBBN); } }
protected void RigidBody_Clone(AnimatTools.Framework.DataObject doOriginal, bool bCutData, AnimatTools.Framework.DataObject doRoot) { RigidBody_DX doOrigBody = (RigidBody_DX) doOriginal; m_d3dDevice = doOrigBody.m_d3dDevice; m_v3Rotation = new Microsoft.DirectX.Vector3(doOrigBody.m_v3Rotation.X, doOrigBody.m_v3Rotation.Y, doOrigBody.m_v3Rotation.Z); m_v3Direction = new Microsoft.DirectX.Vector3(doOrigBody.m_v3Direction.X, doOrigBody.m_v3Direction.Y, doOrigBody.m_v3Direction.Z); m_mtxOrientation = Util_DX.CloneMatrix(doOrigBody.m_mtxOrientation); m_mtxTranslation = Util_DX.CloneMatrix(doOrigBody.m_mtxTranslation); m_d3dMaterial.Ambient = doOrigBody.m_d3dMaterial.Ambient; m_d3dMaterial.Diffuse = doOrigBody.m_d3dMaterial.Diffuse; m_d3dTransparentMaterial.Ambient = doOrigBody.m_d3dTransparentMaterial.Ambient; m_d3dTransparentMaterial.Diffuse = doOrigBody.m_d3dTransparentMaterial.Diffuse; m_snXLocalLocation = (AnimatTools.Framework.ScaledNumber) doOrigBody.m_snXLocalLocation.Clone(this, bCutData, doRoot); m_snYLocalLocation = (AnimatTools.Framework.ScaledNumber) doOrigBody.m_snYLocalLocation.Clone(this, bCutData, doRoot); m_snZLocalLocation = (AnimatTools.Framework.ScaledNumber) doOrigBody.m_snZLocalLocation.Clone(this, bCutData, doRoot); m_snXWorldLocation = (AnimatTools.Framework.ScaledNumber) doOrigBody.m_snXWorldLocation.Clone(this, bCutData, doRoot); m_snYWorldLocation = (AnimatTools.Framework.ScaledNumber) doOrigBody.m_snYWorldLocation.Clone(this, bCutData, doRoot); m_snZWorldLocation = (AnimatTools.Framework.ScaledNumber) doOrigBody.m_snZWorldLocation.Clone(this, bCutData, doRoot); m_snXRotation = (AnimatTools.Framework.ScaledNumber) doOrigBody.m_snXRotation.Clone(this, bCutData, doRoot); m_snYRotation = (AnimatTools.Framework.ScaledNumber) doOrigBody.m_snYRotation.Clone(this, bCutData, doRoot); m_snZRotation = (AnimatTools.Framework.ScaledNumber) doOrigBody.m_snZRotation.Clone(this, bCutData, doRoot); }
public void UpdatePosition(SoundVector pos) { m_buffer3d.Position = pos; }
void execute(string cmd) { if (cmd == null) { return; } //cmd = cmd.ToLower(); string[] kw = cmd.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); if (kw.Length == 0) { return; } kw[0] = kw[0].ToLower(); #region sys if (kw[0] == "?var") { string name = kw[1]; string value = kw[3]; if (kw[2] == "=") { string val = ""; try { val = vars[name].ToString(); } catch { return; } if (val == value) { string[] nkw = new string[kw.Length - 4]; for (int i = 4; i < kw.Length; i++) { nkw[i - 4] = kw[i]; } kw = nkw; } else { return; } } else if (kw[2] == "#") { string val = ""; try { val = vars[name].ToString(); } catch { return; } if (val != value) { string[] nkw = new string[kw.Length - 4]; for (int i = 4; i < kw.Length; i++) { nkw[i - 4] = kw[i]; } kw = nkw; } else { return; } } else if (kw[2] == "<") { string val = ""; try { val = vars[name].ToString(); } catch { return; } if (int.Parse(val) < int.Parse(value)) { string[] nkw = new string[kw.Length - 4]; for (int i = 4; i < kw.Length; i++) { nkw[i - 4] = kw[i]; } kw = nkw; } else { return; } } } if (kw[0] == "exit") { game.Exit(); } else if (kw[0] == "roll") { int l = int.Parse(kw[1]); int h = int.Parse(kw[2]); int seed = Util.Roll(l, h); SetVariable("roll", seed.ToString()); //RETURN.INT = seed; } //else if (kw[0] == "exe") //{ // exe = true; //} else if (kw[0] == "clr") { text = ""; } else if (kw[0] == "var") { if (kw[2] == "=") { SetVariable(kw[1], kw[3]); } } //else if (kw[0] == "return") //{ // try // { // int i = int.Parse(kw[1]); // RETURN.INT = i; // } // catch // { // try // { // bool y = bool.Parse(kw[1]); // RETURN.BOOL = y; // } // catch // { // RETURN.STRING = kw[1]; // } // } //} else if (kw[0] == "fullscreen") { game.ToggleToFullScreen(); } //else if (kw[0] == "comctrl") //{ // game.SceneManager.Controllable = false; // game.FormBoxManager.Controllable = false; //} //else if (kw[0] == "userctrl") //{ // game.SceneManager.Controllable = true; // game.FormBoxManager.Controllable = true; //} else if (kw[0] == "delay") { double ms = double.Parse(kw[1]); //delayLeftTime = delayTime = ms; //delayStartTime = DateTime.Now; Delay((int)ms); } else if (kw[0] == "mp3") { int l = int.Parse(kw[1]); bool loop = false; try { if (kw[3] == "loop") { loop = true; } } catch { } if (kw.Length > 2) { game.PlayMP3Audio(l, game.AudioFiles[kw[2]].FullName, loop); } else { game.StopAudio(l); } } else if (kw[0] == "vol") { game.SetVolume(int.Parse(kw[1]), int.Parse(kw[2])); } else if (kw[0] == "script") { //int c = cmdque.Count; //for (int i = 0; i < c; i++) //{ // tmpcommands.Enqueue(commands.Dequeue()); //} InsertDotMetalXScript(kw[1]); //for (int i = 0; i < c; i++) //{ // commands.Enqueue(tmpcommands.Dequeue()); //} } else if (kw[0] == "untilstop") { double a; if (kw[1] == "pc") { a = game.ME.NeedMovePixel; } else { a = game.GetNPC(kw[1]).NeedMovePixel; } if (a > 0) { block = true; } else { block = false; } } else if (kw[0] == "untilpress") { block = true; string key = kw[1]; if (key == "yes" || key == "y") { key = game.Options.KeyYES.ToString(); } else if (key == "no" || key == "n") { key = game.Options.KeyNO.ToString(); } key = key.ToLower(); if (presskey == key) { block = false; } try { string key2 = kw[2]; if (key2 == "yes" || key2 == "y") { key2 = game.Options.KeyYES.ToString(); } else if (key2 == "no" || key2 == "n") { key2 = game.Options.KeyNO.ToString(); } key2 = key2.ToLower(); if (presskey == key2) { block = false; } } catch { } } #endregion #region npc else if (kw[0] == "npc") { NPC n = game.GetNPC(kw[1]); if (kw[2] == "dir") { Direction dir = Direction.U; if (kw[3] == "def") { n.RecoverDirection(); } else { if (kw[3] == "u") { dir = Direction.U; } else if (kw[3] == "l") { dir = Direction.L; } else if (kw[3] == "d") { dir = Direction.D; } else { dir = Direction.R; } n.Face(dir); } } else if (kw[2] == "move") { int stp = 1; try { stp = int.Parse(kw[3]); } catch { } if (stp > 1) { for (int i = 0; i < stp; i++) { ins_que("npc " + kw[1] + " move 1"); if (i + 1 < stp) { ins_que("untilstop " + kw[1]); } } } else { n.Move(game.SCN, game.GetNPC(n), game.Options.TilePixelX); } //game.SceneManager.Move(n, stp); } else if (kw[2] == "hide") { n.Invisible = true; } else if (kw[2] == "show") { n.Invisible = false; } } #endregion #region pc else if (kw[0] == "pc") { //if (kw[1].Contains("var.")) //{ // string name = kw[1].Substring(4); // kw[1] = vars[name].ToString(); //} PC pc = game.ME; getValueByName(ref kw[1]); int c = int.Parse(kw[1]); if (game.PCs.Count > 0) { pc = game.PCs[c]; } getValueByName(ref kw[2]); if (kw.Length > 3) { getValueByName(ref kw[3]); } if (kw[2] == "skin") { pc.TextureName = kw[3]; pc.TextureIndex = -1; } //else if (kw[1] == "use") //{ // int i = int.Parse(kw[2]); // //game.ME.Gold += int.Parse(kw[2]); //} else if (kw[2] == "freeze") { pc.CanCtrl = false; } else if (kw[2] == "unfreeze") { pc.CanCtrl = true; } else if (kw[2] == "+hp") { pc.HP += int.Parse(kw[3]); } else if (kw[2] == "-hp") { pc.HP -= int.Parse(kw[3]); } else if (kw[2] == "equip") { int i = int.Parse(kw[3]); pc.BagEquip(i); } else if (kw[2] == "unequip") { int i = int.Parse(kw[3]); pc.BagEquip(i); } else if (kw[2] == "unequip") { int i = int.Parse(kw[3]); pc.BagUnequip((EquipmentCHRType)i); } else if (kw[2] == "bagremove") { int i = int.Parse(kw[3]); pc.BagRemove(i); } else if (kw[2] == "+gold") { pc.Gold += int.Parse(kw[3]); } else if (kw[2] == "bagadd") { Item item; int i = -1; try { i = int.Parse(kw[3]); item = game.Items[i].GetClone(); } catch { item = game.Items[kw[3]].GetClone(); } item.GUID = Guid.NewGuid(); pc.BagAdd(item); } else if (kw[2] == "jump") { Microsoft.DirectX.Vector3 v3 = new Microsoft.DirectX.Vector3(); v3.X = float.Parse(kw[3]); v3.Y = float.Parse(kw[4]); pc.SetRealLocation(v3, game.Options.TilePixelX); game.SceneManager.SceneJump(v3); } else if (kw[2] == "dir") { Direction dir = Direction.U; if (kw[3] == "u") { dir = Direction.U; } else if (kw[3] == "l") { dir = Direction.L; } else if (kw[3] == "d") { dir = Direction.D; } else { dir = Direction.R; } if (pc.Face(dir)) { game.SCN.Face(pc.OppositeDirection); } } else if (kw[2] == "move") { int stp = 1; try { stp = int.Parse(kw[3]); } catch { } if (stp > 1) { for (int i = 0; i < stp; i++) { ins_que("pc 0 move 1"); if (i + 1 < stp) { ins_que("untilstop pc"); } } } else { if (pc.Move(game.SCN, game.GetNPC(pc), game.Options.TilePixelX)) { game.SCN.Move(1, game.Options.TilePixelX); } } } else if (kw[2] == "fdir") { Direction dir = Direction.U; if (kw[3] == "u") { dir = Direction.U; } else if (kw[3] == "l") { dir = Direction.L; } else if (kw[3] == "d") { dir = Direction.D; } else { dir = Direction.R; } pc.ForceDirection = dir; game.SCN.Face(Util.GetOppositeDirection(dir)); } else if (kw[2] == "fmove") { int stp = 1; try { stp = int.Parse(kw[3]); } catch { } if (stp > 1) { for (int i = 0; i < stp; i++) { ins_que("pc fmove"); if (i + 1 < stp) { ins_que("untilstop pc"); } } } else { pc.ForceMove(game.Options.TilePixelX); { game.SCN.Move(1, game.Options.TilePixelX); } } } else if (kw[2] == "setrigor") { pc.IsRigor = true; } else if (kw[2] == "clrrigor") { pc.IsRigor = false; } else if (kw[2] == "battlesize") { int w = int.Parse(kw[3]); int h = int.Parse(kw[4]); pc.BattleSize = new Size(w, h); } else if (kw[2] == "standmovie") { int i = (int)BattleState.Stand; pc.BattleMovieIndexers[i].Name = kw[3]; } else if (kw[2] == "blockmovie") { int i = (int)BattleState.Block; pc.BattleMovieIndexers[i].Name = kw[3]; } else if (kw[2] == "hitmovie") { int i = (int)BattleState.Hit; pc.BattleMovieIndexers[i].Name = kw[3]; } else if (kw[2] == "fightmovie") { int i = (int)BattleState.Fight; pc.BattleMovieIndexers[i].Name = kw[3]; } else if (kw[2] == "weaponmovie") { int i = (int)BattleState.Weapon; pc.BattleMovieIndexers[i].Name = kw[3]; } else if (kw[2] == "itemmovie") { int i = (int)BattleState.Item; pc.BattleMovieIndexers[i].Name = kw[3]; } else if (kw[2] == "missmovie") { int i = (int)BattleState.Miss; pc.BattleMovieIndexers[i].Name = kw[3]; } else if (kw[2] == "runmovie") { int i = (int)BattleState.Run; pc.BattleMovieIndexers[i].Name = kw[3]; } else if (kw[2] == "stand") { pc.BattleState = BattleState.Stand; MetalX.File.MetalXMovie mov = game.LoadDotMXMovie(game.MovieFiles[pc.BattleMovieIndexer.Name].FullName); pc.SetBattleMovie(mov); } else if (kw[2] == "block") { pc.BattleState = BattleState.Block; MetalX.File.MetalXMovie mov = game.LoadDotMXMovie(game.MovieFiles[pc.BattleMovieIndexer.Name].FullName); pc.SetBattleMovie(mov); } else if (kw[2] == "hit") { pc.BattleState = BattleState.Hit; MetalX.File.MetalXMovie mov = game.LoadDotMXMovie(game.MovieFiles[pc.BattleMovieIndexer.Name].FullName); pc.SetBattleMovie(mov); } else if (kw[2] == "fight") { int t = int.Parse(kw[3]); Monster mon = game.Monsters[t]; Microsoft.DirectX.Vector3 v3 = mon.BattleLocation; v3.X += (mon.BattleSize.Width / 2 + pc.BattleSize.Width / 2); //v3.Y += mon.BattleSize.Height; //v3.Y -= game.ME.BattleSize.Height; pc.BattleState = BattleState.Fight; MetalX.File.MetalXMovie mov = game.LoadDotMXMovie(game.MovieFiles[pc.BattleMovieIndexer.Name].FullName); pc.SetBattleMovie(mov, pc.BattleLocation, v3, 1); try { game.PlayMP3Audio(2, game.AudioFiles[mov.BGSound.Name].FullName); } catch { } } else if (kw[2] == "weapon") { int t = int.Parse(kw[3]); Monster mon = game.Monsters[t]; pc.BattleState = BattleState.Weapon; MetalX.File.MetalXMovie mov = game.LoadDotMXMovie(game.MovieFiles[pc.BattleMovieIndexer.Name].FullName); pc.SetBattleMovie(mov); Vector3 floc = pc.BattleWeaponLocation; InsertCommand("?var op_type = weapon movie play " + pc.Weapon.ShotMovieIndexer.Name + " " + floc.X + " " + floc.Y); InsertCommand("delay " + mov.MovieTime); Vector3 tloc = mon.BattleLocation; double bt = pc.Weapon.FlyTime; if (bt == 0) { //InsertCommand("monster " + t + " hit"); //InsertCommand("?var bs = weapon movie play " + pc.Weapon.FlyMovieIndexer.Name + " " + tloc.X + " " + tloc.Y); } else { InsertCommand("monster " + t + " hit"); InsertCommand("?var op_type = weapon movie play " + pc.Weapon.FlyMovieIndexer.Name + " " + floc.X + " " + floc.Y + " " + tloc.X + " " + tloc.Y + " " + bt); } InsertCommand("delay " + bt); InsertCommand("?var op_type = weapon movie play " + pc.Weapon.HitMovieIndexer.Name + " " + tloc.X + " " + tloc.Y); } else if (kw[2] == "item") { int item_index = int.Parse(kw[3]); getValueByName(ref kw[4]); int t = int.Parse(kw[4]); Monster mon = game.Monsters[t]; pc.BattleState = BattleState.Item; MetalX.File.MetalXMovie mov = game.LoadDotMXMovie(game.MovieFiles[pc.BattleMovieIndexer.Name].FullName); pc.SetBattleMovie(mov); Vector3 floc = pc.BattleWeaponLocation; InsertCommand("?var op_type = item movie play " + pc.Bag[item_index].ShotMovieIndexer.Name + " " + floc.X + " " + floc.Y); InsertCommand("delay " + mov.MovieTime); Vector3 tloc = mon.BattleLocation; double bt = pc.Bag[item_index].FlyTime; if (bt == 0) { //InsertCommand("monster " + t + " hit"); //InsertCommand("?var bs = item movie play " + pc.Bag[item_index].FlyMovieIndexer.Name + " " + tloc.X + " " + tloc.Y); } else { InsertCommand("monster " + t + " hit"); InsertCommand("?var op_type = item movie play " + pc.Bag[item_index].FlyMovieIndexer.Name + " " + floc.X + " " + floc.Y + " " + tloc.X + " " + tloc.Y + " " + bt); } InsertCommand("delay " + bt); InsertCommand("?var op_type = item movie play " + pc.Bag[item_index].HitMovieIndexer.Name + " " + tloc.X + " " + tloc.Y); } } #endregion #region monster else if (kw[0] == "monster") { getValueByName(ref kw[1]); int i = int.Parse(kw[1]); Monster mon = game.Monsters[i]; if (kw[2] == "weapon") { mon.BattleState = BattleState.Weapon; MetalX.File.MetalXMovie mov = game.LoadDotMXMovie(game.MovieFiles[mon.BattleMovieIndexer.Name].FullName); mon.SetBattleMovie(mov); } else if (kw[2] == "item") { mon.BattleState = BattleState.Item; MetalX.File.MetalXMovie mov = game.LoadDotMXMovie(game.MovieFiles[mon.BattleMovieIndexer.Name].FullName); mon.SetBattleMovie(mov); } else if (kw[2] == "fight") { getValueByName(ref kw[3]); int ti = int.Parse(kw[3]); PC pc = game.PCs[ti]; Microsoft.DirectX.Vector3 v3 = pc.BattleLocation; v3.X -= (mon.BattleSize.Width / 2 + pc.BattleSize.Width / 2); //v3.Y += pc.BattleSize.Height; //v3.Y -= mon.BattleSize.Height; mon.BattleState = BattleState.Fight; MetalX.File.MetalXMovie mov = game.LoadDotMXMovie(game.MovieFiles[mon.BattleMovieIndexer.Name].FullName); mon.SetBattleMovie(mov, mon.BattleLocation, v3, 1); try { game.PlayMP3Audio(2, game.AudioFiles[mov.BGSound.Name].FullName); } catch { } } else if (kw[2] == "run") { mon.BattleState = BattleState.Run; MetalX.File.MetalXMovie mov = game.LoadDotMXMovie(game.MovieFiles[mon.BattleMovieIndexer.Name].FullName); mon.SetBattleMovie(mov); } else if (kw[2] == "miss") { mon.BattleState = BattleState.Miss; MetalX.File.MetalXMovie mov = game.LoadDotMXMovie(game.MovieFiles[mon.BattleMovieIndexer.Name].FullName); mon.SetBattleMovie(mov); } else if (kw[2] == "block") { mon.BattleState = BattleState.Block; MetalX.File.MetalXMovie mov = game.LoadDotMXMovie(game.MovieFiles[mon.BattleMovieIndexer.Name].FullName); mon.SetBattleMovie(mov); } else if (kw[2] == "hit") { mon.BattleState = BattleState.Hit; MetalX.File.MetalXMovie mov = game.LoadDotMXMovie(game.MovieFiles[mon.BattleMovieIndexer.Name].FullName); mon.SetBattleMovie(mov); } else if (kw[2] == "stand") { mon.BattleState = BattleState.Stand; MetalX.File.MetalXMovie mov = game.LoadDotMXMovie(game.MovieFiles[mon.BattleMovieIndexer.Name].FullName); mon.SetBattleMovie(mov); } else if (kw[2] == "bagadd") { Item item; int j = -1; try { j = int.Parse(kw[3]); item = game.Items[j].GetClone(); } catch { item = game.Items[kw[3]].GetClone(); } item.GUID = Guid.NewGuid(); mon.BagAdd(item); } else if (kw[2] == "standmovie") { int j = (int)BattleState.Stand; mon.BattleMovieIndexers[j].Name = kw[3]; } else if (kw[2] == "blockmovie") { int j = (int)BattleState.Block; mon.BattleMovieIndexers[j].Name = kw[3]; } else if (kw[2] == "hitmovie") { int j = (int)BattleState.Hit; mon.BattleMovieIndexers[j].Name = kw[3]; } else if (kw[2] == "fightmovie") { int j = (int)BattleState.Fight; mon.BattleMovieIndexers[j].Name = kw[3]; } else if (kw[2] == "weaponmovie") { int j = (int)BattleState.Weapon; mon.BattleMovieIndexers[j].Name = kw[3]; } else if (kw[2] == "itemmovie") { int j = (int)BattleState.Item; mon.BattleMovieIndexers[j].Name = kw[3]; } else if (kw[2] == "missmovie") { int j = (int)BattleState.Miss; mon.BattleMovieIndexers[j].Name = kw[3]; } else if (kw[2] == "runmovie") { int j = (int)BattleState.Run; mon.BattleMovieIndexers[j].Name = kw[3]; } else if (kw[2] == "+hp") { mon.HP += int.Parse(kw[3]); } else if (kw[2] == "-hp") { mon.HP -= int.Parse(kw[3]); if (mon.HP < 0) { mon.HP = 0; } } else if (kw[2] == "gethp") { SetVariable(kw[3], mon.HP.ToString()); } else if (kw[2] == "dead") { mon.HP = -1; //game.Monsters.RemoveAt(i); } } #endregion #region scn else if (kw[0] == "scn") { int range = -100; try { range = int.Parse(kw[3]); } catch { } if (kw[1] == "enter") { Microsoft.DirectX.Vector3 v3 = new Microsoft.DirectX.Vector3(); v3.X = float.Parse(kw[3]); v3.Y = float.Parse(kw[4]); game.SceneManager.Enter(kw[2], v3, game.ME.RealDirection); } else if (kw[1] == "shock" && range != -100) { double ms = double.Parse(kw[2]); game.SceneManager.ShockScreen(ms, range); } //else if (kw[1] == "delay") //{ // game.SceneManager.Delay(int.Parse(kw[2])); //} else if (kw[1] == "shock") { double ms = double.Parse(kw[2]); game.SceneManager.ShockScreen(ms); } else if (kw[1] == "fallout") { double ms = double.Parse(kw[2]); game.SceneManager.FallOutSceen(ms); } else if (kw[1] == "fallin") { double ms = double.Parse(kw[2]); game.SceneManager.FallInSceen(ms); } else if (kw[1] == "setctrl") { game.SceneManager.Controllable = true; } else if (kw[1] == "clrctrl") { //gsc_bak = game.SceneManager.Controllable; game.SceneManager.Controllable = false; } else if (kw[1] == "enableall") { game.SceneManager.EnableAll(); } else if (kw[1] == "disableall") { game.SceneManager.DisableAll(); } else if (kw[1] == "visible") { game.SceneManager.Visible = true; } else if (kw[1] == "invisible") { game.SceneManager.Visible = false; } else if (kw[1] == "enable") { game.SceneManager.Enable = true; } else if (kw[1] == "disable") { game.SceneManager.Enable = false; } //else if (kw[1] == "ctrl") //{ // game.SceneManager.Controllable = true; //} //else if (kw[1] == "ctrless") //{ // game.SceneManager.Controllable = false; //} } #endregion #region btl else if (kw[0] == "btl") { int range = -100; try { range = int.Parse(kw[3]); } catch { } if (kw[1] == "shock" && range != -100) { double ms = double.Parse(kw[2]); game.BattleManager.ShockScreen(ms, range); } else if (kw[1] == "shock") { double ms = double.Parse(kw[2]); game.BattleManager.ShockScreen(ms); } else if (kw[1] == "getout") { game.BattleManager.GetOut(); } else if (kw[1] == "pctop") { game.BattleManager.PCOnTop = true; } else if (kw[1] == "montop") { game.BattleManager.PCOnTop = false; } else if (kw[1] == "fallout") { double ms = double.Parse(kw[2]); game.BattleManager.FallOutSceen(ms); } else if (kw[1] == "fallin") { double ms = double.Parse(kw[2]); game.BattleManager.FallInSceen(ms); } else if (kw[1] == "enableall") { game.BattleManager.EnableAll(); } else if (kw[1] == "disableall") { game.BattleManager.DisableAll(); } } #endregion else if (kw[0] == "movie") { try { if (kw.Length >= 7) { if (kw[1] == "play") { double offsettime = 1; MetalX.File.MetalXMovie mov = game.LoadDotMXMovie(game.MovieFiles[kw[2]].FullName); int x = int.Parse(kw[3]); int y = int.Parse(kw[4]); int tx = int.Parse(kw[5]); int ty = int.Parse(kw[6]); try { offsettime = int.Parse(kw[7]); } catch { } Vector3 f = new Vector3(x, y, 0); Vector3 t = new Vector3(tx, ty, 0); game.MovieManager.PlayMovie(mov, f, t, offsettime); if (mov.BGSound.Name != null) if (mov.BGSound.Name != string.Empty) game.PlayMP3Audio(2, game.AudioFiles[mov.BGSound.Name].FullName); } } else { if (kw[1] == "play") { MetalX.File.MetalXMovie mov = game.LoadDotMXMovie(game.MovieFiles[kw[2]].FullName); int x = int.Parse(kw[3]); int y = int.Parse(kw[4]); Vector3 f = new Vector3(x, y, 0); game.MovieManager.PlayMovie(mov, f); if (mov.BGSound.Name != null) if (mov.BGSound.Name != string.Empty) game.PlayMP3Audio(2, game.AudioFiles[mov.BGSound.Name].FullName); } else if (kw[1] == "set") { int x = int.Parse(kw[3]); int y = int.Parse(kw[4]); Vector3 f = new Vector3(x, y, 0); game.MovieManager.PlayMovie(kw[2], f); } } } catch { } //else if (kw[1] == "bplay") //{ // int i = int.Parse(kw[2]); // int x = int.Parse(kw[4]); // int y = int.Parse(kw[5]); // Vector3 f = new Vector3(x, y, 0); // MetalX.File.MetalXMovie mov = game.LoadDotMXMovie(game.MovieFiles[kw[3]].FullName); // if (mov.BGSound != null) // { // inscommands.Enqueue("mp3 2 " + mov.BGSound.Name); // } // game.MovieManager.BattlePlayMovie(i, mov, f, f, 1); //} } #region gui else if (kw[0] == "gui") { if (kw[1] == "shock") { double ms = double.Parse(kw[2]); game.FormBoxManager.ShockScreen(ms); } else if (kw[1] == "focuson") { game.FormBoxManager.FocusOn(kw[2]); } else if (kw[1] == "fallout") { double ms = double.Parse(kw[2]); game.FormBoxManager.FallOutSceen(ms); } else if (kw[1] == "fallin") { double ms = double.Parse(kw[2]); game.FormBoxManager.FallInSceen(ms); } else if (kw[1] == "appear") { if (kw.Length == 5) { if (kw[3] == "arg") { if (kw[4] == "me") { game.FormBoxManager.Appear(kw[2], game.ME); } } else { int x = 0; int y = 0; try { x = int.Parse(kw[3]); y = int.Parse(kw[4]); game.FormBoxManager.Appear(kw[2], new Point(x, y)); } catch { } } } else { game.FormBoxManager.Appear(kw[2]); } } else if (kw[1] == "disappear") { if (kw[2] == "all") { game.FormBoxManager.DisappearAll(); } else { game.FormBoxManager.Disappear(kw[2]); } } } else if (kw[0] == "ask") { if (kw.Length == 1) { game.FormBoxManager.Disappear("ASKboolBox"); game.FormBoxManager.Disappear("ASKintBox"); } else { if (kw[2] == "bool") { game.FormBoxManager.Appear("ASKboolBox", kw[1]); } } } //else if (kw[0] == "check") //{ // if (kw[1] == "bool") // { // game.FormBoxManager.Appear("ASKboolBox", kw[2]); // } //} else if (kw[0] == "msg") { //if (kw[1].Contains("var.")) //{ // string name = kw[1].Substring(4); // kw[1].re = vars[name].ToString(); //} if (kw.Length == 1) { game.FormBoxManager.Disappear("MessageBox"); } else { getValueByName(ref kw[1]); string str = kw[1].Replace(@"n\", "\n"); game.FormBoxManager.Appear("MessageBox", str); } } #endregion else { //TextBox tb = new TextBox(game); //tb.Text = kw[0]; //game.FormBoxManager.Appear("MessageBox", tb); } }
public void RecalcPrimaryDependant(Canguro.View.GraphicView activeView, PointMagnet primaryPoint, LineMagnet[] globalAxes) { if (primaryPoint != null) { // Move area to lay on the primaryPoint and to set its direction any canonic // plane (X=x, Y=y or Z=z) which is the most paralell to the screen plane position = primaryPoint.Position; // Get screen plane normal Vector3 s0 = screenNormal[0], s1 = screenNormal[1], sNormal; activeView.Unproject(ref s0); activeView.Unproject(ref s1); sNormal = s0 - s1; // Assign the area normal to the most paralell canonical plane // (giving priority to the Z plane) int maxCosIndex = 2; float cosX, cosY, cosZ; cosX = Vector3.Dot(sNormal, globalAxes[0].Direction); cosY = Vector3.Dot(sNormal, globalAxes[1].Direction); cosZ = Vector3.Dot(sNormal, globalAxes[2].Direction); if (Math.Abs(cosZ) < minZPlaneAngle) maxCosIndex = (cosX >= cosY) ? ((cosX > cosZ) ? 0 : 2) : ((cosY > cosZ) ? 1 : 2); normal = globalAxes[maxCosIndex].Direction; } else { position = Vector3.Empty; normal = globalAxes[2].Direction; } }
public Vertex(DX.Vector3 position, DX.Vector2 texCoord, DX.Vector4 c) { this.position = position; this.texCoord = texCoord; this.normal = c; }
private void UpdateRadar(RadarData RadarData) { if (ResizingRadar) return; try { lock (this.lockdevice) { if (this.device != null && RadarData.Me != null) { this.focusObject = null; if (focusObjectOverrideGuid != null) { var focusObjectOverride = RadarData.GetWowObjectByGuid(focusObjectOverrideGuid.Value); if (focusObjectOverride != null) this.focusObject = focusObjectOverride; //else // focusObjectOverrideGuid = null; } if (this.focusObject == null) this.focusObject = RadarData.Me; var zoneId = ((WowPlayerMe)RadarData.Me).ZoneID; this.device.Clear(ClearFlags.Target, Color.Black, 1f, 0); float valueZ = 100000f; Microsoft.DirectX.Vector3 cameraPosition = new Microsoft.DirectX.Vector3(0f, 0f, valueZ); Microsoft.DirectX.Vector3 cameraTarget = new Microsoft.DirectX.Vector3(0f, 0f, 0f); Microsoft.DirectX.Vector3 cameraUpVector = new Microsoft.DirectX.Vector3(0f, -1f, 0f); Microsoft.DirectX.Matrix sourceMatrix = Microsoft.DirectX.Matrix.RotationY(Rotation) * Microsoft.DirectX.Matrix.RotationX(Rotation); if (this.settings.RotateMap) { sourceMatrix *= Microsoft.DirectX.Matrix.RotationZ(6.283185f - this.focusObject.Facing); } cameraPosition.TransformCoordinate(sourceMatrix); cameraTarget.TransformCoordinate(sourceMatrix); cameraUpVector.TransformCoordinate(sourceMatrix); cameraTarget.Add(new Microsoft.DirectX.Vector3(this.focusObject.X, this.focusObject.Y, this.focusObject.Z)); cameraPosition.Add(new Microsoft.DirectX.Vector3(this.focusObject.X, this.focusObject.Y, this.focusObject.Z)); this.device.Transform.View = Microsoft.DirectX.Matrix.LookAtLH(cameraPosition, cameraTarget, cameraUpVector); this.device.Transform.Projection = Microsoft.DirectX.Matrix.PerspectiveLH(((float)base.Width) / (valueZ * this.scale), ((float)base.Height) / (valueZ * this.scale), 1f, 1000000f); this.device.BeginScene(); if (this.showMapTexturesOverride && this.settings.ShowMinimap) { this.DrawMinimap(); } foreach (var WowObject in RadarData.Objects) { PresentWowObject(WowObject); } PresentWowObject(RadarData.Me); var ArchaeologyCacheList = BlackRain.Cache.ArchaeologyCache.ObjList.Where(t => t.ZoneID == zoneId); foreach (var WowGameObject in ArchaeologyCacheList) { PresentWowObject(WowGameObject); } this.device.EndScene(); this.device.Present(); ClearAlerts(RadarData); } } } catch (Exception exception) { Console.WriteLine(exception); this.InitializeDXDevice(); } }
public void OrientBody() { Vector3 v3InitDir = new Vector3(0,0,1); float fltAngle = (float)Math.Acos(Vector3.Dot(v3InitDir,Direction)); Vector3 v3Axis = Vector3.Cross(v3InitDir, Direction); m_mtxOrientation.RotateAxis(v3Axis,fltAngle); m_v3Rotation = Util_DX.DecomposeXYZRotationMatrix(m_mtxOrientation); this.Rotation = new Vec3d(null,Geometry.RadianToDegree(m_v3Rotation.X),Geometry.RadianToDegree(m_v3Rotation.Y),Geometry.RadianToDegree(m_v3Rotation.Z)); }
/// <summary> /// Test for intersection with the mesh /// </summary> /// <param name="device">The Direct3D device associated with the mesh</param> /// <param name="x">X coordinate of the mouse</param> /// <param name="y">Y coordinate of the mouse</param> /// <param name="cmCommand">Which mode we are in: SelectBodies, SelectJoints, or AddBodies</param> /// <param name="colSelected">A collection of meshes that intersected with the ray from the mouse</param> public override void TestIntersection(int x, int y, AnimatTools.Forms.BodyPlan.Command.enumCommandMode cmCommand, ref System.Collections.ArrayList colSelected) { //If we're not in the right mode the skip this computation if(m_d3dMesh != null && cmCommand != AnimatTools.Forms.BodyPlan.Command.enumCommandMode.SelectJoints) { //matrix transormation of the world Matrix mWorld = CombinedTransformationMatrix * Device.Transform.World1; //a temporary intersect information for the selected bounding box IntersectInformation iiTmp = new IntersectInformation(); //shoot the ray and test for intersection if(Util_DX.TestIntersectWithMouse(m_d3dMesh,Device.Viewport, Device.Transform.Projection, Device.Transform.View, mWorld, x, y, out this.m_iiIntersectInfo)) { //if there was a sucessfull intersection then add this mesh to the selected collection colSelected.Add(this); //Vertices that represent the intersected face Vector3[] vertsFace = Util_DX.FindIntersectionFace(m_d3dMesh, m_iiIntersectInfo); //the normal of the selected face this.m_v3FaceNormal = Util_DX.CalculateNormal(vertsFace); //m_v3SelectedFacePoint = this.RayIntersectWithPlane(new Vector3(),FaceNormal,vertsFace); m_v3SelectedFacePoint = Util_DX.FindIntersectionPoint(this.Mesh,this.IntersectInfo); //Vector3 v = m_v3SelectedFacePoint - m_v3Location; //Debug.WriteLine("Relative Point: (" + v.X + ", " + v.Y + ", " + v.Z + ")"); } else if((this.m_mshSelectedBoundingBox != null && this.m_bSelected && Util_DX.TestIntersectWithMouse(m_mshSelectedBoundingBox,Device.Viewport, Device.Transform.Projection, Device.Transform.View, mWorld, x, y, out iiTmp))) { colSelected.Add(this); } // else // m_bSelected = false; } base.TestIntersection (x, y, cmCommand, ref colSelected); }
protected static void AddVertex(string strLine, ArrayList aryVertices) { string delimStr = " "; char [] delimiter = delimStr.ToCharArray(); string[] aryParts = strLine.Split(delimiter); if(aryParts.Length != 4) throw new System.Exception("invalid vertex node found in .obj file."); else { float fltX = float.Parse(aryParts[1]); float fltY = float.Parse(aryParts[2]); float fltZ = float.Parse(aryParts[3]); Microsoft.DirectX.Vector3 vVertice = new Microsoft.DirectX.Vector3(fltX, fltY, fltZ); aryVertices.Add(vVertice); } }
protected void DoMouseRotation(AnimatTools.Framework.MouseEventArgs AnimatMouseArgs) { if(AnimatMouseArgs.XKey) { float fX = (AnimatMouseArgs.DeltaX * AnimatMouseArgs.Scale) + (AnimatMouseArgs.DeltaY * -AnimatMouseArgs.Scale); m_mtxOrientation.Multiply(Matrix.RotationX(fX)); m_v3Rotation = Util_DX.DecomposeXYZRotationMatrix(m_mtxOrientation); } else if(AnimatMouseArgs.YKey) { float fY = (AnimatMouseArgs.DeltaX * AnimatMouseArgs.Scale) + (AnimatMouseArgs.DeltaY * -AnimatMouseArgs.Scale); m_mtxOrientation.Multiply(Matrix.RotationY(fY)); m_v3Rotation = Util_DX.DecomposeXYZRotationMatrix(m_mtxOrientation); } else if(AnimatMouseArgs.ZKey) { float fZ = (AnimatMouseArgs.DeltaX * AnimatMouseArgs.Scale) + (AnimatMouseArgs.DeltaY * -AnimatMouseArgs.Scale); m_mtxOrientation.Multiply(Matrix.RotationZ(fZ)); m_v3Rotation = Util_DX.DecomposeXYZRotationMatrix(m_mtxOrientation); } else if(AnimatMouseArgs.SKey) { float fX = (AnimatMouseArgs.DeltaX * -AnimatMouseArgs.Scale * 2); float fZ = (AnimatMouseArgs.DeltaY * -AnimatMouseArgs.Scale * 2); m_mtxOrientation.Multiply(Matrix.RotationY(fZ)* Matrix.RotationZ(fX)); m_v3Rotation = Util_DX.DecomposeXYZRotationMatrix(m_mtxOrientation); } else { float fX = (AnimatMouseArgs.DeltaX * -AnimatMouseArgs.Scale * 2); float fY = (AnimatMouseArgs.DeltaY * -AnimatMouseArgs.Scale * 2); m_mtxOrientation.Multiply(Matrix.RotationX(fY) * Matrix.RotationY(fX)); m_v3Rotation = Util_DX.DecomposeXYZRotationMatrix(m_mtxOrientation); } }
protected static void AddTexCoord(string strLine, ArrayList aryTextures) { string delimStr = " "; char [] delimiter = delimStr.ToCharArray(); string[] aryParts = strLine.Split(delimiter); if(aryParts.Length != 4 && aryParts.Length != 3) throw new System.Exception("invalid texture node found in .obj file."); else { float fltX = float.Parse(aryParts[1]); float fltY = float.Parse(aryParts[2]); Microsoft.DirectX.Vector3 vTexture = new Microsoft.DirectX.Vector3(fltX, fltY, 0); aryTextures.Add(vTexture); } }
/// <summary> /// Forces display of lable if we are hooked /// </summary> /// <param name="drawArgs"></param> /// <param name="sprite"></param> /// <param name="projectedPoint"></param> /// <param name="color"></param> /// <param name="labelRectangles"></param> /// <param name="isMouseOver"></param> protected override void RenderLabel(DrawArgs drawArgs, Microsoft.DirectX.Direct3D.Sprite sprite, Microsoft.DirectX.Vector3 projectedPoint, int color, System.Collections.Generic.List <System.Drawing.Rectangle> labelRectangles, bool isMouseOver) { base.RenderLabel(drawArgs, sprite, projectedPoint, color, labelRectangles, (isMouseOver || IsHooked)); }
public virtual void Play(SoundVector pos, bool loop, int volume) { }