• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Erika Forgione

Members
  • Content count

    5
  • Joined

  • Last visited

Community Reputation

116 Neutral

About Erika Forgione

  • Rank
    Newbie
  1. [quote name='luca-deltodesco' timestamp='1349939391' post='4988994'] You should really just look up the DDA algorithm as previously suggested, it is 'far' simpler implementation than what you have described. [/quote] My description was very poor. The algorithm I wrote is really simple, but it requires that your ray is inside the cell that you're finding the neighbor of. Here's a simple version with a single value: [code] int sign = Math.Sign(direction) float distance; if(sign == 1) { distance = 1 - value; } else if(sign == -1) { distance = -value; } else { distance = infinity; } [/code] After you get the distance to the next face for each component (X, Y, and Z), you figure out which face you will get to first by dividing the distance by the direction. Once you know which face you will encounter first, you know which cell is the next cell. The problem I'm having is that I rely on the position of the ray to trace through the cells. Sorry that I'm being very vague, I have ADHD, and it's really hard for me to articulate what's going through my mind. All I see is a visualization of my algorithm, and I could give you the code, but it wouldn't make sense since there are a few things that you'll likely not know what's happening.
  2. I decided to just go ahead and write the hard, complicated code to find the next cell from the camera, and it works, but I'm having trouble tracing through the cells. My problem is a little simple. All I need to do is figure out how to properly get the position that the ray touched the next cell. I don't need the complicated math to do this, it's something I THOUGHT I would be able to do. The ray is positioned inside a cell, then I find the face that's closest, and I move into that cell, and move the ray along itself until it is against the edge of that cell. I figured that I could do this: ray.Position = ray.Position + ray.Direction * distanceNeeded, but I now realize why that won't work. if the ray is a simple ray with a position of (0.5,0.5,0.5) and a direction of (1.0,0.0,0.0), then the next position should be (1.0,0.5,0.5). The distance between the X component of the wall and the X component of the ray's position is 0.5f, it works just fine when you have those values, but when the direction has values for all three components, and it's normalized, you won't be able to get the same value by multiplication. So, really, what my new question is: How can I find the position that a ray collides with a plane? I just want to move the ray along itself until it is inside the next cell, but that's not working for some reason.
  3. For simplicity, since my voxels are 1x1x1 in size, I decided I could just move the ray by 1 unit, then get the cell that the ray is in, then check collision within that cell. Then I just keep incrementing it until I either reach my max length, or I find collision. Now I just need to remember how to collide a 3D ray with a 3D quad.
  4. I could write the algorithm to do this myself if I took the time to work it out, but I wanted to see if someone else has done it first. I'm working on a voxel engine for a game that I'm working on, and I need to trace a ray from the camera's position out a certain distance to try to find the nearest intersection. I was thinking of just taking the cell that the camera is in, then taking the direction, figuring out at what point the ray leaves the cell, then figure out what the next cell is that it will enter. I would keep doing this until I find an intersection. Does anyone have experience with this? Maybe you have an algorithm that can do just that?
  5. I have some modified Bresenham line code, but I can't seem to wrap my head around the concept of taking it into the third dimension. [CODE] typedef void (*pointCallback)(int x, int y); void DoLine(int startX, int startY, int endX, int endY, pointCallback callback) { int dx, dy; int sx, sy; int accum;//accumilator dx = endX - startX;//Start X subtracted from End X dy = endY - startY; sx = ((dx) < 0 ? -1 : ((dx) > 0 ? 1 : 0));//if dx is less than 0, sx = -1; otherwise if dx is greater than 0, sx = 1; otherwise sx = 0 sy = ((dy) < 0 ? -1 : ((dy) > 0 ? 1 : 0)); //dx = (dx < 0 ? -dx : dx);//if dx is less than 0, dx = -dx (becomes positive), otherwise nothing changes dx = abs(dx);//Absolute value //dy = (dy < 0 ? -dy : dy); dy = abs(dy); endX += sx;//Add sx to End X endY += sy; //x = 6 //y = 5 //accum = 3 //accum - 5 = 1 //startx + 1 = 1 //accum - 5 = -4 //accum + 6 = 2 //startY + 1 = 1 if (dx > dy)//if dx is greater than dy { accum = dx >> 1;//Accumilator = dx / 2 do { //Plot point callback(startX, startY); //Subtract dy from accumilator accum -= dy; //if accumilator is less than 0 if (accum < 0) { //Add dx to accumilator accum += dx; //Add sy to Start Y startY += sy; } //Add sx to Start X startX += sx; } while (startX != endX); } else { accum = dy >> 1; do { callback(startX, startY); accum -= dx; if (accum < 0) { accum += dy; startX += sx; } startY += sy; } while (startY != endY); } } [/CODE] All I can think of to do is parallel draw the line between the XY and YZ planes, but I'm not sure of how do go about doing that. Edit: I think I figured it out. I always figure out my problem right after I resort to asking for help >.< [CODE] public static void DoLine(int startX, int startY, int startZ, int endX, int endY, int endZ, Action<int, int, int> callback) { int dx, dy, dz; int sx, sy, sz; int accum, accum2;//accumilator dx = endX - startX;//Start X subtracted from End X dy = endY - startY; dz = endZ - startZ; sx = ((dx) < 0 ? -1 : ((dx) > 0 ? 1 : 0));//if dx is less than 0, sx = -1; otherwise if dx is greater than 0, sx = 1; otherwise sx = 0 sy = ((dy) < 0 ? -1 : ((dy) > 0 ? 1 : 0)); sz = ((dz) < 0 ? -1 : ((dz) > 0 ? 1 : 0)); //dx = (dx < 0 ? -dx : dx);//if dx is less than 0, dx = -dx (becomes positive), otherwise nothing changes dx = Math.Abs(dx);//Absolute value //dy = (dy < 0 ? -dy : dy); dy = Math.Abs(dy); dz = Math.Abs(dz); endX += sx;//Add sx to End X endY += sy; endZ += sz; if (dx > dy)//if dx is greater than dy { if (dx > dz) { accum = dx >> 1; accum2 = accum; do { callback(startX, startY, startZ); accum -= dy; accum2 -= dz; if (accum < 0) { accum += dx; startY += sy; } if (accum2 < 0) { accum2 += dx; startZ += sz; } startX += sx; } while (startX != endX); } else { accum = dz >> 1; accum2 = accum; do { callback(startX, startY, startZ); accum -= dy; accum2 -= dx; if (accum < 0) { accum += dz; startY += sy; } if (accum2 < 0) { accum2 += dz; startX += sx; } startZ += sz; } while (startZ != endZ); } } else { if (dy > dz) { accum = dy >> 1; accum2 = accum; do { callback(startX, startY, startZ); accum -= dx; accum2 -= dz; if (accum < 0) { accum += dx; startX += sx; } if (accum2 < 0) { accum2 += dx; startZ += sz; } startY += sy; } while (startY != endY); } else { accum = dz >> 1; accum2 = accum; do { callback(startX, startY, startZ); accum -= dx; accum2 -= dy; if (accum < 0) { accum += dx; startX += sx; } if (accum2 < 0) { accum2 += dx; startY += sy; } startZ += sz; } while (startZ != endZ); } } } [/CODE]