Jump to content
Xtreme .Net Talk

SleepingTroll

Members
  • Posts

    12
  • Joined

  • Last visited

About SleepingTroll

  • Birthday 10/13/1955

SleepingTroll's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. I had assumed that a Vector3 type used double values... bad assumption!
  2. Thx, buffer was not enabled (I'm a DX nube)
  3. Velocity[a] is a Vector3 type (all doubles), Proximity is a double as is Influence. The highlighted code produces a cannot convert double to float error... I have tried (double)0 and that did not solve the problem. Any ideas? Velocity[a] = (new Vector3( [color="Red"]Proximity.X != 0[/color] ? Velocity[a].X + (1/(Influence * Proximity.X)) : Velocity[a].X, [color="Red"]Proximity.Y != 0[/color] ? Velocity[a].Y + (1/(Influence * Proximity.Y)) : Velocity[a].Y, [color="Red"]Proximity.Z != 0[/color] ? Velocity[a].Z + (1/(Influence * Proximity.Z)) : Velocity[a].Z ));
  4. Does DX not have the intelligence to render an object while masking by proximity to the camera?
  5. Yep, brain fart... I had created no values for the last member...
  6. Maybe it is just a brain fart, however the highlighted line of my code produces and index out of range error... can anyone spot the problem? public void AddParticle() { Array.Resize(ref Particlestemp, Particlestemp.Length); Array.Copy(Particles, Particlestemp, Particles.Length); Array.Resize(ref Particles, Particles.Length); Array.Copy(Particlestemp, Particles, Particles.Length); Array.Resize(ref ParticleMeshtemp, ParticleMesh.Length); Array.Copy(ParticleMesh, ParticleMeshtemp,ParticleMesh.Length); Array.Resize(ref ParticleMesh, ParticleMesh.Length); [color="Red"]ParticleMesh[ParticleMesh.Length-1] = Mesh.Sphere(device, 4, 64, 64 );[/color] ParticleMaterial[Particles.Length-1].Ambient = Color.Green; ParticleMaterial[Particles.Length-1].Diffuse = Color.Green; ParticleMaterial[Particles.Length-1].Specular = Color.Green; ParticleMaterial[Particles.Length-1].SpecularSharpness = 100; VelocityX.Add(1); VelocityY.Add(1); VelocityZ.Add(1); PositionX.Add(1); PositionY.Add(1); PositionZ.Add(1); }
  7. I have managed to fumble my way to some degree of success with DirectX... only real problem I have now is that my render meshes take on the aspect ratio of the windows form object... ? using System; using System.Windows.Forms; using System.Collections.Generic; using System.Timers; using System.Drawing; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; namespace Model { /// <summary> /// Description of MainForm. /// </summary> public partial class MainForm : Form { private Device device = null; private Mesh NeutronMesh; private Material NMaterial; private float NMass = (float)1.67495438; private float NRad = (float)1.11328405736; private Mesh ProtonMesh; private Material PMaterial; private float PMass = (float)1.67264858; private float PRad = (float)1.11277296101; private Mesh ElectronMesh; private Material EMaterial; private float EMass = (float).00091095344; private float ERad = (float).0908734583548; public MainForm() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); InitializeDevice(); } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { this.Render(); this.Invalidate(); } protected override void Dispose(bool disposing) { base.Dispose( disposing ); } private void InitializeDevice() { Caps caps = Manager.GetDeviceCaps( Manager.Adapters.Default.Adapter, DeviceType.Hardware ); CreateFlags flags; if( caps.DeviceCaps.SupportsHardwareTransformAndLight ) flags = CreateFlags.HardwareVertexProcessing; else flags = CreateFlags.SoftwareVertexProcessing; PresentParameters pp = new PresentParameters(); pp.BackBufferFormat = Format.Unknown; pp.SwapEffect = SwapEffect.Discard; pp.Windowed = true; pp.EnableAutoDepthStencil = true; pp.AutoDepthStencilFormat = DepthFormat.D16; pp.PresentationInterval = PresentInterval.Default; device = new Device( 0, DeviceType.Hardware, this, flags, pp ); device.VertexFormat = CustomVertex.PositionNormalColored.Format; device.DeviceReset += new System.EventHandler( this.OnResetDevice ); OnResetDevice( device, null ); } public void OnResetDevice(object sender, EventArgs e) { Device device = (Device)sender; device.Transform.Projection = Matrix.PerspectiveFovLH( Geometry.DegreeToRadian( 45.0f ), (float)this.ClientSize.Width / this.ClientSize.Height, 0.1f, 100.0f ); device.RenderState.Lighting = true; device.RenderState.Ambient = Color.White; device.Lights[0].Type = LightType.Directional; device.Lights[0].Diffuse = Color.White; device.Lights[0].Direction = new Vector3(1, -1, 1); device.Lights[0].Enabled = true; device.RenderState.CullMode = Cull.None; device.RenderState.FillMode = FillMode.Solid; NeutronMesh = Mesh.Sphere( device, NRad, 64, 64 ); NMaterial = new Material(); NMaterial.Ambient = Color.Green; NMaterial.Diffuse = Color.Green; NMaterial.Specular = Color.Green; NMaterial.SpecularSharpness = 100; ProtonMesh = Mesh.Sphere( device, PRad, 64, 64 ); PMaterial = new Material(); PMaterial.Ambient = Color.DarkRed; PMaterial.Diffuse = Color.DarkRed; PMaterial.Specular = Color.DarkRed; PMaterial.SpecularSharpness = 100; ElectronMesh = Mesh.Sphere( device, ERad, 64, 64 ); EMaterial = new Material(); EMaterial.Ambient = Color.White; EMaterial.Diffuse = Color.White; EMaterial.Specular = Color.White; EMaterial.SpecularSharpness = 100; } private void SetupMatrices() { device.Transform.World = Matrix.Identity; device.Transform.View = Matrix.LookAtLH(new Vector3(0, 0, -30), new Vector3(0, 0, 0), new Vector3(0, 1, 0)); device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, 1, 1, 100); } private void Render() { SetupMatrices(); device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.DimGray, 1, 0 ); device.BeginScene(); device.Transform.World = Matrix.Translation(0, 0, 0); device.Material = NMaterial; NeutronMesh.DrawSubset(0); device.Transform.World = Matrix.Translation(5,5,-10); device.Material = PMaterial; ProtonMesh.DrawSubset(0); device.Transform.World = Matrix.Translation(7,7,7); device.Material = EMaterial; ElectronMesh.DrawSubset(0); device.EndScene(); device.SetStreamSource(0, NeutronMesh.VertexBuffer, 0); device.VertexFormat = CustomVertex.PositionColored.Format; device.Present(); } } }
  8. I found my solution! app.cfg needs to read like this... <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup>
  9. When I add a reference, how can I be sure I am referencing the correct version of DirectX? I first installed DirectX 11 SDK... I did a system restore, however when I ran my IDE and added references, DirectX was still there when I should have had no SDK installed.
  10. I do have more info, although it is not encouraging... It would seem that the compiler is having a problem with the DirectX framework, when it references it, it goes into limbo! I am redownloading the framework, somehow though... I don't expect that this is a solution, any ideas greatly appreciated! AHA! When searching for the DirectX download I was directed(no pun intended) to DirectX 11! Downloading Version 9 now... I can't imagine all the trouble this is going to cause for nubes like myself...
  11. (sorry about the repost, just realized the original was in the wrong place) I create a form and it displays fine, however as soon as I create my directX device the form stops displaying! Here is my code, please note that I can eliminate all of the DirectX code and the form displays, however just the line 'private Device device = null;' will prevent my form from displaying. using System; using System.Drawing; using System.Windows.Forms; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; namespace Model { public partial class MainForm : Form { private Device device = null; public MainForm() { InitializeComponent(); InitializeDevice(); } private void InitializeDevice() { PresentParameters pp = new PresentParameters(); pp.Windowed = true; pp.SwapEffect = SwapEffect.Discard; device = new Device(0, DeviceType.Reference, this, CreateFlags.SoftwareVertexProcessing, pp); } protected override void OnPaint(PaintEventArgs e) { device.Clear(ClearFlags.Target, Color.CornflowerBlue, 0, 1); device.Present(); } } } I am new at directX and will likely stay that way if I can't get by this!
  12. Just a guess, since I am new at DirectX (see my post)... But I suspect your Gamma is off?
×
×
  • Create New...