Jump to content

  • Log In with Google      Sign In   
  • Create Account


Nyxenon

Member Since 31 Oct 2011
Offline Last Active May 23 2012 03:02 AM

Topics I've Started

[C#/C++] Getting convex polygons from concave polygon?

19 May 2012 - 10:07 PM

I'm working on a library for collision detection/response and perhaps slightly realistic physics. It's going well, but I want my library to have some pretty advanced features. I honestly think if I took enough time, I could find a solution to my problem, but I was wondering if there were any good resources to figure out how to get convex polygons out of concave ones. I thought about using triangulation, which would technically work, but it would be best if I could just use convex polygons with multiple sides (if that's what the shape calls for) rather than using multiple triangles to form a single convex shape.

I haven't written a triangulation algorithm yet, but I think I have a good idea of how to write one (thanks to reading up on it online). Could I use triangulation at first, then get each convex shape, or is it easier to get each convex shape individually?

Diffuse color?

21 April 2012 - 02:14 PM

With XNA, you have BasicEffect which has the "Diffuse" property. I haven't messed with HLSL in a while, but I'm wondering how to write the code to add color to a texture. For example: I have a texture, and I want to draw it with it blended red. What would I do if I had float4 blendColor and float4 texColor (where texColor is the color of the pixel for that pass)?

[HLSL] Half vectors in shaders?

14 April 2012 - 07:44 AM

I'm working on a prototype of sorts that will use voxels, and I'm trying to make the renderer. For performance and memory preservation, I've written a struct using XNA types like this:
    //32 bytes
    [StructLayout(LayoutKind.Sequential)]
    public struct VoxVertex
    {
	    //12 bytes
	    Vector3 Position;
	    //8 bytes
	    HalfVector4 Normal;
	    //4 bytes
	    HalfVector2 UV;
	    //8 bytes
	    HalfVector4 Diffuse;
	    public static int Size
	    {
		    get { return 32; }
	    }
	    public static readonly VertexElement[] Format = new VertexElement[]
	    {
		    new VertexElement(0,0,VertexElementFormat.Vector3,VertexElementMethod.Default,VertexElementUsage.Position,0),
		    new VertexElement(0,12,VertexElementFormat.HalfVector4,VertexElementMethod.Default,VertexElementUsage.Normal,0),
		    new VertexElement(0,20,VertexElementFormat.HalfVector2,VertexElementMethod.Default,VertexElementUsage.TextureCoordinate,0),
		    new VertexElement(0,24,VertexElementFormat.HalfVector4,VertexElementMethod.Default,VertexElementUsage.Color,0)
	    };
    }

I'm not entirely sure of how to get the data in the shader. If it were normal floats and vectors, I would have no problem, but it's not. Would it be alright to write a shader as if it's going to be accessing normal float data, or will I need to use half types, and somehow convert them to float?

Frequently setting data to a vertex buffer?

08 April 2012 - 03:56 PM

I'm using Xna 3.1, and I want to use a vertex buffer that can be "cleared" when a certain event happens, then data can be put into it. I don't know what the difference between a DynamicVertexBuffer and the regular VertexBuffer would be. I'm really unsure of how I should go about using the VertexBuffer. I was thinking that I could use a static array with a fairly large size to set the vertex data, then transfer that array to the vertex buffer.
So which VertexBuffer type should I be using?

How to read PNG images without a library?

02 April 2012 - 10:33 AM

I don't want to rely on a library to load PNG images, and I want to know how I can write the code myself. I found http://www.libpng.org/pub/png/spec/1.2/PNG-Structure.html, but I'm finding it hard to understand how to go about writing the code to load the pixel data from a PNG file. Any help would be greatly appreciated, thanks.

PARTNERS