zoukankan      html  css  js  c++  java
  • 球中的initVertex

    private void initVertex(float r) {
    		// TODO Auto-generated method stub
    		R=r;
    		ArrayList<Float>alVertix=new ArrayList<Float>();
    		for(float vAngle=90;vAngle>-90;vAngle-=angleSpan){
    			for(float hAngle=360;hAngle>0;hAngle-=angleSpan){
    				float x1=getCoor(0, vAngle, hAngle);
    				float y1=getCoor(1, vAngle, hAngle);
    				float z1=getCoor(2, vAngle, hAngle);
    				
    				float x2=getCoor(0, vAngle-angleSpan, hAngle);
    				float y2=getCoor(1, vAngle-angleSpan, hAngle);
    				float z2=getCoor(2, vAngle-angleSpan, hAngle);
    				
    				float x3=getCoor(0, vAngle-angleSpan, hAngle-angleSpan);
    				float y3=getCoor(1, vAngle-angleSpan, hAngle-angleSpan);
    				float z3=getCoor(2, vAngle-angleSpan, hAngle-angleSpan);
    				
    				float x4=getCoor(0, vAngle, hAngle-angleSpan);
    				float y4=getCoor(1, vAngle, hAngle-angleSpan);
    				float z4=getCoor(2, vAngle, hAngle-angleSpan);
    				
    				alVertix.add(x1);alVertix.add(y1);alVertix.add(z1);
            		alVertix.add(x2);alVertix.add(y2);alVertix.add(z2);
            		alVertix.add(x4);alVertix.add(y4);alVertix.add(z4);        		
            		//构建第二三角形
            		alVertix.add(x4);alVertix.add(y4);alVertix.add(z4);
            		alVertix.add(x2);alVertix.add(y2);alVertix.add(z2);
            		alVertix.add(x3);alVertix.add(y3);alVertix.add(z3); 
    			}
    		}
    		 vCount=alVertix.size()/3;
    	        float vertices[]=new float[vCount*3];
    	    	for(int i=0;i<alVertix.size();i++){
    	    		vertices[i]=alVertix.get(i);
    	    	}
    	        ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length*4);
    	        vbb.order(ByteOrder.nativeOrder());
    	        mVertexBuffer = vbb.asFloatBuffer();
    	        mVertexBuffer.put(vertices);
    	        mVertexBuffer.position(0);
    	}
    

  • 相关阅读:
    python常见对象的结构
    python不可变对象
    python常用对象使用方法
    python对象分类
    Binary Tree Serialization
    Two nodes of a BST are swapped, correct the BST
    Redis数据库
    CGI和FastCGI的区别
    mysql索引
    Python和Golang的应用
  • 原文地址:https://www.cnblogs.com/Anzhongliu/p/6092069.html
Copyright © 2011-2022 走看看