XMVECTOR and XMVectorSet

Started by
1 comment, last by Conny14156 11 years, 4 months ago
Hi, Have some few questions that are probably stupid questions.

Am trying to set the rotaxis to All zero so that my BasicCubeSecond Doesnt get a rotation at all. But everytime I try to do it I get some wierd error in the XNA source file, complaining about

> FusionEmpty.exe!XMAssert(const char * pExpression, const char * pFileName, unsigned int LineNumber) Line 1865 C++
And something about the program reaching a breakpoint (__debugbreak()) which I have no idea why.

Is my way to do it wrong?


[source lang="cpp"]
void UpdateScene()
{
rot += .0005f;
if(rot > 6.28)
{
rot = 0.0f;
}

//Reset Cube rotation

BasicCube = XMMatrixIdentity();
XMVECTOR rotaxis = XMVectorSet(0.0f,1.0f,0.0f,0.0f);
WorldRotation = XMMatrixRotationAxis(rotaxis,rot);
WorldTranslation = XMMatrixTranslation(0.0f,0.0f,4.0f);

//Set cube1's world space using the transformations
BasicCube = WorldTranslation * WorldRotation;

//Reset Cube 2


BasicCubeSecond = XMMatrixIdentity();
rotaxis = XMVectorSet(0.0f,0,0.0f,0.0f); //<------------------ Trying to set the rotation to 0
WorldRotation = XMMatrixRotationAxis(rotaxis, rot);
WorldScale = XMMatrixScaling(1.3f,1.3f,1.3f);
//Set Cube 2
BasicCubeSecond = WorldRotation * WorldScale;
}
[/source]
Advertisement
Are you sure it is XMVectorSet line, not the XMMatrixRotationAxis one? Because if you look at the source of XMMatrixRotationAxis you'll see following code:
XMINLINE XMMATRIX XMMatrixRotationAxis
(
FXMVECTOR Axis,
FLOAT Angle
)
{
#if defined(_XM_NO_INTRINSICS_)
XMVECTOR Normal;
XMMATRIX M;
XMASSERT(!XMVector3Equal(Axis, XMVectorZero()));
XMASSERT(!XMVector3IsInfinite(Axis));
Normal = XMVector3Normalize(Axis);
M = XMMatrixRotationNormal(Normal, Angle);
return M;
#elif defined(_XM_SSE_INTRINSICS_)
XMASSERT(!XMVector3Equal(Axis, XMVectorZero()));
XMASSERT(!XMVector3IsInfinite(Axis));
XMVECTOR Normal = XMVector3Normalize(Axis);
XMMATRIX M = XMMatrixRotationNormal(Normal, Angle);
return M;
#else // _XM_VMX128_INTRINSICS_
#endif // _XM_VMX128_INTRINSICS_
}


Basically it will assert if rotaxis equals to zero vector.
Yeha thanks, seems like it was stupid of me setting rotaxis to all zero >.< thank you

This topic is closed to new replies.

Advertisement