关于urho3d编辑器场景编辑处理

urho3d场景编辑设计的几个点

  1. 场景
  2. 灯光
  3. 设计相机
  4. 场景zone
  5. 其他

有一些需要注意的
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



大体这样,需要具体的细节,要自己去尝试了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值