C#에서 SlimMath 매트릭스를 FLOAT *로 가능한 한 깨끗하게 관리해야합니다. 지금까지 나의 모든 시도는 더럽고 부서졌습니다.C# 매트릭스를 C++로 변환 FLOAT *
C#을
Matrix m = Matrix.Identity;
//.......(transform matrix)
//.......Convert it to something I can get into c++ ??
myManagedCPPFunction(m.ToArray());
C++
void myClass::myManagedCPPFunction(?? matTransform)
{
//FLOAT* f = reinterpret_cast<FLOAT*>(&matTransform); //Cant do this cause managed code
otherClass->Go((FLOAT*)matTransform);
}
//This is existing code I'm trying to get to:
class otherClass
{
public:
virtual void STDMETHODCALLTYPE Go(const FLOAT *pTransformMatrix);
}
나는 그와 함께 작동 할 수있는 충분한 의미가 희망 : 코드는 다음과 같이 보인다.
감사합니다.
편집이 작업은 문자열 및 일반 수레에서 이미 작동하고 있음을 잊어 버렸습니다. float [] -> float * 일을 할 수없는 것 같습니다.
나는 이런 식으로 작업을 진행 할 수 있었다, 그러나 이상적이지의 :
unsafe
{
fixed (float* f = m.ToArray())
myManagedCPPFunction(f);
}
는 분명한 이유 그렇게하지 않으시겠습니까. 내가 지금 일하고 있다고 생각
OK는 (적어도 그것과 실행을 컴파일하지만 지금은 변환과 재생해야) 다음과 같이 당신이 할 수있는 방법을
void myClass::myManagedCPPFunction(SlimDX::Matrix^ matTransform)
{
FLOAT* f = reinterpret_cast<FLOAT*>(&matTransform);
otherClass->Go(f);
}
예, 좋습니다. 전에는 SlimDX :: Matrix ^를 사용해야한다는 것을 깨닫지 못했습니다. 감사! – FrozT