Page 1 of 1

Mesh Size?

Posted: Mon Sep 16, 2013 3:28 pm
by Mythros
How do you get a mesh's size (X, Y, Z)?

I want to be able to return the correct sizes in seperate functions.

Re: Mesh Size?

Posted: Mon Sep 16, 2013 5:00 pm
by Bananenfreak
Hmm, with Boundingbox?

Re: Mesh Size?

Posted: Mon Sep 16, 2013 5:07 pm
by Mythros
How would I do this? I'm new to bounding boxes. :oops:

Re: Mesh Size?

Posted: Mon Sep 16, 2013 5:35 pm
by falsam
Contributor : Comtois
http://www.forums.purebasic.com/english ... 36&t=55959

Code: Select all

InitEngine3D()
InitKeyboard()
InitSprite()

window = OpenWindow(#PB_Any,0,0,1024,768,"Entity Size")
OpenWindowedScreen(WindowID(window),0,0,1024,768)

Camera = CreateCamera(#PB_Any,0,0,100,100)
MoveCamera(Camera, 0, 5, 3)
CameraLookAt(camera,0,0,0)

Mesh = CreateCube(#PB_Any, 1) 
Entity = CreateEntity(#PB_Any, MeshID(Mesh),  #PB_Material_None , 0, 0, 0)

ScaleEntity(Entity, 2, 1, 5)

GetEntitySize = #True

While #True  
  Event = WindowEvent()
    
  ExamineKeyboard()  
  
  If Event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
    Break
  EndIf    

  ClearScreen(RGB(0, 0, 0))
  RenderWorld() 
  
  If GetEntitySize = #True 
    Debug "X : " + Str(EntityBoundingBox(Entity, #PB_Entity_MinBoundingBoxX | #PB_Entity_WorldBoundingBox) / EntityBoundingBox(Entity, #PB_Entity_MinBoundingBoxX | #PB_Entity_LocalBoundingBox))
    Debug "Y : " + Str(EntityBoundingBox(Entity, #PB_Entity_MinBoundingBoxY | #PB_Entity_WorldBoundingBox) / EntityBoundingBox(Entity, #PB_Entity_MinBoundingBoxY | #PB_Entity_LocalBoundingBox))
    Debug "Z : " + Str(EntityBoundingBox(Entity, #PB_Entity_MinBoundingBoxZ | #PB_Entity_WorldBoundingBox) / EntityBoundingBox(Entity, #PB_Entity_MinBoundingBoxZ | #PB_Entity_LocalBoundingBox))
    GetEntitySize = #False  
  EndIf
  
  FlipBuffers()
Wend
PS : RenderWorld() should be called before debug

Re: Mesh Size?

Posted: Mon Sep 16, 2013 5:55 pm
by Mythros
Thank you very much, Falsam! =) This is PERFECT!