setting up models for collisions

Blitz3D Forums/Blitz3D Beginners Area/setting up models for collisions

scribbla(Posted 2004) [#1]
what is the best way to set up models for collisions...
what i mean is if i have a platform and model it as one then texture it as one...then cut out the floor section and save it as a seperate model...then load them both into blitz, parent the floor to the walls then apply the texture to both this way the texture will run seamless thru both....this way i have 2 models to detect for collisions a wall and a floor....does this sound like the right way to do it...or is there another way and am i being daft



when its joined it looks like this but each platform piece is 2 models, or should i be setting up some sort of detection zone thingy ma jigg


plus while im picking ppls brains has any one got any sample code on using translate entity...for a total newb at b3d


scribbla(Posted 2004) [#2]
was this a daft question ?...
and didnt deserve a response :(


Mustang(Posted 2004) [#3]
Nope, it was not a daft question... IMO what you are doing seems OK, if you need separate collisions for the parts... dunno why need those though (as separate).

And great looking gfx BTW!


Ross C(Posted 2004) [#4]
Yep, excellent looking stuff :D

Translate entity basically moves entities along the X,Y&Z axis. There's not alot more too it. I rarely ever use it :)

Can you be more specific?


Rob Farley(Posted 2004) [#5]
Translateentity moves an entity in xyz not based on it's rotation. Whereas Moveentity moves an entity in xyz based on the direction it's pointing.

Translateentity is great for applying forces to things. For example, you've got an object hitting another one and you want to shift the target object in the same direction as the source object, it's easy with translate entity, not so easy with move.


scribbla(Posted 2004) [#6]
hi guys

what im trying to is: add another jump cycle to the model
but with a flip so the character rotates in the air.. so i thought i better read up on how to do this in blitz...as far as can figure i have to use translate to make sure he keeps moving up/down when rotating as his y# will be spinning...i just wanted to see the command in use, thought there may be somthing in the tuts but cant find anything


big10p(Posted 2004) [#7]
The docs for TranslateEntity use that very example for usage i.e. a character that spins in the air while jumping. What do you need demonstrating, specifically?


scribbla(Posted 2004) [#8]
thanks

i think i understand it
TranslateEnity is basicly MoveEntity but with world co-ords x,y,z
not character x,y,z...
so i use this for spin/flip jumps or bouncing of object...
or spinning when falling...anytime the character co-ords are rotated but i want him to move in world co-ords

i will be honest.....i feel a bit of a pratt :)
but im damn sure it WONT be the last time


eBusiness(Posted 2004) [#9]
About that splitting up thing, I have thougt about it for a while, and I think that I have figured out a way of doing collisions to both walls and floors without the player being able of walking on too steep walls.

In addition to the normal player collision sphere you will need another sphere, one with a small radius. It should be located right on the bottom of the other collision sphere. The lower sphere will only collide with the enviroment if the surface is not too steep. So by checking the small sphere for collisions you can tell if the player can walk and stand, or if he should slide down the hill. I havn't written any code using this, it's just an idea. I hope you can use it :)


scribbla(Posted 2004) [#10]
i thought about something similar for a character that runs on one wheel over uneven ground
like stabilisers on a kids bike... main sphere then 4 more , one either side and one in front and one at back, so as to make him rock n roll over the uneven ground

.... i felt my brain turn over then :)


eBusiness(Posted 2004) [#11]
Dam, now my head hurts too, but here is the cause:
;Generate the landscape
scr=512 ;alter if you like
SeedRnd(MilliSecs())
Dim plots(scr-1,scr-1)
For a=0 To scr-1
For b=0 To scr-1
	plots(a,b)=Rand(0,1)
Next
Next
;While Not KeyHit(1)
	For a=0 To 399999 ;alter too if you like
		x=Rand(scr,scr+scr-1)
		y=Rand(scr,scr+scr-1)
		b=0
		For c=-2 To 2
		For d=-2 To 2
			If Abs(c)+Abs(d)<4 Then b=b+plots((x+c) Mod scr,(y+d) Mod scr)
		Next
		Next
		b=b+Rand(0,4)
		plots(x-scr,y-scr)=b/13
	Next
	c1#=Cos(Rnd(0,180))/2.0+.5
	c2#=Cos(Rnd(0,180))/2.0+.5
	c3#=Cos(Rnd(0,180))/2.0+.5
	c4#=Cos(Rnd(0,180))/2.0+.5
	c5#=Cos(Rnd(0,180))/2.0+.5
	c6#=Cos(Rnd(0,180))/2.0+.5
	c1=0
	c3=0
	c5=0
	c2=1
	c4=1
	c6=1
;	LockBuffer BackBuffer()
	out=WriteFile("Output.bmp")
	WriteByte(out,66)
	WriteByte(out,77)
	WriteByte(out,118)
	WriteByte(out,47)
	SeekFile(out,10)
	WriteByte(out,54)
	SeekFile(out,14)
	WriteByte(out,40)
	SeekFile(out,18)
	WriteShort(out,scr)
	SeekFile(out,22)
	WriteShort(out,scr)
	SeekFile(out,26)
	WriteByte(out,1)
	SeekFile(out,28)
	WriteByte(out,24)
	SeekFile(out,34)
	WriteByte(out,64)
	WriteByte(out,47)
	SeekFile(out,54)
	strange=scr Mod 4
	For x=scr To scr+scr-1
	For y=scr To scr+scr-1
		b=0
		For c=-2 To 2
		For d=-2 To 2
			If Abs(c)+Abs(d)<4 Then b=b+plots((x+c) Mod scr,(y+d) Mod scr)
		Next
		Next
		WriteByte(out,(c1*(21-b)+c2*b)*255.0/21.0)
		WriteByte(out,(c3*(21-b)+c4*b)*255.0/21.0)
		WriteByte(out,(c5*(21-b)+c6*b)*255.0/21.0)
;		WritePixelFast x-scr,y-scr,255*256*256+b*256*6,BackBuffer()
	Next
	For a=1 To strange
		WriteByte(out,0)
	Next
	Next
;	UnlockBuffer BackBuffer()
;	Flip








Graphics3D 640,480
camera=CreateCamera()
position=CreatePivot()
positionsl=CreatePivot()
positionst=CreatePivot()
button=CreatePivot()
EntityRadius position,1
EntityRadius positionsl,1
EntityRadius positionst,1
EntityRadius button,.01
PositionEntity button,0,-1.02,0
;EntityType position,1
EntityType positionsl,2
EntityType positionst,3
EntityType button,4

texture=LoadTexture("Output.bmp")
ScaleTexture texture,64,64
aterr=LoadTerrain("Output.bmp")
ScaleEntity aterr,2,8,2
MoveEntity aterr,-50,-100,-50
EntityTexture aterr,texture
TerrainDetail aterr,5000
EntityType aterr,5
Collisions 2,5,2,2 
Collisions 3,5,2,3 
Collisions 4,5,2,2

Repeat
  mx% = MouseX()
  my% = MouseY()
  rotation# = rotation# + (mx% - 200) * .1
  tilt# = tilt# + (my% - 200) * .1
  If tilt# < -90 Then tilt# = -90
  If tilt# > 90 Then tilt# = 90
  If rotation# < 0 Then rotation# = rotation# + 360
  If rotation# > 360 Then rotation# = rotation# - 360
  MoveMouse 200, 200
  walk%=0
  stepp%=0
  If KeyDown(17) walk% = 2
  If KeyDown(31) walk% = -2
  If KeyDown(30) stepp% = -2
  If KeyDown(32) stepp% = 2
  If KeyDown(1) endproc% = 1
  If KeyDown(57) And inair=0 Then
    bmove#=0.35
  End If

  dmove# = 1
  If walk% <> 0 And stepp% <> 0 Then dmove# = .707106
  If inair=0 Then
    cmove# = cmove# + (Cos(rotation#) * walk% * dmove# - Sin(rotation#) * stepp% * dmove#)*.01
    amove# = amove# + (Sin(rotation#) * walk% * dmove# + Cos(rotation#) * stepp% * dmove#)*.01
  End If
	If ground Then
    cmove# = cmove# * .95
    amove# = amove# * .95
	End If
  If cmove*cmove+amove*amove<.000001 Then
    cmove=0
    amove=0
  End If
  ;the gravity
  bmove#=bmove-.025
	smartx#=EntityX(position)
	smarty#=EntityY(position)
	smartz#=EntityZ(position)
	PositionEntity positionsl,EntityX(position)+amove,EntityY(position)+bmove,EntityZ(position)+cmove
	PositionEntity positionst,EntityX(position)+amove,EntityY(position)+bmove,EntityZ(position)+cmove
	PositionEntity button,EntityX(position)+amove,EntityY(position)+bmove-1.2,EntityZ(position)+cmove
	UpdateWorld
	If EntityCollided(button,5)<>0 Then
		inair=0
;		bmove=0
		PositionEntity position,EntityX(positionst),EntityY(positionst),EntityZ(positionst)
	Else
		inair=1
		PositionEntity position,EntityX(positionsl),EntityY(positionsl),EntityZ(positionsl)
	End If
	ground=0
	If EntityCollided(positionsl,5) Then
		bmove=0
		ground=1
	End If
  RotateEntity camera,tilt#,-rotation#,0
	PositionEntity camera,EntityX(position),EntityY(position)+.7,EntityZ(position)
	RenderWorld
	Flip
	amove=EntityX(position)-smartx
	bmove=EntityY(position)-smarty
	cmove=EntityZ(position)-smartz
Until endproc



scribbla(Posted 2004) [#12]
nice

when i grow up i wana write code like that please.....

im going to tear your code apart n learn ;)