public HUDToggleButton()
        {
            Shape = new HUDShape()
            {
                Type = HUDShapeType.Disc, Radius = 0.1f
            };
            bChecked = true;

            TextHeight = 0.8f;
            TextColor  = Colorf.Black;
            text       = "";
        }
 //public GuiElement elementGoWithMouse { get; set; }
 public MainPlace(string name) :
     base(name)
 {
     ElementsGoWithMouse = new List <GameElement>();
     mainPlaceImage      = Image.Load(".\\pic\\pic_mainback.jpg");
     picRect             = new Rectanglef((Program.totalWidth - Program.placeWidth), 0,
                                          Program.totalWidth, 900);
     picRectColor  = new Colorf(1, 1, 1, 0.98f);
     backRect      = new Rectanglef(0, 0, 1600, 900);
     backRectColor = new Colorf(0, 0, 0, 0.97f);
     //elementGoWithMouse = new GuiElement();
 }
		public void AppendSample(Vector3f pos, Vector2f screenPos, Colorf color)
		{
			ARKitPoint pt = new ARKitPoint();
			pt.pos = pos;
			pt.screenPos = screenPos;
			pt.color = color;

			if (ActiveMode == StreamMode.WriteToDiskStream)
				disk_writer.WriteLine(to_string(pt));
			else
				currentFrame.SamplePoints.Add(pt);
		}
Exemple #4
0
 protected void update(float newWidth, Colorf newColor)
 {
     if (width != newWidth)
     {
         vectorLine.SetWidth(newWidth);
         width = newWidth;
     }
     if (color != newColor)
     {
         vectorLine.SetColor(newColor);
         color = newColor;
     }
 }
Exemple #5
0
        public HUDLabel(float width, float height, ITextElementStyle textStyle)
        {
            Shape           = new HUDShape(HUDShapeType.Rectangle, width, height);
            BackgroundColor = Colorf.TransparentBlack;
            BorderWidth     = 0;
            BorderColor     = Colorf.TransparentBlack;
            EnableBorder    = false;

            TextHeight    = textStyle.TextHeight;
            TextColor     = textStyle.TextColor;
            AlignmentHorz = textStyle.AlignmentHorz;
            text          = "(default)";
        }
Exemple #6
0
        public HUDLabel(IContentBoxStyle boxStyle, ITextElementStyle textStyle)
        {
            Shape           = boxStyle.ShapeF(boxStyle.Width, boxStyle.Height);
            BackgroundColor = boxStyle.BackgroundColor;
            BorderWidth     = boxStyle.BorderWidth;
            BorderColor     = boxStyle.BorderColor;
            EnableBorder    = (boxStyle.BorderWidth != 0);

            TextHeight    = textStyle.TextHeight;
            TextColor     = textStyle.TextColor;
            AlignmentHorz = textStyle.AlignmentHorz;
            text          = "(default)";
        }
Exemple #7
0
        void compute_slice_polylines()
        {
            // fMaterial mat1 = MaterialUtil.CreateFlatMaterialF(Colorf.Black);
            // fMaterial mat2 = MaterialUtil.CreateFlatMaterialF(Colorf.BlueMetal);

            // [TODO] do we need to hold data_lock here? seems like no since main thread is blocked,
            //  then it would never be the case that we are setting SliceSet = null

            // create geometry
            int slice_i = 0;

            //SlicePolylines = new List<fPolylineGameObject>();

            foreach (PlanarSlice slice in SliceSet.Slices)
            {
                //DebugUtil.Log(2, "Slice has {0} solids", slice.Solids.Count);
                Colorf slice_color = (slice_i % 2 == 0) ? Colorf.Black : Colorf.BlueMetal;
                // fMaterial slice_mat = (slice_i % 2 == 0) ? mat1 : mat2;
                slice_i++;
                foreach (GeneralPolygon2d poly in slice.Solids)
                {
                    List <Vector3f> polyLine = new List <Vector3f>();
                    for (int pi = 0; pi <= poly.Outer.VertexCount; ++pi)
                    {
                        int      i  = pi % poly.Outer.VertexCount;
                        Vector2d v2 = poly.Outer[i];
                        Vector2d n2 = poly.Outer.GetTangent(i).Perp;

                        Vector3d v3 = new Vector3d(v2.x, v2.y, slice.Z);
                        v3 = MeshTransforms.ConvertZUpToYUp(v3);
                        v3 = MeshTransforms.FlipLeftRightCoordSystems(v3);
                        Vector3d n3 = MeshTransforms.ConvertZUpToYUp(new Vector3d(n2.x, n2.y, 0));
                        n3 = MeshTransforms.FlipLeftRightCoordSystems(n3);
                        n3.Normalize();
                        v3 += 0.1f * n3;

                        polyLine.Add((Vector3f)v3);
                    }

                    // Do something with polyline....
                    Console.WriteLine(polyLine);

                    ////DebugUtil.Log(2, "Polyline has {0} vertiecs", polyLine.Count);
                    //fPolylineGameObject go = GameObjectFactory.CreatePolylineGO(
                    //    "slice_outer", polyLine, slice_color, 0.1f, LineWidthType.World);
                    //go.SetMaterial(slice_mat, true);
                    //CC.ActiveScene.RootGameObject.AddChild(go, false);
                    //SlicePolylines.Add(go);
                }
            }
        }
Exemple #8
0
        public virtual void OnSetConstants(IMaterialRendererServices services)
        {
            IVideoDriver driver = services.VideoDriver;

            // set inverted world matrix
            // if we are using highlevel shaders (the user can select this when
            // starting the program), we must set the constants by name.
            Matrix4 invWorld = driver.GetTransform(TransformationState.WORLD);
            invWorld.MakeInverse();

            if (UseHighLevelShaders)
                services.SetVertexShaderConstant("mInvWorld", invWorld.GetFloats(), 16);
            else
                services.SetVertexShaderConstant(invWorld.GetFloats(), 0, 4);

            // set clip matrix
            Matrix4 worldViewProj;
            worldViewProj = driver.GetTransform(TransformationState.PROJECTION);
            worldViewProj *= driver.GetTransform(TransformationState.VIEW);
            worldViewProj *= driver.GetTransform(TransformationState.WORLD);

            if (UseHighLevelShaders)
                services.SetVertexShaderConstant("mWorldViewProj", worldViewProj.GetFloats(), 16);
            else
                services.SetVertexShaderConstant(worldViewProj.GetFloats(), 4, 4);

            // set camera position
            Vector3D pos = device.SceneManager.ActiveCamera.Position;

            if (UseHighLevelShaders)
                services.SetVertexShaderConstant("mLightPos",vectorToArray(pos), 3);
            else
                services.SetVertexShaderConstant(vectorToArray(pos), 8, 1);

            // set light color
            Colorf col= new Colorf(0.0f,1.0f,1.0f,0.0f);

            if (UseHighLevelShaders)
                services.SetVertexShaderConstant("mLightColor", colorToArray(col), 4);
            else
                services.SetVertexShaderConstant(colorToArray(col), 9, 1);

            // set transposed world matrix
            Matrix4 world = driver.GetTransform(TransformationState.WORLD);
            world = world.GetTransposed();

            if (UseHighLevelShaders)
                services.SetVertexShaderConstant("mTransWorld", world.GetFloats(), 16);
            else
                services.SetVertexShaderConstant(world.GetFloats(), 10, 4);
        }
Exemple #9
0
 protected void update(float newWidth, Colorf newColor)
 {
     if (width != newWidth)
     {
         width = newWidth;
         renderer.update_width(width);
     }
     if (color != newColor)
     {
         color = newColor;
         renderer.update_color(color);
         base.SetColor(color);       // material overrides line renderer??
     }
 }
Exemple #10
0
        public static fCircleGameObject CreateCircleGO(string sName, float fRadius, Colorf color, float fLineWidth)
        {
            GameObject go = new GameObject(sName);
            CurveRendererImplementation curveRen = CurveRendererSource.Build();

            curveRen.initialize(go, new Colorf(Colorf.Black, 0.75f));
            fCircleGameObject fgo = new fCircleGameObject(go, curveRen);

            fgo.SetColor(color);
            fgo.SetLineWidth(fLineWidth);
            fgo.SetSteps(32);
            fgo.SetRadius(fRadius);
            return(fgo);
        }
Exemple #11
0
        public static BakedPointCloud Initialize(BpcData data)
        {
            BakedPointCloud bpc = new BakedPointCloud();

            bpc._pointCount = data.size;

            int width = Mathf.CeilToInt(Mathf.Sqrt(bpc._pointCount));

            bpc._positionMap            = new Texture2D(width, width, TextureFormat.RGBAFloat, false);
            bpc._positionMap.name       = "Position Map";
            bpc._positionMap.filterMode = FilterMode.Point;

            bpc._colorMap            = new Texture2D(width, width, TextureFormat.RGBA32, false);
            bpc._colorMap.name       = "Color Map";
            bpc._colorMap.filterMode = FilterMode.Point;

            int  i1 = 0;
            uint i2 = 0U;

            IEnumerator <Vector3d> position = data.positions.GetEnumerator();
            IEnumerator <Colorf>   color    = data.colors.GetEnumerator();

            position.MoveNext();
            color.MoveNext();


            for (int y = 0; y < width; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    int i = i1 < bpc.pointCount ? i1 : (int)(i2 % bpc._pointCount);

                    Vector3d p = position.Current;
                    Colorf   c = color.Current;

                    bpc._positionMap.SetPixel(x, y, new Color((float)p.x, (float)p.y, (float)p.z));
                    bpc._colorMap.SetPixel(x, y, c);

                    i1++;
                    i2 += 132049U; // prime

                    position.MoveNext();
                    color.MoveNext();
                }
            }

            bpc._positionMap.Apply(false, true);
            bpc._colorMap.Apply(false, true);
            return(bpc);
        }
Exemple #12
0
        /// <summary>
        /// Add point that lives on TargetSO surface
        /// TODO: generalize to multiple target SOs??
        /// </summary>
        public virtual int AppendSurfacePoint(string name, Colorf color, float sizeScene = -1)
        {
            SurfacePoint pt = new SurfacePoint();

            pt.id              = point_id_counter++;
            pt.name            = name;
            pt.color           = color;
            pt.layer           = -1;
            pt.sizeS           = (sizeScene > 0) ? sizeScene : default_indicator_size;
            pt.initialized     = false;
            GizmoPoints[pt.id] = pt;
            OnPointAdded(pt);
            return(pt.id);
        }
Exemple #13
0
        /// <summary>
        /// Add point that lives on arbitrary surface
        /// rayTarget Must compute ray-intersections in *scene space*
        /// </summary>
        public virtual int AppendTargetPoint(string name, Colorf color, IIntersectionTarget sceneRayTarget, float sizeScene = -1)
        {
            TargetPoint pt = new TargetPoint();

            pt.id              = point_id_counter++;
            pt.name            = name;
            pt.color           = color;
            pt.layer           = -1;
            pt.sizeS           = (sizeScene > 0) ? sizeScene : default_indicator_size;
            pt.initialized     = false;
            pt.RayTarget       = sceneRayTarget;
            GizmoPoints[pt.id] = pt;
            OnPointAdded(pt);
            return(pt.id);
        }
Exemple #14
0
        public void SetColor(Colorf color)
        {
            switch (eType)
            {
            case TextType.UnityTextMesh:
                (text_component as TextMesh).color = color;
                break;

            case TextType.TextMeshPro:
#if G3_ENABLE_TEXT_MESH_PRO
                (text_component as TextMeshPro).color = color;
#endif
                break;
            }
        }
        public void AddAttribute(string sName, Colorf cValue, bool bInline = false)
        {
            string s = cValue[0].ToString("F8", CultureInfo.InvariantCulture) + " "
                       + cValue[1].ToString("F8", CultureInfo.InvariantCulture) + " "
                       + cValue[2].ToString("F8", CultureInfo.InvariantCulture) + " "
                       + cValue[3].ToString("F8", CultureInfo.InvariantCulture);

            if (bInline)
            {
                Writer.WriteAttributeString(sName, s);
            }
            else
            {
                Writer.WriteElementString(sName, s);
            }
        }
        public virtual void AddLabel(double atValue, string text, Colorf color, LabelPositionType position, Vector2f offset)
        {
            PositionLabel label = new PositionLabel();

            label.text     = text;
            label.color    = color;
            label.position = position;
            label.offset   = offset;

            if (Labels.ContainsKey(atValue))
            {
                RemoveGO((fGameObject)Labels[atValue].go);
                Labels[atValue].go.Destroy();
            }

            Labels[atValue] = label;
        }
Exemple #17
0
        public static DMesh3 MakeMarker(Vector3d vPos, float fRadius, Colorf color)
        {
            DMesh3 markerMesh        = new DMesh3(true, true, false);
            TrivialDiscGenerator gen = new TrivialDiscGenerator()
            {
                Slices = 8
            };

            gen.Radius = fRadius;
            gen.Generate();
            gen.MakeMesh(markerMesh);
            foreach (int vid in markerMesh.VertexIndices())
            {
                markerMesh.SetVertexColor(vid, color);
            }
            MeshTransforms.Translate(markerMesh, vPos.x, vPos.y, vPos.z);
            return(markerMesh);
        }
Exemple #18
0
        public void SetPointColor(int id, Colorf color, int nLayer = -1)
        {
            ControlPoint pt;

            if (GizmoPoints.TryGetValue(id, out pt) == false)
            {
                throw new Exception("MultiSurfacePointTool.SetPointMaterial: point with id " + id + " does not exist!");
            }
            pt.color = color;
            if (nLayer != -1)
            {
                pt.layer = nLayer;
                if (pt.indicator != null)
                {
                    Indicators.SetLayer(pt.indicator, nLayer);
                }
            }
        }
Exemple #19
0
        static public fGameObject EmitDebugMesh(string name, DMesh3 meshIn, Colorf color, GameObject parent = null, bool bIsInWorldPos = true)
        {
            DMesh3 mesh = new DMesh3(meshIn);

            if (FPlatform.InMainThread() == false)
            {
                ThreadMailbox.PostToMainThread(() => { DebugUtil.EmitDebugMesh(name, mesh, color, parent, bIsInWorldPos); });
                return(null);
            }
            fMeshGameObject fMeshGO = GameObjectFactory.CreateMeshGO(name, new fMesh(mesh), false, true);

            fMeshGO.SetMaterial(MaterialUtil.CreateStandardMaterialF(color));
            if (parent != null)
            {
                parent.AddChild(fMeshGO, bIsInWorldPos);
            }
            return(fMeshGO);
        }
Exemple #20
0
        /// <summary>
        /// This is very hacky.
        /// </summary>
        public static void AddDropShadow(HUDStandardItem item, Cockpit cockpit, Colorf color,
                                         float falloffWidthPx, Vector2f offset, float fZShift, bool bTrackCockpitScaling = true)
        {
            if (item is IBoxModelElement == false)
            {
                throw new Exception("HUDUtil.AddDropShadow: can only add drop shadow to IBoxModelElement");
            }

            float falloffWidth = falloffWidthPx * cockpit.GetPixelScale();

            // [TODO] need interface that provides a HUDShape?
            var   shape = item as IBoxModelElement;
            float w     = shape.Size2D.x + falloffWidth;
            float h     = shape.Size2D.y + falloffWidth;

            fRectangleGameObject meshGO = GameObjectFactory.CreateRectangleGO("shadow", w, h, color, false);

            meshGO.RotateD(Vector3f.AxisX, -90.0f);
            fMaterial dropMat = MaterialUtil.CreateDropShadowMaterial(color, w, h, falloffWidth);

            meshGO.SetMaterial(dropMat);

            item.AppendNewGO(meshGO, item.RootGameObject, false);
            BoxModel.Translate(meshGO, offset, fZShift);

            if (bTrackCockpitScaling)
            {
                PreRenderBehavior pb = meshGO.AddComponent <PreRenderBehavior>();
                pb.ParentFGO = meshGO;
                pb.AddAction(() => {
                    Vector3f posW = item.RootGameObject.PointToWorld(meshGO.GetLocalPosition());
                    ((Material)dropMat).SetVector("_Center", new Vector4(posW.x, posW.y, posW.z, 0));
                    float curWidth    = falloffWidthPx * cockpit.GetPixelScale();
                    Vector2f origSize = shape.Size2D + falloffWidth * Vector2f.One;
                    Vector2f size     = cockpit.GetScaledDimensions(origSize);
                    float ww          = size.x;
                    float hh          = size.y;
                    ((Material)dropMat).SetVector("_Extents", new Vector4(ww / 2, hh / 2, 0, 0));
                    float newWidth = falloffWidthPx * cockpit.GetPixelScale();
                    ((Material)dropMat).SetFloat("_FalloffWidth", newWidth);
                });
            }
        }
Exemple #21
0
        public static HUDButton CreateGeometryIconClickButton(HUDShape shape,
                                                              float fHUDRadius, float fAngleHorz, float fAngleVert,
                                                              Colorf bgColor,
                                                              IGameObjectGenerator addGeometry = null)
        {
            fMaterial mat = (bgColor.a == 1.0f) ?
                            MaterialUtil.CreateStandardMaterialF(bgColor) : MaterialUtil.CreateTransparentMaterialF(bgColor);
            HUDButton button = new HUDButton()
            {
                Shape = shape
            };

            button.Create(mat);
            if (addGeometry != null)
            {
                button.AddVisualElements(addGeometry.Generate(), true);
            }
            HUDUtil.PlaceInSphere(button, fHUDRadius, fAngleHorz, fAngleVert);
            return(button);
        }
Exemple #22
0
        public static HUDButton CreateMeshClickButton(
            fMesh mesh, Colorf color, float fMeshScale, Quaternionf meshRotation,
            float fHUDRadius, float fAngleHorz, float fAngleVert,
            IGameObjectGenerator addGeometry = null)
        {
            fMaterial mat = (color.a < 1.0f) ?
                            MaterialUtil.CreateTransparentMaterialF(color, color.a) :
                            MaterialUtil.CreateStandardMaterialF(color);

            HUDButton button = new HUDButton();

            button.Create(mesh, mat, fMeshScale, meshRotation);

            if (addGeometry != null)
            {
                button.AddVisualElements(addGeometry.Generate(), true);
            }
            HUDUtil.PlaceInSphere(button, fHUDRadius, fAngleHorz, fAngleVert);
            return(button);
        }
Exemple #23
0
        public static HUDButton CreateMeshClickButton(
            fMesh mesh, Colorf color, float fMeshScale, Quaternionf meshRotation,
            HUDSurface hudSurf, float dx, float dy,
            IGameObjectGenerator addGeometry = null)
        {
            fMaterial mat = (color.a < 1.0f) ?
                            MaterialUtil.CreateTransparentMaterialF(color, color.a) :
                            MaterialUtil.CreateStandardMaterialF(color);

            HUDButton button = new HUDButton();

            button.Create(mesh, mat, fMeshScale, meshRotation);

            if (addGeometry != null)
            {
                button.AddVisualElements(addGeometry.Generate(), true);
            }
            hudSurf.Place(button, dx, dy);
            return(button);
        }
Exemple #24
0
        public GraphicsContext(GraphicsDevice Device, Box Viewport)
        {
            this.CoreNum = 6;

            this.Device     = Device;
            this.Viewport   = Viewport;
            this.FrameCount = 0;

            this.ColorBuffer = null;
            this.ZBuffer     = new float[Viewport.Width * Viewport.Height];

            this.Vertices  = new ListCore <Vertex>(this.CoreNum);
            this.Fragments = new ListCore <Fragment>(this.CoreNum);
            this.Indices   = null;

            this.ClearColor         = Colorf.Black;
            this.FillModeState      = FillMode.Solid;
            this.CullFaceModeState  = CullFaceMode.Back;
            this.FrontFaceModeState = FrontFaceMode.CCW;
            this.Shader             = null;
            this.VertexBuffer       = null;
            this.IndexBuffer        = null;
        }
        void DrawPolygon(SKCanvas canvas, SKPaint paint, GeneralPolygon2d poly, Func <Vector2d, SKPoint> mapF)
        {
            Colorf color = Colorf.Red;

            if (Colors.ContainsKey(poly))
            {
                color = Colors[poly];
            }
            paint.Color = SkiaUtil.Color(color);

            SKPath path = SkiaUtil.ToSKPath(poly, mapF);

            paint.StrokeWidth = 2;
            canvas.DrawPath(path, paint);

            //paint.Color = SKColors.Orange;
            paint.StrokeWidth = 1;
            foreach (Vector2d v in poly.AllVerticesItr())
            {
                SKPoint c = mapF(v);
                canvas.DrawCircle(c.X, c.Y, 3.0f, paint);
            }
        }
        void DrawGraph(SKCanvas canvas, SKPaint paint, DGraph2 graph, Func <Vector2d, SKPoint> mapF)
        {
            Colorf color = Colorf.Red;

            if (Colors.ContainsKey(graph))
            {
                color = Colors[graph];
            }
            paint.Color = SkiaUtil.Color(color);

            SKPath path = SkiaUtil.ToSKPath(graph, mapF);

            paint.StrokeWidth = 2;
            canvas.DrawPath(path, paint);

            paint.StrokeWidth = 1;
            //paint.Color = SKColors.Black;
            foreach (Vector2d v in graph.Vertices())
            {
                SKPoint c = mapF(v);
                canvas.DrawCircle(c.X, c.Y, 3.0f, paint);
            }
        }
Exemple #27
0
        public virtual void initialize(fGameObject go, Colorf color)
        {
            // ugly...
            __VectrosityConfig.Configure();

            if (go.GetComponent <MeshFilter>() == null)
            {
                go.AddComponent <MeshFilter>();
            }
            if (go.GetComponent <MeshRenderer>() == null)
            {
                go.AddComponent <MeshRenderer>();
            }

            List <Vector3> vertices = new List <Vector3>()
            {
                Vector3f.Zero, Vector3f.Zero
            };

            vectorLine = new VectorLine(go.GetName() + "_vline", vertices, 1.0f, LineType.Continuous);
            VectorManager.ObjectSetup(go, vectorLine, Visibility.Dynamic, Brightness.None);
            vectorLine.SetColor(color);
        }
    void splat_to_grid(Vector3[] points)
    {
        Vector3f     camPos = Camera.main.gameObject.transform.position;
        UnityARVideo video  = Camera.main.gameObject.GetComponent <UnityARVideo>();

        for (int pi = 0; pi < points.Length; ++pi)
        {
            Vector3f pt = points[pi];
            if (pt.Distance(camPos) > MaxSampleDistanceM)
            {
                continue;
            }

            Vector3f screenCoords = Camera.main.WorldToScreenPoint(pt);
            Colorf   c            = Colorf.White;
            if (video != null)
            {
                c = video.QueryPixel(screenCoords.x, screenCoords.y);
            }

            grid.AddParticle(points[pi], c);
        }
    }
Exemple #29
0
        static public fGameObject EmitDebugBox(string name, Box3d box, Colorf color, GameObject parent = null, bool bIsInWorldPos = true)
        {
            if (FPlatform.InMainThread() == false)
            {
                ThreadMailbox.PostToMainThread(() => { DebugUtil.EmitDebugBox(name, box, color, parent, bIsInWorldPos); });
                return(null);
            }
            TrivialBox3Generator boxgen = new TrivialBox3Generator()
            {
                Box = box, NoSharedVertices = true, Clockwise = true
            };

            boxgen.Generate();
            DMesh3          mesh    = boxgen.MakeDMesh();
            fMeshGameObject fMeshGO = GameObjectFactory.CreateMeshGO(name, new fMesh(mesh), false, true);

            fMeshGO.SetMaterial(MaterialUtil.CreateStandardMaterialF(color));
            if (parent != null)
            {
                parent.AddChild(fMeshGO, bIsInWorldPos);
            }
            return(fMeshGO);
        }
Exemple #30
0
        static public GameObject EmitDebugCurve(string name, Vector3d[] curve, bool bClosed,
                                                float diameter, Colorf startColor, Colorf endColor,
                                                GameObject parent = null, bool bIsInWorldPos = true)
        {
            if (FPlatform.InMainThread() == false)
            {
                ThreadMailbox.PostToMainThread(() => { DebugUtil.EmitDebugCurve(name, curve, bClosed, diameter, startColor, endColor, parent, bIsInWorldPos); });
                return(null);
            }

            GameObject line = new GameObject();

            line.SetName(name);
            line.AddComponent <LineRenderer> ();
            LineRenderer lr = line.GetComponent <LineRenderer> ();

            lr.material   = MaterialUtil.CreateParticlesMaterial();
            lr.startColor = startColor;
            lr.endColor   = endColor;
            lr.startWidth = lr.endWidth = diameter;
            Vector3[] verts = new Vector3[curve.Length];
            for (int i = 0; i < curve.Length; ++i)
            {
                verts[i] = (Vector3)curve[i];
            }
            lr.positionCount = curve.Length;
            lr.SetPositions(verts);
            lr.loop          = bClosed;
            lr.useWorldSpace = (parent == null && bIsInWorldPos);

            if (parent != null)
            {
                line.transform.SetParent(parent.transform, bIsInWorldPos);
            }

            return(line);
        }
Exemple #31
0
 public void Update()
 {
     if (CCStatus.InOperation)
     {
         if (statusBG.IsVisible() == false)
         {
             statusBG.SetVisible(true);
             statusText.text = CCStatus.CurrentOperation;
             start_time      = FPlatform.RealTime();
         }
         else
         {
             double cur_time = FPlatform.RealTime();
             double dt       = cur_time - start_time;
             double t        = (Math.Cos(frequency * dt) + 1) * 0.5;
             Colorf c        = Colorf.Lerp(color1, color2, (float)t);
             statusBGImage.color = c;
         }
     }
     else
     {
         statusBG.SetVisible(false);
     }
 }
Exemple #32
0
 float[] colorToArray(Colorf p_m)
 {
     float[] t_a=new float[4];
     t_a[0]=p_m.r;
     t_a[1]=p_m.g;
     t_a[2]=p_m.b;
     t_a[3]=p_m.a;
     return t_a;
 }
Exemple #33
0
		static void gpu_OnSetConstants(MaterialRendererServices services, int userData)
		{
			VideoDriver driver = services.VideoDriver;

			if (useHighLevelShaders && shaderFirstUpdate)
			{
				shaderWorldViewProjId = services.GetVertexShaderConstantID("mWorldViewProj");
				shaderTransWorldId = services.GetVertexShaderConstantID("mTransWorld");
				shaderInvWorldId = services.GetVertexShaderConstantID("mInvWorld");
				shaderLightPosId = services.GetVertexShaderConstantID("mLightPos");
				shaderLightColorId = services.GetVertexShaderConstantID("mLightColor");

				// textures id are important only for OpenGL interface
				if (driver.DriverType == DriverType.OpenGL)
					shaderTextureId = services.GetVertexShaderConstantID("myTexture");

				shaderFirstUpdate = false;
			}

			// set inverted world matrix
			// if we are using highlevel shaders (the user can select this when
			// starting the program), we must set the constants by name

			Matrix invWorld = driver.GetTransform(TransformationState.World);
			invWorld.MakeInverse();

			if (useHighLevelShaders)
				services.SetVertexShaderConstant(shaderInvWorldId, invWorld.ToArray());
			else
				services.SetVertexShaderConstant(0, invWorld.ToArray());

			// set clip matrix

			Matrix worldViewProj = driver.GetTransform(TransformationState.Projection);
			worldViewProj *= driver.GetTransform(TransformationState.View);
			worldViewProj *= driver.GetTransform(TransformationState.World);

			if (useHighLevelShaders)
				services.SetVertexShaderConstant(shaderWorldViewProjId, worldViewProj.ToArray());
			else
				services.SetVertexShaderConstant(4, worldViewProj.ToArray());

			// set camera position

			Vector3Df pos = device.SceneManager.ActiveCamera.AbsolutePosition;

			if (useHighLevelShaders)
				services.SetVertexShaderConstant(shaderLightPosId, pos.ToArray());
			else
				services.SetVertexShaderConstant(8, pos.ToArray());

			// set light color

			Colorf col = new Colorf(0, 1, 1, 0);

			if (useHighLevelShaders)
				services.SetVertexShaderConstant(shaderLightColorId, col.ToArray());
			else
				services.SetVertexShaderConstant(9, col.ToArray());

			// set transposed world matrix

			Matrix transpWorld = driver.GetTransform(TransformationState.World).Transposed;

			if (useHighLevelShaders)
			{
				services.SetVertexShaderConstant(shaderTransWorldId, transpWorld.ToArray());
				services.SetPixelShaderConstant(shaderTextureId, new int[] { 0 });
			}
			else
			{
				services.SetVertexShaderConstant(10, transpWorld.ToArray());
			}
		}