关于urho3d编辑器场景编辑处理
urho3d场景编辑设计的几个点
- 场景
- 灯光
- 设计相机
- 场景zone
- 其他
有一些需要注意的
zone这个需要注意的是
这一些参数
因为范围和环境光没设好,场景就是灰色的到是就悲剧了
下来就是编辑一个场景,我这里的一个例子
base_scene.xml这个文件如下
<?xml version="1.0"?>
<scene id="1">
<attribute name="Name" value="" />
<attribute name="Time Scale" value="1" />
<attribute name="Smoothing Constant" value="50" />
<attribute name="Snap Threshold" value="5" />
<attribute name="Elapsed Time" value="0" />
<attribute name="Next Replicated Node ID" value="3" />
<attribute name="Next Replicated Component ID" value="6" />
<attribute name="Next Local Node ID" value="16777280" />
<attribute name="Next Local Component ID" value="16777306" />
<attribute name="Variables" />
<attribute name="Variable Names" value="" />
<component type="Octree" id="1" />
<component type="DebugRenderer" id="2" />
<component type="Zone" id="3">
<attribute name="Bounding Box Min" value="-1000 -1000 -1000" />
<attribute name="Bounding Box Max" value="1000 1000 1000" />
<attribute name="Ambient Color" value="1 1 1 1" />
</component>
<node id="16777217">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="light" />
<attribute name="Tags" />
<attribute name="Position" value="0 -3.94427 7.88854" />
<attribute name="Rotation" value="0.866012 0.470597 -0.148493 0.0806919" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<component type="Light" id="16777228">
<attribute name="Light Type" value="Directional" />
</component>
</node>
<node id="16777219">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="ground" />
<attribute name="Tags" />
<attribute name="Position" value="0 0 0" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="1000 1 1000" />
<attribute name="Variables" />
<component type="StaticModel" id="16777229">
<attribute name="Model" value="Model;Models/Box.mdl" />
<attribute name="Material" value="Material;Materials/Stone.xml" />
</component>
</node>
<node id="16777275">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="" />
<attribute name="Tags" />
<attribute name="Position" value="0 -3.94427 7.88854" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
</node>
<node id="2">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="" />
<attribute name="Tags" />
<attribute name="Position" value="0 -0.12 0" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="2 2 2" />
<attribute name="Variables" />
<component type="Skybox" id="5">
<attribute name="Model" value="Model;test/Models/Cube.mdl" />
<attribute name="Material" value="Material;Materials/Skybox.xml" />
</component>
</node>
<node id="16777278">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="CamNode" />
<attribute name="Tags" />
<attribute name="Position" value="2.01865 9.62687 6.09177" />
<attribute name="Rotation" value="0.98618 0.165674 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<component type="Camera" id="16777304">
<attribute name="Aspect Ratio" value="1.78534" />
</component>
</node>
<node id="16777279">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="" />
<attribute name="Tags" />
<attribute name="Position" value="2.01866 5.98918 18.8706" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<component type="StaticModel" id="16777305">
<attribute name="Model" value="Model;Models/Box.mdl" />
<attribute name="Material" value="Material;Materials/Stone.xml" />
</component>
</node>
</scene>
可以保持并在编辑器中加载进来看看
这个是一个简单的场景
那么如何加载这个文件呢
function Start()
graphics:SetWindowIcon(icon)
graphics.windowTitle = "Urho3D Sample"
local uiStyle = cache:GetResource("XMLFile", "UI/DefaultStyle.xml")
if uiStyle == nil then
return
end
engine:CreateConsole()
console.defaultStyle = uiStyle
console.background.opacity = 0.8
engine:CreateDebugHud()
debugHud.defaultStyle = uiStyle
input.mouseVisible = true
scene_ = Scene()
scene_:LoadXML("Data/Scenes/base_scene.xml");
local CamNode = scene_:GetChild("CamNode");
local camera = CamNode:GetComponent("Camera");
camera.farClip = 300.0
renderer:SetViewport(0, Viewport:new(scene_, camera))
end
function Stop()
end
大体这样,需要具体的细节,要自己去尝试了