shadmar Posted April 23, 2016 Share Posted April 23, 2016 I was sure I had done this before, but I'm stuck. This is my entity script attached to the brush: if self.entity:GetClassName()=="Brush" then tolua.cast(self.entity, "Model") System:Print(self.entity:GetClassName()) -- still says brush, so I cant get to surface System:Print(self.entity:CountSurfaces()) -- crashes, since it is still a brush end 2 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
macklebee Posted April 23, 2016 Share Posted April 23, 2016 Agree... i thought this was possible before. The only way I have found that I can get a brush's material is if I perform a pick on the brush or if I just perform SetMaterial() on it (which seems silly to do then perform a GetMaterial()).. Casting the Brush to Model doesn't appear to work... but if the brush doesnt have mass or script, then it will be converted to the model class and the normal GetSurface/Material will work. You can perform a pick on a brush and get the material but that's alot of work for something like this. Edit: yeah the pick only works if you just set the material via code... otherwise it doesn't work. hmmm. The entity script I was testing this with (the camera is global in my main script): function Script:Start() if self.entity:GetMaterial()==nil then System:Print("material not found") end local material = Material:Load("Materials/developer/bluegrid.mat") self.entity:SetMaterial(material) if self.entity:GetMaterial()~=nil then System:Print("material found") end end function Script:UpdateWorld() local window = Window:GetCurrent() if camera==nil then System:Print("no cam") end if window:MouseHit(1) then local pickinfo = PickInfo() local p = window:GetMousePosition() if (camera:Pick(p.x,p.y,pickinfo,0,true)) then System:Print("Class: "..pickinfo.entity:GetClassName()) if pickinfo.entity:GetClassName()=="Brush" then local bmat = pickinfo.entity:GetMaterial() if bmat~=nil then System:Print("Brush mat found") end end if pickinfo.entity:GetClassName()=="Model" then local mmat = pickinfo.surface:GetMaterial() if mmat~=nil then System:Print("Model mat found") end end end end end 2 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
shadmar Posted April 23, 2016 Author Share Posted April 23, 2016 Well, I'm working on the automatic setting of cubemaps for substances, which are all fine on models, but on brushes it gets complicated when you can't get to the material, thanks for the effort and example mack. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
shadmar Posted April 23, 2016 Author Share Posted April 23, 2016 You can do brush:GetFace(0), but still no path to material 1 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
macklebee Posted April 23, 2016 Share Posted April 23, 2016 yeah it looks like we need a brush:CountFaces() and a face:GetMaterial() in addition to the brush:GetFace(i) for this to work properly. Edit: And a face:SetMaterial() to be used with the PickInfo.face 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Josh Posted April 23, 2016 Share Posted April 23, 2016 The brush entity is not documented or "official" because it is too complicated to use. To create brushes you have to do things like update the tex coords, normals, build the faces and edges, and build the visible geometry. I don't want the user to think this is something they need to know. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
shadmar Posted April 23, 2016 Author Share Posted April 23, 2016 I would like to get a brushes' surface and material, like you can on models and entities. It would just be consistent I'd think. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Josh Posted April 23, 2016 Share Posted April 23, 2016 Adding it in. It's brush->GetFace()->GetMaterial() 3 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted April 23, 2016 Share Posted April 23, 2016 Adding it in. It's brush->GetFace()->GetMaterial() Will this addition also include brush->GetFace(index)->SetMaterial(material) and brush->CountFaces()? Counting faces would be nice but SetMaterial() would allow us to apply different materials to a brush's different faces just like in the editor. 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Josh Posted April 23, 2016 Share Posted April 23, 2016 Yes. However, if you set the material of a face there will be no visible effect.until you call Brush::Build(). 2 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
shadmar Posted May 8, 2016 Author Share Posted May 8, 2016 This works now. Thanks! 1 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Marcousik Posted March 17, 2017 Share Posted March 17, 2017 http://www.leadwerks.com/workshopitem?tags=&queryType=1&fileType=0&fileid=699303085 Interesting I worked on this and wanted to ask the same about catching a brush surface because of need to use GetVertexTexCoords() Or is there another way to make this ? It's a bit strange because with Model:Box() I would get no problem. So another way would be to construct with Model:Box() the same Brush as edited (assuming it is a box) and apply GetSurface()... I also wanted to ask about changing texture scale (easy to change from the editor) with a script function on brushes ? thx Quote Link to comment Share on other sites More sharing options...
macklebee Posted March 18, 2017 Share Posted March 18, 2017 Currently you cannot get the surface of a brush (at least via lua) which means you cannot use Get/SetVertexTexCoords(). You can get the face of a brush via a pick and you can set the material but you can't set the vertex texcoords. You could try not applying script or mass to your Editor-created CSG/brushes. Then at runtime when the map is loaded, the CSG/brushes will be automatically converted to the Model class which will allow you to get the surface and set the vertex texcoords. Edit: you could change the texture scale / position through a shader 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.