コード例 #1
0
            internal Model(GraphicsDevice device, ContentManager content, string name, Camera camera)
            {
                mDevice             = device;
                mModel              = content.Load <Microsoft.Xna.Framework.Graphics.Model>(name);
                mCamera             = camera;
                mBoundingBoxManager = new BoundingBoxManager(device, camera);
                mBoundingBox        = BoundingBoxManager.CreateBoundingBox(mModel, new Vector2());

                foreach (var mesh in mModel.Meshes)
                {
                    foreach (var meshPart in mesh.MeshParts)
                    {
                        var effect = content.Load <Effect>("effects/InstancedModel").Clone();

                        effect.Parameters["LightDirection"].SetValue(new Vector3(0, -1, -1));
                        effect.Parameters["DiffuseLight"].SetValue(Vector3.One * 1.25f);
                        effect.Parameters["AmbientLight"].SetValue(Vector3.One * 0.25f);
                        effect.Parameters["Texture"].SetValue(meshPart.Effect.Parameters["Texture"].GetValueTexture2D());
                        meshPart.Effect = effect;
                    }
                }
            }
コード例 #2
0
            public bool PickingRayHittingMeshes(Ray pickingRay, Vector2 position)
            {
                var modelMeshesBoundingBoxes = BoundingBoxManager.CreateAllBoundingBoxes(mModel, position);

                return(modelMeshesBoundingBoxes.Any(box => pickingRay.Intersects(box).HasValue));
            }