Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

eppo

Member Since 14 Mar 2008
Offline Last Active Today, 12:38 PM
*****

#5028755 Writing to a dynamic vertex buffer

Posted by eppo on 04 February 2013 - 01:34 PM

Mapping with WRITE_DISCARD invalidates the contents of the buffer, so you'll have to update the entire buffer as you do in the second method.
You're effectively given a new buffer, which avoids stalls when the GPU is still using the resource.


#5028292 Sprite won't change position

Posted by eppo on 03 February 2013 - 04:07 AM

Objects.push_back( object );

 

std::vector::push_back() adds a copy of 'object' at the end of the vector. LeftPaddle in WinMain is no longer the same object as stored in Objects[].

 

std::list<Object*> Objects;

 

...should work.




#5027857 Texture won't load and I get an unhandled exception

Posted by eppo on 01 February 2013 - 09:01 AM

There's a bug in the Graphics class.

DxManager getD3DManager() { return this -> D3DManager; }

This method returns a copy of the D3DManager object. Because it's a (temporary) copy, its destructor is called causing the D3D device to be released.

You should return a pointer or a reference to the manager:

DxManager &getD3DManager() { return this -> D3DManager; }


(+1 for posting clean/readable code)


#5027513 Texture won't load and I get an unhandled exception

Posted by eppo on 31 January 2013 - 04:53 AM

I had another look at your code, and there's a bug in the Object::setPosition() method. You are dereferencing a null-pointer, 'Object::position'.

You never create the actual vector (in Object's constructor): 'position = new D3DXVECTOR3'.

 

b.t.w. there's no reason why position should be placed on the heap: LPD3DXVECTOR3 > D3DXVECTOR3;




#5027173 Texture won't load and I get an unhandled exception

Posted by eppo on 30 January 2013 - 08:05 AM

For default usage, use '0' (which also happens to be the value of D3DPOOL_DEFAULT, but it's an unrelated constant).

 

What is the HRESULT of D3DXCreateTextureFromFileEx?




#5026777 Texture won't load and I get an unhandled exception

Posted by eppo on 29 January 2013 - 08:59 AM

You (incorrectly) pass a member of the D3DPOOL enumeration as the Usage argument to D3DXCreateTextureFromFileEx.
This function has a return value that could tell you a lot about what you could be doing wrong.


#5025725 Slerping the Kool Aid - Help!

Posted by eppo on 26 January 2013 - 04:53 AM

Quaternion.CreateFromAxisAngle(rotationAxis, rotationAngle) calculates the difference in orientation between forward and lookAt, but when slerping you treat is as an absolute orientation.

Quaternion qSlerp = Quaternion.Slerp(qStart, qEnd, (float)gameTime.ElapsedGameTime.Milliseconds / 1000f);

should be:

Quaternion qSlerp = Quaternion.Slerp(qStart, qStart * qEnd, (float)gameTime.ElapsedGameTime.Milliseconds / 1000f);

I don't know the exact implementation of these math functions, but you should check whether CreateFromAxisAngle() requires a normalized vector as input (which rotationAxis = Vector3.Cross(lookAtDirection, forward) likely isn't).

MathUtilities.GetUnsignedAngle() seems to throw out the sign of the angle, but in the code that follows you recalculate it:

Vector3 right = Vector3.Normalize(transformComponent.Transform.Right);

float rightDot = (float)Math.Round()...
if (rightDot > 0){ rotationAngle *= -1; }

So, you should either use GetSignedAngle() (if it exists) or use angle = acos(forwardDot).


#5025137 computer vision

Posted by eppo on 24 January 2013 - 11:06 AM

I think as an introduction '3D Math Primer for Graphics and Game Development' might suit.




#5024759 Best way to create spherical terrain?

Posted by eppo on 23 January 2013 - 10:20 AM

This article from GPU Gems 3 explains how to construct terrain on the GPU (and has a paragraph on spherical planets), but this can also be done offline (it uses basic marching cubes).


#5024657 Textures

Posted by eppo on 23 January 2013 - 03:49 AM

Have you inspected the final contents of the Points[] list in a debugger?




#5024318 Textures

Posted by eppo on 22 January 2013 - 09:43 AM

But is it important? Point will be added several times (for each rectangle) but with same texCoords...
It may be. When you iterate over all the points (for (int j = 0; j < list.Count; j++)), including the duplicates, they may no longer match up with what you have stored in 'elements[i].valueOnPoint[]' when you index it with 'j'.


#5024301 Textures

Posted by eppo on 22 January 2013 - 08:35 AM

Are the positions in 'list[]' duplicated somehow?




#5024287 Textures

Posted by eppo on 22 January 2013 - 07:59 AM

There are mustn't be 4 different corors around 1 vertex. Oposite, there are must be one color on the 4 quads (near this vertex)

 

Perhaps it's best if you post the code that shows how you set up the quads' vertex positions and their accompanying temperature-texcoords. Like said before, it's probably something in there that's causing these unwanted discontinuities.




#5024233 Trouble with AlphaState

Posted by eppo on 22 January 2013 - 03:00 AM

The Xbox supports a variation of shader model 3.0.

Windows Phone 8 can run D3D 11 with feature level 9_3.




#5023941 Textures

Posted by eppo on 21 January 2013 - 10:06 AM

How about you recreate the entire texture as a lookup table in the pixel shader and then sample it like this: out.color = colors[round(texCoords.x * 11)]?

const float3 colors[] = {

   float3(0.f, 0.f, .5f),
   float3(0.f, .23f, .73f),
   float3(0.f, .45f, .95f),
   float3(0.f, .68f, 1.f),

   float3(0.f, .9f, 1.f),
   float3(0.f, 1.f, .73f),
   float3(0.f, 1.f, .27f),
   float3(.23f, 1.f, 0.f),

   float3(.63f, 1.f, 0.f),
   float3(1.f, .91f, 0.f),
   float3(1.f, .45f, 0.f),
   float3(.93f, .11f, .14f),
}





PARTNERS