Does anyone have any quick "generate cube" code?

Blitz3D Forums/Blitz3D Programming/Does anyone have any quick "generate cube" code?

Damien Sturdy(Posted 2004) [#1]
im rushing around at the moment and cant think quickly enough to make one myself.
And nope, i dont mean CreateCube()

Something that does it using the createmesh functions?


Cheers guys (and any gals who are around too!) :)


[edit]

Found a fix:

Function CreateCube(parent=0)
Local m,s
	m=CreateMesh(parent)
	s=CreateSurface( m)
	AddVertex s,-1,+1,-1,0,0:AddVertex s,+1,+1,-1,1,0
	AddVertex s,+1,-1,-1,1,1:AddVertex s,-1,-1,-1,0,1
	AddTriangle s,0,1,2:AddTriangle s,0,2,3
	s=CreateSurface( m)
	AddVertex s,+1,+1,-1,0,0:AddVertex s,+1,+1,+1,1,0
	AddVertex s,+1,-1,+1,1,1:AddVertex s,+1,-1,-1,0,1
	AddTriangle s,0,1,2:AddTriangle s,0,2,3
	s=CreateSurface( m)
	AddVertex s,+1,+1,+1,0,0:AddVertex s,-1,+1,+1,1,0
	AddVertex s,-1,-1,+1,1,1:AddVertex s,+1,-1,+1,0,1
	AddTriangle s,0,1,2:AddTriangle s,0,2,3
	s=CreateSurface( m)
	AddVertex s,-1,+1,+1,0,0:AddVertex s,-1,+1,-1,1,0
	AddVertex s,-1,-1,-1,1,1:AddVertex s,-1,-1,+1,0,1
	AddTriangle s,0,1,2:AddTriangle s,0,2,3
	s=CreateSurface( m)
	AddVertex s,-1,+1,+1,0,1:AddVertex s,+1,+1,+1,0,0
	AddVertex s,+1,+1,-1,1,0:AddVertex s,-1,+1,-1,1,1
	AddTriangle s,1,2,0:AddTriangle s,2,3,0
	s=CreateSurface( m)
	AddVertex s,-1,-1,-1,1,0:AddVertex s,+1,-1,-1,1,1
	AddVertex s,+1,-1,+1,0,1:AddVertex s,-1,-1,+1,0,0
	AddTriangle s,0,1,2:AddTriangle s,0,2,3
	FitMesh m,-1,-1,-1,2,2,2
	UpdateNormals m
	Return m
End Function



Beaker(Posted 2004) [#2]
There is one (or two) here:
http://www.blitzbasic.com/logs/userlog.php?user=6822&log=379


Damien Sturdy(Posted 2004) [#3]
Myb god hes been at it, aint ya "Puki"? :D


Cheers for that Beaker...


puki(Posted 2004) [#4]
WOW - "Beaker" saw my worklog.

Yeh, I am working away at documenting vertex stuff. In honesty, I am a newbie at this, but I want to document my ongoing experience so that others can eventually benefit from it.

Be careful with my stuff though - it may not be the most optimised. Some of the comments in the code may be incorrect (but that won't affect the code).


Damien Sturdy(Posted 2004) [#5]
i saw your worklog too :P

Ive dont vertex n creation quite heavily before but i just needed to grab some quick code- Youve done some very good stuff puki!


GfK(Posted 2004) [#6]
And nope, i dont mean CreateCube()

Damn.

/me wanders off....


Damien Sturdy(Posted 2004) [#7]
Its all sorted now... juts added my cubemap system into supernova- and im thorougholy dissapointed at how incorect cubemaps are....when used on cubes.... :/


puki(Posted 2004) [#8]
Does it work if you just try to do the mapping to one face of the cube?


Damien Sturdy(Posted 2004) [#9]
sorry, what do you mean by that? not sure what you mean.


puki(Posted 2004) [#10]
Oh, I thought you were doing the cube-mapping to each side of the cube and it wasn't working.

Ignore me - I'm mental.


Damien Sturdy(Posted 2004) [#11]
hehe. no worries :/ il hjave to just do a clever spheremap trick instead of cubemap. Odd, init?


Wait.. no, cuz you cant correctly spheremap a cube.


Il just do a standard texture :/