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 / Mesh Vertex world co-ords

Author
Message
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 10th Dec 2017 01:50
So, I have made this function where I can use a fan object to simulate spotlight effect by ray tracing the vertices for collision. Works a treat

But when I rotate my beam, the vertex values are stuck relative to the origin and they don't rotate with the object.

I use the nice GetMeshMemblockVertexX() etc. functions to find the positions for the ray trace, but I need the world co-ords of my vertices once I rotate my object, not the object relative (local without rotation) vertices.

I *could* attach a null object to the vertices and fixobject blah blah to keep track, but is there a nice way to get the world co-ods of the internal vertices?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 10th Dec 2017 11:26 Edited at: 10th Dec 2017 11:27
u can't use ?
GetObjectRayCastX ( index )
GetObjectRayCastY ( index )
GetObjectRayCastZ ( index )
GetObjectRayCastBounceX
GetObjectRayCastBounceY
GetObjectRayCastBounceZ
AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.11.4) Radeon R7 265 : Mac mini OS High Sierra (10.13)
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 11th Dec 2017 17:47
Basically, GetMeshMemblockVertexX() etc, return the local offset value of Vertex from origin.
If the object is say, rotated around then adding GetMeshMemblockVertexX() to GetObjectX() which is the origin, doesn't give you the world position of the vertex, just the relative X position, which doesn't change.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 11th Dec 2017 18:40 Edited at: 11th Dec 2017 19:19
i understand but me thought "ray tracing the vertices for collision"
you used a raytrace and have the hit position.
you will start a raytrace from each rotated vertex?
i imagine you have light rays and a rotated fan and will create a light effect, but then the light ray is blocked or not or get a break into other directtion.
i don't understand why you need the vertices.
screenshot?

other idea is to use the object quaternion information and rotate your vertices self and add the obj position.
AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.11.4) Radeon R7 265 : Mac mini OS High Sierra (10.13)
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: 11th Dec 2017 20:16
You need to use the matrix math commands that Paul never added.
If he did it would be simple just multiply the rotation matrix by the vector which has the X,Y,Z coordinates.
Wait a minute didn't someone create a matrix math library for Tier 1?
The coffee is lovely dark and deep,and I have code to write before I sleep.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 14th Dec 2017 20:34
@markus: I use a fan object like this

The left point is the origin of the object and I try to match the vertices of the fan at the collision point of the object.
I ray trace from origin to the expected vertex location and reposition the vertex at the collision site.

Trouble is, the vertex position is local to the origin, so transforming the world collision point to the local relative vertex point is the issue.

Attachments

Login to view attachments
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 14th Dec 2017 22:45
@stab there's a library here, but how to use?

I have tried to use some of it in the past, but failed.
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: 15th Dec 2017 02:24
I will look over the library, not sure if it is complete.
Simply you build a world matrix which contains the rotation for the object then multiply the vector which
will give you the new vector location. Maybe a simple code example of what you are trying to do.
The coffee is lovely dark and deep,and I have code to write before I sleep.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 15th Dec 2017 22:10
I don't know how to "build a world matrix"; I wish there was an example for it.

The tracing stuff is fine, but the collision points are world and the vertex positions I need to set are local.

If I rotate the beam, say by 30 degrees and intersect an object, the local vectors are 30 degrees off from the beam, not the object.
I sort of get the idea of a world matrix, but would love to just see a local rotation -> world co-ord transformation example and vice versa.
I've spent a month on this and it's getting too frustrating after trying so many techniques.




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: 16th Dec 2017 00:20
I will look over the library this weekend and create an example if I can using the library.
Can you create a small code example of what you are trying to do? I can then add the matrix math to it.
The coffee is lovely dark and deep,and I have code to write before I sleep.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 16th Dec 2017 16:52
I've made a little test project showing the issue.
You'll see I'm moving a temp object up the right hand side of the fan to get the global position of the ray target. I was originally using the calculated vertex position at one point (base position + vertex values)

The fan object is the one in the picture a few posts up. It's origin is at the left side of the triangle and the example rotates about that point.

At one earlier point I was using vectors, now it's back to co-ords. I was getting the same problem with either method.

Fingers crossed!

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 17th Dec 2017 03:01 Edited at: 17th Dec 2017 03:10
I'm not sure this will be fast enough for you but you could try this;
1. Create an object (I would say a plane for min polys). Set it's position to the absolute position of the vertex (The co-ordinates you extract from your Memblock)
2. Fix that object to your fan
3. Get the world co-ordinates of the object you created in 1

Don't worry if you've rotated and scaled the object. FixObjectToObject() will manage that for you
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 17th Dec 2017 11:16
how about this,
i use 2 object as line to simulate a rotated hand fan.
if you collect this 3d coords you can create a new triangle mesh in world space.
(its not a real 3d line)
AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.11.4) Radeon R7 265 : Mac mini OS High Sierra (10.13)
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 20th Dec 2017 02:21
@Blink
Quote: "I'm not sure this will be fast enough for you but you could try this;
1. Create an object (I would say a plane for min polys). Set it's position to the absolute position of the vertex (The co-ordinates you extract from your Memblock)
2. Fix that object to your fan
3. Get the world co-ordinates of the object you created in 1
"


I don't have any problem getting the world co-ord of the vertex. It's the setting of the world co-ord back to the vertex is the problem
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 20th Dec 2017 02:23
@markus:
Quote: "how about this,
i use 2 object as line to simulate a rotated hand fan.
if you collect this 3d coords you can create a new triangle mesh in world space.
(its not a real 3d line)
"


I thought about that too. I made a triangle mesh but there will be seams.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 20th Dec 2017 07:44
Quote: " I made a triangle mesh but there will be seams."

seams in fan obj made from mem block? why?
AGK (Steam) V2017.12.12 : Windows 10 Pro 64 Bit : AMD (17.12.1) Radeon R7 265 : Mac mini OS High Sierra (10.13)
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 23rd Dec 2017 02:02
Oh, you don't mean make a separate object for each triangle, do it all in one?
Well, I would be back at the start again, because I don't know where to put the local vertex in world space again. I already have an object with all the vertices available.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 23rd Dec 2017 10:30 Edited at: 23rd Dec 2017 10:32
yes i meant one fan object with some triangles.
why you need them local ? you can also create a non rotated object with a mesh in world coords or not, it looks same?

i you really will use your rotated mesh u need a vector transform as mentioned above (i tryed but had no success with quaternion matrix)

or as workaround may create dummy objects for vertex and use
FixObjectToObject
MoveObjectLocalX ( objID, amount )
MoveObjectLocalY ( objID, amount )
MoveObjectLocalZ ( objID, amount )
GetObjectWorldX ( objID )
GetObjectWorldY ( objID )
GetObjectWorldZ ( objID )
GetObjectX ( objID )
GetObjectY ( objID )
GetObjectZ ( objID )
AGK (Steam) V2017.12.12 : Windows 10 Pro 64 Bit : AMD (17.12.1) Radeon R7 265 : Mac mini OS High Sierra (10.13)
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 30th Dec 2017 16:15
Well, I tried again to transform the matrix and also failed.
The workaround using local movement does work but is not as elegant.

It would be great if transformations were added to the command set.

Login to post a reply

Server time is: 2024-11-24 03:31:48
Your offset time is: 2024-11-24 03:31:48