No Operator = Matches Operands - DX11

George_H

I'm trying to multiply two sets of values together in DX11.

void Update()
{
    rot += 0.0005f;
    if (rot > 6.26f)
        rot = 0.0f;

    cube1 = XMMatrixIdentity();

    XMVECTOR rotaxis = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
    Rotation = (rotaxis, rot);
    Translation = XMMatrixTranslation(0.0f, 0.0f, 4.0f);

    cube1 = Translation * Rotation;
    cube2 = XMMatrixIdentity();

    Rotation = XMMatrixRotationAxis(rotaxis, -rot);
    Scale = XMMatrixScaling(1.3f, 1.3f, 1.3f);

    cube2 = Rotation * Scale;

But I keep getting the error;

[code]No operator "=" matches these operands
operand types are: DirectX::XMVECTOR = DirectX::XMMATRIX[/code]

From what I have read, they can't be multiplied together, but I cannot seem to find a workaround.

Code Snippets.

Forward Declarations

const int Width = 300;
const int Height = 300;

XMMATRIX WVP;
XMMATRIX cube1;
XMMATRIX cube2;
XMMATRIX camView;
XMMATRIX camProjection;

XMVECTOR camPosition;
XMVECTOR camTarget;
XMVECTOR camUp;

XMVECTOR Rotation;
XMVECTOR Scale;
XMVECTOR Translation;
float rot = 0.1f;

Setting camera/projection at the end of the InitDevice() Function.

camPosition = XMVectorSet(0.0f, 3.0f, -8.0f, 0.0f);
camTarget = XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f);
camUp = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
camView = XMMatrixLookAtLH(camPosition, camTarget, camUp);
camProjection = XMMatrixPerspectiveFovLH(0.4f*3.14f, Width / Height, 1.0f, 1000.0f);
Chuck Walbourn

The first problem I see is:

XMVECTOR rotaxis = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
Rotation = (rotaxis, rot); <<--- You are missing the name of a function here!
Translation = XMMatrixTranslation(0.0f, 0.0f, 4.0f);

Since there's no function name there so you are actually using the comma operator. It's basically the same as:

Rotation = rotaxis = rot;

I'm not sure what you are trying to do here, but it's probably not that.

The second issue is:

Rotation = XMMatrixRotationAxis(rotaxis, -rot);

XMMatrixRotationAxis returns a XMMATRIX which you are trying to assign to a XMVECTOR which doesn't work.

You need to review your usage. If Rotation is supposed to be a quaternion (which fits in a XMVECTOR) then you need to use XMQuaternion* functions instead of XMMatrix*.

I'd recommend using C++-style type declaration instead of putting them all at the top. It's a lot easier to read and follow the types.

Note if you are new to DirectXMath, you should take a look at the SimpleMath wrapper in the DirectX Tool Kit for DX11 / DX12.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

error: no operator "<" matches these operands

IntelliSense: no operator "<<" matches these operands

Error: no operator "==" matches these operands

no operator "/" matches these operands

no operator ""<<"" matches these operands error

Error : no operator " != " matches these operands

no operator "=" matches these operands error

"no operator >> matches these operands"

C++ No operator [] matches these operands

No operator "<<" matches these operands - C++

No operator "[ ]" matches these operands C++

E0349 no operator ">>" matches these operands

C++ - Error - No operator "[]" matches these operands

more than one operator "[]" matches these operands

E0349 no operator "<<" matches these operands

no operator "<<" matches these operands recursive tower of hanoi error

No operator "<" matches these operands operand types are: double < my_class

Accessing an entry in std::map causes 'no operator "[]" matches these operands'

C++ - no operator "<<" matches these operands directory_iterator()

No operator ">=" matches these operands error in c++ when using while loop

No operator "+" matches these operands, aka cannot add Array<double> to double

C++) E0349 no operator matches these operands occured

No Operator ">>" matches these operands operand types are: std::istream>>int

no operator ">>" matches these operands -- operand types are: std::istream >> const double

no operator ">>" matches these operands operand types are: std::istream >> double*

no operator matches these operands; operand types are: std::istream >> const char [5]

No operator "<<" matches these operands error between an object and a string literal

Error during implementation of operator>> :C++ no operator matches these operands operand types are: std::istream >> const double error

No operator "=" matches these operands. I have overloaded it but it doesn't seem to be working properly