本文整理汇总了C++中Matrix32::translate方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix32::translate方法的具体用法?C++ Matrix32::translate怎么用?C++ Matrix32::translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix32
的用法示例。
在下文中一共展示了Matrix32::translate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: size
//.........这里部分代码省略.........
float ptime = ((float)i / particle_count)*explosiveness;
if (ptime<time_pos)
ptime=time_pos-ptime;
else
ptime=(1.0-ptime)+time_pos;
uint32_t rand_seed=p.seed*(i+1);
Color color;
if(color_ramp.is_valid())
{
color = color_ramp->get_color_at_offset(ptime);
} else
{
color = default_color;
}
{
float huerand=_rand_from_seed(&rand_seed);
float huerot = param[PARAM_HUE_VARIATION] + randomness[PARAM_HUE_VARIATION] * huerand;
if (Math::abs(huerot) > CMP_EPSILON) {
float h=color.get_h();
float s=color.get_s();
float v=color.get_v();
float a=color.a;
//float preh=h;
h+=huerot;
h=Math::abs(Math::fposmod(h,1.0));
//print_line("rand: "+rtos(randomness[PARAM_HUE_VARIATION])+" rand: "+rtos(huerand));
//print_line(itos(i)+":hue: "+rtos(preh)+" + "+rtos(huerot)+" = "+rtos(h));
color.set_hsv(h,s,v);
color.a=a;
}
}
float initial_size = param[PARAM_INITIAL_SIZE]+param[PARAM_INITIAL_SIZE]*_rand_from_seed(&rand_seed)*randomness[PARAM_FINAL_SIZE];
float final_size = param[PARAM_FINAL_SIZE]+param[PARAM_FINAL_SIZE]*_rand_from_seed(&rand_seed)*randomness[PARAM_FINAL_SIZE];
float size_mult=initial_size*(1.0-ptime) + final_size*ptime;
//Size2 rectsize=size * size_mult;
//rectsize=rectsize.floor();
//Rect2 r = Rect2(Vecto,rectsize);
Matrix32 xform;
if (p.rot) {
xform.set_rotation(p.rot);
xform.translate(-size*size_mult/2.0);
xform.elements[2]+=p.pos;
} else {
xform.elements[2]=-size*size_mult/2.0;
xform.elements[2]+=p.pos;
}
if (!local_space) {
xform = invxform * xform;
}
xform.scale_basis(Size2(size_mult,size_mult));
VisualServer::get_singleton()->canvas_item_add_set_transform(ci,xform);
if (texrid.is_valid()) {
Rect2 src_rect;
src_rect.size=size;
if (total_frames>1) {
int frame = Math::fast_ftoi(Math::floor(p.frame*total_frames)) % total_frames;
src_rect.pos.x = size.x * (frame%h_frames);
src_rect.pos.y = size.y * (frame/h_frames);
}
texture->draw_rect_region(ci,Rect2(Point2(),size),src_rect,color);
//VisualServer::get_singleton()->canvas_item_add_texture_rect(ci,r,texrid,false,color);
} else {
VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(Point2(),size),color);
}
}
} break;
}
}
示例2: dcol
void RayCast2D::_notification(int p_what) {
switch(p_what) {
case NOTIFICATION_ENTER_TREE: {
if (enabled && !get_tree()->is_editor_hint())
set_fixed_process(true);
else
set_fixed_process(false);
} break;
case NOTIFICATION_EXIT_TREE: {
if (enabled)
set_fixed_process(false);
} break;
#ifdef TOOLS_ENABLED
case NOTIFICATION_DRAW: {
if (!get_tree()->is_editor_hint())
break;
Matrix32 xf;
xf.rotate(cast_to.atan2());
xf.translate(Vector2(0,cast_to.length()));
//Vector2 tip = Vector2(0,s->get_length());
Color dcol(0.9,0.2,0.2,0.4);
draw_line(Vector2(),cast_to,dcol,3);
Vector<Vector2> pts;
float tsize=4;
pts.push_back(xf.xform(Vector2(0,tsize)));
pts.push_back(xf.xform(Vector2(0.707*tsize,0)));
pts.push_back(xf.xform(Vector2(-0.707*tsize,0)));
Vector<Color> cols;
for(int i=0;i<3;i++)
cols.push_back(dcol);
draw_primitive(pts,cols,Vector<Vector2>()); //small arrow
} break;
#endif
case NOTIFICATION_FIXED_PROCESS: {
if (!enabled)
break;
Ref<World2D> w2d = get_world_2d();
ERR_BREAK( w2d.is_null() );
Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(w2d->get_space());
ERR_BREAK( !dss );
Matrix32 gt = get_global_transform();
Vector2 to = cast_to;
if (to==Vector2())
to=Vector2(0,0.01);
Physics2DDirectSpaceState::RayResult rr;
if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude,layer_mask)) {
collided=true;
against=rr.collider_id;
collision_point=rr.position;
collision_normal=rr.normal;
against_shape=rr.shape;
} else {
collided=false;
}
} break;
}
}
示例3:
void RayCast2D::_notification(int p_what) {
switch(p_what) {
case NOTIFICATION_ENTER_TREE: {
if (enabled && !get_tree()->is_editor_hint())
set_fixed_process(true);
else
set_fixed_process(false);
if (get_parent()->cast_to<PhysicsBody2D>()) {
if (exclude_parent_body)
exclude.insert( get_parent()->cast_to<PhysicsBody2D>()->get_rid() );
else
exclude.erase( get_parent()->cast_to<PhysicsBody2D>()->get_rid() );
}
} break;
case NOTIFICATION_EXIT_TREE: {
if (enabled)
set_fixed_process(false);
} break;
case NOTIFICATION_DRAW: {
if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
break;
Matrix32 xf;
xf.rotate(cast_to.angle());
xf.translate(Vector2(0,cast_to.length()));
//Vector2 tip = Vector2(0,s->get_length());
Color dcol=get_tree()->get_debug_collisions_color();//0.9,0.2,0.2,0.4);
draw_line(Vector2(),cast_to,dcol,3);
Vector<Vector2> pts;
float tsize=4;
pts.push_back(xf.xform(Vector2(0,tsize)));
pts.push_back(xf.xform(Vector2(0.707*tsize,0)));
pts.push_back(xf.xform(Vector2(-0.707*tsize,0)));
Vector<Color> cols;
for(int i=0;i<3;i++)
cols.push_back(dcol);
draw_primitive(pts,cols,Vector<Vector2>()); //small arrow
} break;
case NOTIFICATION_FIXED_PROCESS: {
if (!enabled)
break;
_update_raycast_state();
} break;
}
}