// etc... public ClipContainer(CreatureSpecies species) { this.species = species; partDictionary = new Dictionary <string, Dictionary <string, AnimationClip> >(); partDictionary.Add("root", rootDict); partDictionary.Add("rootPivot", rootPivotDict); partDictionary.Add("pelvis", pelvisDict); partDictionary.Add("waist", waistDict); partDictionary.Add("torso", torsoDict); partDictionary.Add("FL_Hip", FL_HipDict); partDictionary.Add("FL_Thigh", FL_ThighDict); partDictionary.Add("FL_Knee", FL_KneeDict); partDictionary.Add("FL_Ankle", FL_AnkleDict); partDictionary.Add("FL_Toe", FL_ToeDict); partDictionary.Add("FR_Hip", FR_HipDict); partDictionary.Add("FR_Thigh", FR_ThighDict); partDictionary.Add("FR_Knee", FR_KneeDict); partDictionary.Add("FR_Ankle", FR_AnkleDict); partDictionary.Add("FR_Toe", FR_ToeDict); partDictionary.Add("BL_Hip", BL_HipDict); partDictionary.Add("BL_Thigh", BL_ThighDict); partDictionary.Add("BL_Knee", BL_KneeDict); partDictionary.Add("BL_Ankle", BL_AnkleDict); partDictionary.Add("BL_Toe", BL_ToeDict); partDictionary.Add("BR_Hip", BR_HipDict); partDictionary.Add("BR_Thigh", BR_ThighDict); partDictionary.Add("BR_Knee", BR_KneeDict); partDictionary.Add("BR_Ankle", BR_AnkleDict); partDictionary.Add("BR_Toe", BR_ToeDict); //etc... }
public Creature(CreatureSpecies specie) { ID = nextID; nextID++; this.specie = specie; }
public AnimationBase(CreatureSpecies species, string animName, float animTime) { this.species = species; float legSeparation = species.legSeparation; float shoulderWidth = species.spineData.torsoData.radiusB; float hipWidth = species.spineData.pelvisData.radiusA; root_defOffset = new Vector3(-legSeparation / 2, species.backLegData.legLength, 0.0f); root_defRotation = Quaternion.Euler(0.0f, 0.0f, species.spineElevation - 90.0f); FL_defOffset = new Vector3(legSeparation / 2, 0.0f, shoulderWidth); FR_defOffset = new Vector3(legSeparation / 2, 0.0f, -shoulderWidth); BL_defOffset = new Vector3(-legSeparation / 2, 0.0f, hipWidth); BR_defOffset = new Vector3(-legSeparation / 2, 0.0f, -hipWidth); GameObject sphere0 = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere0.transform.position = FL_defOffset; animGroup = CreateClips(animTime, animName); UpdateDictionaries(animName); }
// Use this for initialization void Start() { if (species == null) { Debug.LogWarning("CreatureBase added with no species set. Creating new species..."); species = new CreatureSpecies(); species.CreateNewSpecies(); } // Attach body parts as children GameObject body = NewChild("body"); BodyBase bodyBase = body.AddComponent <BodyBase>(); bodyBase.Init(); PGAnimationController animator = gameObject.AddComponent <PGAnimationController>(); animator.Init(ref species, bodyBase.legBase); }
// Use this for initialization void Start() { if (generate_terrain && Terrain.activeTerrain != null) { terrain = Terrain.activeTerrain; if (terrain.GetComponent <TerrainGenerator>() != null) { terrain.GetComponent <TerrainGenerator>().GenerateTerrain(); if (generate_trees) { ForestCreator forest = gameObject.GetComponent <ForestCreator>(); //gameObject.AddComponent<ForestCreator>(); forest.SetTerrain(terrain); forest.SetSpeciesNum(tree_species_num); } } else { Debug.LogError("ERROR: No TerrainGenerator component on active terrain."); } } if (generate_creatures) { // Generate species for new creatures for (int i = 0; i < creature_species_num; i++) { CreatureSpecies newSpecies = new CreatureSpecies(); newSpecies.CreateNewSpecies(); creature_species_list.Add(newSpecies); } // Generate creatures from new species // For now, just generate a single test creature GameObject testCreature = new GameObject("TestCreature"); testCreature.transform.position = Vector3.zero; CreatureBase creatureScript = testCreature.AddComponent <CreatureBase>(); creatureScript.species = creature_species_list[0]; } }
void Awake() { m_legBase = new Transform[4]; defaultMat = new Material(Shader.Find("Diffuse")); species = transform.parent.GetComponent <CreatureBase>().species; }
// Use this for initialization public void Init(ref CreatureSpecies species, Transform[] legBase) { // Get reference to creature species this.species = species; // Attach animation components to all objects //int animNum = 28; //Animation[] animComps = new Animation[animNum]; GameObject bodyBase = gameObject.transform.FindChild("body").gameObject; GameObject root = bodyBase.transform.FindChild("root").gameObject; AddToAnimList(ref root); GameObject rootPivot = root.transform.FindChild("rootPivot").gameObject; AddToAnimList(ref rootPivot); GameObject pelvisPivot = rootPivot.transform.FindChild("pelvis").gameObject; AddToAnimList(ref pelvisPivot); GameObject waistPivot = pelvisPivot.transform.FindChild("waist").gameObject; AddToAnimList(ref waistPivot); GameObject torsoPivot = waistPivot.transform.FindChild("torso").gameObject; AddToAnimList(ref torsoPivot);; //GameObject neckPivot = torsoPivot.transform.FindChild("neckPivot").gameObject; //neckPivot.AddComponent<Animation>(); GameObject BL_hipPivot = root.transform.FindChild("BL_hipPivot").gameObject; //AddToAnimList(ref BL_hipPivot); GameObject BR_hipPivot = root.transform.FindChild("BR_hipPivot").gameObject; //AddToAnimList(ref BR_hipPivot); GameObject FL_hipPivot = torsoPivot.transform.FindChild("FL_hipPivot").gameObject; //AddToAnimList(ref FL_hipPivot); GameObject FR_hipPivot = torsoPivot.transform.FindChild("FR_hipPivot").gameObject; //AddToAnimList(ref FR_hipPivot); GameObject BL_hip = bodyBase.transform.FindChild("BL_hip").gameObject; GameObject BR_hip = bodyBase.transform.FindChild("BR_hip").gameObject; GameObject FL_hip = bodyBase.transform.FindChild("FL_hip").gameObject; GameObject FR_hip = bodyBase.transform.FindChild("FR_hip").gameObject; GameObject[] hips = { BL_hip, BR_hip, FL_hip, FR_hip }; for (int i = 0; i < 4 /* Number of legs */; i++) { string prefix = i == 0?"BL_":i == 1?"BR_":i == 2?"FL_":i == 3?"FR_":"ERROR_"; GameObject child = hips[i]; AddToAnimList(ref child, prefix + "Hip"); child = child.transform.FindChild("thigh").gameObject; AddToAnimList(ref child, prefix + "Thigh"); child = child.transform.FindChild("calf").gameObject; AddToAnimList(ref child, prefix + "Knee"); child = child.transform.FindChild("foot").gameObject; AddToAnimList(ref child, prefix + "Ankle"); child = child.transform.FindChild("toe").gameObject; AddToAnimList(ref child, prefix + "Toe"); } /* * ClipContainer clips = species.clips; * for(int i = 0; i < animObjectList.Count; i++) { * for(int j = 0; j = clips.ActiveGroupNum(); j++) { * animObjectList[i].AddClip(clips.idleAnim.rootClip,"idle"); * } * } */ }
public AnimationGenerator(CreatureSpecies species) { this.species = species; }
public WalkAnimation(CreatureSpecies species_w, string animName) : base(species_w, animName, animTime) { species = species_w; }
// It is the constructors function, when this object is created, to fill the animation group with all the relevant animation clips public IdleAnimation(CreatureSpecies species, string animName) : base(species, animName, animTime) { }