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 / face from object

Author
Message
oJoe
2
Years of Service
User Offline
Joined: 30th Apr 2021
Location:
Posted: 30th Apr 2021 18:01
Hello,

how can i get a return of a face from a 3D object ?

ObjectRayCast (0,rayStartX,rayStartY,rayStartZ,rayEndX,rayEndY,rayEndZ) // is useful for complete object

but I need only a face from the object.

sorry, english is not my strong point

thx,
joe
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 30th Apr 2021 19:01
to get an object to face an object
SetObjectLookAt ( objID, x, y, z, roll )
where x,y,z would be the other objects position
to then face the opposite direction or face away from it
RotateObjectLocalY ( objID, amount )

if thats what you want to do

the raycastfunctions are for determining if a collision has occurred

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
MikeHart
AGK Bronze Backer
20
Years of Service
User Offline
Joined: 9th Jun 2003
Location:
Posted: 2nd May 2021 11:48
Quote: "the raycastfunctions are for determining if a collision has occurred"


And that is what he is after. The Triangle or Quad (Face) that the ray hit.
James H
16
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 3rd May 2021 22:08
Cast your ray, determine which coordinate is the point of contact(if result is global you will need to calculate local coordinates in relation to the object being ray cast upon ie calculate the difference)

Grab a mesh of your object

Convert your objects mesh into memblock data.

Every 3 vertices is 1 triangle/polygon in the memblock - these are all local coordinates, hence why step one needs anything global converting. So you can then iterate through each poly/tri in memblock and compare the ray cast coordinates to each of the tri/poly's vertices by calculating distance. The smallest distance is the poly/tri where the ray cast contact point occurred. Use the position within the memblock as a reference to which poly/tri is being targeted.

The above points seem simple, however if you are unfamiliar with memblocks you need to get stuck into them first as you will presumably be wanting to create a visual representation of the tri you are aiming at which will then involve creating your own object to overlay at the exact position required. Memblocks are relatively easy though so you shouldn't have too much of a problem
Win 7 Pro 64 bit SP1, AMD A4-5300 APU 3.4GHz, 8GB DDR3, NVidia GeForce GTX 750 1GB GDDR5, ASUS A55BM-E
oJoe
2
Years of Service
User Offline
Joined: 30th Apr 2021
Location:
Posted: 9th May 2021 17:15
thanks for the help

fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 9th May 2021 20:33
apologies i didnt quite understand

if its a building(object) for example using memblocks may not be the best approach if you just wanted the player to look at the door
for this i would attach an invisible object with collisions disabled at the door and use that to point your character at

it might just be an object you create with code and fix to the object so when the main object is rotate etc the door etc object moves
and rotates with it. If its a person for example and you want the head to look at another persons face there is bone commands etc depending
on how the model has been set up


fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk

Login to post a reply

Server time is: 2024-03-29 08:02:09
Your offset time is: 2024-03-29 08:02:09