Exemplo n.º 1
0
 PerfomanceComponent(double elapsedMilliseconds, double fPS) : this()
 {
     Tag = ElementTag.New();
     ElapsedMilliseconds = elapsedMilliseconds;
     IsValid             = true;
     FPS = fPS;
 }
Exemplo n.º 2
0
 CollidedWithEntityByRayComponent(ElementTag with, Vector3 intersectionPositionWorld) : this()
 {
     Tag     = ElementTag.New("CollidedWith");
     With    = with;
     IsValid = true;
     IntersectionPositionWorld = intersectionPositionWorld;
 }
 public SpherePointComponent(Vector3 center, float radius) : this()
 {
     Center  = center;
     Radius  = radius;
     IsValid = true;
     Tag     = ElementTag.New();
 }
Exemplo n.º 4
0
 ColorComponent(Vector4 color, ColorTypes type) : this()
 {
     IsValid = true;
     Tag     = ElementTag.New();
     Color   = color;
     Type    = type;
 }
Exemplo n.º 5
0
        public GameObject DrawPolyline(string key, Vector3[] margin, Vector4 green)
        {
            var line = VisualPolylineObject.Create(Context, ElementTag.New($"{key}_polyline"),
                                                   margin, green, true);

            return(line);
        }
Exemplo n.º 6
0
        static void _Create(IContextState context, IEnumerable <IFileGeometry3D> meshes,
                            FileInfo texture, string name, LoadedVisualObject visual)
        {
            List <ElementTag> t    = new List <ElementTag>();
            var            details = new LoadedObjectDetails();
            var            baseTag = ElementTag.New();
            var            index   = 0;
            AxisAlignedBox fullBox = AxisAlignedBox.Zero;

            foreach (var geo in meshes)
            {
                var tag = Create(context, baseTag.WithPrefix(geo.Name ?? index.ToString()),
                                 new GeometryStructures <IFileGeometry3D>(geo), texture, out var box);
                t.Add(tag);
                fullBox                = fullBox.Merge(box.Bounds);
                details.VertexCount   += geo.Positions.Count;
                details.TriangleCount += (geo.Indices.Count / 3);
                index++;
            }

            visual.tags.AddRange(t);
            visual.Details = details;

            var size = fullBox.Size();

            visual.worldX = VisualPolylineObject.Create(context, baseTag.WithPrefix("WorldX"),
                                                        new[] { Vector3.Zero + Vector3.UnitX * size.X * -2f, Vector3.Zero + Vector3.UnitX * size.X * 2f }, V4Colors.Red, false);
            visual.worldX.IsVisible = false;
            visual.worldY           = VisualPolylineObject.Create(context, baseTag.WithPrefix("WorldY"),
                                                                  new[] { Vector3.Zero + Vector3.UnitY * size.Y * -2f, Vector3.Zero + Vector3.UnitY * size.Y * 2f }, V4Colors.Green, false);
            visual.worldY.IsVisible = false;
            visual.worldZ           = VisualPolylineObject.Create(context, baseTag.WithPrefix("WorldZ"),
                                                                  new[] { Vector3.Zero + Vector3.UnitZ * size.Z * -2f, Vector3.Zero + Vector3.UnitZ * size.Z * 2f }, V4Colors.Blue, false);
            visual.worldZ.IsVisible = false;
        }
Exemplo n.º 7
0
        public GameObject DrawCylinder(string key, CylinderDetails cyl)
        {
            var geo = GeometryBuilder.BuildCylinder(cyl.Start, cyl.Axis, cyl.Radius, cyl.Length);

            var en = EntityBuilders.BuildColored(Context, ElementTag.New(key), geo, cyl.Color, SharpDX.Direct3D11.CullMode.None);

            return(new SingleVisualObject(en.Tag, key));
        }
Exemplo n.º 8
0
 public GameObject DrawPoint(string key, Vector3 center, Vector4 color)
 {
     return(VisualSphereObject.Create(Context, ElementTag.New($"{key}_Point"), new VisualSphereObject.Data {
         Center = center,
         Color = color,
         Radius = .1f
     }));
 }
Exemplo n.º 9
0
 public static RenderableComponent AsTriangleColoredList(CullMode mode)
 => new RenderableComponent(mode, PrimitiveTopology.TriangleList, RenderTechniques.TriangleColored)
 {
     Tag           = ElementTag.New(),
     IsValid       = true,
     HasBlendState = true,
     RasterizerStateDescription = D3DRasterizerStateDescriptions.Default(mode),
     BlendStateDescription      = D3DBlendStateDescriptions.BlendStateEnabled,
 };
Exemplo n.º 10
0
 LightComponent(float intensity, int index, Vector3 position, Vector3 direction, LightTypes type) : this()
 {
     Tag       = ElementTag.New();
     IsValid   = true;
     Intensity = intensity;
     Index     = index;
     Position  = position;
     Direction = direction;
     Type      = type;
 }
Exemplo n.º 11
0
        public RenderableComponent SwitchCullModeTo(CullMode mode)
        {
            Tag          = ElementTag.New();
            IsRenderable = true;
            var rast = RasterizerStateDescription;

            rast.CullMode = mode;
            RasterizerStateDescription = rast;
            return(this);
        }
Exemplo n.º 12
0
 static RenderableComponent AsLineList(RasterizerStateDescription2 rast, RenderTechniques technique)
 => new RenderableComponent(CullMode.None, PrimitiveTopology.LineList, technique)
 {
     Tag           = ElementTag.New(),
     IsValid       = true,
     HasBlendState = true,
     RasterizerStateDescription  = rast,
     DepthStencilStateDefinition = D3DDepthStencilDefinition.DepthEnabled,
     BlendStateDescription       = D3DBlendStateDescriptions.BlendStateDisabled,
 };
Exemplo n.º 13
0
 CameraMovementComponent(CameraState state, MovementData movementData, MovementTypes movementType,
                         int delta, float speedValue) : this()
 {
     Tag          = ElementTag.New();
     IsValid      = true;
     State        = state;
     MovementData = movementData;
     MovementType = movementType;
     Delta        = delta;
     SpeedValue   = speedValue;
 }
Exemplo n.º 14
0
 static RenderableComponent AsTriangleList(CullMode mode, D3DDepthStencilDefinition depth,
                                           RenderTechniques technique)
 => new RenderableComponent(mode, PrimitiveTopology.TriangleList, technique)
 {
     Tag           = ElementTag.New(),
     IsValid       = true,
     HasBlendState = true,
     DepthStencilStateDefinition = depth,
     RasterizerStateDescription  = D3DRasterizerStateDescriptions.Default(mode),
     BlendStateDescription       = D3DBlendStateDescriptions.BlendStateEnabled,
 };
Exemplo n.º 15
0
        public static GraphicEntity BuildColored(IContextState context,
                                                 IReadOnlyCollection <Vector3> pos, IReadOnlyCollection <int> indexes,
                                                 IReadOnlyCollection <Vector3> norm, Vector4 v4color, CullMode cullMode)
        {
            var mormals = norm ?? pos.ToList().CalculateNormals(indexes.ToList()).AsReadOnly();

            return(BuildColored(context, ElementTag.New("TriangleColored"), new ImmutableGeometryData(
                                    pos,
                                    mormals,
                                    indexes), v4color, cullMode));
        }
Exemplo n.º 16
0
        public static RenderableComponent AsTriangleColored(PrimitiveTopology topology)
        {
            var mode = CullMode.Front;

            return(new RenderableComponent(mode, topology, RenderTechniques.TriangleColored)
            {
                Tag = ElementTag.New(),
                IsValid = true,
                HasBlendState = true,
                DepthStencilStateDefinition = D3DDepthStencilDefinition.DepthEnabled,
                RasterizerStateDescription = D3DRasterizerStateDescriptions.Default(mode),
                BlendStateDescription = D3DBlendStateDescriptions.BlendStateEnabled,
            });
        }
Exemplo n.º 17
0
 public MaterialColorComponent(
     Vector4 ambient, Vector4 diffuse, Vector4 specular, Vector4 reflection,
     float specularFactor, bool hasAlpha, bool isModified) : this()
 {
     Tag            = ElementTag.New();
     IsValid        = true;
     IsModified     = isModified;
     Ambient        = ambient;
     Diffuse        = diffuse;
     Specular       = specular;
     Reflection     = reflection;
     SpecularFactor = specularFactor;
     HasAlpha       = hasAlpha;
 }
Exemplo n.º 18
0
 /// <summary>
 /// NOTE: the text inside image has gap need to move attachment point backford a little bit
 /// </summary>
 /// <param name="position"></param>
 /// <param name="text"></param>
 /// <param name="fontSize"></param>
 /// <param name="textColor"></param>
 /// <param name="mode"></param>
 /// <param name="point"></param>
 /// <returns></returns>
 public static BillboardTextComponent CreateUpdatable(Vector3 position, string text, double fontSize,
                                                      Vector4 textColor, BillboardSizeModes mode, BillboardAttacmentPoints point)
 {
     return(new BillboardTextComponent {
         Tag = ElementTag.New("BILLTEX_"),
         AttacmentType = point,
         Type = BillboardTypes.Updatable,
         SizeMode = mode,
         Position = position,
         FontSize = fontSize,
         Text = text,
         TextColor = textColor,
         //OffsetToAttachmentPoint = 0.05f
     });
 }
Exemplo n.º 19
0
 public void Draw(IContextState context, List <VisualPolylineObject> drawed)
 {
     if (IsLeaf())
     {
         drawed.Add(VisualPolylineObject.CreateBox(context, ElementTag.New(),
                                                   Bounds, V4Colors.Yellow));
     }
     else
     {
         var nodes = Nodes.ToArray();
         for (int i = 0; i < nodes.Length; i++)
         {
             nodes[i].Draw(context, drawed);
         }
     }
     foreach (var i in items.ToList())
     {
         drawed.Add(VisualPolylineObject.CreateBox(context, ElementTag.New("DEBUG_BOX_"),
                                                   i.Bound, V4Colors.Blue));
     }
 }
Exemplo n.º 20
0
        public static RenderableComponent AsBackground()
        => new RenderableComponent(CullMode.None, PrimitiveTopology.TriangleStrip, RenderTechniques.Background)
        {
            Tag     = ElementTag.New(),
            IsValid = true,
            DepthStencilStateDefinition = D3DDepthStencilDefinition.DepthDisabled,
            RasterizerStateDescription  = new RasterizerStateDescription2()
            {
                CullMode             = CullMode.None,
                FillMode             = FillMode.Solid,
                IsMultisampleEnabled = false,

                IsFrontCounterClockwise  = false,
                IsScissorEnabled         = false,
                IsAntialiasedLineEnabled = false,
                DepthBias            = 0,
                DepthBiasClamp       = .0f,
                SlopeScaledDepthBias = .0f
            },
            HasBlendState         = true,
            BlendStateDescription = D3DBlendStateDescriptions.BlendStateEnabled,
        };
Exemplo n.º 21
0
        public GameObject DrawArrow(string key, ArrowDetails arrowData)
        {
            var llength = 10;

            var tt = new ArrowData {
                axis       = arrowData.Axis,
                orthogonal = arrowData.Orthogonal,
                center     = arrowData.Center + arrowData.Axis * (llength - 2),
                lenght     = 2.1f,
                radius     = .8f,
                color      = arrowData.Color
            };

            var points = new[] {
                arrowData.Center, arrowData.Center + arrowData.Axis * llength,
            };

            var arrow = ArrowGameObject.Create(Context, ElementTag.New($"{key}_arrowhead"), tt);

            var line = VisualPolylineObject.Create(Context, ElementTag.New($"{key}_arrowline"),
                                                   points, arrowData.Color, true);

            return(new MultiVisualObject(new[] { arrow.Tag, line.Tag }, key));
        }
Exemplo n.º 22
0
 GeometryBoundsComponent(AxisAlignedBox bounds) : this()
 {
     Tag     = ElementTag.New();
     Bounds  = bounds;
     IsValid = true;
 }
Exemplo n.º 23
0
 BlackAndWhiteRenderComponent(bool isValid) : this()
 {
     IsValid = isValid;
     Tag     = ElementTag.New();
 }
Exemplo n.º 24
0
 CaptureTargetUnderMouseComponent(Vector2 screenPosition) : this()
 {
     ScreenPosition = screenPosition;
     Tag            = ElementTag.New();
     IsValid        = true;
 }
Exemplo n.º 25
0
 HittableComponent(uint priorityIndex) : this()
 {
     PriorityIndex = priorityIndex;
     IsValid       = true;
     Tag           = ElementTag.New();
 }
 public static FollowCameraDirectLightComponent Create()
 {
     return(new FollowCameraDirectLightComponent(ElementTag.New()));
 }
Exemplo n.º 27
0
 public GeometryPoolComponent(Guid index) : this()
 {
     Key     = index;
     Tag     = ElementTag.New();
     IsValid = true;
 }
Exemplo n.º 28
0
 public WireframeGeometryComponent(bool isValid) : this()
 {
     IsValid = isValid;
     Tag     = ElementTag.New();
 }
 FlatShadingGeometryComponent(bool isValid) : this()
 {
     Tag     = ElementTag.New();
     IsValid = isValid;
 }
Exemplo n.º 30
0
 public static ZoomToAllCompponent Create() =>
 new ZoomToAllCompponent(ElementTag.New());