第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何在實(shí)心模式下繪制網(wǎng)格表面?

如何在實(shí)心模式下繪制網(wǎng)格表面?

紫衣仙女 2022-09-28 14:48:03
我有這個(gè)代碼,我應(yīng)該修改它來做2件事:使用基本照明(和獨(dú)特的)以實(shí)體模式繪制表面,以及l(fā)ights()fill()用兩種顏色漸變繪制表面(例如,紅色表示z的低值,黃色表示高值)為此,我建議在每個(gè)頂點(diǎn)()之前使用調(diào)用fill()這是我的第一個(gè)代碼,問題是我不希望網(wǎng)格在我應(yīng)用顏色后顯示。// Drawing a 3D functionfloat rotX = 0.0, rotY = 0.0;int lastX, lastY;float distX = 0.0, distY = 0.0;// Function stepsint steps = 50;// z scalefloat scaleZ = 200.0;// z zoomfloat zoomZ = -300.0;// Graphic sizefloat gX = 500.0, gY = 500.0;void setup(){    size(500, 500, P3D);    noFill();    strokeWeight(0.005);}float function(float x, float y){    return x*x*x + y*y*y;}void draw() {    lights();    background(0);    // We center the results on window    translate(gX/2, gY/2, zoomZ);    // Rotation    rotateY(rotY + distX);    rotateX(rotX + distY);    // Centering around (0, 0);    translate(-gX/2, -gY/2);    // Function covers    // 400 x 400 x scaleZ    scale(gX, gY, scaleZ);    // Drawing the function    fill(167);    drawFunction();    // Drawing axes    stroke(255, 0, 0);    line(0,0,0,2000,0,0);    stroke(0,255,0);    line(0,0,0,0,2000,0);    stroke(0,0,255);    line(0,0,0,0,0,2000);}void drawFunction(){    float x, y, z;    int i = 0, j = 0;    float in_steps = 1.0 / steps;    float[][] matrix = new float[steps+1][steps+1];    for (y = 0.0, j = 0; y <= 1.0; y+=in_steps, j++)        for (x = 0.0, i = 0; x <= 1.0; x+=in_steps, i++)            matrix[i][j] = function(x, y);    stroke(167);    for (j = 0, y = 0.0; j < steps; j++, y+=in_steps) {        beginShape(QUAD_STRIP);        for (i = 0, x = 0.0; i <= steps; i++, x+=in_steps) {            vertex(x, y, matrix[i][j]);            vertex(x, y + in_steps, matrix[i][j+1]);        }        endShape();    }}void mousePressed(){    lastX = mouseX;    lastY = mouseY;}void mouseDragged(){     distX = radians(mouseX - lastX);    distY = radians(lastY - mouseY);}void mouseReleased(){    rotX += distY;    rotY += distX;    distX = distY = 0.0;}
查看完整描述

1 回答

?
開心每一天1111

TA貢獻(xiàn)1836條經(jīng)驗(yàn) 獲得超13個(gè)贊

lights() 已經(jīng)在代碼中正確設(shè)置。

使用無中風(fēng)()擺脫線條。 禁用繪圖輪廓。noStroke

填充區(qū)域的顏色可以通過將 RGB(紅色、綠色和藍(lán)色)值傳遞給 fill()來設(shè)置。
這些值是范圍[0, 255] 中的整數(shù)值。紅色的 RGB vlaue 是 (255, 0, 0),黃色的 RGB 值為 (255, 255, 0)。

紅色到黃色的漸變顏色可以通過以下方式實(shí)現(xiàn):

fill(255, z*255, 0);

其中 z 位于 [0.0, 1.0] 中。如果結(jié)果為紅色 (255, 0, 0),如果結(jié)果為黃色 (255, 255, 0)。z 的所有值在 0.0 和 1.0 之間都會(huì)導(dǎo)致讀取和黃色之間的線性插值。z = 0.0z = 1.0

例如

for (j = 0, y = 0.0; j < steps; j++, y+=in_steps) {

    beginShape(QUAD_STRIP);


    noStroke(); // no lines


    for (i = 0, x = 0.0; i <= steps; i++, x+=in_steps) {


        fill(255, matrix[i][j] * 255, 0); // interpolate between red and yellow

        vertex(x, y, matrix[i][j]);


        fill(255, matrix[i][j+1] * 255, 0); // interpolate between red and yellow

        vertex(x, y + in_steps, matrix[i][j+1]);

    }

    endShape();

}  

http://img1.sycdn.imooc.com//6333ee4d0001279d04580361.jpg

查看完整回答
反對(duì) 回復(fù) 2022-09-28
  • 1 回答
  • 0 關(guān)注
  • 80 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)