Esempio n. 1
0
        /*public CollisionObject GetGUIObject(IGUIMapper mapper)
         * {
         *  int index = mappers.IndexOf(mapper);
         *  if (index >= 0)
         *      return guiColObjs[index];
         *  else
         *      return null;
         * }*/

        public void UpdateMapperMatrix(IGUIMapper mapper, Matrix renderMatrix)
        {
            int index = mappers.IndexOf(mapper);

            if (index >= 0)
            {
                renderers[index].RenderMatrix = renderMatrix;
            }
        }
Esempio n. 2
0
        public void UpdateMapperTexture(IGUIMapper mapper, uint[] textureData)
        {
            int index = mappers.IndexOf(mapper);

            if (index >= 0)
            {
                renderers[index].Texture = textureData;
            }
        }
Esempio n. 3
0
        public bool RemoveMapper(IGUIMapper mapper)
        {
            int  index   = mappers.IndexOf(mapper);
            bool removed = mappers.Remove(mapper);

            if (removed)
            {
                renderers.RemoveAt(index);
            }

            return(removed);
        }
Esempio n. 4
0
 public bool AddMapper(IGUIMapper mapper, Matrix renderMatrix)
 {
     if (!mappers.Contains(mapper))
     {
         mappers.Add(mapper);
         //CollisionObject colObj = new CollisionObject();
         //guiColObjs.Add(colObj);
         //renderers.Add(new GUIRenderer(mapper, renderMatrix, colObj));
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 5
0
            public GUIRenderer(IGUIMapper mapper, Matrix renderMatrix /*, CollisionObject colObj*/)
            {
                this.mapper       = mapper;
                this.renderMatrix = renderMatrix;
                //this.colObj = colObj;

                guiTexture = new Texture2D(State.Device, mapper.GUIWidth, mapper.GUIHeight,
                                           false, mapper.TextureFormat);
                texCoords = new VertexPositionTexture[4];

                // Calculate the GUI positions where it will rendered in the 3D world
                Matrix texPos = Matrix.Identity;

                width  = guiTexture.Width * mapper.DrawingScaleFactor.X / 2;
                height = guiTexture.Height * mapper.DrawingScaleFactor.Y / 2;

                texCoords[0].Position          = new Vector3(-width, height, 0);
                texCoords[0].TextureCoordinate = new Vector2(0, 1);

                texCoords[1].Position          = new Vector3(width, -height, 0);
                texCoords[1].TextureCoordinate = new Vector2(1, 0);

                texCoords[2].Position          = new Vector3(-width, -height, 0);
                texCoords[2].TextureCoordinate = new Vector2(0, 0);

                texCoords[3].Position          = new Vector3(width, height, 0);
                texCoords[3].TextureCoordinate = new Vector2(1, 1);

                vb = new DynamicVertexBuffer(State.Device, VertexPositionTexture.VertexDeclaration, 4, BufferUsage.WriteOnly);
                vb.SetData(texCoords);

                short[] indices = new short[6];

                indices[0] = 0;
                indices[1] = 1;
                indices[2] = 2;
                indices[3] = 3;
                indices[4] = 1;
                indices[5] = 0;

                ib = new DynamicIndexBuffer(State.Device, typeof(short), 6, BufferUsage.WriteOnly);
                ib.SetData(indices);

                textureData = mapper.GUITexture;

                //colObj = GoblinSetting.UICollisionWorld.Add2Dto3DGUI(new Vector2(width * 2, height * 2),
                //            renderMatrix, mapper.GetGUIName());
            }