Vertex questions

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
pixartist
Posts: 25
Joined: Thu Apr 14, 2011 4:58 pm

Vertex questions

Post by pixartist »

Okay, first of all, I use the IrrlichtLime .Net wrapper.

So I have List of vertice and I can render them, BUT:

1) When I change the color of a vertex, it won't render colored:

Code: Select all

 vertices.Add(new Vertex3D((x + chunkX * World.chunkSize) * Render.blockSize - Render.blockSize / 2,
                y * Render.blockSize + Render.blockSize / 2,
                (z + chunkZ * World.chunkSize) * Render.blockSize - Render.blockSize / 2));
            vertices[vertices.Count - 1].Color = new Color(0,255,0);
2) Is it wise to combine the vertices into a mesh before rendering them? And if so, how to do it ?

3) Is it possible to project a texture onto a simple vertex?
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

On 1) and 2) I believe you may find the irrlicht 03.CustomSceneNode.exe example very useful. It`s there. Just take a look.

On 3)- this is not a valid question. The vertex is just a point is space (and some extra data) and as such its a 0-dimensional object. So it has no surface to project anything on it. If you meant whether you`re able to draw some texture on a bunch of vertices (forming triangles) then its already proven by all the textured models you see rendered by Irrlicht. You just need to set the correct texture uv coordinates to tell the driver how to align your texture, which is usually done in the modelling program, but for simplier objects it can be calculated or set manually.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
pixartist
Posts: 25
Joined: Thu Apr 14, 2011 4:58 pm

Post by pixartist »

1) 2)
I don't use node, I manually draw the vertices. As you can see I can set Vertex.Color. My question is why this does not work
3) Yea, sorry I meant a vertex list / polygon
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Post by greenya »

pixartist,

where do you want me to asnwer your question, in this thread or in IrrlichtLime' thread (in Project Announcemenrs), where you also asked the same about vertex color?
pixartist
Posts: 25
Joined: Thu Apr 14, 2011 4:58 pm

Post by pixartist »

greenya wrote:pixartist,

where do you want me to asnwer your question, in this thread or in IrrlichtLime' thread (in Project Announcemenrs), where you also asked the same about vertex color?
Well, I presumed you were busy, and did not have time to reply to the question, since it does not really have anything to do with your topic anyway, so I made a thread for this question and a few more (this thread has 3 questions)

So if you'd like to answer the question, you might do it here, so other users have an easier way to find the answer if they have the same problem
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

pixartist wrote:I don't use node, I manually draw the vertices. As you can see I can set Vertex.Color. My question is why this does not work
Doesn`t matter at all. The method is all the same.
Taken from the tutorial/example. Looks very similar to your "manual draw" of vertices, doesn`t it?! :)

Code: Select all

virtual void render()
{
  u16 indices[] = { 0,2,3, 2,1,3, 1,0,3, 2,0,1 };
  video::IVideoDriver* driver = SceneManager->getVideoDriver();

  driver->setMaterial(Material);
  driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
  driver->drawIndexedTriangleList(&Vertices[0], 4, &indices[0], 4);
}
Note the way we`re setting the correct material to the driver. Make sure you do it the same way. The material has its lighting set to "false", so that the vertex colors will appear the same as we`ve set them.
pixartist wrote:As you can see I can set Vertex.Color
In fact the only thing I see is one short piece of messy-hard-to-read-code-thingy, which is insufficient to tell where exactly you`re doing sth wrong. We`re still out of crystal spheres, so asking "My question is why this does not work" won`t help that much. :D
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
pixartist
Posts: 25
Joined: Thu Apr 14, 2011 4:58 pm

Post by pixartist »

hmm okay, thanks that works, though I can only use one single color for a whole vertex list. :/
edit: ahh ! lighting=false !

Damn, so is there a way to apply some form of colors/texture to a list of vertices, but still have lighting on?

btw, here is a better-to read piece of code:

Code: Select all

private void addTopFace(int x, int y, int z)
        {
            uint i = (uint)vertexIndices.Count;
            float gx = (x + chunkX * World.chunkSize) * Render.blockSize;
            float gy = y * Render.blockSize;
            float gz = (z + chunkZ * World.chunkSize) * Render.blockSize;
            float hb = Render.blockSize / 2;
            vertices.Add(new Vertex3D(
                gx - hb,
                gy + hb,
                gz - hb));
            vertices[vertices.Count - 1].Color = new Color(0, 255, 0);
            vertexIndices.Add(i);

            vertices.Add(new Vertex3D(
                 gx - hb,
                 gy + hb,
                 gz + hb));
            vertices[vertices.Count - 1].Color = new Color(0, 255, 0);
            vertexIndices.Add(i + 1);

            vertices.Add(new Vertex3D(
                gx + hb,
                gy + hb,
                gz + hb));
            vertices[vertices.Count - 1].Color = new Color(0, 255, 0);
            vertexIndices.Add(i + 2);

            vertices.Add(new Vertex3D(
                gx + hb,
                gy + hb,
                gz - hb));
            vertices[vertices.Count - 1].Color = new Color(0, 255, 0);
            vertexIndices.Add(i + 3);
        }
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

pixartist wrote:Damn, so is there a way to apply some form of colors/texture to a list of vertices, but still have lighting on?
Then set the material lighting to true. But you need to have at least one light added maybe?! Try some directional pointing somewhere downwards or everything with lighting set to "true" in your scene will be all black.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
pixartist
Posts: 25
Joined: Thu Apr 14, 2011 4:58 pm

Post by pixartist »

doesn't irrlicht have global lighting? like sunlight... ?
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

pixartist wrote:doesn't irrlicht have global lighting? like sunlight... ?
Why on earth would it create an unneeded light source?
Working on game: Marrbles (Currently stopped).
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You can set ambient light, but also this needs to be configured.
Post Reply