Painting on a pre-generated texture map

yrro

05-06-2006 14:19:29

Here's my project:

We're using the terrain for a small game for a class. The ground is supposed to be kind of cartoonish in its coloring, so we're using a hand-drawn texture map as the base image. We do, however, want to have small explosions on the map, which deform the terrain and blacken that spot. We also want it in general to be playable on older video cards.

Its seems to me that what I want to try to use is the InstantBaseTextureEdit texture unit, with our texture as the base texture. However, I'm still fuzzy on the exact order and procedure I need to do to be able to paint on the terrain.

Say, if I want to to just make a 10 pixel by 10 pixel black square on the ground, I would:

Create a brush array that is 10 by 10 (what format do the pixels need to be in? RGBA? Is it a straight array of bytes in RGBARGBARGBA or does it need to be a different format?)
Set the height and width of the brush (is this in bytes or in pixels?)
Set the brush to be my new array.
Set the the "PaintColorCenter" of the brush.

When I do this, I don't see any changes, so it seems I must be doing something wrong?

Here is my config file:


GroupName=PLSM2

Width=1
Height=1

Data2DFormat=HeightField
LandScapeFileName=lemmings

FileSystem=Media/paginglandscape2/terrains/lemmings

NumTextureFormatSupported=19

NumTextureFormatSupported=19

TextureFormatSupported0=Image
TextureFormatSupported1=BaseTexture
TextureFormatSupported2=BaseTexture2
TextureFormatSupported3=InstantBaseTexture
TextureFormatSupported4=InstantBaseTextureEdit
TextureFormatSupported5=Splatting
TextureFormatSupported6=Splatting2
TextureFormatSupported7=Splatting2Edit
TextureFormatSupported8=Splatting4
TextureFormatSupported9=Splatting6
TextureFormatSupported10=Splatting7
TextureFormatSupported11=Splatting7Edit
TextureFormatSupported12=BaseTexture
TextureFormatSupported13=BaseTexture2
TextureFormatSupported14=InstantBaseTexture
TextureFormatSupported15=Splatting3
TextureFormatSupported16=Splatting5
TextureFormatSupported17=SplattingShader
TextureFormatSupported18=InstantBaseTextureShadowed

TextureFormat=InstantBaseTextureEdit
ImageFilename=lemmingsBaseColorMap

ScaleX=500
ScaleY=200
ScaleZ=500

Deformable=yes
SaveDeformation=no
VertexCompression=no
VertexProgramMorph=no
VertexNormals=yes
VertexLit=yes
MaxPixelError=10

NumMatHeightSplat=0

# where to put camera on load.
BaseCameraViewpoint.x=0.0f
BaseCameraViewpoint.y=500.0f
BaseCameraViewpoint.z=0.0f

Baselookat.x=0.0f
Baselookat.y=0.0f
Baselookat.z=0.0f


Any help is appreciated (as would be filling in the "how do I?" section of the wiki. There is good information on what options are available, but not in how you combine them to produce useful results).

Thanks.

tuan kuranes

06-06-2006 15:58:10


Create a brush array that is 10 by 10 (what format do the pixels need to be in? RGBA? Is it a straight array of bytes in RGBARGBARGBA or does it need to be a different format?)
Set the height and width of the brush (is this in bytes or in pixels?)
Set the brush to be my new array.
Set the the "PaintColorCenter" of the brush.

brush array that is 10 by 10 is a Real[100] array.
Set the height and width of the brush is in bytes
you need to set channel of colors of your brush, as for now brush only supports a color. Here's how to set a black brush on current CVS:

const std::vector<Real> rgba;
rgba.reserve(3);
rgba.resize(3);
rgba[0] = 0.0f;
rgba[1] = 0.0f;
rgba[2] = 0.0f;
setOption(setPaintChannelValues", myVector);

yrro

06-06-2006 20:11:43

How does this work if we are using the Ogre SDK (1.2) ? I looked through the SDK-stable PLSM2 source and the option is still "PaintChannel" and takes a uint.

Are the channels just RGBA (0,1,2,3)? is there an enum that I'm missing somewhere?

Thanks for your help.

tuan kuranes

06-06-2006 20:28:49

it was "PaintColor" before

yrro

07-06-2006 00:52:44

I'm feeling very dense right now, but I'm not understanding what I'm doing wrong.

This is my painting code:


void PlayState::Explosions(const Ogre::Vector3& impact)
{

Ogre::Real brush[100];
for (int i=0; i<100; i++)
{
brush[i]=1.f;
}
int width=10, height=10;

Ogre::ColourValue black(0, 0, 0);

mSceneMgr->setOption("BrushHeight", &height);
mSceneMgr->setOption("BrushWidth", &width);
mSceneMgr->setOption("BrushArray", brush);
mSceneMgr->setOption("PaintColor", &black);

mSceneMgr->setOption("PaintColorCenter", &impact);
}


I really appreciate the help.

yrro

07-06-2006 04:57:57

Ok, let's try for what's wrong with it aside from the obvious stupidity. This code still doesn't work.


Ogre::Real *brush = new Ogre::Real[100];
for (int i=0; i<100; i++)
{
brush[i]=1.f;
}
int width=10, height=10;

Ogre::ColourValue black(0, 0, 0);

mSceneMgr->setOption("BrushArrayHeight", &height);
mSceneMgr->setOption("BrushArrayWidth", &width);
mSceneMgr->setOption("BrushArray", brush);
mSceneMgr->setOption("PaintColor", &black);

mSceneMgr->setOption("PaintColorCenter", &impact);

tuan kuranes

07-06-2006 08:46:00

perhaps a sign problem, width, height should be unsigned int

yrro

07-06-2006 11:08:52

But as long as I don't pass in a negative number, the encoding for a signed or unsigned int is the same. I'll try, though...


Nope, no luck. :(

tuan kuranes

08-06-2006 10:56:05

have to wait next imminent SDK realease or get CVS plsm2.