Basically, an advanced version of hologram extension.
The following example code is from GMod wiki:
local mat = Material( "editor/wireframe" ) -- The material ( a wireframe )
local obj = Mesh() -- Create the IMesh object
local verts = { -- A table of 3 vertices that form a triangle
{ pos = Vector( 0, 0, 0 ), u = 0, v = 0 }, -- Vertex 1
{ pos = Vector( 10, 0, 0 ), u = 1, v = 0 }, -- Vertex 2
{ pos = Vector( 10, 10, 0 ), u = 1, v = 1 }, -- Vertex 3
}
obj:BuildFromTriangles( verts ) -- Load the vertices into the IMesh object
hook.Add( "PostDrawOpaqueRenderables", "IMeshTest", function()
render.SetMaterial( mat ) -- Apply the material
obj:Draw() -- Draw the mesh
end )
So, is anyone willing to implement this into official Wire?
I have plans for it in starfall as long as it is manageable without crashing. You can copy it here if I finish it.
Also this already exists http://steamcommunity.com/sharedfiles/filedetails/?id=384561758
@thegrb93 that implementation seems pretty bad, you really don't want to use immediate rendering for this
Yeah I didn't see the comments till now.
Where are the limits? Couldn't I lag everyone's game spamming meshes with 25k tris all over the place?
Loading arbitrary meshes seems dangerous and there needs to be some kind of system in place (e.g. "volume cannot be > ~x units!" "radius cannot be > ~r units!") to prevent abuse.
Combine this with http, oh gosh think of the possibilities...
@oldmud0 That happens even now with holomodel_any. It's up to the server admins to enable it and control it.
Also it would be a good idea to limit the number of triangles per player.
More ways to crash the client? awesome!
The models will ultimately be somewhat distorted, but this will convert any STL saved from 123D Design (as ascii of course) to an e2 chip that will spawn the model.
It creates an e2 titled 'cunt.txt' that will spawn the model with some holoclip magic. (don't ask me why I named it that)
@name "STL to E2L"
@inputs
@outputs
@persist FILE:array L Status E2File:string Q:string F C
@trigger
#[
Fac = Model["f1",table]
Fac["normal",vector] = NORMAL
]#
interval(250)
if(first()){
Q=entity():getName():explode(""):string(1)
function string q(S:string){
return Q+S+Q
}
fileLoad(">e2shared/map.txt")
E2File="@name Generated Model
@persist Model:table P H Max
if(first()){
runOnTick(1)
function holoPoly(N:vector,A1:vector,B1:vector,C1:vector){
P++
A = A1+entity():pos()
B = B1+entity():pos()
C = C1+entity():pos()
holoCreate(P,(A+B+C)/3)
V = ((C-A):cross(B-A)):normalized()
holoAng(P,V:toAngle())
holoScale(P,vec(0.1,50,50))
holoClipEnabled(P,1,1)
local N = V:rotateAroundAxis((A-B),-90)
holoClip(P,1,A,N,1)
holoClipEnabled(P,2,1)
local N = V:rotateAroundAxis((B-C),-90)
holoClip(P,2,B,N,1)
holoClipEnabled(P,3,1)
local N = V:rotateAroundAxis((C-A),-90)
holoClip(P,3,C,N,1)
holoParent(P,entity())
}"
}
if(changed(fileLoaded())&fileLoaded()){
#Process that file mate
File = fileRead()
L=1
FILE = File:explode("
")
C=FILE:count()
}
if(fileLoaded()){
if(FILE[L+6,string]==""){
Status=-1
print("STL Converted to GMOD format")
E2File=E2File+"
}
Max=Model:count()
if(H<=Max){
H++
Fac = Model["+q("f")+"+H,table]
holoPoly(Fac["+q("normal")+",vector],Fac[1,vector],Fac[2,vector],Fac[3,vector])
}"
fileWrite(">e2shared/cunt.txt",E2File)
selfDestruct()
}
#######################################
if(Status==0){
L++
S = FILE[L,string]
F++
E2File=E2File+("
Fac = table()
Fac["+q("normal")+",vector] = vec(")
S = S:explode("facet normal "):string(2)
R = S:explode(" ")
WR=(R[2,string]+","+R[3,string]+","+R[3,string]+")")
WR=WR:replace("+000","")
WR=WR:replace("+00","+")
WR=WR:replace("+0","+")
WR=WR:replace("-00","-")
WR=WR:replace("-0","-")
WR=WR:replace("table","T")
WR=WR:replace("del","R")
WR=WR:replace("e+","K")
WR=WR:replace("e-","G")
WR=WR:replace("e","")
WR=WR:replace("K","e+")
WR=WR:replace("G","e-")
WR=WR:replace("T","table")
WR=WR:replace("R","del")
WR=WR:replace("0.",".")
WR=WR:replace(".","0.")
E2File=E2File+WR
Status=1
}
#######################################
if(Status==1){
L++
Status=2
}
#######################################
if(Status==2){
L++
S = FILE[L,string]
E2File=E2File+("
Fac[1,vector] = vec(")
S = S:explode("vertex "):string(2)
R = S:explode(" ")
WR=(R[1,string]+","+R[2,string]+","+R[3,string]+")")
WR=WR:replace("+000","")
WR=WR:replace("+00","+")
WR=WR:replace("+0","+")
WR=WR:replace("-00","-")
WR=WR:replace("-0","-")
WR=WR:replace("table","T")
WR=WR:replace("del","R")
WR=WR:replace("e+","K")
WR=WR:replace("e-","G")
WR=WR:replace("e","")
WR=WR:replace("K","e+")
WR=WR:replace("G","e-")
WR=WR:replace("T","table")
WR=WR:replace("R","del")
WR=WR:replace("0.",".")
WR=WR:replace(".","0.")
E2File=E2File+WR
Status=3
}
#######################################
if(Status==3){
L++
S = FILE[L,string]
E2File=E2File+("
Fac[2,vector] = vec(")
S = S:explode("vertex "):string(2)
R = S:explode(" ")
WR=(R[1,string]+","+R[2,string]+","+R[3,string]+")")
WR=WR:replace("+000","")
WR=WR:replace("+00","+")
WR=WR:replace("+0","+")
WR=WR:replace("-00","-")
WR=WR:replace("-0","-")
WR=WR:replace("table","T")
WR=WR:replace("del","R")
WR=WR:replace("e+","K")
WR=WR:replace("e-","G")
WR=WR:replace("e","")
WR=WR:replace("K","e+")
WR=WR:replace("G","e-")
WR=WR:replace("T","table")
WR=WR:replace("R","del")
WR=WR:replace("0.",".")
WR=WR:replace(".","0.")
E2File=E2File+WR
Status=4
}
#######################################
if(Status==4){
L++
S = FILE[L,string]
E2File=E2File+("
Fac[3,vector] = vec(")
S = S:explode("vertex "):string(2)
R = S:explode(" ")
WR=(R[1,string]+","+R[2,string]+","+R[3,string]+")
Model["+q("f"+F)+",table] = Fac
")
WR=WR:replace("+000","")
WR=WR:replace("+00","+")
WR=WR:replace("+0","+")
WR=WR:replace("-00","-")
WR=WR:replace("-0","-")
WR=WR:replace("table","T")
WR=WR:replace("del","R")
WR=WR:replace("e+","K")
WR=WR:replace("e-","G")
WR=WR:replace("e","")
WR=WR:replace("K","e+")
WR=WR:replace("G","e-")
WR=WR:replace("T","table")
WR=WR:replace("R","del")
WR=WR:replace("0.",".")
WR=WR:replace(".","0.")
E2File=E2File+WR
L=L+2
Status=0
}
#######################################
}
@Fasteroid Please use Gist, and post a link to it instead of non-formatted wall of code.
Most helpful comment
More ways to crash the client? awesome!