コード例 #1
0
    private void StartSmart()
    {
        Debug.Log("Start Smart Tile");
        if (!_isSmartTile)
        {
            return;
        }

        if (_geometrySmart != null)
        {
            Destroy(_geometrySmart);
        }

        GameObject loc = Resources.Load <GameObject>(ReturnSmartTileRoot());

        Debug.Log("Smart loc: " + loc);

        _geometrySmart      = (GameObject)Instantiate(loc);
        _geometrySmart.name = H.Geometry.ToString() + "Smart " + loc;

        _geometrySmart.transform.SetParent(gameObject.transform);
        _geometrySmart.transform.localPosition = new Vector3();

        PlaneGeometry.SetActive(false);
        ScaleSmart();

        //seting an area cost
        //var child = _geometrySmart.transform.GetChild(0);
        //child.gameObject.AddComponent<NavMeshSourceTag>();
        //GameObjectUtility.SetNavMeshArea(child.gameObject, 3);
    }
コード例 #2
0
        private void GenerateGrounds()
        {
            bool enableSkybox = _level.SkyboxType != SkyboxType.None;

            if (!enableSkybox)
            {
                PlaneGeometry planG = new PlaneGeometry(new Vector3(_level.Width * _level.BlockSizes.Width, 0, _level.Depth * _level.BlockSizes.Depth));
                planG.InvertFaces   = true;
                planG.TextureRepeat = new Vector2(24);

                YnMeshGeometry top = new YnMeshGeometry(planG, new BasicMaterial(_level.TopTexture));
                top.LoadContent();
                top.Position = new Vector3((_level.Width * _level.BlockSizes.Width), _level.BlockSizes.Height * 2, (_level.Depth * _level.BlockSizes.Depth));
                Add(top);
            }

            PlaneGeometry planG2 = new PlaneGeometry(new Vector3(_level.Width * _level.BlockSizes.Width, 0, _level.Depth * _level.BlockSizes.Depth));

            planG2.TextureRepeat = new Vector2(24);

            YnMeshGeometry ground = new YnMeshGeometry(planG2, _level.GroundTexture);

            ground.LoadContent();
            ground.Position = new Vector3((_level.Width * _level.BlockSizes.Width), 0, (_level.Depth * _level.BlockSizes.Depth));
            Add(ground);
        }
コード例 #3
0
    protected void Start()
    {
        if (MyId == null)
        {
            return;
        }

        base.Start();
        PlaneGeometry.GetComponent <Renderer>().sharedMaterial = _material;

        //This is when the Plane is called from the loading fuction
        if (_scale != new Vector3() && _scale != null)
        {
            _planeGeometry.transform.SetParent(null);
            _planeGeometry.transform.position   = transform.position;
            _planeGeometry.transform.localScale = _scale; //it will work it if is initiated with a scale

            if (!_isAnInVisiblePlane)
            {
                _planeGeometry.GetComponent <Renderer>().enabled = true;
            }

            _planeGeometry.transform.SetParent(transform);
            InitializeMatColors();
        }
        DetermineTileImAndSmartStart();
    }
コード例 #4
0
ファイル: BigBoxPrev.cs プロジェクト: naaturaz/SM
    /// <summary>
    /// Check what is current color if is initial color or red and with condition will
    /// switch current game obj color
    /// </summary>
    /// <param name="condition">condition true = initial_color, condition false = red</param>
    public void CheckAndSwitchColor(bool condition)
    {
        if (PlaneGeometry.GetComponent <Renderer>().material.color == InitialColor && !condition)
        {
            PlaneGeometry.GetComponent <Renderer>().material.color = Color.red;
        }
        else if (PlaneGeometry.GetComponent <Renderer>().material.color == Color.red && condition)
        {
            PlaneGeometry.GetComponent <Renderer>().material.color = InitialColor;
        }

        if (BuildingPot.Control == null)
        {
            return;
        }
        if (BuildingPot.Control.CurrentSpawnBuild == null)
        {
            return;
        }
        if (BuildingPot.Control.CurrentSpawnBuild.Projector == null)
        {
            return;
        }
        BuildingPot.Control.CurrentSpawnBuild.Projector.SwitchColorLight(condition);
    }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="control"></param>
        public override void Load(Control control)
        {
            base.Load(control);

            camera = new Camera();
            this.camera.Position.Z = 1;

            scene = new Scene();

            var geometry = new PlaneGeometry(2, 2);

            uniforms = new Uniforms
            {
                { "time", new Uniform()
                  {
                      { "type", "f" }, { "value", 1.0f }
                  } },
                { "resolution", new Uniform()
                  {
                      { "type", "v2" }, { "value", new Vector2() }
                  } }
            };

            var material = new ShaderMaterial(null)
            {
                Uniforms       = uniforms,
                VertexShader   = VertexShader,
                FragmentShader = FragmentShader,
            };

            mesh = new Mesh(geometry, material);
            scene.Add(mesh);
        }
コード例 #6
0
        public override void LoadContent()
        {
            _width  = _width <= 0 ? 1 : _width;
            _height = _height <= 0 ? 1 : _height;


            _position.Y = 1;
            _geometry   = new PlaneGeometry(new Vector3(_width, 1, _height));
            base.LoadContent();
        }
コード例 #7
0
ファイル: YnBillboard.cs プロジェクト: shaoleibo/YnaEngine
        public override void LoadContent()
        {
            _width = _width <= 0 ? 1 : _width;
            _height = _height <= 0 ? 1 : _height;


            _position.Y = 1;
            _geometry = new PlaneGeometry(new Vector3(_width, 1, _height));
            base.LoadContent();
        }
コード例 #8
0
            public BoxGeometry(float3 lowerBound, float3 upperBound)
            {
                this.lowerBound = lowerBound;
                this.upperBound = upperBound;
                float3 X = float3(1, 0, 0), Y = float3(0, 1, 0), Z = float3(0, 0, 1);

                XYlow = new PlaneGeometry(lowerBound, Z);
                XYup  = new PlaneGeometry(upperBound, Z);
                XZlow = new PlaneGeometry(lowerBound, Y);
                XZup  = new PlaneGeometry(upperBound, Y);
                YZlow = new PlaneGeometry(lowerBound, X);
                YZup  = new PlaneGeometry(upperBound, X);
            }
コード例 #9
0
        private void CreateGroundPlane()
        {
            var groundPlaneMaterial = this.Scene.Physics.CreateMaterial(0.1f, 0.1f, 0.1f);

            var groundPlane = this.Scene.Physics.CreateRigidStatic();

            groundPlane.GlobalPose = Matrix.RotationAxis(new Vector3(0, 0, 1), (float)System.Math.PI * 0.5f).AsPhysX();

            var planeGeom = new PlaneGeometry();

            groundPlane.CreateShape(planeGeom, groundPlaneMaterial);

            this.Scene.AddActor(groundPlane);
        }
コード例 #10
0
ファイル: Engine.cs プロジェクト: zhu1987/PhysX.Net
        private void CreateGroundPlane()
        {
            var groundPlaneMaterial = this.Scene.Physics.CreateMaterial(0.1f, 0.1f, 0.1f);

            var groundPlane = this.Scene.Physics.CreateRigidStatic();

            groundPlane.Name       = "Ground Plane";
            groundPlane.GlobalPose = Matrix4x4.CreateFromAxisAngle(new System.Numerics.Vector3(0, 0, 1), (float)System.Math.PI / 2);

            var planeGeom = new PlaneGeometry();

            RigidActorExt.CreateExclusiveShape(groundPlane, planeGeom, groundPlaneMaterial, null);

            this.Scene.AddActor(groundPlane);
        }
コード例 #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="control"></param>
        public override void Load(Control control)
        {
            base.Load(control);

            camera          = new PerspectiveCamera(60, control.Width / (float)control.Height, 1, 1000);
            camera.Position = new Vector3(0, 75, 100);

            scene = new Scene();

            var geometry = new PlaneGeometry(100, 100);

            var texture = new Texture(generateTexture());

            texture.NeedsUpdate = true;

            for (var i = 0; i < 15; i++)
            {
                var material = new MeshBasicMaterial()
                {
                    Color       = new HSLColor(0.3f, 0.75f, (i / 15.0f) * 0.4f + 0.1f),
                    Map         = texture,
                    DepthTest   = false,
                    DepthWrite  = false,
                    Transparent = true
                };

                mesh = new Mesh(geometry, material);

                mesh.Position.Y = i * 0.25f;
                mesh.Rotation.X = -(float)Math.PI / 2;

                scene.Add(mesh);
            }

            scene.Children.Reverse();

            renderer.SortObjects = false;
            renderer.SetClearColor((Color)colorConvertor.ConvertFromString("#003300"));
        }
コード例 #12
0
ファイル: Engine.cs プロジェクト: flair2005/PhysX.Net
		private void CreateGroundPlane()
		{
			var groundPlaneMaterial = this.Scene.Physics.CreateMaterial(0.1f, 0.1f, 0.1f);

			var groundPlane = this.Scene.Physics.CreateRigidStatic();
			groundPlane.Name = "Ground Plane";
			groundPlane.GlobalPose = Matrix4x4.CreateFromAxisAngle(new System.Numerics.Vector3(0, 0, 1), (float)System.Math.PI / 2);

			var planeGeom = new PlaneGeometry();

			groundPlane.CreateShape(planeGeom, groundPlaneMaterial);

			this.Scene.AddActor(groundPlane);
		}
コード例 #13
0
 // Use this for initialization
 void Start()
 {
     planeGeo        = new PlaneGeometry(10, 10, 3, 3);
     meshFilter.mesh = planeGeo.CreateAndGetMesh();
 }
コード例 #14
0
ファイル: Engine.cs プロジェクト: kpko/PhysX.Net
		private void CreateGroundPlane()
		{
			var groundPlaneMaterial = this.Scene.Physics.CreateMaterial(0.1f, 0.1f, 0.1f);

			var groundPlane = this.Scene.Physics.CreateRigidStatic();
			groundPlane.GlobalPose = Matrix.RotationAxis(new Vector3(0, 0, 1), (float)System.Math.PI * 0.5f).AsPhysX();

			var planeGeom = new PlaneGeometry();

			groundPlane.CreateShape(planeGeom, groundPlaneMaterial);

			this.Scene.AddActor(groundPlane);
		}
コード例 #15
0
ファイル: PhysXTest.cs プロジェクト: TopXiong/GameServer
        public void Awake()
        {
            Console.WriteLine("StartGame");
            //初始化物理
            ErrorOutput errorOutput = new ErrorOutput();
            Foundation  foundation  = new Foundation(errorOutput);

            //var pvd = new PhysX.VisualDebugger.ConnectionManager
            Physics = new Physics(foundation);
            var sceneDesc = new SceneDesc
            {
                Gravity      = new System.Numerics.Vector3(0, -9.81f, 0),
                FilterShader = new SampleFilterShader()
            };

            Scene = Physics.CreateScene(sceneDesc);

            this.Scene.SetVisualizationParameter(VisualizationParameter.Scale, 2.0f);
            this.Scene.SetVisualizationParameter(VisualizationParameter.CollisionShapes, true);
            this.Scene.SetVisualizationParameter(VisualizationParameter.JointLocalFrames, true);
            this.Scene.SetVisualizationParameter(VisualizationParameter.JointLimits, true);
            this.Scene.SetVisualizationParameter(VisualizationParameter.ActorAxes, true);

            Physics.PvdConnectionManager.Connect("localhost", 5425);

            //创建平面
            var groundPlaneMaterial = this.Scene.Physics.CreateMaterial(0.1f, 0.1f, 0.1f);
            var groundPlane         = this.Scene.Physics.CreateRigidStatic();

            groundPlane.GlobalPose = Matrix4x4.CreateFromAxisAngle(new System.Numerics.Vector3(0, 0, 1), (float)System.Math.PI / 2);
            groundPlane.Name       = "Ground Plane";
            var planeGeom = new PlaneGeometry();

            groundPlane.CreateShape(planeGeom, groundPlaneMaterial);
            this.Scene.AddActor(groundPlane);

            //创建角色
            var material          = Scene.Physics.CreateMaterial(0.1f, 0.1f, 0.1f);
            var controllerManager = Scene.CreateControllerManager();
            {
                var desc = new CapsuleControllerDesc()
                {
                    Height         = 4,
                    Radius         = 1,
                    Material       = material,
                    UpDirection    = new Vector3(0, 1, 0),
                    Position       = new Vector3(0, 3, 0),
                    ReportCallback = new ControllerHitReport()
                };

                _controller = controllerManager.CreateController <CapsuleController>(desc);
            }
            //再来一个不动的
            {
                var desc = new CapsuleControllerDesc()
                {
                    Height      = 4,
                    Radius      = 1,
                    Material    = material,
                    UpDirection = new Vector3(0, 1, 0),
                    Position    = new Vector3(15, 3, 15)
                };

                controllerManager.CreateController <CapsuleController>(desc);
            }
        }
コード例 #16
0
ファイル: ProgramRTT.cs プロジェクト: vijirams/three.net
        private static void Init()
        {
            camera = new PerspectiveCamera(renderer, 30, 1, 10000)
            {
                Position = new Vector3(0, 0, 100)
            };

            cameraRTT = new OrthographicCamera(renderer, -10000, 10000)
            {
                Position = new Vector3(0, 0, 100)
            };

            scene       = new Scene();
            sceneRTT    = new Scene();
            sceneScreen = new Scene();

            var light = new DirectionalLight(Color.White)
            {
                Position = Vector3.UnitZ.Normalized()
            };

            sceneRTT.Add(light);

            light = new DirectionalLight(new Color(0xffaaaa))
            {
                Position  = Vector3.UnitNegativeZ.Normalized(),
                Intensity = 1.5f
            };
            sceneRTT.Add(light);

            rtTexture = new RenderTarget(renderer.Width, renderer.Height)
            {
                MinFilter = TextureMinFilter.Linear,
                MagFilter = TextureMagFilter.Nearest,
                Format    = Three.Net.Renderers.PixelFormat.RGB
            };

            var vertexShaderSource = @"
varying vec2 vUv;
void main() 
{
	vUv = uv;
	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}";

            var fragment_shader_screenSource = @"
varying vec2 vUv;
uniform sampler2D tDiffuse;
void main() 
{
	gl_FragColor = texture2D( tDiffuse, vUv );
}";
            var fragment_shader_pass_1Source = @"
varying vec2 vUv;
uniform float time;
void main() 
{
	float r = vUv.x;
	if( vUv.y < 0.5 ) r = 0.0;
	float g = vUv.y;
	if( vUv.x < 0.5 ) g = 0.0;

	gl_FragColor = vec4( r, g, time, 1.0 );
}";

            material = new CustomShaderMaterial(renderer, vertexShaderSource, fragment_shader_pass_1Source, m => { });

            var materialScreen = new CustomShaderMaterial(renderer, vertexShaderSource, fragment_shader_screenSource, m => {})
            {
                ShouldDepthWrite = false
            };

            var plane = new PlaneGeometry(renderer.Width, renderer.Height);
            var quad  = new Mesh(plane, material)
            {
                Position = new Vector3(0, 0, -100)
            };

            sceneRTT.Add(quad);

            var geometry = new TorusGeometry(100, 25, 15, 30);

            var mat1 = new MeshPhongMaterial(renderer)
            {
                Diffuse   = new Color(0x555555),
                Specular  = new Color(0xffaa00),
                Shininess = 5
            };
            var mat2 = new MeshPhongMaterial(renderer)
            {
                Diffuse   = new Color(0x550000),
                Specular  = new Color(0xff2200),
                Shininess = 5
            };

            zmesh1 = new Mesh(geometry, mat1)
            {
                Position = new Vector3(0, 0, 100),
                Scale    = new Vector3(1.5f, 1.5f, 1.5f)
            };
            sceneRTT.Add(zmesh1);

            zmesh2 = new Mesh(geometry, mat2)
            {
                Position = new Vector3(0, 150, 100),
                Scale    = new Vector3(0.75f, 0.75f, 0.75f)
            };
            sceneRTT.Add(zmesh2);

            quad = new Mesh(plane, materialScreen)
            {
                Position = new Vector3(0, 0, -100)
            };
            sceneScreen.Add(quad);

            var n = 5;
            var sphereGeometry = new SphereGeometry(10, 64, 32);
            var material2      = new MeshBasicMaterial(renderer)
            {
                Diffuse    = Color.White,
                DiffuseMap = rtTexture
            };

            for (var j = 0; j < n; j++)
            {
                for (var i = 0; i < n; i++)
                {
                    var mesh = new Mesh(sphereGeometry, material2)
                    {
                        Position = new Vector3(
                            (i - (n - 1) / 2) * 20,
                            (j - (n - 1) / 2) * 20,
                            0),
                        Rotation = new Euler(0, -Mathf.Pi / 2, 0)
                    };
                    scene.Add(mesh);
                }
            }

            renderer.ShouldAutoClear = false;
        }
コード例 #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="control"></param>
        public override void Load(Control control)
        {
            base.Load(control);

            camera            = new PerspectiveCamera(35, control.Width / (float)control.Height, 1, 25000);
            camera.Position.Z = 1500;

            scene1 = new Scene();
            scene2 = new Scene();

            scene1.Fog = new Fog((Color)colorConvertor.ConvertFromString("#f2f7ff"), 1, 25000);
            scene2.Fog = scene1.Fog;

            scene1.Add(new AmbientLight((Color)colorConvertor.ConvertFromString("#eef0ff")));
            scene2.Add(new AmbientLight((Color)colorConvertor.ConvertFromString("#eef0ff")));

            var light1 = new DirectionalLight(Color.White, 2);

            light1.Position = new Vector3(1, 1, 1);
            scene1.Add(light1);

            var light2 = new DirectionalLight(Color.White, 2);

            light2.Position = new Vector3(1, 1, 1);
            scene2.Add(light2);

            // GROUND

            var maxAnisotropy = renderer.MaxAnisotropy;

            var texture1  = ImageUtils.LoadTexture("examples/textures/crate.gif");
            var material1 = new MeshPhongMaterial()
            {
                Color = Color.White, Map = texture1
            };

            texture1.Anisotropy = maxAnisotropy;
            texture1.WrapS      = texture1.WrapT = ThreeCs.Three.RepeatWrapping;
            texture1.Repeat     = new Vector2(512, 512);

            var texture2  = ImageUtils.LoadTexture("examples/textures/crate.gif");
            var material2 = new MeshPhongMaterial()
            {
                Color = Color.White, Map = texture2
            };

            texture2.Anisotropy = 1;
            texture2.WrapS      = texture2.WrapT = ThreeCs.Three.RepeatWrapping;
            texture2.Repeat     = new Vector2(512, 512);

            //if (maxAnisotropy > 0)
            //{
            //    document.getElementById("val_left").innerHTML = texture1.anisotropy;
            //    document.getElementById("val_right").innerHTML = texture2.anisotropy;
            //}
            //else
            //{
            //    document.getElementById("val_left").innerHTML = "not supported";
            //    document.getElementById("val_right").innerHTML = "not supported";
            //}

            //

            var geometry = new PlaneGeometry(100, 100);

            var mesh1 = new Mesh(geometry, material1);

            mesh1.Rotation.X = (float)-Math.PI / 2;
            mesh1.Scale      = new Vector3(1000, 1000, 1000);

            var mesh2 = new Mesh(geometry, material2);

            mesh2.Rotation.X = (float)-Math.PI / 2;
            mesh2.Scale      = new Vector3(1000, 1000, 1000);

            scene1.Add(mesh1);
            scene2.Add(mesh2);

            // RENDERER

            renderer.SetClearColor(scene1.Fog.Color, 1);
            renderer.AutoClear = false;
        }
コード例 #18
0
        /// <summary>
        /// Constructor
        /// </summary>
        public void init()
        {
            this.handles = new Object3D();
            this.pickers = new Object3D();
            this.planes  = new Object3D();

            this.Add(this.handles);
            this.Add(this.pickers);
            this.Add(this.planes);

            //// PLANES

            var planeGeometry = new PlaneGeometry(50, 50, 2, 2);
            var planeMaterial = new MeshBasicMaterial {
                Wireframe = true
            };

            planeMaterial.Side = ThreeCs.Three.DoubleSide;

            var planes = new Hashtable();

            planes["XY"]   = new Mesh(planeGeometry, planeMaterial);
            planes["YZ"]   = new Mesh(planeGeometry, planeMaterial);
            planes["XZ"]   = new Mesh(planeGeometry, planeMaterial);
            planes["XYZE"] = new Mesh(planeGeometry, planeMaterial);

            this.activePlane = (Mesh)planes["XYZE"];

            ((Object3D)planes["YZ"]).Rotation.set(0, (float)Math.PI / 2, 0);
            ((Object3D)planes["XZ"]).Rotation.set((float)-Math.PI / 2, 0, 0);

            foreach (DictionaryEntry i in planes)
            {
                ((Mesh)planes[i.Key]).Name = (string)i.Key;
                this.planes.Add((Object3D)planes[i.Key]);
                this.planes[i.Key] = planes[i.Key];
                ((Object3D)planes[i.Key]).Visible = false;
            }

            //// HANDLES AND PICKERS

            setupGizmos(this.handleGizmos, this.handles);
            setupGizmos(this.pickerGizmos, this.pickers);

            // reset Transformations

            this.Traverse(child => {
                if (child is Mesh)
                {
                    child.UpdateMatrix();

                    var tempGeometry = new Geometry();
                    tempGeometry.Merge((Geometry)child.Geometry, child.Matrix);

                    child.Geometry = tempGeometry;
                    child.Position.set(0, 0, 0);
                    child.Rotation.set(0, 0, 0);
                    child.Scale.set(1, 1, 1);
                }
            });
        }