Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About Mijin

  • Rank
  1. Doh! You're right of course, texTrans is the transformation matrix. There are three matrices involved in calculating the position of a given vertex on the screen. The world matrix is unique for each model/billboard/whatever and is basically a given object's position and orientation. The view matrix can be considered the camera's matrix: by changing the view matrix everything on screen moves without you needing to recalculate any world matrices. The projection matrix is how to project the 3d world on to your 2d screen. Different matrices here can go from fish-eye to regular lens or even views where objects don't diminish in size with distance. Anyhoo, in answer to your question, I'd try sptWorldViewProjection. Although the code only specifies WorldProjection, often the "world" is assumed to already be multiplied by the view (you have to do this in OpenGL, so former OpenGL programmers rarely differentiate between "world" and "world x view"). If it doesn't work, get the matrices separately, something like this: pDevice->GetRenderState( D3DMATRIX_WORLD, &world); pDevice->GetRenderState( D3DMATRIX_PROJECTION, &proj); worldProj = world * proj; ---- Regarding the other question, yes, glowTexture is a bitmap file that you must provide. Remember, load it in using pDevice->LoadTexture and then set it via pShader->SetTexture. I'd use a 256x256 texture (this is probably bigger than necessary or optimal here, but I always use this size first as it's the "safest". Try with a smaller texture once you've got it working with a 256 texture). Just a white circle on a black background, but with a gradient (so the circle appears more opaque towards the centre), and see what effect you get.
  2. hey no worries. I think I might also appropriate the shader you've downloaded ;) According to the comment, pSize = "the pixel size of the texture, equivalent to the inverse of the texture width". The inverse of a number is 1 / that number. So the inverse of 4 is 1/4 or 0.25. I think what he or she (let's face it, it's not a she), is getting at, is the size of a pixel in UV scale. So if you have a square that has UVs 0...2 in both dimensions and a texture that is 256x256 then pSize = 2 / 256. If you don't know about UVs then assume 0..1 in both dimensions. glowTexture and texTrans are obviously both textures. IIRC the command, in C, is just this: pShader->SetTexture("glowTexture", theTextureYouveLoaded); where theTextureYouveLoaded is, I think, a LPDIRECT3D9TEXTURE. I think the command to load a texture in turn is device->LoadTexture. Where "device" is the LPDIRECT3D9DEVICE that you had to set up to get anything working at all.
  3. Howdy, I'm at work right now, so I'll just give you a general idea of what you need to do rather than specific code. If it's too difficult to go from my rough outline to looking up the actual function names then perhaps you should consider whether you're diving into shaders a little too soon (I don't mean that in a bad way). 1. The parameters that you need to pass in are basically the globals at the top of the file. glowTexture, texTrans and pSize. The command you want is something like this: pShader->SetFloatParameter("pSize", 0.4f); where pShader is the compiled shader. 2. Your vertex buffer or model needs to contain at least the parameters mentioned in the vertex shader's input. Namely pos and texCoord. If it's your own vertex buffer, make sure that it contains this data (it doesn't need to be named the same, but it should be the same size (e.g. your vertex buffer's texCoord could be stored as float u; float v;)). If it's a model, you may need to clone the model to another vertex format and then add the data. This is a pretty big topic in itself. 3. Applying the shader. Again, off the top of my head: UINT passes = pShader->Begin(); for (UINT n = 0; n < passes; n++) { pShader->BeginPass(n); // Do your rendering here pShader->EndPass(n); } pShader->End(); good luck!
  4. Mijin

    Dumb matrix question

    I have a scene like this: object's (world) matrix: a known value, W camera's (view) matrix: identity What I then need to do is calculate a new view matrix, V, such that if I set the object's world matrix to identity, it will appear the same way on the screen as it did in the previous scene. I know there's a simple way to do this, but my brain seems to have been cryogenically frozen while I am still alive :)
  5. Quote: do you want to save a texture you've created in your simulation to a bitmap (or similar) ? Yes Quote: Use glGetTexImage. glGetTexImage...as simple as I would've expected it to be. Thanks Lord Faron. You kicked Google's ass today. For anyone else reading this because they're doing a similar thing you can also use glGetTexLevelParameteriv with parameter GL_TEXTURE_WIDTH / HEIGHT to work out the size of the buffer you need. Mijin
  6. Hello, I would like to be able to save out some OpenGL textures to files. But I don't know how to access a texture's pixel data. Yes I have Googled this first and all I could get were tutorials on the opposite: how to "save a texture to memory" or "read from a texture file" [totally] Is the only way to read from a texture to use glReadPixels with a quad covering the view? I hope not. thanks Mijin
  7. Hi, For an application that I'm working on, I need to do various texture transforms, blending etc and then calculate a total luminosity (a single scalar for the whole image). The transforms and blending I've managed to do fine on the GPU, but what about calculating the total luminosity? Is it possible to keep a running total within a fragment shader (somehow) or must I resort to reading the texture out using glReadPixels and calc the total application-side? Someone must have needed to do something like this before... cheers Mijin
  8. Doh! I scanned through the FAQ but must've missed that question. Oh well, at least I've already apologised...
  9. Apologies if this is a dumb question but I assure you I have looked elsewhere for a solution before posting here. How can I link applications that include extension functions such as glFramebufferTexture2DEXT? My <gl/glext.h> file includes prototypes for framebuffer functions, but it seem that my opengl32.lib file does not, and when I view opengl32.dll in dependency walker....there's no framebuffer functions in there either. All the 'solutions' on the web seem to say "just get the latest graphics drivers". Well, I have latest NVidia drivers for my GeForce 6800 GT, and I've installed them again to be on the safe side. My DLL didn't change, and I somehow doubt that a runtime drivers download would install the dev libs. Someone please help me understand how OpenGL installing works.
  10. Mijin

    Quaternion components?

    Just thought I'd say thanks for the help guys. Basically, the suggestion of storing angular momentum as a vector was enough. I'd already considered doing this but....when you've rewritten the same chunk of code many times you get reluctant to make changes until you're sure it will be an improvement this time [depressed]. Oh, and these are the core functions of the new code, in case anyone is interested. You won't be able to run them as is though, because they use my own struct AxisAngle and class Vector3, but you'll get the idea. // Convert the Quaternion target into a target angular momentum void Mechanics::CalculateDelta (AxisAngle & out, const D3DXQUATERNION & currentRot, const D3DXQUATERNION & targetRot) { D3DXQUATERNION delta; D3DXQUATERNION conjugateOfCurrent; // TargetRot = quatDelta * currentRot so... // quatDelta = targetRot * currentRot-1 D3DXQuaternionConjugate(&conjugateOfCurrent, &currentRot); delta = targetRot * conjugateOfCurrent; D3DXQuaternionToAxisAngle(&delta, (D3DXVECTOR3*)&out.axis, &out.angle); out.axis.Normalise(); } // Based on the desired angular momentum, the current angular momentum and the // ship's rotate speed, calculate the angular momentum to set this frame void Mechanics::ConstrainDelta (AxisAngle & outDelta, float & inOutThrust, const AxisAngle & targetDelta, const AxisAngle & currentDelta) { AxisAngle difference; Vector3 current; Vector3 target; // We need to calculate the axis and angle of rotation that will make currentDelta become targetDelta // So we work backwards, calculating the difference required from subtracting // current from target rot target = targetDelta.axis * targetDelta.angle; current = currentDelta.axis * currentDelta.angle; difference.axis = target - current; difference.Normalise(); if (difference.angle > inOutThrust) { difference.angle = inOutThrust; } // And the out variables can be written outDelta.axis = (currentDelta.axis * currentDelta.angle) + (difference.axis * difference.angle); outDelta.Normalise(); inOutThrust -= difference.angle; } Of the three prizes, you can have...my eternal gratitude. :)
  11. Mijin

    Quaternion components?

    I've been struggling to solve a quaternion problem now for days, if not weeks. Anyone who can help me with this will receive one of the following: money, sexual favours, eternal gratitude. 8) I'll start with as brief a problem description as I can and I'll clarify any unclear areas as necessary. ----- I'm working on a spaceship game. Each ship has an orientation described by a quaternion. Each frame a rotation difference (a 'delta') is applied to each ship's quaternion (new_orientation = old_orientation * (delta * elapsedTime)). While a ship's delta remains the same it will spin in the same direction at the same speed. It is the calculation of the delta that's the problem. The ship's mechanics need to have a degree of 'intelligence' to the force that is applied to angular momentum. I have a current rotation delta (Q_current), and a target rotation delta (Q_target) (both expressed as quaternions) and a constant; rotation acceleration (C_acceleration, scalar). I need to apply the following restrictions to Q_target before Q_target becomes the new delta (Q_new) for this frame: 1. The difference between Q_current and Q_target cannot exceed C_acceleration. Obviously the way I'm doing this by clamping against a dot product scaled by PI. 2. If Q_target is identity, then the C_acceleration force is used to 'cancel out' (dampen) Q_current. 3. If neither Q_current or Q_target is identity, then C_acceleration is still used to dampen Q_current. However, in this situation it only needs to dampen a component of the rotation. e.g. The axis of rotation for Q_current and Q_target is very similar, and they are in the same direction. Obviously here, we don't want to cancel out Q_current; we want to use C_acceleration to 'tip the axis' of rotation. 4. The C_acceleration force can be used to both dampen out Q_current, and apply a force in Q_target's direction, if necessary, in the same frame. 5. We don't want to overshoot Q_target. There is no requirement to use all of C_acceleration. --------- It is requirement 3 that is the main issue. I think I need to separate out the current delta into 'parallel' and 'remainder' components but I can't seem to come up with a working algorithm. Also, is the whole concept of representing a quaternion delta as a quaternion flawed? Should I be using differentials? Thanks in advance
  12. Mijin

    Difference between quaternions

    Oh, I see now. The relevance of what Anonymous Poster said didn't quite sink in. thanks Mijin
  13. Mijin

    Difference between quaternions

    Are you sure you've read the original post? OK, I'll rephrase it again so it's more clear: Given a quaternion Q_start and a quaternion Q_end, can a quaternion Q_delta be calculated such that Q_end is the product of Q_start and Q_delta. i.e. Q_end = Q_delta x Q_start ..and Q_delta is the only unknown
  14. I need to calculate the difference between two quaternions (as a quaternion). Let me clarify what I mean. Imagine we have a quaternion Qtotal that is the product of two quaternions Q1 and Q2 (Qtotal = Q1 x Q2). The operations required to perform this multiplication are common knowledge. But what if I know Qtotal and Q2 and what I want to know is the quaternion that Q2 would need to be multiplied by to become Qtotal? For this I kind of need to do a quaternion 'divide', but since the multiplication involves cross and dot products I don't see how it could be reversed. Any help much appreciated. --------------- BTW I'll post up application details/code if necessary. I just wanted to see first if there is a simple answer to the problem.
  15. Mijin

    Good starting maths book ?

    Sorry I can't help, but I thought I'd share that I also made the mistake of purchasing this book. I think I mis-read the title as "...for game programmers..." i.e. a book that helps improve programmers' maths. I'm not sure who the book is aimed at. Even people from a strong mathematical background, who are not intimidated by pages full of formal descriptions, would find the many proofs useless.
  • 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!