Rcpp::Arrayがないので

# 必要なパッケージ
library(Rcpp)
library(inline)
# C++ソース本体
src<-'
int Nx=as<int>(N1);
int Ny=as<int>(N2);
int Nz=as<int>(N3);
Rcpp::NumericVector a(Nx*Ny*Nz);
int counter=0;
	for (int k = 0; k < Nz; k++) {
	for (int j = 0; j < Ny; j++) {
	for (int i = 0; i < Nx; i++) {
		a[counter]= (i + 1)*(j + 1)*(k + 1)*1.0;
		counter++;
	}
	}
	}
return a;
'
# R内で、関数をコンパイル
fx.test1<-cxxfunction(signature(N1="integer",N2="integer",N3="integer"), include=c(""),src,plugin="Rcpp")
# 使う
library(rgl)
N1<-10
N2<-15
N3<-20
test.out<-fx.test1(N1,N2,N3)

test.out2<-array(1,c(N1,N2,N3))
addresses<-which(test.out2>0,arr.ind=TRUE)

plot3d(addresses,col=gray((test.out-min(test.out))/(max(test.out)-min(test.out))))

A<-array(test.out,c(N1,N2,N3))

plot3d(slice.index(A,1),slice.index(A,2),slice.index(A,3),col=rainbow(256)[A/(max(A))*256+1],alpha=ifelse(A!=0,1,0))