public override void Process(RenderObject renderObject)
        {
            var renderSprite = (RenderSprite)renderObject;

            var renderStage = renderSprite.SpriteComponent.CurrentSprite.IsTransparent ? TransparentRenderStage : MainRenderStage;
            renderObject.ActiveRenderStages[renderStage.Index] = new ActiveRenderStage(EffectName);
        }
        public override void Process(RenderObject renderObject)
        {
            var renderMesh = (RenderMesh)renderObject;

            var renderStage = renderMesh.Material.HasTransparency ? TransparentRenderStage : MainRenderStage;
            renderObject.ActiveRenderStages[renderStage.Index] = new ActiveRenderStage(EffectName);
        }
        public override void Process(RenderObject renderObject)
        {
            var renderMesh = (RenderMesh)renderObject;

            // Only handle non-transparent meshes
            if (!renderMesh.Material.HasTransparency)
            {
                if (renderMesh.IsShadowCaster)
                    renderMesh.ActiveRenderStages[ShadowMapRenderStage.Index] = new ActiveRenderStage(EffectName);
            }
        }
Beispiel #4
0
        public void AddRenderObject(RenderObject newobject)
        {
            // Store the grid if one is added.
            if (newobject is Grid)
            {
                m_grid = (Grid)newobject;
                m_gridSizeX = m_grid.SizeX;
                m_gridSizeY = m_grid.SizeY;
                m_camera.SetGridSize(m_gridSizeX, m_gridSizeY);
            }

            if (m_renderObjects.Contains(newobject))
            {
                // Do nothing
            }
            else
            {
                m_renderObjects.Add(newobject);
            }
        }
Beispiel #5
0
 protected override void insertChildRenderObject(RenderObject child, object slot)
 {
     renderObject.setupParentData(child);
 }
Beispiel #6
0
 public ViewObjectNode(RenderObject renderObject, RenderView renderView, ObjectNodeReference objectNode)
 {
     RenderObject = renderObject;
     RenderView   = renderView;
     ObjectNode   = objectNode;
 }
 public override void Process(RenderNodeReference renderNodeReference, ref RenderNode renderNode, RenderObject renderObject, PipelineStateDescription pipelineState)
 {
     // Disable culling and depth clip
     if (VoxelRenderStage.Contains(renderNode.RenderStage))
     {
         pipelineState.RasterizerState = new RasterizerStateDescription(CullMode.None)
         {
             DepthClipEnable = DepthClipping
         };
         pipelineState.DepthStencilState.DepthBufferEnable      = false;
         pipelineState.DepthStencilState.DepthBufferWriteEnable = false;
         pipelineState.DepthStencilState.StencilEnable          = false;
         pipelineState.DepthStencilState.StencilWriteMask       = 0;
         pipelineState.DepthStencilState.StencilMask            = 0;
         pipelineState.BlendState.RenderTarget0.BlendEnable     = false;
         pipelineState.BlendState.IndependentBlendEnable        = false;
     }
 }
Beispiel #8
0
 public override void updateRenderObject(BuildContext context, RenderObject renderObject)
 {
     ((_RenderCupertinoAlertActions)renderObject).dividerThickness = this._dividerThickness;
     ((_RenderCupertinoAlertActions)renderObject).hasCancelButton  = this._hasCancelButton;
 }
Beispiel #9
0
 public override void applyPaintTransform(RenderObject child, Matrix4 transform)
 {
     this.applyPaintTransformForBoxChild((RenderBox)child, transform);
 }
 public ViewObjectNode(RenderObject renderObject, RenderView renderView, ObjectNodeReference objectNode)
 {
     RenderObject = renderObject;
     RenderView = renderView;
     ObjectNode = objectNode;
 }
Beispiel #11
0
 public override void updateRenderObject(BuildContext context, RenderObject renderObject)
 {
     renderObject = (_RenderCupertinoSliverRefresh)renderObject;
     ((_RenderCupertinoSliverRefresh)renderObject).refreshIndicatorLayoutExtent = refreshIndicatorLayoutExtent;
     ((_RenderCupertinoSliverRefresh)renderObject).hasLayoutExtent = hasLayoutExtent;
 }
Beispiel #12
0
 public RenderObjectHandle(IShader shader)
 {
     obj = shader;
     type = RenderObjectType.SHADER;
 }
Beispiel #13
0
 public RenderObjectHandle(Instance instance)
 {
     obj = instance;
     type = RenderObjectType.INSTANCE;
 }
Beispiel #14
0
 public void AppendObject(RenderObject renderobj)
 {
     renderobj.Scene = this;
     Objects.Add(renderobj);
 }
Beispiel #15
0
 public override void updateRenderObject(BuildContext context, RenderObject renderObject)
 {
     ((RenderAnimatedOpacity)renderObject).opacity = this.opacity;
 }
        //Main render function
        public void Render(Player player, List <GameObject> objects, List <ObjectReference> objref, RenderWindow window)
        {
            List <RenderObject> renderobjs = new List <Renderer.RenderObject>();

            //Generate view triangle with top vertex being player
            Vector2f tp = player.GetPosition();
            //Left and right vertices
            Vector2f tl = new Vector2f((float)(tp.X + Math.Cos(player.GetAngle() - player.FOV / 2) * player.MAXVIEWDIST), (float)(tp.Y + Math.Sin(player.GetAngle() - player.FOV / 2) * player.MAXVIEWDIST));
            Vector2f tr = new Vector2f((float)(tp.X + Math.Cos(player.GetAngle() + player.FOV / 2) * player.MAXVIEWDIST), (float)(tp.Y + Math.Sin(player.GetAngle() + player.FOV / 2) * player.MAXVIEWDIST));

            //Find all objects in view
            for (int n = 0; n < objects.Count; n++)
            {
                if (objects[n].GetVisible() && PointInTriangle(objects[n].GetPosition(), tp, tl, tr))
                {
                    renderobjs.Add(new Renderer.RenderObject(n, PointDistance(tp, objects[n].GetPosition())));
                }
            }


            //Sort objects by distance (bro Z buffering)
            //Insertion sort
            int i = 1, j;

            while (i < renderobjs.Count)
            {
                j = i;
                while (j > 0 && renderobjs[j - 1].distance < renderobjs[j].distance)
                {
                    RenderObject obj = renderobjs[j - 1];
                    renderobjs[j - 1] = renderobjs[j];
                    renderobjs[j]     = obj;
                    j--;
                }
                i++;
            }


            //Draw sky
            float  xpos   = (float)((int)(((player.GetAngleMod() / (2 * Math.PI)) * sky.Size.X) * 10)) % sky.Size.X;
            Sprite sprite = new Sprite(sky, new IntRect((int)xpos, 0, windowsize.X, windowsize.Y));

            //Sprite sprite = new Sprite(sky, new IntRect((int)xpos, 0, (int)sky.Size.X/2, (int)sky.Size.Y));
            sprite.Origin = new Vector2f(0, 0);
            //byte brightness = (byte)random.Next(200, 255);
            skybrightness   += (random.Next(150, 255) - skybrightness) >> 4;
            floorbrightness += (random.Next(200, 255) - floorbrightness) >> 4;
            byte brightness = (byte)skybrightness;

            sprite.Color = new Color(brightness, brightness, brightness);
            sprite.Scale = new Vector2f(1.0f, (float)windowsize.Y / (float)sky.Size.Y);
            rendertexture.Draw(sprite);

            //Draw floor
            //Get walk position
            int walkpos = (int)(((int)player.GetFloorMovement() * 1.5) % floor.Size.Y);

            sprite          = new Sprite(floor, new IntRect((int)xpos, walkpos, windowsize.X, windowsize.Y + walkpos));
            brightness      = (byte)floorbrightness;
            sprite.Color    = new Color(brightness, brightness, brightness);
            sprite.Position = new Vector2f(0, player.GetYView());
            sprite.Scale    = new Vector2f(1.0f, (float)windowsize.Y / (float)floor.Size.Y);
            rendertexture.Draw(sprite);

            float px, py;
            float scale;

            for (int n = 0; n < renderobjs.Count; n++)
            {
                //for(int n = 0; n<0; n++){
                int objindex = renderobjs[n].index;

                px = (float)tp.X;
                py = (float)tp.Y;

                //Vector2f objpos = new Vector2f(objects[objindex].GetPosition().X, objects[objindex].GetPosition().Y);
                Vector2f objpos = objects[objindex].GetPosition();;

                //Distance from player to object
                float playerpointdist = (float)renderobjs[n].distance;

                //Angle between leftmost triangle vertex and player
                float line1angle = (float)Math.Atan2((float)tl.Y - py, (float)tl.X - px);

                //Angle between object and player
                float line2angle = (float)Math.Atan2(objpos.Y - py, objpos.X - px);

                //Difference between the two
                float langle = line2angle - line1angle;
                //Wrap
                if (langle < 0)
                {
                    langle += (float)Math.PI * 2;
                }

                //Calculate image scale dependent on distance to player
                //scale = 1.0/(0.003*Math.Cos(player.FOV/2-langle)*playerpointdist);
                //scale = (float)(1.0f/(0.003*Math.Cos(player.FOV/2-langle)*playerpointdist));
                scale = (float)(1.0f / (0.02 * Math.Cos(player.FOV / 2 - langle) * playerpointdist));

                //Grab image with draw widths and height
                //Texture im = objects[objindex].GetImage();
                Texture im  = objref.Find(obj => obj.GetID() == objects[objindex].GetTextureReference()).GetTexture();
                float   imh = (float)im.Size.Y * scale / 2;
                float   imw = (float)im.Size.X * scale / 2;

                //Physical draw distance on the screen
                //As you get closer to objects, make them appear lower in the screen
                //to remove the effect of making it look like you're lying down
                float drawy;
                //drawy = player.GetYView()+1-(imh*(playerpointdist*0.5/player.GetMaxDistance()+0.2));
                //drawy = (player.GetYView()+1)-(imh*(0.8+0.2*playerpointdist/player.GetMaxDistance()) - imh*(1-objects[objindex].GetScale()));
                drawy = (float)((player.GetYView() + 1) - (imh * (0.8 + 0.2 * playerpointdist / player.GetMaxDistance())));

                //double drawy = player.GetYView()+1-imh;
                float drawx = (float)(langle * (float)windowsize.X / player.FOV - (imw / 2));

                sprite          = new Sprite(im);
                sprite.Scale    = new Vector2f(imw / (float)im.Size.X, imh / (float)im.Size.Y);
                sprite.Position = new Vector2f(drawx, drawy);
                //sprite.Origin = new Vector2f(sprite.Texture.Size.X/2, 0);

                //Set reference point dependent on angle within viewing triangle from player vertex
                //Note: Seems to add issues with object jitter and lower frame rate
                //sprite.Origin = new Vector2f((float)(sprite.Texture.Size.X*(1-langle/player.FOV)), 0);

                //Decrease object brightness for further objects
                //byte brightness = (byte)(255*Math.Pow(1.0-playerpointdist/player.GetMaxDistance(), 2));
                brightness   = (byte)(255 * Math.Pow(1.0 - playerpointdist / player.MAXVIEWDIST, 1));
                sprite.Color = new Color(brightness, brightness, brightness);
                //Draw image
                rendertexture.Draw(sprite);
            }

            RenderPlayerOverlays(objects, player);
            RenderMiniMap(minimappos, objects, player);

            //FPS
            fps += (1000.0f / clock.Restart().AsMilliseconds() - fps) * 0.1f;
            //Console.WriteLine("Avg FPS: " + fps);
            Text text = new Text("FPS: " + fps.ToString(), textfont);

            text.Color         = new Color(255, 255, 0);
            text.CharacterSize = 16;
            text.Position      = new Vector2f(0, windowsize.Y / 2);
            rendertexture.Draw(text);

            Sprite frame = new Sprite(rendertexture.Texture);

            //frame.Origin = new Vector2f(frame.GetLocalBounds().Left + frame.GetLocalBounds().Width/2, frame.GetLocalBounds().Top + frame.GetLocalBounds().Height/2);
            //frame.Scale = new Vector2f(1.0f, -1.0f);
            frame.TextureRect = new IntRect(0, frame.TextureRect.Height, frame.TextureRect.Width, -frame.TextureRect.Height);
            //frame.Color = new Color(10, 255, 10);
            window.Draw(frame);
        }
        protected override void ProcessPipelineState(RenderContext context, RenderNodeReference renderNodeReference, ref RenderNode renderNode, RenderObject renderObject, PipelineStateDescription pipelineState)
        {
            // Bind VAO
            pipelineState.InputElements = PrimitiveQuad.VertexDeclaration.CreateInputElements();
            pipelineState.PrimitiveType = PrimitiveQuad.PrimitiveType;

            // Don't clip nor write Z value (we are writing at 1.0f = infinity)
            pipelineState.DepthStencilState = DepthStencilStates.DepthRead;
        }
Beispiel #18
0
 public ObjectNode(RenderObject renderObject)
 {
     RenderObject = renderObject;
 }
Beispiel #19
0
        protected override void removeChildRenderObject(RenderObject child)
        {
            TableCellParentData childParentData = child.parentData as TableCellParentData;

            renderObject.setChild(childParentData.x, childParentData.y, null);
        }
	public void Register (RenderObject obj) {
		objects.Add (obj);
	}
Beispiel #21
0
 public override Rect describeApproximatePaintClip(RenderObject child)
 {
     return(_isOverflowing ? Offset.zero & size : null);
 }
 public void LoadObject(string objectName)
 {
   if (_objectsHandleDictionary.ContainsKey(objectName))
     return;
   _objectsHandleDictionary[objectName] = new RenderObject();
 }
Beispiel #23
0
 public RenderObjectHandle(ITesselatable tesselatable)
 {
     obj = new Geometry(tesselatable);
     type = RenderObjectType.GEOMETRY;
 }
Beispiel #24
0
        public void Start()
        {
            // Create an example triangle object.
            _triangleVertices = new List<Vertex>(6)
            {
                new Vertex(new Vector3(-0.25f, 0.25f, 0.0f), Colour.White, new Vector2(0.0f, 0.0f)),
                new Vertex(new Vector3(0.25f, -0.25f, 0.0f), Colour.White, new Vector2(1.0f, 64.0f)),
                new Vertex(new Vector3(-0.25f, -0.25f, 0.0f), Colour.White, new Vector2(0.0f, 64.0f)),

                new Vertex(new Vector3(-0.25f, 0.25f, 0.0f), Colour.White, new Vector2(0.0f, 0.0f)),
                new Vertex(new Vector3(0.25f, 0.25f, 0.0f), Colour.White, new Vector2(1.0f, 0.0f)),
                new Vertex(new Vector3(0.25f, -0.25f, 0.0f), Colour.White, new Vector2(1.0f, 64.0f))
            };

            _vertexBuffer = ResourceFactory.CreateVertexBufferInstance();
            _vertexBuffer.SetVertices(_triangleVertices);

            _pTexture = ResourceFactory.CreateTexture();
            _pTexture.Load(Helpers.GetRelativePath("Textures\\font.dds"));

            _pMaterial = ResourceFactory.CreateMaterial();
            _pMaterial.SetTexture(_pTexture);
            _pMaterial.LoadVertexShader(Helpers.GetRelativePath("Shaders\\DiffuseTexture.hlsl"), "VSMain", "vs_5_1");
            _pMaterial.LoadPixelShader(Helpers.GetRelativePath("Shaders\\DiffuseTexture.hlsl"), "PSMain", "ps_5_1");
            _pMaterial.Finalise(false);

            _pTriangle = new RenderObject("triangle");
            _pTriangle.SetVertexBuffer(_vertexBuffer);
            _pTriangle.SetMaterial(_pMaterial);

            // Create an example triangle object.
            _vertices2 = new List<Vertex>(4)
            {
                new Vertex(new Vector3(-0.25f, 0.25f, 0.0f), Colour.White, new Vector2(0.0f, 0.0f)),
                new Vertex(new Vector3(0.25f, -0.25f, 0.0f), Colour.White, new Vector2(1.0f, 1.0f)),
                new Vertex(new Vector3(0.25f, 0.25f, 0.0f), Colour.White, new Vector2(1.0f, 0.0f)),
                new Vertex(new Vector3(-0.25f, -0.25f, 0.0f), Colour.White, new Vector2(0.0f, 1.0f))
            };

            _indices = new List<int>(6)
            {
                1, 0, 2,
                0, 1, 3
            };

            _vertexBuffer2 = ResourceFactory.CreateVertexBufferInstance();
            _vertexBuffer2.SetVertices(_vertices2);

            _indexBuffer = ResourceFactory.CreateIndexBufferInstance();
            _indexBuffer.SetIndices(_indices);

            _pTexture2 = ResourceFactory.CreateTexture();
            _pTexture2.Load(Helpers.GetRelativePath("Textures\\test2.png"));

            _pMaterial2 = ResourceFactory.CreateMaterial();
            _pMaterial2.SetTexture(_pTexture2);
            _pMaterial2.LoadVertexShader(Helpers.GetRelativePath("Shaders\\DiffuseTexture.hlsl"), "VSMain", "vs_5_1");
            _pMaterial2.LoadPixelShader(Helpers.GetRelativePath("Shaders\\DiffuseTexture.hlsl"), "PSMain", "ps_5_1");
            _pMaterial2.Finalise(false);

            _pTriangle2 = new RenderObject("triangle2");
            _pTriangle2.SetIndexBuffer(_indexBuffer);
            _pTriangle2.SetVertexBuffer(_vertexBuffer2);
            _pTriangle2.SetMaterial(_pMaterial2);

            _pFont = FontManager.LoadFont("Myriad", Helpers.GetRelativePath("Textures\\myriad.dds"), Helpers.GetRelativePath("Textures\\myriad.txt"));
            _pText = new Text("text", _pFont);
            _pText.SetText("test");
            _pText.SetColour(Colour.Yellow);
            _pText.Transform.Position = new Vector3(0.0f, 0.0f, 0.0f);
            _pText2 = new Text("text2", _pFont);
            _pText2.SetText("Hello world!");
            _pText2.Transform.Position = new Vector3(0.0f, 20.0f, 0.0f);
            _pText2.EnableWorldSpace(true);
        }
Beispiel #25
0
 public RenderObjectHandle(CameraBase camera)
 {
     obj = camera;
     type = RenderObjectType.CAMERA;
 }
Beispiel #26
0
 public override void applyPaintTransform(RenderObject child, Matrix3 transform)
 {
     D.assert(child != null);
     D.assert(child == this.child);
     RenderSliverHelpers.applyPaintTransformForBoxChild(this, this.child, transform);
 }
 public abstract void Process(RenderObject renderObject);
Beispiel #28
0
 public override float childMainAxisPosition(RenderObject child)
 {
     return(0.0f);
 }
Beispiel #29
0
 protected override void moveChildRenderObject(RenderObject child, object slot)
 {
     this._placeChildInSlot(child, (_AlertSections)slot);
 }
Beispiel #30
0
 public override float childMainAxisPosition(RenderObject child)
 {
     D.assert(child == this.child);
     return(this._childPosition);
 }
Beispiel #31
0
 public override float?childMainAxisPosition(RenderObject child)
 {
     return(childScrollOffset(child) - constraints.scrollOffset);
 }
Beispiel #32
0
 public override float childMainAxisPosition(RenderObject child)
 {
     return(base.childMainAxisPosition(this.child));
 }
Beispiel #33
0
 public override void applyPaintTransform(RenderObject child, Matrix4 transform)
 {
 }
Beispiel #34
0
 public override Rect describeApproximatePaintClip(RenderObject childRaw)
 {
     return(_hasVisualOverflow ? Offset.zero & size : null);
 }
Beispiel #35
0
 public RenderNodeFeatureReference(RootRenderFeature rootRenderFeature, RenderNodeReference renderNode, RenderObject renderObject)
 {
     RootRenderFeature = rootRenderFeature;
     RenderNode        = renderNode;
     RenderObject      = renderObject;
 }
Beispiel #36
0
            public override bool IsVisible(RenderObject renderObject, RenderView renderView, RenderViewStage renderViewStage)
            {
                var entity = ((renderObject as RenderMesh)?.Source as ModelComponent)?.Entity;

                return(entity != null && selectedEntities.Contains(entity));
            }
        static void _reportOverflow(RenderObject renderObject, RelativeRect overflow, string overflowHints)
        {
            overflowHints = overflowHints ?? $"The edge of the {renderObject.GetType()} that is " +
                            "overflowing has been marked in the rendering with a yellow and black " +
                            "striped pattern. This is usually caused by the contents being too big " +
                            $"for the {renderObject.GetType()}.\n" +
                            "This is considered an error condition because it indicates that there " +
                            "is content that cannot be seen. If the content is legitimately bigger " +
                            "than the available space, consider clipping it with a ClipRect widget " +
                            $"before putting it in the {renderObject.GetType()}, or using a scrollable " +
                            "container, like a ListView.";

            List <string> overflows = new List <string> {
            };

            if (overflow.left > 0.0f)
            {
                overflows.Add($"{_formatPixels(overflow.left)} pixels on the left");
            }

            if (overflow.top > 0.0f)
            {
                overflows.Add($"{_formatPixels(overflow.top)} pixels on the top");
            }

            if (overflow.bottom > 0.0f)
            {
                overflows.Add($"{_formatPixels(overflow.bottom)} pixels on the bottom");
            }

            if (overflow.right > 0.0f)
            {
                overflows.Add($"{_formatPixels(overflow.right)} pixels on the right");
            }

            string overflowText = "";

            D.assert(overflows.isNotEmpty(),
                     $"Somehow {renderObject.GetType()} didn't actually overflow like it thought it did.");
            switch (overflows.Count)
            {
            case 1:
                overflowText = overflows.first();
                break;

            case 2:
                overflowText = $"{overflows.first()} and {overflows.last()}";
                break;

            default:
                overflows[overflows.Count - 1] = $"and {overflows[overflows.Count - 1]}";
                overflowText = string.Join(", ", overflow);
                break;
            }

            UIWidgetsError.reportError(
                new UIWidgetsErrorDetails(
                    exception: new Exception($"A {renderObject.GetType()} overflowed by {overflowText}."),
                    library: "rendering library",
                    context: "during layout",
                    informationCollector: (information) => {
                information.AppendLine(overflowHints);
                information.AppendLine($"The specific {renderObject.GetType()} in question is:");
                information.AppendLine($"  {renderObject.toStringShallow(joiner: "\n  ")}");
                information.AppendLine(string.Concat(Enumerable.Repeat("◢◤", 32)));
            }
                    )
                );
        }
Beispiel #38
0
        public override void ProcessPipelineState(RenderContext context, RenderNodeReference renderNodeReference, ref RenderNode renderNode, RenderObject renderObject, PipelineStateDescription pipelineState)
        {
            base.ProcessPipelineState(context, renderNodeReference, ref renderNode, renderObject, pipelineState);

            // Check if this is a wireframe rendering
            var perDrawLayout = renderNode.RenderEffect.Reflection?.PerDrawLayout;

            if (perDrawLayout == null)
            {
                return;
            }

            var perDrawDataOffset = perDrawLayout.GetConstantBufferOffset(this.perDrawData);

            if (perDrawDataOffset == -1)
            {
                return;
            }

            // Display using wireframe and without depth-buffer
            pipelineState.BlendState      = BlendStates.AlphaBlend;
            pipelineState.RasterizerState = RasterizerStates.Wireframe;
            pipelineState.DepthStencilState.DepthBufferEnable = false;
        }
Beispiel #39
0
 protected override void moveChildRenderObject(RenderObject child, object slot)
 {
 }
Beispiel #40
0
 public void RemoveRenderObject(RenderObject oldobject)
 {
     m_renderObjects.Remove(oldobject);
 }
 public abstract bool Matches(Engine.VPT.Table.Table table, IRenderable item, RenderObject ro, GameObject obj);
Beispiel #42
0
 public override void updateRenderObject(BuildContext context, RenderObject renderObject)
 {
 }
 public override void Process(RenderObject renderObject)
 {
     renderObject.ActiveRenderStages[RenderStage.Index] = new ActiveRenderStage(EffectName);
 }
Beispiel #44
0
 protected override void insertChildRenderObject(RenderObject child, object slot)
 {
     D.assert(slot == _rootChildSlot);
     D.assert(this.renderObject.debugValidateChild(child));
     this.renderObject.child = (T)child;
 }
Beispiel #45
0
 public RenderObjectHandle(Modifier modifier)
 {
     obj = modifier;
     type = RenderObjectType.MODIFIER;
 }
Beispiel #46
0
 protected override void moveChildRenderObject(RenderObject child, object slot)
 {
     D.assert(false);
 }
Beispiel #47
0
 public RenderObjectHandle(PrimitiveList prims)
 {
     obj = new Geometry(prims);
     type = RenderObjectType.GEOMETRY;
 }
Beispiel #48
0
 protected override void removeChildRenderObject(RenderObject child)
 {
     D.assert(this.renderObject.child == child);
     this.renderObject.child = null;
 }
Beispiel #49
0
 public RenderObjectHandle(LightSource light)
 {
     obj = light;
     type = RenderObjectType.LIGHT;
 }
Beispiel #50
0
        protected override void OnLoad(object sender, EventArgs e)
        {
            WaveProgram = MainWindow.CreateProgram(WaveVertexShader, MainWindow.ColoredFragmentShaderPath);

            _wave = new RenderObject(
                ObjectFactory.Curve(
                    FunctionToCurve((x) => 0f, -_length * 1f, _length * 1f, 1600),
                    Color4.White),
                WaveProgram)
            {
                Scale = new Vector3(Window.Width / _length, 1, 1)
            };

            ///// BUTTONS /////
            _startButton = new RectangularButton(
                new RectangleF(Window.Width / 2f - 75f, -Window.Height / 2f + 15f, 60f, 60f),
                ARectangularInteraction.DefaultLineWidth,
                Color4.Gray,
                Color4.White,
                Window.ColoredProgram);
            _startButton.ButtonPressEvent += (o, a) =>
            {
                _working ^= true;
                _startButton.FillColor = _working ? Color4.Red : Color4.Gray;
            };
            ///////////////////

            ///// CHECKBOX /////
            _timeSlipCheck = new RectangularCheckBox(60f, 60f, 5f, Color4.Black, Color4.White, Color4.Red, Window.ColoredProgram);
            ////////////////////

            ///// CIRCLES /////
            Color4 colorC = new Color4(0xCA, 0xC0, 0x3E, 128);

            _circleL = new RenderObject(ObjectFactory.FilledCircle(20f, colorC), Window.ColoredProgram);
            _circleR = new RenderObject(ObjectFactory.FilledCircle(20f, colorC), Window.ColoredProgram);
            ///////////////////

            Color4 colorL = new Color4(0.5f, 0.5f, 0.2f, 1.0f);

            _ampLines = new ROCollection(new RenderObject[]
            {
                new RenderObject(
                    ObjectFactory.Curve(
                        colorL,
                        new System.Numerics.Vector2(-0.5f * _length, +_amplitude / 0.1f),
                        new System.Numerics.Vector2(+0.5f * _length, +_amplitude / 0.1f)),
                    Window.ColoredProgram),
                new RenderObject(
                    ObjectFactory.Curve(
                        colorL,
                        new System.Numerics.Vector2(-0.5f * _length, -_amplitude / 0.1f),
                        new System.Numerics.Vector2(+0.5f * _length, -_amplitude / 0.1f)),
                    Window.ColoredProgram),
                new RenderObject(
                    ObjectFactory.Curve(
                        new Color4(1f, 1f, 1f, 0.3f),
                        new System.Numerics.Vector2(-0.5f * _length, 0f),
                        new System.Numerics.Vector2(+0.5f * _length, 0f)),
                    Window.ColoredProgram)
            })
            {
                Scale = new Vector3(Window.Width / _length, 1, 1)
            };

            ///// SLIDERS /////
            _freqSlider = new StandardSlider(400, 50, 20, 0, 5f, Color4.LightBlue, Color4.White, Window.ColoredProgram);
            _freqSlider.ValueChangedEvent += (o, ev) =>
            {
                _frequency     = ev.NewValue;
                _freqText.Text = $"f={ev.NewValue:0.000} Hz";
                UniformComponents();
            };
            _speedSlider = new StandardSlider(400, 50, 20, 0, 200, Color4.LightBlue, Color.White, Window.ColoredProgram)
            {
                Value = 100f
            };
            _speedSlider.ValueChangedEvent += (o, ev) =>
            {
                _speed          = ev.NewValue;
                _speedText.Text = $"v={ev.NewValue:000.00} m/s";
                UniformComponents();
            };
            ///////////////////

            ////// TEXTS //////
            string fontName = "Time New Roman";

            _freqText      = new RenderText(25, fontName, "f=0.000 Hz", Color.Transparent, Color.White, Window.TexturedProgram);
            _speedText     = new RenderText(25, fontName, "v=100.00 m/s", Color.Transparent, Color.White, Window.TexturedProgram);
            _lengthText    = new RenderText(25, fontName, "L=100.00 m", Color.Transparent, Color.White, Window.TexturedProgram);
            _timeSlipLabel = new RenderText(10, fontName, "timeslip", Color.Transparent, Color.White, Window.TexturedProgram);
            _startLabel    = new RenderText(10, fontName, "start", Color.Transparent, Color.White, Window.TexturedProgram);
            //////////////////

            UniformComponents();
        }
Beispiel #51
0
 public RenderObjectHandle(Options options)
 {
     obj = options;
     type = RenderObjectType.OPTIONS;
 }
Beispiel #52
0
 public void AddRenderObject(RenderObject renderObject)
 {
     _RenderObjects.Add(renderObject);
 }
	public void UnRegister (RenderObject obj) {
		objects.Remove (obj);
	}
Beispiel #54
0
        protected override void RenderModel(Entity e, Model m, SlimDX.Matrix parentWorld, float dtime)
        {
            if (m != null && m.Visible && e.IsVisible)
            {
                RenderObject tmp = new RenderObject { World = m.World * e.World * parentWorld, Model = m, AnimationController = e.AnimationController, AnimList = e.AnimationList, BillboardMatrix = m.World* Matrix.Scaling(e.Scale), BillboardVector = e.Translation };
                Renderer.Add(tmp);
            }

            if (((WorldEntity)e).IsSelected)
            {
                /*
                Device.SetSamplerState(0, SamplerState.AddressU, TextureAddress.Wrap);
                Device.SetSamplerState(0, SamplerState.AddressV, TextureAddress.Wrap);

                Device.SetTexture(0, selectionModel.Texture);
                Device.SetTransform(TransformState.Projection, Camera.Projection);
                Device.SetTransform(TransformState.View, Camera.View);
                Device.SetTransform(TransformState.World, selectionModel.World * Matrix.Translation(e.Translation));
                selectionModel.XMesh.DrawSubset(0);*/

                if (m.SkinnedMesh != null)
                {
                    float y = m.SkinnedMesh.maxY - m.SkinnedMesh.minY;
                    float x = m.SkinnedMesh.maxX - m.SkinnedMesh.minX;
                    float r = (float)Math.Sqrt((float)Math.Pow((x / 2), 2) + (float)Math.Pow((y / 2), 2)) / 4;

                    //boundingScales = new Vector3(o.Model.World.M32 * r / 1.2f, o.Model.World.M32 * r / 1.2f, o.Model.World.M32 * z / 1.8f);

                    RenderObject tmp = new RenderObject { Model = selectionModel, World = Matrix.Scaling(new Vector3(m.World.M32 * r * 1.2f, m.World.M32 * r * 1.2f, 1f)) * selectionModel.World * Matrix.Translation(e.Translation) };
                    Renderer.Add(tmp);
                }
            }
        }