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
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
Posted: 2nd May 2021 11:48
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.
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
Posted: 9th May 2021 17:15
thanks for the help
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