Help

Blitz3D Forums/Blitz3D Beginners Area/Help

????(Posted 2005) [#1]
Hi im somewhat new blitz3d I want to make a game that the main models leaves off a trail just like the tron demo blitz came with. Can someone give step by step instructions on how to do this?


RiverRatt(Posted 2005) [#2]
Ok mr. ????
heres a link
[edit] link removed


????(Posted 2005) [#3]
Link dosent not work


WolRon(Posted 2005) [#4]
????, you can check out my Programming Tutorial. I'm sorry it's not finished..., it's a work in progress.

Hope it helps...


EDIT:
I want to make a game that the main models leaves off a trail just like the tron demo blitz came with. Can someone give step by step instructions on how to do this?

I'm sorry, I didn't realize exactly what you were asking for...

In order to leave a trail, you have to dynamically create/add vertices and triangles to your trail mesh, just like in the Tron demo.

The trail in Tron is simply (what they call) a quad. It is as simple a mesh that can exist. It consists of four vertices and two triangles (actually four triangles because it's double-sided). Every so often, the program adds two more vertices to the trail mesh and four more triangles that are attached to the two vertices it just added and the last two vertices.

Any kind of trails you want to make, would have to be in a similar fashion. If you're new, don't get in over your head and try to make some kind of super fancy trail. Start out small, like the Tron trail, and work your way up from there.


????(Posted 2005) [#5]
Can you please tell me how to "dynamically create/add vertices and triangles to your trail mesh"


WolRon(Posted 2005) [#6]
Well, the Tron demo shows you how:
	If add_flag
		AddVertex trail_surf,EntityX(bike),2,EntityZ(bike),0,0
		AddVertex trail_surf,EntityX(bike),0,EntityZ(bike),0,1
		AddTriangle trail_surf,trail_vert,trail_vert+2,trail_vert+3
		AddTriangle trail_surf,trail_vert,trail_vert+3,trail_vert+1
		AddTriangle trail_surf,trail_vert,trail_vert+3,trail_vert+2
		AddTriangle trail_surf,trail_vert,trail_vert+1,trail_vert+3
		trail_vert=trail_vert+2


It's adding two more vertices to the trail mesh at the bikes current location.

Then, it adds four triangles to the trail mesh (the trail_surf surface) using the last four vertices that have been added (vertices in a mesh are numbered sequentially).

The last thing it does, is increment the trail_vert variable by 2 (because two vertices were added) so that the next time it adds triangles, they will be added onto the end of the trail.


WolRon(Posted 2005) [#7]
It would most likely help if you read up on the AddVertex and AddTriangle commands.


RiverRatt(Posted 2005) [#8]
Sorry for the bad link. Don't know why it did not work. But it let to a tutorial at blitz coder, so check over there.


????(Posted 2005) [#9]
Ok I got it to sort of work. But when I turn everthing spazzs out. Heres my code what am I doing wrong?

Graphics3D 1024,768,32,1
Const carcoll = 1
Const wallcoll = 2
Global coll = 0
Global turn
Global starttrail = 0
Global add = 0
Global add_flag = True
Global cam_piv = CreatePivot() ;creates pivot
Global cam = CreateCamera(cam_piv) ;create camra
CameraViewport cam,0,0,1024,768 ; creates camera viewing area
PositionEntity cam,-0.2,6,-7

AmbientLight 255,255,255 ;sets ambeint light
plane = CreatePlane() ;create plane
PositionEntity plane,0,1,0 ; position plane
gridtex = LoadTexture("grid.bmp") ;loadgrid texture
EntityTexture plane,gridtex ;set grid texture
wall = LoadMesh("wall.x") ; load wall mesh file
PositionEntity wall,0,-20,0
EntityAlpha wall,0.3; makes wall transperant
EntityType wall,wallcoll ;sets collision type
Global c1 = LoadMesh("car1\car1.x",cam_piv);loads car1 mesh
EntityRadius cam_piv,0.5 ;sets raduis for collsions
EntityType cam_piv,carcoll ;sets collusiontype
PositionEntity c1,0,1,0
RotateEntity c1,0,-90,0
;;;;;;;;;;;;;;;;;;;;;;;;;
Global trail_mesh=CreateMesh()
Global trail_brush=CreateBrush()
BrushColor trail_brush,255,0,0
BrushBlend trail_brush,3
BrushFX trail_brush,1
Global trail_surf=CreateSurface( trail_mesh,trail_brush )
AddVertex trail_surf,0,2,0,0,0
AddVertex trail_surf,0,0,0,0,1
AddVertex trail_surf,0,2,0,0,0
AddVertex trail_surf,0,0,0,0,1
AddTriangle trail_surf,0,2,3
AddTriangle trail_surf,0,3,1
AddTriangle trail_surf,0,3,2
AddTriangle trail_surf,0,1,3
trail_vert=2
;;;;;;;;;;;;;;;;;;;;;;;;;
Collisions carcoll,wallcoll,2,1

While Not KeyDown(1)

trail()

add_flag = False

If EntityCollided(cam_piv,wallcoll)
coll = 1
PositionEntity cam,0,50,0
TurnEntity cam,90,0,0

Else

pos()
EndIf




RenderWorld
UpdateWorld
Flip


Wend

Function pos()

If KeyHit(30)
turn = 90
add_flag = True

EndIf
If KeyHit(32)
turn = -90
add_flag = True

EndIf
TurnEntity cam_piv,.0,turn,0





MoveEntity cam_piv,0,0,0.3


End Function
Function trail()

If add_flag


AddVertex trail_surf,EntityX(cam_piv),2,EntityZ(cam_piv),0,0
AddVertex trail_surf,EntityX(cam_piv),0,EntityZ(cam_piv),0,1
AddTriangle trail_surf,trail_vert,trail_vert+2,trail_vert+3
AddTriangle trail_surf,trail_vert,trail_vert+3,trail_vert+1
AddTriangle trail_surf,trail_vert,trail_vert+3,trail_vert+2
AddTriangle trail_surf,trail_vert,trail_vert+1,trail_vert+3
trail_vert=trail_vert+2

Else
VertexCoords trail_surf,trail_vert,EntityX(cam_piv),2,EntityZ(cam_piv)
VertexCoords trail_surf,trail_vert+1,EntityX(cam_piv),0,EntityZ(cam_piv)
EndIf





End Function


RiverRatt(Posted 2005) [#10]
You dont't need to turn the camera by 90 every loop, so take that out and it should work. I think.


????(Posted 2005) [#11]
Ok I added turn = 0 right after while it stopped the spazzing but the trail is doing this.
****O****
**** \***
**** \***
***** \**
***** s*
when i want it to do this
***O----*
***** |*
***** |*
***** |*
***** s*


????(Posted 2005) [#12]
Found the problem didnt make trail_vert global. Works great now. Thanks for the help.