XMMatrix的访问浮点数-()运算符不起作用 [英] Access floats of XMMatrix - () operator not working

查看:108
本文介绍了XMMatrix的访问浮点数-()运算符不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在DirectX中做一些3D的工作(我正在从OpenGL迁移),但是遇到了麻烦.

I'm trying to do some 3D stuff in DirectX (I'm migrating from OpenGL) and I've hit a snag.

我想访问XMMATRIX的值,并查看Microsoft文档,应该有一个()运算符:

I want to access the values of an XMMATRIX and looking at the Microsoft documentation there should be an () operator:

    float&  operator ()(
  size_t Row,
  size_t Column
);

所以我尝试这样使用:

XMMATRIX i = XMMatrixIdentity();
float j = i(0,0);

但是Intellisense给了我错误:

But Intellisense gives me the error:

IntelliSense:在没有适当的operator()或没有将函数转换为指针到函数的类型的情况下,调用类类型的对象.

IntelliSense: call of an object of a class type without appropriate operator() or conversion functions to pointer-to-function type.

如果我忽略Intellisense并仍然进行编译,则会出现编译时错误:

If I ignore Intellisense and compile anyway I get the compile-time error:

错误C2064:术语未评估为带有2个参数的函数

error C2064: term does not evaluate to a function taking 2 arguments

任何人都知道为什么会这样吗?还是访问矩阵元素的另一种方法?

Anybody have any idea of why this is happening? Or another way to access the elements of the Matrix?

感谢您的时间.

P.S.如果此信息有帮助,我将为Windows 8创建一个C ++/DirectX Modern UI App.

P.S. I am creating a C++/DirectX Modern UI App for Windows 8 if this information helps at all.

推荐答案

检查

Check this MSDN link and you'll see that it depends on which DirectX or XNA math header you have and the pre-processor definitions in force at the time. By default, and for optimisation reasons, the matrix and vector structures will be implemented using SSE and intrinsics, which makes it difficult and expensive to provide row/col access.

尝试在项目属性的C ++条目的预处理器指令中定义_XM_NO_INTRINSICS_,或者在#include任何DirectX标头之前定义#define _XM_NO_INTRINSICS_.

Try defining _XM_NO_INTRINSICS_ in the pre-processor directive of the C++ entry of your project properties, or #define _XM_NO_INTRINSICS_ before you #include any DirectX headers.

此摘录来自我的Windows 8 VS2012系统上的DirectXMath.h,显示了为什么出现此错误:

This excerpt from DirectXMath.h on my Windows 8 VS2012 system shows why you get this error:

struct XMMATRIX
{
    // ... code removed for clarity

#ifdef _XM_NO_INTRINSICS_
    float       operator() (size_t Row, size_t Column) const { return m[Row][Column]; }
    float&      operator() (size_t Row, size_t Column) { return m[Row][Column]; }
#endif

    // ... code removed for clarity
};

这篇关于XMMatrix的访问浮点数-()运算符不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆