Is it possible to render a model from .mdl, for example, an airboat engine, without creating any entities? I need to draw a lot of them and don't want to take up precious entity slots and risk crashing the game.
You can create a single entity and render it several times at different locations with a different model.
Something like this:
[lua]function ENT:Draw()
self:SetModel("models/props_junk/watermelon01.mdl")
self:SetRenderOrigin(self:GetPos() + 10 * self:GetUp())
self:SetRenderAngles(self:GetAngles())
self:DrawModel()
self:SetModel("models/props_junk/popcan01a.mdl")
self:SetRenderOrigin(self:GetPos() + 10 * self:GetRight())
self:SetRenderAngles(self:GetAngles() + Angle(10,0,0))
self:DrawModel()
self:SetModel("models/props_junk/popcan01a.mdl")
self:SetRenderOrigin(self:GetPos() - 10 * self:GetRight())
self:SetRenderAngles(self:GetAngles() - Angle(10,0,0))
self:DrawModel()
end[/lua]
You have to always set the model before drawing, even if it's the same model drawn several times, else it will only render the last one.
Also, don't forget to extend the render bounds if necessary, else everything will disappear if you look away from the entity.
Thanks.
For some reason the above code causes the rendered models to fly upwards 10 units a frame, though the serverside part of the entity stays on the ground as seen by collisions. Apparently, self:SetRenderOrigin() also causes the pos of the clientside "self" change. As in, GetPos reflects the pos of the rendered part, and GetAngles gives the actual entity angles =/
Any idea how to make the models parented to the entity? (I can make them stop in one place by storing the pos at the begining of the draw and restoring it at the end but still, that's weird)
Sorry, you need to Log In to post a reply to this thread.