Jump to content

Josh

Staff
  • Posts

    24,591
  • Joined

  • Last visited

Everything posted by Josh

  1. Josh

    Why Apple Fails

    The 9400M gets 13 FPS with Crysis. The ATI 4670 seems to get decent performance, and that is what they are using in all but the worst IMacs. Too bad the only way to get the 4670 is to pay an extra $300! I could buy a much better GPU for less than half the price increase. The 21.5" iMac with the ATI 4670 is probably the best choice. At $1499, it's more than twice what I would pay for a much better PC.
  2. Josh

    Why Apple Fails

    Their prices are more than 250% the price of a comparable PC. Even their "most expensive" laptop is using a budget GPU! So for less than half the price, you can actually get a laptop with a much better GPU! $999: http://www.newegg.co...=laptop%209800m $2499: http://store.apple.c...mco=MTM3NDcyOTc Just for fun, I checked all the most expensive options. The grand total was $7305.35. Who spends $7000 on a laptop with a budget GPU??? I can't believe how dense their management is. It's as if they don't want to succeed.
  3. Increased to 1024. I didn't even know this setting existed.
  4. Josh

    December 7, 2009

    So you want global variables, but you don't? I suggest storing any per-class variable as member of the class: class.myglobal=3 That should keep your per-class variables out of trouble, and your other scripts can still access them.
  5. You could use model:GetKey() or you could set an internal value when the Lua script calls SetKey(). function SetKey(model,key,value) if key=="pickable" then entity.pickable=tonumber(value) else end end
  6. Uncompressed is required for editing, because the terrain editing is performed on the GPU.
  7. Why would you want to only check for objects that can be picked up? If there is a wall between you and the object, the raycast won't see it. Use collision types for this.
  8. It's 12:30 in the morning, but I have the model scripts working the way I want. Thanks to "Nilium" for his tips, and to everyone who gave their feedback. I am confident in this revision. I have a lot of scripts that need to be slightly altered, but it's just a matter of adjusting the function structure, not really changing any existing code. Here's the light_ambient script: require("scripts/class") require("scripts/linkedlist") local class=CreateClass(...) function class:Spawn(model) local object=self.super:Spawn(model) function object:Update() AmbientLight(self.model.color) end function object:SetKey(key,value) if key=="color" then local returnvalue=self.super:SetKey(key,value) self:Update() return returnvalue elseif key=="intensity" then local returnvalue=self.super:SetKey(key,value) self:Update() return returnvalue else return self.super:SetKey(key,value) end return 1 end function object:Kill(model) local model,object --Iterate through all instances of this class. --If any instances are found, use them to set --the ambient light value. for model,object in pairs(self.class.instances) do if object~=self then object:Update() break end end self.super:Kill() end object.model:SetKey("intensity","0.5") --Call the update function before finishing. --This can only be called after the function is declared. --We don't actually need to call it here since setting the intensity key --will do that for us, but it's still a good idea as a general rule. object:Update() end function class:Cleanup() --Restore default ambient light setting. AmbientLight(Vec3(0.5,0.5,0.5)) self.super:Cleanup() end
  9. Josh

    Single-state Lua

    It's like calling base_whatever().
  10. Josh

    Single-state Lua

    I've got it working now. Here's what it looks like: require("scripts/class") local class=CreateClass(...) function class:InitDialog(grid) self.super:InitDialog(grid) group=grid:AddGroup("Light") group:AddProperty("Resolution",PROPERTY_CHOICE,"256,512,1024,2048") group:AddProperty("linearoffset",PROPERTY_VEC3,"0,1,2","Linear offset" ) group:AddProperty("shadowdistance",PROPERTY_VEC3,"","Shadow distance" ) group:AddProperty("Range",PROPERTY_FLOAT) group:Expand(1) end function class:Spawn(model) local object=self.super:Spawn(model) object.model:SetKey("resolution","2") object.light=CreateDirectionalLight(object.model) function object:SetKey(key,value) if key=="resolution" then if value=="0" then self.light:SetShadowmapSize(256) elseif value=="1" then self.light:SetShadowmapSize(512) elseif value=="2" then self.light:SetShadowmapSize(1024) elseif value=="3" then self.light:SetShadowmapSize(2048) end elseif key=="range" then self.light:SetRange(value) elseif key=="shadowdistance" then local offset=string.Explode(value,",") x=tonumber(offset[1]) y=tonumber(offset[2]) z=tonumber(offset[3]) if x==nil then x=0 end if y==nil then y=0 end if z==nil then z=0 end self.light:SetShadowDistance(x,0) self.light:SetShadowDistance(y,1) self.light:SetShadowDistance(z,2) elseif key=="linearoffset" then local offset=string.Explode(value,",") x=tonumber(offset[1]) y=tonumber(offset[2]) z=tonumber(offset[3]) if x==nil then x=0 end if y==nil then y=0 end if z==nil then z=0 end self.light:SetShadowOffset(x,1.0,0) self.light:SetShadowOffset(y,1.0,1) self.light:SetShadowOffset(z,1.0,2) else return self.super:SetKey(key,value) end end function object:GetKey(key,value) if key=="linearoffset" then return self.light:GetShadowOffset(0,0)..","..self.light:GetShadowOffset(0,1)..","..self.light:GetShadowOffset(0,2) elseif key=="shadowdistance" then return self.light:GetShadowDistance(0)..","..self.light:GetShadowDistance(1)..","..self.light:GetShadowDistance(2) elseif key=="range" then return self.light:GetRange() elseif key=="shadowresolution" then resolution=self.light:GetShadowmapSize() if resolution==256 then return 0 elseif resolution==512 then return 1 elseif resolution==1024 then return 2 elseif resolution==2048 then return 3 else return -1 end else return self.super:GetKey(key,value) end end function object:Kill(model) if self.light~=nil then self.light:Free() self.light=nil end self.super:Kill() end return object end
  11. I think the main point is C# has memory management which can make complex apps a lot easier. However, most third party libraries you will find are written in C++, so I am not sure what the point of using C# is. There are easier languages that are cross-platform compatible like Java and BlitzMax. I think C# is still Windows-only. There might be some workarounds, but since it is MS you know they are probably never going to put real effort into Linux and Mac. There are other people who know a lot more about C# than me, so take that with a grain of salt.
  12. Josh

    Scripted GUI

    File Name: Scripted GUI File Submitter: Josh File Submitted: 06 Dec 2009 File Category: Lua Scripts Here's a GUI system with support for windows, panels, drop down boxes, buttons, sliders, labels, and checkboxes. It could still use some improvement, but it's pretty functional and provides a good base to work with. Click here to download this file
  13. That post is referring to textures that have partial mipmaps. Mipmaps should not be required, but if they are present, the texture should have all of them down to 1x1.
  14. Josh

    Single-state Lua

    I have something else wrong here...
  15. Josh

    Single-state Lua

    require("scripts/class") local modelreference=... local class = CreateClass(modelreference) function class:InitDialog(grid) self.super:InitDialog(grid) group=grid:AddGroup("Light") group:AddProperty("Resolution",PROPERTY_CHOICE,"256,512,1024,2048") group:AddProperty("linearoffset",PROPERTY_VEC3,"0,1,2","Linear offset" ) group:AddProperty("shadowdistance",PROPERTY_VEC3,"","Shadow distance" ) group:AddProperty("Range",PROPERTY_FLOAT) group:Expand(1) end function class:Spawn(model) local object=self.super:Spawn(model) object.model:SetKey("resolution","2") object.light=CreateDirectionalLight(object.model) function object:SetKey(key,value) if key=="resolution" then if value=="0" then self.light:SetShadowmapSize(256) elseif value=="1" then self.light:SetShadowmapSize(512) elseif value=="2" then self.light:SetShadowmapSize(1024) elseif value=="3" then self.light:SetShadowmapSize(2048) end elseif key=="range" then self.light:SetRange(value) elseif key=="shadowdistance" then local offset=string.Explode(value,",") x=tonumber(offset[1]) y=tonumber(offset[2]) z=tonumber(offset[3]) if x==nil then x=0 end if y==nil then y=0 end if z==nil then z=0 end self.light:SetShadowDistance(x,0) self.light:SetShadowDistance(y,1) self.light:SetShadowDistance(z,2) elseif key=="linearoffset" then local offset=string.Explode(value,",") x=tonumber(offset[1]) y=tonumber(offset[2]) z=tonumber(offset[3]) if x==nil then x=0 end if y==nil then y=0 end if z==nil then z=0 end self.light:SetShadowOffset(x,1.0,0) self.light:SetShadowOffset(y,1.0,1) self.light:SetShadowOffset(z,1.0,2) else return self.super:SetKey(key,value) end end function object:GetKey(key,value) if key=="linearoffset" then return self.light:GetShadowOffset(0,0)..","..self.light:GetShadowOffset(0,1)..","..self.light:GetShadowOffset(0,2) elseif key=="shadowdistance" then return self.light:GetShadowDistance(0)..","..self.light:GetShadowDistance(1)..","..self.light:GetShadowDistance(2) elseif key=="range" then return self.light:GetRange() elseif key=="shadowresolution" then resolution=self.light:GetShadowmapSize() if resolution==256 then return 0 elseif resolution==512 then return 1 elseif resolution==1024 then return 2 elseif resolution==2048 then return 3 else return -1 end else return self.super:GetKey(key,value) end end function object:Kill(model) if self.light~=nil then self.light:Free() self.light=nil end self.super:Kill() end return object end return class
  16. Josh

    Single-state Lua

    My loadfile() method returns 1 if luaL_loadfile() returns 0. I'm now getting "attempt to call a string value".
  17. If you change materials on one instance of the mesh, all instances of the mesh will be changed. The entity color is a unique value we can use to store information on a per-instance level. The switch has a special shader that uses the entity color value to display the different appearances of the switch.
  18. Josh

    Single-state Lua

    And the application end is like this? It doesn't look like modelreference is being passed correctly: Local result:Int Local size:Int=modelref.lua.StackSize() lua_pushstring(modelref.lua.L,modelref.prefix+"CreateClass") result=modelref.lua.loadfile(StripExt(modelref.path)+".lua") If result lua_settable(modelref.lua.L,LUA_GLOBALSINDEX) EndIf modelref.lua.SetStackSize(size) If result size=modelref.lua.StackSize() lua_getglobal(modelref.lua.L,modelref.prefix+"CreateClass") If lua_isfunction(modelref.lua.L,-1) modelref.lua.pushobject(modelref) modelref.lua.invoke(1,0) EndIf modelref.lua.SetStackSize(size) EndIf
  19. Josh

    entity name

    You are always returning 1 from SetKey. I experienced this same problem and realized you don't want to actually set the position, rotation, scale keys. If you open base.lua you will see that when those values are set, the functions positions them, then returns 0. Your function should say this: return base_SetKey(model,key,value) Instead of this: return 1
  20. Josh

    Single-state Lua

    There is no preprocessor. How would light_directional_CreateClass() be a class? If you have any ideas tell me. I could eliminate the big class function and just set the value of modelreference directly from the engine before the script is run. That gets rid of one layer of nesting: require("scripts/class") local class=CreateClass(modelreference) function class:InitDialog(grid) self.super:InitDialog(grid) group=grid:AddGroup("Light") group:AddProperty("Resolution",PROPERTY_CHOICE,"256,512,1024,2048") group:AddProperty("linearoffset",PROPERTY_VEC3,"0,1,2","Linear offset" ) group:AddProperty("shadowdistance",PROPERTY_VEC3,"","Shadow distance" ) group:AddProperty("Range",PROPERTY_FLOAT) group:Expand(1) end function class:Spawn(model) local object=self.super:Spawn(model) object.model:SetKey("resolution","2") object.light=CreateDirectionalLight(object.model) function object:SetKey(key,value) if key=="resolution" then if value=="0" then self.light:SetShadowmapSize(256) elseif value=="1" then self.light:SetShadowmapSize(512) elseif value=="2" then self.light:SetShadowmapSize(1024) elseif value=="3" then self.light:SetShadowmapSize(2048) end else return self.super:SetKey(key,value) end end function object:GetKey(key,value) if key=="linearoffset" then return self.light:GetShadowOffset(0,0)..","..self.light:GetShadowOffset(0,1)..","..self.light:GetShadowOffset(0,2) elseif key=="shadowdistance" then return self.light:GetShadowDistance(0)..","..self.light:GetShadowDistance(1)..","..self.light:GetShadowDistance(2) else return self.super:GetKey(key,value) end end function object:Kill(model) if self.light~=nil then self.light:Free() self.light=nil end self.super:Kill() end return object end class=nil
  21. Josh

    entity name

    Post your script.
×
×
  • Create New...