coding Shift_JIS;

import Math;
import Graphics3D;
import graphics3d.Graphics3DFramework;


// �O���b�h��X/Y������
const int X_N = 16;
const int Y_N = 16;

// ���_���W���i�[����z��
float vertex[ Y_N ][ X_N ][ 3 ];

// ���f����ID���i�[����
int model;

// ���f���̕ό`�Ɏg�������ϐ�
float time = 0.0;

// 1�t���[�����Ƃ̎��ԕω���
float timeStep = 0.1;


// ���̊֐��̓v���O�����N�����1�x�����R�[�������
void onStart(int renderer){

	// �l�p�`�O���b�h�`���Ń��f���𐶐�
	model = newModel(vertex, QUADRANGLE_GRID);

	// ���f���̐F�ݒ�i�ԁA�΁A�A���l�j
	setModelColor(model, 0, 0, 255, 255);

	// ���f����z�u
	mountModel(model, renderer);
}


// ���̊֐���1�b�Ԃɐ��\��R�[�����ꑱ����
void onUpdate(int renderer){

	// �����ϐ������Z
	time += timeStep;

	// ���_���W�̌v�Z
	for(int i=0; i<Y_N; i++){
		for(int j=0; j<X_N; j++){

			float x = j * 0.2;
			float y = i * 0.2;
			float z = 0.2 * ( sin( 2.0*x - time ) + sin( 2.0*y - time ) );

			vertex[ i ][ j ][ 0 ] = x;
			vertex[ i ][ j ][ 1 ] = y;
			vertex[ i ][ j ][ 2 ] = z;

		}
	}

	// ���f���̒��_�z����X�V
	setModelVertex(model, vertex, QUADRANGLE_GRID);
}