Example #1
0
        public override void DrawBox(ElementTag tag, BoundingBox box, IEntityManager emanager)
        {
            var points = GeometryBuilder.BuildBox(box);
            var color  = V4Colors.NextColor(random);

            if (tag.IsEmpty)
            {
                Thread.Sleep(10);
                tag = new ElementTag(DateTime.Now.Ticks.ToString());
            }
            debug.Add(PolylineGameObject.Create(emanager, new ElementTag("OctreeBox_" + tag.ToString()), points, points.Select(x => color).ToArray()));
        }
Example #2
0
        static ElementTag Create(IContextState context, ElementTag tag, GeometryStructures gdata, FileInfo texture,
                                 out GeometryBoundsComponent boundsComponent)
        {
            var manager = context.GetEntityManager();

            if (!gdata.Normals.Any())
            {
                gdata.ReCalculateNormals();
            }

            gdata.BuildTreeAsync();

            var cullmode = SharpDX.Direct3D11.CullMode.Front;
            var geo      = context.GetGeometryPool().AddGeometry(gdata);

            var en = manager.CreateEntity(tag);

            MaterialColorComponent material;
            RenderableComponent    renderable;

            if (gdata.TexCoor.Any() && texture != null)
            {
                material   = MaterialColorComponent.CreateTransparent().ApplyAlpha(1);
                renderable = RenderableComponent.AsTriangleTexturedList(cullmode);
                en.AddComponent(new D3DTexturedMaterialSamplerComponent(texture));
            }
            else
            {
                material   = MaterialColorComponent.Create(V4Colors.NextColor(random));
                renderable = RenderableComponent.AsTriangleColoredList(cullmode);
            }
            boundsComponent = GeometryBoundsComponent.Create(gdata.Positions);

            en.AddComponent(TransformComponent.Identity())
            .AddComponent(HittableComponent.Create(0))
            .AddComponent(boundsComponent)
            .AddComponent(material)
            .AddComponent(geo)
            .AddComponent(renderable);

            return(tag);
        }
Example #3
0
            public void Execute(object parameter)
            {
                Task.Run(() => {
                    var count = 1;      // 00;
                    while (count-- > 0) //64, 4, 32
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(0.5));
                        var max = RandomUtil.NextVector3(r, new Vector3(0, 0, 0), new Vector3(10, 0, 10));
                        PhysicsObjectTest.Create(main.context.GetEntityManager(),
                                                 new BoundingBox(
                                                     new Vector3(max.X - 10, 90, max.Y - 10),
                                                     new Vector3(max.X, 100, max.Z)),
                                                 V4Colors.NextColor(r));
                    }
                });
                //if (stat.IsNull()) {
                //    stat = new LoadedItem(main, PhysicsObjectTest.CreateStatic(main.context.GetEntityManager(),
                //        new BoundingBox(new Vector3(-50, -50, -50), new Vector3(50, 50, 50))));
                //    main.items.Add(stat);

                //    PhysicsObjectTest.CreateStaticAABB(main.context.GetEntityManager(),
                //        new BoundingBox(new Vector3(-150, -30, -150), new Vector3(150, -15, 150)));
                //}
            }