public void spawn_asteroid(Vector3 aPos, Vector3 aVel) { //pull the images from the character loader //I should have done this using dependency injection but who cares string[] astroNames = { "BG-1", "BG-2", "BG-3", "BG-4", "FG-1", "FG-2" }; astroNames.Shuffle(); var sizing = ManagerManager.Manager.mGameManager.CurrentCharacterLoader.Sizes.find_static_element(astroNames[0]); var astroImage = ManagerManager.Manager.mGameManager.CurrentCharacterLoader.Images.staticElements [astroNames[0]]; var ast = new ImageGameObjectUtility(astroImage, sizing.Size).ParentObject; foreach (Renderer e in ast.GetComponentsInChildren <Renderer>()) { e.material.renderQueue = 5000; e.gameObject.layer = 1; //this is the mainbodycamera layer } ast.AddComponent <AstronautCollisionBehaviour>().Astronaut = this; ast.AddComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezePositionZ & RigidbodyConstraints.FreezeRotationX & RigidbodyConstraints.FreezeRotationY; ast.AddComponent <SphereCollider>().radius = sizing.Size.y * 4 / 9f; ast.transform.position = aPos; ast.GetComponent <Rigidbody>().velocity = aVel; ast.GetComponent <Rigidbody>().useGravity = false; mAsteroids.Add(ast); }
//ugg public void draw_background(Texture2D aBg) { GameObject bg = ImageGameObjectUtility.create(aBg); bg.GetComponentInChildren <Renderer>().material.shader = ManagerManager.Manager.mReferences.mGraphShader; draw_gameObject(bg, Vector2.zero, true); GameObject.Destroy(bg); }
public MeterImageObject(Texture2D aTex, Vector2?aSize, FillStyle aStyle, int aDepth) { //SoftColor = new Color(0.5f,0.5f,0.5f,1); HardColor = GameConstants.UiBlue; Style = aStyle; mImage = new ImageGameObjectUtility(aTex, aSize); PrimaryGameObject = mImage.ParentObject; Depth = aDepth; mCurrentPercentage = mPercentage = 0; }
public void initialize(Texture aTex, System.Nullable <Vector2> aSize, int aDepth) { SoftColor = new Color(0.5f, 0.5f, 0.5f, 0.5f); mImage = new ImageGameObjectUtility(aTex, aSize); PrimaryGameObject = mImage.ParentObject; if (aTex != null) { PrimaryGameObject.name = "genImageObject_" + aTex.name; } Depth = aDepth; }
public Texture2D take_color_image() { if (ManagerManager.Manager.mZigManager.is_reader_connected() == 2) { //TODO temporarily disabled to slove wrong format bug return(null); //TODO write the shader and test ManagerManager.Log("taking color image"); Material mat = new Material(ManagerManager.Manager.mReferences.mXB1KinectImageMaskingShader); mat.SetTexture("_MainTex", mKinect.ColorTexture); mat.SetTexture("_AlphaTex", mKinect.LabelTexture); //mat.SetTexture("_MainTex",mKinect.LabelTexture); if (mColorImageRT == null) { mColorImageRT = new RenderTexture(mKinect.ColorTexture.width, mKinect.ColorTexture.height, 0); } var img = new ImageGameObjectUtility(mKinect.ColorTexture); img.PlaneObject.GetComponent <Renderer>().material = mat; Camera cam = ManagerManager.Manager.gameObject.AddComponent <Camera>(); cam.orthographic = true; cam.orthographicSize = img.BaseDimension.y; img.PlaneObject.transform.position = cam.transform.position + cam.transform.forward * 10; cam.transform.LookAt(img.PlaneObject.transform.position); //TODO resize the camera RenderTexture.active = mColorImageRT; cam.targetTexture = mColorImageRT; cam.clearFlags = CameraClearFlags.SolidColor; cam.backgroundColor = Color.blue; cam.Render(); //Texture2D copyTex = new Texture2D(mColorImageRT.width,mColorImageRT.height); //copyTex.ReadPixels(new Rect(0,0,mColorImageRT.width,mColorImageRT.height),0,0); //copyTex.Apply(); RenderTexture.active = null; cam.targetTexture = null; GameObject.Destroy(cam); img.destroy(); return(ManagerManager.Manager.mZigManager.ImageView.UpdateTexture(mKinect.ColorTexture, mKinect.LabelTexture)); } return(null); }