3d Editor , those little grab tags thingys

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

MattG(Posted 2004) [#1]
Ok you know in all other 3d editors when you select an object little square boxes appear where you can strech/move etc... what would be a good way to implement them ... i am not intrested in how to get them strech/move ... but should i use a 3d sprite ? 2d image ?
As i heard doing 2d stuff and 3d stuff is not the way to go.

any helpfull hints will be welcomed

thanks

Matt
www.16vmini.co.uk/rtc


MattG(Posted 2004) [#2]
after more thinking i guess i will have to use 2d images ? as at the moment my editor shows wire frame models ... if i add a sprite that is shown in wire frame as well ... unless i do to renderworlds ? will that work ?

Matt


aCiD2(Posted 2004) [#3]
do you mean making a grid? :P


Neo Genesis10(Posted 2004) [#4]
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