コード例 #1
0
ファイル: gxtDynamicMesh.cs プロジェクト: Loko/GXT
 public gxtDynamicMesh(Vector2[] verts, gxtIMaterial material, Texture2D texture, Vector2[] textureCoordinates, bool setDefaultIndices = true)
 {
     gxtDebug.Assert(gxtRoot.SingletonIsInitialized);
     this.material = material;
     this.texture = texture;
     SetVertices(verts, textureCoordinates, setDefaultIndices);
 }
コード例 #2
0
ファイル: gxtLineList.cs プロジェクト: Loko/GXT
 public gxtLineList(Vector2[] verts, gxtIMaterial material, bool setDefaultIndices = true)
 {
     gxtDebug.Assert(gxtRoot.SingletonIsInitialized);
     gxtDebug.Assert(verts != null && verts.Length >= 2);
     this.material = material;
     SetVertices(verts, setDefaultIndices);
 }
コード例 #3
0
ファイル: gxtTextField.cs プロジェクト: Loko/GXT
 public gxtTextField(SpriteFont spriteFont, string text, gxtIMaterial material)
 {
     gxtDebug.Assert(spriteFont != null && text != null);
     this.text = text;
     this.spriteFont = spriteFont;
     this.material = material;
     UpdateOrigin();
 }
コード例 #4
0
ファイル: gxtDynamicMesh.cs プロジェクト: Loko/GXT
 public gxtDynamicMesh(Vector2[] verts, gxtIMaterial material, Texture2D texture, gxtTextureCoordinateType uvType = gxtTextureCoordinateType.CLAMP, bool setDefaultIndices = true)
 {
     gxtDebug.Assert(gxtRoot.SingletonIsInitialized);
     this.material = material;
     this.texture = texture;
     Vector2[] texCoords = gxtGeometry.CalculateTextureCoordinates(verts, texture.Width, texture.Height, uvType);
     SetVertices(verts, texCoords, setDefaultIndices);
 }
コード例 #5
0
ファイル: gxtSprite.cs プロジェクト: Loko/GXT
        public gxtSprite(Texture2D texture, gxtIMaterial material)
        {
            gxtDebug.Assert(gxtRoot.SingletonIsInitialized);
            gxtDebug.Assert(texture != null);
            gxtDebug.Assert(material != null);

            this.texture = texture;
            this.material = material;
            SetVertices();
            SetIndices();
        }
コード例 #6
0
ファイル: gxtCircle.cs プロジェクト: Loko/GXT
        public gxtCircle(float radius, gxtIMaterial material, gxtCircleDrawMode circleDrawMode = gxtCircleDrawMode.CIRCLE)
        {
            gxtDebug.Assert(radius > 0.0f);
            gxtDebug.Assert(gxtRoot.SingletonIsInitialized);

            this.radius = radius;
            this.circleDrawMode = circleDrawMode;
            this.material = material;

            SetVertices();
            SetIndices();
        }
コード例 #7
0
 public gxtDynamicIndexedPrimitive(Vector2[] verts, PrimitiveType primitiveType, gxtIMaterial material)
 {
     gxtDebug.Assert(gxtRoot.SingletonIsInitialized);
     this.primitiveType = primitiveType;
     int indicesArraySize = CalcIndicesArraySize(verts.Length, primitiveType);
     this.primitiveCount = CalcPrimitiveCount(indicesArraySize, primitiveType);
     this.material = material;
     // set up both buffers
     SetupVertices(verts);
     SetupIndices(indicesArraySize, primitiveType);
     localAABB = gxtGeometry.ComputeAABB(verts);
 }
コード例 #8
0
        public gxtDynamicIndexedPrimitive(Vector2[] verts, PrimitiveType primitiveType, gxtIMaterial material, Texture2D texture, Vector2[] textureCoordinates)
        {
            gxtDebug.Assert(gxtRoot.SingletonIsInitialized);
            this.primitiveType = primitiveType;
            int indicesArraySize = CalcIndicesArraySize(verts.Length, primitiveType);

            this.material = material;
            this.texture = texture;
            // set up vertices
            SetupVertices(verts, textureCoordinates);
            SetupIndices(indicesArraySize, primitiveType);
            localAABB = gxtGeometry.ComputeAABB(verts);
        }
コード例 #9
0
ファイル: gxtLine.cs プロジェクト: Loko/GXT
        public gxtLine(Vector2 start, Vector2 end, gxtIMaterial material)
        {
            gxtDebug.Assert(gxtRoot.SingletonIsInitialized);
            gxtDebug.Assert(material != null);

            this.material = material;
            vertices = new VertexPositionColorTexture[2];
            Color overlay = (material != null) ? material.ColorOverlay : gxtMaterial.DEFAULT_COLOR_OVERLAY;
            vertices[0] = new VertexPositionColorTexture(new Vector3(start.X, start.Y, 0.0f), overlay, Vector2.Zero);
            vertices[1] = new VertexPositionColorTexture(new Vector3(end.X, end.Y, 0.0f), overlay, Vector2.One);
            vertexBuffer = new VertexBuffer(gxtRoot.Singleton.Graphics, typeof(VertexPositionColorTexture), 2, BufferUsage.WriteOnly);
            vertexBuffer.SetData<VertexPositionColorTexture>(vertices);

            indices = new int[] { 0, 1 };
            indexBuffer = new IndexBuffer(gxtRoot.Singleton.Graphics, typeof(int), 2, BufferUsage.WriteOnly);
            indexBuffer.SetData<int>(indices);
        }
コード例 #10
0
ファイル: gxtRectangle.cs プロジェクト: Loko/GXT
        public gxtRectangle(float width, float height, gxtIMaterial material)
        {
            gxtDebug.Assert(width >= 0.0f && height >= 0.0f);
            gxtDebug.Assert(gxtRoot.SingletonIsInitialized);
            this.size = new Vector2(width, height);
            this.material = material;

            float rX = width * 0.5f, rY = height * 0.5f;
            vertices = new VertexPositionColorTexture[4];
            Color overlay = (material != null) ? material.ColorOverlay : gxtMaterial.DEFAULT_COLOR_OVERLAY;
            vertices[0] = new VertexPositionColorTexture(new Vector3(-rX, -rY, 0.0f), overlay, Vector2.Zero);
            vertices[1] = new VertexPositionColorTexture(new Vector3(-rX, rY, 0.0f), overlay, Vector2.UnitY);
            vertices[2] = new VertexPositionColorTexture(new Vector3(rX, rY, 0.0f), overlay, Vector2.One);
            vertices[3] = new VertexPositionColorTexture(new Vector3(rX, -rY, 0.0f), overlay, Vector2.UnitX);
            vertexBuffer = new VertexBuffer(gxtRoot.Singleton.Graphics, typeof(VertexPositionColorTexture), 4, BufferUsage.WriteOnly);
            vertexBuffer.SetData<VertexPositionColorTexture>(vertices);

            indices = new int[] { 0, 1, 2, 0, 2, 3 };
            indexBuffer = new IndexBuffer(gxtRoot.Singleton.Graphics, typeof(int), 6, BufferUsage.WriteOnly);
            indexBuffer.SetData<int>(indices);
        }
コード例 #11
0
ファイル: gxtInGameConsole.cs プロジェクト: Loko/GXT
        /// <summary>
        /// Note: consider making a struct that packages all these settings, or one or two structs
        /// At this rate, the number of variables for this function is growing to the point that it 
        /// deteroriates readability
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="consoleHeight"></param>
        /// <param name="initEnabled"></param>
        /// <param name="verbosity"></param>
        /// <param name="useGlobalVerbosity"></param>
        /// <param name="useTimeStamps"></param>
        /// <param name="consoleFont"></param>
        /// <param name="initOpen"></param>
        /// <param name="consolePrefix"></param>
        /// <param name="consoleTextRenderDepth"></param>
        /// <param name="consoleBackgroundRenderDepth"></param>
        /// <param name="logBufferSize"></param>
        public void Initialize(gxtSceneGraph scene, float consoleHeight, bool initEnabled = true, gxtVerbosityLevel verbosity = gxtVerbosityLevel.INFORMATIONAL, bool useGlobalVerbosity = true, bool useTimeStamps = false, SpriteFont consoleFont = null, 
            bool initOpen = true, string consolePrefix = "console: ", float consoleTextRenderDepth = 0.0f, float consoleBackgroundRenderDepth = 1.0f, int logBufferSize = 6)
        {
            gxtDebug.Assert(logBufferSize >= 0);
            gxtDebug.Assert(gxtDisplayManager.SingletonIsInitialized);

            this.enabled = initEnabled;
            this.useGlobalVerbosity = useGlobalVerbosity;
            this.verbosityLevel = verbosity;
            this.useTimeStamps = useTimeStamps;
            this.isOpen = initOpen;
            this.text = string.Empty;

            // all these colors and depths should be taken as parameters
            this.consoleSpriteFont = consoleFont;
            this.informationalMaterial = new gxtMaterial(isOpen, Color.White, consoleTextRenderDepth);
            this.successMaterial = new gxtMaterial(isOpen, Color.Green, consoleTextRenderDepth);
            this.warningMaterial = new gxtMaterial(isOpen, Color.Yellow, consoleTextRenderDepth);
            this.criticalMaterial = new gxtMaterial(isOpen, Color.Red, consoleTextRenderDepth);
            this.inputMaterial = new gxtMaterial(isOpen, Color.Black, consoleTextRenderDepth);
            this.backgroundMaterial = new gxtMaterial(isOpen, new Color(255, 255, 255, 65), consoleBackgroundRenderDepth);

            this.resolutionWidth = gxtDisplayManager.Singleton.ResolutionWidth;
            this.resolutionHeight = gxtDisplayManager.Singleton.ResolutionHeight;
            this.consoleWidth = resolutionWidth;
            this.consoleHeight = gxtMath.Clamp(consoleHeight, 0.0f, resolutionHeight);
            gxtDisplayManager.Singleton.resolutionChanged += OnResolutionChange;
            // these should be taken as parameters
            this.horizontalPadding = 15.0f;
            this.verticalPadding = 0.0f;
            this.verticalTextSpacing = 5.0f;

            // background rectangle and container node
            backgroundRectangle = new gxtRectangle(consoleWidth, consoleHeight, backgroundMaterial);
            consoleNode = new gxtSceneNode();
            consoleNode.Position = new Vector2(0.0f, (-resolutionHeight * 0.5f) + (consoleHeight * 0.5f));
            consoleNode.AttachDrawable(backgroundRectangle);

            // textnode
            this.consolePrefix = consolePrefix;
            consoleTextField = new gxtTextField(consoleFont, consolePrefix + "_", inputMaterial);
            consoleTextNode = new gxtSceneNode();
            consoleTextNode.AttachDrawable(consoleTextField);

            consoleNode.AddChild(consoleTextNode);

            this.logBufferSize = logBufferSize;
            this.logWriteIndex = 0;

            logBufferNodes = new gxtSceneNode[logBufferSize];
            logBufferEntries = new gxtTextField[logBufferSize];

            // consider using a fixed size queue instead
            gxtISceneNode topAnchor = new gxtSceneNode();
            topAnchor.Position = new Vector2((consoleWidth * 0.5f) - horizontalPadding, (-consoleHeight * 0.5f) + verticalPadding);
            logBufferNodes[0] = topAnchor;
            logBufferEntries[0] = new gxtTextField(consoleFont);
            logBufferEntries[0].Material = new gxtMaterial();
            logBufferNodes[0].AttachDrawable(logBufferEntries[0]);

            gxtISceneNode current = topAnchor;
            for (int i = 1; i < logBufferSize; ++i)
            {
                gxtISceneNode node = new gxtSceneNode();
                logBufferNodes[i] = node;
                current.AddChild(node);
                node.Position = new Vector2(0.0f, verticalTextSpacing);
                current = node;

                gxtTextField tf = new gxtTextField(consoleFont);
                logBufferEntries[i] = tf;
                tf.Material = new gxtMaterial();
                current.AttachDrawable(tf);
            }

            consoleNode.AddChild(topAnchor);
            scene.AddNode(consoleNode);

            AdjustConsoleTextPos();
        }
コード例 #12
0
ファイル: gxtTextField.cs プロジェクト: Loko/GXT
 public void UpdateFromMaterial(gxtIMaterial material)
 {
     // nothing to update
 }
コード例 #13
0
ファイル: gxtLineList.cs プロジェクト: Loko/GXT
 public gxtLineList(gxtIMaterial material)
 {
     gxtDebug.Assert(gxtRoot.SingletonIsInitialized);
     this.material = material;
 }
コード例 #14
0
ファイル: gxtLineList.cs プロジェクト: Loko/GXT
 public void UpdateFromMaterial(gxtIMaterial material)
 {
     gxtDebug.Assert(this.material == material);
     if (material != null)
     {
         if (vertices.Length > 0 && !vertices[0].Color.Equals(material.ColorOverlay))
         {
             for (int i = 0; i < vertices.Length; ++i)
             {
                 vertices[i].Color = material.ColorOverlay;
             }
             vertexBuffer.SetData<VertexPositionColorTexture>(vertices);
         }
     }
     else
     {
         if (vertices.Length > 0 && !vertices[0].Color.Equals(gxtMaterial.DEFAULT_COLOR_OVERLAY))
         {
             for (int i = 0; i < vertices.Length; ++i)
             {
                 vertices[i].Color = material.ColorOverlay;
             }
             vertexBuffer.SetData<VertexPositionColorTexture>(vertices);
         }
     }
 }
コード例 #15
0
ファイル: gxtLineList.cs プロジェクト: Loko/GXT
        public gxtLineList(Vector2[] verts, int[] indices, gxtIMaterial material)
        {
            gxtDebug.Assert(gxtRoot.SingletonIsInitialized);
            gxtDebug.Assert(verts != null && verts.Length >= 2);
            gxtDebug.Assert(indices != null && indices.Length >= 2);
            gxtDebug.Assert(material != null);

            this.material = material;
            Set(verts, indices);
        }
コード例 #16
0
ファイル: gxtLine.cs プロジェクト: Loko/GXT
 public void UpdateFromMaterial(gxtIMaterial material)
 {
     gxtDebug.Assert(this.material == material);
     if (material != null)
     {
         vertices[0].Color = material.ColorOverlay;
         vertices[1].Color = material.ColorOverlay;
     }
     else
     {
         vertices[0].Color = gxtMaterial.DEFAULT_COLOR_OVERLAY;
         vertices[1].Color = gxtMaterial.DEFAULT_COLOR_OVERLAY;
     }
 }
コード例 #17
0
ファイル: gxtDynamicMesh.cs プロジェクト: Loko/GXT
 public gxtDynamicMesh(Vector2[] verts, gxtIMaterial material, bool setDefaultIndices = true)
 {
     gxtDebug.Assert(gxtRoot.SingletonIsInitialized);
     this.material = material;
     SetVertices(verts, setDefaultIndices);
 }