Drawing the same entity more than once in different locations. Is it possible?
9 replies, posted
In any way at all?
Yes
[editline]saving my ass from manhalis' banhamma of not liking the funny[/editline]
Put multiple cam.Start3D(pos,ang) statements in the ent's draw hook and use self:DrawModel() there.
Alright, I figured that was the only way. Are the parameters to that local to your camera? I can never get them right and the models always follow my view.
I doubt it, the 3d2d ones aren't.
[editline]10:21PM[/editline]
[lua] local ang = self:GetAngles()
ang:RotateAroundAxis(ang:Right(), rot.x)
ang:RotateAroundAxis(ang:Up(), rot.y)
ang:RotateAroundAxis(ang:Forward(), rot.z)
cam.Start3D2D(self:GetPos() + self:GetUp() * -39 + self:GetForward() * 1.3 + self:GetRight()*4, ang ,0.2)[/lua]
Doesn't something like this work?
[code]
self:SetRenderOrigin( somewhere )
self:DrawModel( )
self:SetRenderOrigin( somewhere_else )
self:DrawModel( )
[/code]
[QUOTE=Kogitsune;19188378]Doesn't something like this work?
[code]
self:SetRenderOrigin( somewhere )
self:DrawModel( )
self:SetRenderOrigin( somewhere_else )
self:DrawModel( )
[/code][/QUOTE]
That works, but it requires a call to SetupBones, or it will use the original bone cache, thus leaving the model in its original location.
[lua]local pos = self:GetPos();
// draw original model
self:DrawModel();
// draw a copy of the model above it
// SetupBones is what allows it to draw in the new location
// otherwise it'd use the original bone cache
self:SetRenderOrigin( pos + Vector( 0, 0, 32 ) );
self:SetupBones();
self:DrawModel();
// reset the render origin, we don't want it intact for the next frame
self:SetRenderOrigin();
[/lua]
Thank you very much.
[QUOTE=Jinto;19188393]That works, but it requires a call to SetupBones, or it will use the original bone cache, thus leaving the model in its original location.
[lua]local pos = self:GetPos();
// draw original model
self:DrawModel();
// draw a copy of the model above it
// SetupBones is what allows it to draw in the new location
// otherwise it'd use the original bone cache
self:SetRenderOrigin( pos + Vector( 0, 0, 32 ) );
self:SetupBones();
self:DrawModel();
// reset the render origin, we don't want it intact for the next frame
self:SetRenderOrigin();
[/lua][/QUOTE]
Jinto, how did you know the bone cache had to be set up in order for SetRenderOrigin/SetRenderAngles to take effect?
I don't really get why scripters should have to do this. Why isn't :SetupBones() isn't called implicitly by SetRenderOrigin? Is it because SetRenderAngles may be called in conjunction with SetRenderOrigin and implicitly calling SetupBones would cause the bone cache to be rebuilt twice in that case?
If that's the case, I don't see why we couldn't just have SetRenderOrigin(pos), SetRenderAngles(ang), and SetRenderOriginAngles(pos,ang) (where SetRenderOriginAngles sets both the origin and angles, then builds the bone cache).
Also, when is the bone cache built? I noticed you didn't setup the bones after resetting it's render position.
[lua]function _R.Entity:SetRenderOriginAngles( pos, ang )
if (pos) then self:SetRenderOrigin( pos ) end
if (ang) then self:SetRenderAngles( ang ) end
self:SetupBones()
end[/lua]
Arguments are optional. I do agree that this sort of stuff should be built in though, to save us spending 5% of our time writing cool stuff and 95% of our time writing macros, util functions and shortcuts.
[QUOTE=theJ89;19198382]Also, when is the bone cache built? I noticed you didn't setup the bones after resetting it's render position.[/QUOTE]
I would assume directly before ENT:Draw() is called, because he didn't do the bones at the start either. :eng101:
Sorry, you need to Log In to post a reply to this thread.