Mesh Size?

Advanced game related topics
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Mesh Size?

Post 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.
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

Re: Mesh Size?

Post by Bananenfreak »

Hmm, with Boundingbox?
Image
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Re: Mesh Size?

Post by Mythros »

How would I do this? I'm new to bounding boxes. :oops:
User avatar
falsam
Enthusiast
Enthusiast
Posts: 630
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: Mesh Size?

Post 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
Last edited by falsam on Mon Sep 16, 2013 6:06 pm, edited 2 times in total.

➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect.
Mythros
Enthusiast
Enthusiast
Posts: 306
Joined: Mon Aug 19, 2013 3:28 pm

Re: Mesh Size?

Post by Mythros »

Thank you very much, Falsam! =) This is PERFECT!
Post Reply