ARPrintPick

From Blue Mars Developer Guidebook

Jump to: navigation, search
There are security restrictions on this article

This is an Avatar Reality Utilities function.

Function

ARPrintPick(count)
print results of most recent ARMousePick call
count - number of hit results to print

Notes

This function demonstrates how to access the contents of the results table are filled in by Physics.RayWorldIntersectionAR and Physics.RayWorldIntersection. It uses ARPrint to print on-screen and log common information, and ARPrintEntity when the result is an entity.

count should be the number returned by ARMousePick. Note this function shares a global variable g_hitTable with ARMousePick. For your own purposes, you should copy and customize ARMousePick and this function as appropriate, using your own shared table, and processing the result in a suitable manner for your own application.

Code

function ARPrintPick(count)
   ARPrint("Found "..count.." intersections");
   for i = 1,count do
      local firstHit = g_HitTable[i];
      ARPrint("hit type: "..g_HitResultTypes[firstHit.type+1]);
      ARPrint("hit pos: "..Vec2Str(firstHit.pos));
      ARPrint("hit normal: "..Vec2Str(firstHit.normal));
      ARPrint("hit dist: "..firstHit.dist);
      if firstHit.entity then
	 ARPrintEntity(firstHit.entity);
      end
      if firstHit.renderNode then
	 ARPrint("hit rendernode: "..tostring(firstHit.renderNode));
      end
      if firstHit.surface_idx then
	 ARPrint("hit surface: "..tostring(firstHit.surface_idx));
      end
   end
end

String representations for the hit types.

g_HitResultTypes = {
   "TERRAIN",
   "STATIC",
   "ENTITY",
   "FOLIAGE",
   "ROPE",
   "OBSTRUCTION",
   "WATERVOLUME",
}
Problems with this wiki page? Contact us either by: Support Email or Support Ticket System

Blue Mars Guidebook Privacy Policy
Blue Mars Guidebook Community Guidelines

Personal tools