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.

AppGameKit Classic Chat / No VR forum Section?

Author
Message
wopag
6
Years of Service
User Offline
Joined: 13th May 2018
Location:
Posted: 13th May 2018 14:47


Hi

New to APK - the lure of an easy way to jump into VR was too great (and I find Unity sooo bloated).

So has anyone started on any standard code for VR? Ive found a few threads but they dont contain much in the way of code? Be nice to have a section in the forums just dedicated to it.

First thing I need is to grab an object and it attaches to your hand - when you rotate your hand the object also rotates. Examples given seem to just create a joint that doesnt rotate the object,




Wopag
wopag
6
Years of Service
User Offline
Joined: 13th May 2018
Location:
Posted: 15th May 2018 00:02

Firstly it may be because im used to B3D and Blitzmax commands, that im used to doing things the "Blitz way".....

Done a bit more playing, Using the demo code Ive tried to get the Object to appear at the centre of the hand object.

1) get the object ID
2) parent the Object to the HAND object
3) turn off object collisions

When the object appears, it is indeed parented (rotates with the hand) but it appears up in the sky (rather than at the parents 0,0,0 ) ?

When you release the object, I was expecting the object to drop to the floor (un parent and turn collisions back on), but the object just appears in the position it was when it was first picked up?


smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 15th May 2018 09:26
Move the object to 0,0,0 then fix it to the hand... You will also want to move it by the objects size so it isn't inside the hand.

For dropping I guess grab the position before you unparent it and then position it there after you unfix it.
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
basicFanatic
7
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 15th May 2018 12:23
I'm on my mobile phone phone right now, but I played around with kinda the same thing:

https://forum.thegamecreators.com/thread/221666
wopag
6
Years of Service
User Offline
Joined: 13th May 2018
Location:
Posted: 15th May 2018 22:17

The only way I can get it to work is by Delete3DPhysicsBody and then recreating the 3d physics again when its let go....


wopag
6
Years of Service
User Offline
Joined: 13th May 2018
Location:
Posted: 22nd May 2018 23:50 Edited at: 23rd May 2018 00:01
Playing around a bit more with picking up objects and dropping them. Most of the time it looks like it works - but try holding an object then turn around. The rotation kinda flips out when you drop it (but only when using dynamicBody)

It seems that

Create3DPhysicsDynamicBody( LeftHandContact ) // <<<<< This rotates the object ?

Create3DPhysicsKinematicBody( LeftHandContact ) // <<<< This works fine ....


/Wopag

wopag
6
Years of Service
User Offline
Joined: 13th May 2018
Location:
Posted: 23rd May 2018 18:22 Edited at: 23rd May 2018 18:29
Its not the Create3DPhysicsDynamicBody thats causing the error. If you pickup and object then turn 180 degrees, the rotations are then incorrect, so it seems more that the GetObjectWorld<> commands are not returning the correct values ?

I guess this is linked to gimbal lock in some way? Or is it just that the GetObjectWorld is aligning wrong using the AGKVR plugin ?

So it seems to happen if you move the player/head, itsd like it still aligns the angle with the original cameras angle maybe?
wopag
6
Years of Service
User Offline
Joined: 13th May 2018
Location:
Posted: 24th May 2018 10:21

or maybe its related to the world rotation - is it not mapping to the VR camera correctly?

Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 24th May 2018 11:46
Hi Wopag,

I remember struggling with this when writing the AGKVR demos. The problem had to do with trying to control an object dynamically (when grabbing an object), then allowing the physics system to take over again when letting go of the object. If I remember correctly, you can't manually move kinematic objects around, so you can't grab them and orient then using the hands. You can do this nicely with dynamic objects, but they can only be moved around manually. That is why I tried to solve the problem using joints, but then there were issues when changing the rotation of your character. Since I was more focused on trying to demo the AGKVR commands, I didn't want to over-complicate the demo with trying to get the physics perfect (as there seems to be no easy solution)! I remember looking into creating new dynamic physics objects when an object is grabbed (and deleting the kinematic body), then deleting the dynamic body and creating a new kinematic body when the item is let go again. I can't remember where I left off with that. It may have been too slow, or there was some other reason it did not work, or possibly it was just too complicated for a simple "VR" demo.
Although this is more of a physics issue than a VR issue, I could possibly have another look at this problem but it will be a couple weeks until I can get to it. I'm leaving on a vacation in a couple days and won't have access to any my PC for a couple of weeks.

Ron
a.k.a WOLF!
wopag
6
Years of Service
User Offline
Joined: 13th May 2018
Location:
Posted: 24th May 2018 12:34

Than ks for the reply.

As you can see tho, I am now deleting the physics body and trying to recreate it as a new body - which I can do, but it seems that the orientation of the object is wrong (position is fine). As you can see by my testing it does seem that there is a problem with the orientation of the headset camera - as tho the 3dphysics is trying to orientate it to a different camera?

I'll try creating the same demo but without the VR, parent an object / turn the camera 180 / place object . This should narrow down where the problem is?



Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 24th May 2018 13:16
Maybe I'm misunderstanding what you are trying to do. I don't believe anything should be oriented based on the camera. The world rotation of an object should not be based on it's link (by physics or any other means) to any other object (or camera). It should just be the rotation on the Global X, Y and Z axis.
Be careful when reading the X, Y and Z rotation values of an object. You can't really use those values directly as they are Euler rotations. Euler rotations describe the final orientation as the object is rotated on the given global X then Y then Z axis. You can't trust the individual values because the entire set is used to describe the final orientation. So, while it may look like one of the values "flip" 180 degrees you will also probably notice that one (or both) of the other values seems to have a step change. There can be different paths of rotation sets that reach the same orientation, and the path given by the Euler XYZ values is just what is calculated when converting from the Quaternion rotation that sits underneath.
a.k.a WOLF!
wopag
6
Years of Service
User Offline
Joined: 13th May 2018
Location:
Posted: 24th May 2018 22:46 Edited at: 24th May 2018 22:55
A video to describe it is probably best - as it does seem that the 3dphysics is at fault.


Both captures are using the same code,

I pickup the object
delete the Delete3DPhysicsBody
turn collisions off on the object
parent the object to the hand

let go of the object
turn off parenting
set the position of the object
set the rotation of the object
create the 3d physics object (see below)

Without 3d physics the object is rotated correctly.



using Create3DPhysicsKinematicBody - rotation is correct





using Create3DPhysicsDynamicBody - rotation is incorrect - and even changes every time you drop the object

basicFanatic
7
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 25th May 2018 18:37

I had pretty much given up on this when I tried to create a simple little VR thing where you could put toy bricks on top of each other. So thanks for looking into this!

Little bit of nitpicking about your screenshots: The VR plugin sets the camera to render 1330x1584 pixels. So if you render to the monitor using another aspect ratio, the image gets stretched:

Attachments

Login to view attachments
wopag
6
Years of Service
User Offline
Joined: 13th May 2018
Location:
Posted: 26th May 2018 09:35 Edited at: 27th May 2018 07:58
Yes basicFanatic - Ive read most of your forum posts

We need to keep on top of this, the only reason I paid for AppGameKit was because it had the VR plugin. Picking objects up and dropping them is the most basic of tasks in VR and I just cant get it todo it !!!!

Its definitely seems its the physics that is overriding the objects rotation - but only Create3DPhysicsDynamicBody

Heres a demo - press Z when the object is at rest. ( no VR in this one ..... which proves its nothing todo with the plugin !!!!!!!!! )

the cones rotation and position are recorded
objects 3d physics are deleted
cone repositioned and rotated using previous
physics reapplied to object

Z - object will flip rotations
X - object is correct

wopag
6
Years of Service
User Offline
Joined: 13th May 2018
Location:
Posted: 26th May 2018 15:54
being new to agk (not to programming), Im loving the engine be so far. get this annoying bug sorted (or at least a work. around) and then I want to start a VR playground. There are lots of nice vr demos in unity, but the engine is sooo bloated and so much breaks. between updates.....

lots of levers, buttons, doors etc will. be a nice showcase for the agk engine (I hope) I've got a little point and teleport done already, as I need. these for a work demo I'm doing.

No pickup and put down will. be a deal. breaker.........
basicFanatic
7
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 26th May 2018 16:45

Agreed! One quick question ... at line 19 it says LeftHandContact = cone ... what is the purpose of this? Couldn't you just use the cone directly, instead of creating a new integer reference?
wopag
6
Years of Service
User Offline
Joined: 13th May 2018
Location:
Posted: 26th May 2018 16:50

I was being lazy, cut and pasted the code from the Vr version.

Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 26th May 2018 19:15
You need to use the Create3DPhysicsPickJoint() command to be able to pick up a dynamic rigid body.
Demo is posted here.
https://forum.thegamecreators.com/thread/216683
The coffee is lovely dark and deep,and I have code to write before I sleep.
basicFanatic
7
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 26th May 2018 23:21
Thanks for the tip! But what about rotation? As I understand things, pick joints can be used to change an objects position, but not its angle. And in VR, the angle should change along with the changing angle of the hand holding it.
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 27th May 2018 03:16
Pick Joints handle position and rotation. Where did you get the info that it does not handle rotation?
The coffee is lovely dark and deep,and I have code to write before I sleep.
wopag
6
Years of Service
User Offline
Joined: 13th May 2018
Location:
Posted: 27th May 2018 07:57 Edited at: 27th May 2018 08:05
Firstly good demos Stab - very nice.

But I dont want to pickup a dynamic rigid body, as you see by my code, im destroying the 3d physics object when I grab it. When its being carried around I want no collisions etc.

Your demo uses velocity to move the picked object around, whereas in the VR world we want the object attached to your hand - that way we get no lag of the object following the hand. i would hate to see the maths to create the correct velocity to make the object "SNAP" into the players hand (and then the way it interacts with the rest of the physics world if an object were in the way)



My examples clearly show its the Create3DPhysicsDynamicBody that is rotating the object
basicFanatic
7
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 27th May 2018 10:52
Stab in the Dark software wrote: "Pick Joints handle position and rotation. Where did you get the info that it does not handle rotation?"


Have I been wrong about something? Me, being WRONG? That can't be.

But my reasoning went kinda like this:

The Tutorial Guide Vol. 2 said that a 3D object with a pick joint ignores other physic forces and centers itself on the position of the pick joint.

The guide mentions Update3DPhysicsPickJoint(pickJointID, PositionVectorID) and my understanding was that this command updates the pick joint with a vector thing containing 3 pieces of data: x, y and z position. But no data for rotation.


Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 27th May 2018 18:04
I agree that this is essential functionality, so I'll find a way to do it, one way or another. Like I said, I'm on vacation at the moment, so it may be a couple of weeks before I can look at it at all.

Ron
a.k.a WOLF!
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 27th May 2018 18:39
Quote: "Your demo uses velocity to move the picked object around"


It does not use velocity to move a picked object. Please study the demo.

Quote: "When its being carried around I want no collisions etc"


Then just do as you said and delete the physics object.

Quote: "The Tutorial Guide Vol. 2 said that a 3D object with a pick joint ignores other physic forces and centers itself on the position of the pick joint.

The guide mentions Update3DPhysicsPickJoint(pickJointID, PositionVectorID) and my understanding was that this command updates the pick joint with a vector thing containing 3 pieces of data: x, y and z position. But no data for rotation."


The author of the guide was not the author of the physics code used in AGK.
He did not contact me for any info on how the physics actually works.
The physics always updates the position and rotation of all physics objects.
The coffee is lovely dark and deep,and I have code to write before I sleep.
basicFanatic
7
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 27th May 2018 19:49
Quote: "The physics always updates the position and rotation of all physics objects."


Yes, of course it does. That much we agrees on! But the Update3DPhysicsPickJoint() only accepts a vector with XYZ position. No rotation data. (that's at least is what I understood so far)
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 27th May 2018 23:15 Edited at: 27th May 2018 23:17
You can easily rotate the position vector using this code.

The coffee is lovely dark and deep,and I have code to write before I sleep.
basicFanatic
7
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 28th May 2018 09:54

Thanks Stab! Looks like I had gotten the concept of vectors totally wrong. I'll try to get a more solid grasp of the basics. This one seems userfriendly: http://chortle.ccsu.edu/vectorlessons/vectorIndex.html
basicFanatic
7
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 9th Jun 2018 17:37
I ran out of steam on this one, again! However, I finally created a function to add mouselook to my VR games. This is pretty crucial when you want to avoid having to put the HMD on every time you test your game. Can't believe I figure this out now!

The Globals:


The function: (call it from the DO loop)

Login to post a reply

Server time is: 2024-11-23 20:19:17
Your offset time is: 2024-11-23 20:19:17