Ribbon effects.
Moderator: Moderators
Re: Ribbon effects.
I'm almost done, if I can just get the table I've built in the sync side to show up on the unsync side. The actual drawing part's not too hard, getting the data that you need, insofar as it's available without having to do a lot of really heavy math... is not the hard part... it's the data-transport that's been a royal pain in the ass. You would think that it'd be fairly easy, but that's the worst part.
If LUA in Spring could just draw in sync, or if there were some SIMPLE examples of how to do sync-->unsync communication available, then I'd have had this done and available to mess with two days ago...
If LUA in Spring could just draw in sync, or if there were some SIMPLE examples of how to do sync-->unsync communication available, then I'd have had this done and available to mess with two days ago...
Re: Ribbon effects.
Projectiles are a problem, it's something that's really generally needed, a way for LUA to see the projectiles. I think this is the biggest weakness of LUA currently.
Hint on how to do it is cross-product of vector between camera and points, and vector between the two points of the effect, for a sort of semi-billboard.
Hint on how to do it is cross-product of vector between camera and points, and vector between the two points of the effect, for a sort of semi-billboard.
Last edited by Zpock on 22 Feb 2008, 08:36, edited 2 times in total.
Re: Ribbon effects.
Um, can I have a hint on how to get SYNCED to actually do anything useful? That's where I'm stuck. I have data coming in from COB... but I cannot seem to get unsync to do anything with it...
That last Spring.Echo in DrawWorld() results in a table value for the first query, then nil for the second one... so what am I doing wrong? The only thing that's left here is to get that done, and I'll have some ribbon effects...
Code: Select all
function gadget:GetInfo()
return {
name = "Trails.lua",
desc = "Draws trails behind fighters.",
author = "Argh",
date = "February 21st, 2007",
license = "Public Domain",
layer = 1,
enabled = true,
}
end
if (gadgetHandler:IsSyncedCode()) then
local TrailQueue = {}
--////////////////////////////////////////////////////////////////BEGIN SYNC
--////////////////////////////////////////////////////////////////////////////
function GetValues(u,ud,team)
local x,y,z = Spring.GetUnitPosition(u)
return x,y,z
end
gadgetHandler:RegisterGlobal("GetValues", GetValues)
--////////////////////////////////////////////////////////////////////////////
--////////////////////////////////////////////////////////////////////////////
function SendOverValues(u,ud,team,X1,Y1,Z1,X2,Y2,Z2)
table.insert(TrailQueue,{x1=X1,y1=Y1,z1=Z1,x2=X2,y2=Y2,z2=Z2})
end
gadgetHandler:RegisterGlobal("SendOverValues", SendOverValues)
--////////////////////////////////////////////////////////////////////////////
--////////////////////////////////////////////////////////////////END SYNC
else
--////////////////////////////////////////////////////////////////BEGIN UNSYNC
--////////////////////////////////////////////////////////////////////////////
function gadget:DrawWorld()
Spring.Echo (SYNCED,SYNCED.TrailQueue)
--[[if (TrailQueue[0]) ~= nil then
for _,u in ipairs(TrailQueue) do
Spring.Echo (u.x1,u.y1,u.z1) end
gl.Color(0,0.3,1,0.5)
gl.LineWidth(1.0)
for _,t in ipairs(TrailQueue) do
gl.BeginEnd(GL.LINE_STRIP,function()
gl.Vertex(t.x1,t.y1,t.z1)
gl.Vertex(t.x2,t.y2,t.z2)
end)
end
end]]
end
--////////////////////////////////////////////////////////////////////////////
--////////////////////////////////////////////////////////////////END UNSYNC
endRe: Ribbon effects.
You can make a table that is in synced to become global so it's acessible in the unsynced part with this:
I put the above in
Then to acess the table in the unsynced part:
I see that you try to do something like this altough I can't really dechiper your code it looks really weird. Try to just make your trailqueue table global and then calculate the values in that table in the synced part, and draw in the unsynced, you have too many functions and crap I think.
Code: Select all
gadgetHandler:RegisterGlobal('tablename', tablename)Code: Select all
function gadget:Initialize()Code: Select all
SYNCED.tablenameRe: Ribbon effects.
<testing>
DRAT. I know I'm close. I can taste it. But, no. This still doesn't work.
DRAT. I know I'm close. I can taste it. But, no. This still doesn't work.
Code: Select all
function gadget:GetInfo()
return {
name = "Trails.lua",
desc = "Draws trails behind fighters.",
author = "Argh",
date = "February 21st, 2007",
license = "Public Domain",
layer = 1,
enabled = true,
}
end
if (gadgetHandler:IsSyncedCode()) then
local TrailQueue = {}
--////////////////////////////////////////////////////////////////BEGIN SYNC
--////////////////////////////////////////////////////////////////////////////
function GetValues(u,ud,team)
local x,y,z = Spring.GetUnitPosition(u)
return x,y,z
end
gadgetHandler:RegisterGlobal("GetValues", GetValues)
--////////////////////////////////////////////////////////////////////////////
--////////////////////////////////////////////////////////////////////////////
function SendOverValues(u,ud,team,X1,Y1,Z1,X2,Y2,Z2)
table.insert(TrailQueue,{x1=X1,y1=Y1,z1=Z1,x2=X2,y2=Y2,z2=Z2})
end
gadgetHandler:RegisterGlobal("SendOverValues", SendOverValues)
--////////////////////////////////////////////////////////////////////////////
function gadget:Initialize()
gadgetHandler:RegisterGlobal("TrailQueue", TrailQueue)
end
--////////////////////////////////////////////////////////////////END SYNC
else
--////////////////////////////////////////////////////////////////BEGIN UNSYNC
--////////////////////////////////////////////////////////////////////////////
function gadget:DrawWorld()
gl.Color(0,0.3,1,0.5)
gl.LineWidth(1.0)
for _,t in ipairs(SYNCED.TrailQueue) do
gl.BeginEnd(GL.LINE_STRIP,function()
gl.Vertex(t.x1,t.y1,t.z1)
gl.Vertex(t.x2,t.y2,t.z2)
end)
end
end
--////////////////////////////////////////////////////////////////////////////
--////////////////////////////////////////////////////////////////END UNSYNC
endRe: Ribbon effects.
OMFG!!!! I DID IT! FINALLY!!!
Screen, here in a second. Please, don't laugh, it looks like crap, and I don't know how to get rid of the old lines yet...
Screen, here in a second. Please, don't laugh, it looks like crap, and I don't know how to get rid of the old lines yet...
Re: Ribbon effects.

Er... so how am I supposed to remove the lines, anyhow? Maybe tie them to a unitID, instead of just using table.insert?
Screw it, I need to get to bed, I have a busy day tomorrow. Maybe I'll be able to figure it out when I wake up.
At any rate, here's the code to do this, including the COB stuff I'm using. Feel free to improve it, it has nowhere to go but up, but I'd strongly prefer that the COB-->LUA back-and-forth stayed in, there are other things that can be done with that... hereby released into the Public Domain...
COB:
Code: Select all
lua_GetValues(arg){return 0;}
lua_SendOverValues(arg){return 0;}
positionUpdate()
{
while(1)
{
call-script lua_GetValues();
X1 = GET LUA1;
Y1 = GET LUA2;
Z1 = GET LUA3;
call-script lua_SendOverValues(X1,Y1,Z1,X2,Y2,Z2);
sleep 1000;
X2 = X1;
Y2 = Y1;
Z2 = Z1;
}
}Code: Select all
function gadget:GetInfo()
return {
name = "Trails.lua",
desc = "Draws trails behind fighters.",
author = "Argh",
date = "February 21st, 2007",
license = "Public Domain",
layer = 1,
enabled = true,
}
end
if (gadgetHandler:IsSyncedCode()) then
local TrailQueue = {}
--////////////////////////////////////////////////////////////////BEGIN SYNC
--////////////////////////////////////////////////////////////////////////////
function GetValues(u,ud,team)
local x,y,z = Spring.GetUnitPosition(u)
return x,y,z
end
gadgetHandler:RegisterGlobal("GetValues", GetValues)
--////////////////////////////////////////////////////////////////////////////
--////////////////////////////////////////////////////////////////////////////
function SendOverValues(u,ud,team,X1,Y1,Z1,X2,Y2,Z2)
table.insert(TrailQueue,{x1=X1,y1=Y1,z1=Z1,x2=X2,y2=Y2,z2=Z2})
end
gadgetHandler:RegisterGlobal("SendOverValues", SendOverValues)
--////////////////////////////////////////////////////////////////////////////
function gadget:Initialize()
gadgetHandler:RegisterGlobal("TrailQueue", TrailQueue)
end
--////////////////////////////////////////////////////////////////END SYNC
else
--////////////////////////////////////////////////////////////////BEGIN UNSYNC
--////////////////////////////////////////////////////////////////////////////
function gadget:DrawWorld()
gl.Color(0,0.3,1,0.5)
gl.LineWidth(1.0)
for _,t in spairs(SYNCED.TrailQueue) do
gl.BeginEnd(GL.LINE_STRIP,function()
gl.Vertex(t.x1,t.y1,t.z1)
gl.Vertex(t.x2,t.y2,t.z2)
end)
end
end
--////////////////////////////////////////////////////////////////////////////
--////////////////////////////////////////////////////////////////END UNSYNC
endRe: Ribbon effects.
//////////////////////cantreadshit///////////////////////
Re: Ribbon effects.
replace the '/' with '-'.
try it with, lots of fighters, about 200-500.
to remove the lines, just make it remove old points.
you really should consider using a display list.
and please make a better screenshot, we can hardly see how cool it looks in game.
try it with, lots of fighters, about 200-500.
to remove the lines, just make it remove old points.
you really should consider using a display list.
and please make a better screenshot, we can hardly see how cool it looks in game.
Re: Ribbon effects.
Can't you get a units position through Lua? Also, lines. Some textured polygon strips would be nicer.
Re: Ribbon effects.
not really:I DID IT!
and they have their own UnitDef tags, like:
trailwidth,
trailframes,
trailfadealpha,
trail<color,r,g,b,a>,
trailblendmode,
what still needs to be done is make it use quads instead of lines.
Re: Ribbon effects.
this was originally made by quantum, but it was very very limited.
all it did was drawing a fixed size trail with the team color.
its features were:
you can't choose which units use it.
you can't choose the size, color, width.
it wont be draw on the minimap.
since i don't like limits and magic numbers i made all this:
you can choose which units use it,
you can choose the RGBA color,
you can choose the blend mode,
you can choose the max life time,
you can choose the trail width,
you can choose if you want to draw it on the minimap,
you can choose if its alpha will fade over size,
you can choose to draw its shadows or not,
you can choose to draw its reflection and refraction,
soon to come: you can choose which rendering mode(points,lines,quads)
if you want to help then you can,
all it did was drawing a fixed size trail with the team color.
its features were:
you can't choose which units use it.
you can't choose the size, color, width.
it wont be draw on the minimap.
since i don't like limits and magic numbers i made all this:
you can choose which units use it,
you can choose the RGBA color,
you can choose the blend mode,
you can choose the max life time,
you can choose the trail width,
you can choose if you want to draw it on the minimap,
you can choose if its alpha will fade over size,
you can choose to draw its shadows or not,
you can choose to draw its reflection and refraction,
soon to come: you can choose which rendering mode(points,lines,quads)
if you want to help then you can,
Re: Ribbon effects.
Does this come in a non-gpl flavor as well? Thanks bunches for taking this on user!
Re: Ribbon effects.
well, since nobody was going to make this, i decided to make it.
look at the first page, they were not getting anywhere,
argh was doing it wrong, and jk said it can't be made in lua.
when i make a cool effect in lua, i always do everything possible to make it work for everyone.
look at the first page, they were not getting anywhere,
argh was doing it wrong, and jk said it can't be made in lua.
when i make a cool effect in lua, i always do everything possible to make it work for everyone.
Re: Ribbon effects.
Yes, quantum was making a tech demo for someone else to finish.user wrote:its features were:
Re: Ribbon effects.
i really have to thank him for taking time to start this, i couldn't have started this myself, i am not that good.
Re: Ribbon effects.
I appreciate it man, I will give you full props in the gundam credits page once I add your lua! thanks in advance!
- bobthedinosaur
- Blood & Steel Developer
- Posts: 2702
- Joined: 25 Aug 2004, 13:31
Re: Ribbon effects.
prettiness, will this be in the next spring version?
Re: Ribbon effects.
thanks smoth.
this wont be on the next spring version, because this is a lua script.will this be in the next spring version?
