• 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.
Sign in to follow this  
Followers 0
Werner291

A ring of vertices perpendicular to a given direction

2 posts in this topic

Good afternoon,
 
I'm currently developing a game for Android using OpenGL ES 2.0 where users fly through a tunnel, the goal being not to hit the walls.
 
The tunnel is randomly generated and it is composed of a series of interconnected rings. The rings are supposed to be perpendicular to the direction of the tunnel. See this screenshot when things go well:
 
 [spoiler]tunnelflyer.png[/spoiler]

Things still look good in this screenshot, but as the tunnel drifts away from the Z axis, the rings do not rotate with it correctly, causing this nice round tunnel to gradually flatten out then turn into an unmanageable mess of lines.
 
Currently, here's the code that I use to generate the rings: (Java)
// Constructor
public TunnelSection(GameManager myRenderer, TunnelSection previous) {
        
        sectionTransform = new float[16];
        
        float ring_radius =  RING_MIN_RADIUS + (float)(Math.random()) * (RING_MAX_RADIUS - RING_MIN_RADIUS);
        
        if (previous != null){
            mDirection = previous.mDirection;
            
            Quaternion randomRot = new Quaternion();
            randomRot.fromAngles(((float)Math.random()-0.5f)/5f, ((float)Math.random()-0.5f)/5f, ((float)Math.random()-0.5f)/5f);
            mDirection = mDirection.mult(randomRot);
            mDirection.normalizeLocal();
            
            Vector3f delta = mDirection.mult(Vector3f.UNIT_Z);
            
            mPosition = new float[]{previous.mPosition[0]+delta.x, previous.mPosition[0]+delta.y, previous.mPosition[2]+delta.z};
        }
        else {
            mDirection = Quaternion.DIRECTION_Z;
            mPosition = new float[]{0,0,0};
        }
        
        ringCoords = new float[(COORDS_PER_VERTEX) * RING_VERTICE_COUNT];
        
        Vector3f vertLocal = Vector3f.UNIT_X;
        
        for (int itr=0;itr<RING_VERTICE_COUNT;itr++){
            vertLocal.set(android.util.FloatMath.sin((float)Math.PI * 2f * ((float)itr/(float)RING_VERTICE_COUNT )) * ring_radius,
                          android.util.FloatMath.cos((float)Math.PI * 2f * ((float)itr/(float)RING_VERTICE_COUNT )) * ring_radius,
                          0f);
            
            vertLocal = mDirection.mult(vertLocal);
            
            ringCoords[itr*3]   = vertLocal.x;
            ringCoords[itr*3+1] = vertLocal.y;
            ringCoords[itr*3+2] = vertLocal.z;
        }
// Initialize the rest...
Why is it that the rings do not rotate like they should? It must be something very simple, but I can't find it... Edited by Werner291
0

Share this post


Link to post
Share on other sites
It looks like you have a typo in your first if statement where you're calculating mPosition. You're adding delta.x and delta.y to previous.mPosition[0] when you may want previous.mPosition[1] + delta.y.
1

Share this post


Link to post
Share on other sites

Aaargh... sleep.png typos... Always such errors when I'm doing maths... Why do other people always see such stuff so easily? Thanks.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0