示例#1
0
文件: NodeBase.cs 项目: wachel/block
    public static NodeBase createNewTextureOutput()
    {
        NodeBase rlt = new TextureOutput();

        rlt.initInput();
        rlt.guid = Guid.NewGuid().ToString();
        return(rlt);
    }
 private void RetroThreadFinished(object sender, EventArgs e)
 {
     _retroEmulator.Dispose();
     _retroEmulator = null;
     if (_textureOutput != null)
     {
         _textureOutput.Dispose();
         _textureOutput = null;
     }
     if (_soundOutput != null)
     {
         _soundOutput.Dispose();
         _soundOutput = null;
     }
     Logger.Debug("LibRetroFrontend: Libretro thread finished");
 }
        protected void InitializeLibRetro()
        {
            _textureOutput = new TextureOutput(SkinContext.Device);
            //_soundOutput = new LibRetroDirectSound(SkinContext.Form.Handle, _settings.AudioDeviceId, _settings.AudioBufferSize);
            _soundOutput   = new LibRetroXAudio(_settings.AudioDeviceId);
            _retroEmulator = new LibRetroEmulator(_corePath)
            {
                SaveDirectory   = _settings.SavesDirectory,
                SystemDirectory = _settings.SystemDirectory,
                LogDelegate     = RetroLogDlgt,
                Controller      = _controllerWrapper,
                AudioOutput     = _soundOutput as IAudioOutput,
                VideoOutput     = _textureOutput
            };

            SetCoreVariables();
            _retroEmulator.Init();
            Logger.Debug("LibRetroFrontend: Libretro initialized");
        }
示例#4
0
        public override UILayout Cook(CookingContext context)
        {
            if (BitmapSheetSize.IsEmpty)
            {
                throw new InvalidOperationException("BitmapSheetSize is empty.");
            }
            if (string.IsNullOrEmpty(TextureOutput))
            {
                throw new InvalidOperationException("TextureOutput is null.");
            }
            if (TextureOutput.Contains("{0}") == false)
            {
                throw new InvalidOperationException("TextureOutput not exists {0}.");
            }
            if (string.IsNullOrEmpty(ImageOutput))
            {
                throw new InvalidOperationException("ImageOutput is null.");
            }
            if (ImageOutput.Contains("{0}") == false)
            {
                throw new InvalidOperationException("ImageOutput not exists {0}.");
            }

            UILayout input = Input.Cook(context);

            List <UIImage> images = new List <UIImage>();
            List <UILabel> labels = new List <UILabel>();

            CollectObjects(input.Root, images, labels);

            OptimizeAllImages(context, images);
            MergeAllImages(context, images);
            ExportAllMasks(context, images);

            return(input);
        }
示例#5
0
    private void updateTerrainTexture()
    {
        Terrain terr = Terrain.activeTerrain;

        if (terr != null)
        {
            List <SplatPrototype>     prototypes = new List <SplatPrototype>();
            NodeManager.OrderValueFun orderFun   = (n) => {
                if (n.node.value.getNodeType() == NodeType.TextureOutput)
                {
                    return(((TextureOutput)n.node.value).paintOrder);
                }
                return(0);
            };
            nodeManager.forEachNodes_Sorted(orderFun, (n) => {
                if (n.node.value.getNodeType() == NodeType.TextureOutput)
                {
                    TextureOutput texNode = (TextureOutput)(n.node.value);
                    if (texNode.Texture != null)
                    {
                        texNode.textureIndex = prototypes.Count;
                        SplatPrototype p     = new SplatPrototype();
                        p.texture            = texNode.Texture;
                        p.normalMap          = texNode.Normal;
                        p.tileSize           = new Vector2(texNode.texSizeX, texNode.texSizeY);
                        prototypes.Add(p);
                    }
                }
            });
            terr.terrainData.splatPrototypes = prototypes.ToArray();
            int w = terr.terrainData.alphamapWidth;
            int h = terr.terrainData.alphamapHeight;
            float[,] totalAlpha = new float[w, h];
            float scaleX = terr.terrainData.heightmapWidth / ((float)w);
            float scaleY = terr.terrainData.heightmapHeight / ((float)w);
            int   layers = terr.terrainData.alphamapLayers;
            float[, ,] alphaDatas = new float[w, h, layers];//terr.terrainData.GetAlphamaps(0, 0, w, h);
            for (int l = layers - 1; l >= 0; l--)
            {
                NodeBase tempNode = null;
                nodeManager.forEachNodes((n) => {
                    if (n.node.value.getNodeType() == NodeType.TextureOutput)
                    {
                        if (((TextureOutput)n.node.value).paintOrder == l)
                        {
                            tempNode = n.node.value;
                        }
                    }
                });
                if (tempNode != null)
                {
                    float[,] values = tempNode.update(nodeManager.seed, nodeManager.baseX, nodeManager.baseY, w, h, scaleX, scaleY);
                    for (int i = 0; i < w; i++)
                    {
                        for (int j = 0; j < h; j++)
                        {
                            if (totalAlpha[i, j] + values[i, j] <= 1.00001f)
                            {
                                alphaDatas[i, j, l] = values[i, j];
                                totalAlpha[i, j]   += values[i, j];
                            }
                            else
                            {
                                alphaDatas[i, j, l] = 1f - totalAlpha[i, j];
                                totalAlpha[i, j]    = 1f;
                            }
                        }
                    }
                }
            }
            terr.terrainData.SetAlphamaps(0, 0, alphaDatas);
        }
    }