Jump to content

  • Log In with Google      Sign In   
  • Create Account

MarlboroKing

Member Since 16 Nov 2010
Offline Last Active Apr 21 2016 06:49 PM

Topics I've Started

[Java] LibGDX GestureDetector - Calling Zoom and Pinch simultaneously

31 December 2015 - 02:53 PM

In LibGDX, inheriting the GestureDetector class and implementing in to the InputMultiplexer, I am able to pan(move), zoom and pinch(zoom out) my mobile screen in my game (sort of, neither works too well!). The problem I'm facing is when I pinch or zoom, it'll call both Override methods "zoom" and "pinch", to be more precise it'll call "pinch" and then "zoom" directly right after each other.

 

I've read through the LibGDX documentation and spent hours on Google, have not really found a problem similar to mine. Did I miss a method or member? Here's some rough code;

public class GameWorld implements GestureListener, InputProcessor
{
    .....

    public GameWorld()
    {
        ....

        InputMultiplexer im = new InputMultiplexer();
        GestureDetector gd = new GestureDetector(this);
        im.addProcessor(gd);
        im.addProcessor(this);

        Gdx.input.setInputProcessor(im);

        ....
    }

    @Override
    public boolean zoom(float initialDistance, float distance)
    {
        m_Camera.OnZoom(initialDistance, distance);
        return false;
    }

    @Override
    public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2,
            Vector2 pointer1, Vector2 pointer2)
    {
        m_Camera.OnPinch(initialPointer1, initialPointer2, pointer1, pointer2);
        return false;
    }
}

Exactly what's the point of 'int32_t', etc.

17 March 2014 - 12:07 PM

I see very little point of using the 'int32_t' compared to 'signed int'. The project irrLicht actually shows one valid example for it in .\irrTypes.h:

#if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
typedef unsigned __int64            u64;
#elif __GNUC__
#if __WORDSIZE == 64
typedef unsigned long int           u64;
#else
__extension__ typedef unsigned long long    u64;
#endif
#else
typedef unsigned long long          u64;
#endif

MSDN writes little about the 'fixed size' data types it supports, such as __int32:
"The types __int8__int16, and __int32 are synonyms for the ANSI types that have the same size, and are useful for writing portable code that behaves identically across multiple platforms" -- Great, it's "ANSI principle", I suppose.

 

I guess my point is; why does MSVC declare the data types prefixed with "__" a fixed size, yet \most\ other compilers determine the globally used "int"(etc.) as a fixed size? Is there any scenario that I should dread about a non-fixed size integer?

 

Edit: I am aware that 'int' on a x86 build is 32 bits, yet should be 64 bits on a x64 build.


Moving object based on camera direction

05 February 2013 - 12:59 AM

This one is a pickle. Basically, I am trying to keep a 3D object in the center of the camera. I figured the easy way would be to invert the view matrix, add 5 to the mat.Forward member and everything would be O.K. Well, now I don't even see it. My previous attempts were fiddling with the UpDown / LeftRight rotations, they worked for the most part but couldn't get it corrected without really hardcoding the issue (and even then didn't work properly). Been stuck on this for the past 3 or 4 days, really not much else I can think of.

 

if( nType != EItemType.None )
{
    Matrix matWorld = Matrix.Invert( m_Player.m_Camera.View );
    matWorld.Translation += (matWorld.Forward * 5);

    m_Effect.World = matWorld;
    m_Effect.View = m_Player.m_Camera.View;
    m_Effect.Projection = m_Player.m_Camera.Projection;
    m_Effect.TextureEnabled = true;
    m_Effect.Texture = m_Texture;

    foreach( EffectPass pass in m_Effect.CurrentTechnique.Passes ) 
    {
        pass.Apply();

        m_GraphicsDevice.BlendState = BlendState.AlphaBlend;

        m_GraphicsDevice.DrawUserPrimitives<VertexPositionTexture>( PrimitiveType.TriangleList,    m_Verts.ToArray(), 0, 2 );

    }
}

 

 

-Edit- For the most part, this works:

Matrix matWorld = Matrix.Identity *
					Matrix.CreateScale( 2f ) *
					Matrix.CreateRotationZ( -m_Player.m_Camera.UpDownRot ) *
					Matrix.CreateRotationY( m_Player.m_Camera.LeftRightRot - MathHelper.PiOver2 ) *
					Matrix.CreateTranslation( m_Player.Position + (m_Player.LookVector * 0.3f) );

 

 

I thought I introduced tearing, but nope. Was able to angle my camera just right and noticed it was my item. Fixed!


Simple rotation

09 January 2013 - 10:22 AM

I'm attempting to rotate a code-defined model, however it appears to be moving instead of rotating. I've looked all over, even copy/pasting, but to no avail.

 

Edit- This current code shows me using a custom effect, however, I'm basing all this off my previous edits (that being, using the BasicEffect)!

			m_GraphicsDevice.BlendState = BlendState.Opaque;
			m_GraphicsDevice.DepthStencilState = DepthStencilState.Default;

			m_Effect.Parameters["View"].SetValue( m_Camera.View );
			m_Effect.Parameters["Projection"].SetValue( m_Camera.Projection );
			m_Effect.Parameters["CameraPosition"].SetValue( m_Camera.Position );
			m_Effect.Parameters["Texture1"].SetValue( m_TextureAtlas );
			
			foreach( EffectPass pass in m_Effect.CurrentTechnique.Passes )
			{
				foreach( Item item in m_World.ItemMap.Values )
				{
					if( item == null || !item.BoundingBox.Intersects( frustum ) )
						continue;

					Matrix matWorld = Matrix.CreateRotationY( fRROT );
					m_Effect.Parameters["World"].SetValue( matWorld );
					pass.Apply();

					m_GraphicsDevice.SetVertexBuffer( item.m_VertexBuffer );
					m_GraphicsDevice.Indices = item.m_IndexBuffer;

					m_GraphicsDevice.DrawIndexedPrimitives( PrimitiveType.TriangleList, 0, 0,
						item.m_VertexBuffer.VertexCount, 0, item.m_IndexBuffer.IndexCount / 3 );

I've tried using Matrix.CreateFromAxisAngle which did rotate, just not anywhere near the axis I want - even when defining just that axis.

My other attempt was Matrix.CreateRotationY(..) * Matrix.CreateTranslation(..) and still seemed to move.

 

Further information:

m_VertexBuffer = VertexPositionTexture

m_Effect = BasicEffect

ItemMap only contains 1 value for the time being.

I know Quanternations is better for this since it holds the rotation, but I'd like to avoid that route..


What culling method would be best for cube land?

20 September 2012 - 10:28 AM

Cube land.. Lol. I'm 'immitating' Minecraft, like everybody else. I'm debating against the two: Occlusion Culling & Ray Casting.
http://lodev.org/cgtutor/raycasting.html
http://http.developer.nvidia.com/GPUGems/gpugems_ch29.html

At the moment, I'm using this as a helper (and some code too...!): http://codeflow.org/entries/2010/dec/09/minecraft-like-rendering-experiments-in-opengl-4/

I tried using the LPDIRECT3DQUERY9 interface for occlusion culling but my scene rendered extremely slowly (screw up on my part...?). I usually got 15 FPS for drawing 6963 cubes and the 12 faces it has. I read that an Octree would be a good choice to help determine what the 'neighbors' are of a certain cube, but at the same time, I don't think an Octree would be good for a game that already splits its world? Or is this question/statement just complete jibberish.?

Occlusion Culling (or just this method I used? not sure lol) seems to be aimed for more pixel-perfect culling, which I believe would NOT be necessary for a game such as this. Ray Casting, I haven't looked too much into so I can't really output an opinion and/or a stupid opinion about it.

I'm basically running back and forth between the two (Well, three: Occ-culling, Ray Casting & implementing an Octree) from various websites where others are discussing -semi- the same thing and reading mixed (biased?) opinions about it all.

PARTNERS