Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About WhiteWizardEtc

  • Rank
  1. WhiteWizardEtc

    Rotation + Translation

    I think ill just clear up that stuff about identity matrices i said before. Basically calling D3DXMatrixIdentity(&matWorld); makes sure the matrix is set to Identity. This identity matrix is such that if any other matrix is multiplied by it, its result remains unchanged. eg. if matrix 'I' is the indentiy matrix then... I x A = A. Anyway applying it to your program, If you have your matrices set as global that means they retain their data until such point as their parent class is destroyed. Which means they retain data between frames. After typing out some code to show you how it works, i realized your program wont be affected by any permanence of the matrices, so using the identity matrices wont be necessary. But its still good to know about it and be aware of what it can do. also some of the code you posted before //Fix orientation of character (only needed once) 1 D3DXMatrixRotationX( &matRotX, D3DXToRadian(90.0f) ); 2 D3DXMatrixRotationY( &matRotY, D3DXToRadian(90.0f) ); 3 4 // Move character left or right 5 D3DXMatrixTranslation(&matTrans, indexx, indexy, 0); 6 7 //Transform character world 8 d3dDevice->SetTransform( D3DTS_WORLD, &(matRotX * matRotY) ); 9 d3dDevice->SetTransform( D3DTS_WORLD, &(matTrans) ); on line 8 you set the world matrix as one rotated 90degrees along X and Y, then at line 9 you RE-set the world matrix as one ONLY translated by 5x and 5y. They need to be done is a single calculation eg. d3dDevice->SetTransform( D3DTS_WORLD, &(matRotX * matRotY * matTrans) ); This ensures that both the rotations and translations are applied
  2. WhiteWizardEtc

    Rotation + Translation

    I think that because its a side scroller you want to rotate the player around the Y axis (ie the axis running vertical to the screen), rotating around the Z axis would tilt the character forward and back. Tiege seems very confused about how to use World matrices properly. Rather than having your translation/rotation/world matrices as global variables, having them as local variables for the render function seems more foolproof, so each time render() is called you declare them, and initialize to an identity matrix. From there you would do psuedocode: Render() { declare all matrices (world/translation/rotation) initialize to identity set rotation/translation matrices for the terrain set the world matrix (world= scale*rotate*translate) render the terrain set all matrices back to identity set rotation/translation matricies for the player set the world matrix (world= scale*rotate*translate) render the player } basically the world matrix should not persist between frames being rendered (for simplicity) , it should be calculated every frame (of course persistence is fine if the matrix never changes)
  3. WhiteWizardEtc

    Rotation + Translation

    EDIT: The correct order to do matrix transforms is scale, rotate(x, y, z), then translate. eg Direct3D_device->SetTransform(D3DTS_WORLD, &(matScale * matRotateX * matRotateY * matRotateZ * matTranslate)); another possible problem you may be having is the rotation itself, is the angle you use in degrees or radians? and are you calculating it from a vector direction? You also need to remember to reset the world matrix if you are rendering stuff after the player, and make sure its set to identity in the first place before rotating/translating the player (there are of course times when you want to keep the translating of the last object, mabey the parent object is being rendered first and you want to offset the next object). Hope that helps:)
  4. WhiteWizardEtc

    Indexed cube

    [font="Arial"]I can see two things that could be a problem. 1. The order in which you multiply the matricies to work out the world matrix seems to be mixed up, [/font][font="Arial"]m_matWorld = m_matWorld * matTranslate * matScale * matRotate; have a read of http://msdn.microsof...v=vs.85%29.aspx , basically you need to go [/font][font="Arial"]m_matWorld = m_matWorld * [/font][font="Arial"]matRotate[/font][font="Arial"] * [/font][font="Arial"]matScale[/font][font="Arial"] * [/font][font="Arial"]matTranslate ; Although to be honest you are not translating or scaling so it shouldnt affect it. Is there a reason you are maintaining the world matrix? Does this cube have a parent is needs to rendered in relation to? If not you can leave the m_matWorld out of the multiplication. 2. Both your eye and look vector for the camera is on the positive z axis, which is into the screen for directx, so you will essentially be rendering the back of the cube, which doesnt solve your problem at all, but may solve others later down the track.[/font]
  5. WhiteWizardEtc

    Loading/Mapping Textures Help

    [font="Arial"] You my friend, need some error checking. Alot of directx functions return the result of the function in the form of HRESULT. My guess is that the texture you are trying to read in [/font][font="Arial"] "goof.JPG" is in the wrong folder, but unless you do some error checking on the D3DXCreateTextureFromFile function you would never know it wasnt even loading. If the create texture function fails it uses a white texture. [/font][font="Arial"]Do something like [source] HRESULT hr; hr = D3DXCreateTextureFromFile(d3ddev, "goof.JPG", &texture_1); if(FAILED(hr)) { // find out what the failure was //will be one of the following D3DERR_NOTAVAILABLE, D3DERR_OUTOFVIDEOMEMORY, D3DERR_INVALIDCALL, D3DXERR_INVALIDDATA, E_OUTOFMEMORY. } [/source] [/font]
  6. WhiteWizardEtc

    D3DXFONT rendering/releasing weird problems [DX9]

    BUMP anyone got any ideas? no matter how wild or seemingly obvious. on a related note, i did some fiddling today and found that if i release the font object right after the creation it runs fine, so something must be happening during update/render that is screwing the font up somehow. Another thing i noticed is that in the D3DXCreateFont() call i can set the text name (Arial etcetc) to whatever i want and it doesnt return errors, eg. Facename = TEXT("asdasdasdasd") EDIT: later on i did some more testing I started a new project solution and added in only the bare bones of the graphics system, and it works! So at least now i know there is nothing wrong with my font code, its some other conflict elsewhere and its going to take a longggg time to find
  7. WhiteWizardEtc

    D3DXFONT rendering/releasing weird problems [DX9]

    hi, thanks for the reply. I dont have a font class yet, its just sitting in the main directx graphics class, and i have stepped through debugging so i know that the release() is being called, thats where it throws that: Unhandled exception at 0x76f76579 in ICT311.exe: 0xC0000005: Access violation reading location 0x222c166d. I get the feeling that this problem has nothing to do with the font class, it just happened to show up when i went to use fonts. But i dont have enough knowledge of directx to know about its inner workings. Text() seems more readable i guess, for people reading it who dont know what 'L' does.
  8. I am currently working on the Graphics portion of my game engine, and have hit a brick wall with font rendering, I have read a whole bunch of tutorials and it seems to be very straight forward, but these weird problems continue popping up. The creation of the font object works properly, HRESULT is ok and the object has a valid address, the d3d_device is fine because i am using to render terrain and objects allready. My problems appear when i got to render the font. the DrawText function itself runs and returns that the correct amount of characters has been written, but immediately after, a whole bunch of totally unrelated object pointers in the main engine loop become corrupter (set to things like 0x0000000f and 0x00000018). If i remove the draw() and just use the create() and release(), it crashes on release() with: Unhandled exception at 0x76f76579 in ICT311.exe: 0xC0000005: Access violation reading location 0x222c166d. now for some code. Creation looks like this: [source] m_Font = NULL; //font object hr = D3DXCreateFont( Direct3D_device, 20, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Arial"), &m_Font ); if(FAILED(hr)) { throw Exception("DX:error loading font\n"); m_Font = NULL; } [/source] ~De-constructor: [source] if(m_Font!=NULL) { m_Font->Release(); //still problems with releasing this m_Font = NULL; } //..a bit later down //release Direct X stuff Direct3D_object->Release(); Direct3D_device->Release(); [/source] within DX::Render() [source] D3DCOLOR fontColor = D3DCOLOR_ARGB(255,0,0,255); RECT rct; rct.left=2; rct.right=780; rct.top=10; rct.bottom=rct.top+20; int result = m_Font->DrawText(NULL, TEXT("test text"), -1, &rct, 0, fontColor ); [/source] Some things that may or may not be related: Im using a pixel shader for the terrain rendering, but have tried setting it to NULL before rendering fontsi have directx debugging enabled and it does not say anything apart from (Ignoring redundant SetRenderState) which i think is elsewhereI do not have WinMain() as my entry point for directX, and instead i retrieve the window handle in the contructor of the graphics classdo the world, projection and view matrices affect font rendering? and if so, what should they be set as (similar to hud rendering i assume, but have not tried it yet)i have also tried rendering the font within a sprite, same results Any help would be much appreciated , and btw this is my first post, so if i have used the source tags incorrectly then
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!