其實我是Arduino Neopixel粉絲,並試圖運行球形POV。對於運行POV,每個圖像應該轉換爲每次革命中使用的行數,我認爲轉換規劃器POV不能太難以進行java基礎處理,以便像素化爲行,但我現在不會如何映射在球面上的圖像,然後轉換爲圖像線我真的很感謝您的任何意見使用處理3D圖像映射
回答
處理編輯器附帶示例,其中之一將紋理圖像映射到球體。它通過將球體分成三角形,然後使用texture()
和vertex()
函數來繪製紋理球體。
您可以將File > Examples > Topics > Textures > TextureSphere
得到從處理編輯的代碼,但這裏的代碼:
/**
* Texture Sphere
* by Gillian Ramsay
*
* Rewritten by Gillian Ramsay to better display the poles.
* Previous version by Mike 'Flux' Chang (and cleaned up by Aaron Koblin).
* Original based on code by Toxi.
*
* A 3D textured sphere with simple rotation control.
*/
int ptsW, ptsH;
PImage img;
int numPointsW;
int numPointsH_2pi;
int numPointsH;
float[] coorX;
float[] coorY;
float[] coorZ;
float[] multXZ;
void setup() {
size(640, 360, P3D);
background(0);
noStroke();
img=loadImage("world32k.jpg");
ptsW=30;
ptsH=30;
// Parameters below are the number of vertices around the width and height
initializeSphere(ptsW, ptsH);
}
// Use arrow keys to change detail settings
void keyPressed() {
if (keyCode == ENTER) saveFrame();
if (keyCode == UP) ptsH++;
if (keyCode == DOWN) ptsH--;
if (keyCode == LEFT) ptsW--;
if (keyCode == RIGHT) ptsW++;
if (ptsW == 0) ptsW = 1;
if (ptsH == 0) ptsH = 2;
// Parameters below are the number of vertices around the width and height
initializeSphere(ptsW, ptsH);
}
void draw() {
background(0);
camera(width/2+map(mouseX, 0, width, -2*width, 2*width),
height/2+map(mouseY, 0, height, -height, height),
height/2/tan(PI*30.0/180.0),
width, height/2.0, 0,
0, 1, 0);
pushMatrix();
translate(width/2, height/2, 0);
textureSphere(200, 200, 200, img);
popMatrix();
}
void initializeSphere(int numPtsW, int numPtsH_2pi) {
// The number of points around the width and height
numPointsW=numPtsW+1;
numPointsH_2pi=numPtsH_2pi; // How many actual pts around the sphere (not just from top to bottom)
numPointsH=ceil((float)numPointsH_2pi/2)+1; // How many pts from top to bottom (abs(....) b/c of the possibility of an odd numPointsH_2pi)
coorX=new float[numPointsW]; // All the x-coor in a horizontal circle radius 1
coorY=new float[numPointsH]; // All the y-coor in a vertical circle radius 1
coorZ=new float[numPointsW]; // All the z-coor in a horizontal circle radius 1
multXZ=new float[numPointsH]; // The radius of each horizontal circle (that you will multiply with coorX and coorZ)
for (int i=0; i<numPointsW ;i++) { // For all the points around the width
float thetaW=i*2*PI/(numPointsW-1);
coorX[i]=sin(thetaW);
coorZ[i]=cos(thetaW);
}
for (int i=0; i<numPointsH; i++) { // For all points from top to bottom
if (int(numPointsH_2pi/2) != (float)numPointsH_2pi/2 && i==numPointsH-1) { // If the numPointsH_2pi is odd and it is at the last pt
float thetaH=(i-1)*2*PI/(numPointsH_2pi);
coorY[i]=cos(PI+thetaH);
multXZ[i]=0;
}
else {
//The numPointsH_2pi and 2 below allows there to be a flat bottom if the numPointsH is odd
float thetaH=i*2*PI/(numPointsH_2pi);
//PI+ below makes the top always the point instead of the bottom.
coorY[i]=cos(PI+thetaH);
multXZ[i]=sin(thetaH);
}
}
}
void textureSphere(float rx, float ry, float rz, PImage t) {
// These are so we can map certain parts of the image on to the shape
float changeU=t.width/(float)(numPointsW-1);
float changeV=t.height/(float)(numPointsH-1);
float u=0; // Width variable for the texture
float v=0; // Height variable for the texture
beginShape(TRIANGLE_STRIP);
texture(t);
for (int i=0; i<(numPointsH-1); i++) { // For all the rings but top and bottom
// Goes into the array here instead of loop to save time
float coory=coorY[i];
float cooryPlus=coorY[i+1];
float multxz=multXZ[i];
float multxzPlus=multXZ[i+1];
for (int j=0; j<numPointsW; j++) { // For all the pts in the ring
normal(-coorX[j]*multxz, -coory, -coorZ[j]*multxz);
vertex(coorX[j]*multxz*rx, coory*ry, coorZ[j]*multxz*rz, u, v);
normal(-coorX[j]*multxzPlus, -cooryPlus, -coorZ[j]*multxzPlus);
vertex(coorX[j]*multxzPlus*rx, cooryPlus*ry, coorZ[j]*multxzPlus*rz, u, v+changeV);
u+=changeU;
}
v+=changeV;
u=0;
}
endShape();
}
希望這是一個良好的開端,但更普遍的:堆棧溢出ISN真的不是爲普通人設計的,我該如何做這個「類型的問題。它更專門設計用於特定的「我試過X,預計Y,但得到Z」類型的問題。你可以發佈你嘗試過的任何東西嗎?你的Minimal, Complete, and Verifiable example在哪裏?
如果你不知道如何開始,那麼開始更小:你可以得到一個映射到矩形的圖像?如果你遇到困難,從那裏開始工作併發布信息。祝你好運。
非常感謝@Kevin,我也收到了你的筆記,其實我是新手,並沒有完全意識到如何打開票和如何迴應,請你讓我知道如何邀請現在可能的答案的人在特定主題 –
@Hamidsk這實際上不是Stack Overflow的工作原理。您可以通過電子郵件向他們發送問題鏈接,但如果您正在通過Stack Overflow發送消息,那實際上並沒有完成。 –
- 1. 3D紋理映射
- 2. 使用HTML5 Canvas進行圖像處理和紋理映射?
- 3. C#3D圖像處理
- 4. matlab圖像處理3d
- 5. 使用映射的多處理
- 6. 如何使用圖像處理從圖像中移除反射
- 7. 3D投影映射
- 8. 紋理如何映射到3D對象?
- 9. 什麼是圖像處理中的逆映射函數?
- 10. 基於圖像的紋理映射
- 11. PHP/GD圖像映射/紋理
- 12. Opengl紋理映射和圖像資源
- 13. WPF圖像映射
- 14. IIS7處理程序映射
- 15. XML2Java映射 - 處理繼承
- 16. 使用CALayer顯示Alpha映射圖像
- 17. 使用Fancybox和圖像映射
- 18. 使用逆映射顯示GreyScale圖像
- 19. 使用Fancybox和圖像映射/視頻
- 20. 如何使用Hadoop MapReduce處理3D圖像?
- 21. 使用構建器(使用immutables註釋處理器)將映射對象映射到不可變對象映射
- 22. 圖像處理使用MATLABR2010a
- 23. 使用Javascript處理圖像?
- 24. 使用javascript處理圖像
- 25. 使用MVC3處理圖像
- 26. 使用Gnuplot進行3D映射的圖形不準確
- 27. 3D圖形批處理
- 28. Categories圖像插件如何使用term_id來映射圖像?
- 29. 使用圖像映射時通過jquery交換圖像
- 30. 使用jQuery和圖像映射關於懸停更改圖像
請在crossposts之間建立鏈接:https://forum.processing.org/two/discussion/18313/using-processing-for-3d-image-mapping –
Stack Overflow並非真正爲一般設計「我該怎麼辦這個「類型的問題。它更專門設計用於特定的「我試過X,預計Y,但得到Z」類型的問題。你可以發佈你嘗試過的任何東西嗎?你的[mcve]在哪裏?如果你不知道如何開始,那麼開始縮小:你能得到映射到矩形的圖像嗎?如果你遇到困難,從那裏開始工作併發布信息。祝你好運。 –