Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 8th Mar 2019 11:35
Here is my implementation for a simple 3D move gizmo
The main file:


and the include file

I hope it will be useful to someone
nonom
6
Years of Service
User Offline
Joined: 12th Nov 2017
Location: Picking mushrooms
Posted: 8th Mar 2019 13:23
Woah george++!!!. It will be quite useful

Thanks for sharing, It works flawless
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 8th Mar 2019 20:05 Edited at: 8th Mar 2019 21:07
Nice work. Just a suggestion, as I ran into this issue myself with a map editor I'm working on. Since you're using 2D to render the gizmo, you may want to add in a check to make sure the gizmo and its line points are not behind the camera before allowing it to render or run. Otherwise you'll have an inverted gizmo and some other odd drawing issues when it's behind the camera.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 8th Mar 2019 23:23 Edited at: 8th Mar 2019 23:55
Very nice work. I was looking for something like that. thanks
I added a gimbal so you can navigate the scene using the mouse.
just realized i forgot zoom. i'll make sure i add that


*EDIT*: Added zoom

project attached

Attachments

Login to view attachments
george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 9th Mar 2019 06:03
@hendron: unfortunately, I cannot handle this issue
Nice addition, blink0k, I made a small modification to your code: when the user drags the gizmo the camera navigation is being disabled

Attachments

Login to view attachments
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 9th Mar 2019 11:49
Nice, put your SyncGimbal() function somewhere above gizmo3D_Update() to remove the delay of the gizmo when moving the camera.
And I don't like inverted camera y movement:


How about rotation via Gizmo using DrawEllipse ?
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 9th Mar 2019 16:52 Edited at: 9th Mar 2019 20:58
@george++ Here you go, a function to check if a world point is behind the camera.





EDIT: Just thought of a much simpler way to do it. Simply check to see if moving the camera forward increases the distance from the camera to the world point. Won't be quite as accurate as the other method, but should work pretty well.

george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 9th Mar 2019 19:51
@hendron: Thank you very much I'll be in home next week and I will take a look at it.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 10th Mar 2019 03:57
Quote: "How about rotation via Gizmo using DrawEllipse ?"


That sounds like a great idea!. I thought a free movement (relative to the camera) if you dragged the object (Not using the gizmo) would be good too
george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 11th Mar 2019 19:34 Edited at: 11th Mar 2019 19:37
You can find a new improved version of the gizmo thanks to you guys!
1. I removed the delay between gizmo and screen navigation
2. I changed the control of the camera. janbo's suggestion fits better to my preferences
3. I used, the built-in command of AppGameKit to detect if the gizmo is inside the screen area. @hendron: Your code snippets are still usefull, but I think the built-in command is faster.
@blink0k: I am not sure if I will manage to detect pointer touch on a 3D ellipse, but I will try later.

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 12th Mar 2019 01:00 Edited at: 12th Mar 2019 01:12
Quote: "I am not sure if I will manage to detect pointer touch on a 3D ellipse, but I will try later."


I was thinking about that and maybe if you draw a small circle at the end of your axis lines. If they click and drag those then the object rotates around the appropriate axis

ps: looks awesome george.
george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 12th Mar 2019 10:11
Thank you blink0k. A small circle at the end of the handle (one for each axis), it is a good idea and easy (I think) to implement
george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 14th Mar 2019 15:54
Hi guys,
I've attached an optimized version of the gizmo but, sorry, without rotation skills
I started this just for fun and there is no good base to add rotation handles. Unfortunately I don't have enough time to start from scratch.

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 14th Mar 2019 20:48
Superb george!
Rotation and drag handles look awesome.
Question with drawing the gizmo: If i use SetViewOffset() to move the camera will the handles still be drawn?
george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 15th Mar 2019 01:20
Thank you blink0k. I suppose it will work since all the handles are being translated from 3D to screen coordinates. But it should be tested
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 25th Feb 2021 20:21 Edited at: 25th Feb 2021 20:41
I have updated this code;

function SetupGimbal(angle as float, plane as integer, distance as float) returns a tCamera type
angle The angle of the camera to the ground plane
plane a plane object, usually a plane with a grid texture. Should be very large
distance Camera distance from 0,0,0

function SyncGimbal(camera ref as tCamera) // call before sync()

RightClick Drag camera
Ctrl+RightClick Rotate camera around center point


Attachments

Login to view attachments
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 26th Feb 2021 00:18 Edited at: 26th Feb 2021 00:44
For rotation and scale I opt for a blender like approach in my 3D editor, the gizmo is a rudimentary blender model rotated and coloured and press a hotkey to enter (r) rotate or (t) scale mode and the o------o shows, press x,y,z to lock to axis while in either mode, it works quite well except the object placement from the widget is off, I need to get to that my math is off in X3D_Widget_RayCast() or X3D_Cursor_MoveXXX

just saying, its easier to code this way, project attached below, this is designed to be a drop-in system that can be enabled/disabled for ingame editing, it has some camera modes (free flight, orbit, fixed (FPSC like), I have removed the grid shader as its from the store (Janbos) but the code that loads it is still in there if you have it to throw in, parts of this system are unfinished but what is in there now is fully functional.



add your objects to the system with X3D_AddObject(id, active, visible) and call X3D_Sync(), thats it, the scripts take care of the rest but you are responsible for saving the objects transform, I might add a matrix when I update it, the code is pretty old now and could probable use a revisit but I thought I'd post to maybe spark an idea for the rotation and scale.

Edit:

I forgot: CTRL+C >> clone object, CTRL+I, instance object (you must save object data)

Events are passed to X3D_Events.agc, events are OnInstance, OnClone, OnSelect, OnMove, OnScale and OnRotate <<; this is where you record object transforms

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 26th Feb 2021 19:37 Edited at: 2nd Mar 2021 00:46
Very nice.

Added some functions that make navigating the scene a bit easier.

GetObjectAtPointer() - Returns the id of the object at the pointer or 0 if there is not object at the pointer
FitToWindow(obj) - Centers the object in the window and zooms to fill the view with the object

Changed the interface so now you right click inside the circle to roll, outside to drag (I hate the middle button)

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-03-28 15:20:42
Your offset time is: 2024-03-28 15:20:42