• Content count

  • Joined

  • Last visited

Community Reputation

767 Good

About ajas95

  • Rank
    Advanced Member
  1. We just got a main Feature of the Week from Google Play, and the #1 staff pick, w00t! (and #2 for tablets) https://play.google.com/store/apps
  2. So a friend and I (Emeyex, another long-time gamedev.net poster) made this game-- he wrote the engine and gameplay, and I wrote the Android port, and my 2 other friends made the levels and art. It's a fast-paced and very pretty Tower Defense game, and free to play! Download it and let me know what you think! [url="https://play.google.com/store/apps/details?id=project.android.ftdjni"]https://play.google.....android.ftdjni[/url] [url="https://play.google.com/store/apps/details?id=project.android.ftdjni"][img]http://i48.tinypic.com/2h80qom.jpg[/img][/url]
  3. First you need to construct the world matrix for your "UCS" transform. You need the Z axis which can be found by taking the cross of X and Y, and then arranging them as columns in a 4x4 matrix (with translation in the last column). so then you have: 0.9644 0.8617 -0.029 438.8587 0.2481 0.5029 0.0131 180.6440 0.0913 0.0679 0.2712 0.0 0.0000 0.0000 0.0000 1.0 You're looking to transform the point in world-space by the INVERSE of this matrix to go into UCS space. To invert a 4x4 matrix that has only rotation and translation, you transpose the 3x3 portion which is the rotation, and then multiply the negative translation by that transposed 3x3 matrix and those combine to yield the inverse. So you multiply your point by the resulting matrix: 0.9644 0.2481 0.0913 -468.053 495.835 0.8617 0.5029 0.0679 -469.010 * 203.1717 -.0290 0.0132 0.2712 10.374 43.2574 0.0000 0.0000 0.0000 1.0 1.0 and that will give the point in the local coordinate system.
  4. Convert UV coord to 3d position

    Okay, I think I know how to do this. Roughly, first treat the UVs of the vertices as a 2d space, and find the barycentric coords of the input UV. This gives an output UV s.t. v0.uv + v1.uv*outU + v2.uv*outV = inUV then outUV can be applied to the vertices positions like: outPos = v0.xyz + v1.xyz*outU + v2.xyz*outV and that's that. So just need the 2d triangle barycentric calculation.
  5. So, I can't seem to figure this one out for some reason. I'm sure the answer involves solving a simple determinant or something similar to moller-trumbore ray/tri intersection but in reverse! Anyway, say I have a triangle and the three verts have x,y,z position and u,v coords. Now say I have an input UV coordinate, how do I find the point in 3d space in the plane of the triangle for that UV coordinate, given the UV space defined by the verts? Thanks for any help.
  6. Freshman in college (advice)

    Haha! I will agree with trzy wrt Ironpoint (though Ironpoint has some very true things to say depending on who you are). It comes down to this... some problems are important to you, you work through the night and drain every ounce of your brain to solve them, and you work until you're convinced that every human on earth, if placed in your shoes, would quit. And that makes you go further until you have it working... or there is tomorrow day and night if you are lucky! Or... you can choose another path. It's a pretty clear split that lays at your feet.
  7. PS3 (going down???)

    I know one thing: I bought my sister a PS2 for xmas because... it's hard to say exactly. There are so many sweet games, you don't need HD, they're all priced reasonably, the slimline is so small and sexy, plays DVDs, networking built in, it's pretty cheap, more games coming. In some respects like the Wii, except half the cost. There are more games, better games, at less than half the price. Folks who enjoy their XBox 360 seem to think that Halo 3 will be a huge attraction to people beyond those that own Halo 2 and Halo 1... and who don't already own an XBox 360. That's pretty unlikely. Next-gen all around has exhausted its current pricing.
  8. Happy Valentine's Day!

    yom tov rebbe valenstein. I've learned this: At least write a card. You have feelings and you can write and it costs nothing. Seriously, if you can't write a good card once a year, you probably don't deserve to be loved ;) Hey, someone has to say it.
  9. Unity avoiding virtual functions

    Hi ToohrVyk, You should understand that while "last-gen" consoles had a piddly, measly I-Cache size of 16kb, after 6 years of technological breakthroughs our monster-sized "Next-Gen" I-cache is a whopping 32kb (shared between 2 hardware threads, just to show it is a really poor improvement). And the cache-line is quadrupled from 32 bytes to 128. So grabbing a few bytes here and there randomly, like accesses into vtables, or even when the vtable pointer itself may be unfortunately positioned... it can be really bad. There just isn't enough wayism in the cache to cover the wayivity of tendrils thrown out from virtual functions. Still, toohrvyk, I have myself written almost exactly your code into games that have shipped on three platforms! I felt really guilty at the time, it looks like a huge hack... But the client just includes your header, and doesn't even realize it's getting the platform-specific version rather than just an interface. And just for debugging purposes, a flip in the typedef gives the "reference version" platform-agnostic C code to test against the 3000 lines of vector assembly version. I'm glad someone else thought of the same solution to a weird problem. [Edited by - ajas95 on January 30, 2007 2:22:15 AM]
  10. Tetris Programming?

    Hi Strass150, Tetris is a good place to start. At least, it was my first game of any substance because it was my favorite game in high school (we're talking 13h days... :) Anyway, here is kind of the order I did things. 1) draw one brick square, solid color. const int BRICK_WIDTH = 9; const int BRICK_HEIGHT = 10; void drawBrick( int xCoordinate, int yCoordinate, int color ) { for( int y = 0; y < BRICK_HEIGHT; y++ ) for( int x = 0; x < BRICK_WIDTH; x++ ) PlotPixel(x,y,color); } 2) draw a darker line near the left and bottom to look more 3d. 3) draw 4 such bricks in a shape like a tetris block, positioning by hand. 4) draw 4 bricks based on a little piece of C code like int brickPos[4][2] = { {0,0}, {1,0}, {1,0}, {1,1} }; // square block for( brickIdx = 0; brickIdx < 4; brickIdx++ ) { drawBrick( brickPos[brickIdx][0] * BRICK_WIDTH, brickPos[brickIdx][1] * BRICK_HEIGHT, YELLOW ); } 5) rotate a block through its positions: // L-block in all four rotations int brickPos[4][4][2] = { { {0,0}, {0,1}, {1,1}, {2,1} }, { {1,0}, {1,1}, {0,2}, {1,2} }, { {0,0}, {1,0}, {2,0}, {2,1} }, { {0,0}, {1,0}, {0,1}, {0,2} }, }; int rotationIdx = 2; // rotated twice for( brickIdx = 0; brickIdx < 4; brickIdx++ ) { drawBrick( brickPos[rotationIdx][brickIdx][0] * BRICK_WIDTH, brickPos[rotationIdx][brickIdx][1] * BRICK_HEIGHT, YELLOW ); } 6) Same for all seven blocks. 7) Position a block within the well. int rotationIdx = 2; // rotated twice int wellPos[2] = { 3, 5 }; // three blocks over, 5 down for( brickIdx = 0; brickIdx < 4; brickIdx++ ) { drawBrick( (wellPos[0] + brickPos[rotationIdx][brickIdx][0]) * BRICK_WIDTH, (wellPos[1] + brickPos[rotationIdx][brickIdx][1]) * BRICK_HEIGHT, YELLOW ); } 8) Actual game is now starting... when a block lands, assign its brick positions into the well. const int WELL_WIDTH = 10; const int WELL_HEIGHT = 23; int Well[WELL_HEIGHT][WELL_WIDTH] = { {0} }; void brickLanded( int brickPos[4][2], int wellPos[2], int color ) { for( brickIdx = 0; brickIdx < 4; brickIdx++ ) { Well[wellPos[1] + brickPos[brickIdx][1]] // y coordinate in well [wellPos[0] + brickPos[brickIdx][0]] // x coordinate in well = color; } } 9) Check to see if a block can move down. bool canMoveToPos( int brickPos[4][2], int wellPos[2] ) { for( brickIdx = 0; brickIdx < 4; brickIdx++ ) { if( Well[wellPos[1] + brickPos[brickIdx][1]] // y coordinate in well [wellPos[0] + brickPos[brickIdx][0]] // x coordinate in well != 0 ) return false; // this brick would collide with one already in well. } return true; // no collisions, so new position is okay. } bool canMoveDown( int brickPos[4][2], int currentWellPos[2] ) { int newWellPos[2]; int newWellPos[0] = currentWellPos[0]; // x-coordinate the same int newWellPos[1] = currentWellPos[1] + 1; // y-coordinate bumped down one return canMoveToPos( brickPos, newWellPos ); } 10) Check for rotations also. bool canRotate( int brickPos[4][4][2], int currentRotation, int currentWellPos[2] ) { return canMoveToPos( brickPos[(currentRotation 1)%4], currentWellPos ); } 11) ..........
  11. I'll amend what I wrote by mentioning that the compiler can use the *ss form of instructions to carry out the fp math on your vector component. I'm pretty sure it doesn't, but... It could generate a shufps or movhlps to grab your component into the SSE prefered slot, manipulate it via addss mulss etc, and shufps it back into the original vector. It all stays in SSE registers so no penalties I mentioned before apply, and it would be much faster. If I see a compiler do this... maybe that day I will stop writing assembly :)
  12. Hi janta, You're pretty much right on. You don't have to worry about incorrect code being generated, but it will move your xmm register back out to the stack, then load your component into floating point registers to do some math, then store back out to the stack, and then finally reload the xmm register with a new value. If you care at all, I'll explain why this is worse than it sounds. Now, the big problem is that store-forwarding doesn't work for you in this case. Store-forwarding can apply to the case where you store out data from a register to memory and immediately load it back. In general, stores don't go directly to L1, but instead get pushed out to a little (generally cache-line size) store queue. The reason is that you typically have a bunch of stores in a row, and it's better for the memory architecture to flush that queue all out at once instead of a few bytes per instruction. With store forwarding, special logic detects the reload case and allows the processor to grab the value on its way to the store queue instead of going back to memory. Unfortunately, if the load overlaps the store but doesn't use the same alignment, it breaks the store-forward. It's not clear to me if store-forwards even work on the xmm registers in the first place! The end result is that you stall first waiting for your store queue to get flushed back to L1, then you get hit again on the same issue when reloading that xmm register. That penalty... I'm not sure if there's an official number, but in cases where I hit it, it was like 20 cycles.
  13. Hi, this page may be helpful to you. Particularly: "The sizeof value for any structure is the offset of the final member, plus that member's size, rounded up to the nearest multiple of the largest member alignment value or the whole structure alignment value, whichever is greater." This leads me to believe that by declspec(align())ing your class will change its size, so as to be a multiple of your alignment... which should make your array sizing work implicitly. As far as reasons why a structure is not an expected size... you know that vtable may not be 4 bytes (in cases of multiple virtual inheritance, for instance), and that if RTTI is turned on, that will get some bytes too. I suspect RTTI may well be your problem.
  14. Wow, such viciousness against C. I've tried the various streams for file I/O, but I always make it back to good old ftell, fseek, fwrite for exporting binary game data. Also the printf-style functions are more convenient, IMO. If I want to only output 2 decimals of precision or properly display a pointer address, it's just %4.2f or %.8x, done. I'm not saying this because of an affinity for any language... simply what I've found most convenient in the real world. Someone made the point that NULL-terminated strings are stupid. Well that's true without a doubt. std::string is no picnic, though. At least for internal use, those str* functions are pretty succinct and even have range-checked versions. Seriously, what is the best way to implement strtok with std::string?
  15. Sampling Points on a Triangle?

    for 2 positive random values u,v where u + v <= 1.0 : P = v1 + (v2-v1)*u + (v3-v1)*v