• DModelPanel campos
    6 replies, posted
hey im trying to get my model panel to display the model and face the face of the model. but the vectors are so confusing i just cant get it in the right pos. [IMG]http://i.imgur.com/F7sjV5Q.png[/IMG] [CODE]local icon1 = vgui.Create( "DModelPanel", bg1 ) icon1:SetPos( 10, 10 ) icon1:SetModel( npcmodel ) icon1:SetSize( 150, 100 ) icon1:SetCamPos( Vector( -20, 0, 100 ) ) icon1:SetFOV(30) icon1:SetLookAt( Vector( 0, 0, 0 ) ) function icon1:LayoutEntity( Entity ) return end[/CODE] can any one help me position it to make the cam face the model
You're setting the Z pos of the camera way up high, and setting the camera to look at the feet / origin ( all players positions start at the feet ) without moving the camera back.. Do something like this: [code]local INCH = 4 / 3; local FOOT = INCH * 12; local _ent = icon1.Entity; local _mins, _mids, _maxs = _ent:OBBMins( ), _ent:OBBMids( ), _ent:OBBMaxs( ); -- We're only using maxs, but to get the difference you'd need mins and maxs. // Set the camera at the top of the model and a suitable direction backwards by height / 12 feet in units away.. so a 72 unit will yield 4.5 feet away from the object icon1:SetCamPos( _maxs + _ent:GetAngles( ):Forward( ) * ( FOOT * ( _maxs.z / 12 ) ) ); // Make the camera look at the center of the object icon1:SetLookAt( _mids );[/code]
[QUOTE=Acecool;46633459]You're setting the Z pos of the camera way up high, and setting the camera to look at the feet / origin ( all players positions start at the feet ) without moving the camera back.. Do something like this: [code]local INCH = 4 / 3; local FOOT = INCH * 12; local _ent = icon1.Entity; local _mins, _mids, _maxs = _ent:OBBMins( ), _ent:OBBMids( ), _ent:OBBMaxs( ); -- We're only using maxs, but to get the difference you'd need mins and maxs. // Set the camera at the top of the model and a suitable direction backwards by height / 12 feet in units away.. so a 72 unit will yield 4.5 feet away from the object icon1:SetCamPos( _maxs + _ent:GetAngles( ):Forward( ) * ( FOOT * ( _maxs.z / 12 ) ) ); // Make the camera look at the center of the object icon1:SetLookAt( _mids );[/code][/QUOTE] i get a error for obbmids attempt to call obbmids <nill value>. i want the camera to be a close up profile view of the face and sholders. this is not easy to just add by 5's and move the camera around. 1 second its almost perfict so i add just 5 to x and the camera spins around???
Sorry, it's OBBCenter instead of OBBMids... For it to look at the face, use the OBBMaxs instead of OBBCenter or GetAttachment / Bone for head for SetLookAt...
[QUOTE=Acecool;46633796]Sorry, it's OBBCenter instead of OBBMids... For it to look at the face, use the OBBMaxs instead of OBBCenter or GetAttachment / Bone for head for SetLookAt...[/QUOTE] now the panel is blank i tryed all of them its only (150, 100) panel size. would that matter?
The size shouldn't matter but I'm not sure the contents do; you may need to zoom in/out depending how large it is. Forward may be relative with the entity in a dmodelpanel... Try multiplying that value by -1 to move it in the opposite direction. [code]local INCH = 4 / 3; local FOOT = INCH * 12; local _ent = icon1.Entity; local _mins, _mids, _maxs = _ent:OBBMins( ), _ent:OBBCenter( ), _ent:OBBMaxs( ); -- We're only using maxs, but to get the difference you'd need mins and maxs. // Set the camera at the top of the model and a suitable direction backwards by height / 12 feet in units away.. so a 72 unit will yield 4.5 feet away from the object icon1:SetCamPos( _maxs + _ent:GetAngles( ):Forward( ) * -1 * ( FOOT * ( _maxs.z / 12 ) ) ); // Make the camera look at the center of the object icon1:SetLookAt( _mids ); [/code]
[CODE] icon1:SetCamPos( Vector( -20, 0, 90 ) ) icon1:SetLookAt( Vector( 0, 0, 90 ) ) [/CODE]
Sorry, you need to Log In to post a reply to this thread.