About Store Forum Documentation Contact



Post Reply 
VI and image part
Author Message
Houge Offline
Member

Post: #1
VI and image part
Hello!
How can i combine VI buffering (with VI.image()) for 3d drawing and Image.drawPart?
VI allows drawing only full images, not parts.
04-24-2017 06:06 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #2
RE: VI and image part
some time ago I made this

VI Decal
is this similar to what you need?
it uses Vtx3DTex position and texture coordinates to allow you to decide the UV(part) of the image to draw
(This post was last modified: 04-24-2017 06:55 PM by Zervox.)
04-24-2017 06:49 PM
Find all posts by this user Quote this message in a reply
Houge Offline
Member

Post: #3
RE: VI and image part
Very nice, but it draws full image, and I want to take image atlas and draw animation using VI, but Atlas uses drawPart, because it keeps all frames on one image.

So it's not the thing I need smile
P.S. if i crop a part of an atlas into new image it's too heavy to do it every frame.

UPD:
OK i figured it out smile


(This post was last modified: 04-24-2017 09:25 PM by Houge.)
04-24-2017 08:41 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #4
RE: VI and image part
Glad it worked out. smile
04-24-2017 10:31 PM
Find all posts by this user Quote this message in a reply
Houge Offline
Member

Post: #5
RE: VI and image part
Just for information, fast implementation
Code:
Int frame = N;
    C ImageAtlas::Part &part = T._atlas->parts[frame];
    if(C Image *image = atlas->images.addr(part.image_index))
    {
        if(part.rotated)
        {
            v[3].tex.set(part.tex_rect.lu().x, part.tex_rect.lu().y);
            v[0].tex.set(part.tex_rect.ld().x, part.tex_rect.ld().y);
            v[1].tex.set(part.tex_rect.rd().x, part.tex_rect.rd().y);
            v[2].tex.set(part.tex_rect.ru().x, part.tex_rect.ru().y);
        }
        else
        {
            v[0].tex.set(part.tex_rect.lu().x, part.tex_rect.lu().y);
            v[1].tex.set(part.tex_rect.ld().x, part.tex_rect.ld().y);
            v[2].tex.set(part.tex_rect.rd().x, part.tex_rect.rd().y);
            v[3].tex.set(part.tex_rect.ru().x, part.tex_rect.ru().y);
        }
        VI.image(image);
        VI.face(v[0], v[1], v[2], v[3]);
        VI.end();
    }

This example does not use image offset in Atlas (but it should), so it shall be added.
This example draws animation using part.tex_rect placed in VI.tex.
(This post was last modified: 04-25-2017 07:58 AM by Houge.)
04-25-2017 07:43 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #6
RE: VI and image part
Very nice, mine was written just as test code, glad to see it inspired a better solution for in with atlas, at the time I had written my own Atlas and packer solution. smile
(This post was last modified: 04-25-2017 09:12 AM by Zervox.)
04-25-2017 09:09 AM
Find all posts by this user Quote this message in a reply
Post Reply