Jump to content
  • Advertisement

Gerhard Mostert

  • Content Count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About Gerhard Mostert

  • Rank
  1. Gerhard Mostert

    [XNA /C# ] Where to start

    Let us know what you decided to do and how far you are getting, this looks like a very cool project.
  2. Gerhard Mostert

    [XNA /C# ] Where to start

    Howzit, since you are not realy a programmer it will probably not be as trivial as doing it in 4 days! Give yourself some weeks I would say (maybe even months). I would say that the easiest prog. lang. to start with would be C#. Try going for a book that would teach you game programming in C# like, "Beginning C# game programming" by Penton. It teaches a bit of C# before going on to Managed DirectX which would be the fastest and easiest to program! If you finished with that book, go on to "Managed DirectX9 Kick Start" by Tom Miller. Therefore, I would suggest C#. I think it would be the easiest and quickest! If you worked through those two books, I think you would be set. C# is very easy to understand as well! Can't help about the french, sorry! :P
  3. Gerhard Mostert

    which C# book should I buy?

    Another great book you can look at, if you have finished learning C#, is "Managed DirectX9 Kick Start" by Tom Miller. It will take you step-by-step through game programming using C#. It is also an advantage that the author is the creator of Managed DirectX. It helped me a great deal in programming games in C#!
  4. Gerhard Mostert

    DirectX Camera rotation

    Are you using Native or Managed DirectX?
  5. Are you using DirectX 9c ? or What?
  6. First thing first, (1) You create your mesh in some 3D modelling package. I use 3Ds Max. (2) You export your mesh to a .X file, using a package like PandaSoft's .X exporter. Read the first Thread in this forum! (3) Import your .x file using D3DXLoadMeshFromFile (native) or LoadMeshFromFile (managed). Not that trivial though, look how they do it in the Directx Samples, Loading a mesh. Hope this helps, if this was completely useless, sorry!
  7. Gerhard Mostert

    Applying 3Ds Max 9 FX file to a DirectX 9 mesh

    So by the way, I am using C# and MDX for this specific example.
  8. Gerhard Mostert

    DirectX and C#

    Cool thanks. Thank explains it.
  9. Gerhard Mostert

    DirectX and C#

    So would you say that D3D10 is more managed than D3D9?
  10. Gerhard Mostert

    DirectX and C#

    So would you say that XNA and it's capabilities would be limited to what the Xbox has to offer or not (in the sense of it's hardware capabilities and device? Can you look at XNA as just a managed DirectX10? Will it be able to do the same things as DX10, but with lesser performance?
  11. Howzit ankhd, Looks like the big guns don't want to help you, but I will see what I can do. If you could maybe just give a clearer discription of what you did and are trying to do, I could try to help. I have started to export .x files with PandaExporter for 3Ds Max 9 and it did export the mesh and the texture coordinates etc. so that I could Load it into my DirectX app and it worked. I have trouble with the .fx files, loading and using them.
  12. Gerhard Mostert

    Applying 3Ds Max 9 FX file to a DirectX 9 mesh

    I exported a FX file from 3DSMAX 9 that is a normal diffuse color effect(just to test if the .fx file works, I did not try to do anything fancy), I got 2 files .fx, .hlsl. I tried to render the box, but it's seem to be black. How could I use these effect files in Managed DirectX for C#? This is my .fx file float4x4 mWorld_0_0 : WORLDT; float4x4 mIWorld_0_0 : WORLDI; float4x4 mWorldViewProj_0_0 : WORLDVIEWPROJECTION; float4 mCamPos_0_0 : WORLD_CAMERA_POSITION = {0.000000f, 0.000000f, 0.000000f, 0.000000f}; float Opacity_1_0 : OPACITY < string UIName = "Opacity"; float UIMin = 0.0; float UIMax = 1.0; float UIStep = 0.01; > = 1.000000f; float SpecularLevel_1_0 : SPECULARLEVEL < string UIName = "SpecularLevel"; float UIMin = 0.0; float UIMax = 1.0; float UIStep = 0.01; > = 0.000000f; float GlossLevel_1_0 : GLOSSLEVEL < string UIName = "GlossLevel"; float UIMin = 0.0; float UIMax = 100.0; float UIStep = 1.0; > = 10.000000f; float4 LightDir0_1_0 : DIRECTION < string Object = "TargetLight"; string UIName = "LightDir0"; int refID = 0; > = {0.000000f, 0.000000f, 0.000000f, 0.000000f}; float4 LightCol0_1_0 : LIGHTCOLOR < int LightRef = 0; > = {0.000000f, 0.000000f, 0.000000f, 0.000000f}; float4 Emissive_1_0 : EMISSIVE < string UIName = "Emissive"; > = {0.000000f, 0.000000f, 0.000000f, 1.000000f}; float4 Specular_1_0 : SPECULAR < string UIName = "Specular"; > = {0.900000f, 0.900000f, 0.900000f, 1.000000f}; float4 Diffuse_1_0 : DIFFUSE < string UIName = "Diffuse"; > = {1.000000f, 0.000000f, 0.000000f, 1.000000f}; VertexShader VS_pass0 = asm { vs_2_0 // Generated by ATI's Ashli Compiler on 2007-03-15 13:55:56. // Ashli Version: 1.7.9 // Instructions (Alu): 18 // Registers (Temp): 3 // Registers (Constant): 14 // Registers (Output): 1 // Registers (OutputTexCoord): 2 dcl_position0 v0 dcl_normal0 v2 def c5, 0, 0, 0, 0 mul r0, c13, v0.r mad r0, c12, v0.g, r0 mad r0, c11, v0.b, r0 mad r0, c10, v0.a, r0 mov r1, c5.r dp4 r1.r, c9, v2 dp4 r1.g, c8, v2 dp4 r1.b, c7, v2 dp4 r1.a, c6, v2 mov r2, c5.r dp4 r2.r, c4, v0 dp4 r2.g, c3, v0 dp4 r2.b, c2, v0 dp4 r2.a, c1, v0 add r2, c0, -r2 mov oPos, r0 mov oT0, r1 mov oT2, r2 }; PixelShader PS_pass0 = asm { ps_2_0 // Generated by ATI's Ashli Compiler on 2007-03-15 13:55:56. // Ashli Version: 1.7.9 // Instructions (Alu): 38 // Registers (Temp): 6 // Registers (Constant): 10 // Registers (TexCoord): 2 // Registers (OutputColor): 1 dcl t0.rgba dcl t2.rgba def c0, 0, 1, 0, 0 def c9, 0, 0, 0, 1 mov r0, c0.r mov r0.rgb, t2 mov r0.a, t2.b dp3 r1.r, r0, r0 rsq r1.r, r1.r mov r2, c0.r mul r2.rgb, r1.r, r0 dp3 r0.r, r2, r2 rsq r0.r, r0.r mul r0, r0.r, r2 mov r1, c0.r mov r1.rgb, t0 mov r1.a, t0.b dp3 r2.r, r1, r1 rsq r2.r, r2.r mul r1, r2.r, r1 dp3 r0.r, r1, r0 max r0.r, r0.r, c0.r min r0.r, r0.r, c0.g pow r0.r, r0.r, c3.r mul r0.r, r0.r, c2.r mul r0, c7, r0.r dp3 r1.r, r1, c4 max r1.r, r1.r, c0.r min r1.r, r1.r, c0.g mul r1, c8, r1.r mov r2, c0.r mov r2.rgb, c5 mov r2.a, c0.g mov r4, c6 mov r5, c8 mad r3, r4, r5, c9 mad r1, r2, r1, r3 mad r0, r2, r0, r1 mov r0.a, c1.r mov oC0, r0 }; technique technique0 { pass { VertexShaderConstant[0] = <mCamPos_0_0>; VertexShaderConstant[1] = <mWorld_0_0[3]>; VertexShaderConstant[2] = <mWorld_0_0[2]>; VertexShaderConstant[3] = <mWorld_0_0[1]>; VertexShaderConstant[4] = <mWorld_0_0[0]>; VertexShaderConstant[6] = <mIWorld_0_0[3]>; VertexShaderConstant[7] = <mIWorld_0_0[2]>; VertexShaderConstant[8] = <mIWorld_0_0[1]>; VertexShaderConstant[9] = <mIWorld_0_0[0]>; VertexShaderConstant[10] = <mWorldViewProj_0_0[3]>; VertexShaderConstant[11] = <mWorldViewProj_0_0[2]>; VertexShaderConstant[12] = <mWorldViewProj_0_0[1]>; VertexShaderConstant[13] = <mWorldViewProj_0_0[0]>; PixelShaderConstant[1] = <Opacity_1_0>; PixelShaderConstant[2] = <SpecularLevel_1_0>; PixelShaderConstant[3] = <GlossLevel_1_0>; PixelShaderConstant[4] = <LightDir0_1_0>; PixelShaderConstant[5] = <LightCol0_1_0>; PixelShaderConstant[6] = <Emissive_1_0>; PixelShaderConstant[7] = <Specular_1_0>; PixelShaderConstant[8] = <Diffuse_1_0>; VertexShader = <VS_pass0>; PixelShader = <PS_pass0>; } } bool UseLPRT = false; This is the HLSL file that was created, I do not know how to use this file either, since Tom Miller's book only uses .fx files (ironically, this file looks more like the .fx files that I learned about than the .fx that was created). struct PixelInput { float4 norm : TEXCOORD0; float4 worldpos : TEXCOORD1; float4 eyevector : TEXCOORD2; float4 tangent : TEXCOORD3; float4 binormal : TEXCOORD4; float4 objpos : TEXCOORD5; float4 tex0 : TEXCOORD6; float4 tex1 : TEXCOORD7; }; struct PixelOutput { float4 c : COLOR; }; uniform float4 Diffuse = float4(1.000000,0.000000,0.000000,1.000000); uniform float4 Specular = float4(0.900000,0.900000,0.900000,1.000000); uniform float4 Emissive = float4(0.000000,0.000000,0.000000,1.0f); uniform float SpecularLevel = 0.000000; uniform float GlossLevel = 9.999999; uniform float3 LightCol0; uniform float3 LightDir0; uniform float LightFallOff0; uniform float LightHotSpot0; uniform float Opacity = 1.000000; PixelOutput fragmentEntry(PixelInput pi) { PixelOutput PO; float3 N; N = normalize(pi.norm.xyz); float3 Eye; Eye.xyz = normalize(pi.eyevector.xyz); float4 nColor = float4(0.0,0.0,0.0,1.0); float4 mDiffuse = Diffuse; float4 mSpecular = Specular; float4 SelfIllum = Emissive; nColor = nColor + SelfIllum * mDiffuse; float3 H; float3 Light; float f; float fAtt; float fDist; /* default light */ fAtt = 1.0; nColor = nColor + float4(LightCol0,1.0) * mDiffuse * clamp(dot(N,LightDir0),0,1) * fAtt; H = normalize(Eye+Light); f = clamp(dot(N,H),0,1); f = pow(f, GlossLevel); f = f * SpecularLevel; nColor = nColor + float4(LightCol0,1.0) * mSpecular * f * fAtt; /* end of default light */ nColor.a = Opacity; PO.c = nColor; return PO; } This is my Framework class for setting up the HLSL and effects using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; namespace HLSL_Framework { public partial class HLSLFramework : Form { private Device device = null; private Effect effect = null; // Matrices private Matrix worldMatrix; private Matrix viewMatrix; private Matrix projMatrix; private MeshObject mesh; /// <summary> /// 1) Called once and sets presentation parameters and create device /// 2) Pass a call to OnDeviceReset /// </summary> public bool InitializeGraphics() { PresentParameters presentParams = new PresentParameters(); presentParams.Windowed = true; presentParams.SwapEffect = SwapEffect.Discard; presentParams.AutoDepthStencilFormat = DepthFormat.D16; presentParams.EnableAutoDepthStencil = true; bool canDoShaders = true; // Does a hardware device support shaders? Caps hardware = Manager.GetDeviceCaps(0, DeviceType.Hardware); if (hardware.VertexShaderVersion >= new Version(2, 0)) { // Default to software processing CreateFlags flags = CreateFlags.SoftwareVertexProcessing; // Use hardware if it's available if (hardware.DeviceCaps.SupportsHardwareTransformAndLight) flags = CreateFlags.HardwareVertexProcessing; // Use pure if it's available if (hardware.DeviceCaps.SupportsPureDevice) flags |= CreateFlags.PureDevice; // Yes, Create our device device = new Device(0, DeviceType.Hardware, this, flags, presentParams); } else { // No shader support canDoShaders = false; // Create a reference device device = new Device(0, DeviceType.Reference, this, CreateFlags.SoftwareVertexProcessing, presentParams); } //Load .fx file here ex: effect = Effect.FromFile(device, "..\\..\\boilerDiffuseRed.fx", null, ShaderFlags.None, null); //Set effect.Technique here ex: effect.Technique = "technique0"; device.DeviceReset += new EventHandler(OnDeviceReset); OnDeviceReset(device, null); return canDoShaders; } /// <summary> /// Called on each device reset event, this includes instantiation of the device /// 1) Sets up Camera position /// 2) Sets Cull mode to Counter clockwise /// 3) Load Meshes /// 4) Sets up lights /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnDeviceReset(object sender, EventArgs e) { Device dev = (Device)sender; SetupCamera(); //Load Mesh here ex: mesh = new MeshObject(@"..\..\boilerpipe.x", device); } /// <summary> /// Called on every frame /// 1) Clear device /// 2) Start rendering /// 3) Draw Meshes /// </summary> /// <param name="e"></param> protected override void OnPaint(PaintEventArgs e) { device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.CornflowerBlue, 1.0f, 0); device.BeginScene(); //Do World transformation here "TransformWorld(,,,,,,);" TransformWorld(0, 0, 0, 0, 0, 0); //& Draw the mesh mesh.DrawMesh(device, ref effect); device.EndScene(); device.Present(); this.Invalidate(); } // Sets up Projection and Viwe Transformation. // Called from OnDeviceReset() private void SetupCamera() { //Setup Projection Frustum projMatrix = Matrix.PerspectiveFovLH((float)Math.PI / 4, this.Width / this.Height, 1.0f, 10000.0f); //Setup View Point viewMatrix = Matrix.LookAtLH(new Vector3(0,0,580.0f), new Vector3(), new Vector3(0,1,0)); } //Transform the object's position, rotation and scaling private void TransformWorld(float x, float y, float z, float yaw, float pitch, float roll, float sx, float sy, float sz) { Matrix worldViewProj; //Rotation & Translation worldMatrix = Matrix.RotationYawPitchRoll(yaw, pitch, roll) * Matrix.Translation(x, y, z) * Matrix.Scaling(sx, sy, sz); worldViewProj = worldMatrix * viewMatrix * projMatrix; effect.SetValue("mWorldViewProj_0_0", worldViewProj); } //Transform the object's position and rotation private void TransformWorld(float x, float y, float z, float yaw, float pitch, float roll) { Matrix worldViewProj; //Rotation & Translation worldMatrix = Matrix.RotationYawPitchRoll(yaw, pitch, roll) * Matrix.Translation(x, y, z); worldViewProj = worldMatrix * viewMatrix * projMatrix; effect.SetValue("mWorldViewProj_0_0", worldViewProj); } public HLSLFramework() { InitializeComponent(); this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); } } } This is just a class that I use as a mesh container tipe of class, setting up the mesh, loading and drawing it. using System; using System.Collections.Generic; using System.Text; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; namespace HLSL_Framework { class MeshObject { private Mesh ObjectMesh = null; private Material[] ObjectMeshMaterials = null; private Texture[] ObjectMeshTextures = null; /// <summary> /// Loads mesh from file and laods mesh materials and textures /// </summary> /// <param name="file"></param> /// <returns></returns> public MeshObject(String file, Device device) { ExtendedMaterial[] mtrl; ObjectMesh = Mesh.FromFile(file, MeshFlags.Managed, device, out mtrl); if ((mtrl != null) && (mtrl.Length > 0)) { ObjectMeshMaterials = new Material[mtrl.Length]; ObjectMeshTextures = new Texture[mtrl.Length]; for (int i = 0; i < mtrl.Length; i++) { ObjectMeshMaterials = mtrl.Material3D; if ((mtrl.TextureFilename != null) && (mtrl.TextureFilename != string.Empty)) { ObjectMeshTextures = TextureLoader.FromFile(device, @"..\..\" + mtrl.TextureFilename); } } } } /// <summary> /// Receives a Mesh object retrieved from LoadMesh and draw this object /// </summary> /// <param name="objectMesh"></param> public void DrawMesh(Device device, ref Effect fx ) { int numPasses = fx.Begin(0); for (int iPass = 0; iPass < numPasses; iPass++) { fx.BeginPass(iPass); //Draw for (int i = 0; i < ObjectMeshMaterials.Length; i++) { device.SetTexture(0, ObjectMeshTextures); ObjectMesh.DrawSubset(i); } fx.EndPass(); } fx.End(); } } }
  13. How does one apply a .fx file that was created in 3Ds Max 9 to a mesh that was created in DirectX 9c. I know the basics of HLSL but can not seem to get this right. All I get is a mesh that is black. I worked through the Chapters of HLSL in Tom Miller's Managed DirectX 9 and I am now trying to use the .fx file that was created in 3Ds max9 instead of simple.fx that miller used, but now Ii only get a black Tiny instead.
  14. Gerhard Mostert

    Help on D3DXLoadMeshHierarchyFromX, please

    In the DirectX Sample Browser(October 2005) I searched for SimpleAnimation, but did not find anything? I even browsed through it manually. There is only a MultipleAnimation sample and a SkinnedMesh, which could have relevance.Could it maybe be in a newer version?
  15. Gerhard Mostert

    Help on D3DXLoadMeshHierarchyFromX, please

    Quote:AnimationFrame AF= Frame.Find(SceneRootFrame , "Car"); Is AnimationFrame a DirectX SDK class or is it one that you make yourself? Cause I can't seem to find it in the DirectX 9 Ref Manual.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!