Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

133 Neutral

About Damocles

  • Rank
    Advanced Member
  1. Excellent, thanks Lauris. I appreciate the detailed explanation.
  2. I'm trying to place my game camera so that the resulting view for the player will encompass a selection of points in world space. I have calculated the central averaged position of the points, worked out the unit vector in which I want the camera to travel away from the central point, but I can't seem to quite get my head around the required distance to move the camera. I can't figure out how to take the FOV of the camera, the list of points, and the facing angle/projection matrix of the camera to determine how far back I need to pull the camera. I'm currently thinking that I might be able to reverse the 'is point on screen' equation using the cameras projection matrix, then get a required distance for each point and use the biggest distance. I'm just not sure how to reverse that equation - or if I'm even on the right track here. Can someone point me in the right direction please?
  3. [font=arial,helvetica,sans-serif]Thanks DvDmanDT, [/font]it's working great now. Not as nice and clean as passing a ref parameter, but at least it's not as long winded as I thought it was going to be.
  4. I've not read much about delegates, but from what I have read, would I have to make a new delegate every time I want to animate a variable? so instead of writing: animateVar(someVar, start, end, time); I would have to write: animateVar(void delegateName(parm1) {instance.someVar = parm1; }, start, end, time); Is that along the right lines? Seems like an overly complicated way of updating a variable.
  5. I'm trying to move from C++ to C# because Unity3D uses C# fairly extensively. So far so [s]horrific[/s] good. Unfortunately, I have hit a problem - Unity does not allow unsafe compiling if you want to publish using the Unity web player. This means no pointers. I feel naked and alone. In particualr, one set of methods I used extensively in past C++ projects is a generic single-variable animation system, which would let me make a call like: animateVar(&someVar, startValue, endValue, animTime); The function would add the reference to a list, and another function would regularly update the values, setting the variable's new values using the stored pointers. I tried this in C# using ref, but there seems to be no way to store the reference to an integral type, meaning there's no way to update the variable. How could I achieve this in C# without pointers?
  6. I have a small memory leak in my game, as reported by PIX and D3DX. It's a single, small vertex buffer of data, but here's the thing - it gets released. I have tracked this variable from start to finish, and it only ever has 4 things happen: the buffer gets created it gets locked it gets unlocked it gets released There's only ever one pointer to the buffer and that gets released. Yet D3DX and PIX are reporting it as a leak. I'm completely stumped here - I have no idea why it would not be released. Debug runtimes don't give any errors or warnings during creation/destruction of the buffer, and it's definitely unlocked with only one reference to it at release time. Anyone have anything similar happen to them before? Or maybe you have some ideas to try out?
  7. This problem is driving me nuts. I'm making a system that creates low res copies of high res textures for low-memory systems. I am using D3DXLoadSurfaceFromSurface to copy mipmap surfaces from the high res texture into the low res texture to be used by the game. It all works fine except for this: Those horrible grey lines are created during the resizing process. The issue is - I'm not resiing the textures! I'm simply copying the mipmap surface levels appropriate for the size of the smaller texture. For example, if I load the high res 1024x1024 texture, and I want to size it to 512x512, then I'll copy surfaces 1 through numLevels into the new texture. The high res surfaces work great - no grey lines, not even in the distance geometry. So as far as I can tell the mipmaps themselves are good, but when they get copies into the new texture, they develop a transparent 1-pixel border around all edges. I tried copying the level 0 surface form the high res texture and using various filter types for the resizing, which does change the severity of the grey lines, but never gets rid of them. I don't know what else to try. Anyone have any idea how to get around this problem? Here's the code I use to load and resize (technically just copy) the surfaces: bool bShrinkIfDesired=false; if (strstr(filename, "interface")==NULL) bShrinkIfDesired=true; int divisor = 1; if (config->textureDetail!=3 && bShrinkIfDesired) { nml = -1; divisor = (config->textureDetail==2)?(2):(4); } // load hi-res version first HRESULT texLoadHR=D3D_OK; texLoadHR = D3DXCreateTextureFromFileEx(g->d3d, str.c_str(), 0, 0, nml, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, filt, D3DX_FILTER_LINEAR | D3DX_FILTER_MIRROR, 0, info, NULL, (bShrinkIfDesired)?(&d3dTextureHigh)&(*d3dTexture))); if (!FAILED(texLoadHR) && bShrinkIfDesired) { // creature texture ready for copying surfaces texLoadHR=D3DXCreateTexture(g->d3d, info->Width/divisor, info->Height/divisor, nml, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &(*d3dTexture)); if (!FAILED(texLoadHR)) { // copy surfaces IDirect3DSurface9 *surfHigh, *surfLow; int e = d3dTextureHigh->GetLevelCount(); int lowID = 0; for (int i=0; i!=e; ++i) { lowID = i + 3-config->textureDetail; if (lowID >= (int)d3dTextureHigh->GetLevelCount()) break; d3dTextureHigh->GetSurfaceLevel(lowID, &surfHigh); (*d3dTexture)->GetSurfaceLevel(i, &surfLow); if (surfHigh && surfLow) D3DXLoadSurfaceFromSurface(surfLow, 0, 0, surfHigh, 0, 0, D3DX_FILTER_NONE, 0); } } } }
  8. Damocles

    'Max' colour blending operation

    Thanks for the info. I eventually decided to make it work via shader, but now you say MAX blend op support is iffy on some hardware, I might just see if I can rework the effect to use additive instead. That will probably be less hassle than trying to second guess support or trawling through cheat sheets.
  9. I'm trying to get a blend mode where the source colour is multiplied by the source alpha, and the largest value of each rgb channel between the source and destination pixels is chosen as the result. I've been messing around with blend functions, but am not getting the results I desire. I thought this would work: d3d->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); d3d->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_MAX); d3d->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); d3d->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); but no dice - the source colours are not being multiplied by the source alpha value. The max op seems to work, but without the alpha blending of the source colour, it's useless to me. I've been playing aroudn trying all sorts of different blend combinations, but none of them seem to fit the bill. I figure I could achieve the result I want through a pixel shader, but I'm trying to use this blend mode with my particle system, and it'll be a royal pain to shoehorn it into the particles shader just to handle this one effect. So I'm hoping it's possible through blend functions. Anyone know what I'm doing wrong? Or know of a better way to achieve the desired result?
  10. Hi, I have an idea for a new control system that I'd like for users to be able to use in existing games. So I figure the best way to achieve this would be to somehow 'spoof' the messages from the controller (in this case a gamepad) so that DirectInput receives different messages. Unfortunately I have no idea if this is even possible or how to go about it. Has anyone tried something like this before? Am I wasting my time? If it is possible, got any tips on where to begin?
  11. Ah, of course. I should have thought of that *slaps self*. Thanks taz.
  12. Using the WM_NCHITTEST WndProc message, I'm trying to determine if the mouse is inside the actual drawing area of the window, or on a board/caption/etc. So I use this code in my WndProc: case WM_NCHITTEST: { static LRESULT r; r = DefWindowProc(hWnd, WM_NCHITTEST, wParam, lParam); if (r==HTCLIENT && r!=HTCAPTION) { app->mouse->bInsideClient=true; } else app->mouse->bInsideClient=false; return r; } break; I set a break point on the line that sets bInsideClient to false to test this, and it works on everything except the caption. Mousing over the caption does not return a HTCAPTION result. I even tried adding code like this: if (r==HTCAPTION) DebugBreak(); inserted into the above, but it never triggered the debugbreak. Anyone have any idea why it's never receiving a HTCAPTION result?
  13. Shouldn't the d3dx9.dll file already be installed on the laptop as part of DirectX9.0c? She's running Vista Home, probably with SP1 (she has auto update on) so DX9 should be installed by default (and she can run other DX9 games no problem). So I'm probably barking up the wrong tree anyway. When I get the chance I'll try dropping the d3dx9.dll into the game folder on her laptop just to test and see if that is the problem or not.
  14. I vaguely remember something about DX9 and one of the D3DX components changing from a lib to a dll. Is that the problem here do you think? Would shipping the dll in the game folder work? I can't remember what the dll was off the top of my head, so I may be barking up the wrong tree.
  15. This one really does have me stumped. I've tried both precompiled and dynamically compiled shaders - same problem, no shader created, no error returned. So I tried running fxc.exe and compiling the shader on the laptop, and nothing happened. No errors, no compiled shader output, nothing. Nada. Zip. bupkiss. It just gave me back the dos prompt without so much as a copyright notice. I simply do not understand what could be causing this. To get no output at all and for all return values to be ok, but still fail is crazy.
  • 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!