Skip to content

Adding Image Materials

Coela Can't! edited this page Aug 20, 2021 · 4 revisions

Image Material

The image material allows you to use a converted picture as a material mapped with the frontal perspective to an Object3D instance. To create an Image material, open the ProtoTracerImageConverter project. Change the top lines of the python code to match your input file name, output file name, palettized picture output name, and class name:

inputFile = "Example Files\CoelaToot.png"
outputFile = "Output\CoelaToot.h"
pictureOutput = "Output\CoelaToot.png"
name = "CoelaToot"

Created Image Header

Running this Python code will create a file similar to the following which you can import and use as a material:

#pragma once

#include "..\..\Materials\Image.h"

class CoelaToot : public Image{
private:
	static const uint8_t rgbMemory[];
	static const uint8_t rgbColors[];

public:
	CoelaToot(Vector2D size, Vector2D offset) : Image(rgbMemory, rgbColors, 200, 200, 16) {
		SetSize(size);
		SetPosition(offset);
	}
};

const uint8_t CoelaToot::rgbMemory[] PROGMEM = {0...0};
const uint8_t CoelaToot::rgbColors[] PROGMEM = {0...0};

Image Material Usage

The created C++ file can be included and instantiated. The default constructer takes two Vecto2D objects as parameters. The first specifies the XY size in millimeters, the second is the position offset from origin. The material can be applied to any number of objects and its parameters can be changed:

#include "Flash\Images\CoelaToot.h"

CoelaToot image = CoelaToot(Vector2D(200, 145), Vector2D(20, 40));

object3D.SetMaterial(&image);

image.SetPosition(Vector2D(20.0f, 135.0f));
image.SetSize(Vector2D(-200.0f, 200.0f));
image.SetRotation(15.0f);
image.SetHueAngle(90.0f);

image.Update();