• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

145 Neutral

About UsingBytes

  • Rank
  1. Hello everyone, Just wanted to post some code regarding gathering only the position and normal data from an .X file becuase this is a question I had here, but figured out how to do this. I originally thought I was going to need to write my own .X parser specificaly for this job, but turns out its not needed. I'm using C# with MDX 1.1 So I basically load up an .X file as a mesh object and then gather the data I need from that mesh object. I still need to refactor the code a little bit, but it does what i need it to. // Get the base mesh position & normal information private CustomVertex.PositionNormal[] meshVertices; // Position holder private float[] x; private float[] y; private float[] z; // Normals holder private float[] nx; private float[] ny; private float[] nz; private void CopyData() { int[] numberVertices = new int[1]; numberVertices[0] = mesh.NumberVertices; Array getPoints; CustomVertex.PositionNormal pointMover = new CustomVertex.PositionNormal(); meshVertices = new CustomVertex.PositionNormal[mesh.NumberVertices]; x = new float[mesh.NumberVertices]; y = new float[mesh.NumberVertices]; z = new float[mesh.NumberVertices]; nx = new float[mesh.NumberVertices]; ny = new float[mesh.NumberVertices]; nz = new float[mesh.NumberVertices]; getPoints = mesh.LockVertexBuffer(pointMover.GetType(), LockFlags.None, numberVertices); for (int i = 0; i < mesh.NumberVertices; i++) { pointMover = (CustomVertex.PositionNormal)getPoints.GetValue(i); meshVertices[i].Normal = pointMover.Normal; meshVertices[i].Position = pointMover.Position; x.SetValue(meshVertices[i].Position.X, i); y.SetValue(meshVertices[i].Position.Y, i); z.SetValue(meshVertices[i].Position.Z, i); nx.SetValue(meshVertices[i].Normal.X, i); ny.SetValue(meshVertices[i].Normal.Y, i); nz.SetValue(meshVertices[i].Normal.Z, i); } mesh.UnlockVertexBuffer(); mesh.Dispose(); }
  2. RPG balancing

    Hello, I read the op's comments but didnt read through the rest, just figured I would offer this. (sorry for not reading, mind is current in thought about a specific algo) Anyway just wanted to add that a good idea is to create a tool just for balancing. This can be something as simple as a form just displaying numbers. So basically in this tool (simulation) you would load in the desired data (avatar's armour, hp, mana whatever, Monsters armor, hp, mana etc) and run a simulation on all these different types of objects, you can even have the data recorded and printed out for you to review, make notes etc. Then you can tweak a little bit more and run again. I find this method of using an additional tool for balancing issues works much better / (faster) just because your not really needing to test it (in game) which can take awhile + plus whatever you program in the tool for instance printing the data out can be a great help, with visual feedback. Good luck, Andy
  3. DeviceLostException

    Hello, In your code you can handle a DeviceLost exception by doing the following. I always name my handle either Update() or ReloadResources() as in essence thats what is happening when you recover from a lost device. But you should be able to setup an event to be fired like this: this.graphicDevice.DeviceLost += new EventHandler(this.ReloadResources); ReloadResources(Microsoft.DirectX.Direct3D.Device graphicDevice) { // Handle your device lost (reload your resources) graphicDevice.Clear(etc..) } Another great thing to do while in the creation process is to run your application in windowed mode (becuase for me, its a pain going into full screen mode while im creating my application, that extra 2 seconds just bugs me for how many times I will run my app) and while in windowed mode you can setup a toggle for going to full screen (if you need to see the effect in full screen), but if you do that you need to specify another event or the screen will be re-drawn incorrectly. Here is the event: this.graphicDevice.DeviceResizing += new System.ComponentModel.CancelEventHandler(this.graphicDevice_DeviceResizing); void graphicDevice_DeviceResizing(object sender, System.ComponentModel.CancelEventArgs e) { e.Cancel = true; } Anyway if you need some more help just let me know:)
  4. Design & Implamentation

    Hi everyone, So I am working on I suppose we could say a very small RPG, though right now it comprises of just an editor with various methods for testing out different things such as HLSL, texture splatting etc... I am just wondering what the prefered way is for creating terrain. Basically to give you a better understanding of what I am attempting this game will have a look and feel like World Of Warcraft, with a 3rd person positioned camera. I am just trying to think of the best way to utilize terrain. Weather that be using 3d Studio max to create my terrain and export to an .X file, and then just load up the terrain as a mesh object, Or if it would be best to create my terrain in 3d Studio max export to an .X file and write my own .X parser to get the vertice / normal information, and then drop that data into a couple arrays. I will be using a (terrain streaming) method to present the terrain from the hard drive, and when creating the terrain in 3d studio max I will either use height maps for the displacement modifier or will just push and pull vertex's to create my desired look. I dont really want to use random terrain generation of (hills, mountains, rivers) etc, just because this world will be small enough that I can create the desired terrain look and feel by hand, then just use random generation of trees, rocks and all that good stuff. I am unsure and haveent really tested different methods yet, but I think writing my own .X parser to gather the vertex, index, and normal information from my terrain made in 3d studio max would be the best bet, because I can then drop that information into an [x, y] and [z] array, which would then be very usefull in an array form for my terrain streaming, and (character position / character to terrain collision checking). Does anyone know if I was to go the other route and drop the terrain into an .X file, then create a mesh object from that .X file if MDX 1.1 provides methods or properties for me to be able to access the vertex, index and normal data from the mesh container? That way I could still get the data out to put into an array. Just wondering because I already have code to load an display a mesh object, to load and display a mesh object with animation, and to also load display / call animation by frame names and alter specific matrix transformations on that animation. But I havent really dug around yet to see if I am able to get the vertex, normal and index information out. Well anyway please post any advice, comments about this matter as it will be very appreciated. As you can see I'm a little torn, (thinking heavily) about the most efficient way for creating my terrain. I really want to stick to using 3d Studio Max to create my terrain (not texturing) Just the placement of vertices becuase it is a very nice tool for that. But I really need an effecient way to access the [x, y] and [z] information so I can throw that information into a couple arrays. Maybe there is a another whole method of doing terrain that I somehow missed. Again thanks for any repli's and thanks for reading this long post, Andy
  5. Visibility determination

    Really quick and just off of the top of my head "sorry wife agro" but lets say point A is 0 and point b is 2000.0 along the z axis and you are at point A. You would like to see point b in the distance. So in real life we cannot see objects that are small and far away, but larger objects we can see "they may be small" because they are far away, but up close they are large. So you would need to write an algorithm that would tell the render to draw these objects if in the view frustem depending on (how far you can see, and the size of an object) So I might say there is a large tower placed here, it's 1000.0f in height(y) and I also say that any object that is larger then 800.0f (y) in height & is within 2000.0f (z) of myself & is within my view frustom to render this object. And lets say for your camera object you set you can see up to 2000.0f before being culled out. Then you would be able to see point b in the distance from point a if your camera was in the right direction. Sorry if this not what your looking for, its hard to determine the type of application you have going. This is in a nutshell (very simplified) what I would use in a 3d world where I am using streaming terrain and have the world objects broken up into different grids using node lists, so I wouldnt have to check all world objects, just however many were in my little grid of an area i was currently present in. If this is sort of what your asking for, let me know and if you need me to I can fully explain better when i get home this afternoon. Good luck, Andy
  6. What language are you using to be able to have a Full Screen / Windowed toggle?
  7. 1 thing you might want to check depending on how your running the application: There was this error / bug with vs 2005 dev edition where in some cases if I ran the application in debug mode through the vs interface it would take a fairly decent amount of time to load up and shut down. But if I just ran the .exe of my application everything ran great. If vs is your IDE and you test this, and this is the problem just let me know and I can try to find the Microsoft link on how to correct this problem, as I dont remember off the top of my head its been so long.
  8. X file - Terrain

    Thanks for the reply, Basically the base terrain I create in 3d studio max will have hills, depressions, etc.. as a sort of starting point. The editor will be able to (tweak) those x,y,z coords as needed in order for world objects to look right in the scene. I know in 3dS I can just (xRef) a scene object and do the checking that way, but that would just be to easy:) Plus I would like to keep everything I need in my MDI application that will consist of the editors / engine testing etc.. Im leaning towards just creating my own parser for .x files becuase all I want out of 3d studio is the x,y,z coords, I wont even be creating a mesh object out of the terrain. I guess another example of what im trying to achieve would be that I have my base terrain loaded up in the editor and I decide I would like a pond to be placed somewhere, so in the editor I would check some input controls stating that when I push -Y down on a specific point I would like all surrounding vertices in a radius of 10.0f to follow the depression but for every 2.0f += 20% of the depression total. Hmm decisions, Talking about this helps in some wierd way lol I suppose another route I could go is to just use 3ds as the pure editor but I would still need to have access to the x,y,z coords of the terrain so that when I create my character he wouldnt fall through the ground. I cant remember, (maybe I'll go check now) but does creating a mesh object and using a mesh container allow me access to the values in the vertex & index buffers? If so then I suppose I could just make this alot easier on myself and import the terrain as a mesh object, and pull those values out so I have access to them. And if not I can just continue to write a parser that gathers the information I need. I guess to sum up this overly long post of me rambling I'll state that im trying to get away from creating 3d terrain by just creating an array of [x,y] and then loading in a grayscale heightmap for the array of [z]. Doing so just doesnt seem very pratical as in my mind its not exact. I want all the control I can get in forming my small 3d world. Anyway thanks for the reply and any further comments would be appreciated, Andy
  9. X file - Terrain

    Hello everyone, Ive been visiting this website for a long while now, and finally just registered heh. Anyway I just have a quick question. I'm creating a 3D terrain / scene editor and while I can already use MDX 1.1 included librarys to load and view static meshes and animated meshes I'm just wondering what everyone thinks would be the best approach to what I'm trying to achieve. Trying to achieve: I'm creating in 3D studio max my (base) terrain, lets say its 1000.0 units in length, 1000.0 units in width, 100 lenght segs 100 width segs and 20000 total faces. There will be no animation, no texture, no materials. Im trying to figure out the best approach at reading the .X file to "only" gather the vertice and normal information. I would then take this information and toss it into 2 arrays, 1 for (x,y) and 1 for (z), then using vertex and index buffers render the terrain. The reason behind wanting to gather this information is so when my (base) terrain is rendered I will be able to use the mouse to push & pull vertices as needed in the editor while placing other actual mesh objects in the world. Which then I would save to some type of file format I come up with for actual use in the engine. I guess im just looking for some feedback on what everyone thinks would be the best approach for this, using .ASE or .X files, using the helpers included with MDX to parse this information like I'm parsing .X files for animated meshes, or if I should just create my own file reading class specific for this job. Any ideas, referances, links, thoughts would be greatly appreciated. Thanks, Andy PS Suppose I should also state that the editor is being built using C# & MDX 1.1
  • Advertisement