//----------------------------------------------------------------------------------------------------------------------------------------
void NebuRayon::UpdateFrame(Ufloat step) {
    OneNebuRayon*   tmp = AllRayon;
    CoordU3D        pt1,pt2;
    Camera*         cam = U3D3Monde3D->GetActualCamera();
    Ufloat          RVBA[2][4];
    Ufloat          intensity;
    Ufloat          APintensity;

    APintensity = 1.0f - TimeToGo / TotalTime;

    vec4_set(RVBA[0], .5f, .5f, .5f, 1.0f);
    vec4_set(RVBA[1], .1f, .1f, .1f, 1.0f);

    U3D3Pipeline->Begin(MatTranspAddAlpha);

    for (U32 a=0; a<NB_RAYON; a++,tmp++) {
        if (!tmp->Move(step*APintensity))
            tmp->Ini();

        pt1.frame_process = -1;
        pt2.frame_process = -1;
        tmp->GetVal(pt1.trans, pt2.trans, intensity);

        vec4_set(RVBA[0], intensity, intensity, intensity, APintensity);
        vec4_set(RVBA[1], intensity*.2f, intensity*.2f, intensity*.2f, APintensity);

        U3D3Pipeline->AfficheLigneFromEngine(&pt1, &pt2, RVBA);
    }

    U3D3Pipeline->End(NULL);


    TimeToGo -= step;
    if (TimeToGo < 0.0f) TimeToGo = 0.0f;
}
Exemple #2
0
/* copies a ray into another ray */
ray_t* ray_copy(ray_t *rayout, const ray_t *ray)
{
	vec4_set(&rayout->direction, (float *)&ray->direction);
	vec4_set(&rayout->origin, (float *)&ray->origin);
	rayout->magnitude = ray->magnitude;

	return rayout;
}
static inline void render_display_begin(struct obs_display *display)
{
	struct vec4 clear_color;

	gs_load_swapchain(display ? display->swap : NULL);

	if (display->size_changed) {
		gs_resize(display->cx, display->cy);
		display->size_changed = false;
	}

	gs_beginscene();

	vec4_set(&clear_color, 0.3f, 0.3f, 0.3f, 1.0f);
	gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH | GS_CLEAR_STENCIL,
			&clear_color, 1.0f, 0);

	gs_enable_depthtest(false);
	/* gs_enable_blending(false); */
	gs_setcullmode(GS_NEITHER);

	gs_ortho(0.0f, (float)display->cx,
			0.0f, (float)display->cy, -100.0f, 100.0f);
	gs_setviewport(0, 0, display->cx, display->cy);
}
Exemple #4
0
static inline void render_main_texture(struct obs_core_video *video,
		int cur_texture)
{
	profile_start(render_main_texture_name);

	struct vec4 clear_color;
	vec4_set(&clear_color, 0.0f, 0.0f, 0.0f, 1.0f);

	gs_set_render_target(video->render_textures[cur_texture], NULL);
	gs_clear(GS_CLEAR_COLOR, &clear_color, 1.0f, 0);

	set_render_size(video->base_width, video->base_height);

	pthread_mutex_lock(&obs->data.draw_callbacks_mutex);

	for (size_t i = 0; i < obs->data.draw_callbacks.num; i++) {
		struct draw_callback *callback;
		callback = obs->data.draw_callbacks.array+i;

		callback->draw(callback->param,
				video->base_width, video->base_height);
	}

	pthread_mutex_unlock(&obs->data.draw_callbacks_mutex);

	obs_view_render(&obs->data.main_view);

	video->textures_rendered[cur_texture] = true;

	profile_end(render_main_texture_name);
}
//----------------------------------------------------------------------------------------------------------------------------------------
void CoupleOnePetals3D::IncAnim(Ufloat laptime) {
    Mat3x4  mat;
    Ufloat  tmp[3];

    CalcPos(laptime);

    Ufloat alpha = GetAlpha();

    vec4_set(p1->RVBA, 1.0f, 1.0f, 1.0f, alpha);
    vec4_set(p2->RVBA, 1.0f, 1.0f, 1.0f, alpha);

    rot *= incrot * laptime;
    rot.matrix(mat);
    vec3_mul(tmp, GetPos(), FACT_SCENE_CM);
    mat.SetPos(tmp[0], tmp[1], tmp[2]);

    for (U32 a=0; a<6; a++)
        mat.GetTransfo(coord[a]->trans, coord[a]->origine);
}
Exemple #6
0
/* create a ray from two points [p1 -> p2] (vector4_t under the hood) */
ray_t* ray_create(ray_t *rayout, const point_t *p1, const point_t *p2)
{
	/* origin of ray is point 1 */
	vec4_set(&rayout->origin, (float *)p1);
	/* get vector from point 1 to point 2 */
	vec4_sub(&rayout->direction, p2, p1);
	/* get magnitude of vector we just created */
	rayout->magnitude = vec4_magnitude(&rayout->direction);
	/* normalize the vector this way to prevent duplicate work */
	vec4_scale(&rayout->direction, &rayout->direction, 1.0f / rayout->magnitude);

	return rayout;
}
Exemple #7
0
static inline void render_main_texture(struct obs_core_video *video,
		int cur_texture)
{
	struct vec4 clear_color;
	vec4_set(&clear_color, 0.0f, 0.0f, 0.0f, 1.0f);

	gs_set_render_target(video->render_textures[cur_texture], NULL);
	gs_clear(GS_CLEAR_COLOR, &clear_color, 1.0f, 0);

	set_render_size(video->base_width, video->base_height);
	obs_view_render(&obs->data.main_view);

	video->textures_rendered[cur_texture] = true;
}
Exemple #8
0
/* this function is needed for a serious hack that I really
 * hate doing.  R.I.P. clean code R.I.P. */
ray_t* ray_tinypush(ray_t *rayout, const ray_t *ray)
{
	vector4_t v;
	vec4_set(&v, (float *)&ray->direction);
	/* make sure direction was normalized */
	vec4_normalize(&v);
	/* create a tiny displacement vector along direction */
	vec4_scale(&v, &v, 0.001f);
	/* copy the ray */
	ray_copy(rayout, ray);
	/* display the new rays origin */
	vec4_add(&rayout->origin, &rayout->origin, &v);

	return rayout;
}
//----------------------------------------------------------------------------------------------------------------------------------------
void CoupleShadowP3D::IncAnim(Ufloat laptime) {
    Mat3x4  mat;
    Ufloat  tmp[3]= {0.0f,1.0f,0.0f};
    Ufloat  alpha = petal->GetAlpha();

    vec4_set(p1->RVBA, 1.0f, 1.0f, 1.0f, alpha);

    petal->GetQuat().matrix(mat);
    vec3_mul(tmp, petal->GetPos(), FACT_SCENE_CM);
    mat.SetPos(tmp[0], tmp[1], tmp[2]);
    mat *= petal->GetMass() + tmp[1]*.001f;


    for (U32 a=0; a<4; a++) {
        mat.GetTransfo(p1->Vtab[a]->c->trans, p1->Vtab[a]->c->origine);
        p1->Vtab[a]->c->trans[1] = 0.0f;
    }
}
Exemple #10
0
static inline void render_begin(struct obs_display *display)
{
	struct vec4 clear_color;
	uint32_t width, height;

	gs_load_swapchain(display ? display->swap : NULL);

	gs_getsize(&width, &height);

	gs_beginscene();
	vec4_set(&clear_color, 0.3f, 0.0f, 0.0f, 1.0f);
	gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH | GS_CLEAR_STENCIL,
			&clear_color, 1.0f, 0);

	gs_enable_depthtest(false);
	/* gs_enable_blending(false); */
	gs_setcullmode(GS_NEITHER);

	gs_ortho(0.0f, (float)width, 0.0f, (float)height, -100.0f, 100.0f);
	gs_setviewport(0, 0, width, height);
}
void OBSBasicPreview::DrawSceneEditing()
{
	OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());

	effect_t    solid = obs_get_solid_effect();
	technique_t tech  = effect_gettechnique(solid, "Solid");

	vec4 color;
	vec4_set(&color, 1.0f, 0.0f, 0.0f, 1.0f);
	effect_setvec4(solid, effect_getparambyname(solid, "color"), &color);

	technique_begin(tech);
	technique_beginpass(tech, 0);

	OBSScene scene = main->GetCurrentScene();
	if (scene)
		obs_scene_enum_items(scene, DrawSelectedItem, this);

	gs_load_vertexbuffer(nullptr);

	technique_endpass(tech);
	technique_end(tech);
}
Exemple #12
0
inline void urand_sphere(Sampler *s, float r, Vector4 *out) {
    float u = urand(s), v = urand(s), theta = TWO_PI * u, phi = acos(2 * v - 1),
            sphi = sin(phi);
    vec4_set(out, r * cos(theta) * sphi, r * cos(phi), r * sin(theta) * sphi, 1.0f);
}
//----------------------------------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                  +---------------------------+
//                                  |  Class OneNebuParticule   |
//                                  +---------------------------+
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------------------------
OneNebuParticule::OneNebuParticule() {
    PosKeyFileU3D   allKey[11];
    Ufloat          disttmp;
    Ufloat          ydectmp;

    Ufloat  dist = (NEBU_RAYON /*- BIGPART_SIZE*.5f*/) * Random1()  + BIGPART_SIZE;
    Ufloat  angle = 2.f * M_PI * Random1();
    dist = .6f*dist + NEBU_RAYON*0.4f * sin(angle * 2.f * M_PI);
    Ufloat  anglespeed = ((1.0f - dist / NEBU_RAYON)* 30.f + 10.f) * .0174532925f;
    Ufloat  fact = 1.0f - dist / NEBU_RAYON;

    //-------------------- calcul decalage en Y
    Ufloat ydec = dist;
    if (ydec > 900.f)   ydec = 900.f;
    ydec = 350.f * (.5f + .5f*cos(M_PI * ydec / 900.f)) + 50.f * Random1() * (1.0f - dist /NEBU_RAYON);
    if (Random1()>.5f) ydec = -ydec;

    //------------------- calcul les déplacements
    for (U32 a=0; a<11; a++) {
        allKey[a].k.Ini();

        if (a< 6)
            allKey[a].k.time = (U32)(FRAMEPERSECOND* (a*5.f + 2.f*Random1() - 1.f));
        else if (a== 6)
            allKey[a].k.time = (U32)(FRAMEPERSECOND* (28.f + 1.f*Random1()));
        else if (a== 7)
            allKey[a].k.time = (U32)(FRAMEPERSECOND* (29.f + 1.f*Random1()));
        else if (a== 8)
            allKey[a].k.time = (U32)(FRAMEPERSECOND* (30.f + 1.f*Random1()));
        else if (a== 9)
            allKey[a].k.time = (U32)(FRAMEPERSECOND* (31.f + 1.f*Random1()));
        else if (a== 10)
            allKey[a].k.time = (U32)(FRAMEPERSECOND* (32.f + 1.f*Random1()));

        disttmp = dist + NEBU_RAYON*.05f * Random1() - NEBU_RAYON*.025f;
        ydectmp = ydec + ydec * .1f * Random1() - ydec * .05f;

        vec3_set(allKey[a].p, disttmp * cos(-angle) + BIGPART_X ,
                 ydectmp + BIGPART_Y,
                 disttmp * sin(-angle) + BIGPART_Z);

        switch (a) {
        case 7:
        case 8:
        case 9:
        case 10:
            angle += anglespeed*.6f /*+ .08f * Random1() - .04f*/;
            dist *= .9;
            break;

        default:
            angle += anglespeed + .14f * Random1() - .07f;
            break;
        }
    }

    //-------------------- alloue et calcul la spline
    mouvement = new SplineU3D(allKey, 11);

    //-------------------- calcul taille et couleur
    size = PART_SIZE_MIN + PART_SIZE_RND * Random1();
    vec4_set(RVBA, PART_RFACT*(1.f-fact) + fact, PART_VFACT*(1.f-fact) + fact, PART_BFACT*(1.f-fact) + fact, 0.6f);
    vec3_mul(RVBA, RVBA, Random1()*(1.f-fact) + fact);
}