示例#1
0
        public IList <SequenceData> OutputSequence(IList <MotionObjectInfo> selected, IList <ProcParam <MotionProcEnv> > args, IEnumerable <ReadOnlyMotionFrame> frames, ProgressInformation progressInfo)
        {
            List <SequenceData> ret = new List <SequenceData>();

            foreach (MotionObjectInfo info in selected)
            {
                TimeSeriesValues values = new TimeSeriesValues("radius");
                foreach (var frame in frames)
                {
                    CylinderObject cylinder = frame[info] as CylinderObject;
                    if (cylinder != null)
                    {
                        try {
                            values[frame.Time] = new decimal?[] { (decimal)cylinder.Radius };
                        } catch (ArithmeticException) {
                            values[frame.Time] = null;
                        }
                    }
                    else
                    {
                        values[frame.Time] = null;
                    }
                }
                SequenceData data = new SequenceData(values, null, PathEx.GiveName("Radius", info.Name));
                ret.Add(data);
            }
            return(ret);
        }
        public IList <MotionObject> EditObject(IList <MotionObjectInfo> targetInfoList, IList <ProcParam <MotionProcEnv> > args, ReadOnlyMotionFrame frame, bool previewMode)
        {
            SingleSelectParameter modeRad   = args[0] as SingleSelectParameter;
            NumberParameter       valueRad  = args[1] as NumberParameter;
            SingleSelectParameter modeAxis  = args[2] as SingleSelectParameter;
            NumberParameter       valueAxis = args[3] as NumberParameter;
            List <MotionObject>   ret       = new List <MotionObject>();

            foreach (MotionObjectInfo info in targetInfoList)
            {
                CylinderObject cylinder = frame[info] as CylinderObject;
                if (cylinder != null)
                {
                    float radius = cylinder.Radius;
                    float axis   = cylinder.AxisLength();
                    try {
                        switch (modeRad.Value)
                        {
                        case 0:
                            radius *= (float)valueRad.Value;
                            break;

                        case 1:
                            radius = (float)valueRad.Value;
                            break;

                        case 2:
                            radius += (float)valueRad.Value;
                            break;
                        }
                    } catch (ArithmeticException) { }
                    try {
                        switch (modeAxis.Value)
                        {
                        case 0:
                            axis *= (float)valueAxis.Value;
                            break;

                        case 1:
                            axis = (float)valueAxis.Value;
                            break;

                        case 2:
                            axis += (float)valueAxis.Value;
                            break;
                        }
                    } catch (ArithmeticException) { }
                    ret.Add(new CylinderObject(cylinder.Position, cylinder.AxisDirection() * axis, radius));
                }
                else
                {
                    ret.Add(null);
                }
            }
            return(ret);
        }
示例#3
0
        private void CreateScene6()
        {
            for (var i = 0; i < 10; i += 2)
            {
                var boxObj0 = new BoxObject(this, boxModel, new Vector3(1, 1f, 3), Matrix.Identity, new Vector3(0, i * 1f - 14, 1));
                var boxObj1 = new BoxObject(this, boxModel, new Vector3(1, 1f, 3), Matrix.Identity, new Vector3(1, i * 1f - 14, 1));
                var boxObj2 = new BoxObject(this, boxModel, new Vector3(1, 1f, 3), Matrix.Identity, new Vector3(2, i * 1f - 14, 1));
                Components.Add(boxObj0);
                Components.Add(boxObj1);
                Components.Add(boxObj2);

                var boxObj3 = new BoxObject(this, boxModel, new Vector3(3, 1f, 1), Matrix.Identity, new Vector3(1, i * 1f + 1f - 14, 0));
                var boxObj4 = new BoxObject(this, boxModel, new Vector3(3, 1f, 1), Matrix.Identity, new Vector3(1, i * 1f + 1f - 14, 1));
                var boxObj5 = new BoxObject(this, boxModel, new Vector3(3, 1f, 1), Matrix.Identity, new Vector3(1, i * 1f + 1f - 14, 2));
                Components.Add(boxObj3);
                Components.Add(boxObj4);
                Components.Add(boxObj5);
            }

            for (var i = 0; i < 10; i++)
            {
                var cyl = new CylinderObject(this, 0.5f, 1.0f, new Vector3(5, i * 1.01f - 14.2f, 0), cylinderModel);
                Components.Add(cyl);
            }

            RagdollObject rgd;


            for (var e = 0; e < 2; e++)
            {
                for (var i = 0; i < 2; i++)
                {
                    rgd          = new RagdollObject(this, capsuleModel, sphereModel, boxModel, RagdollObject.RagdollType.Simple, 1.0f);
                    rgd.Position = new Vector3(e * 2, -14, 10 + i * 2);
                    rgd.PutToSleep();
                }
            }


            for (var x = 0; x < 8; x++)
            {
                for (var y = 0; y < 3; y++)
                {
                    if (y % 2 == 0)
                    {
                        Components.Add(new BoxObject(this, boxModel, new Vector3(1, 1, 1), Matrix.Identity, new Vector3(x * 1.01f - 10.0f, y * 1.01f - 14.5f, 0)));
                    }
                    else
                    {
                        Components.Add(new BoxObject(this, boxModel, new Vector3(1, 1, 1), Matrix.Identity, new Vector3(x * 1.01f - 10.5f, y * 1.01f - 14.5f, 0)));
                    }
                }
            }
        }
示例#4
0
 private void SpawnPrefab(CylinderObject prefab)
 {
     if (lastSpawned == null)
     {
         var newCylinder = Instantiate(prefab, transform.position, transform.rotation);
         lastSpawned = newCylinder;
     }
     else
     {
         var newCylinder = Instantiate(prefab, lastSpawned.EndPoint.position, lastSpawned.EndPoint.rotation);
         lastSpawned = newCylinder;
     }
 }
        public static IObject[] CreateOBJ(IWorld world, GraphicFactory factory, GraphicInfo ginfo, ObjectInformation[] mi)
        {
            IModelo model = new CustomModel(factory, mi);

            MaterialDescription material;

            if (mi[0].staticfriction == -1 || mi[0].dinamicfriction == -1 || mi[0].ellasticity == -1)
            {
                material = MaterialDescription.DefaultBepuMaterial();
            }
            else
            {
                material = new MaterialDescription(mi[0].staticfriction, mi[0].dinamicfriction, mi[0].ellasticity);
            }

            IPhysicObject po;

            bool massflag = false;

            if (mi[0].mass == 0)
            {
                massflag   = true;
                mi[0].mass = 0.5f;
            }

            BatchInformation binf = model.GetBatchInformation(0)[0];

            BoundingBox bb;

            switch (mi[0].collisionType)
            {
            case "Ghost":


                po = new GhostObject(mi[0].position, Matrix.CreateFromQuaternion(mi[0].rotation), mi[0].scale);

                break;

            case "Cylinder":

                binf.ModelLocalTransformation = Matrix.Identity;
                bb = ModelBuilderHelper.CreateBoundingBoxFromModel(binf);
                Vector3 len = bb.Max - bb.Min;

                po = new CylinderObject(mi[0].position, len.Y, len.X / 2, Vector3.Up, mi[0].mass, Matrix.CreateFromQuaternion(mi[0].rotation), material);

                break;


            case "Sphere":
                binf.ModelLocalTransformation = Matrix.Identity;
                po          = new SphereObject(mi[0].position, model.GetModelRadius(), mi[0].mass, mi[0].scale.X, material);
                po.Rotation = Matrix.CreateFromQuaternion(mi[0].rotation);

                break;


            case "Box":

                bb = ModelBuilderHelper.CreateBoundingBoxFromModel(binf);

                len = bb.Max - bb.Min;

                po = new BoxObject(mi[0].position, len.X, len.Y, len.Z, mi[0].mass, mi[0].scale, Matrix.CreateFromQuaternion(mi[0].rotation), material);

                break;

            case "Water":
                po = new GhostObject(mi[0].position, Matrix.CreateFromQuaternion(mi[0].rotation), mi[0].scale);
                break;

            case "TriangleMesh":
            default:
                po = new TriangleMeshObject(model, Vector3.Zero, Matrix.Identity, new Vector3(1), material);
                break;
            }

            po.isMotionLess = massflag;

            IShader shader = null;

#if !REACH && !WINDOWS_PHONE
            if (mi[0].HasTexture(TextureType.ENVIRONMENT))
            {
                shader = new DeferredEMReflectiveShader();
                (shader as DeferredEMReflectiveShader).TextureCube = mi[0].textureInformation.getCubeTexture(TextureType.ENVIRONMENT);
            }
            else if (mi[0].collisionType != null && mi[0].collisionType.Contains("Water"))
            {
                Vector3 position = (Vector3)(mi[0].extra["position"]);
                var     width    = (mi[0].extra["width"]);
                var     height   = (mi[0].extra["length"]);
                shader = new DeferredWaterCompleteShader((int)width, (int)height, new Plane(position.X, position.Y, position.Z, 1), 10.0f);
            }

            else
            {
                shader = new DeferredCustomShader(mi[0].HasTexture(TextureType.GLOW), mi[0].HasTexture(TextureType.BUMP), mi[0].HasTexture(TextureType.SPECULAR), mi[0].HasTexture(TextureType.PARALAX));
            }

            DeferredMaterial dm = new DeferredMaterial(shader);
#else
            shader = new ForwardXNABasicShader();
            ForwardMaterial dm = new ForwardMaterial(shader);
#endif
            IObject ob = new IObject(dm, model, po);

            ob.Name = mi[0].modelName;

            return(new IObject[] { ob });
        }