Ergebnis 1 bis 1 von 1

Thema: Größe eines Models rausfinden

  1. #1

    Standard Größe eines Models rausfinden

    Ich versuche mit Lua die größe eines Models/Entities rauszufinden. Die wiki.garrysmod.com ist ja noch ziemlich lückenhaft was das angeht :/
    Im Adv. Stacker gibts eine funktion die das macht. Nur habe ich absolut keine Ahnung was die genutzen Funktionen(...AABB, ...OBB) machen.
    Lua Code:
    1. function TOOL:CalcOffset( ent )
    2.  
    3. 	-- makes ghosts' DoRagdollBone() 5-7 times faster
    4. 	if CLIENT && mem[ent] && mem[ent].frame == FrameNumber() then return mem[ent].transl, mem[ent].rot end
    5.  
    6. 	local usephysics = self:GetClientBool( USEPHYSICS )
    7. 	local worldspace = self:GetClientBool( WORLDSPACE )
    8. 	local dir = self:GetClientNumber( DIRECTION )
    9. 	local offset = self:GetClientVector( OFFSET )
    10. 	local offset_td = self:GetClientBool( OFFTIMESDIM )
    11. 	local rot = self:GetClientAngle( ROTATION )
    12. 	local roto = self:GetClientVector( ROTORIGIN )
    13.  
    14. 	local ang, mins, maxs, rotoffset
    15.  
    16. 	if worldspace then
    17. 		ang = Angle(0,0,0)
    18. 		mins, maxs = ent:WorldSpaceAABB()
    19. 		rotoffset = vector_origin
    20. 		--[[
    21. 		roto = ent:LocalToWorld( roto ) - ent:GetPos()
    22. 		rotoffset = roto - VecRotate( roto, rot )
    23. 		rot = ent:LocalToWorldAngles( ang - rot )
    24. 		--]]
    25. 	else
    26. 		ang = ent:GetAngles()
    27.  
    28. 		assert( !(usephysics && CLIENT) )
    29. 		if usephysics && IsValid( ent:GetPhysicsObject() ) then
    30. 			for _, obj in PhysObjects(ent) do
    31. 				local omins, omaxs = obj:GetAABB()
    32. 				if !mins then
    33. 					mins = obj:LocalToWorldVector(omins)
    34. 					maxs = obj:LocalToWorldVector(omaxs)
    35. 				else
    36. 					mins = VecMin( mins, obj:LocalToWorldVector(omins) )
    37. 					maxs = VecMax( maxs, obj:LocalToWorldVector(omaxs) )
    38. 				end
    39. 			end
    40. 		else
    41. 			mins, maxs = ent:OBBMins(), ent:OBBMaxs()
    42. 		end
    43.  
    44. 		--offset = ent:LocalToWorld( offset ) - ent:GetPos()
    45. 		rotoffset = roto - VecRotate( roto, rot )
    46. 		rotoffset = ent:LocalToWorld( rotoffset ) - ent:GetPos()
    47. 		rot = ent:LocalToWorldAngles( rot ) - ent:GetAngles()
    48. 	end
    49.  
    50. 	local dimensions = maxs - mins
    51. 	if offset_td then
    52. 		offset.x = offset.x * dimensions.x
    53. 		offset.y = offset.y * dimensions.y
    54. 		offset.z = offset.z * dimensions.z
    55. 	end
    56.  
    57. 	local transl = dir == 0 and vector_origin or (-1)^(dir-1) * ang[ dirs[dir] ](ang) * dimensions[ dims[dir] ] -- ÿ ìàíüÿã, çíàþ.
    58. 	offset = ang:Forward()*offset.x - ang:Right()*offset.y + ang:Up()*offset.z
    59. 	transl = transl + offset + rotoffset
    60.  
    61. 	if CLIENT then mem[ent] = { frame = FrameNumber(), transl = transl, rot = rot } end
    62. 	return transl, rot
    63. end

    Kennt jemand eine Lösung/Möglichkeit (die GM:Think "fähig"(Custom AI) ist)?

    Edit: nvm. 2 Stunden nach dem ich den Beitrag hier geschrieben hatte, sind die Befehle nicht mehr nicht dokumentiert.
    Geändert von CGamer (20.02.2010 um 18:56 Uhr) Grund: Wiki Update

Ähnliche Themen

  1. [Problem] - Textur eines Models
    Von PytonB!tch im Forum Models & Skins
    Antworten: 4
    Letzter Beitrag: 04.01.2009, 19:46
  2. Einzelne teile eines models mit anderen phys attribs
    Von micropro im Forum Models & Skins
    Antworten: 5
    Letzter Beitrag: 26.05.2008, 15:06
  3. Größe
    Von Kevin_N. im Forum Hilfe & Support
    Antworten: 8
    Letzter Beitrag: 19.01.2008, 16:58
  4. Große Stahlplatte (War: help)
    Von 45.Colt im Forum Suche
    Antworten: 6
    Letzter Beitrag: 17.04.2007, 17:49
  5. Die größe der zitadelle
    Von Dark im Forum Mapping
    Antworten: 1
    Letzter Beitrag: 13.03.2007, 14:38

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •