Hey,
nice approach. I updated our
Lugre Sample code. The
CaduneTree-Leaves are moving in the Wind now, with a simple shader. I also activated
Caelum, now it looks pretty nice
.
it's simple to script Ogre with the usage of
Lugre (lua). here is the sample code:
Code: Select all
--- main function, when it returns, the program ends
function Main ()
local luaversion = string.sub(_VERSION, 5, 7)
print("Lua version : "..luaversion)
HandleCommandLine()
gMyTicks = Client_GetTicks()
if (not InitOgre("LugreExample",lugre_detect_ogre_plugin_path())) then Exit() end
if (OgreInitResLocs) then OgreInitResLocs() end
Client_RenderOneFrame() -- first frame rendered with ogre, needed for init of viewport size
----- your init code here ----
Bind("v", function (state) Client_TakeScreenshot(gMainWorkingDir.."screenshots/") end )
------------------------------
-- CaduneTree
local p = CreateCaduneTreeParameters()
p:SetNumLeaves(5)
p:SetLeafScale(3)
print( p:GetLeafMaterial() )
p:SetLeafMaterial("Leaves/Orange")
--p:SetLeafMaterial("Leaves/Ivylite")
local s = CreateCaduneTreeStem(p)
s:Grow()
local gfx_stem = s:CreateGeometry()
local gfx_leav = s:CreateLeaves()
gfx_stem:SetPosition(0,-6,23)
gfx_leav:SetPosition(0,-6,23)
------------------------------
-- Caelum
gCaelumSystem = CreateCaelumCaelumSystem(
CAELUM_COMPONENT_SUN +
CAELUM_COMPONENT_MOON +
CAELUM_COMPONENT_SKY_DOME +
CAELUM_COMPONENT_IMAGE_STARFIELD +
CAELUM_COMPONENT_CLOUDS +
CAELUM_COMPONENT_PRECIPITATION +
0 --CAELUM_COMPONENT_GROUND_FOG
)
gCaelumSystem:SetManageSceneFog(true)
gCaelumSystem:SetSceneFogDensityMultiplier(0.0015)
gCaelumSystem:SetManageAmbientLight(true)
-- Sunrise with visible moon.
local cl = gCaelumSystem:GetUniversalClock()
cl:SetGregorianDateTime(2007, 4, 9, 9, 33, 10)
cl:SetTimeScale(2500)
-- mainloop
while (Client_IsAlive()) do MainStep() end
----- your deinit code here ----
--Cleanup
if (gfx) then gfx:Destroy() end
if (s) then s:Destroy() end
if (p) then p:Destroy() end
------------------------------
end
-- called every frame, after all timer-steppers, see Step() in lib.time.lua
function MainStep ()
if (gMainWindowSizeDirty) then UpdateMainWindowSize() end
LugreStep()
NetReadAndWrite()
InputStep() -- generate mouse_left_drag_* and mouse_left_click_single events
GUIStep() -- generate mouse_enter, mouse_leave events (might adjust cursor -> before CursorStep)
ToolTipStep() -- needs mouse_enter, should be after GUIStep
CursorStep() -- update cursor gfx pos, should be directly before frame is drawn
Client_RenderOneFrame()
-- kill the programm with the escape key
if gKeyPressed[GetNamedKey("escape")] then Terminate() end
--SoundStep()
Client_USleep(1) -- just 1 millisecond, but gives other processes a chance to do something
end
Anyone can find the
Lugre Sample and the scriptcode
here.
SiENcE