zoukankan      html  css  js  c++  java
  • MatrixState中的参数与 CP_Na_Cl中参数的比较

    MatrixState:

     public static void setInitStack()//获取不变换初始矩阵
        {
        	currMatrix=new float[16];
        	Matrix.setRotateM(currMatrix, 0, 0, 1, 0, 0);
        }
        
        public static void pushMatrix()//保护变换矩阵
        {
        	stackTop++;
        	for(int i=0;i<16;i++)
        	{
        		mStack[stackTop][i]=currMatrix[i];
        	}
        }
        
        public static void popMatrix()//恢复变换矩阵
        {
        	for(int i=0;i<16;i++)
        	{
        		currMatrix[i]=mStack[stackTop][i];
        	}
        	stackTop--;
        }
        
        public static void translate(float x,float y,float z)//设置沿xyz轴移动
        {
        	Matrix.translateM(currMatrix, 0, x, y, z);
        }
        
        public static void rotate(float angle,float x,float y,float z)//设置绕xyz轴移动
        {
        	Matrix.rotateM(currMatrix,0,angle,x,y,z);
        }
        
        public static void scale(float x,float y,float z)
        {
        	Matrix.scaleM(currMatrix,0, x, y, z);
        }
        
        //插入自带矩阵
        public static void matrix(float[] self)
        {
        	float[] result=new float[16];
        	Matrix.multiplyMM(result,0,currMatrix,0,self,0);
        	currMatrix=result;
        }

    CP_Na_Cl:


    public void drawSelf(){
    		
    		MatrixState.rotate(roateX, 1, 0, 0);
    		MatrixState.rotate(roateY, 0, 1, 0);
    		MatrixState.rotate(roateZ, 0, 0, 1);
    		
    		drawLine(-offset, 1, 1, 1, 1);
    		MatrixState.pushMatrix();
    		MatrixState.rotate(90, 0, 1, 0);
    		drawLine(-offset, 1, 1, 1, 1);
    		MatrixState.popMatrix();
    		MatrixState.pushMatrix();
    		MatrixState.rotate(90, 1, 0, 0);
    		drawLine(-offset, 1, 1, 1, 1);
    		MatrixState.popMatrix();
    		
    		drawLine(0, 1, 1, 1, 1);
    		MatrixState.pushMatrix();
    		MatrixState.rotate(90, 0, 1, 0);
    		drawLine(0, 1, 1, 1, 1);
    		MatrixState.popMatrix();
    		MatrixState.pushMatrix();
    		MatrixState.rotate(90, 1, 0, 0);
    		drawLine(0, 1, 1, 1, 1);
    		MatrixState.popMatrix();
    		
    		drawLine(offset, 1, 1, 1, 1);
    		MatrixState.pushMatrix();
    		MatrixState.rotate(90, 0, 1, 0);
    		drawLine(offset, 1, 1, 1, 1);
    		MatrixState.popMatrix();
    		MatrixState.pushMatrix();
    		MatrixState.rotate(90, 1, 0, 0);
    		drawLine(offset, 1, 1, 1, 1);
    		MatrixState.popMatrix();
    		
    		draw5Big(-offset, 0, 1, 0, 1);
    		draw4Small(-offset, 1, 1, 0, 1);
    		
    		
    		
    		draw4Big(0, 0, 1, 0, 1);
    		draw5Small(0, 1, 1, 0, 1);
    		
    		
    		
    		draw5Big(offset, 0, 1, 0, 1);
    		draw4Small(offset, 1, 1, 0, 1);
    		
    		
    	}

    总结:CP_Na_Cl中的rotatex是在MatrixState中rotate上进行的,rotatex用于计算比较,不过相当于rotate中的X!

  • 相关阅读:
    SQL语句汇总——数据修改、数据查询
    Spring AOP详解
    action类中属性驱动和模型驱动的区别
    数组指针的用法,用处。
    C,C++回文字符串判断(字符串指针的用法)
    C,C++容易被忽略的问题
    c,c++函数返回多个值的方法
    adsf
    Establishing a Build Environmen
    Setting up a Mac OS build environment
  • 原文地址:https://www.cnblogs.com/Anzhongliu/p/6092070.html
Copyright © 2011-2022 走看看