std::vector<int> somevalues; std::vector<int> somevaluesTocheck; bool status = false; for(int i = 0 ; i < (int)somevaluesTocheck.size() ; i++){ status = false; for(int j = 0; j < (int)somevalues.size(); j++){ if(somevaluesTocheck[i] == somevalues[j]){ status = true; } } if(!status){ somevaluesTocheck.erase(somevaluesTocheck.begin() + i); } }
 Home
 » Viewing Profile: Reputation: Exessuz
Exessuz
Member Since 28 Jun 2012Offline Last Active Feb 04 2013 03:14 PM
Community Stats
 Group Members
 Active Posts 8
 Profile Views 1,659
 Submitted Links 0
 Member Title Member
 Age 28 years old
 Birthday November 6, 1987

Gender
Male

Interests
C++ / C / Opengl /Directx / SQL
141
Learning
User Tools
Latest Visitors
#4972750 C++: problem erasing vector items
Posted by Exessuz on 23 August 2012  03:09 PM
try something like this, havent t
#4972716 Raycasting
Posted by Exessuz on 23 August 2012  01:42 PM
I think you should try with ray / plane collision , for example an Axis Aligned box or a OOB
the idea is to cast a ray from the eye or from a click point and check if the ray intersect the plane
a ray is defined by
P= Ro + (Rd*t)
Ro = camera eye for example
Rd = ray dir;
t = distance or time
and a plane (P  Po). n = 0
n = plane normal
(Ro + Rd.t  Po).n = 0
Rd.t.n + (Ro  Po).n = 0
t = (Po  Ro)n / Rd.n
If the line starts outside the plane and is parallel to the plane, there is no intersection. In this case, the above denominator will be zero and the numerator will be nonzero. If the line starts inside the plane and is parallel to the plane, the line intersects the plane everywhere. In this case, both the numerator and denominator above will be zero. In all other cases, the line intersects the plane once and t represents the intersection as the distance along the line from Ro
the idea is to cast a ray from the eye or from a click point and check if the ray intersect the plane
a ray is defined by
P= Ro + (Rd*t)
Ro = camera eye for example
Rd = ray dir;
t = distance or time
and a plane (P  Po). n = 0
n = plane normal
(Ro + Rd.t  Po).n = 0
Rd.t.n + (Ro  Po).n = 0
t = (Po  Ro)n / Rd.n
If the line starts outside the plane and is parallel to the plane, there is no intersection. In this case, the above denominator will be zero and the numerator will be nonzero. If the line starts inside the plane and is parallel to the plane, the line intersects the plane everywhere. In this case, both the numerator and denominator above will be zero. In all other cases, the line intersects the plane once and t represents the intersection as the distance along the line from Ro
#4972705 Map Coordinates
Posted by Exessuz on 23 August 2012  01:04 PM
if you want to make a 10 x 10 map , lets say that each tile is 32 x 32 px
i used to make a linear array holding all the tile ids
int width = 32;
short map[100]; > 10x10
supposing that you are drawing Y first
for(int x =0 ; x < 10; x++){
for(int y =0 ; y < 10; y++){
RENDER()
}
}
int x = click.x / 32;
int y = click.y / 32;
then the tile is
int id = x*width + y;
map[id].selected;
i used to make a linear array holding all the tile ids
int width = 32;
short map[100]; > 10x10
supposing that you are drawing Y first
for(int x =0 ; x < 10; x++){
for(int y =0 ; y < 10; y++){
RENDER()
}
}
int x = click.x / 32;
int y = click.y / 32;
then the tile is
int id = x*width + y;
map[id].selected;