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 / [SOLVED] Manipulate vertex on object

Author
Message
Carharttguy
7
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 25th Jun 2019 21:52
Hello

I'm trying to manipulate a vertex on a plane; So I did some simple testing.
I wanted to change 1 vertex on a plane by using this code:



However, the plane looks like a normal plane, where I would expect to have 1 vertex a lot 'higher' than the others.

What am I missing here?

Thanks!

The author of this post has marked a post as an answer.

Go to answer

fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 25th Jun 2019 22:09
works fine for me
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 25th Jun 2019 22:27
Same here...your code works fine
I'm not a grumpy grandpa
Carharttguy
7
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 26th Jun 2019 07:34
Thanks for your prompt replies!

I must be doing something wrong, or my expectations are wrong.
This is my full code:



And this is what I see:



It seems too flat, no?
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 26th Jun 2019 07:58 Edited at: 26th Jun 2019 08:01
This post has been marked by the post author as the answer.
the problem is the camera angles
try changing CreateObjectPlane(1, 10, 10)
and commenting these lines out
//SetCameraPosition(1, 0, -150, 50)
//SetCameraLookAt(1, GetObjecTX(1), GetObjectY(1), GetObjectZ(1), 0)

you could try and rotate the object rather than position the camera in some obscure way
ie RotateObjectLocalX(1,90) mind you if you rotate the object you should do it before you do
your vertex calculations and they will then be different
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 26th Jun 2019 09:14 Edited at: 26th Jun 2019 09:16
Its because there is a front side plane and a rear side plane in an AppGameKit plane.... Your looking at the backside of the plane while manipulating a vertex that is on the other (front) side

Just change your camera position like fubarpk said above

SetCameraPosition(1, 0, -150, -50)

and you will see the moved vertex! You cant see it from your current perspective as backface culling and the direction you looking from wont show it.


Alternatively leave your camera where it is and move vertex number 6 which is on the side your looking at and you see it has moved.
Carharttguy
7
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 26th Jun 2019 10:20
Aha ok, now I get it!

There are 2 more things that I don't seem to understand:
-Why does a plane hava 2 sides? Isn't a plane a just a square? So 2 polygons?
-How are there 12 vertices? I tought it would be 4 (the 4 corners), but ok, if there is also a backside, I count 8, where are those other 4? (Is there a way to 'show' vertices?)

Thanks a bunch for the great answers.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 26th Jun 2019 11:45 Edited at: 26th Jun 2019 11:56
This one wasn't by me but by Chafari but I think its very usefull
Find the VertexData of an Object presently shows the vertex's of a cube but easily changed
If you change it to an objectplane you can step through what vertexs are needed for which



its a good method of finding all vertex points at a corner
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 26th Jun 2019 11:57 Edited at: 26th Jun 2019 12:01
Quote: "Why does a plane hava 2 sides? Isn't a plane a just a square? So 2 polygons?"


It has 2 sides due to the fact that triangles that face away from the camera are not drawn (due to Screen culling). As the documentation states ..."Creates a 3D double sided plane with the given width (X) and height (Y)."
Backface triangles (ones that are not facing the camera) are not drawn unless you specifically turn off backface culling in AppGameKit and open gl. Also the normals for those triangles would be pointing in the opposite direction if if you forced them to be drawn by turning culling off so the lighting would look odd. The easiest way to fix these issues is simply to use 4 triangles (2 on the front and 2 on the rear) and then no culling changes and no special lighting is needed...it just works.

Quote: "-How are there 12 vertices? I thought it would be 4 (the 4 corners), but ok, if there is also a backside, I count 8, where are those other 4? (Is there a way to 'show' vertices?)"

There are 4 traingles...each triangle has 3 vertices = 3 x 4 = 12 vertices processed

A plane object is fairly unique in AppGameKit as it doesnt use indexed vertices. It literally stores 12 vertices and no indices at all. It uses non indexed triangle drawing mode. Even if it did reuse the corners, the vertices would still be processed twice to display the two triangles it used on.
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 26th Jun 2019 13:02 Edited at: 26th Jun 2019 13:03
Thanks fubarpk ... I coudn't find this example in my old junk .

Here's the image of the vertex plane order in Agk with the camera in 0,0,30
I'm not a grumpy grandpa

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-04-20 10:24:34
Your offset time is: 2024-04-20 10:24:34