Example #1
0
        private GameElement _appendGameElement(GameElement element, Node node)
        {
            var _tempGameMesh = new GameElement(node.Name);

            var meshTrasform = new MeshTransformation(node.Transform);

            _tempGameMesh.LocalTransform.Translation = meshTrasform.Position;
            _tempGameMesh.LocalTransform.Rotation    = meshTrasform.Rotation;
            _tempGameMesh.LocalTransform.Scale       = meshTrasform.Scale;

            if (node.HasMeshes)
            {
                if (node.MeshCount == 1)
                {
                    _tempGameMesh.AttachComponent(_materials[node.MeshIndices[0]]);
                    _tempGameMesh.AttachComponent(new MeshRenderer(_meshes[node.MeshIndices[0]]));
                }
                else
                {
                    for (int i = 0; i < node.MeshCount; i++)
                    {
                        var _subMesh = new GameElement(node.Name);
                        _subMesh.AttachComponent(_materials[node.MeshIndices[i]]);
                        _subMesh.AttachComponent(new MeshRenderer(_meshes[node.MeshIndices[i]]));
                        _tempGameMesh.AddChild(_subMesh);
                    }
                }
            }

            if (node.HasChildren)
            {
                for (int i = 0; i < node.ChildCount; i++)
                {
                    _appendGameElement(_tempGameMesh, node.Children[i]);
                }
            }

            if (element != null)
            {
                element.AddChild(_tempGameMesh);
            }

            return(_tempGameMesh);
        }
Example #2
0
        private void _initMoverAxis()
        {
            _axisXMoverMaterial = new Material()
            {
                HasColorAmbient = true,
                ColorAmbient    = Color4.Red,
                HasColorDiffuse = true,
                ColorDiffuse    = Color4.Red,
                ShaderProgram   = new ObjectAxisShader()
            };

            _axisYMoverMaterial = new Material()
            {
                HasColorAmbient = true,
                ColorAmbient    = Color4.Green,
                HasColorDiffuse = true,
                ColorDiffuse    = Color4.Green,
                ShaderProgram   = new ObjectAxisShader()
            };

            _axisZMoverMaterial = new Material()
            {
                HasColorAmbient = true,
                ColorAmbient    = Color4.Blue,
                HasColorDiffuse = true,
                ColorDiffuse    = Color4.Blue,
                ShaderProgram   = new ObjectAxisShader()
            };

            var arrow = MeshImporter.ImportMesh("Assets/alienEngineSceneEditorObjectMover.obj");

            _axisXMoverMeshRenderer = new MeshRenderer()
            {
                Visible    = false,
                MeshFilter = new MeshFilter(arrow, arrow.RootNode.Meshes[0])
            };

            _axisYMoverMeshRenderer = new MeshRenderer()
            {
                Visible    = false,
                MeshFilter = new MeshFilter(arrow, arrow.RootNode.Meshes[0])
            };

            _axisZMoverMeshRenderer = new MeshRenderer()
            {
                Visible    = false,
                MeshFilter = new MeshFilter(arrow, arrow.RootNode.Meshes[0])
            };

            _sceneEditorObjectAxisMoverX = new GameElement("axisMoverX__sceneEditorElement");
            _sceneEditorObjectAxisMoverY = new GameElement("axisMoverY__sceneEditorElement");
            _sceneEditorObjectAxisMoverZ = new GameElement("axisMoverZ__sceneEditorElement");

            PickableObject xPicker = new PickableObject();

            xPicker.Hover     += _xPickerOnHover;
            xPicker.LostHover += _xPickerOnLostHover;
            xPicker.Picking   += _xPickerOnPicking;
            xPicker.Unpick    += _xPickerOnUnpick;

            PickableObject yPicker = new PickableObject();

            yPicker.Hover     += _yPickerOnHover;
            yPicker.LostHover += _yPickerOnLostHover;
            yPicker.Picking   += _yPickerOnPicking;
            yPicker.Unpick    += _yPickerOnUnpick;

            PickableObject zPicker = new PickableObject();

            zPicker.Hover     += _zPickerOnHover;
            zPicker.LostHover += _zPickerOnLostHover;
            zPicker.Picking   += _zPickerOnPicking;
            zPicker.Unpick    += _zPickerOnUnpick;

            _sceneEditorObjectAxisMoverX.AttachComponent(xPicker);
            _sceneEditorObjectAxisMoverX.AttachComponent(_axisXMoverMaterial);
            _sceneEditorObjectAxisMoverX.AttachComponent(_axisXMoverMeshRenderer);

            _sceneEditorObjectAxisMoverY.AttachComponent(yPicker);
            _sceneEditorObjectAxisMoverY.AttachComponent(_axisYMoverMaterial);
            _sceneEditorObjectAxisMoverY.AttachComponent(_axisYMoverMeshRenderer);

            _sceneEditorObjectAxisMoverZ.AttachComponent(zPicker);
            _sceneEditorObjectAxisMoverZ.AttachComponent(_axisZMoverMaterial);
            _sceneEditorObjectAxisMoverZ.AttachComponent(_axisZMoverMeshRenderer);

            _sceneEditorObjectAxisMoverX.LocalTransform.SetRotationZ(-90.0f);
            _sceneEditorObjectAxisMoverZ.LocalTransform.SetRotationX(+90.0f);

            _sceneEditorObjectAxisMover = new GameElement("axisMover__sceneEditorElement");
            _sceneEditorObjectAxisMover.AddChild(_sceneEditorObjectAxisMoverX);
            _sceneEditorObjectAxisMover.AddChild(_sceneEditorObjectAxisMoverY);
            _sceneEditorObjectAxisMover.AddChild(_sceneEditorObjectAxisMoverZ);

            ParentScene.AddGameElement(_sceneEditorObjectAxisMover);
        }