craksy
Member
|
Help with markers
Ok after getting my selectionbox done, i tried adding a marker to my character.
but i got a little confused and ended up with having a few questions about it:
1.
i dont really understand this line:
PosPointMeshY(Vec2(i ? 1 : -1, 0),terrain,&m.local_matrix.pos);
what exactly does it do? my first guess was setting the markers matrix according to the terrain mesh, but it was already set in the previous line:
m.local_matrix.setPosDir(Vec(0,0,0), Vec(0,1,0));
so.. what does it do? and what do you do if you are using an imported .world file, and not a mesh base?
2.
here's what i tried to do.. Am i totally wrong about it?
My extension of Chr:
Code:
struct Unit : Game::Chr
{
Bool selected;
Marker m ;
virtual Bool update();
void init ();
};
//Called in the main Init() function
void Unit::init(){
m.set(GREEN, 0, *Images("particle/star.gfx"), 1, 0.2, 0.3);
m.local_matrix.setPosDir(Vec(T.pos().x, 0, T.pos().z), Vec(0,1,0));
}
//gonna have some if(selected) and turn on/off visibility later
Bool Unit::update(){
m.local_matrix.orn.rotateZVec(Tm.d());
return true;
}
and in my draw() function i have:
Code:
case RM_BLEND:
REPA(Chrs)Chrs[i].m.draw(Chrs[i].m.local_matrix);
break;
}
so am i totally wrong about this, and what do i need to do to make it work?
thanks in advance
-Craksy
(This post was last modified: 10-17-2009 04:15 PM by craksy.)
|
|
10-17-2009 04:14 PM |
|
Esenthel
Administrator
|
RE: Help with markers
Quote:and what do you do if you are using an imported .world file, and not a mesh base?
then please use Physics.ray for collision detecion
|
|
10-17-2009 04:18 PM |
|
craksy
Member
|
RE: Help with markers
what do you mean? use Physics.ray()?
does PosPointMeshY(Vec2(i ? 1 : -1, 0),terrain,&m.local_matrix.pos); do collision detection?
i'm not sure i understand :/
|
|
10-17-2009 04:32 PM |
|
Esenthel
Administrator
|
RE: Help with markers
(10-17-2009 04:32 PM)craksy Wrote: what do you mean? use Physics.ray()?
does PosPointMeshY(Vec2(i ? 1 : -1, 0),terrain,&m.local_matrix.pos); do collision detection?
i'm not sure i understand :/
PosPointMeshY it does do collision detection but only for specified mesh (and is slower)
world creates actors for which you can use Physics.ray which is faster
|
|
10-17-2009 04:41 PM |
|
craksy
Member
|
RE: Help with markers
ok this is how i understand it... please correct me if i'm wrong:
PosPointMeshY() do a ray test from markers position matrix, and straight down.
if it hits the terrain mesh, it sets the markers position matrix = the first argument Vec2(x, z) on the mesh surface?
im probably wrong about this, so please correct me!
anyway i still don't got a clue of how to do it with World :/
i am sorry, but could you please give me a little example?
|
|
10-17-2009 04:58 PM |
|
Esenthel
Administrator
|
RE: Help with markers
yes you understand it correctly, search tutorials for Physics.ray
|
|
10-17-2009 05:32 PM |
|
craksy
Member
|
RE: Help with markers
ok i tried this:
Code:
m.set(GREEN, 0, *Images("particle/star.gfx"), 1, 0.2, 0.3);
m.local_matrix.setPosDir(Vec(0, 0, 0), Vec(0,1,0));
if(Physics.ray(m.local_matrix.pos, m.local_matrix.pos + Vec(0, -5, 0))){
m.local_matrix.pos.v2 = T.pos().v2;
}
but it still doesn't show up.
what did i do wrong?
|
|
10-17-2009 05:52 PM |
|
Esenthel
Administrator
|
RE: Help with markers
if(Physics.ray(m.local_matrix.pos, m.local_matrix.pos + Vec(0, -5, 0)))
this is wrong
|
|
10-17-2009 06:08 PM |
|
craksy
Member
|
RE: Help with markers
then what? :/
|
|
10-17-2009 06:09 PM |
|
craksy
Member
|
RE: Help with markers
hmm... i could really use some help :/
i supposed that its current position + negative value on the Y axis would make it go straight down.
also in my characters update function:
m.local_matrix.pos = phys_hit.plane.p;
works fine, but:
m.local_matrix.pos = T.pos();
gives some weird results... how do i make it be at my characters feet? like on the ground, and still at the characters xz position?
thanks
-Craksy
|
|
10-18-2009 01:49 PM |
|
Esenthel
Administrator
|
RE: Help with markers
Flt x=pos.x(), z=pos.z(), y=pos.y();
Physics.ray(Vec(x,y+100,z),Vec(0,-200,0),..
plus you need to do callback to skip unwanted actors
|
|
10-18-2009 02:02 PM |
|
craksy
Member
|
RE: Help with markers
ok i tried and this was what i ended up with
i suppose thats the callback thing? i need it to ignore the character itself and only register the terrain right?
but how do i do this?
|
|
10-18-2009 02:20 PM |
|
Xhizors
Member
|
RE: Help with markers
Try put IndexToFlag( AG_TERRAIN ) in the end of the ray function.
Like ray( Vec(x,y+100,z),Vec(0,-200,0), PhysHit, IndexToFlag( AG_TERRAIN ));
(This post was last modified: 10-19-2009 10:15 AM by Xhizors.)
|
|
10-19-2009 10:14 AM |
|
craksy
Member
|
RE: Help with markers
didn't work :/
it still gives me the weird shadow thingy :/
thanks for trying though
great to see that other people than Esenthel is starting to help in the support forum (not saying that you are the only one)
hopefully with time, we will have more experienced users, so Esenthel doesn't have to do all the supporting
|
|
10-19-2009 03:25 PM |
|
Esenthel
Administrator
|
RE: Help with markers
please experiment with the marker parameters, and show which texture image are you using for the marker
|
|
10-19-2009 04:16 PM |
|