Esempio n. 1
0
 public Sprite(DynamicTexture texture, IntVec sourceTile, Color color, Direction direction, bool isVisible = true)
 {
     this.texture    = texture;
     this.sourceTile = sourceTile;
     this.blend      = color;
     this.direction  = direction;
     this.isVisible  = isVisible;
 }
Esempio n. 2
0
 public Sprite(DynamicTexture texture, bool isVisible = true)
 {
     this.texture    = texture;
     this.sourceTile = new IntVec(0, 0);
     this.blend      = Color.White;
     this.direction  = Direction.RIGHT;
     this.isVisible  = isVisible;
 }
Esempio n. 3
0
 public Ability()
 {
     abilityLine    = Engine.Engine.GetTexture("UI/Abilities");
     abilitySprites = new Sprite[30];
     for (int i = 0; i < abilitySprites.Length; i++)
     {
         abilitySprites[i] = new Sprite(abilityLine, new IntVec(i, 0));
     }
 }
    public void OnInjectionFinished()
    {
        songMetaChangeEventStream.Subscribe(OnSongMetaChanged);

        overviewAreaNotes.RegisterCallbackOneShot <GeometryChangedEvent>(evt =>
        {
            dynamicTexture = new DynamicTexture(songEditorSceneControl.gameObject, overviewAreaNotes);
            UpdateNoteOverviewImage();
        });
    }
Esempio n. 5
0
		/// <summary>
		/// /
		/// </summary>
		public override void Initialize ()
		{
			averageLum	=	new RenderTarget2D( Game.GraphicsDevice, ColorFormat.Rgba16F, 256,256, true, false );
			paramsCB	=	new ConstantBuffer( Game.GraphicsDevice, typeof(Params) );
			whiteTex	=	new DynamicTexture( Game.RenderSystem, 4,4, typeof(Color), false, false);
			whiteTex.SetData( Enumerable.Range(0,16).Select( i=> Color.White ).ToArray() );

			LoadContent();

			Game.Reloading += (s,e) => LoadContent();
		}
Esempio n. 6
0
        /// <summary>Renders an arc from the previous point to this one.</summary>
        public override void RenderLine(CanvasContext context)
        {
            // Grab the raw drawing data:
            DynamicTexture data = context.ImageData;

            // Time to go polar!
            // We're going to rotate around the pole drawing one pixel at a time.
            // For the best accuracy, we first need to find out how much to rotate through per pixel.

            if (Length == 0f)
            {
                // Nothing to draw anyway.
                return;
            }

            // How much must we rotate through overall?
            float angleToRotateThrough = EndAngle - StartAngle;

            // So arc length is how many pixels long the arc is.
            // Thus to step that many times, our delta angle is..
            float deltaAngle = angleToRotateThrough / Length;

            // The current angle:
            float currentAngle = StartAngle;

            // The number of pixels:
            int pixelCount = (int)Mathf.Ceil(Length);

            if (pixelCount < 0)
            {
                // Going anti-clockwise. Invert deltaAngle and the pixel count:
                deltaAngle = -deltaAngle;
                pixelCount = -pixelCount;
            }

            // Step pixel count times:
            for (int i = 0; i < pixelCount; i++)
            {
                // Map from polar angle to coords:
                float x = Radius * (float)Math.Cos(currentAngle);
                float y = Radius * (float)Math.Sin(currentAngle);

                // Draw the pixel:
                data.DrawPixel((int)(CircleCenterX + x), data.Height - (int)(CircleCenterY + y), context.StrokeColour);

                // Rotate the angle:
                currentAngle += deltaAngle;
            }
        }
        /// <summary>Renders a straight line from the previous point to this one.</summary>
        public override void RenderLine(CanvasContext context)
        {
            // Grab the raw drawing data:
            DynamicTexture data = context.ImageData;

            // Invert y:
            int endY   = data.Height - (int)Y;
            int startY = data.Height - (int)Previous.Y;

            // Grab X:
            int endX   = (int)X;
            int startX = (int)Previous.X;

            data.DrawLine(startX, startY, endX, endY, context.StrokeColour);
        }
Esempio n. 8
0
        protected override void Initialize()
        {
            Common.Initialize(this);
            Window.AllowUserResizing = true;
            bullets = new List <Bullet>();
            graphics.PreferredBackBufferWidth  = 1920;
            graphics.PreferredBackBufferHeight = 1080;
            graphics.ApplyChanges();
            a = new FlareFxAlt(graphicsDevice, 40, 40, "Test2");
            MeteorBullet.flarefx    = new FlareFx(graphicsDevice, 40, 40, "Test");
            MeteorBullet.flarefxAlt = a as FlareFxAlt;
            mousePos    = new Vector2[15];
            text        = new DynamicTextureText(graphicsDevice, new System.Drawing.Font("华文中宋", 50), "Stellaris");
            vertexBatch = new VertexBatch(graphicsDevice);
            swordFx     = new SwordFx(GraphicsDevice, 1);

            u = new UIBase();
            base.Initialize();
        }
Esempio n. 9
0
        private static void CopyGlyphToTexture(FontRenderer.Glyph glyph, DynamicTexture texture, IntVector2 position)
        {
            var srcPixels = glyph.Pixels;

            if (srcPixels == null)
            {
                return;                 // Invisible glyph
            }
            int    si;
            Color4 color         = Color4.Black;
            var    dstPixels     = texture.GetPixels();
            int    bytesPerPixel = glyph.RgbIntensity ? 3 : 1;

            for (int i = 0; i < glyph.Height; i++)
            {
                // Sometimes glyph.VerticalOffset could be negative for symbols with diacritics and this results the symbols
                // get overlapped or run out of the texture bounds. We shift the glyph down and increase the current line
                // height to fix the issue. Also we store the shift amount in FontChar.VerticalOffset property.
                int verticalOffsetCorrection = -Math.Min(0, glyph.VerticalOffset);

                var di = (position.Y + glyph.VerticalOffset + i + verticalOffsetCorrection) * texture.ImageSize.Width + position.X;
                for (int j = 0; j < glyph.Width; j++)
                {
                    si = i * glyph.Pitch + j * bytesPerPixel;
                    if (glyph.RgbIntensity)
                    {
                        color.A = 255;
                        color.R = srcPixels[si];
                        color.G = srcPixels[si + 1];
                        color.B = srcPixels[si + 2];
                    }
                    else
                    {
                        color   = Color4.White;
                        color.A = srcPixels[si];
                    }

                    dstPixels[di++] = color;
                }
            }
            texture.Invalidated = true;
        }
    public void OnInjectionFinished()
    {
        horizontalGrid.RegisterCallbackOneShot <GeometryChangedEvent>(evt =>
        {
            dynamicTexture = new DynamicTexture(songEditorSceneControl.gameObject, horizontalGrid);
            dynamicTexture.backgroundColor = new Color(0, 0, 0, 0);
            UpdateMidiNoteLabels();

            if (settings.SongEditorSettings.GridSizeInDevicePixels > 0)
            {
                UpdateMidiNoteLines();
            }
        });

        noteAreaControl.ViewportEventStream.Subscribe(OnViewportChanged);

        settings.ObserveEveryValueChanged(_ => settings.SongEditorSettings.GridSizeInDevicePixels)
        .Where(_ => dynamicTexture != null)
        .Subscribe(_ => UpdateMidiNoteLines())
        .AddTo(gameObject);
    }
Esempio n. 11
0
 protected override void Initialize()
 {
     Common.Initialize(this);
     Window.AllowUserResizing = true;
     bullets = new List <Bullet>();
     graphics.PreferredBackBufferWidth  = 1920;
     graphics.PreferredBackBufferHeight = 1080;
     graphics.ApplyChanges();
     a = new FlareFxAlt(graphicsDevice, 40, 40, "Test2");
     MeteorBullet.flarefx    = new FlareFx(graphicsDevice, 40, 40, "Test");
     MeteorBullet.flarefxAlt = a as FlareFxAlt;
     mousePos    = new Vector2[15];
     vertexBatch = new VertexBatch(graphicsDevice);
     swordFx     = new SwordFx(GraphicsDevice, 1);
     u           = new UIBase();
     text        = new DynamicTextureTextGDI(graphicsDevice, Environment.CurrentDirectory + Path.DirectorySeparatorChar + "SourceHanSansCN-Regular.ttf", 40, "***ABCD文字绘制测试\nStellaris\n增益免疫汉化组");
     dtt         = new DynamicTextureFont(graphicsDevice, Environment.CurrentDirectory + Path.DirectorySeparatorChar + "SourceHanSansCN-Regular.ttf", 80);
     tex         = Texture2D.FromStream(graphicsDevice, File.OpenRead(Environment.CurrentDirectory + @"\Extra_197.png"));
     tex2        = Texture2D.FromStream(graphicsDevice, File.OpenRead(Environment.CurrentDirectory + @"\Extra_194.png"));
     tt          = new TestTex(graphicsDevice, 70, 70);
     base.Initialize();
 }
Esempio n. 12
0
        private void setup()
        {
            if (isFontInstalled(fontName))
            {
                font = new Font(fontName, fontSize);
            }
            else
            {
                if (File.Exists(fontName))
                {
                    privateFontCollection = new PrivateFontCollection();
                    privateFontCollection.AddFontFile(fontName);
                    font = new Font(privateFontCollection.Families[0], fontSize);
                }
                else
                {
                    font = SystemFonts.DefaultFont;
                    Log.WriteLine(Log.LOG_WARNING, "TextSprite font '" + fontName + "' not found. Using default font.");
                }
            }

            texture = new DynamicTexture((int)Size.X, (int)Size.Y, TextureUnit.Texture0, renderingHint);
            updateText();
        }
Esempio n. 13
0
        protected override void Initialize()
        {
            Ste.Initialize(this, graphics);
            Window.AllowUserResizing = true;
            bullets = new List <Bullet>();
            Ste.ChangeResolution(1920, 1080);
            a = new FlareFxAlt(graphicsDevice, 40, 40, "Test2");
            MeteorBullet.flarefx    = new FlareFx(graphicsDevice, 40, 40, "Test");
            MeteorBullet.flarefxAlt = a as FlareFxAlt;
            mousePos    = new Vector2[15];
            vertexBatch = new VertexBatch(graphicsDevice);
            //var n = new FontStb_Native(Ste.GetAsset("SourceHanSansCN-Regular.ttf"), graphicsDevice);
            //text = new DynamicTextureTextGDI(graphicsDevice, Environment.CurrentDirectory + Path.DirectorySeparatorChar + "SourceHanSansCN-Regular.ttf", 40, "***ABCD文字绘制测试\nStellaris\n增益免疫汉化组");
            dtt = new DynamicSpriteFont(graphicsDevice, Ste.GetAsset("SourceHanSansCN-Regular.ttf"), 80, useNative: false);
            var font = new FontStb_Native(Ste.GetAsset("Product-Sans-Regular.ttf"));

            font.ReverseFont = dtt.font;
            dtt2             = new DynamicSpriteFont(graphicsDevice, font, 80);
            tex3             = Texture2D.FromStream(graphicsDevice, Ste.GetAsset("trail3.png"));
            tex  = Texture2D.FromStream(graphicsDevice, Ste.GetAsset("zzzz.png"));
            tex2 = Texture2D.FromStream(graphicsDevice, Ste.GetAsset("trail3.png"));
            z    = new Effect(graphicsDevice, Ste.GetAsset("Blur.cfx").ToByteArray());
            base.Initialize();
        }
Esempio n. 14
0
 private void CreateNewFontTexture()
 {
     texture      = new DynamicTexture(CalcTextureSize());
     textureIndex = textures.Count;
     textures.Add(texture);
 }
Esempio n. 15
0
		/// <summary>
		/// Ctor
		/// </summary>
		/// <param name="rs"></param>
		/// <param name="capacity">Number of sprites</param>
		public SpriteLayer ( RenderSystem rs, int capacity )
		{
			this.rs		=	rs;

			Order		=	0;

			Visible		=	true;
			Transform	=	Matrix.Identity;
			Color		=	Color.White;
			BlendMode	=	SpriteBlendMode.AlphaBlend;
			FilterMode	=	SpriteFilterMode.LinearClamp;
			StereoMode	=	SpriteStereoMode.All;

			defaultTexture	=	new DynamicTexture( rs, 16,16, typeof(Color), false, false );
			defaultTexture.SetData( Enumerable.Range(0,16*16).Select( i => Color.White ).ToArray() );

			ReallocGpuBuffers( capacity );

			framesBuffer	=	new ConstantBuffer( rs.Device, typeof(SpriteFrame), MaxSpriteFrames );
		}
Esempio n. 16
0
 public Bullet(DynamicTexture dynamicTexture, Vector2 position, Vector2 velocity, int damage, Color color, Character owner, int oldPosLength = 0, float scale = 1, bool flipped = false)
 {
     this.dynamicTexture = dynamicTexture;
     Initialize(position, velocity, damage, color, owner, oldPosLength, scale, flipped);
 }
Esempio n. 17
0
    public void buildCubes()
    {
        //Camera camera = GetComponent<Camera>();
        //Vector3 p0 = camera.ScreenToWorldPoint(new Vector3(0, 0, camera.nearClipPlane));

        //MainController.TwitterAction -= handleAction;

        float scalar = 0.68F;// Core.Instance._settings.Kinect_area_X/100;

        int counter = 0;

        //cubes_array = new GameObject[maxY, maxX];
        cubes_array = new GameObject[maxX];

        zoom_targets = new float[8];

        zoom_targets[0] = -scalar - scalar * 6;

        zoom_targets[1] = -scalar - scalar * 4;

        zoom_targets[2] = -scalar - scalar * 2;

        zoom_targets[3] = -scalar;

        zoom_targets[4] = scalar;

        zoom_targets[5] = scalar + scalar * 2;

        zoom_targets[6] = scalar + scalar * 4;

        zoom_targets[7] = scalar + scalar * 6;

        //zoom_bool = new bool[8];

        TweetSearchTwitterData twitterData;

        int tweet_counter     = 0;
        int tweet_counter_max = MainController.Instance.TweetsList.Count;
        int tweet_index;

        for (int px = 0; px < maxX; ++px)
        {
            GameObject clone = Instantiate(rounded_cube, new Vector3(gameObject.transform.position.x, -4.0F, 10.0f), transform.rotation) as GameObject;

            clone.GetComponent <RoundedCube>().image_quad.SetActive(true);

            //ATTACH TO PARENT
            clone.transform.parent = gameObject.transform;


            //ADD TWITTER DATA TO CUBE
            tweet_index = tweet_counter + (cube_id - 1) * maxX;

            if (tweet_index >= tweet_counter_max)
            {
                tweet_counter = 0;
                tweet_index   = tweet_counter_max - 1;
            }

            twitterData = MainController.Instance.TweetsList[tweet_index];

            tweet_counter++;

            DynamicTexture dtex = clone.GetComponentInChildren <DynamicTexture>();

            Text tweet = clone.GetComponentInChildren <Text>();

            if (twitterData.tweetMedia != "")
            {
                dtex.url = twitterData.tweetMedia;
                dtex.Apply(true);
                clone.GetComponent <RoundedCube>().hasImage = true;
            }
            else
            {
                clone.GetComponent <RoundedCube>().image_quad.SetActive(false);
            }

            string text = twitterData.tweetText;

            clone.GetComponentInChildren <RoundedCube>().setTweetText(text);

            //clone.GetComponent<RoundedCube>().cube_grp.transform.Rotate(Vector3.up * 90);// Random.Range(0, 20));

            cubes_array[px] = clone;

            counter++;

            //clone.transform.DOScale(0, 0);

            //clone.SetActive(false);
        }

        INIT = true;
    }
Esempio n. 18
0
 public Character(DynamicTexture dynamicTexture, int life, int lifeMax, Vector2 position)
 {
     this.dynamicTexture = dynamicTexture;
     Initialize(life, lifeMax, position);
 }
Esempio n. 19
0
		/// <summary>
		/// Intializes graphics engine.
		/// </summary>
		public override void Initialize ()
		{
			whiteTexture	=	new DynamicTexture( this, 4,4, typeof(Color), false, false );
			whiteTexture.SetData( Enumerable.Range(0,16).Select( i => Color.White ).ToArray() );
			
			grayTexture		=	new DynamicTexture( this, 4,4, typeof(Color), false, false );
			grayTexture.SetData( Enumerable.Range(0,16).Select( i => Color.Gray ).ToArray() );

			blackTexture	=	new DynamicTexture( this, 4,4, typeof(Color), false, false );
			blackTexture.SetData( Enumerable.Range(0,16).Select( i => Color.Black ).ToArray() );

			flatNormalMap	=	new DynamicTexture( this, 4,4, typeof(Color), false, false );
			flatNormalMap.SetData( Enumerable.Range(0,16).Select( i => new Color(127,127,255,127) ).ToArray() );

			var baseIllum = new BaseIllum();
			defaultMaterial	=	baseIllum.CreateMaterialInstance(this, Game.Content);

			//	add default render world
			renderWorld	=	new RenderWorld(Game, Width, Height);
			AddLayer( renderWorld );
		}
Esempio n. 20
0
 public AudioWaveFormVisualization(GameObject gameObject, VisualElement visualElement)
 {
     dynTexture = new DynamicTexture(gameObject, visualElement);
 }
Esempio n. 21
0
 public GameObject(DynamicTexture texture)
     : this(texture.Texture)
 {
     SetSource(texture.Source);
 }
Esempio n. 22
0
		/// <summary>
		/// 
		/// </summary>
		private void PlatformInitialize( byte[] bytes, Stream stream, string url )
		{
			if (Topology != null) {
				return;
			}

			MediaFactory.CreateTopology(out _topology);

			SharpDX.MediaFoundation.MediaSource mediaSource;
			{
				SourceResolver resolver = new SourceResolver();
				
				ObjectType otype;
				ComObject source = null;

				if (url!=null) {
					source = resolver.CreateObjectFromURL(url, SourceResolverFlags.MediaSource, null, out otype);
				}

				if (stream!=null) {
					var bs = new ByteStream( stream );
					source = resolver.CreateObjectFromStream(bs, null, SourceResolverFlags.MediaSource, null, out otype);
				}

				if (bytes!=null) {
					var bs = new ByteStream( bytes );
					source = resolver.CreateObjectFromStream(bs, null, SourceResolverFlags.MediaSource|SourceResolverFlags.ContentDoesNotHaveToMatchExtensionOrMimeType, null, out otype);
				}

				if (source==null) {
					throw new ArgumentException("'stream' and 'url' are null!");
				}

				mediaSource = source.QueryInterface<SharpDX.MediaFoundation.MediaSource>();

				
				resolver.Dispose();
				source.Dispose();
			}


			PresentationDescriptor presDesc;
			mediaSource.CreatePresentationDescriptor(out presDesc);
			
			for (var i = 0; i < presDesc.StreamDescriptorCount; i++) {

				RawBool selected = false;
				StreamDescriptor desc;
				presDesc.GetStreamDescriptorByIndex(i, out selected, out desc);
				
				if (selected) {

					TopologyNode sourceNode;
					MediaFactory.CreateTopologyNode(TopologyType.SourceStreamNode, out sourceNode);

					sourceNode.Set(TopologyNodeAttributeKeys.Source, mediaSource);
					sourceNode.Set(TopologyNodeAttributeKeys.PresentationDescriptor, presDesc);
					sourceNode.Set(TopologyNodeAttributeKeys.StreamDescriptor, desc);
					

					TopologyNode outputNode;
					MediaFactory.CreateTopologyNode(TopologyType.OutputNode, out outputNode);

					var majorType = desc.MediaTypeHandler.MajorType;
					
					if (majorType == MediaTypeGuids.Video) {

						Activate activate;
						
						sampleGrabber = new VideoSampleGrabber();

						_mediaType = new MediaType();
						
						_mediaType.Set(MediaTypeAttributeKeys.MajorType, MediaTypeGuids.Video);

						// Specify that we want the data to come in as RGB32.
						_mediaType.Set(MediaTypeAttributeKeys.Subtype, new Guid("00000016-0000-0010-8000-00AA00389B71"));

						MediaFactory.CreateSampleGrabberSinkActivate(_mediaType, SampleGrabber, out activate);
						outputNode.Object = activate;


						long frameSize = desc.MediaTypeHandler.CurrentMediaType.Get<long>(MediaTypeAttributeKeys.FrameSize);

						Width	= (int)(frameSize >> 32);
						Height	= (int) (frameSize & 0x0000FFFF);
					}

					if (majorType == MediaTypeGuids.Audio)
					{
						Activate activate;
						MediaFactory.CreateAudioRendererActivate(out activate);

						outputNode.Object = activate;
					}

					_topology.AddNode(sourceNode);
					_topology.AddNode(outputNode);
					sourceNode.ConnectOutput(0, outputNode, 0);
					

					Duration = new TimeSpan(presDesc.Get<long>(PresentationDescriptionAttributeKeys.Duration));
					

					sourceNode.Dispose();
					outputNode.Dispose();
				}

				desc.Dispose();
			}

			presDesc.Dispose();
			mediaSource.Dispose();


			videoFrame = new DynamicTexture(Game.Instance.RenderSystem, Width, Height, typeof(ColorBGRA), false, false);
		}
Esempio n. 23
0
        /// <summary>
        ///
        /// </summary>
        private void PlatformInitialize(byte[] bytes, Stream stream, string url)
        {
            if (Topology != null)
            {
                return;
            }

            MediaFactory.CreateTopology(out _topology);

            SharpDX.MediaFoundation.MediaSource mediaSource;
            {
                SourceResolver resolver = new SourceResolver();

                ObjectType otype;
                ComObject  source = null;

                if (url != null)
                {
                    source = resolver.CreateObjectFromURL(url, SourceResolverFlags.MediaSource, null, out otype);
                }

                if (stream != null)
                {
                    var bs = new ByteStream(stream);
                    source = resolver.CreateObjectFromStream(bs, null, SourceResolverFlags.MediaSource, null, out otype);
                }

                if (bytes != null)
                {
                    var bs = new ByteStream(bytes);
                    source = resolver.CreateObjectFromStream(bs, null, SourceResolverFlags.MediaSource | SourceResolverFlags.ContentDoesNotHaveToMatchExtensionOrMimeType, null, out otype);
                }

                if (source == null)
                {
                    throw new ArgumentException("'stream' and 'url' are null!");
                }

                mediaSource = source.QueryInterface <SharpDX.MediaFoundation.MediaSource>();


                resolver.Dispose();
                source.Dispose();
            }


            PresentationDescriptor presDesc;

            mediaSource.CreatePresentationDescriptor(out presDesc);

            for (var i = 0; i < presDesc.StreamDescriptorCount; i++)
            {
                RawBool          selected = false;
                StreamDescriptor desc;
                presDesc.GetStreamDescriptorByIndex(i, out selected, out desc);

                if (selected)
                {
                    TopologyNode sourceNode;
                    MediaFactory.CreateTopologyNode(TopologyType.SourceStreamNode, out sourceNode);

                    sourceNode.Set(TopologyNodeAttributeKeys.Source, mediaSource);
                    sourceNode.Set(TopologyNodeAttributeKeys.PresentationDescriptor, presDesc);
                    sourceNode.Set(TopologyNodeAttributeKeys.StreamDescriptor, desc);


                    TopologyNode outputNode;
                    MediaFactory.CreateTopologyNode(TopologyType.OutputNode, out outputNode);

                    var majorType = desc.MediaTypeHandler.MajorType;

                    if (majorType == MediaTypeGuids.Video)
                    {
                        Activate activate;

                        sampleGrabber = new VideoSampleGrabber();

                        _mediaType = new MediaType();

                        _mediaType.Set(MediaTypeAttributeKeys.MajorType, MediaTypeGuids.Video);

                        // Specify that we want the data to come in as RGB32.
                        _mediaType.Set(MediaTypeAttributeKeys.Subtype, new Guid("00000016-0000-0010-8000-00AA00389B71"));

                        MediaFactory.CreateSampleGrabberSinkActivate(_mediaType, SampleGrabber, out activate);
                        outputNode.Object = activate;


                        long frameSize = desc.MediaTypeHandler.CurrentMediaType.Get <long>(MediaTypeAttributeKeys.FrameSize);

                        Width  = (int)(frameSize >> 32);
                        Height = (int)(frameSize & 0x0000FFFF);
                    }

                    if (majorType == MediaTypeGuids.Audio)
                    {
                        Activate activate;
                        MediaFactory.CreateAudioRendererActivate(out activate);

                        outputNode.Object = activate;
                    }

                    _topology.AddNode(sourceNode);
                    _topology.AddNode(outputNode);
                    sourceNode.ConnectOutput(0, outputNode, 0);


                    Duration = new TimeSpan(presDesc.Get <long>(PresentationDescriptionAttributeKeys.Duration));


                    sourceNode.Dispose();
                    outputNode.Dispose();
                }

                desc.Dispose();
            }

            presDesc.Dispose();
            mediaSource.Dispose();


            videoFrame = new DynamicTexture(Game.Instance.RenderSystem, Width, Height, typeof(ColorBGRA), false, false);
        }
Esempio n. 24
0
    public void buildCubes()
    {
        MainController.TwitterAction -= handleAction;

        int   counter  = 0;
        float x_factor = 14;
        float y_factor = 3;
        float z_factor = 10;

        float noisefy = 0.5f;
        float noisefx = 7.0f;

        //float noisefy = 0f;
        //float noisefx = 0f;

        float cube_root = Mathf.Floor(Mathf.Pow(maxX, 1f / 3f));

        TweetSearchTwitterData twitterData;

        int max_count = MainController.Instance.TweetsList.Count;

        for (float x = 0; x < cube_root; ++x)
        {
            for (float y = 0; y < cube_root; ++y)
            {
                for (float z = 0; z < cube_root; ++z)
                {
                    //GameObject clone = Instantiate(rounded_cube, new Vector3(px / 2 * Random.Range(-2.0f, 2.0f), Random.Range(-5.0f, 5.0f), Random.Range(-10.0f, 30.0f)), transform.rotation) as GameObject;
                    float noisey = Random.Range(-noisefy, noisefy);
                    float noisex = Random.Range(-noisefx, noisefx);

                    GameObject clone = Instantiate(rounded_cube, new Vector3(x_factor * (x - (cube_root - 1) / 2) + noisex, y_factor * (y - (cube_root - 1) / 2) + noisey, z_factor * z), transform.rotation) as GameObject;

                    clone.GetComponent <RoundedCube>().image_quad.SetActive(true);

                    clone.GetComponent <RoundedCube>().speed = 1.0f - 1.5f * z / z_factor;

                    //clone.transform.parent = transform;
                    //ADD TWITTER DATA TO CUBE
                    if (counter >= max_count)
                    {
                        counter = 0;
                    }

                    twitterData = MainController.Instance.TweetsList[counter];

                    DynamicTexture dtex  = clone.GetComponentInChildren <DynamicTexture>();
                    Text           tweet = clone.GetComponentInChildren <Text>();

                    if (twitterData.tweetMedia != "")
                    {
                        dtex.url = twitterData.tweetMedia;
                        dtex.Apply(true);
                    }
                    else
                    {
                        clone.GetComponent <RoundedCube>().image_quad.SetActive(false);
                    }

                    string text = twitterData.tweetText;

                    clone.GetComponentInChildren <RoundedCube>().setTweetText(text);

                    clone.GetComponent <RoundedCube>().cube_grp.transform.Rotate(Vector3.up * Random.Range(0, 20));

                    clone.GetComponentInChildren <RoundedCube>().ambient = true;

                    floats_array.Add(clone);

                    counter++;
                }
            }
        }

        //turnOnFloaters();

        INIT = true;
    }
Esempio n. 25
0
 public DynamicImage(Vector2 size) : base("texture", size)
 {
     SnapToPixel = true;
     texture     = new DynamicTexture((int)Size.X, (int)Size.Y, TextureUnit.Texture0);
 }
Esempio n. 26
0
    public void buildCubes()
    {
        DestroyAllCubes();

        int counter = 0;

        float cube_root = TweetsList.Count;

        //MAXIMUM OF 10
        if (cube_root > 10)
        {
            cube_root = 10;
        }

        screeners_array = new List <GameObject>();

        for (float x = 0; x < cube_root; ++x)
        {
            GameObject clone = Instantiate(rounded_cube, new Vector3(-20.0f, Random.Range(-1.5f, 1.5f), 0), transform.rotation) as GameObject;
            clone.GetComponent <RoundedCube>().image_quad.SetActive(true);

            clone.transform.parent = transform;

            //ADD TWITTER DATA TO CUBE
            twitterData = TweetsList[counter];

            DynamicTexture dtex = clone.GetComponentInChildren <DynamicTexture>();

            Text tweet = clone.GetComponentInChildren <Text>();

            if (twitterData.tweetMedia != "")
            {
                dtex.url = twitterData.tweetMedia;
                dtex.Apply(true);
                clone.GetComponent <RoundedCube>().hasImage = true;
            }
            else
            {
                clone.GetComponent <RoundedCube>().image_quad.SetActive(false);
            }

            string text = twitterData.tweetText;

            clone.GetComponentInChildren <RoundedCube>().setTweetText(text);

            //THESE ARE ALL OUR FLOATERS
            //clone.GetComponent<RoundedCube>().floater = true;

            clone.GetComponent <RoundedCube>().index = 5 / 2 * Random.Range(-2.0f, 2.0f);

            clone.GetComponent <RoundedCube>().ypos = Random.Range(-1.5f, 1.5f);

            screeners_array.Add(clone);

            counter++;
        }

        turnOnFloater();

        INIT = true;
    }