Is it possible to change the angle of a sphere rendered with render.DrawSphere?
Cheers.
I can't think of any way to do it, you will most likely need to use basetexturetransform in the material
Really, there is no way? I figure i can render a client-side model sphere and use that, but i'm pretty sure that would a lot less efficient with it being a fully actualized entity and all.
I looked into basetexturetransform, but it seems i would need to call IMaterial/Recompute every frame with the updated transform coordinates and that would be super slow, so slow in fact i don't think it's a viable solution.
I dont think Recompute is needed, the material tends to update itself upon modifying the parameters, Recompute is rarely used to force it on the material in case it does't want to change. Also could you explain what are you trying to do, there might be a better way to achieve what you are trying to do.
Haven't tried it myself, but try using cam.PushModelMatrix with a rotation matrix before you draw the sphere.
All i am trying to do is spin a textured sphere within the cam.Start3D2D function to draw a planet. I realize this can be achieved with a cl model but figured there would be a more efficient way to do this.
Cheers, i'll play around with that.
You could draw a texture instead, its less dynamic though.
If a planet is what you want to do, using a ClientsideModel is probably a better solution
Not sure what you mean by that, if you mean using render.DrawSprite that doesn't solve anything as i need a rotating planet, not a static picture.
I do still think you should use a clientside model, as Gmod4phun suggests, because unless your sphere won't be drawn for very long, this isn't a very elegant solution. Currently, it's recalculating (from the longitude/latitude steps) and redrawing what looks to be a very high-quality sphere every frame. You may want to find a sphere model with proper UV mapping instead, as using a model will (should) be less taxing.
I don't see why spawning a client side model is going to be more efficient considering the game has to load and keep in memory a meta table with 400 odd functions - including the draw function that is rendering the 3D object. I'm not savvy to the internal workings of the rendering system so can you further enlighten me as to why this is so?
There most likely won't be any noticeable impact on using one from another, but you should consider using a model instead as it gives you more control over it since it is an actual entity on which you can do stuff, there is not much you can do with a drawn sphere, but maybe it's enough for you. However, using a model is a more elegant way, unlike changing the model matrix which is a hacky way to do stuff.
Cheers for explaining. I realize you can do more with a fully actualized entity, but for my purposes a simple sphere seems sufficient:
https://files.facepunch.com/forum/upload/654/26bb2750-3d94-4f10-88da-7e95f227ea70/2018-08-24_22-26-43.mp4
Rendering quite nicely so far.
That is looking very nice. Also, with a model you could make it so that half of the planet is lit up and the other half is in shadow
Can also do that with render functions. No need for model
Yeah, i figured so. Do you know of any examples around? I'm assuming it uses render.SetLightingOrigin or render.SetModelLighting ?
Try something like this in a Draw Hook
render.SuppressEngineLighting( true )
render.SetLightingOrigin( self.Entity:GetPos() )
render.ResetModelLighting( self.colAmbientLight.r/255, self.colAmbientLight.g/255, self.colAmbientLight.b/255 )
render.SetColorModulation( self.colColor.r/255, self.colColor.g/255, self.colColor.b/255 )
render.SetBlend( self.colColor.a/255 )
for i=0, 6 do
local col = self.DirectionalLight[ i ]
if ( col ) then
render.SetModelLighting( i, col.r/255, col.g/255, col.b/255 )
end
end
-- Render models here
render.SuppressEngineLighting( false )
This should hopefully give you an idea. Think this is derived from the DModelPreview.
..that looks absolutely stunning, good job!
Cheers. I'll give it a shot some time.
Sorry, you need to Log In to post a reply to this thread.