TextureCube.java revision 99b93819f12f18b8559f702d7a303c31fe05205a
1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.scenegraph; 18 19import java.lang.Math; 20 21import com.android.scenegraph.SceneManager; 22import com.android.scenegraph.TextureBase; 23 24import android.content.res.Resources; 25import android.renderscript.*; 26import android.util.Log; 27 28/** 29 * @hide 30 */ 31public class TextureCube extends TextureBase { 32 String mFileName; 33 String mFileDir; 34 35 public TextureCube() { 36 } 37 38 public TextureCube(Allocation tex) { 39 setTexture(tex); 40 } 41 42 public TextureCube(String dir, String file) { 43 setFileDir(dir); 44 setFileName(file); 45 } 46 47 public void setFileDir(String dir) { 48 mFileDir = dir; 49 } 50 51 public void setFileName(String file) { 52 mFileName = file; 53 } 54 55 public String getFileName() { 56 return mFileName; 57 } 58 59 public void setTexture(Allocation tex) { 60 mRsTexture = tex; 61 } 62 63 Allocation getRsData(RenderScriptGL rs, Resources res) { 64 if (mRsTexture != null) { 65 return mRsTexture; 66 } 67 68 String shortName = mFileName.substring(mFileName.lastIndexOf('/') + 1); 69 mRsTexture = SceneManager.loadCubemap(mFileDir + shortName, rs, res); 70 71 return mRsTexture; 72 } 73} 74 75 76 77 78 79