Jump to content

windmill


wayneg
 Share

Recommended Posts

I can turn the mesh using the first findchild, but not the blades, what am I doing wrong?

 

require("scripts/class")

local class=CreateClass(...)

function class:InitDialog(grid)
self.super:InitDialog(grid)
group=grid:AddGroup("Model")
group:AddProperty("Scale",PROPERTY_VEC3,"","Scale")
group:Expand(1)
end


function class:CreateObject(model)
local object=self.super:CreateObject(model)
local mesh1=CreateCube()

object.mesh=model:FindChild("U3D_STATIC_MESH")
object.blades=model:FindChild("blades")

object.scale=Vec3(0.05,0.05,0.05)
object.model:SetKey("scale","0.05,0.05,0.05")


function object:Update()

	if object.blades~=nil then
		object.blades:Turn(Vec3(0,1,0))
		mesh1:Turn(Vec3(0,1,0))
	end
end

function object:SetKey(key,value)
	if key=="scale" then
		self.scale=StringToVec3(value)
		object.model:SetScale(StringToVec3(value))

	else
		return self.super:SetKey(key,value)
	end
	--return 1
end

function object:GetKey(key,value)
	if key=="scale" then
		return self.scale.x..","..self.scale.y..","..self.scale.z
	else
		return self.super:GetKey(key,value)
	end
	return value
end

function object:Refresh()

	object.model:SetScale(StringToVec3(self.model:GetKey("scale")))

end

function object:RestoreDefaults()

end

function object:Free(model)

	self.super:Free()
	mesh1:Free()
end

object:Refresh()

end

Link to comment
Share on other sites

is this the old windmill by wailingmonkey from the early 2.3 days? If so, then the lua script should be for the windmill gmf and the findchild name for the blades is "windmill_blades". If it is some other model, then without seeing the model i can only guess that you do not have the right name for the submesh.

 

and fyi, the '<>' icon in the reply toolbar is for code... just place your code in between...

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

is this the old windmill by wailingmonkey from the early 2.3 days? If so, then the lua script should be for the windmill gmf and the findchild name for the blades is "windmill_blades". If it is some other model, then without seeing the model i can only guess that you do not have the right name for the submesh.

 

and fyi, the '<>' icon in the reply toolbar is for code... just place your code in between...

 

I downloaded the windmill off google into sketchup and then setup a group to include the blades and bearings.

I saved to skp, and then loaded UU3D and changed the bone name to 'blades' and saved to GMF. I confirmed the bone name with leadwerks model viewer.

 

I probably should of posted the windmill model, so I'll do that later today.

 

Thanks for quick reply :)

Link to comment
Share on other sites

I mean like make some Print or Notify so that you can see if it actually finds the objects. Like Notify("Blades not found!").

 

That was the purpose of the cube, but yeah, I can add that check at the top.

I must confess I added a notify to the update section and that was a really bad idea since it notified me every frame!! doh! lo l :)

Link to comment
Share on other sites

Guest Red Ocktober

hey... the ole squeaky windmill... yeah, i remember that...

 

spent a lot of time around that thing... i also played around with spinning the blades (in Blitzmax code)...

 

 

 

 

like Mac said above, findchild will do it...

 

     '	  find the windmill blades... only they will spin, not the entire object '
     Local theBlades:TEntity=FindChild(Self.mesh,"windmill_blades")

 

 

 

--Mike

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...