• 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.

howie_007

Members
  • Content count

    313
  • Joined

  • Last visited

Community Reputation

285 Neutral

About howie_007

  • Rank
    Member

Personal Information

  1. Looks cool!
  2. That helps because I didn't know what the tangent was for.   I've analyzed the code and simplified it. Below is the final modified version. Let's look at it line by line.   First useless line. const float pi = 4.0f*atanf(1.0f); All this does is give us the value of PI. math.h has a #define you can use so this is unnecessary. As you'll see in the finial code, many things were unnecessary.   Next line. const float aspect = (float)(m_renderbufferWidth) / (float)(m_renderbufferHeight); This give us the aspect ratio of the screen. Not sure why this is needed for the x coordinate and not the y. I think it's magic.   Next Two lines. const float fx = 2.0f * ((float)(x) / (float)(m_renderbufferWidth - 1)) - 1.0f; const float fy = 2.0f * ((float)(y) / (float)(m_renderbufferHeight - 1)) - 1.0f; This converts screen coordinates from a top/left orientation to a center screen coordinates but there's a little more to this then that. 1) Subtracting the width and height by one. The reason you do this is because resolution sizes are usually all even numbers. For example, a resolution of 1280x720 there is no center pixel or a pixel at 0. The other reason this could be is that you need a value of base 0, as if this was an array and w/h represents the total number of elements. 2) x/y divied by w/h. This gives you a normalize value of the point on your screen. In other words, a value from 0 to 1. 3) 2.0f *; not entirely sure what this is doing and why it is needed. 4) The last - 1.0f flips the sign.   Second useless line const float y_fov = pi/4; // pi/4 radians = 45 degrees This takes PI and divides it by 4 to give us 45 degrees in radians. This is unnecessary.   Modified line. const float tangent = tan(y_fov / 2.0f); This divides the 45 degrees by 2 to give use 22.5 degrees in radians. This can be simplified by plopping a number in tan.   I know what the rest is doing, I just don't understand why it works. /************************************************************************ * desc: Convert 2d screen coordinates to 3D perspective space ************************************************************************/ void Convert2Dto3D( float & destX, float & destY, float x, float y, float width, float height ) { const float aspect = width / height; // Convert upper left 0,0 to center screen 0,0 coordinates const float fx = (2.0f * (x / (width - 1))) - 1.0f; const float fy = (2.0f * (y / (height - 1))) - 1.0f; // (pi/4 radians = 45 degrees / 2) or ((pi/4) / 2)) const float tangent = tan( 0.392699082 ); // Project x,y to a z plane of 1 destX = aspect * tangent* fx; destY = -tangent * fy; } // Convert2Dto3D
  3. done! You have your up vote.   I wish I could look at this code and know what it's doing. If anyone can explain it, please do.
  4. Thank you guys for your help!   Taby, thank you for posting the code. It works GREAT!   All I had to do was multiply the final X and Y values by a positive z order.   I couldn't be more happy! There's no way I would have been able to write that code. Taby, you are Awesome!
  5. I want to be able to click on the screen and place a box at that spot in perspective 3D space. I would need to give the box the offsets in world view. The camera is at 0,0,0. In addition to the screen coordinates where 0,0 is the center of the screen, I also know the z order of where I want to box to go. Say -150   I've been struggling with this problem for a day now and google searches are not helping. Thought I could solve it with simple tri which is all I'm good at.   Can anyone solve this?  
  6. As a side note, std::future will not build on armeabi but will build on armeabi-v7a.   I'm trying to use std::packaged_task but it breaks my build in an odd way. My app will run on the phone but will lockup before it even gets near the code using the std::packaged_task. I can tell this because there is a graphic that will show before getting into the main game loop and if I put a delay as the first line in main, I'll never see the graphic. Even if I put a break point on the below code, it never get's hit.   Below is some example code that will cause the build to lock up before the code reached that point. Just the fact that the code is present somewhere seems to cause this problem.   std::packaged_task not ready for prime time on NDK 10? void CMenu::DoTransform() { if( m_visible ) { // Test code auto task = [this] { this->Transform(); }; std::packaged_task<void()> package( task ); package(); //Transform();
  7. As far as I know, the possible native build options in Application.mk are APP_ABI := armeabi armeabi-v7a x86   Do you really need to build all three? Will one do for all Android phones?
  8.   Saying the camera is at 0,0,0 is a bit misleading. In computer graphics, everything is a vector and vector math requires that the origin be 0. It's no more complicated then that. The camera, which is nothing more then a matrix, is the translation and rotation from 0,0,0.
  9. I'd post some code but my stuff is optimized so it wouldn't make any sense. I'm sure there's examples online (and DirectX SDK) for this but here's the over view in a nut shell.   First you want to compute a bell curve based on the number of samples that you want to use for your blur. You can use hard coded numbers for this but computing your own bell curve will allow you fine tune it to your needs. All we care about is half the bell curve because this is your target pixel and the number of samples taken. These values are your weights. Target pixel plus half the number of samples. We can now reused these samples for the other side of the target pixel. X = target pixel.   +++++X+++++ = 1.0   In the example above, there is 11 weights. If you were to add them all up, they would equal 1.0. You use the same array of weights to do the horizontal and vertical blur pass. At this point you simply multiply the sampled pixels by their respective weights to calculate the new color of the target pixel.   As stated above, this is a two step process and you'll need one additional buffer to complete the process. This assumes you're using a back buffer. Otherwise you'll need two buffers depending on how you are implementing it.   First pass - horizontal: Sample the values from the back buffer and write the new pixel value to the extra buffer. Second pass - vertical: Sample the values from the extra buffer and write the new pixel value to the back buffer.   That's it in a nut shell. There's optimizations you can do like use two smaller buffers to do the blurring. Scale it down to a smaller buffer, blur between the two buffers, scale back up to the original size.
  10. I tried messing with it again and now the __android_log_print is working. these tools...
  11. I'm trying to send log messages so that I can see the output in LogCat via Eclipse. I tried it with the Android and SDL call but nothing shows up in Log Cat. I set the filter to "verbos" or "debug" but none of the information is displayed.   Is there a trick to this or am I doing something wrong.   Had to apply a fix to Eclipse so that it would show all the LogCat tabs so I do see all the info. void CStatCounter::IncCycle( SDL_Window * m_pWindow ) { // These counters are incremeented each game loop cycle so they can // be placed here in this function because this function is also called // each game loop cycle m_elapsedFPSCounter += CHighResTimer::Instance().GetFPS(); ++m_cycleCounter; // update the stats every 500 miliseconds if( m_statsDisplayTimer.Expired(CTimer::RESTART_ON_EXPIRE) ) { // Show the output #if defined(__ANDROID__) __android_log_print(ANDROID_LOG_DEBUG, "Lap Cat Games", "%s", "Test Message"); #else if( !CSettings::Instance().GetFullScreen() ) SDL_SetWindowTitle( m_pWindow, GetStatString().c_str() ); #endif // Now that the stats are displayed, we can reset out counters. ResetCounters(); } } // HasCycleCompleted or void CStatCounter::IncCycle( SDL_Window * m_pWindow ) { // These counters are incremeented each game loop cycle so they can // be placed here in this function because this function is also called // each game loop cycle m_elapsedFPSCounter += CHighResTimer::Instance().GetFPS(); ++m_cycleCounter; // update the stats every 500 miliseconds if( m_statsDisplayTimer.Expired(CTimer::RESTART_ON_EXPIRE) ) { // Show the output #if defined(__IPHONEOS__) || defined(__ANDROID__) SDL_LogDebug( SDL_LOG_CATEGORY_RENDER, "%s", GetStatString().c_str() ); #else if( !CSettings::Instance().GetFullScreen() ) SDL_SetWindowTitle( m_pWindow, GetStatString().c_str() ); #endif // Now that the stats are displayed, we can reset out counters. ResetCounters(); } } // HasCycleCompleted
  12. I'm only setting it in the init now. My stencil needs at the moment are very simple but I can't see needing to do more at this time.   The way to think of this is the glStencilMask() is like glClearColor, you're telling OpenGL what value to use when clearing the stencil buffer, just like the color or depth buffer. This all happens when glClear is used. Example: glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT )   See my adjusted code below. /************************************************************************ * desc: Init the game ************************************************************************/ void CBaseGame::Init() { // Init the clear color glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Init the stencil clear mask based on the bit size of the mask // Stencil buffer can only be 1 or 8 bits per pixel if( CSettings::Instance().GetStencilBufferBitSize() == 1 ) glStencilMask(0x1); else if( CSettings::Instance().GetStencilBufferBitSize() == 8 ) glStencilMask(0xff); // Cull the back face glFrontFace(GL_CCW); glCullFace(GL_BACK); glEnable(GL_CULL_FACE); // Enable alpha blending glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Make the zero texture the active texture glActiveTexture(GL_TEXTURE0); // Show the window CDevice::Instance().ShowWindow( true );     if( CSettings::Instance().GetClearTargetBuffer() )         m_clearBufferMask |= GL_COLOR_BUFFER_BIT;     if( CSettings::Instance().GetEnableDepthBuffer() )         m_clearBufferMask |= GL_DEPTH_BUFFER_BIT;          if( CSettings::Instance().GetClearStencilBuffer() )         m_clearBufferMask |= GL_STENCIL_BUFFER_BIT; // Display a black screen glClear( GL_COLOR_BUFFER_BIT ); SDL_GL_SwapWindow( m_pWindow ); } // Init
  13. Thanks frob but I found the problem (face palm).   I was setting glStencilMask() before and after the render to the stencil buffer. I found some info about how this should be set before the stencil buffer is cleared and in many cases, only needs to be set in your init with all your other OpenGL settings on start up.   My implementation was from some stencil buffer demo but worked fine in WIndows and Linux. Odd.
  14. Got my game engine to build and run on the Android over the week end. It also builds and runs on Windows and Linux.   Is there some extra step to get stencil buffering working? Same code works as expected on WIndows and Linux.