public override void Run(RenderControl render)
        {
            RedMaterial = MeshPhongMaterial.Create("phong.color");
            RedMaterial.SetColor(Vector3.Red);

            GrayMaterial = MeshPhongMaterial.Create("phong.color");
            GrayMaterial.SetColor(Vector3.LightGray);
            GrayMaterial.SetTransparent(true);
            GrayMaterial.SetOpacity(0.5f);

            var tube = ShapeBuilder.MakeTube(new GPnt(0, 0, 5), GP.DZ(), 10, 2, 50);

            TubeNode = BrepSceneNode.Create(tube, RedMaterial, null);

            var cylinder = ShapeBuilder.MakeCylinder(GP.XOY(), 10, 60, 0);

            CylinderNode = BrepSceneNode.Create(cylinder, GrayMaterial, null);

            render.ShowSceneNode(TubeNode);
            render.ShowSceneNode(CylinderNode);


            var cone = ShapeBuilder.MakeCone(GP.YOZ(), 5, 0, 10, 0);
            var bs   = new BufferShape(cone, RedMaterial, null, 0.1);

            bs.Build();
            ConeNode1 = new BrepSceneNode(bs);
            ConeNode2 = new BrepSceneNode(bs);

            render.ShowSceneNode(ConeNode1);
            render.ShowSceneNode(ConeNode2);
        }
Esempio n. 2
0
        private static GameObject CreateShip(VoxelTypes types, MaterialInstance materialInstance)
        {
            var gridLength     = 4;
            var voxelSize      = 1;
            var voxelSpaceData = new VoxelGridData(gridLength, gridLength, gridLength, voxelSize);

            voxelSpaceData[0, 0, 0] = new Voxel()
            {
                Exists = true
            };

            var voxelSpace = new VoxelSpace(new Vector3i(gridLength, gridLength, gridLength), voxelSize);
            var spaceShip  = new GameObject("Single Block");

            spaceShip.AddComponent(voxelSpace);
            spaceShip.AddComponent(new DynamicVoxelSpaceBody());
            spaceShip.AddComponent(new Construct());
            spaceShip.AddComponent(new ConstructFlightControl());
            spaceShip.AddComponent(new ConstructVoxelSpaceExpander(types, materialInstance));

            var voxelGridObj = new GameObject($"{spaceShip.Name} Voxel Grid");

            voxelGridObj.AddComponent(new VoxelGrid(voxelSpaceData, new Dictionary <Vector3i, GameObject>()));
            voxelGridObj.AddComponent(new VoxelMeshRenderable(types, materialInstance));
            //voxelGridObj.AddComponent(new VoxelGridRenderable(types, materialInstance));

            voxelSpace.Add(new Vector3i(0, 0, 0), voxelGridObj);

            return(spaceShip);
        }
Esempio n. 3
0
        private void ReplaceWithMaterialInstance(ModelEntryInfo modelEntryInfo)
        {
            if (modelEntryInfo == null)
            {
                return;
            }
            if (!modelEntryInfo.Material)
            {
                return;
            }

            modelEntryInfo.Material = _instance = modelEntryInfo.Material.CreateVirtualInstance();
        }
Esempio n. 4
0
        public override void OnCreate()
        {
            m_PhysicsBody = GetComponent <RigidBody2DComponent>();

            var meshComponent = GetComponent <MeshComponent>();

            m_MeshMaterial = meshComponent.Mesh.GetMaterial(0);
            m_MeshMaterial.Set("u_Metalness", 0.0f);

            m_MeshMaterial.Set("u_AlbedoColor", new Vector3(1.0f, 0.0f, 0.0f));

            AddCollision2DBeginCallback(OnPlayerCollisionBegin);
            AddCollision2DEndCallback(OnPlayerCollisionEnd);
        }
 protected PrimitiveProceduralModelBase()
 {
     MaterialInstance = new MaterialInstance();
 }
 protected PrimitiveProceduralModelBase()
 {
     MaterialInstance = new MaterialInstance();
     UvScale = Vector2.One;
 }