質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
OpenGL

OpenGLは、プラットフォームから独立した、デスクトップやワークステーション、モバイルサービスで使用可能な映像処理用のAPIです。

Q&A

0回答

615閲覧

OpenGLのテクスチャマッピング

akstn

総合スコア0

OpenGL

OpenGLは、プラットフォームから独立した、デスクトップやワークステーション、モバイルサービスで使用可能な映像処理用のAPIです。

0グッド

0クリップ

投稿2021/07/16 02:51

matlab上でアニメーション作成しており、OpenGLの関数を呼び出して作っています。
赤い立方体の側面にテクスチャマッピングをしたいのですがうまくいきません。
またjpegを貼り付ける方法も知りたいです。

現在
glTranslatef(-7.5, 2, -50);
glMaterialfv(GL.FRONT_AND_BACK,GL.AMBIENT, [ 1 0.0 0.0 ]);
glMaterialfv(GL.FRONT_AND_BACK,GL.DIFFUSE, [ 1.0 0.0 0.0 ]);
glutSolidCube(3.05);
glTranslatef(7.5, -2, 50);
この位置に赤い立方体を置いており、
サブルーチンのcubefaceを呼び出しています。
function cubeface( i, tx )
% We want to access OpenGL constants. They are defined in the global
% variable GL. GLU constants and AGL constants are also available in the
% variables GLU and AGL...
global GL
% Vector v maps indices to 3D positions of the corners of a face:
v=[ 0 0 0 ; 1 0 0 ; 1 1 0 ; 0 1 0 ; 0 0 1 ; 1 0 1 ; 1 1 1 ; 0 1 1 ]'-0.5;
% Compute surface normal vector. Needed for proper lighting calculation:
n=cross(v(:,i(2))-v(:,i(1)),v(:,i(3))-v(:,i(2)));
% Bind (Select) texture 'tx' for drawing:
glBindTexture(GL.TEXTURE_2D,tx);
% Begin drawing of a new quad:
glBegin(GL.QUADS);
% Assign n as normal vector for this polygons surface normal:
glNormal3f(n(1), n(2), n(3));
x_1=7.5;
y_1=-2;
z_1=50;
k_1=3.05;
% Define vertex 1 by assigning a texture coordinate and a 3D position:
glTexCoord2f(0, 0);
glVertex3f(x_1,y_1,z_1);
% Define vertex 2 by assigning a texture coordinate and a 3D position:
glTexCoord2f(1, 0);
glVertex3f(x_1,y_1-k_1,z_1);
% Define vertex 3 by assigning a texture coordinate and a 3D position:
glTexCoord2f(1, 1);
glVertex3f(x_1,y_1-k_1,z_1-k_1);
% Define vertex 4 by assigning a texture coordinate and a 3D position:
glTexCoord2f(0, 1);
glVertex3f(x_1,y_1,z_1-k_1);
% Done with this polygon:
glEnd;
% Return to main function:
return
こうしているのですが、できないという状態です。
エラーなどは出ないので、座標が間違っているのかと思います。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問