Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 20 Nov 2011
Offline Last Active May 26 2015 10:23 AM

Topics I've Started

Converting between coordinate systems

17 February 2015 - 05:40 PM

Hi, I'm a little lost about this. I need to convert from one coordinate system to another. My first coordinate system is like this:


(Right-hand rule)


X+ to the east     (Pitch)

Y+ to the north   (roll)

Z+up                   (yaw)


Yaw = 0 points towards y axis(north)



The 2nd coordinate system (the one I'm converting to) goes like this:


(Left hand rule)


X+ to the west   (roll)

Y+ to the north (pitch)

Z+ goes up       (yaw)


Yaw = 0 points towards x axis (west)


I'm using D3DXMatrixLookAt and D3DXMatrixPerspectiveFov functions to create the view and perspective transforms. I think I should be negating x, but I'm not sure what to do about the yaw=0 direction being different, or the roll/pitch being on different axes.

Installing an app permanently on a device

24 May 2012 - 09:03 AM

Hi all, I've been developing an android app for a few weeks now, and I've been able to "install" my app through USB debugging and eclipse, but it'll only run if my device is hooked up to the computer, and eclipse is running. How do I install the app permanently on the device?

After a USB debugging session, the file shows up in settings->apps with the option of uninstalling it, but that's it. no icon anywhere to run the app.

edit: As per what I've read on the web, I've tried putting the .apk in my public dropbox folder, then downloading it via a link on the device itself, but all that does is download it onto a folder in the device. I can then browse to that folder, and put a nice checkmark next to it when I touch it, but nothing actually happens.

I've also tried "adb install", which "install's" it much like USB debugging does.

The only option I haven't tried is publishing it on Android store or whatever, but I don't actually want to publishing this.

Android & Java language question

07 May 2012 - 02:06 PM

Hello, I have a question about an example given at: Service | Android Developers
I don't think you need to know anything about Android to be able to answer this question.
What the heck is going on here? I've never seen syntax like this before, but nowadays I see it all the time in Android examples.

It looks like a new ServiceConnection is being made, but then, instead of ending with a semicolon, we've got braces and then 2 function definitions (overriding the 2 abstract ServiceConnection functions) This must be some special feature of Java I've never seen before, can someone tell me what this feature is called so I can read more about it? I know you can't do this in C++.

private LocalService mBoundService;

private ServiceConnection mConnection = new ServiceConnection() {
    public void onServiceConnected(ComponentName className, IBinder service) {
    public void onServiceDisconnected(ComponentName className) {

projecting 3D coordinates to 2D screen coordinates

20 November 2011 - 04:37 PM

Hi everyone, I`ve got these squares that move around and rotate on the screen, and I need to be able to tell which one the player`s cursor is over.
I use: Viewport.Project to get the screen coordinates of the 4 corners of the square, then I do point-in-polygon 2D collision detection, using the player`s cursor as the point. That`s the idea anyway, but the screen Y coordinates for the squares seem to be off. When I'm testing a square that shows up above the middle of the screen, the Y coordinate seems to be higher than it should be, when I'm testing a square that shows up below the middle of the screen, the Y coordinate seems to be lower (of course, lower for Y means higher up on the screen) than it should be, in comparison to the player's cursor. So basically, the further a coordinate is from (0, 0, 0) on the Y axis, the further off it'll be on the Y axis when I project it.

Maybe I`m missing something obvious? The first functions of the first 2 boxes are the most important, I included some more of the code too, but its less important.


        public static Vector2 GetScreenSpace(Vector3 cntr, Matrix world)
            Vector3 projection = device.Viewport.Project(cntr, camera.projection, camera.view, world);
            return (new Vector2(projection.X, projection.Y));

From the matchPiece (square) class:

        public new bool Intersects(Player player, Matrix matWorld)
            Vector2[] polygon = new Vector2[cubeFront.Length];
            for(int i=0; i < cubeFront.Length; i++)
                polygon[i] = GameObject.GetScreenSpace(cubeFront[i].Position, matWorld);

            if (GlobalFuncs.PointInPolygonCollision2D(player.center, polygon))
                playersSelecting[player.index] = true;
                interactedColor = new Color(player.color.R/4 + 128, player.color.G / 4 + 128, player.color.B / 4 + 128);
                playersSelecting[player.index] = false;

            return playersSelecting[player.index];

        public void Draw(Camera camera, Matrix matWorld)
            Matrix rotMatrix = Matrix.CreateRotationY(rotOffset);
            this.worldTranslation = rotMatrix * matWorld;

            cubeEffect.World = worldTranslation;
            cubeEffect.View = camera.view;
            cubeEffect.Projection = camera.projection;
            // Render background of Square
            cubeEffect.DiffuseColor = color.ToVector3();
            cubeEffect.TextureEnabled = false;
            //cubeEffect.Texture = texture;

            cubeEffect.DiffuseColor = backColor.ToVector3();
            foreach (EffectPass pass in cubeEffect.CurrentTechnique.Passes)
                GameObject.device.DrawUserPrimitives<VertexPositionColorTexture>(PrimitiveType.TriangleStrip, cubeFront, 0, 2);


            // Render foreground of Square with shape
            cubeEffect.DiffuseColor = color.ToVector3();
            cubeEffect.TextureEnabled = true;
            //cubeEffect.Texture = texture;

            foreach (EffectPass pass in cubeEffect.CurrentTechnique.Passes)
                GameObject.device.DrawUserPrimitives<VertexPositionColorTexture>(PrimitiveType.TriangleStrip, cubeFront, 0, 2);



Just in case you want to see it, matchpiece's constructor:

        /// <summary>
        /// When a Match Piece is created:
        /// 	- Randomly select an identity (texture)
        /// 	- Set its facing direction (front, side, back)
        /// 	- Set it's offset from the middle
        /// 	- Create a backsurface and front texture key
        /// </summary>
        public MatchPiece(float posOffset, float size, int facingDirection, float midLen)
            cubeFront = new VertexPositionColorTexture[4];
            this.pieceSize = size;
            this.posOffset = posOffset;
            position3 = new Vector3(posOffset, 0, 0);
            faceOffset = new Vector3(0, -size, midLen);
            rotOffset = (float)(facingDirection * Math.PI / 2.0);

            //initialize the world transform, for drawing and collision detection
 		//   worldTranslation = Matrix.CreateRotationY(rotOffset) * Matrix.CreateTranslation(position3);
            playersSelecting = new bool[MAXPLAYERS];
            cubeFront[0] = new VertexPositionColorTexture(new Vector3(posOffset, pieceSize, 0) + faceOffset, color, new Vector2(0, 0));
            cubeFront[1] = new VertexPositionColorTexture(new Vector3(posOffset + pieceSize, pieceSize, 0) + faceOffset, color, new Vector2(1, 0));
            cubeFront[2] = new VertexPositionColorTexture(new Vector3(posOffset, 0, 0) + faceOffset, color, new Vector2(0, 1));
            cubeFront[3] = new VertexPositionColorTexture(new Vector3(posOffset + pieceSize, 0, 0) + faceOffset, color, new Vector2(1, 1));


From CubeSegment, the class that holds the squares:

public void intersects(Player[] players)

                    //test each square on this row
                    for (; j < (i + 1) * numSquaresAcross; j++)
                        foreach (Player p in players)
                            if(p != null)
                                squares[j].Intersects(p, matWorld);

    public CubeSegment(Vector3 position3, bool isForward)
            this.isForward = isForward;
            this.position3 = position3;
            matWorld = Matrix.CreateTranslation(position3);
            squares = new MatchPiece[numSquaresTotal];

            for (int i = 0; i < numSquaresTotal; ++i)
                squares[i] = new MatchPiece(i % numSquaresAcross - (numSquaresAcross / 2.0f), squareWidth, i / numSquaresAcross, (numSquaresAcross / 2.0f));


        public void DrawPieces()
            foreach (MatchPiece piece in squares)
                if (piece != null) 
                    piece.Draw(camera, matWorld);        

        public new void Draw()
            segmentEffect.World = matWorld;
            segmentEffect.View = camera.view;
            segmentEffect.Projection = camera.projection;
            RasterizerState backupState = device.RasterizerState;

            //draw top
            //draw bottom

            device.RasterizerState = backupState;

The functions: Draw() and DrawAllPieces() are called separately. For the purpose of testing, I'm not rotating anything right now, so rotOffset would be 0.