Zero this merges the physics mesh of the objects. parent makes the childs stay at a certin point to the parent. this actulyy makes them 1 prop.
Now if only there was a way to make a single entity with multiple models...
[QUOTE=Dubby;22774486]Now if only there was a way to make a single entity with multiple models...[/QUOTE]
I thought that was what this does?
The last step i think will be ability to grab polyweld entity without the ball, and polywelding scripted entities. Great work Haza!
Truly phenomenal, I never thought we'd see the day in GMod's current status when a tool such as this was created.
[QUOTE=ralle105;22776441]I thought that was what this does?[/QUOTE]
No. This breaks apart the convex shapes in a prop's physics object, and compiles them into a single physics object. Those other props are still there, and still create entity lag even with collision turned off.
[QUOTE=haza55;22482862][release][highlight]This tool is a weld that merges physics models.[/highlight]
[b]You cannot get welds better than this.[/b]
So yeah, I'm not going to waste writing some fapworthy article about it.
Left Click = Select(Can be many props)
Right Click = DeSelect
Reload = Finish Weld[/release]
[release][highlight]Download[/highlight]
[b]This is only required on the server or for singleplayer.[/b]
[highlight]DO NOT UPLOAD ANYWHERE, THIS SVN IS THE ONLY PLACE![/highlight]
[b]SVN Download: [/b][url]http://gmod-haza.googlecode.com/svn/trunk/gm_queryphys/garrysmod/[/url][/release][/QUOTE]
I decided to work on your code too. Hope that's alright with you. Here:
lua/entities/gmod_poly/init.lua
[CODE]--[[
Developed By Sir Haza
Modified by Dubby [without permission]
Copyright (c) Sir Haza 2010
]]--
hook.Add( "InitPostEntity", "Load_queryphys", function()
require( "queryphys" )
end )
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( "shared.lua" )
/*---------------------------------------------------------
Name: Initialize
---------------------------------------------------------*/
function ENT:Initialize()
self:SetModel( "models/dav0r/hoverball.mdl" )
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self:BuildPhysics()
end
/*---------------------------------------------------------
Name: Build Physics
---------------------------------------------------------*/
function ENT:BuildPhysics()
if( self.Mesh && table.Count(self.Mesh) > 0 ) then
local phys = self:GetPhysicsObject()
if(phys:IsValid()) then
phys:RebuildFromConvexs(self:GetPos(), self:GetAngles(), self.Mass, 0.001, 0.001, 1, 1, self.Mesh)
phys = nil
end
end
end
/*---------------------------------------------------------
Name: BuildWeld
---------------------------------------------------------*/
function ENT:BuildWeld(entTable)
for _, v in pairs(entTable) do
self:MergeEntity(v)
end
end
/*---------------------------------------------------------
Name: MergeEntity
---------------------------------------------------------*/
function ENT:MergeEntity(ent)
local c = ent:GetClass()
if ( c ~= "prop_physics" and c ~= "prop_physics_multiplayer" ) or ValidEntity(ent:GetParent()) then return end
self.Mesh = self.Mesh or {}
self.Children = self.Children or {}
self.Mass = self.Mass or 0
local delta = ent:GetPos() - self:GetPos()
local phys = ent:GetPhysicsObject()
if( phys:IsValid() ) then
constraint.RemoveAll(ent)
local convexCount = phys:GetConvexCount()
if( convexCount and convexCount > 0 ) then
local angle = phys:GetAngle()
for i = 0, convexCount - 1 do
local convex = phys:GetConvexMesh(i)
for _, triangle in pairs(convex) do
for index, vertex in pairs(triangle) do
vertex:Rotate(angle)
triangle[index] = vertex + delta
end
end
table.insert(self.Mesh, convex)
end
phys:EnableCollisions(false)
self.Mass = self.Mass + phys:GetMass()
ent:SetParent(self)
table.insert(self.Children, ent)
end
ent.Unconstrainable = true
ent.PhysgunDisabled = true
ent.CanTool = function( ply, trace, mode )
return false
end
end
end
/*---------------------------------------------------------
Name: OnRestore
---------------------------------------------------------*/
function ENT:OnRestore()
end
/*---------------------------------------------------------
Name: OnTakeDamage
---------------------------------------------------------*/
function ENT:OnTakeDamage( dmginfo )
self:TakePhysicsDamage( dmginfo )
end
/*---------------------------------------------------------
Name: Think
---------------------------------------------------------*/
function ENT:Think()
self:NextThink( CurTime() + 0.25 )
return true
end
/*---------------------------------------------------------
Name: Use
---------------------------------------------------------*/
function ENT:Use( activator, caller )
end
/*---------------------------------------------------------
Name: PreEntityCopy
---------------------------------------------------------*/
function ENT:PreEntityCopy()
local info = {}
info.Children = {}
for _, v in pairs(self.Children) do
local child = {}
child.Class = v:GetClass()
child.Model = v:GetModel()
child.Pos = v:GetPos() - self:GetPos()
child.Pos:Rotate(-1 * self:GetAngles()) -- ??
child.Ang = v:GetAngles() - self:GetAngles()
child.Mat = v:GetMaterial()
child.Skin = v:GetSkin()
table.insert(info.Children, child)
end
info.Mass = self.Mass
info.Frozen = !self:GetPhysicsObject():IsMoveable()
duplicator.StoreEntityModifier(self.Entity, "PolyDupe", info)
end
/*---------------------------------------------------------
Name: PostEntityPaste
---------------------------------------------------------*/
function ENT:PostEntityPaste(ply, ent, createdEnts)
self:Initialize()
if(ent.EntityMods and ent.EntityMods.PolyDupe) then
local entList = {}
for _, v in pairs(ent.EntityMods.PolyDupe.Children) do
local prop = ents.Create(v.Class)
prop:SetModel(v.Model)
local pos = Vector(v.Pos.x, v.Pos.y, v.Pos.z)
pos:Rotate(self:GetAngles())
pos = pos + self:GetPos()
prop:SetPos(pos)
prop:SetAngles(v.Ang + self:GetAngles())
prop:Spawn()
prop:SetMaterial(v.Mat)
prop:SetSkin(v.Skin)
prop:Activate()
if(SPropProtection) then
SPropProtection.PlayerMakePropOwner(ply, prop)
end
table.insert(entList, prop)
end
self.Mass = ent.EntityMods.PolyDupe.Mass
self:Spawn()
self:BuildWeld(entList)
if(ent.EntityMods.PolyDupe.Frozen) then
ent:GetPhysicsObject():EnableMotion(false)
end
self:Activate()
end
timer.Simple( 1, self.BuildPhysics, self )
end[/CODE]
*Fixes crashes with adv duplicator, as well as physics not loading properly after pasting
lua/autorun/server/constraint_hack.lua
[CODE]--[[
Developed By Dubby
Purpose: Prevents our props from being welded,
roped, etc. - which was found to cause crashes
when duping or colliding.
]]--
module( "constraint", package.seeall )
/*----------------------------------------------------------------------
CanConstrain( Ent, Bone )
Returns false if we shouldn't be constraining this entity
----------------------------------------------------------------------*/
function CanConstrain( Ent, Bone )
if ( !Ent ) then return false end
if ( !Ent:IsWorld() && !Ent:IsValid() ) then return false end
if ( !Ent:GetPhysicsObjectNum( Bone ) || !Ent:GetPhysicsObjectNum( Bone ):IsValid() ) then return false end
if ( Ent.Unconstrainable ) then ForgetConstraints(Ent) return false end
return true
end[/CODE]
*For stability, since without this, those prop_physics could still be constrained in various other ways - which can cause problems, especially if constrained to their own poly ball.
Working on a physgun hack right now (so targeting the props re-targets the poly ball), and trying to resolve the excess entity lag caused by the prop_physics.
Will tackle your clipplane tool after I'm done here, and if you haven't already. ^_^
Clip plane isn't mine, but ok :P
I've been distracted from this due to working on clientside prediction for gm_queryphys.
If i use the tool, A ball just gets spawned and my contraption falls apart D:
Built a house with this. And it crashed when I tried to weld it.
Umm, I made a 11^3 box out of phx 1x1 plates, to test it out, and they are dominating my cpu.
Nice work, when you can adv. duplicate this stuff ill work on it getting to my favorite server
fuckinghell ur 3 days late for that lol. I love this tool =)
Simply. Amazing.
If you can allow us to toggle the weld like Wired Weld Latch, You will have solved doors forever.
I just had a violent fapgasm...
[QUOTE=sheofaps;22982195]I just had a violent fapgasm...[/QUOTE]
That's a rather creepy image. I thank you for not including pictures.
This is so god damn epic I don't know how to state my feelings.
Garry must be contacted as this is the future of gmod!
Has the crash fix been implemented into the SVN?
If this gets more stable I'll use it but otherwise I don't think it would be good on a server.
Yo what do I put for the directory? Like gmod/gmod or in addons or what.
Triple amazing by the way. We'll see if this is more of a hassle than anything. Garry will see it, give it time
[QUOTE=haza55;22482862][release][highlight]This tool is a weld that merges physics models.[/highlight]
[b]You cannot get welds better than this.[/b]
So yeah, I'm not going to waste writing some fapworthy article about it.
Left Click = Select(Can be many props)
Right Click = DeSelect
Reload = Finish Weld[/release]
[release][highlight]Download[/highlight]
[b]This is only required on the server or for singleplayer.[/b]
[highlight]DO NOT UPLOAD ANYWHERE, THIS SVN IS THE ONLY PLACE![/highlight]
[b]SVN Download: [/b][url]http://gmod-haza.googlecode.com/svn/trunk/gm_queryphys/garrysmod/[/url][/release][/QUOTE]
hellp i have no clue where to put this im a total retard!
[editline]12:05AM[/editline]
[QUOTE=Tobba;22483883]GMod folder, this needs a .dll for it to work[/QUOTE]
i dont know where to put all the files please help!
i do not know what directory to put the files in does it go in garrysmod/addons? or garrysmod/gamemodes/sandbox/entities/stools <---or something like that
Check out your garrysmod/garrysmod folder with the svn link provided in the OP. If you don't know how to use SVN, google it. If you don't know how to google it you don't deserve this addon:colbert:
Bump
This was made to be loved.
The adv dupe issue seems to be limited to angles. If the angle changes after polywelding any dupes are fucked up, so freezing it, polywelding it, duping it and using paste at original angles (seems to prevent small misplacements from pasting at different angles) works fine.It seems that in a messed up dupe the physical model is still correct (makes sense, since its ONE model) and the visuals are rotated out of place...
also about tb duplicator: i remember seeing a video (or was it pictures in the thread?) advertising that the strength loss from duping is less and ents are spawned correctly even if they were out of place while duping. that same "out of place" fix might apply here.
[QUOTE=AzraelUK;22559453]Would it be possible to calculate the effective values from the props? So there would be as little difference as possible between the bunch of props all welded/parented/whatever and this.[/QUOTE]
Yeah, do this. The inertia can be easily calculated using the parallel axis theorem, and the mass is just the sum of all the masses.
Are other physical properties correct too, like drag and buoyancy?
[QUOTE=zoombahh;23201632]also about tb duplicator: i remember seeing a video (or was it pictures in the thread?) advertising that the strength loss from duping is less and ents are spawned correctly even if they were out of place while duping. that same "out of place" fix might apply here.[/QUOTE]
It works fine with my duplicator.
Can someone explain me how to install this? i have the needed .dll and i know this goes into /addons but how to download it? I allready google'd how to use svn but I didn't find anything useful. Please explain how to use that SVN.
Feal free to rate me dumb.
[QUOTE=Niklas;23229531]Can someone explain me how to install this? [highlight]i have the needed .dll and i know this goes into /addons[/highlight] but how to download it? I allready google'd how to use svn but I didn't find anything useful. Please explain how to use that SVN.
Feal free to rate me dumb.[/QUOTE]
garrysmod/lua/includes/modules/* :eng101:
[QUOTE=The-Stone;23229735]garrysmod/lua/includes/modules/* :eng101:[/QUOTE]
I have the gm_queryphys.dll in /modules but how do i use SVN and how do i download poly welder :( . I'm confused.
Sorry, you need to Log In to post a reply to this thread.