Randy
Member
|
Draw3D image disappears at distance
I am using Image.Draw3D for drawing player names.
Close to camera it looks ok -
But on big distances image becomes invisible -
Image was created manually:
Code:
(*tmp_image).create2D(256, 256, IMAGE_B8G8R8A8);
and letters drawing by tmp_image->color() method
Imported images works fine at every distance, so I think problem in manually created image.
How can I fix this problem?
|
|
09-21-2011 07:48 PM |
|
Esenthel
Administrator
|
RE: Draw3D image disappears at distance
Use D.text
|
|
09-21-2011 08:56 PM |
|
Zervox
Member
|
RE: Draw3D image disappears at distance
also remember color might need setting alpha.
image.draw3D(color,size,angle,position,ALPHA_NONE); ?
(This post was last modified: 09-21-2011 09:07 PM by Zervox.)
|
|
09-21-2011 09:06 PM |
|
Randy
Member
|
RE: Draw3D image disappears at distance
(09-21-2011 08:56 PM)Esenthel Wrote: Use D.text
In this case player names will be visible through objects and terrain.
I think billboards is the best solution.
The question is - what property of Image class responsible for rendering distance?
|
|
09-21-2011 09:16 PM |
|
Esenthel
Administrator
|
RE: Draw3D image disappears at distance
there is D.textDepth or similar
|
|
09-21-2011 09:37 PM |
|
Rofar
Member
|
RE: Draw3D image disappears at distance
You can do some ray casting and check for collisions with objects from the camera to the player to determine whether or not to display the text. That's what I do.
|
|
09-21-2011 10:44 PM |
|
Randy
Member
|
RE: Draw3D image disappears at distance
(09-21-2011 09:37 PM)Esenthel Wrote: there is D.textDepth or similar
Thanks!
I found PosToScreen() + D.textDepth() + D.text() is very useful combination for player names/chat clouds drawing, but how about setting image distance draw parameter? Is it a secret? )
|
|
09-21-2011 10:49 PM |
|
llynx
Member
|
RE: Draw3D image disappears at distance
(09-21-2011 10:49 PM)Randy Wrote: Thanks!
I found PosToScreen() + D.textDepth() + D.text() is very useful combination for player names/chat clouds drawing, but how about setting image distance draw parameter? Is it a secret? )
It's a function you should create that would fit your aesthetic requirements.
|
|
09-21-2011 11:22 PM |
|
Randy
Member
|
RE: Draw3D image disappears at distance
(09-21-2011 11:22 PM)llynx Wrote: (09-21-2011 10:49 PM)Randy Wrote: how about setting image distance draw parameter? Is it a secret? )
It's a function you should create that would fit your aesthetic requirements.
Engine automatically manages visibility of image (see screenshots), i just want to know how to configure it's parameters.
|
|
09-21-2011 11:43 PM |
|
Driklyn
Member
|
RE: Draw3D image disappears at distance
(09-21-2011 09:37 PM)Esenthel Wrote: there is D.textDepth or similar
Wow, never knew...
|
|
09-22-2011 12:12 AM |
|
Zervox
Member
|
RE: Draw3D image disappears at distance
(09-21-2011 11:43 PM)Randy Wrote: (09-21-2011 11:22 PM)llynx Wrote: (09-21-2011 10:49 PM)Randy Wrote: how about setting image distance draw parameter? Is it a secret? )
It's a function you should create that would fit your aesthetic requirements.
Engine automatically manages visibility of image (see screenshots), i just want to know how to configure it's parameters.
Did you try the alpha tip?
|
|
09-22-2011 07:35 AM |
|
Esenthel
Administrator
|
RE: Draw3D image disappears at distance
Maybe you haven't called image.updateMipMaps
|
|
09-22-2011 08:54 AM |
|
Randy
Member
|
RE: Draw3D image disappears at distance
(09-22-2011 08:54 AM)Esenthel Wrote: Maybe you haven't called image.updateMipMaps
Yes, now it's works!
(Previously I called .updateMipMaps() before .unlock() and it makes nothing without error)
But another question - Draw3D() automatically stretch image height equally to width, is it configurable?
Here a testing example of my code, based on '03 - World with Character.cpp' tutorial
replace
Code:
STRUCT(Player , Game::Chr)
.....
};
with
Code:
STRUCT(Player , Game::Chr) // extend character structure by defining a player class based on the character
//{
Memx<Game::Item> items;
virtual Memx<Game::Obj>* itemContainer() {Memx<Game::Obj> &items=T.items; return &items;} // override default method of character, to return proper item container
void updateItems(); // update items actions
virtual Bool update (); // here we'll update the player
Player();
UInt drawPrepare();
void drawBlend();
Image * img;
};
Image * CreateImage(Color col)
{
Image * tmp_image = new Image;
(*tmp_image).create2D(256, 32, IMAGE_B8G8R8A8);
tmp_image->lock();
for (int x=0; x < tmp_image->x(); x++)
for (int y=0; y<tmp_image->y(); y++)
{
Color c = col;
tmp_image->color(x, y, c);
}
tmp_image->unlock();
tmp_image->updateMipMaps(); // remove this to make image auto-disappearing at distance
return tmp_image;
}
// Constructor
Player::Player()
{
img = CreateImage(RED);
}
UInt Player::drawPrepare()
{
UInt ret = super::drawPrepare();
return IndexToFlag(RM_BLEND);
}
void Player::drawBlend()
{
SetMatrix();
img->draw3D(Color(255,255,255,255), 1, 0, pos()+Vec(0,2,0));
}
As you can see, red picture is always square.
(09-21-2011 09:06 PM)Zervox Wrote: also remember color might need setting alpha.
image.draw3D(color,size,angle,position,ALPHA_NONE); ?
Default mode=ALPHA_BLEND_DEC gives best results (fits my aesthetic requirements ; )
(This post was last modified: 09-22-2011 04:40 PM by Randy.)
|
|
09-22-2011 04:31 PM |
|