Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

126 Neutral

About Hibbs

  • Rank
  1. Ignore me - only just realised you can create generic class's. doh
  2. Im writing a custom collection class to handle my arrays and avoid boxing when using c# collections. Ive looked at the new c# beta generic collections - but they wont statisfy my requirements. My Question is - is there a way of creating a base class to hold the methods/functions ect and definiing different array types in inherited class's? I dont really want to duplicate the code when making an int & struc array class. Cheers
  3. Does anyone know of some tips or a specific resource for writing high performance c# code? I understand about avoiding boxing/unboxing, any other fundemental things i should avoid before getting to far in? Cheers
  4. Ive recently got my Octree working with my particle system, now Im able to have multiple different emitters and particles mingling together and still have correct culling and alpha sorting. Even though I still have many optimizations to make it obviously eats the CPU when the particle number increases because of all the dynamic updates for the particle position. I could remove the particles from the octree and frustrum check each particle, or I could add a bounding volume into the octree to represent the emitters maximum bounding area, then only frustrum check the particles in the frustum when there emiiters bounding volume is inside the frustum. Does anyone know of a better way of culling/alpha sorting particles?
  5. Hibbs

    Frustrum Bounding Volume

    I think its to do with the perspective - does opengl use Right Hand coords and in directx im using left hand, becuase the test returns the opposite box as the intersecting box, and if I reverse the frustrum xyz it returns the correct box.
  6. Hibbs

    Frustrum Bounding Volume

    Thanks for the replies, The problem with the code i pasted earlier was that only the view * projection matrix's needed inverting - multiplying them and inverting then multiplying the world matrix worked. Anyway indeed i was looking at it the wrong way. Ive tried converting the code for the "cube in frustrum" test from mark's tutorial (which was just the sort of test i was after thanks) into directx but it dosnt seem to be working, heres my code: This get the frustrum planes: Matrix M = w * v * p; //Left Clip Plane cp[0] = new Plane(M.M14 + M.M11, M.M24 + M.M21, M.M34 + M.M31, M.M44 + M.M41); //Right Clip Plane cp[1] = new Plane(M.M14 - M.M11, M.M24 - M.M21, M.M34 - M.M31, M.M44 - M.M41); //Top Clip Plane cp[2] = new Plane(M.M14 - M.M12, M.M24 - M.M22, M.M34 - M.M32, M.M44 - M.M42); //Bottom Clip Plane cp[3] = new Plane(M.M14 + M.M12, M.M24 + M.M22, M.M34 + M.M32, M.M44 + M.M42); //Near Clip Plane cp[4] = new Plane(M.M13, M.M23, M.M33, M.M43); //Far Clip Plane cp[5] = new Plane(M.M14 - M.M13, M.M24 - M.M23, M.M34 - M.M33, M.M44 - M.M43); for (int i = 0; i < 6; i++) { cp.Normalize(); } this is the cube test function: private static int cubeInFrustum(float x, float y, float z, float size) { int c; int c2 = 0; for (short p = 0; p < 6; p++) { c = 0; if (cp.A * (x - size) + cp.B * (y - size) + cp.C * (z - size) + cp.D > 0) c++; if (cp.A * (x + size) + cp.B * (y - size) + cp.C * (z - size) + cp.D > 0) c++; if (cp.A * (x - size) + cp.B * (y + size) + cp.C * (z - size) + cp.D > 0) c++; if (cp.A * (x + size) + cp.B * (y + size) + cp.C * (z - size) + cp.D > 0) c++; if (cp.A * (x - size) + cp.B * (y - size) + cp.C * (z + size) + cp.D > 0) c++; if (cp.A * (x + size) + cp.B * (y - size) + cp.C * (z + size) + cp.D > 0) c++; if (cp.A * (x - size) + cp.B * (y + size) + cp.C * (z + size) + cp.D > 0) c++; if (cp.A * (x + size) + cp.B * (y + size) + cp.C * (z + size) + cp.D > 0) c++; if (c == 0) return 0; if (c == 8) c2++; } return (c2 == 6) ? 2 : 1; } Any ideas what im doing wrong?
  7. Hibbs

    Frustrum Bounding Volume

    Finding the clipping planes didnt help me much becuase i want to check the frustrum volume against my octree & the clipping planes tell me if a point isnt in the frustrum where-as I want to check to see if the frustrum is inside a quad. I coded up to find the eight points of the frustrum and created a virtual camera(world view projection) so that I could render it all on the screen. It draws a frustrum shaped pyramid on the screen :) - but changing the world matrix moves it in the opposite direction - obviously becuase of the invert - removing the invert and i dont get a pyramid frustrum. Inverting the world matrix before the multiplication works. Is this a correct behaviour? Added: Somthing is deffinatley wrong, changing the farPlane increases the size of the frustrum but also moves its posiition. Am I multiplying the matrix's in the correct order? Heres my code: Matrix p = Matrix.PerspectiveFovLH((float)Math.PI / 4, 1, 1.0f, 2.0f); Matrix v = Matrix.LookAtLH(new Vector3(0, 0, 0), new Vector3(0, 0, 2), new Vector3(0, 1, 0)); Matrix m = Matrix.Translation(-3, -1, -3); Matrix M = m * v * p; M.Invert(); fv[0] = new Vector3(-1, -1, -1); fv[1] = new Vector3(1, -1, -1); fv[2] = new Vector3(1, 1, -1); fv[3] = new Vector3(-1, 1, -1); fv[4] = new Vector3(-1, -1, 1); fv[5] = new Vector3(1, -1, 1); fv[6] = new Vector3(1, 1, 1); fv[7] = new Vector3(-1, 1, 1); for (int i = 0; i < 8; i++) { fv.TransformCoordinate(M); } Thanks
  8. Can anyone help me with calculating a Frustrum Bounding Volume, or obtaining the four corner vertex's. Im using directx. Thanks
  9. It seems that there is a new solution in 2005, that removes the boxing/unboxing, called "generics" - its possible to create a collection defined to use a basetype. It dosnt look like they plan to have STL in anything but c++. Ill probably end up kicking myself for deciding to use c#.
  10. I think that C# 2005 has improvemnts to storing object types and gets around the boxing problem. I think ill download the beta and check into it further. DO you know if the STL.NET is being released as part of the 2005 version, or is it coming out seperate?
  11. im using c# - can i still use stl? i dont imagine that the collection class is as good - i think it will cause a problem with boxing/unboxing.
  12. Im working on a octree class, I have it calculating the cubes(nodes) and i want to assign an array to each cube to hold the index of the objects in a list. The question i want to ask is that when declaring the array of indexs for each cube i obviously have to choose a default array size. If during runtime i reach this size and have to resize the array, this will obviously affect performance( specially as most of my objects are dynaimic). Is there an alternative or is this performance hit going to be managable? I have though about using a string to hold the indexs, this would take up more storage if full but alot less when half full & wouldnt need resizing. Does anyone have any pointers?
  13. Hibbs

    Object Management

    i cant see how sorting by particle system will work, as some of my emitters output multiple particle types at the same location. Anyway ive updated my particle engine to use a staticly declared vertex & index buffer, so i can have all of my emitters outputing to a managed buffer - which at the moment tracks which parts of the buffer use which textures and calls the draw command in batches. Im planning to change this to use a texture which holds a tiled array of textures so I can call the draw command once and alter the Tu & Tv variables instead. Is there an upper limit size of a texture, and can these tiled textures be generated at runtime or is it easier to create them in paintshop or some equivalant? As the particles need sorting would it be more benifical in the long run to implement an octree (which i could use for culling & collision later on) to handle the sorting?
  14. Im working on a space sim, having gotten to the stage where i have object(mesh's mainly) and particles(billboards) classes working. I now realise that i need to sort the particles so that i can render them back to front. although my mesh's don't contain any alpha polys so they could be rendered first. My question is, with the dynamic nature of my scene would it be advisable to impletment some sort of tree structure to manage the objects, for sorting initally, but also to help with culling and collision later on. I think ive read some where that BSP trees are to slow to work with dynamic environments. any thoughts?
  15. Hibbs

    Particle RenderStates

    I like the idea of combining the textures into a single tiled texture atlas (so to speak). although my emiiters can contain several types of particles each with changing variables (color, alpha, blendtype, rotation, size, texture, velocity, age ect ect) and each if these variables can vary over life and have a random generation. so i dont think pre-multipled alpha will work for me. Is it possible to create these atlas textures at runtime as i create the emitters and load the individual textures, or will i have to create them externally?
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!