Advertisement Jump to content
  • Advertisement

Steven Ford

Member
  • Content Count

    68
  • Joined

  • Last visited

Community Reputation

150 Neutral

About Steven Ford

  • Rank
    Member

Personal Information

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Steven Ford

    Learning DX11 from DX12 book - is it possible?

    I'm going to play devil's advocate here and argue that both the DX11 and DX12 interfaces will stay alive and separate for different use-cases. DX12 gives you access to greater performance possibilities, but also the rope to hang yourself with. Whereas DX11 is going to be the standard approach for areas where you don't need access to those greater performance possibilities. Naturally, if you're talking ray tracing, then you're also talking about needing to have high performance requirements and so you'll have to get used to DX12 - unless MS come up with a simpler access layer of course πŸ™‚ In terms of books and the original question - no. Either use the rastertek tutorials: Rastertek - DX11 series 2 Rastertek - DX11 (original) or Luna's book. As an aside, you might also want to try 'Game Engine Architecture' by Jason Gregory, but that's less for DX11 and more for extending your knowledge afterwards. Steve
  2. Steven Ford

    Can't properly rotate in my sprite batch.

    Hi @Midnightas, on your code, you're applying the same value for the + and the - steps from the location; you'll need to do the transformation separately for each point of your square. If you draw it out on paper, you'll see what I mean (I'm using the DX Toolkit's spritebatch code for my sprite batch so I don't have the code handy sorry). Steve
  3. Steven Ford

    R16_FLOAT, SampleCmp and CheckFormatSupport

    Hi @acerskyline, Looking at the documentation for CheckFormatSupport - MSDN, I'm not convinced that you're using it correctly. You're looking at the result of the call and not the value which is written into pFormatSupport. To me, you're only checking if there's a catastrophic failure in the call to get the information, you're not checking that the actual field is supported. Regards Steve
  4. Hi @Josheir, I don't know the answer here (I'm using UWP to deliver and was hoping that I'm either using such standard libraries for my Win32 builds or that Steam, if I ever get round to releasing it on there, does the packaging for me). However, I just wanted to say thanks for following up your question with your answer. It's a habit that more of us should get into! πŸ™‚ Regards Steve
  5. Steven Ford

    Using windows messages for camera movement

    Completely seconding the comments from @fleabay and @0xnullptr ; the only addition I'd make is that I put a class wrapper around the array and let that handle whether there's been a repeat (see attachments) (note that within the main game loop, you then need to call ->NewFrame(frameTime).. Then you can use the same code abstraction for both Win32 and UWP. The only requirements are to handle the WM_KEYDOWN / WM_KEYUP messages for Win32 and in the UWP version: void handleKeyDown(CoreWindow^ /* window */, KeyEventArgs^ args) { int key = (int)args->VirtualKey; _keyboardManager.RegisterKeyDown(key); args->Handled = true; } void handleKeyUp(CoreWindow^ /* window */, KeyEventArgs^ args) { int key = (int)args->VirtualKey; _keyboardManager.RegisterKeyUp(key); args->Handled = true; } // In SetWindow window->KeyDown += ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &ViewProvider::handleKeyDown); window->KeyUp += ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &ViewProvider::handleKeyUp); Regards Steve KeyboardManager.cpp KeyboardManager.h
  6. Yep - although given the amount of time that I've already spent on that particular function rather than actually doing anything more useful / interesting on the game, I'm inclined to leave it as it is for now. I need to do a similar sort of exercise for identifying the following collisions: line -> circle intersections (for weapons hitting semi-circular ground turrets - the other part of the circle is within a wall so I don't need to worry that much. moving circle - line intersections (for the ship hitting walls / game objects) moving circle - fixed circle intersection (for the ship hitting the aforementioned semi-circular ground turret) Once I've done that, then I'll do a little blog post with a summary of the discussions. In terms of the special casing for vertical lines, as I already separate out point interactions, then the easiest way would be to simply rotate everything through 90 degrees so that I never have to handle vertical lines πŸ™‚ The biggest complexity in the algorithm that I can see is the need to handle the 3 possibilities when parallel lines overlap (line 1 starts in line 2, and then would hit the start and/or end). The real fun part would be to do a SIMD implementation of the code to get a speed up in the comparison code - although given the number of comparisons that I actually need to do, then that would be completely pointless! πŸ˜‰ Fun, but pointless πŸ˜‰ Dzieki. The basic idea is that you have to fly around an alien world in your space ship, there are tractor beams (which can either be destroyed or disabled by turning off the electricity supply), gates, ground turrets etc. and you have to explore the maze. The 'pick ups' will be survivors from another ship which previously crashed. At some stage I should probably look to convert my games from PC/X1 to Android - would get a much larger market!
  7. Hi @_WeirdCat_, yep, I should add some epsilon testing code, numerical noise is bad! For now, for your second comment, all my numbers are already within a range of 0-128 so there should be minimal accuracy issues there hopefully. Attached is the use-case for the collisions Note that before doing the line-segment interactions, I do a macroscopic bounding box test to avoid the calculations in the majority of cases. I might try to be a bit more detailed in the collision shapes (to reflect the non-pure rectangular nature of the tractor beams) but that can be later if it's necessary! Frame Time_ 16.6846ms (60.0349fps) 07_12_2018 16_32_20.mp4
  8. Yep; that's a relatively easy one, I was just calling it out explicitly to remind me to add it in my code πŸ™‚ Yep, so what I do is work out whether the start of line 1 is within line 2's range, and then, if it's not, calculate n1 for the start and end of line 2 and use the lowest valid value of n1 - i.e. which end would have been hit first. This has now all been implemented (see attached) and the explosions are now visually in the right place! Thanks again for all your help - much appreciated! template<class T = float> static bool DoLinesIntersect( T line1StartX, T line1StartY, T line1EndX, T line1EndY, T line2StartX, T line2StartY, T line2EndX, T line2EndY, T& line1Proportion, T& line2Proportion) { bool line1IsPoint = line1StartX == line1EndX && line1StartY == line1EndY; bool line2IsPoint = line2StartX == line2EndX && line2StartY == line2EndY; auto dx2 = line2EndX - line2StartX; auto dy2 = line2EndY - line2StartY; if (line1IsPoint && line2IsPoint) { // both points, just check if they're the same if (line1StartX == line2StartX && line1StartY == line2StartY) { line1Proportion = 0.0; line2Proportion = 0.0; return true; } return false; } if (line1IsPoint) { // line 2 must be a line... if (dx2 == 0 && line1StartX != line2StartX) return false; if (dy2 == 0 && line1StartY != line2StartY) return false; auto line2ProportionX = (line1StartX - line2StartX) / (line2EndX - line2StartX); auto line2ProportionY = (line1StartY - line2StartY) / (line2EndY - line2StartY); if (dx2 == 0) { line2Proportion = line2ProportionY; } else if (dy2 == 0) { line2Proportion = line2ProportionX; } else { if (line2ProportionX != line2ProportionY) return false; line2Proportion = line2ProportionX; } if (line2Proportion < 0 || line2Proportion>1) return false; line1Proportion = 0; return true; } if (line2IsPoint) { // Line 1 is a line though... return DoLinesIntersect(line2StartX, line2StartY, line2EndX, line2EndY, line1StartX, line1StartY, line1EndX, line1EndY, line2Proportion, line1Proportion); } // At this stage, we have 2 general lines and need to see if they intersect with each other... // // There are 3 possibilities: // 1. The lines are parallel to each other // 2. Line 1 is a vertical line (has to be separated out to enable the equations to be solved) // 3. they're general lines and there's a general solution auto dx1 = line1EndX - line1StartX; auto dy1 = line1EndY - line1StartY; auto a1 = line1StartX; auto b1 = line1StartY; auto a2 = line2StartX; auto b2 = line2StartY; bool line1IsVertical = dx1 == 0; if (line1IsVertical) { if (dx2 == 0) { // We have the even more special case that both lines are vertical hence this is similar to the parallel case if (a1 != a2) return false; // There are 4 options if we're in the same linear space: // 1. No overlap // 2. Initial overlap // 3. line 2 starts in line 1 // 4. line 2 ends in line 1 // // Note that #3 and #4 are both possible, at which point the lowest n1 should be selected auto n2Initial = (b1 - b2) / dy2; if (n2Initial >= 0 && n2Initial <= 1) { line1Proportion = 0; line2Proportion = n2Initial; return true; } auto n1Line2Start = (b2 - b1) / dy1; auto n1Line2End = (line2EndY - b1) / dy1; bool line2StartIntersects = n1Line2Start >= 0 && n1Line2Start <= 1; bool line2EndIntersects = n1Line2End >= 0 && n1Line2End <= 1; if (line2StartIntersects && line2EndIntersects) { line2StartIntersects = n1Line2Start <= n1Line2End; line2EndIntersects = !line2StartIntersects; } if (line2StartIntersects) { line1Proportion = n1Line2Start; line2Proportion = 0; return true; } if (line2EndIntersects) { line1Proportion = n1Line2End; line2Proportion = 1; return true; } return false; } // Check to see where we hit line 2 auto n2 = (a1 - a2) / dx2; if (n2 < 0 || n2 > 1) return false; // Check to see whether this would give a reasonable value for line 1 auto n1 = (b2 - (n2*dy2) - b1) / dy1; if (n1 < 0 || n1 > 1) return false; line1Proportion = n1; line2Proportion = n2; return true; } bool linesAreParallel = (dy2 - (dx2*dy1 / dx1)) == 0; if (linesAreParallel) { auto n2InitialX = (a1 - a2) / dx2; auto n2InitialY = (b1 - b2) / dy2; if (dx2 != 0 && dy2 != 0 && n2InitialX != n2InitialY) return false; auto n2Initial = dx2 == 0 ? n2InitialY : n2InitialX; if (n2Initial >= 0 && n2Initial <= 1) { line1Proportion = 0; line2Proportion = n2Initial; return true; } // Now, it's time to do the check for the line2Start and line2End and calculate accordingly T n1Line2Start, n1Line2End; { auto n1Line2StartX = (a2 - a1) / dx1; auto n1Line2StartY = (b2 - b1) / dy1; n1Line2Start = dx1 == 0 ? n1Line2StartY : n1Line2StartX; } { auto n1Line2EndX = (line2EndX - a1) / dx1; auto n1Line2EndY = (line2EndY - b1) / dy1; n1Line2End = dx1 == 0 ? n1Line2EndY : n1Line2EndX; } bool line2StartIntersects = n1Line2Start >= 0 && n1Line2Start <= 1; bool line2EndIntersects = n1Line2End >= 0 && n1Line2End <= 1; if (line2StartIntersects && line2EndIntersects) { line2StartIntersects = n1Line2Start <= n1Line2End; line2EndIntersects = !line2StartIntersects; } if (line2StartIntersects) { line1Proportion = n1Line2Start; line2Proportion = 0; return true; } if (line2EndIntersects) { line1Proportion = n1Line2End; line2Proportion = 1; return true; } return false; } // General solution time { // Calculate n2 line2Proportion = (b1 + (a2 * dy1 / dx1) - (a1*dy1 / dx1) - b2) / (dy2 - (dx2*dy1 / dx1)); if (line2Proportion < 0 || line2Proportion > 1) return false; // We hit within a reasonable region of line 2, now let's check for line 1 line1Proportion = (a2 + (line2Proportion*dx2) - a1) / dx1; if (line1Proportion < 0 || line1Proportion>1) return false; return true; } }
  9. Hi @Alberth, thank you very much, that explains it rather nicely and easily! I'm guessing that the 2 edge cases are: 1. Line 1 is vertical => can have a separate code path to check that 2. (dy2 - (dx2.dy1/dx1)) == 0 - If I'm correct, this means that the lines are running parallel to each other - again, I can have a separate code path for this. I'll get this implemented today and then hopefully I can have my pretty (well, by developer art standards) explosions in the right place!
  10. Hi all, thanks for the comments. The approach that I've been taking (as with @Alberth) is that each line can be described as: x = startX + lineProportion*dX y = startY + lineProportion*dY I can't use y = ax + b as this won't handle vertical lines. I'm clearly missing something when it comes to solving the equations for n1 and n2. It feels like there must be a simple closed form (i.e. not iterative) approach which can be used to solve the equations, but I'm drawing a blank. My main thought is to transform one of the lines into an axis aligned line by calculation the angle of one of the lines and then transforming all of the vectors by this angle and then I'd only need to solve one equation which should be easy. This feels like I'm over complicating efforts, especially when I look at @_WeirdCat_ code. If I'm reading it correctly, one takes the normal between the 2 vectors but then I get a little lost (it's been almost 2 decades since I studied this area ) @Zakwayda - in terms of complete reliability, I'm not massively bothered if there are some extreme edge cases which aren't covered, My collision boxes are slightly padded so it wouldn't be an issue in the main. I just want to make sure that the explosion graphics appear in the right place as at the moment, I display them where the projectile would have gotten to if nothing had gotten in the way which means that the animation sometimes starts within the walls rather than on the wall.
  11. Steven Ford

    Starting point for game editor

    HI @jjd, Echoing people's comments above, it would depend heavily on the type of game you're writing. My experience is with 2D games, this answer is focussed on them. Initially I used Tiled - Link. This is a brilliant tool which allows you to define tiles (hence the name) on a 2D grid as well as lay addition items not necessarily based off a grid. To use Tiled with game objects, you add these floating tiles (which can have arbitrary properties). Your resource pipe line can then load in the file definition (Tiled's XML file format is trivial to read) and then process it accordingly. I subsequent wrote my own (see below) for many reasons: 1. I wanted to 2. I wanted to have greater control over the properties of the game objects Point #2 was the most important thing for me as it made the tool more generally usable by non-specialists. It also allows you to edit more complicated items / specify dependencies and have them picked up in the tooling layer rather than the subsequent processing layer etc. The way I've written it is as a generic tile editor with the ability to add .net game objects (using reflection / plugins) to the levels. This way, I can use it for any future games within the same genre. This genericity added to the development costs of it, but proved to be useful for me with my 2nd game. Whether it's worth going to this extreme depends on you, your time budgets and your requirements. With hindsight (given it slowed me down in terms of development of the game by about a year if not longer) then I'd say that it wasn't and I would have been better off staying with Tiled for longer. I don't regret having the tooling now as I find it very useful, but... Note that I simplified migration matters somewhat by having the ability to write an importer for TIled files so that was all simple. If you're working as part of a team, do that approach. Hope this is vaguely helpful Steve
  12. Hi guys, I've got a little problem which is irritating me as there must be a simple solution but Google isn't necessarily being my friend right now. In my new game, I've got a set of projectiles for which I need to check for collisions with typically rectangular shapes (but which aren't axis aligned). My general approach is to create an axis aligned bounding box for both the projectile's movement and the target object. If there's a match on the broad phase, then I want to check whether the projectile collides with any of the edges of the collision and then report the first collision (i.e. if the projectile would have gone through multiple lines then I want to know the first collision so I can display the explosion animation in the right place). I represent my shapes as a series of line segments (there's a future question about colliding with semi-circles and circles, but that's later). Can anyone 'refresh my memory' on being able to test for the interaction of line segments? Thanks Steve
  13. Echoing @Finalspace's suggestion of Tiled (although admittedly I did get bored and wrote my own subsequently for other reasons), it's brilliant for being able to knock up 2D maps really quite quickly. The file format is simple to interpret in your own tooling subsequently. What I did was use Tiled to create the initial map, and then have a resource generation step (a custom MSBuild task) which loaded up the file, created the appropriate sprite sheets etc. and then outputted a file which could easily be consumed by my C++ layer. In my case, I had 2 layers: Pure background tiles Foreground tiles (Game Objects were handled separately) These tile layers were then stored in a simple array (offset = (y*width)+x) with zero meaning no tile, any other value being the tile id. At rendering time, I simply had 2 for loops (x and y) and wrote any tile to screen (the loop ranges were based off what was visible on screen) using the DirectX Toolkit. As @Finalspace says, get it working first, then worry about doing speed ups if you have to. Clearly you can pre-generate the DX11 command list etc. if you need to, but cross that bridge when you come to it. Note that on my tiles / sprite sheets, I made the conscious decision to handle overlays in the tooling and output a fresh sprite sheet each resource build. Depending on how much you share the sprites with other items in your games you may or may not want to do this. Either way, the principle holds true, you just store multiple values for each tile to allow for overlays etc. (or multiple layers)
  14. Steven Ford

    i need directions

    If you're interested in low level C++, then one thing which make the learning process simpler was to use the DirectX Toolkit as it provides easy ways to render 2D sprites. Once you're comfortable with that / how the GPU works, then you can do more experimental things. If you combine this with the templates here then you'll be fairly quick able to access a loop where you get given an instance of ID3D11DeviceContext* (which can be passed in to the DX Toolkit's SpriteBatch object) and then you're all set.
  15. Steven Ford

    New 2D Renderer d3d11 or d3d12

    Hi @Quat, my understanding is that you'll be able to get better potential performance using DX12 but you're also given enough rope to hang yourself / can get lower performance if you're not careful. Unless you truly need the power of DX12, then I'd be inclined to stay with DX11 for sheer simplicity's sake if nothing else.
  • 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!