|
Go
![]() |
New
![]() |
Find
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
| <nerz>
|
Never mind I figured this out on my own.
|
||
|
|
Member |
hi nerz
i also in need to find out the 3d point of the object,when i click on the object. if u got any solution please share with me. |
|||
|
|
Member |
Hi
I found one intersting solution in the forum it self. Here is it for your reference. For your purpose you can use the WorldPoint event. WorldPoint is a 3D point which of course has it's children WorldPoint.x, WorldPoint.y, and WorldPoint.z. So this will return the point in space where an objects surface has been clicked, so you can copy that point to the location of another object, or send the coordinates to a javascript function as in the below example: <MTSScene Version="313"> <MTSSceneParms RenderMode="LightTexture" BlendShadow="1" EdgeBias="1"/> <MTSCamera OrbitDist="5"> <ViewLocation x="0" y="0" z="4"/> <Rotate x="23" y="45" z="0"/> </MTSCamera> <MTSInstance Name="Simple_0" PassClick="1"> <Transform> <Scale x="0.201" y="0.201" z="0.201"/> </Transform> <MTSGeometry Name="MTSSimple_0" Type="MTSSphere"/> </MTSInstance> <MTSInstance Name="Simple_1"> <Transform> <Scale x="2" y="2" z="2"/> </Transform> <MTSGeometry Name="MTSSimple_1" Type="MTSCube"/> <MTSHandle Event="MouseLeftDown" Action="MTSCopyProperty" Src="MTSEvent.WorldPoint" Dest="Simple_0.loc_"/> <!-- example of sending coords to a javascript function (requires there be a function in the page to receive the coords) <MTSHandle Event="MouseLeftDown" Action="MTSJavaScript" Target="showCoords(MTSEvent.WorldPoint.x,MTSEvent.WorldPoint.y,MTSEvent.WorldPoint.z)"/> --> </MTSInstance> </MTSScene> |
|||
|
| <Niko>
|
you need to use the context (IPB_Context3d) directly (instead of the scene)
then call IPB_Context3d::SZID* pick = context->GetPickArray(); it returns the informations about the last pick. (you will need to pick first) the 32 higher bits of the is can be casted to IMTS_Instance3d* ((IMTS_Instance3d*)(uint64(pick[i].id)>>32)) the low 32 bits are the face index in the geometry of this instance. having the pick.z the face which has been clicked, the world matrix of the instance anbd the 2d coordinates of the pick, you compute (projecting this face on the screen) where you clicked on this face... so where you clicked in the world.... note that to compute the Z coordinate of the click, you will need to convert pick.z in scene coordinate. to do it apply the following code: mreal Z = PB_ConvertFromZElem(pick[i].z-context->GetZTranslation()); Z = context->GetNearPlane()/Z; |
||
|
|
Member |
Hi Niko !!
Can you explain the thing little bit deeper? |
|||
|
| Powered by Eve Community |
| Please Wait. Your request is being processed... |
|

