Przeglądaj źródła

Fixed smoothing of the cone model.
Added menu in the editor for instantiating the primitive shapes.

Lasse Öörni 13 lat temu
rodzic
commit
3833c24ab3

BIN
Bin/Data/Models/Cone.mdl


+ 12 - 0
Bin/Data/Scripts/Editor/EditorSceneWindow.as

@@ -727,6 +727,18 @@ void HandleBoneHierarchyCreated(StringHash eventType, VariantMap& eventData)
         UpdateSceneWindowNode(node);
 }
 
+void CreateBuiltinObject(const String& name)
+{
+    Node@ newNode = editorScene.CreateChild(name, REPLICATED);
+    // Set the new node a certain distance from the camera
+    newNode.position = GetNewNodePosition();
+
+    StaticModel@ object = newNode.CreateComponent("StaticModel");
+    object.model = cache.GetResource("Model", "Models/" + name + ".mdl");
+
+    UpdateAndFocusNode(newNode);
+}
+
 bool CheckSceneWindowFocus()
 {
     // When we do scene operations based on key shortcuts, make sure either the 3D scene or the node list is focused,

+ 16 - 0
Bin/Data/Scripts/Editor/EditorUI.as

@@ -100,6 +100,18 @@ void CreateMenuBar()
         uiMenuBar.AddChild(editMenu);
     }
 
+    {
+        Menu@ createMenu = CreateMenu("Create");
+        Window@ createPopup = createMenu.popup;
+        createPopup.AddChild(CreateMenuItem("Box", 0, 0));
+        createPopup.AddChild(CreateMenuItem("Cone", 0, 0));
+        createPopup.AddChild(CreateMenuItem("Cylinder", 0, 0));
+        createPopup.AddChild(CreateMenuItem("Plane", 0, 0));
+        createPopup.AddChild(CreateMenuItem("Pyramid", 0, 0));
+        createPopup.AddChild(CreateMenuItem("Sphere", 0, 0));
+        uiMenuBar.AddChild(createMenu);
+    }
+
     {
         Menu@ fileMenu = CreateMenu("View");
         Window@ filePopup = fileMenu.popup;
@@ -357,6 +369,10 @@ void HandleMenuSelected(StringHash eventType, VariantMap& eventData)
 
     if (action == "Toggle update")
         ToggleUpdate();
+        
+    if (action == "Box" || action == "Cone" || action == "Cylinder" || action == "Plane" || 
+        action == "Pyramid" || action == "Sphere")
+        CreateBuiltinObject(action);
 
     if (action == "Exit")
         engine.Exit();

+ 2 - 0
Docs/GettingStarted.dox

@@ -651,6 +651,8 @@ Components of same type can be multi-edited. Where attribute values differ, the
 
 In addition to whole scenes, single scene nodes including all their components and child nodes can be loaded and saved (%File -> Load node, %File -> Save node as.) These can act as "prefabs" for speeding up scene construction. To save a node, it needs first to be selected in the hierarchy window.
 
+Primitive geometries (boxes, spheres, cylinders) can be instantiated from the Create menu. Note that these are just ordinary model files in the Bin/Data/Models directory; their Blender format source files are in the SourceAssets directory.
+
 \section EditorInstructions_Importing Importing
 
 The editor can import models or scenes from all the formats that the Open Asset Import Library supports, see http://assimp.sourceforge.net/main_features_formats.html

BIN
SourceAssets/Cone.blend


BIN
SourceAssets/Cylinder.blend