コード例 #1
0
ファイル: med.c プロジェクト: CDarrow/DXX-Retro
//sets the player facing curseg/curside, normal to face0 of curside, and
//far enough away to see all of curside
int SetPlayerFromCursegMinusOne()
{
	vms_vector view_vec,view_vec2,side_center;
	vms_vector corner_v[4];
	vms_vector	upvec;
	g3s_point corner_p[4];
	int i;
	fix max,view_dist=f1_0*10;
        static int edgenum=0;
	int newseg;

	view_vec = Cursegp->sides[Curside].normals[0];
	vm_vec_negate(&view_vec);

	compute_center_point_on_side(&side_center,Cursegp,Curside);
	vm_vec_copy_scale(&view_vec2,&view_vec,view_dist);
	vm_vec_sub(&ConsoleObject->pos,&side_center,&view_vec2);

	vm_vec_sub(&upvec, &Vertices[Cursegp->verts[Side_to_verts[Curside][edgenum%4]]], &Vertices[Cursegp->verts[Side_to_verts[Curside][(edgenum+3)%4]]]);
	edgenum++;

	vm_vector_2_matrix(&ConsoleObject->orient,&view_vec,&upvec,NULL);

	gr_set_current_canvas(Canv_editor_game);
	g3_start_frame();
	g3_set_view_matrix(&ConsoleObject->pos,&ConsoleObject->orient,Render_zoom);

	for (i=max=0;i<4;i++) {
		corner_v[i] = Vertices[Cursegp->verts[Side_to_verts[Curside][i]]];
		g3_rotate_point(&corner_p[i],&corner_v[i]);
		if (labs(corner_p[i].p3_x) > max) max = labs(corner_p[i].p3_x);
		if (labs(corner_p[i].p3_y) > max) max = labs(corner_p[i].p3_y);
	}

	view_dist = fixmul(view_dist,fixdiv(fixdiv(max,SIDE_VIEW_FRAC),corner_p[0].p3_z));
	vm_vec_copy_scale(&view_vec2,&view_vec,view_dist);
	vm_vec_sub(&ConsoleObject->pos,&side_center,&view_vec2);

	//obj_relink(ConsoleObject-Objects, SEG_PTR_2_NUM(Cursegp) );
	//update_object_seg(ConsoleObject);		//might have backed right out of curseg

	newseg = find_point_seg(&ConsoleObject->pos,SEG_PTR_2_NUM(Cursegp) );
	if (newseg != -1)
		obj_relink(ConsoleObject-Objects,newseg);

	Update_flags |= UF_ED_STATE_CHANGED | UF_GAME_VIEW_CHANGED;
	return 1;
}
コード例 #2
0
ファイル: med.c プロジェクト: paud/d2x-xl
//sets the player facing curseg/curside, normal to face0 of curside, and
//far enough away to see all of curside
int SetPlayerFromCursegMinusOne()
{
	vms_vector view_vec,view_vec2,side_center;
	vms_vector corner_v[4];
	vms_vector	upvec;
	g3s_point corner_p[4];
	int i;
	fix max,view_dist=f1_0*10;
        static int edgenum=0;
	int newseg;

	view_vec = Cursegp->sides[Curside].normals[0];
	VmVecNegate(&view_vec);

	COMPUTE_SIDE_CENTER(&side_center,Cursegp,Curside);
	VmVecCopyScale(&view_vec2,&view_vec,view_dist);
	VmVecSub(&gameData.objs.console->pos,&side_center,&view_vec2);

	VmVecSub(&upvec, &gameData.segs.vertices[Cursegp->verts[sideToVerts[Curside][edgenum%4]]], &gameData.segs.vertices[Cursegp->verts[sideToVerts[Curside][(edgenum+3)%4]]]);
	edgenum++;

	VmVector2Matrix(&gameData.objs.console->orient,&view_vec,&upvec,NULL);

	GrSetCurrentCanvas(Canv_editor_game);
	G3StartFrame();
	G3SetViewMatrix(&gameData.objs.console->pos,&gameData.objs.console->orient,nRenderZoom);

	for (i=max=0;i<4;i++) {
		corner_v[i] = gameData.segs.vertices[Cursegp->verts[sideToVerts[Curside][i]]];
		G3TransformAndEncodePoint(&corner_p[i],&corner_v[i]);
		if (labs(corner_p[i].p3_x) > max) max = labs(corner_p[i].p3_x);
		if (labs(corner_p[i].p3_y) > max) max = labs(corner_p[i].p3_y);
	}

	view_dist = fixmul(view_dist,fixdiv(fixdiv(max,SIDE_VIEW_FRAC),corner_p[0].p3_z);
	VmVecCopyScale(&view_vec2,&view_vec,view_dist);
	VmVecSub(&gameData.objs.console->pos,&side_center,&view_vec2);

	//RelinkObject(OBJ_IDX (gameData.objs.console), SEG_PTR_2_NUM(Cursegp) );
	//UpdateObjectSeg(gameData.objs.console);		//might have backed right out of curseg

	newseg = FindSegByPoint(&gameData.objs.console->pos,SEG_PTR_2_NUM(Cursegp) );
	if (newseg != -1)
		RelinkObject(OBJ_IDX (gameData.objs.console),newseg);

	Update_flags |= UF_ED_STATE_CHANGED | UF_GAME_VIEW_CHANGED;
	return 1;
}
コード例 #3
0
ファイル: med.c プロジェクト: CDarrow/DXX-Retro
void move_player_2_segment_and_rotate(segment *seg,int side)
{
	vms_vector vp;
	vms_vector	upvec;
        static int edgenum=0;

	compute_segment_center(&ConsoleObject->pos,seg);
	compute_center_point_on_side(&vp,seg,side);
	vm_vec_sub2(&vp,&ConsoleObject->pos);

	vm_vec_sub(&upvec, &Vertices[Cursegp->verts[Side_to_verts[Curside][edgenum%4]]], &Vertices[Cursegp->verts[Side_to_verts[Curside][(edgenum+3)%4]]]);
	edgenum++;

	vm_vector_2_matrix(&ConsoleObject->orient,&vp,&upvec,NULL);
//	vm_vector_2_matrix(&ConsoleObject->orient,&vp,NULL,NULL);

	obj_relink( ConsoleObject-Objects, SEG_PTR_2_NUM(seg) );
	
}
コード例 #4
0
ファイル: med.c プロジェクト: paud/d2x-xl
void move_player_2_segment_and_rotate(segment *seg,int side)
{
	vms_vector vp;
	vms_vector	upvec;
        static int edgenum=0;

	COMPUTE_SEGMENT_CENTER(&gameData.objs.console->pos,seg);
	COMPUTE_SIDE_CENTER(&vp,seg,side);
	VmVecDec(&vp,&gameData.objs.console->pos);

	VmVecSub(&upvec, &gameData.segs.vertices[Cursegp->verts[sideToVerts[Curside][edgenum%4]]], &gameData.segs.vertices[Cursegp->verts[sideToVerts[Curside][(edgenum+3)%4]]]);
	edgenum++;

	VmVector2Matrix(&gameData.objs.console->orient,&vp,&upvec,NULL);
//	VmVector2Matrix(&gameData.objs.console->orient,&vp,NULL,NULL);

	RelinkObject( OBJ_IDX (gameData.objs.console), SEG_PTR_2_NUM(seg) );
	
}
コード例 #5
0
ファイル: meddraw.c プロジェクト: Ringdingcoder/d1x
//for looking for segment under a mouse click
void check_segment(segment *seg)
{
	short	*svp;
	int	nv;
	g3s_codes cc;

	med_get_vertex_list(seg,&nv,&svp);				// set nv = number of vertices, svp = pointer to vertex indices
	cc=rotate_list(nv,svp);

	if (! cc.and) {		//all off screen?
		int fn;

		gr_setcolor(0);
		gr_pixel(Search_x,Search_y);	//set our search pixel to color zero
		gr_setcolor(1);					//and render in color one

		for (fn=0;fn<6;fn++) {
			g3s_point *vert_list[4];
			
			vert_list[0] = &Segment_points[seg->verts[Side_to_verts[fn][0]]];
			vert_list[1] = &Segment_points[seg->verts[Side_to_verts[fn][1]]];
			vert_list[2] = &Segment_points[seg->verts[Side_to_verts[fn][2]]];
			g3_check_and_draw_poly(3,vert_list,NULL,NULL);

			vert_list[1] = &Segment_points[seg->verts[Side_to_verts[fn][2]]];
			vert_list[2] = &Segment_points[seg->verts[Side_to_verts[fn][3]]];
			g3_check_and_draw_poly(3,vert_list,NULL,NULL);

		}

		if (gr_ugpixel(&grd_curcanv->cv_bitmap,Search_x,Search_y) == 1)
                 {
			if (N_found_segs < MAX_FOUND_SEGS)
				Found_segs[N_found_segs++] = SEG_PTR_2_NUM(seg);
			else
				Warning("Found too many segs! (limit=%d)",MAX_FOUND_SEGS);
                 }
	}
}
コード例 #6
0
ファイル: meddraw.c プロジェクト: Ringdingcoder/d1x
//draws an entire mine
void draw_mine(segment *mine_ptr,int depth)
{
	int	i;

	// clear visited list
	for (i=0; i<=Highest_segment_index; i++)
		Been_visited[i] = 0;

	edge_list_size = min(Num_vertices*4,MAX_EDGES);		//make maybe smaller than max

	// clear edge list
	for (i=0; i<edge_list_size; i++) {
		edge_list[i].type = ET_EMPTY;
		edge_list[i].face_count = 0;
		edge_list[i].backface_count = 0;
	}

	n_used = 0;

	draw_mine_sub(SEG_PTR_2_NUM(mine_ptr),depth);

	draw_mine_edges(0);

}