1. 程式人生 > >關於urho3d編輯器場景編輯處理

關於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



大體這樣,需要具體的細節,要自己去嘗試了