public Base3DDeferredSkinnedInstance(Game game, Vector3 position, Vector3 scale, Quaternion rotation, ref Base3DDeferredSkinnedObjectInstancer instancer) : base(game) { Position = position; Scale = scale; Rotation = rotation; Instancer = instancer; Instancer.instanceTransformMatrices.Add(this, new InstanceVertex() { TransformMatrix = World, Extras = MyExtras }); Instancer.Instances.Add(Instancer.Instances.Count, this); this.Update(null); }
public Game1() : base() { graphics.PreferredBackBufferHeight = 600; graphics.PreferredBackBufferWidth = 800; camera = new Base3DCamera(this, .1f, 20000); floor = new BaseDeferredObject(this, "Models/plane"); floor.TextureMaterials.Add("Textures/FloorColor"); floor.NormalMaterials.Add("Textures/FloorNormal"); floor.Position = new Vector3(0, -1f, -10); Components.Add(floor); skinnedInstancer = new Base3DDeferredSkinnedObjectInstancer(this, "Models/dude"); skinnedInstancer.AnimationClip = "Take 001"; Components.Add(skinnedInstancer); skinnedInstancerOffset = new Base3DDeferredSkinnedObjectInstancer(this, "Models/dude"); skinnedInstancerOffset.AnimationOffSet = new TimeSpan(0, 0, 0, 0, 500); skinnedInstancerOffset.AnimationClip = "Take 001"; Components.Add(skinnedInstancerOffset); for (int d = 0; d < 10; d++) { float x = MathHelper.Lerp(-sqr, sqr, (float)rnd.NextDouble()); float y = -1; float z = MathHelper.Lerp(-sqr , sqr /2, (float)rnd.NextDouble()); if(((d+1) % 2) == 0) // Split them in two. dudes.Add(dudes.Count, new Base3DDeferredSkinnedInstance(this, new Vector3(x, y, z - 5), Vector3.One * .05f, Quaternion.CreateFromAxisAngle(Vector3.Up, MathHelper.PiOver2), new Vector4((float)rnd.NextDouble(), (float)rnd.NextDouble(), (float)rnd.NextDouble(), 1), ref skinnedInstancer)); else dudes.Add(dudes.Count, new Base3DDeferredSkinnedInstance(this, new Vector3(x, y, z - 5), Vector3.One * .05f, Quaternion.CreateFromAxisAngle(Vector3.Up, MathHelper.PiOver2), Color.White.ToVector4(), ref skinnedInstancerOffset)); } SunPosition = new Vector3(110, 110, 200); renderer.DirectionalLights.Add(new DeferredDirectionalLight(this, SunPosition, Vector3.Zero, Color.White, 1, true)); }
public Base3DDeferredSkinnedInstance(Game game, Vector3 position, Vector3 scale, Quaternion rotation, Vector4 extras, ref Base3DDeferredSkinnedObjectInstancer instancer) : this(game, position, scale, rotation, ref instancer) { MyExtras = extras; }