3d Editor , those little grab tags thingys

Blitz3D Forums/Blitz3D Programming/3d Editor , those little grab tags thingys

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

For this I'd recommend using CameraProject and drawing the rectangle in a 2D way. That way you dont need to worry about scaling or resizing. Here's some dummy code:

Graphics3D 640, 480
SetBuffer BackBuffer()

Global cam = CreateCamera()
Global cube = CreateCube()
RotateEntity cube, 0, 45, 30

Repeat
	If KeyDown(200) TurnEntity cube, 0, 0, 1
	If KeyDown(208) TurnEntity cube, 0, 0, -1

	RenderWorld
	Color 255, 0, 0
	BoxMesh( cam, cube )
	Flip
Until KeyHit(1)

; BoxMesh function (BlitzSupport's code)
; Available from code archives with example code.

Function BoxMesh (usecam, mesh)
	If EntityInView (mesh, usecam)
		largestx = 0: largesty = 0
		gw = GraphicsWidth (): gh = GraphicsHeight ()
		smallestx = gw: smallesty = gh
		For s = 1 To CountSurfaces (mesh)
			surf = GetSurface (mesh, s)
			For vert = 0 To CountVertices (surf) - 1
				vx# = VertexX (surf, vert)
				vy# = VertexY (surf, vert)
				vz# = VertexZ (surf, vert)
				TFormPoint (vx, vy, vz, mesh, 0)
				CameraProject usecam, TFormedX (), TFormedY (), TFormedZ ()
				vx2 = ProjectedX ()
				vy2 = ProjectedY ()
				If vx2 > largestx
					largestx = vx2
				Else
					If vx2 < smallestx
						smallestx = vx2
					EndIf
				EndIf
				If vy2 > largesty
					largesty = vy2
				Else
					If vy2 < smallesty
						smallesty = vy2
					EndIf
				EndIf
			Next
		Next
		If smallestx < 0 Then smallestx = 0
		If smallesty < 0 Then smallesty = 0
		If largestx > gw Then largestx = gw
		If largesty > gh Then largesty = gh
		Rect smallestx, smallesty, largestx - smallestx, largesty - smallesty, False
	EndIf
End Function