PRG3D
Member
|
Strange rendering error
Hi,
When I shoot into sky, everything is ok, but when I shoot to item, or terrain (drawing bullet hole) I have problem.
Screenshot 1(red line - bullet):
Screenshot 2 (white line is something interessing error :-D ):
Somebody can help me?
(This post was last modified: 02-19-2011 01:25 PM by PRG3D.)
|
|
02-19-2011 01:11 PM |
|
menajev
Member
|
RE: Strange rendering error
Sorry but it's too hard for me to guess how you calculate bullet lines after seeing screens only.
Read the title again and get confused - what exactly is wrong?
(This post was last modified: 02-19-2011 07:48 PM by menajev.)
|
|
02-19-2011 07:43 PM |
|
PRG3D
Member
|
RE: Strange rendering error
Hmm. bullet is a ray it's update function:
Code:
if(T.alive())
{
T.move = T.vel*Time.d();//move bullet
//collision
BulletHitDetection bhd(this);
Physics.ray(T.pos,T.move,bhd);
T.pos += T.move;
}
hit metod:
Code:
Bool hit(PhysHit &hit)
{
if(T.bullet->alive())
{
if(hit.obj)
{
if(hit.obj->type() == OBJ_ITEM)
{
Message.Add(S+"Item");
Item *item = CAST(Item, hit.obj);
item->hit(T.bullet,hit);
}
}
}
return true;
}
when bullet hit item:
Code:
void Item::hit(Bullet *bullet,PhysHit &ph)
{
Matrix bullet_matrix;
bullet_matrix.setPosDir(ph.plane.pos,ph.plane.normal).scaleOrn(0.05f);
// add a decal to the item
Decal &decal=decals.New();
decal.material (Materials.ptr("Decal/bullet.mtrl"));
decal.setMatrix(matrixScaled(),bullet_matrix);
}
And now problem is:
All be ok, when I don't shoot to item, but when Item was be hit the white line show up - why? In bullet draw metod is:
Code:
D.line(YELLOW,T.pos-T.move,T.pos);
D.line(RED,T.startPos,T.pos);
|
|
02-19-2011 08:32 PM |
|
PRG3D
Member
|
RE: Strange rendering error
Hmm problem is when I draw bullet hole in Item draw metod (drawOverlay):
Code:
UInt Item::drawPrepare()
{
UInt modes=__super::drawPrepare();
if(T.decals.elms())modes|=IndexToFlag(RM_OVERLAY);
return modes;
}
void Item::drawOverlay()
{
REPAO(decals).drawAnimated(T.matrixScaled());
__super::drawOverlay();
}
|
|
02-20-2011 04:19 PM |
|
Esenthel
Administrator
|
RE: Strange rendering error
D.line is to be called outside of render function
|
|
02-20-2011 05:10 PM |
|
PRG3D
Member
|
RE: Strange rendering error
What I must to do? I don't undertand well.
It's my render function:
Code:
void Render()
{
Game::World.draw();
switch(Renderer())
{
case RM_PREPARE:
case RM_SOLID:
case RM_AMBIENT: REPAO(Bullets).draw(); break;
}
}
(This post was last modified: 02-21-2011 03:39 PM by PRG3D.)
|
|
02-21-2011 03:30 PM |
|
Esenthel
Administrator
|
RE: Strange rendering error
if you want to use D.line, dont call it inside Render/Renderer, but Draw
|
|
02-21-2011 05:07 PM |
|