本文整理汇总了C++中Transformable类的典型用法代码示例。如果您正苦于以下问题:C++ Transformable类的具体用法?C++ Transformable怎么用?C++ Transformable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Transformable类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(Transformable_objects, have_a_left_and_right_direction_along_the_x_axis)
{
Transformable t;
EXPECT_EQ( Transformable::X_AXIS, t.left());
EXPECT_EQ(-Transformable::X_AXIS, t.right());
}
示例2: unserialize
unsigned long Serialization::unserialize(const std::vector<char> &buf, Transformable &tr_data, unsigned long start_loc)
{
// delete all existing items
tr_data.clear();
unsigned long names_arg_sz;
unsigned long n_rec;
unsigned long bytes_read;
size_t i_start = 0;
// get size of names record
i_start = start_loc;
w_memcpy_s(&names_arg_sz, sizeof(names_arg_sz), buf.data()+i_start, sizeof(names_arg_sz));
i_start += sizeof(names_arg_sz);
unique_ptr<char[]> names_buf(new char[names_arg_sz]);
w_memcpy_s(names_buf.get(), sizeof(char)*names_arg_sz, buf.data()+i_start, sizeof(char)*names_arg_sz);
i_start += sizeof(char)*names_arg_sz;
w_memcpy_s(&n_rec, sizeof(n_rec), buf.data()+i_start, sizeof(n_rec));
i_start += sizeof(n_rec);
// build transformable data set
double *value_ptr = (double *) ( buf.data()+i_start);
vector<string> names_vec;
tokenize(strip_cp(string(names_buf.get(), names_arg_sz)), names_vec);
assert(names_vec.size() == n_rec);
for (unsigned long i=0; i< n_rec; ++i)
{
tr_data.insert(names_vec[i], *(value_ptr+i));
}
bytes_read = i_start + n_rec * sizeof(double);
return bytes_read;
}
示例3: rayGridIntersections
CollisionEvent CollisionGrid::cast(const ray& r, CollisionObject* ignore) {
CollisionEvent e;
e.intersected = false;
std::list<vec2> grid_list;
rayGridIntersections(r, grid_list);
for(std::list<vec2>::iterator g = grid_list.begin(); g != grid_list.end(); g++) {
int len = grid_list.size();
int x = (*g)[0];
int y = (*g)[1];
if(x < 0) continue;
if(x >= size_x) continue;
if(y < 0) continue;
if(y >= size_y) continue;
std::list<CollisionObject*>& lst = grid[x+y*size_x];
for(std::list<CollisionObject*>::iterator obj = lst.begin(); obj != lst.end(); obj++) {
if(ignore == (*obj)) continue;
Transformable* t = (Transformable*)((*obj)->script)->getLink(LINK_TRANSFORMABLE);
vec3 p = t->getPosition();
float radius = (*obj)->radius;
vec2 closestP;
float distance;
if(!rayCircleIntersection(r, vec2(p[0], p[2]), radius, closestP, distance)) {
continue;
} else {
e.distance = distance;
e.intersected = true;
e.obj_script = (*obj)->script;
e.obj_type = (*obj)->type;
return e;
}
}
}
return e;
}
示例4:
Transformable
ServerFont::EmbeddedTransformation() const
{
// TODO: cache this?
Transformable transform;
transform.ShearBy(B_ORIGIN, (90.0 - fShear) * M_PI / 180.0, 0.0);
transform.RotateBy(B_ORIGIN, -fRotation * M_PI / 180.0);
return transform;
}
示例5: reverse
void TranScale::reverse(Transformable &data)
{
Transformable::iterator data_iter, data_end = data.end();
for (map<string,double>::const_iterator b=items.begin(), e=items.end();
b!=e; ++b) {
data_iter = data.find(b->first);
if (data_iter != data_end)
{
(*data_iter).second /= b->second;
}
}
}
示例6: forward
///////////////// TranOffset Methods /////////////////
void TranOffset::forward(Transformable &data)
{
Transformable::iterator data_iter, data_end = data.end();
for (map<string,double>::const_iterator b=items.begin(), e=items.end();
b!=e; ++b) {
data_iter = data.find(b->first);
if (data_iter != data_end)
{
(*data_iter).second += (*b).second;
}
}
}
示例7: pow
void TranLog10::reverse(Transformable &data)
{
Transformable::iterator data_iter, data_end = data.end();
for (set<string>::const_iterator b=items.begin(), e=items.end(); b!=e; ++b)
{
data_iter = data.find(*b);
if (data_iter != data_end)
{
(*data_iter).second = pow(10.0, (*data_iter).second);
}
}
}
示例8:
// BoundingBox
BRect
Painter::BoundingBox(const char* utf8String, uint32 length,
const BPoint& baseLine) const
{
Transformable transform;
transform.TranslateBy(baseLine);
BRect dummy;
return fTextRenderer->RenderString(utf8String,
length,
fFontRendererSolid,
fFontRendererBin,
transform, dummy, true);
}
示例9:
void
VectorPath::ApplyTransform(const Transformable& transform)
{
if (transform.IsIdentity())
return;
for (int32 i = 0; i < fPointCount; i++) {
transform.Transform(&(fPath[i].point));
transform.Transform(&(fPath[i].point_out));
transform.Transform(&(fPath[i].point_in));
}
_NotifyPathChanged();
}
示例10: add
void CollisionGrid::add(Script* script, int type, float radius) {
Transformable* t = (Transformable*)script->getLink(LINK_TRANSFORMABLE);
if(!t) return;
vec3 pos = t->getPosition();
int x = pos[0], y = pos[2];
CollisionObject* obj = new CollisionObject;
obj->script = script;
obj->type = type;
obj->radius = radius;
objects.push_back(obj);
script->setCollisionObject(obj);
update(0.f);
}
示例11: update
void CollisionGrid::update(float frameDelta) {
//if(!grid) return;
for(boost::unordered_map<int, std::list<CollisionObject*> >::iterator lst = grid.begin(); lst != grid.end(); lst++) {
lst->second.clear();
}
// memset(walk_grid, 0, sizeof(bool)*size_x*size_y);
for(std::list<CollisionObject*>::iterator obj = objects.begin(); obj != objects.end(); obj++) {
Transformable* t = (Transformable*)((*obj)->script->getLink(LINK_TRANSFORMABLE));
vec3 p = t->getPosition();
float r = (*obj)->radius;
int x = p[0], y = p[2];
walk_grid[x+y*size_x] = 1;
grid[x+y*size_x].push_back(*obj);
}
}