// c'tor
        public UIGridTextElement(String textureName, Vector2 size, String label)
        {
            this.size        = size;
            this.label       = label;
            this.textureName = textureName;

            quad = SimpleTexturedQuad.GetInstance();
        }   // end of UIGridTextElement c'tor
        public Form3DView() : base(ID)
        {
            base.IsOpenReflectsVisiblity = true;

            InitializeComponent();

            LoadOpenGLControl();

            imuModel       = LoadModel("PCB", this.imuHousingToolStripMenuItem.Checked ? housingModelPath : pcbModelPath, true);
            axisModel      = LoadModel("Axis", "~/3DView/Arrow.obj", false);
            floorTileModel = LoadModel("Floor Tile", floorTileModelPath, false);

            material = new SimpleTexturedMaterial(false);
            effects.Effects.Add(material.Name, material);

            tileMaterial = new SimpleTexturedMaterial(true);
            effects.Effects.Add(tileMaterial.Name, tileMaterial);

            effects.Effects.Add(SimpleTexturedQuad.GetName(BoxMode.Color), new SimpleTexturedQuad(BoxMode.Color));
            effects.Effects.Add(SimpleTexturedQuad.GetName(BoxMode.Textured), new SimpleTexturedQuad(BoxMode.Textured));
            effects.Effects.Add(SimpleTexturedQuad.GetName(BoxMode.TexturedColor), new SimpleTexturedQuad(BoxMode.TexturedColor));

            textRenderer         = new TextRenderer(10, 10);
            texturedQuad         = new TextureQuad(effects);
            texturedQuad.Texture = textRenderer.Texture;

            view = new View3D(glControl1.Bounds, glControl1.Bounds.Width, glControl1.Bounds.Height, (float)Math.PI / 4f);

            int lightCount = 1;

            //lightBuffer = new UniformBuffer("Lights", new UniformBufferInfo(ModelLightInstance.Format, 1, OpenTK.Graphics.OpenGL.BufferUsageHint.DynamicDraw));

            lights = new ModelLightInstance[lightCount];

            sceneLights    = new ModelSceneLight[lightCount];
            sceneLights[0] = new ModelSceneLight()
            {
                Center            = new OpenTK.Vector3(30, 80, 60) * 8000f,
                Color             = Color4.White,
                SpecularPower     = 1.2f,
                Radius            = float.PositiveInfinity,
                AttenuatuionTermA = 0f,
                Intensity         = 0.8f,
                Directional       = true,
            };


            lightingArguments = new LightingArguments();

            Quaternion = NgimuApi.Maths.Quaternion.Identity;

            formUpdateTimer          = new Timer();
            formUpdateTimer.Interval = 20;
            formUpdateTimer.Tick    += new EventHandler(formUpdateTimer_Tick);

            tileTexture = new BitmapTexture2D("Tile Texture", "~/3DView/Compass.png", Texture2DInfo.Bitmap32_LinearClampToEdgeMipAnisotropicFilteringX4(new Size(32, 32)));
        }
示例#3
0
        }   // end of HandleTouchInput()

        public override void Render(Camera camera)
        {
            if (rt != null && level != null && !dirty)
            {
                // We do this check here to ensure the download state icon's alpha is reset if needed before being rendered.
                // When this check is performed in Update, we see a fully opaque icon for one frame due to order of operations.
                if (Level != null)
                {
                    if (Level.DownloadState != prevDownloadState)
                    {
                        DownloadStateChanged();
                    }
                    prevDownloadState = Level.DownloadState;
                }

                try
                {
                    SimpleTexturedQuad quad = SimpleTexturedQuad.GetInstance();

                    // Render thumbnail drop shadow.
                    {
                        float  s            = Scale;
                        Matrix shadowMatrix =
                            Matrix.CreateScale(3.8f + 0.25f * s * s) *
                            Matrix.CreateTranslation(0, -0.2f * s, 0) *
                            worldMatrix;
                        quad.Render(camera, levelTileShadow, ref shadowMatrix, 0.6f);
                    }

                    // Render the favorite box
                    if (0 != (level.Genres & BokuShared.Genres.Favorite))
                    {
                        Matrix tileMatrix = Matrix.CreateScale(2.13f) * worldMatrix;
                        quad.Render(camera, favoriteBox, ref tileMatrix, levelTileAlphaMap);
                    }

                    // Render the thumbnail.
                    {
                        Matrix tileMatrix = Matrix.CreateScale(2f) * worldMatrix;
                        quad.Render(camera, rt, ref tileMatrix, levelTileAlphaMap);
                    }

                    if (Level != null)
                    {
                        const float kDownloadStatusX = 0.9f;
                        const float kDownloadStatusY = 0.8f;

                        if (Level.FlaggedByMe)
                        {
                            Matrix m = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY, 0) * worldMatrix;
                            quad.Render(camera, reportAbuse, ref m, 1.0f);
                        }
                        else
                        {
                            switch (Level.DownloadState)
                            {
                            case LevelMetadata.DownloadStates.Queued:
                            {
                                Matrix s = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY - 0.1f, 0) * worldMatrix;
                                quad.Render(camera, statusIconShadow, ref s, 0.75f * downloadStateIconAlpha);
                                Matrix m = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY, 0) * worldMatrix;
                                quad.Render(camera, downloadQueuedIcon, ref m, downloadQueuedAlphaMap, downloadStateIconAlpha);
                            }
                            break;

                            case LevelMetadata.DownloadStates.InProgress:
                            {
                                Matrix s = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY - downloadInProgressAnimOffset - 0.1f, 0) * worldMatrix;
                                quad.Render(camera, statusIconShadow, ref s, 0.75f * downloadStateIconAlpha);
                                Matrix m = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY - downloadInProgressAnimOffset, 0) * worldMatrix;
                                quad.Render(camera, downloadInProgressIcon, ref m, downloadInProgressAlphaMap, downloadStateIconAlpha);
                            }
                            break;

                            case LevelMetadata.DownloadStates.Failed:
                            {
                                Matrix s = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY - 0.1f, 0) * worldMatrix;
                                quad.Render(camera, statusIconShadow, ref s, 0.75f * downloadStateIconAlpha);
                                Matrix m = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY, 0) * worldMatrix;
                                quad.Render(camera, downloadFailedIcon, ref m, downloadFailedAlphaMap, downloadStateIconAlpha);
                            }
                            break;

                            case LevelMetadata.DownloadStates.Complete:
                            {
                                Matrix s = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY - 0.1f, 0) * worldMatrix;
                                quad.Render(camera, statusIconShadow, ref s, 0.75f * downloadStateIconAlpha);
                                Matrix m = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY, 0) * worldMatrix;
                                quad.Render(camera, downloadCompleteIcon, ref m, downloadCompleteAlphaMap, downloadStateIconAlpha);
                            }
                            break;
                            }
                        }
                    }
                }
                catch
                {
                    // This will end up here if the rt call above throws an exception
                    // because it thinks that the rendertarget is still tied to the device.  This
                    // only occurs in some device-reset situations.  If we do nothing here then
                    // everything is ok next frame.
                }
            }
        }   // end of UIGridLevelElement Render()