Home | History | Annotate | Download | only in scenegraph
      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 
     17 package com.android.scenegraph;
     18 
     19 import java.lang.Math;
     20 import java.util.ArrayList;
     21 
     22 import android.renderscript.RenderScriptGL;
     23 import android.renderscript.Matrix4f;
     24 import android.renderscript.ProgramFragment;
     25 import android.renderscript.ProgramStore;
     26 import android.renderscript.ProgramVertex;
     27 import android.renderscript.Element;
     28 import android.util.Log;
     29 
     30 /**
     31  * @hide
     32  */
     33 public class TransformParam extends ShaderParam {
     34 
     35     Transform mTransform;
     36     LightBase mLight;
     37 
     38     public TransformParam(String name) {
     39         super(name);
     40     }
     41 
     42     public void setTransform(Transform t) {
     43         mTransform = t;
     44         if (mField != null && mTransform != null) {
     45             mData.transform = mTransform.getRSData().getAllocation();
     46         }
     47         incTimestamp();
     48     }
     49 
     50     int getTypeFromName() {
     51         int paramType = ScriptC_export.const_ShaderParam_TRANSFORM_DATA;
     52         if (mParamName.equalsIgnoreCase(view)) {
     53             paramType = ScriptC_export.const_ShaderParam_TRANSFORM_VIEW;
     54         } else if(mParamName.equalsIgnoreCase(proj)) {
     55             paramType = ScriptC_export.const_ShaderParam_TRANSFORM_PROJ;
     56         } else if(mParamName.equalsIgnoreCase(viewProj)) {
     57             paramType = ScriptC_export.const_ShaderParam_TRANSFORM_VIEW_PROJ;
     58         } else if(mParamName.equalsIgnoreCase(model)) {
     59             paramType = ScriptC_export.const_ShaderParam_TRANSFORM_MODEL;
     60         } else if(mParamName.equalsIgnoreCase(modelView)) {
     61             paramType = ScriptC_export.const_ShaderParam_TRANSFORM_MODEL_VIEW;
     62         } else if(mParamName.equalsIgnoreCase(modelViewProj)) {
     63             paramType = ScriptC_export.const_ShaderParam_TRANSFORM_MODEL_VIEW_PROJ;
     64         }
     65         return paramType;
     66     }
     67 
     68     void initLocalData() {
     69         mData.type = getTypeFromName();
     70         if (mTransform != null) {
     71             mData.transform = mTransform.getRSData().getAllocation();
     72         }
     73         if (mCamera != null) {
     74             mData.camera = mCamera.getRSData().getAllocation();
     75         }
     76         if (mLight != null) {
     77             mData.light = mLight.getRSData().getAllocation();
     78         }
     79     }
     80 }
     81 
     82 
     83 
     84 
     85 
     86