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 / 2D to 3D Mapping bug

Author
Message
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 4th Dec 2017 22:08 Edited at: 4th Dec 2017 22:43
By bug i mean bug in my code. I am trying to make a Kart Game

Just so you know. The project will create a file called body.obj in your Documents directory. Which it uses to build the kart

I have a Path.pth file which defines the boundaries of the track
I load the Path.pth file and using the same co-ordinates i build 2D shapes and draw 3D lines to define and show the boundaries
Now the 2D co-ordinates are 50 times larger than the 3D ones (I'm not sure if that is part of the problem but it seemed like the 2D co-ordinates need to be bigger to work)
My problem is that at some parts of the geometry the car will pierce the geometry and at others it won't.
It is driving me NUTS!!!

To see it happen just drive the car along the outer boundary, hugging the edge. Notice in the second image how the tire is OVER the green line



Attached is the project file.
Any help/advice would be greatly appreciated

Attachments

Login to view attachments
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 5th Dec 2017 07:42
I thought I'd have a quick bug hunt before work this morning but I can't get the code to compile so I can't see what the issue is.
There appears to be an incompatibility with shader that you're using.

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 5th Dec 2017 07:57
It doesn't use a shader (other than the default). Maybe it requires the latest version but i can't imagine why.
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 5th Dec 2017 08:42
How odd!

I tried it at work where I have 2017.5.15 installed.
I'll try it again when I get home tonight, I have the latest version at home.

It seems very odd that it should make a difference with compiling the code though.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 5th Dec 2017 09:01
Yes. Me too. They did say the latest release would break stuff though. However i'm not sure i'm using any features of the latest release
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 5th Dec 2017 20:17 Edited at: 5th Dec 2017 20:18
I changed it so the scale is smaller. It highlights the problem a little better i think (Spacebar gives you a top down view)

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 5th Dec 2017 20:53
Quote: " but it seemed like the 2D co-ordinates need to be bigger to work)"

i guess it belongs the SetVirtualResolution
i think SetVirtualResolution( 100, 100) as 100x100 cm is much better if your .path file also using 100 units = 100 cm
AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.11.4) Radeon R7 265 : Mac mini OS High Sierra (10.13)
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 5th Dec 2017 20:59
I gave that a try and it doesn't seem to make any difference.
The thing is; It's entirely inconsistent. Sometimes it will be half way outside the lines and sometimes it will be well inside the lines
It doesn't seem to follow any pattern i can see
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 5th Dec 2017 23:06 Edited at: 5th Dec 2017 23:10
what i saw u often use integer values
*400
maybe try if it make a difference if you write .0 at the end
*400.0

yes with your new example i see your problem better
AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.11.4) Radeon R7 265 : Mac mini OS High Sierra (10.13)
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 5th Dec 2017 23:14 Edited at: 5th Dec 2017 23:18
The physics positions are being shifted by 5 pixels along the x and y axis. I can see nothing in my code that would cause this and i'm not sure if the 5 pixels will change if i scale it differently
I have changed the code here (boundary.agc:CreateABoundary()) to shift the physics shapes by 5 pixels along the x/y axis. Note that the 3D co-ordinates are NOT being shifted


As i said; "I cannot find anywhere in my code where it is being shifted". So is this a bug in the physics commands??

See attached project for my patched code. Everything lines up

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 5th Dec 2017 23:35 Edited at: 5th Dec 2017 23:37
i think your 3d outline is wrong.
AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.11.4) Radeon R7 265 : Mac mini OS High Sierra (10.13)
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 5th Dec 2017 23:45
How so? It uses the same numbers as the 2D one
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 6th Dec 2017 00:06
suggestion, please can you make a real point list and not using any calculation after inside a function.
then using this list for 3d track outline and also for 2d.

what i tryed was a global point list and than draw it on screen


AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.11.4) Radeon R7 265 : Mac mini OS High Sierra (10.13)
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 6th Dec 2017 00:22 Edited at: 6th Dec 2017 00:24
I tried changing my 2D point code to look like yours but it didn't work;


Do you think you could alter the project so i can see what you mean?
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 6th Dec 2017 01:02
I incorporated your code into the project. It shows some points hanging out in space but i think they might be points that are off screen.
The points that are on the track line up EXACTLY with the 3D points/lines and do NOT match the 2D points

See attached project

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 6th Dec 2017 01:40
i meant using like this without temporary calculations everywhere
= GetScreenXFrom3D ( f.x , f.y, f.z )
= GetScreenYFrom3D ( f.x , f.y, f.z )
once calculated and then used for 3d/2d
Quote: "It shows some points hanging out in space but i think they might be points that are off screen."

for any reason the pointlist was only one side of the track.
i don't know why points was beside the track.
AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.11.4) Radeon R7 265 : Mac mini OS High Sierra (10.13)
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 6th Dec 2017 02:24
But those functions simply show where on the screen the 3D point is. How does that help me?
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 6th Dec 2017 03:29 Edited at: 6th Dec 2017 03:33
I created a very simple example.;

Top right is a box within four walls. You can use the arrow keys to apply force to it.
It takes the 2D co-ordinates from the box and applies them to the position of the sphere in 3D space. Other than scaling down the 2D co-ordinates by 10 there are NO other calculations.

The four walls are centered around position (0,0) The planes position is (0,0,0) (I use setviewoffset to shift the display so you can see the box)
If you move the box to the far corners of the walls you will see that the co-ordinates returned by the physics system are skewed. The ball will move to the far right and bottom of the plane but not to the left and top of the plane.

There must be something i am doing wrong!
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 6th Dec 2017 11:02 Edited at: 6th Dec 2017 11:08
Quote: "There must be something i am doing wrong!"

yes, i found it.
see Draw2Dline remarks and screenshot. start and then use the row with //OK
i made Draw2Dline2 for verifying.
AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.11.4) Radeon R7 265 : Mac mini OS High Sierra (10.13)

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 6th Dec 2017 18:36
Yes yes yes!!
Thank you so much! It works!
It works in the game as well. I should have realized that it creates a sprite with dimension

Login to post a reply

Server time is: 2024-11-27 23:55:27
Your offset time is: 2024-11-27 23:55:27