Jump to content

  • Log In with Google      Sign In   
  • Create Account


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

Posts I've Made

In Topic: Rotating camera around player origin

23 May 2012 - 03:03 AM

I'm glad I was able to help. I wrote all that code from memory, so I'm actually a little surprised that you were able to get it to do what you want.

In Topic: Rotating camera around player origin

19 May 2012 - 10:48 PM

I always have yaw, pitch, and roll variables, then every frame I update them with the controller or whatever, then I create a quaternion using those variables, then I transform the "backward" vector with that quaternion. Make the camera position that vector (multiply it by whatever distance you want it to be from the player), add the player position to that vector, then set the target to the character position.

It's really not hard to do, and I would provide some sample code, but I'm a little lazy right now :P

Aww, hell, here's some pseudo-code:
float yaw, pitch, roll;//Some variables that will be in your camera class or wherever you want them
//You could also just use a quaternion rather than those variables, then just multiply the quaternions.
//I feel it's a little better to use yaw, pitch, and roll since you can keep track of your camera's rotations a little better (doesn't really matter if it's a free camera anyway)

//I really don't know which is which with yaw pitch roll, but only two are important (I think yaw and pitch, yaw being up/down, pitch being rotation?)
//Anyway, doesn't matter. Just find out which is which, add to them using input from a controller/keyboard, then create your quaternion

Quaternion rotator = Quaternion.FromYawPitchRoll(yaw,pitch,roll);

float camDistance = 5.0f;
vector3 back = Vector3.Backward;

back = Vector3.Transform(back, rotator);//Rotate our vector
rotator *= distance;//Push it out a distance from the player)
rotator += playerPosition;//Add the position

View = Matrix.CreateLookAt(back, playerPosition, upVector);

In Topic: Quadtree problem.

19 May 2012 - 09:47 PM

Are you not releasing any memory? It looks like you're allocating, but not releasing. That might be the problem.

In Topic: Diffuse color?

21 April 2012 - 03:54 PM

Then you can just go like this in your pixel shader (in pseudocode):

outputcolor = (texColor + blendColor) * 0.5;

Or you can blend it more or less strongly like this:

outputcolor = lerp(texColor, blendColor, t);

If t = 0, the output color will just be texColor, if t = 1 then it will be blendColor. Values in between give various blend levels. t = 0.5 corresponds to the blend before.

I actually figured it out myself. I tried the code you provided, and it didn't do what I wanted. It did some weird blending.
texColor * blendColor
does exactly what I want.

In Topic: [HLSL] Half vectors in shaders?

14 April 2012 - 10:52 PM

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?

You can use float types, and the GPU will automatically convert them to 32-bit float for the vertex shader.

So what you're saying is that for the above structure that I provided, I could write the following in HLSL?
struct VoxVertexIn
float4 Position : POSITION;
float4 Normal : NORMAL;
float2 UV : TEXCOORD;
float4 Color : COLOR;

Yes, that will work.

That's definitely a relief. Thanks for the help.