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 Studio Chat / Get3DPhysicsRayCastNormalVector not working?

Author
Message
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 30th Apr 2021 18:10 Edited at: 30th Apr 2021 18:11
Hi all, I try to get the normal vector of a raycast, but apparently it doesn't work. I often get NaN or a null vector:

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 30th Apr 2021 22:37
The contact position appears to be incorrect (inverted) as well
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 1st May 2021 07:19
Yes that's correct. Should be +0.5 actually.
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 3rd May 2021 15:33
So I guess this is broken since the beginning and not supposed to be fixed, right?
James H
16
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 3rd May 2021 21:50
Hi

Change the value of zero to one, in RayCast3DPhysics, this should give you correct contact point

Once done you have to then normalize the resulting normal vector, which is basically divide by the magnitude(length of vector) - ie the y value so before normalize I get 0.0, 1.570796, -0.0. So x:0.0/1.570796=0, y:1.570796/1.570796=1 and z:-0.0/1.570796=-0.0. There is a vector command to get the length of vectors. Don't need it for this specific code as the x znd z cast values are zero so the length is y value in this case. The vector length command returns this same result - I double checked.

Essentially you should then have a readout of 0,0.5,0 for contact and 0,1,0 for normal vector.

As far as I am aware -0.0 is 0.0 so why that occurs I have no idea and why you must change the value of the ray cast line to 1 when the command states 0 is closest is perplexing! I can only think that the next command you used Get3DPhysicsRayCastClosestContactPosition is what is important - perhaps the actual ray cast value zero is changed ie it has had an update that no longer corresponds with the help file or the help file had the values the wrong way round in the first place. Or I suppose there is a chance its use is specific to other ray cast commands but I don't think so because then you would have to cast twice in order to achieve the correct contact point and associated normal. This actually leads me to my best GUESS which when coupled with the possibility of more than one result might make a little more sense...

So my actual best guess is that if you look at help file wording for ray cast physics command it states it returns a true result if closest contact position is returned. I therefore think that is the only purpose of a zero or 1 value at the end of command - what it doesn't mention is which vector is resulted so I think you only ever see the last result unless you use the command Get3DPhysicsRayCastClosestContactPosition if you see what I am saying? I would like to suggest this is because the ray cast command you used is for global physics ie it includes any physics object in a scene.

Normally I would attempt the whole hog here to find out why, but changing existing physics causes a memory leak so I have abandoned the use of 3d physics for my own part. I therefore see little point in wading in further. I hope this post is of some use at the least.
Win 7 Pro 64 bit SP1, AMD A4-5300 APU 3.4GHz, 8GB DDR3, NVidia GeForce GTX 750 1GB GDDR5, ASUS A55BM-E
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 5th May 2021 06:26
Thank you for your help. That stuff is broken as hell. I often get a NaN for the normal in the example above which cannot be normalized obviously.

So those commands are broken and useless. A pity. Back to ${put in your favourite engine here}...
James H
16
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 5th May 2021 14:03
Weird your getting 1 of 3 random results(Not a Number, no value(null) and the correct result) at different times. In both AGKC and AGKS I get consistent results 100% of the time and my rig is old...so what is different between our setups? My sig holds my rig info, I am using latest drivers throughout and windows fully updated etc, care to share your specs/setup? Are you using the broadcast feature by chance? Only when I broadcast do I get results of zero.
Win 7 Pro 64 bit SP1, AMD A4-5300 APU 3.4GHz, 8GB DDR3, NVidia GeForce GTX 750 1GB GDDR5, ASUS A55BM-E
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 5th May 2021 14:54
Using Windows 10, latest SP, Ryzen 7 2700 eight-core CPU, 16GB RAM, GTX 1660Ti, but I don't think that's the root cause. Fails for both Tier 1 and Tier 2 on latest Studio version and I don't use any broadcasting.
James H
16
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 5th May 2021 16:55 Edited at: 5th May 2021 16:56
I dunno, I would say there might be something in it...if it works for me 100% of the time, I have latest AppGameKit versions also, so although the setup might not be the root cause, going through the motions may well highlight the issue - I can now replicate the zero value issue - in my build options there is a check box for 64 bit - mine is checked - when I uncheck it is when I can replicate the issue. Try that - your cpu is x64 right? So if this works for you its because your on a 64 bit system and AppGameKit is failing you there(default is 32 bit) - we should be able to not have to switch to 64 bit without an issue. Hoping this sorts your issue, give it a whirl

Edit you are using win 10 is it 32 or 64?
Win 7 Pro 64 bit SP1, AMD A4-5300 APU 3.4GHz, 8GB DDR3, NVidia GeForce GTX 750 1GB GDDR5, ASUS A55BM-E
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 5th May 2021 17:22
Yes it's a 64 bit Windows 10 and a 64 bit system and I tried both 32 and 64 bit builds and both Tier 1 and 2 but the problem persists.

I'm giving up here and use a different engine. Thanks anyway! Much appreciated!
James H
16
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 5th May 2021 17:38
No worries, totally get it, this product shows excessive continuous page faults for me so there is something fundamentally very wrong with it from where I am sitting - not even using anything other than do, sync(), loop and moving the window!!! Normally the mocking phrase is don't give up your day job(not you!). They need to actually give up their day jobs. Period.
Win 7 Pro 64 bit SP1, AMD A4-5300 APU 3.4GHz, 8GB DDR3, NVidia GeForce GTX 750 1GB GDDR5, ASUS A55BM-E
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 5th May 2021 17:42
I wouldn't put it that hard, it has quite some good functionality but when it comes to 3d... well...

It's just a bit pity because I really like it. But those commands are essential for what I tried to do. Again thanks for your help, this community is just great!
James H
16
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 5th May 2021 17:57
Well I can hardly mock them with the usual phrase - it is their day job lol, but yeah now I read it it does sound exceptionally harsh! Probably should.t have added "period" or said "actually" as it does sound rather finite! I guess I am getting sick of finding issues, feels almost deliberate lol. Best of luck man, I've already started looking elsewhere as there are free better alternatives.
Win 7 Pro 64 bit SP1, AMD A4-5300 APU 3.4GHz, 8GB DDR3, NVidia GeForce GTX 750 1GB GDDR5, ASUS A55BM-E
SFSW
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 6th May 2021 02:57
That does produce strange results for me also. On a side note, in case anyone else might want to accomplish the same kind of thing, here is an approach that just involves performing a ray cast directly, then retrieving the contact point and normals (based on the same code, just with the physics command set remmed out and replaced):



You can optionally press the spacebar to re-run the collision check.
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 6th May 2021 09:36
Oh wow, thanks so much. That looks good actually!

Login to post a reply

Server time is: 2024-04-20 15:07:55
Your offset time is: 2024-04-20 15:07:55