public static Waffen createWaffe(int auswahl, Spieler spieler, Vector3 posi)//TODO
        {
            Controller newcon;
            RevoluteJoint revolute;
            Waffen dasobj;
            Vector3 startort = new Vector3(posi.X,posi.Y, -5f);

            if (auswahl == 1)//Kanone
            {
                Vector3 diff = new Vector3(0.095f, 0.1828f, 0);
                ModelObject Kanonenrohr = new ModelObject(startort + diff, Quaternion.Identity, new Vector3(0.1f, 0.1f, 0.1f), CollisionType.ExactMesh, " ", "Kanonenrohr", 0.001f);
                Kanonenrohr.RenderMaterial.Diffuse = new Vector4(1, 1, 1, 1);
                scene.Add(Kanonenrohr);

                ModelObject Kanonenhalterung = new ModelObject(startort, Quaternion.Identity, new Vector3(0.1f, 0.1f, 0.1f), CollisionType.ExactMesh, " ", "Kanonenhalterung", 1f);
                Kanonenhalterung.RenderMaterial.Diffuse = new Vector4(1, 1, 1, 1);
                scene.Add(Kanonenhalterung);

                newcon = new Controller(new Vector3(0, 0, 0));// Neuer Controller an der Position 0/0/0
                newcon.Add(Kanonenrohr);
                newcon.Add(Kanonenhalterung);

                revolute = new RevoluteJoint(Kanonenhalterung.Physics, Kanonenrohr.Physics, Kanonenhalterung.Position + new Vector3(0, 1, 0), Vector3.Backward);
                /*revolute.Limit.IsActive = true;
                revolute.Limit.MinimumAngle = -MathHelper.Pi;
                revolute.Limit.MaximumAngle = 0;*/
                scene.Physics.Add(revolute);

                revolute.Motor.IsActive = true;
                revolute.Motor.Settings.Mode = BEPUphysics.Constraints.TwoEntity.Motors.MotorMode.Servomechanism;
                revolute.Motor.Settings.Servo.Goal = -MathHelper.Pi / 4;
            }
            else //TEMPORÄR
            {
                BoxObject Box = new BoxObject(startort, new Vector3(0.4f, 0.25f, 0.3f), 0.001f);
                scene.Add(Box);//Standbox

                BoxObject Lat = new BoxObject(startort + new Vector3(0 , 0.35f , 0), new Vector3(0.35f, 0.1f, 0.1f), 0.00001f);
                scene.Add(Lat);//KanonenRohr

                newcon = new Controller(startort);
                newcon.Add(Box);
                newcon.Add(Lat);
                scene.Add(newcon);

                revolute = new RevoluteJoint(Box.Physics, Lat.Physics, Box.Position + new Vector3(0, 0.32f, 0), Vector3.Backward);
                /*revolute.Limit.IsActive = true;
                revolute.Limit.MinimumAngle = -MathHelper.Pi;
                revolute.Limit.MaximumAngle = 0;*/
                scene.Physics.Add(revolute);

                revolute.Motor.IsActive = true;
                revolute.Motor.Settings.Mode = BEPUphysics.Constraints.TwoEntity.Motors.MotorMode.Servomechanism;
                revolute.Motor.Settings.Servo.Goal = MathHelper.Pi / 6;
                
            }

            //TODO z-Achse sperren

            
            //scene.Add(newcon);
            dasobj = new Waffen( newcon, revolute, 1, (float)Math.PI / 4, 5f);
            spieler.setWaffen(dasobj);
            return dasobj;

        }
Ejemplo n.º 2
0
        //TODO
        public static Waffen createWaffe(int auswahl, Spieler spieler, Vector2 posi)
        {
            Waffen dasobj;
            Vector3 startort = new Vector3(posi, -5f);
            Matrix rotationKanone;
            rotationKanone= Matrix.CreateRotationY( (float) Math.PI);
            Quaternion AP;
            if (posi.X > 0) //-->Spieler 2
            {
                AP = Quaternion.CreateFromRotationMatrix(rotationKanone);
            }
            else
            {
                AP = Quaternion.Identity;
            }

            if (auswahl == 1)
            {

                ModelObject Kanone = new ModelObject(startort, AP, new Vector3(1f, 1f, 1f), CollisionType.ExactMesh, " ", "Kanone_ganz", 0.1f);
                Kanone.SubModels[0].RenderMaterial.Diffuse = new Vector4(1, 1, 1, 1);
                Kanone.SubModels[1].RenderMaterial.Diffuse = new Vector4(1, 1, 1, 1);
                Kanone.SubModels[0].RenderMaterial.Specular = new Vector4(0.1f, 0.1f, 0.1f, 1);
                Kanone.SubModels[1].RenderMaterial.Specular = new Vector4(0.1f, 0.1f, 0.1f, 1);

                Kanone.SubModels[0].Physics.Mass = 1f;
                Kanone.SubModels[1].Physics.Mass = 1f;

                Kanone.Physics.Material.Bounciness = 0;
                scene.Add(Kanone);
                //TODO Kosten?

                dasobj = new Waffen(Kanone, 1, (float)Math.PI / 4, 5f,"Kanone");
                spieler.setWaffen(dasobj);
                return dasobj;
            }
            if (auswahl == 2||auswahl==3)
            {

                ModelObject Balliste = new ModelObject(startort, AP, new Vector3(1f, 1f, 1f), CollisionType.ConvexHull, " ", "Balliste", 0.1f);
                Balliste.SubModels[0].RenderMaterial.Diffuse = new Vector4(1, 1, 1, 1);
                Balliste.SubModels[1].RenderMaterial.Diffuse = new Vector4(1, 1, 1, 1);
                Balliste.SubModels[0].RenderMaterial.Specular = new Vector4(0.1f, 0.1f, 0.1f, 1);
                Balliste.SubModels[1].RenderMaterial.Specular = new Vector4(0.1f, 0.1f, 0.1f, 1);

                Balliste.SubModels[0].Physics.Mass = 1f;
                Balliste.SubModels[1].Physics.Mass = 1f;

                Balliste.Physics.Material.Bounciness = 0;
                scene.Add(Balliste);

                //TODO Kosten?

                dasobj = new Waffen(Balliste, 1, (float)Math.PI / 4, 5f,"Balliste");
                spieler.setWaffen(dasobj);
                return dasobj;
            }
            if (auswahl == 4)
            {

                ModelObject Rakete = new ModelObject(startort, AP, new Vector3(1f, 1f, 1f), CollisionType.ConvexHull, " ", "Rakete", 0.1f);
                Rakete.SubModels[0].RenderMaterial.Diffuse = new Vector4(1, 1, 1, 1);

                Rakete.SubModels[0].RenderMaterial.Specular = new Vector4(0.1f, 0.1f, 0.1f, 1);

                Rakete.SubModels[0].Physics.Mass = 1f;

                Rakete.Physics.Material.Bounciness = 0;
                scene.Add(Rakete);

                //TODO Kosten?

                dasobj = new Waffen(Rakete, 1, (float)Math.PI / 4, 5f, "Rakete");
                spieler.setWaffen(dasobj);
                return dasobj;
            }
            else
            {
                ModelObject König = new ModelObject(startort, AP, new Vector3(1f, 1f, 1f), CollisionType.BoundingSphere, " ", "König_Subdivision", 0.1f);
                König.SubModels[0].RenderMaterial.Diffuse = new Vector4(1, 1, 1, 1);
                König.SubModels[0].RenderMaterial.Specular = new Vector4(0.1f, 0.1f, 0.1f, 1);

                König.SubModels[0].Physics.Mass = 0.001f;
                König.SubModels[1].Physics.Mass = 0.001f;

                scene.Add(König);
                dasobj = new Waffen(König, 1, (float)Math.PI / 4, 5f,"König");
                spieler.setWaffen(dasobj);
                return dasobj;
            }
        }