Jump to content

Josh

Staff
  • Posts

    23,308
  • Joined

  • Last visited

Posts posted by Josh

  1. Try this for the firepit script and it will work:

    require("scripts/class")
    
    local class=CreateClass(...)
    class.sound=LoadSound('abstract::campfire_01_15.wav')
    
    function class:CreateObject(model)
    local object=self.super:CreateObject(model)
    
    object.model.aabb.x0=-5
    object.model.aabb.x1=5
    object.model.aabb.y0=-5
    object.model.aabb.y1=5
    object.model.aabb.z0=-5
    object.model.aabb.z1=5
    
    --Create light
    object.light=CreatePointLight(4,model)
    object.light:SetColorf(1,0.6,0.25,1,1)
    object.light:SetPositionf(0,1.2,0,0)
    object.light:SetShadowOffset(0,0.91,0)
    
    --Create emitters
    if fw~=nil then
    	SetWorld(fw.transparency.world)
    
    	object.heathaze=CreateEmitter(10,4500,Vec3(0,1,0),0,object.model)
    	object.heathaze:SetPositionf(-136,52,-662,0)
    	object.material_heathaze=LoadMaterial('abstract::heathaze.mat',0)
    	object.heathaze:Paint(object.material_heathaze,0)
    	object.heathaze:SetRadius(0.25,0.25)
    	object.heathaze:SetWaver(0)
    	object.heathaze:SetOrder(1,0)
    	object.heathaze:SetVelocity(Vec3(0,0.375,0),Vec3(0,0.05,0))
    	object.heathaze:SetRotationSpeed(0.01)
    	object.heathaze:SetArea(Vec3(0.2,0.0,0.2))
    	object.heathaze:SetPositionf(0,0.25,0,0)
    
    	object.fire=CreateEmitter(25,750,Vec3(0,1,0),0,object.model)
    	object.fire:SetPositionf(0,0.25,0,0)
    	object.fire:Paint(LoadMaterial('abstract::fire.mat'),0)
    	object.fire:SetRadius(0.4,0.1)
    	object.fire:SetColorf(0.2,0.2,0.2,1,1)
    	object.fire:SetWaver(1)
    	object.fire:SetVelocity(Vec3(0,1.5,0),Vec3(0,0.05,0))
    	object.fire:SetRotationSpeed(0.01)
    	object.fire:SetArea(Vec3(0.2,0.1,0.2))
    
    	object.sparks=CreateEmitter(5,800,Vec3(0,1,0),0,object.model)
    	object.sparks:Paint(LoadMaterial('abstract::fire.mat'),0)
    	object.sparks:SetRadius(0.01,0.01)
    	object.sparks:SetColorf(1,0.6,0.25,1,1)
    	object.sparks:SetVelocity(Vec3(0,1.5,0),Vec3(0.05,0.5,0.05))
    	object.sparks:SetRotationSpeed(0.1)
    	object.sparks:SetArea(Vec3(0.4,0.0,0.4))
    	object.sparks:SetWaver(5)
    	object.sparks:SetPositionf(0,0.25,0,0)
    
    	SetWorld(fw.main.world)
    end
    
    --Emit fire sound
    if class.sound~=nil then object.model:EmitSound(class.sound,10,1,1) end
    
    --Declare initial values
    object.fluctuation=1.0
    object.smoothedfluctuation=1.0
    
    function object:SetKey(key,value)
    	if key=="color" then
    	elseif key=="intensity" then
    	else
    		return self.super:SetKey(model,key,value)
    	end
    	return 1
    end
    
    --Force the bounding box to be bigger
    --[[function object:UpdateMatrix()
    	object.model.aabb.x0=object.model.mat.tx-5
    	object.model.aabb.x1=object.model.mat.tx+5
    	object.model.aabb.y0=object.model.mat.ty-5
    	object.model.aabb.y1=object.model.mat.ty+5
    	object.model.aabb.z0=object.model.mat.tz-5
    	object.model.aabb.z1=object.model.mat.tz+5
    	object.model.aabb:Update()
    end]]--
    
    function object:GetKey(key,value)
    	if key=="color" then
    	elseif key=="intensity" then
    	else
    		return self.super:GetKey(model,key,value)
    	end
    	return value
    end
    
    function object:Render()
    	self.fluctuation=self.fluctuation+math.random(-100,100)/1000.0*AppSpeed()
    	self.fluctuation=math.min(1.8,self.fluctuation)
    	self.fluctuation=math.max(0.2,self.fluctuation)
    	self.smoothedfluctuation=Curve(self.fluctuation,self.smoothedfluctuation,5.0/AppSpeed())
    	self.light:SetColorf(1.0*self.smoothedfluctuation,0.6*self.smoothedfluctuation,0.25*self.smoothedfluctuation,1,0)
    end
    
    end

  2. Post the obj file. It appears as if your vertices don't have three components listed:

    			Case "v"
    			If line.length<3 Notify "POO1"
    			AppendFloat position,Float(line[1])
    			AppendFloat position,Float(line[2])
    			AppendFloat position,-Float(line[3])

  3. I made a small fix to the waterplane script and uploaded. The SetWaterVisibility arguments were wrong:

    require("scripts/class")
    
    local class=CreateClass(...)
    
    function class:InitDialog(grid)
    self.super:InitDialog(grid)
    local group=grid:AddGroup("Water")
    group:AddProperty("submersioncolor",PROPERTY_COLOR,"","Submersion Color")
    group:AddProperty("Softness",PROPERTY_FLOAT,"0,50")
    group:AddProperty("Visibility",PROPERTY_VEC2)
    group:AddProperty("Amplitude",PROPERTY_FLOAT,"0,16")
    group:AddProperty("WaveSpeed",PROPERTY_FLOAT,"0,10","Wave speed")
    group:Expand(1)	
    end
    
    function class:CreateObject(model)
    local object=self.super:CreateObject(model)
    object.height=model.mat.ty
    
    object.submersioncolor=Vec4(0.5,0.5,0.5,1.0)
    object.softness=1
    object.visibility=Vec2(0,20)
    object.amplitude=1
    object.wavespeed=1
    
    object.model:SetKey("submersioncolor","128,128,128,255")
    object.model:SetKey("softness","1.0")
    object.model:SetKey("visibility","0,20")
    object.model:SetKey("amplitude","1.0")
    object.model:SetKey("wavespeed","1.0")
    
    function object:Refresh()
    	if fw~=nil then
    		fw.renderer:SetWater(1)
    		fw.renderer:SetWaterHeight(self.height)
    		fw.renderer:SetWaterColor(self.model.color,self.submersioncolor)
    		fw.renderer:SetWaterSoftness(self.softness)
    		fw.renderer:SetWaterVisibility(self.visibility.x,self.visibility.y)
    		fw.renderer:SetWaterAmplitude(self.amplitude)	
    		fw.renderer:SetWaterWaveSpeed(self.wavespeed)		
    	end
    end
    
    function object:UpdateMatrix()
    	self.height=self.model.mat.ty
    	self:Refresh()
    end
    
    function object:UnlockKeys(model)
    	object:Refresh()
    end
    
    function object:SetKey(key,value)
    	if key=="softness" then
    		self.softness=tonumber(value)
    	elseif key=="submersioncolor" then
    		self.submersioncolor=StringToColor(value)
    	elseif key=="visibility" then
    		self.visibility=StringToVec2(value)
    	elseif key=="wavespeed" then
    		self.wavespeed=tonumber(value)
    	elseif key=="amplitude" then
    		self.amplitude=tonumber(value)
    	elseif key=="position" then
    		local t
    		t=StringToVec3(value)
    		self.height=t.y
    		return self.super:SetKey(key,value)
    	else
    		return self.super:SetKey(key,value)
    	end
    	return 1
    end
    
    function object:Free()
    	local model,object
    	self.class:RestoreDefaults()
    	for model,object in pairs(self.class.instances) do
    		if object~=self then
    			object:Refresh()
    			break
    		end
    	end
    	self.super:Free()
    end
    
    object:Refresh()
    end
    
    function class:RestoreDefaults()
    if fw~=nil then
    	fw.renderer:SetWater(0)
    	fw.renderer:SetWaterHeight(0.0)
    	fw.renderer:SetWaterColor(Vec4(1,1,1,1),Vec4(0.5,0.5,0.5,1.0))
    	fw.renderer:SetWaterSoftness(1.0)
    	fw.renderer:SetWaterVisibility(Vec2(0,50))
    	fw.renderer:SetWaterAmplitude(1.0)
    	fw.renderer:SetWaterWaveSpeed(1.0)
    end
    if fw.renderer.waterpatch~=nil then
    	fw.renderer.waterpatch:SetParent(nil,1)
    end	
    end
    
    function class:Free()
    self:RestoreDefaults()
    self.super:Free()
    end

  4. Oh my GOD!! believe me, I did not mean, underground models are not good, or I can model better than underground models!!

    I just spent more time to mach colors and contrast in textures :(

    Blasphemy! :rolleyes:

     

    Just kidding. ;)

     

    The texturing looks really nice. It seems like it would fit in with a variety of scenes and not look out of place.

     

    You can make a drawer shape out of multiple objects. Each object has to be a convex hull, but you can make the phy shape out of multiple convex hulls in one obj file.

  5. Whats going on with the VEC2's in LE?

    Nothing. A lot of the Vec2 arguments in the framework commands were redundant, because you would never have those values as Vec2's in the first place, unlike colors and positions, which often already come in a vector object. The parameters are all documented here:

    http://leadwerks.com/wiki/index.php?title=Framework

     

    If you do not want to mess around with this, just use the existing framewerk module, which will work fine.

  6. The problem with the SBX properties not loading is fixed in the DLL which has been uploaded.

     

    If you want the file name of a model, there is a command for that:

    http://leadwerks.com...odels#ModelName

     

    If you want to add a "classname" property for parsing, just open the model .ini file and add something like this:

    classname="light_directional"

     

    That is how it is done in SDK 2.25. I think it is easier to just rely on the model name, because then there is not an extra property to add. Instead of looking for a classname value called "light_directional" look for a file name called "light_directional" (with the file path and extension removed).

  7. Drawer 5 and 6 seem to still use triangle mesh collision, so I have them disabled for now. The drawers tend to droop a bit with gravity. This might be due to the way they are positioned. I created the slider joint at (0,0,0) since there are no pivots in the desk mesh to place them. I think the drawers should be centered at their rear center, and then a pivot added to the desk mesh I can use to position them. That might make the slider joint more accurate.

     

    Here's the script:

    require("scripts/class")
    
    local class=CreateClass(...)
    
    function class:CreateObject(model)
    local object=self.super:CreateObject(model)
    
    local joint
    local n
    
    object.model:SetMass(20)
    object.model:SetCollisionType(COLLISION_PROP)
    
    object.drawer={}
    for n=1,4 do
    	object.drawer[n]=LoadModel("abstract::0d_drawer_0"..n..".gmf",object.model)
    	object.drawer[n]:SetMass(0.1)
    	object.drawer[n]:SetCollisionType(COLLISION_PROP)
    	joint=CreateJointSlider(object.model,object.drawer[n],Vec3(0,0,0),Vec3(0,0,1))
    	joint:SetLimits(-0.5,0)
    end
    
    function object:Reset()
    	local n
    	for n=1,6 do
    		if self.drawer[n]~=nil then
    			self.drawer[n]:SetMatrix(self.model.mat)
    		end
    	end		
    end
    
    function object:Free()
    	local n
    	for n=1,6 do
    		if self.drawer[n]~=nil then
    			self.drawer[n]:Free()
    			self.drawer[n]=nil
    		end
    	end
    	self.super:Free()
    end
    
    end

  8. 1. Replacing o's with e's is cute, but I don't think the engine API commands should be misspelled.

    2. You can use the existing leadwerks.framewerk module if you want. It's the same code.

    3. BlitzMax can't compile a module named "framework" so it isn't going to be distributed as a module. Complain to BRL if you don't like this.

     

    All in all, this really makes no difference to BMX users, so nothing was gained or lost.

  9. when I place it nothing seems to happen like it should

    What doesn't happen like it should? Your coffee maker starts squirting gravy? The purple cats outside your window fly upside-down? Be specific. :lol:

     

    If you mean that your script has no effect, Lua can't run a file from a .pak file, since that is our convention, and Lua doesn't know what it is. I think the best solution is probably to have the engine search for any script by the right name, if one is not found in the same folder as the model. There are reasons for doing the file directly instead of loading the string and passing that to Lua. Only the lua_dofile() command can run a compiled Lua script. It also make debugging easier, because Lua knows what file it is running, and can pass that information back in any error messages that occur.

×
×
  • Create New...