I want to draw an image on 3d rectanle plane (as a texture ?)

Hi, All.

I want to draw an image on 3d rectanle plane (as a texture ?).

And,

I want to move the plane to the direction of minus z-direction far away.

Like a Apple’s Time Machine.

43

How can I make this code using OF?

Thanks in advance.

Best,
@bemoregt.

Hi, sure.
you can use ofPlanePrimitive class.
it should be something like the following

#pragma once

#include "ofMain.h"

class ofApp : public ofBaseApp{
	public:

    void setup();
    void draw();
    
    void mouseMoved(int x, int y);
		
    vector<ofPlanePrimitive> planes;
    ofImage img;
	ofEasyCam cam;
};
#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup() {
    img.load("img.jpg");

	planes.resize(10);
	for(size_t i =0; i < planes.size(); i++){
		planes[i].set(img.getWidth(), img.getHeight(), 2, 2);
		
		planes[i].mapTexCoordsFromTexture(img.getTexture());
		planes[i].setPosition(0, -500, (100)*i);
	
	}
	cam.setFarClip(10000);
}
//--------------------------------------------------------------
void ofApp::draw() {
	
	cam.begin();
	ofDrawGrid(100, 10, true);
    img.getTexture().bind();
    
	for(auto& p: planes){
		p.draw();
	}
	

    img.getTexture().unbind();
	cam.end();
}

//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y){
	cam.setLensOffset({0.f,ofMap(y, 0, ofGetHeight(), -2,2)});
}
1 Like