Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

A problem about variable initialization

Started by wswqwps 3 replies 600+ views
Original Post
wswqwps
wswqwps
When I read the document in DX Sdk,I saw a sample in the chapter [World Transform].Code like this: void C3DModel::MakeWorldMatrix( D3DXMATRIX* pMatWorld ) { D3DXMATRIX MatTemp; // Temp matrix for rotations. ... if(...) { // Produce and combine the rotation matrices. D3DXMatrixRotationX(&MatTemp, m_fPitch); // Pitch ... } } The type [D3DXMATRIX] does not have any constructor to be called to initialize the var [MatTemp], and I thought the value of the var [MatTemp] is rubbish.And the function [D3DXMatrixRotationX()] rotate the matrix around X-axis.Because the the matrix has a random start position ,after rotation,what can we get? Another random position?
wswqwps
wswqwps
Thanks for your reply,but I can not understand the words "Set the matrix".
The value of matrix was set to what? Can you explain the "rotate matrix" detailedly or give me some links about this?

Thanks a lot!!!
Gage64
Gage64
I mean it sets the matrix's elements to the appropriate values. Internally the function might look something like this:

D3DXMATRIX* D3DXMatrixRotationX(const D3DXMATRIX *mat, float angle){    mat->_11 = 1; mat->_12 = 0; mat->_13 = 0; mat->_14 = 0;    //...}


I'm not sure I understand your question correctly - are you asking about the math involved (i.e., how to setup a rotation matrix), or a general programming question?
wswqwps
wswqwps
Yes I understand.You mean in the function the matrix would be given a special value.So we need not to care about what it is before.

Thanks a lot!!!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.