public static AGameObject city(ShaderProgram program, Vector4 position, bool IsTextured) { Dictionary <String, Material> materials = Material.LoadFromFile(@"Materials\TheCity.mtl"); MyComplexObjectFactory3 modelObj = MyComplexObjectFactory3.LoadFromFile(@"Models\TheCity.obj"); Tuple <int[], Dictionary <String, int> > textInd = modelObj.GetTexturesInd(materials); float[] textIndices = new float[textInd.Item1.Length]; for (int i = 0; i < textIndices.Length; i++) { textIndices[i] = textInd.Item1[i]; } Dictionary <String, int> mapInd = textInd.Item2; List <String> texturesPath = new List <string>(); for (int i = 0; i < mapInd.Count; i++) { String mat = mapInd.FirstOrDefault(x => x.Value == i).Key; texturesPath.Add(materials.FirstOrDefault(x => x.Key == mat).Value.DiffuseMap); } ARenderable2 modelRend; modelRend = new TextureRender2(program.program, modelObj.GetVerts(), modelObj.GetTextureCoords(), modelObj.GetNormals(), modelObj.GetIndices(), textIndices, texturesPath.ToArray()); AGameObject model = new CowObject(modelRend, new Vector4(0f, 0f, 0f, 0), position, Vector3.Zero); return(model); }
public static AGameObject earth(ShaderProgram program, Vector4 position, bool IsTextured) { MyComplexObjectFactory2 modelObj = MyComplexObjectFactory2.LoadFromFile(@"Models\earth.obj", 2); ARenderable2 modelRend; if (IsTextured) { modelRend = new TextureRender2(program.program, modelObj.GetVerts(), modelObj.GetTextureCoords(), modelObj.GetNormals(), modelObj.GetIndices(), @"Textures\earth.jpg"); } else { modelRend = new TextureRender2(program.program, modelObj.GetVerts(), modelObj.GetIndices()); } AGameObject model = new CowObject(modelRend, new Vector4(0f, 0f, 0f, 0f), position, Vector3.Zero); return(model); }
public static AGameObject f16(ShaderProgram program, Vector4 position, bool IsTextured) { MyComplexObjectFactory2 objF16 = MyComplexObjectFactory2.LoadFromFile(@"Models\f16.obj", 0); ARenderable2 f16Rend; if (IsTextured) { f16Rend = new TextureRender2(program.program, objF16.GetVerts(), objF16.GetTextureCoords(), objF16.GetNormals(), objF16.GetIndices(), @"Textures\f16.bmp"); } else { f16Rend = new TextureRender2(program.program, objF16.GetVerts(), objF16.GetIndices()); } AGameObject f16 = new CowObject(f16Rend, new Vector4(0f, 0f, 0f, 0f), position, objF16.CalculateObjectCenter(), 100); f16.Rotate(0, null); return(f16); }
public static AGameObject bus(ShaderProgram program, Vector4 position, bool IsTextured) { MyComplexObjectFactory2 objBus = MyComplexObjectFactory2.LoadFromFile(@"Models\bus.obj", 1); ARenderable2 busRend; if (IsTextured) { busRend = new TextureRender2(program.program, objBus.GetVerts(), objBus.GetTextureCoords(), objBus.GetNormals(), objBus.GetIndices(), @"Textures\bus.png"); } else { busRend = new TextureRender2(program.program, objBus.GetVerts(), objBus.GetIndices()); } AGameObject bus = new CowObject(busRend, new Vector4(0f, 0f, 0f, 0f), position, objBus.CalculateObjectCenter(), 100); bus.Rotate(150, null); bus.rot_dir = true; return(bus); }
void Update() { if (temp != null) { GameObject.Destroy(temp); } if (sAI_ != null && sAI_.mAIRT != null) { sAI_.mAIRT.GetComponent <MeshRenderer> ().material.color = mSrc; sAI_ = null; } switch (mEnumType) { case TESTZOOLOGYMOUSE.NONE: break; case TESTZOOLOGYMOUSE.DELETECOW: SimpleAI sAI = FindAIByRayCast("Cow"); if (sAI != null) { sAI_ = sAI; mSrc = sAI.mAIRT.GetComponent <MeshRenderer> ().material.color; sAI.mAIRT.GetComponent <MeshRenderer> ().material.color = new Color(1.0f, 0, 0, 0.4f); if (Input.GetMouseButton(0)) { sAI.Destroy(); } } break; case TESTZOOLOGYMOUSE.DELETEGRASS: SimpleAI sAI1 = FindAIByRayCast("Glass"); if (sAI1 != null) { sAI_ = sAI1; mSrc = sAI1.mAIRT.GetComponent <MeshRenderer> ().material.color; sAI1.mAIRT.GetComponent <MeshRenderer> ().material.color = new Color(1.0f, 0, 0, 0.4f); if (Input.GetMouseButton(0)) { sAI1.Destroy(); } } break; case TESTZOOLOGYMOUSE.DELETETREE: SimpleAI sAI2 = FindAIByRayCast("Tree"); if (sAI2 != null) { sAI_ = sAI2; mSrc = sAI2.mAIRT.GetComponent <MeshRenderer> ().material.color; sAI2.mAIRT.GetComponent <MeshRenderer> ().material.color = new Color(1.0f, 0, 0, 0.4f); if (Input.GetMouseButton(0)) { sAI2.Destroy(); } } break; case TESTZOOLOGYMOUSE.ADDCOW: Vector3 pos = FindPointByRayCast(); if (pos != Vector3.zero) { temp = GameObject.Instantiate(Cow, pos, Quaternion.identity) as GameObject; temp.GetComponent <MeshRenderer> ().material.color = new Color(0, 1, 0, 0.5f); if (Input.GetMouseButton(0)) { CowObject co = new CowObject(); co.RandomData(); co.Type = true; co.mPosition = pos; co.Encode(); co.InitBreakPoint(); SimpleAI scow = RePair(new CowRePairer(), new CowRunner(), new CowJudger(), Cow, Player, new CowDestroyer(), "Cow", co, GAPopulation.allDic["Cow"].mTempCount); scow.mCharacter = co; GAPopulation.allDic ["Cow"].Add(scow); } else if (Input.GetMouseButton(1)) { CowObject co = new CowObject(); co.RandomData(); co.Type = false; co.mPosition = pos; co.Encode(); co.InitBreakPoint(); SimpleAI scow = RePair(new CowRePairer(), new CowRunner(), new CowJudger(), Cow, Player, new CowDestroyer(), "Cow", co, GAPopulation.allDic["Cow"].mTempCount); scow.mCharacter = co; GAPopulation.allDic ["Cow"].Add(scow); } } break; case TESTZOOLOGYMOUSE.ADDGRASS: Vector3 pos1 = FindPointByRayCast(); if (pos1 != Vector3.zero) { temp = GameObject.Instantiate(Grass, pos1, Quaternion.identity) as GameObject; temp.GetComponent <MeshRenderer> ().material.color = new Color(0, 1, 0, 0.5f); if (Input.GetMouseButton(0)) { glassObject go = new glassObject(); go.RandomData(); go.mColor = 0.9f; go.mPosition = pos1; go.Encode(); go.InitBreakPoint(); SimpleAI sglass = RePair(new GlassRePairer(), new GlassRunner(), new GlassJudger(), Grass, Player, new CowDestroyer(), "Glass", go, GAPopulation.allDic["Glass"].mTempCount); sglass.mCharacter = go; //Debug.Log (FreedomAIEncoderAndDecoder.bitbunch2String(FreedomAIEncoderAndDecoder.float2BitBunch(0.2f,0.0f,1.0f,11))); GAPopulation.allDic ["Glass"].Add(sglass); } else if (Input.GetMouseButton(1)) { glassObject go = new glassObject(); go.RandomData(); go.mColor = Random.Range(0.1f, 0.4f); go.mPosition = pos1; go.Encode(); go.InitBreakPoint(); SimpleAI sglass = RePair(new GlassRePairer(), new GlassRunner(), new GlassJudger(), Grass, Player, new CowDestroyer(), "Glass", go, GAPopulation.allDic["Glass"].mTempCount); sglass.mCharacter = go; GAPopulation.allDic ["Glass"].Add(sglass); } } break; case TESTZOOLOGYMOUSE.ADDTREE: Vector3 pos2 = FindPointByRayCast(); if (pos2 != Vector3.zero) { temp = GameObject.Instantiate(Tree, pos2, Quaternion.identity) as GameObject; temp.GetComponent <MeshRenderer> ().material.color = new Color(0, 1, 0, 0.5f); if (Input.GetMouseButton(0)) { TreeObject to = new TreeObject(); to.RandomData(); to.mStrongRate = Random.Range(0.0f, 0.5f); to.mPosition = pos2; // go.mHeight = Random.Range (1.0f,1.5f); to.Encode(); to.InitBreakPoint(); SimpleAI sTree = RePair(new TreeRePairer(), new TreeRunner(), new TreeJudger(), Tree, Player, new CowDestroyer(), "Tree", to, GAPopulation.allDic["Tree"].mTempCount); sTree.mCharacter = to; GAPopulation.allDic ["Tree"].Add(sTree); } else if (Input.GetMouseButton(1)) { TreeObject to = new TreeObject(); to.RandomData(); to.mStrongRate = Random.Range(0.5f, 1.0f); to.mPosition = pos2; to.Encode(); to.InitBreakPoint(); SimpleAI sTree = RePair(new TreeRePairer(), new TreeRunner(), new TreeJudger(), Tree, Player, new CowDestroyer(), "Tree", to, GAPopulation.allDic["Tree"].mTempCount); sTree.mCharacter = to; GAPopulation.allDic ["Tree"].Add(sTree); } } break; } }