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

3D
Need help with Implementing rotation tool user experience

2 posts in this topic

Hi,

I am trying to implement correct user experience for rotation tool in my game engine. I want it visually behave like the same tool in Maya or Unity.

When I rotate an object, rotation tool should also rotate, BUT its axis should always be on the near camera plane and never go to another side of the tool like described in 2 first attached screenshots from Unity. You can see here that X axis (red) go to the up part of the tool instead of the back. The same for Y and Z axis.

Currently I implement something similar, but my code has huge limitation - it gave me correct quaternion for rotation, BUT to have correct axis alignment I must rewrite my existing tool rotation, so I cannot accumulate rotation and I cannot implement correct visual experience for tool. (See next 2 screenshots). As you can see there is no difference between visual tool representation despite I rotate an object itself.

Here is code I am using currently:

/// <summary>
      /// Calculate Quaternion which will define rotation from one point to another face to face
      /// </summary>
      /// <param name="objectPosition">objectPosition is your object's position</param>
      /// <param name="targetPosition">objectToFacePosition is the position of the object to face</param>
      /// <param name="upVector">upVector is the nominal "up" vector (typically Vector3.Y)</param>
      /// <remarks>Note: this does not work when objectPosition is straight below or straight above objectToFacePosition</remarks>
      /// <returns></returns>
      public static QuaternionF RotateToFace(ref Vector3F objectPosition, ref Vector3F targetPosition, ref Vector3F upVector)
      {
         Vector3F D = (objectPosition - targetPosition);
         Vector3F right = Vector3F.Normalize(Vector3F.Cross(upVector, D));
         Vector3F backward = Vector3F.Normalize(Vector3F.Cross(right, upVector));
         Vector3F up = Vector3F.Cross(backward, right);
         Matrix4x4F rotationMatrix = new Matrix4x4F(right.X, right.Y, right.Z, 0, up.X, up.Y, up.Z, 0, backward.X, backward.Y, backward.Z, 0, 0, 0, 0, 1);
         QuaternionF orientation;
         QuaternionF.RotationMatrix(ref rotationMatrix, out orientation);
         return orientation;
      }

And I am using some hack to correctly rotate all axis and keep them 90 degrees to each other:

private void TransformRotationTool(Entity current, Camera camera)
        {
            var m = current.Transform.GetRotationMatrix();
            if (current.Name == "RightAxisManipulator")
            {
                var rot = QuaternionF.RotateToFace(current.GetRelativePosition(camera), Vector3F.Zero, m.Right);
                rot.Z = rot.Y = 0;
                rot.Normalize();
                current.Transform.SetRotation(rot);
            }

            if (current.Name == "UpAxisManipulator")
            {
                var rot = QuaternionF.RotateToFace(current.GetRelativePosition(camera), Vector3F.Zero, m.Up);
                rot.X = rot.Z = 0;
                rot.Normalize();
                current.Transform.SetRotation(rot);
            }

            if (current.Name == "ForwardAxisManipulator")
            {
                var rot = QuaternionF.RotateToFace(current.GetRelativePosition(camera), Vector3F.Zero, m.Forward);
                rot.X = rot.Y = 0;
                rot.Normalize();
                current.Transform.SetRotation(rot);
            }

            if (current.Name == "CurrentViewManipulator" || current.Name == "CurrentViewCircle")
            {
                var billboardMatrix = Matrix4x4F.BillboardLH(
                    current.GetRelativePosition(camera),
                    Vector3F.Zero,
                    camera.Up,
                    camera.Forward);
                var rot = MathHelper.GetRotationFromMatrix(billboardMatrix);
                current.Transform.SetRotation(rot);
            }
        }

As you can see I am zeroing 2 of 3 axis and renormalize quaternion to keep axis perpendicular to each other.

And when I try to accumulate rotation, I am receiving completely incorrect result.

On the last image you see what happening with my tool when I try to apply rotation to face with some basic rotation.

 

This issue is driving me crazy. 

Could anyone help me to implement correct behaviour? 

 

 

Rotation_Unity_1.png

Rotation_Unity_2.png

Static_rotation_1.png

Static_rotation_2.png

Dynamic_rotation_1.png

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

  • Similar Content

    • By AlekseyRybchak
      Hi there!
      We are working on an fantasy based RPG with some really challenging gameplay.  
      We've got two writers (and we are sure we need no more), a couple of designers, one coder, one musician and one PM. 
      Here is the deal. We want to publish a demo within a 3-4 months from now. We got a popular Youtuber who would promote the game. 
      Now we need the following additional members possising SOME of the listed skills:
      2 designers who know substance designer, photoshop, 3ds max/maya. Specifically a character artist and an environment artist.

      2 more programmers with experience in Blueprint, C++ and Unreal Engine.
      You'll get rev share after we publish the full game. However experienced applicants may get some money in exhange for the right to get that rev share. 
      Publishing would not be an issue.
      Important:
      Quitters, dudes runing over 9000 other projects, lurkers, and those who got 'only 30 minutes per week' are highly unwelcome. Yes, this is an indie project. But we want to get it done.
      We communicate in Hacknplan and Discord. And yes we love discipline and consistency! So get ready for real deadlines and regular team calls!
      If you are interested PM me or better e-mail Paul: pauldando21@icloud.com
       
      TY to Scounting Ninja I flamed below for some remarks
      BR,
      Alex
       
       
    • By Ruhani
      Dhruva is one of the best game art studio in Bangalore with over 100 console games, social games, casual games and mobile games. The different teams of console art, concept art and animation work together to deliver the best 3D animated games for mobiles and web.
      The company comes across as one of the best game designing studio which offers a varied list of gaming designs and also offers academic study and job opportunities. Console art and many other art services are offered by Dhruva. Dhruva Art services
    • By GreedyVoxIndieStudios
      GreedyVox Indie Studios is a tiny indie gaming studio created in 2013,  
      With one engineer and one artist, working hard together we created YAARRGH! Me Matey! INDEV FREE build.
      And we have big plans and ideas coming soon!
      YAARRGH! Is being fully developed on Linux, for Linux, Windows and Mac. 
      YAARRGH! Me Matey! is a 3D Procedural Generated Pirate Fantasy Game, Within
      A Large World Of Islands & Habitats To Explore, Mine,
      Build & Craft.
      Facebook
      Twitter
      YouTube
      Google+
      Patreon
    • By instantmelanie
      I really can't figure out the angles needed to aim a certain turret rig I have. The skeleton looks like first image.
      The red arrow is pointing to the joint that is used to aim (via skeletal controller) and the blue arrow is pointing to the joint that needs to be aimed ie this joints forward x vector needs to point to the target. When aimed the turret likes like the second image.
      The red dot is the red joint being controlled and the blue dot is the blue joint being aimed. I just can't seem to calculate theta as a function of (x,y) the targets position.
      So the first thing I tried is the math in third image.
      The first line we get from the law of sines, the second line is just the definition of tangent, the third line is plugging the first equation into the second, and the fourth line is obtained from the general formula for a linear combination of sine and cosine (https://en.wikipedia.org/wiki/List_of_trigonometric_identities#Linear_combinations). The last line is theta as a function of (x,y) simplified which is my goal. But trying all this out in UE4 I get something that's obviously not correct (see last image). I have a feeling the math is wrong.
      Math isn't really my wheelhouse and I'm surprised I even came up with anything even it appears wrong. Anyone able to tell me what stupid overcomplicated mistake I'm making in the math? I would really like an analytical solution and not just iteratively error correct it into aiming correctly. I would really appreciate a pair of eyes on this. Thanks!


       
       


    • By caymanbruce
      For example I have 6000 entities on a 2D map and I want to get about 180 which are on my player's screen. When my player is moving new entities may appear on the map, at the same time some entities or enemies die so they disappear. I used to clear the entire spatial hash and insert everything again a few times a second. But I am thinking maybe it is better to only update those entities that change on the map, the number of changes may be huge though, but still, compared to the number of entities on the map it is still small. I am just not sure if this is worthy or not.
  • Popular Now