gl.Unit / gl.UnitRaw question
Moderator: Moderators
gl.Unit / gl.UnitRaw question
I've been trying to use these functions to draw exact copies of units, however the best I can get is a non-textured version. Is there some simple step I am missing / some way to texture them with right texture? Or is this the best that can be done?
Re: gl.Unit / gl.UnitRaw question
gl.Texture(1,"%unitDefID:0") --texture 1
gl.Texture(2,"%unitDefID:1") --texture 2
Send both to your shader and process. To get exact copies of the Units, you probably need to look up jK's shader framework (which I am working on more when I am not so busy) which has a S3O GLSL shader that behaves exactly like the ARB shader.
gl.Texture(2,"%unitDefID:1") --texture 2
Send both to your shader and process. To get exact copies of the Units, you probably need to look up jK's shader framework (which I am working on more when I am not so busy) which has a S3O GLSL shader that behaves exactly like the ARB shader.
Re: gl.Unit / gl.UnitRaw question
Unfortunately I don't know anything about shaders. Im not after anything fancy like shadows/reflection/lighting/alpha/etc, just a textured model of the unit is all I need, so is there any shortcut/simple way to get just that?Argh wrote:gl.Texture(1,"%unitDefID:0") --texture 1
gl.Texture(2,"%unitDefID:1") --texture 2
Send both to your shader and process. To get exact copies of the Units, you probably need to look up jK's shader framework (which I am working on more when I am not so busy) which has a S3O GLSL shader that behaves exactly like the ARB shader.
Re: gl.Unit / gl.UnitRaw question
Oh, well... if you don't need lighting or anything, then this should get you close.
...just be prepared, it will not look all that cool.
Code: Select all
Spring.UnitRendering.SetUnitLuaDraw(unitID,true)
gl.DepthTest(GL.LEQUAL)
gl.Texture(1,"%unitDefID:0")
gl.Color(1.0,1.0,1.0,1.0)
gl.Unit(unitID,true)
Re: gl.Unit / gl.UnitRaw question
It seems Spring.UnitRendering is nil for me?
But then I am not trying to change the drawing of the unit, I'm trying to draw a copy of it, so I don't know if that function would help anyway. Thanks anyway.
In the meantime I've solved my problem with something different but more than adequate; Drawing the unit with polygonmode fill and some solid color, then polygonmode line with color black. Sure doesn't have any of the details, but the unit is still easily recognizable.
But then I am not trying to change the drawing of the unit, I'm trying to draw a copy of it, so I don't know if that function would help anyway. Thanks anyway.
In the meantime I've solved my problem with something different but more than adequate; Drawing the unit with polygonmode fill and some solid color, then polygonmode line with color black. Sure doesn't have any of the details, but the unit is still easily recognizable.
Re: gl.Unit / gl.UnitRaw question
Code: Select all
-- Draw an armstump, with the color of team team, at the position x,y,z
-- This use an unitDef, not an unit,
-- so on one hand it doesn't copy the exact poses of all the pieces of a live unit,
-- but on the other you don't need any live instance of that unit type.
gl.Translate(x,y,z)
gl.UnitShape(UnitDefNames.armstump.id,team)
gl.Translate(-x,-y,-z)
Code: Select all
-- Draw a copy of a live unit (untested)
local function DrawUnitCopy(unitID,x,y,z)
gl.PushMatrix()
local ux,uy,uz=Spring.GetUnitPosition(unitID)
gl.Translate(x-ux,y-uy,z-uz) -- There's also gl.Scale if you want to draw bigger/smaller
gl.Blending(GL.ONE_MINUS_SRC_COLOR,GL.ONE) -- That was to make it look holographic, remove if you want it solid
gl.Unit(unitID)
gl.Blending(GL.SRC_ALPHA,GL.ONE_MINUS_SRC_ALPHA)
gl.PopMatrix()
end