Quads experiment....

Blitz3D Forums/Blitz3D Programming/Quads experiment....

WillKoh(Posted 2004) [#1]
Here's a little experiment with quads, and with wireframe
on, it seems to be what I expected, but in regular mode it
quads just pops up a little now and then. Please tell
what's wrong!

The reason the code *appears* big is because key consts
are included. The squares image is just 4 by 4 64x64
squares of different color, but just try any image...


	Global QUAD_SIZE = 30
	Graphics3D 640,480
	
	p = CreatePlane()
	c = CreateCamera()
	MoveEntity c, 0,+7,0
	EntityTexture p, LoadTexture("C:\Program Files\Blitz3D\help\commands\3d_examples\media\MossyGround.bmp")
	
	mc# = 0.1
	m = CreateMesh()
	sf = CreateSurface(m)
	EntityTexture m, LoadTexture("Squares.bmp")
	EntityFX m, 16 + 1
	
	For q = 0 To 3
		AddQuad sf, x, y
		x = x + QUAD_SIZE * 1.10
	Next
	
	Repeat
		
		If KeyDown(KEY_SPACE)
			If ison Then WireFrame False: ison = False Else WireFrame True: ison = True
		End If
		
		If KeyDown(KEY_A) MoveEntity c, 0, +mc, 0
		If KeyDown(KEY_Z) MoveEntity c, 0, -mc, 0
		
		If KeyDown(KEY_ARROW_LEFT) MoveEntity c, -mc,0,0
		If KeyDown(KEY_ARROW_RIGHT) MoveEntity c, +mc,0,0
		
		If KeyDown(KEY_ARROW_UP) MoveEntity c, 0, 0, +mc
		If KeyDown(KEY_ARROW_DOWN) MoveEntity c, 0, 0, -mc
		
		RenderWorld()
		
		Text 32,128, "A raise cam"
		Text 32,140, "Z lower cam"
		Text 32,164, "UP move cam fw"
		Text 32,172, "DN move cam bk"
		Text 32,192, "RT move cam rt"
		Text 32,220, "LF move cam lf"
		
		Flip
		
	Until KeyHit(1)


Function AddQuad(surf,x#,y#,z#=0)
	
	luc = AddVertex(surf, x, (z#), 0,0)
	ruc = AddVertex(surf, x + QUAD_SIZE, y, (z#), 1,0)
	ldc = AddVertex(surf, x, y - QUAD_SIZE, (z#), 0,1)
	rdc = AddVertex(surf, x + QUAD_SIZE, y - QUAD_SIZE, (z#), 1,1)
	
	AddTriangle surf, luc, ruc, rdc
	AddTriangle surf, luc, rdc, ldc
	
End Function




Const KEY_NONE				= 0
Const KEY_ESCAPE			= 1
Const KEY_1					= 2
Const KEY_2					= 3
Const KEY_3					= 4
Const KEY_4					= 5
Const KEY_5					= 6
Const KEY_6					= 7
Const KEY_7					= 8
Const KEY_8					= 9
Const KEY_9					= 10
Const KEY_0					= 11
Const KEY_HYPHEN			= 12
Const KEY_EQUAL				= 13
Const KEY_BACKSPACE			= 14
Const KEY_TAB				= 15
Const KEY_Q					= 16
Const KEY_W					= 17
Const KEY_E					= 18
Const KEY_R					= 19
Const KEY_T					= 20
Const KEY_Y					= 21
Const KEY_U					= 22
Const KEY_I					= 23
Const KEY_O					= 24
Const KEY_P					= 25
Const KEY_BRACKET_LEFT	= 26
Const KEY_BRACKET_RIGHT		= 27
Const KEY_ENTER				= 28
Const KEY_CTRL_LEFT			= 29
Const KEY_A					= 30
Const KEY_S					= 31
Const KEY_D					= 32
Const KEY_F					= 33
Const KEY_G					= 34
Const KEY_H					= 35
Const KEY_J					= 36
Const KEY_K					= 37
Const KEY_L					= 38
Const KEY_SEMICOLON			= 39
Const KEY_APOSTROPHE		= 40
Const KEY_GRAVE				= 41
Const KEY_SHIFT_LEFT		= 42
Const KEY_BACKSLASH			= 43
Const KEY_Z					= 44
Const KEY_X					= 45
Const KEY_C					= 46
Const KEY_V					= 47
Const KEY_B					= 48
Const KEY_N					= 49
Const KEY_M					= 50
Const KEY_COMMA				= 51
Const KEY_PERIOD			= 52
Const KEY_SLASH				= 53
Const KEY_SHIFT_RIGHT		= 54
Const KEY_NUMPAD_MULTIPLY	= 55
Const KEY_ALT_LEFT			= 56
Const KEY_SPACE				= 57
Const KEY_CAPS_LOCK			= 58
Const KEY_F1				= 59
Const KEY_F2				= 60
Const KEY_F3				= 61
Const KEY_F4				= 62
Const KEY_F5				= 63
Const KEY_F6				= 64
Const KEY_F7				= 65
Const KEY_F8				= 66
Const KEY_F9				= 67
Const KEY_F10				= 68
Const KEY_NUM_LOCK			= 69
Const KEY_SCROLL_LOCK		= 70
Const KEY_NUMPAD_7			= 71
Const KEY_NUMPAD_8			= 72
Const KEY_NUMPAD_9			= 73
Const KEY_NUMPAD_HYPHEN		= 74
Const KEY_NUMPAD_4			= 75
Const KEY_NUMPAD_5			= 76
Const KEY_NUMPAD_6			= 77
Const KEY_PLUS				= 78
Const KEY_NUMPAD_1			= 79
Const KEY_NUMPAD_2			= 80
Const KEY_NUMPAD_3			= 81
Const KEY_NUMPAD_0			= 82
Const KEY_NUMPAD_PERIOD		= 83
Const KEY_F11				= 87
Const KEY_F12				= 88
Const KEY_F13				= 100
Const KEY_F14				= 101
Const KEY_F15				= 102
Const KEY_NUMPAD_EQUAL		= 141
Const KEY_NUMPAD_ENTER		= 156
Const KEY_CTRL_RIGHT		= 157
Const KEY_NUMPAD_SLASH		= 181
Const KEY_SYS_RQ			= 183
Const KEY_ALT_RIGHT			= 184
Const KEY_PAUSE				= 197
Const KEY_HOME				= 199
Const KEY_ARROW_UP			= 200
Const KEY_PAGE_UP			= 201
Const KEY_ARROW_LEFT		= 203
Const KEY_ARROW_RIGHT		= 205
Const KEY_END				= 207
Const KEY_ARROW_DOWN		= 208
Const KEY_PAGE_DOWN			= 209
Const KEY_INSERT			= 210
Const KEY_DELETE			= 211
Const KEY_WINDOWS_LEFT		= 219
Const KEY_WINDOWS_RIGHT		= 220



Ross C(Posted 2004) [#2]
I don't see anything happening when i run this. I get a plane, with a mossy texture. That's all...


Damien Sturdy(Posted 2004) [#3]
yup, and thats what he wants help with, ya twit :P

what i can see without having time to help much is that youve missed a Y coordinate in one of your Addvetices


EOF(Posted 2004) [#4]
EntityOrder m,-100 to draw the quad mesh in front of the plane.
Add these two lines below the EntityFX m,16+1
EntityOrder m,-100
MoveEntity m,-70,30,80



Ross C(Posted 2004) [#5]
Sorry chaps ^_^