public FBXModel __deref__() { global::System.IntPtr cPtr = FBXImporterUnmanagedPINVOKE.FBXModelPtr___deref__(swigCPtr); FBXModel ret = (cPtr == global::System.IntPtr.Zero) ? null : new FBXModel(cPtr, false); return(ret); }
/// <summary> /// Spread flora over intersection of road. /// </summary> /// <param name="node"></param> /// <param name="first"></param> /// <param name="second"></param> /// <returns></returns> public override bool NewFan( Road.Intersection isect, Road.Section first, Road.Section second, List <Road.RenderObj> fans) { FBXModel model = EndModel; if (model != null) { RoadFBXRenderObj ro = new RoadFBXRenderObj(); ro.Model = model; ro.Animator = EndAnim; Matrix localToWorld = Matrix.Identity; Vector3 position = isect.Node.Position; position.Z = Terrain.GetTerrainHeightFlat(position) + isect.Node.Height; localToWorld.Translation = position; RandomizeAngle(ref localToWorld); ro.LocalToWorld = localToWorld; fans.Add(ro); return(true); } return(false); }
public AnimatorList(FBXModel model) { /// Note these are only setting up capacity, they're still empty. animList = new List <AnimationInstance>(model.NumLODs); restPalettes = new List <Matrix[]>(model.NumLODs); lastUpdates = new List <int>(model.NumLODs); for (int lod = 0; lod < model.NumLODs; ++lod) { AnimationInstance animator = model.MakeAnimator(lod); if (animator != null) { animList.Add(animator); lastUpdates.Add(0); Matrix[] animPalette = animList[lod].Palette; int boneCount = animPalette.Length; Matrix[] palette = new Matrix[boneCount]; for (int bone = 0; bone < boneCount; ++bone) { palette[bone] = animPalette[bone]; } restPalettes.Add(palette); } } }
protected void SetRestPalette(FBXModel model) { if (HasRestPalette) { model.RestPalettes = IdleAnimation.RestPalettes; } }
/// <summary> /// Construct self from a model and active animation name. /// </summary> /// <param name="model"></param> /// <param name="animName"></param> public ModelAnim(FBXModel model, string animName) { ActiveAnimation = new AnimatorList(model); if (ActiveAnimation.NotEmpty) { AnimationInstance sample = ActiveAnimation.Sample; ActiveController = SimpleController.TryMake(sample, animName, sample.FirstAnimationName); if (ActiveController != null) { ActiveAnimation.ApplyController(ActiveController); IdleAnimation = new AnimatorList(model); Debug.Assert(IdleAnimation.NotEmpty, "Could make active but not idle?"); sample = IdleAnimation.Sample; IdleController = SimpleController.TryMake(sample, "idle", null); if (IdleController != null) { IdleAnimation.ApplyController(IdleController); } else { IdleAnimation = null; } } else { ActiveAnimation = null; } } }
/// <summary> /// MenuItem c'tor /// </summary> /// <param name="model">Model used for rendering menu item.</param> /// <param name="desiredRadius">Used to adjust size of bot in menu.</param> /// <param name="name">User friendly name of bot.</param> /// <param name="typeName"></param> protected MenuItem(FBXModel model, float desiredRadius, string name, string typeName) { sro = model; this.desiredRadius = desiredRadius; this.name = name; this.typeName = typeName; BokuGame.Load(this); }
private void LoadAnimations(FBXModel sro) { _animator = sro.MakeAnimator(); _animOpenA = new AnimationController(null, _animator.Animations["open_A"]); _animCloseA = new AnimationController(null, _animator.Animations["close_A"]); _animOpenB = new AnimationController(null, _animator.Animations["open_B"]); _animCloseB = new AnimationController(null, _animator.Animations["close_B"]); // test: just to show that animation is loaded and working _animOpenA.SpeedFactor = 0; SetAnimation(_animOpenA); }
public void SetFlex(FBXModel model) { float flex = 0.0f; SwimChassis sc = Chassis as SwimChassis; if (sc != null) { flex = sc.BodyFlex + sc.FlexAmplitude * 0.2f * (float)Math.Cos(5.0f * Time.GameTimeTotalSeconds + flexOffset); } model.Effect.Parameters["Flex"].SetValue(flex); }
/// <summary> /// Put down a tree at the intersection. /// </summary> public override bool NewFan( Road.Intersection isect, Road.Section first, Road.Section second, List <Road.RenderObj> fans) { FBXModel model = EndModel; if (model != null) { RoadMultiRenderObj multiRo = new RoadMultiRenderObj(); Vector2 center = isect.Node.Position2d; float area = width * width * (float)Math.PI; int count = (int)Math.Ceiling(area * density); for (int i = 0; i < count; ++i) { double rndAng = BokuGame.bokuGame.rnd.NextDouble() * Math.PI * 2.0; float rndOut = (float)(BokuGame.bokuGame.rnd.NextDouble() * 2.0 - 1.0); float cos = (float)Math.Cos(rndAng); float sin = (float)Math.Sin(rndAng); Vector2 rndPos = center; rndPos.X += cos * rndOut; rndPos.Y += sin * rndOut; float height = Terrain.GetTerrainHeightFlat(rndPos); Matrix localToWorld = Matrix.CreateTranslation(rndPos.X, rndPos.Y, height); RoadFBXRenderObj ro = new RoadFBXRenderObj(); ro.Model = model; ro.Animator = EndAnim; ro.LocalToWorld = localToWorld; multiRo.RenderObjList.Add(ro); } fans.Add(multiRo); return(count > 0); } return(false); }
public SharedIdle( string classificationName, BaseChassis chassis, GetModelInstance getModelInstance, StaticActor staticActor) : base(classificationName, classificationName, chassis, getModelInstance, getModelInstance, staticActor) { if (XmlActorParams.SharedIdleData != null) { sharedAnim = new SharedAnimation(XmlActorParams.SharedIdleData.ActiveAnimationName); } else { sharedAnim = new SharedAnimation(""); } fbxSRO = getModelInstance() as FBXModel; Debug.Assert(fbxSRO != null, "Wrong model type?"); }
/// <summary> /// Load up our animations and bind to the given model. /// </summary> /// <param name="sro"></param> private void LoadAnimations(FBXModel sro) { Debug.Assert(SharedAnim != null, "Must set SharedAnim to class's shared animation in constructor."); if (SharedAnim.ActiveAnimator == null) { SharedAnim.ActiveAnimator = new AnimatorList(sro); } _animators = SharedAnim.ActiveAnimator; AnimatorList animList = SharedAnim.ActiveAnimator; AnimationInstance animator = animList.Sample; if (animator != null && animator.HasAnimation(SharedAnim.ActiveName)) { if (SharedAnim.ActiveController == null) { SharedAnim.ActiveController = SimpleController.TryMake(animator, SharedAnim.ActiveName); AnimActive(); } } else { animList.ApplyController(null); } if (SharedAnim.IdleAnimator == null) { SharedAnim.IdleAnimator = new AnimatorList(sro); AnimationInstance sharedIdle = SharedAnim.IdleAnimator.Sample; if ((sharedIdle != null) && sharedIdle.HasAnimation(SharedAnim.IdleName)) { SharedAnim.IdleController = SimpleController.TryMake( sharedIdle, SharedAnim.IdleName); } if (SharedAnim.IdleController != null) { AnimIdle(); } else { SharedAnim.IdleAnimator = null; } } }
/// <summary> /// Spread flora over new section of road. /// </summary> /// <param name="section"></param> public override void NewSection(Road.Section section) { RoadMultiRenderObj multiRo = null; FBXModel model = Model; if (model != null) { multiRo = new RoadMultiRenderObj(); Vector2 start = section.Edge.Node0.Position2d; Vector2 end = section.Edge.Node1.Position2d; Vector2 axis = end - start; Vector2 norm = new Vector2(-axis.Y, axis.X); norm = Vector2.Normalize(norm) * width; float area = axis.Length() * width * 2.0f; int count = (int)Math.Ceiling(area * density); for (int i = 0; i < count; ++i) { float rndTo = (float)BokuGame.bokuGame.rnd.NextDouble(); float rndOut = (float)(BokuGame.bokuGame.rnd.NextDouble() * 2.0 - 1.0); Vector2 rndPos = start + rndTo * axis + rndOut * norm; float height = Terrain.GetTerrainHeightFlat(rndPos); height += section.Edge.Node0.Height + rndTo * (section.Edge.Node1.Height - section.Edge.Node0.Height); Matrix localToWorld = Matrix.CreateTranslation(rndPos.X, rndPos.Y, height); RandomizeAngle(ref localToWorld); RoadFBXRenderObj ro = new RoadFBXRenderObj(); ro.Model = model; ro.LocalToWorld = localToWorld; ro.Animator = Anim; multiRo.RenderObjList.Add(ro); } } section.RenderObj = multiRo; }
/// <summary> /// Returns a new FBXModel. /// </summary> /// <remarks> /// The list of special FBXModel derivatives is kept here. /// </remarks> private static FBXModel InitializeModelFromXml(XmlGameActor xmlGameActor, string modelFileName) { FBXModel result = null; if (xmlGameActor != null && xmlGameActor.ModelData != null) { if (xmlGameActor.ModelData.SpecialType != null) { switch (xmlGameActor.ModelData.SpecialType.ToLower()) { case "bokugreetermodel": //if(BokuGame.bMarsMode) // modelFileName = "Models\\Rover"; result = new BokuGreeterModel(modelFileName); break; } } } if (result == null) { result = new FBXModel(modelFileName); } result.XmlActor = xmlGameActor; if (xmlGameActor != null && xmlGameActor.ModelData != null) { if (xmlGameActor.ModelData.TechniqueExt != null) { result.TechniqueExt = xmlGameActor.ModelData.TechniqueExt; } if (xmlGameActor.ModelData.Shininess != null) { result.Shininess = xmlGameActor.ModelData.Shininess.Value; } } return(result); }
public override void SetupForRender(FBXModel model) { Parameter(EffectParams.FaceBkg).SetValue(BackgroundColor); float pupilScaleLeft = 1.0f / (pupilSizeLeft * PupilSize); Vector2 pupilOffLeft = new Vector2( (pupilOffsetLeft.X - PupilCenter.X - 0.5f) * pupilScaleLeft + 0.5f, (pupilOffsetLeft.Y - PupilCenter.Y - 0.5f) * pupilScaleLeft + 0.5f); float pupilScaleRight = 1.0f / (pupilSizeRight * PupilSize); Vector2 pupilOffRight = new Vector2( (pupilOffsetRight.X + PupilCenter.X - 0.5f) * pupilScaleRight + 0.5f, (pupilOffsetRight.Y - PupilCenter.Y - 0.5f) * pupilScaleRight + 0.5f); Parameter(EffectParams.PupilScale).SetValue(new Vector4( pupilScaleLeft, pupilScaleLeft, pupilScaleRight, pupilScaleRight)); Parameter(EffectParams.PupilOffset).SetValue(new Vector4( pupilOffLeft.X, pupilOffLeft.Y, pupilOffRight.X, pupilOffRight.Y)); float browScaleLeft = 1.0f / BrowSize; Vector2 browOffLeft = new Vector2( (browOffsetLeft.X - BrowCenter.X - 0.5f) * browScaleLeft + 0.5f, (browOffsetLeft.Y - BrowCenter.Y - 0.5f) * browScaleLeft + 0.5f); float browScaleRight = 1.0f / BrowSize; Vector2 browOffRight = new Vector2( (browOffsetRight.X - BrowCenter.X - 0.5f) * browScaleRight + 0.5f, (browOffsetRight.Y - BrowCenter.Y - 0.5f) * browScaleRight + 0.5f); Parameter(EffectParams.BrowScale).SetValue(new Vector4( browScaleLeft, browScaleLeft, browScaleRight, browScaleRight)); Parameter(EffectParams.BrowOffset).SetValue(new Vector4( browOffLeft.X, browOffLeft.Y, browOffRight.X, browOffRight.Y)); Parameter(EffectParams.EyeShapeLeftTexture).SetValue(ShapeLeftTexture()); Parameter(EffectParams.EyePupilLeftTexture).SetValue(PupilLeftTexture()); Parameter(EffectParams.EyeBrowLeftTexture).SetValue(BrowLeftTexture()); Parameter(EffectParams.EyeShapeRightTexture).SetValue(ShapeRightTexture()); Parameter(EffectParams.EyePupilRightTexture).SetValue(PupilRightTexture()); Parameter(EffectParams.EyeBrowRightTexture).SetValue(BrowRightTexture()); }
/// <summary> /// Generate a castle as an intersection. /// </summary> /// <param name="node"></param> /// <param name="first"></param> /// <param name="second"></param> /// <returns></returns> public override bool NewFan( Road.Intersection isect, Road.Section first, Road.Section second, List <Road.RenderObj> fans) { bool didBase = base.NewFan(isect, first, second, fans); WayPoint.Node node = isect.Node; /* * centerheight * 4.4 * height * 4.3, 2.0, 2.3, 2.3, -1.0 * width * 0.05, 0.2, 0.2, 0.3, 0.3 * */ RoadFBXRenderObj ro = null; FBXModel model = ActorManager.GetActor("Castle").Model; if (model != null) { ro = new RoadFBXRenderObj(); ro.Model = model; Matrix localToWorld = Matrix.Identity; Vector3 position = node.Position; localToWorld.Translation = position; ro.LocalToWorld = localToWorld; fans.Add(ro); return(true); } return(didBase); }
public override void SetupForRender(FBXModel model) { Parameter(EffectParams.FaceBkg).SetValue(BackgroundColor); float pupilSize = PupilSize; if (emotionalState == FaceState.Dead) { pupilSize *= 2.0f; } float pupilScaleLeft = 1.0f / (pupilSizeLeft * pupilSize * Asymmetry.X); Vector2 pupilOffLeft = new Vector2( (pupilOffsetLeft.X - PupilCenter.X - 0.5f) * pupilScaleLeft + 0.5f, (pupilOffsetLeft.Y - PupilCenter.Y - 0.5f) * pupilScaleLeft + 0.5f); float pupilScaleRight = 1.0f / (pupilSizeRight * pupilSize * Asymmetry.Y); Vector2 pupilOffRight = new Vector2( (pupilOffsetRight.X + PupilCenter.X - 0.5f) * pupilScaleRight + 0.5f, (pupilOffsetRight.Y - PupilCenter.Y - 0.5f) * pupilScaleRight + 0.5f); Parameter(EffectParams.PupilScale).SetValue(new Vector4( pupilScaleLeft, pupilScaleLeft, pupilScaleRight, pupilScaleRight)); Parameter(EffectParams.PupilOffset).SetValue(new Vector4( pupilOffLeft.X, pupilOffLeft.Y, pupilOffRight.X, pupilOffRight.Y)); /// Transform 0.5,0.5 from texture space to uv space, to find /// where the center of the pupil is on the face. Vector2 leftCenter = new Vector2( (0.5f - pupilOffLeft.X) / pupilScaleLeft, (0.5f - pupilOffLeft.Y) / pupilScaleLeft); Vector2 rightCenter = new Vector2( (0.5f - pupilOffRight.X) / pupilScaleRight, (0.5f - pupilOffRight.Y) / pupilScaleRight); SetLids(leftCenter, rightCenter); Parameter(EffectParams.EyePupilLeftTexture).SetValue(PupilLeftTexture()); Parameter(EffectParams.EyePupilRightTexture).SetValue(PupilRightTexture()); }
public FBXModelPtr(FBXModel p) : this(FBXImporterUnmanagedPINVOKE.new_FBXModelPtr__SWIG_1(FBXModel.getCPtr(p)), true) { }
/// <summary> /// Setup the model with idle animation AND idle in rest palette. /// </summary> /// <param name="model"></param> public void SetupIdle(FBXModel model) { model.Animators = IdleAnimation; SetRestPalette(model); }
/// <summary> /// Set up the model to be rendered using the active animation with idle in rest palette. /// </summary> /// <param name="model"></param> public void SetupActive(FBXModel model) { model.Animators = ActiveAnimation; SetRestPalette(model); }
public virtual void LoadContent(bool immediate) { this.sro = this.getModelInstance(); }
public virtual void UnloadContent() { this.sro = null; }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FBXModel obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; }
abstract public void SetupForRender(FBXModel model);
public FBXModel __ref__() { FBXModel ret = new FBXModel(FBXImporterUnmanagedPINVOKE.FBXModelPtr___ref__(swigCPtr), false); return(ret); }