my fisrt project

Blitz3D Forums/Blitz3D Beginners Area/my fisrt project

seferey(Posted 2005) [#1]
delete thread


Raitsun(Posted 2005) [#2]
nice, but the way you're using the comments is not as it's meant to be.
You should not say WHAT you're doing.. that's clear.. but Why you're doing it and what it's meaning is.
It doesn't make the program more clear, when you comment every line, and write exactly what has been written in code just a line further.

Apart from that code looks good.


seferey(Posted 2005) [#3]
you have a good point there

I'm just trying to make my codes less sloppy more presentable

also I'm problem with this animate command did what I just post up here is it correct if so I'm using milkshape 3d to create It's a great and all but when it comes to saving your model with animation or joints as they call it the model loads up fine in my code but it won't seem to animate the wheels

why


Ross C(Posted 2005) [#4]
Milkshape has a problem saving group names. But i don't think that's the problem. Try using the animate command, with the default parameters, to see if the animation exported correctly:

Animate box


Also, to make your code more presentable, tab your code, when there's an IF or a LOOP, or anything else than runs, depending on a condition. So you code would look like...

;Name of application
AppTitle "My First Terrain And First animated Character"

;Start 3d Mode
Graphics3D 800,600

;Take everything and hide it in the back buffer 
SetBuffer BackBuffer()

;Make a Camera
Camera=CreateCamera()

PositionEntity camera,30,1,0

;Make a Light
Light=CreateLight()

;Rotate the light
RotateEntity Light,90,0,0

;Make some Land 
terrain=CreateTerrain(512)

;Paint image on Land 
Grass=LoadTexture("texture.jpg")
EntityTexture terrain,Grass

;Load my animated object
box=LoadAnimMesh("model\sm.x")

;Make my object normal size
ScaleEntity box,.2,.2,.2

;
TranslateEntity box,30,0,0


;Make it turn it's wheel's
Animate box ; TRY THIS FIRST TO SEE IF IT ANIMATES.


;Begin's the loop 
While Not KeyHit(88)

	;this moves and turn's the box around 
	If KeyDown( 32 )=True Then TurnEntity box,0,-1,0
	If KeyDown( 30 )=True Then TurnEntity box,0,1,0
	If KeyDown( 31 )=True Then MoveEntity box,0,0,-0.05
	If KeyDown( 17 )=True Then MoveEntity box,0,0,0.05
	
	UpdateWorld
	RenderWorld 
	
	;Take everything and unhide it and bring it to the front buffer 
	Flip 
	
;End's a loop 
Wend

;End's the program
End



seferey(Posted 2005) [#5]
I re-wrote the line

Animate ninja

and tried without the no#'s and it loads everything perfect

but putting the no#'s after it. the animation's doesn't seem to work at all


seferey(Posted 2005) [#6]
delete thread


seferey(Posted 2005) [#7]
I could have sworn that there was a chasecam command in b3d


WolRon(Posted 2005) [#8]
EntityParent camera, player ?


Ross C(Posted 2005) [#9]
When your using the animate command and you haven't extracted any animations, then you can't use the sequence parameter. Leave that out and you'll be fine.


seferey(Posted 2005) [#10]
delete thread


seferey(Posted 2005) [#11]
I put camera first before the box

What I need to know is how do you keep the camera on the entity as your turning left or right with the camera while watching the actual entity


seferey(Posted 2005) [#12]
delete thread


Raitsun(Posted 2005) [#13]
the most simple way is to use a pivot.

Put this behind your declaration of "box" and "camera"
player = createpivot()
entityparent(box, player)
entityparent(camera, player)


now turn/translate/move/Scale the pivot and not the "box"...
(change the entity-parameter in all entity control commands in the main cycle)


Raitsun(Posted 2005) [#14]
you will have no smart camera there... that means it won't avoid geo and so on...
but it's okay for the first project...


seferey(Posted 2005) [#15]
delete thread


seferey(Posted 2005) [#16]
delete thread


seferey(Posted 2005) [#17]
i've tried it before the turm and move entity camera commands and tried it after the box commands as well

and it still loads up fine but doesn't turn box with the camera at the same time like I wanted too


Raitsun(Posted 2005) [#18]
;Name of application
AppTitle "My First Terrain And First animated Character"

;*******************
;GRAPHICS
;*******************

Graphics3D 800,600
SetBuffer BackBuffer()

Camera=CreateCamera()
PositionEntity camera,30,1,-3,True 

Light=CreateLight()
RotateEntity Light,90,0,0

terrain=CreateTerrain(512)
Grass=LoadTexture("texture.jpg")
EntityTexture terrain,Grass

box=LoadAnimMesh("model\BOX.B3D")
ScaleEntity box,.1,.1,.1
TranslateEntity box,30,0,-.51
Animate box

player=CreatePivot() 
EntityParent(box,player)
EntityParent(camera,player) 

While Not KeyHit(88)

  ;this moves and turn's the box around 

  If KeyDown( 32 )=True Then TurnEntity player,0,-1,0
  If KeyDown( 30 )=True Then TurnEntity player,0,1,0
  If KeyDown( 31 )=True Then MoveEntity player,0,0,-0.05
  If KeyDown( 17 )=True Then MoveEntity player,0,0,0.05


  UpdateWorld
  RenderWorld 

  Flip 

Wend

End


try to figure this out


seferey(Posted 2005) [#19]
After feeling of ripping my hair out I figured it out and wrote like this

;Name of application
AppTitle "My First Terrain And First animated Character"

;*******************
;GRAPHICS
;*******************

Graphics3D 800,600

SetBuffer BackBuffer()

Camera=CreateCamera()

PositionEntity camera,30,1,-3,True

Light=CreateLight()

RotateEntity Light,90,0,0

terrain=CreateTerrain(512)

Grass=LoadTexture("texture.jpg")
EntityTexture terrain,Grass

box=LoadAnimMesh("model\BOX.B3D")

ScaleEntity box,.1,.1,.1

TranslateEntity box,30,0,-.51

SetAnimKey box,15,True,True,True

AddAnimSeq(box,15)

Animate box

While Not KeyHit(88)

;this moves and turn's the box around player=CreatePivot()
player=CreatePivot()
EntityParent(camera,box,1)


If KeyDown( 32 )=True Then TurnEntity camera,0,-.0,0
If KeyDown( 30 )=True Then TurnEntity camera,0,.0,0
If KeyDown( 31 )=True Then MoveEntity camera,0,0,-0.00
If KeyDown( 17 )=True Then MoveEntity camera,0,0,0.00


If KeyDown( 32 )=True Then TurnEntity box,0,-1,0
If KeyDown( 30 )=True Then TurnEntity box,0,1,0
If KeyDown( 31 )=True Then MoveEntity box,0,0,-0.05
If KeyDown( 17 )=True Then MoveEntity box,0,0,0.05


UpdateWorld
RenderWorld

Flip

Wend

End


seferey(Posted 2005) [#20]
writing it this way I got it to turn the way I wanted

I got the camera to turn as well as the box entity itself to perfectly the box entity makes a turn in the left or right direction and camera goes along with it perfectly

my code is just like the castle example except for minor differences with the pivot and mario loading up a little

mine is much simpler to understand thanks raitsun :D


seferey(Posted 2005) [#21]
Hey raitsun I need to ask how do you keep b3d programs from going kinda slow?


Matty(Posted 2005) [#22]
Have you got debug mode on?


seferey(Posted 2005) [#23]
no My Debug mode is off


seferey(Posted 2005) [#24]
delete thread


seferey(Posted 2005) [#25]
or tell in detail where to put it at


seferey(Posted 2005) [#26]
delete thread


seferey(Posted 2005) [#27]
does the command

dither enable work auto without pressing a key


Raitsun(Posted 2005) [#28]
"player = createpivot()" does nothing in your code...

The keydown-stuff for the camera could be deleted

;Name of application
AppTitle "My First Terrain And First animated Character"

;*******************
;GRAPHICS
;*******************

Graphics3D 800,600
SetBuffer BackBuffer()

Camera=CreateCamera()
PositionEntity camera,30,1,-3,True 

Light=CreateLight()
RotateEntity Light,90,0,0

terrain=CreateTerrain(512)
Grass=LoadTexture("texture.jpg")
EntityTexture terrain,Grass

box=LoadAnimMesh("model\BOX.B3D")
ScaleEntity box,.1,.1,.1
TranslateEntity box,30,0,-.51
SetAnimKey box,15,True,True,True
AddAnimSeq(box,15)
Animate box

EntityParent(camera,box,1)

While Not KeyHit(88)

  If KeyDown( 32 )=True Then TurnEntity box,0,-1,0
  If KeyDown( 30 )=True Then TurnEntity box,0,1,0
  If KeyDown( 31 )=True Then MoveEntity box,0,0,-0.05
  If KeyDown( 17 )=True Then MoveEntity box,0,0,0.05


  UpdateWorld
  RenderWorld 

  Flip 

Wend

End 



Raitsun(Posted 2005) [#29]
does the command

dither enable work auto without pressing a key



I don't know what you mean...
if you set it to true dither is enabled.. when not it's disabled...

if you just set it true somewhere above your main loop dither will be enabled the wohle program long.. but you could do the following:

Put that in your main loop (between while and renderworld):
dith = dither()
if Keyhit(57) then
  if dith = true then dither false
  if dith = false then dither true
endif


with "Space" you can now switch dithering on and off


seferey(Posted 2005) [#30]
but isn't there a way to run this without the necessary use of spacebars and keyboard keys


seferey(Posted 2005) [#31]
delete thread


seferey(Posted 2005) [#32]
give it a try and tell me what you think because what I wrote inside my source code seem's to work for me very well even when compiled into a exe file it still functions the same way


seferey(Posted 2005) [#33]
I allow you to play with my source code raitsun


Raitsun(Posted 2005) [#34]
but isn't there a way to run this without the necessary use of spacebars and keyboard keys



sure... put this over "While" but under "Setbuffer":

dither true

that's it...
"dither" can be set do true (enabled) or to false (disabled) simply via "dither true" or "dither false". You don't have to ask for Keyhit's if you don't want...

i'm sorry... i am not able to download your code... my router doesn't allow it... but you could mail it to me:
silas.bischoff@... (private)
or
silas.bischoff@... (work)

mfg Raitsun


Raitsun(Posted 2005) [#35]
oh.. just one question... why do you need dithering? i don't think it's a somewhat important thing to add, most people have no problems using 32 or 24 bit depth...
focus on the basics some more until you really got into it...


seferey(Posted 2005) [#36]
Raitsun I wrote it this way in my code using tutorials

If Dither=True Then enable=1-enable

Dither enable


but I changed it to yours

dither true

which seems to be much easier


Raitsun(Posted 2005) [#37]
i don't understand your code... what is "enable" initialised with? your code does not make sense to me...


seferey(Posted 2005) [#38]
the only thing Iput in there that says enable is the

dither command but I changed it to dither true


seferey(Posted 2005) [#39]
delete thread


seferey(Posted 2005) [#40]
delete thread


seferey(Posted 2005) [#41]
delete thread


Raitsun(Posted 2005) [#42]
the part you wrote above my last post, this thing about the "Enable" variable, as it is pointless in this case...
everything else is okay, though.


It is probably not my router blocking the download.. it's a problem i often have, don't know how to solve it...
If it helps you i'd really like to opimize or comment your code, if you want mail it...
silas.bischoff@...


seferey(Posted 2005) [#43]
;Name of application
AppTitle "My First Terrain And First animated Character"

;*******************
;GRAPHICS
;*******************

Graphics3D 800,600,16,1

SetBuffer BackBuffer()

Camera=CreateCamera()

PositionEntity camera,30,1,2,True

Light=CreateLight()

RotateEntity Light,90,0,0

terrain=LoadMesh("terrain1.x")

PositionEntity terrain,0,0,5

RotateEntity terrain,0,20,0

TranslateEntity terrain,30,0,-.15

Grass=LoadTexture("grass2.bmp")
EntityTexture terrain,Grass

box=LoadAnimMesh("model\BOX.B3D")

ScaleEntity box,.1,.1,.1

PositionEntity box,0,0,5

TranslateEntity box,30,0,-.15

SetAnimKey box,15,True,True,True

AddAnimSeq(box,15)

Animate box,1,2,0,100

;Set Collision values
type_box=1
type_terrain=2

;Set Box radius values
box_radius#=1

EntityType box,type_box
EntityType terrain,type_terrain

Collisions type_box,type_terrain,2,2

Dither True

While Not KeyHit(88) ;press F12 To Exit

X#=0
Y#=0
Z#=0

;this moves and turn's the box around

player=CreatePivot()
EntityParent(camera,box,1)

If KeyHit(87)=True Then enable=1-enable

WireFrame enable

MoveEntity box,X#,Y#,Z#

If KeyDown( 32 )=True Then TurnEntity camera,0,-.0,0
If KeyDown( 30 )=True Then TurnEntity camera,0,.0,0
If KeyDown( 31 )=True Then MoveEntity camera,0,0,-0.00
If KeyDown( 17 )=True Then MoveEntity camera,0,0,0.00


If KeyDown( 32 )=True Then TurnEntity box,0,-1,0
If KeyDown( 30 )=True Then TurnEntity box,0,1,0
If KeyDown( 31 )=True Then MoveEntity box,0,0,-0.05
If KeyDown( 17 )=True Then MoveEntity box,0,0,0.05

EntityRadius box,box_radius#

EntityRadius terrain,terrain_radius#

UpdateWorld
RenderWorld tween

Flip

Wend

FreeEntity(box)

FreeEntity(terrain)

ClearWorld(box,terrain,Grass )


End


WolRon(Posted 2005) [#44]
seferey, you can click on the EDIT button at the top-right of every one of your posts and edit your last post instead of continually creating new posts every time you want to add something...

By the way, checking out my Programming Tutorial for some help/ideas may prove handy.


seferey(Posted 2005) [#45]
Hey raitsun your version of my code that has no create pivot in it. it makes sense to me now and it's much smaller in the keyboard commands it's using one set of keyboard commands without having to set keyboard commands for the camera thanks raitsun

also I need to know if I wrote collision commands correctly
and do I need to add entityradius to it also I can't seem to set my entity box on the terrain i made


seferey(Posted 2005) [#46]
raitsun or wolfron look at my full source code here and tell me if the entity radius stuff is correct

I have gotten rid of the create pivot a long time ago I probably posted the old code by accident and I also change those line you wanted me to change

my version and your version I still have one small problem
my entity box is under the terrain


Raitsun(Posted 2005) [#47]
You still have a lot of commands written, that do exactly nothing.

Delete (or change) the following lines:
X#=0
Y#=0
Z#=0

player=CreatePivot()

MoveEntity box,X#,Y#,Z#

EntityRadius box,box_radius# ;no need to call this every frame, it's faster you put this ABOVE your main loop.

EntityRadius terrain,terrain_radius# ;Terrain's collision-sphere isn't used for collisions... and terrain_radius# has not been initialised and has, for that reason, a value of 0

If KeyDown( 32 )=True Then TurnEntity camera,0,-.0,0
If KeyDown( 30 )=True Then TurnEntity camera,0,.0,0
If KeyDown( 31 )=True Then MoveEntity camera,0,0,-0.00
If KeyDown( 17 )=True Then MoveEntity camera,0,0,0.00

RenderWorld tween ;why "tween"? use normal renderworld, you have no initialised variable called "tween", you would need one for frame-tweening... just write "Renderworld" alone, it does exactly the same in this case...

FreeEntity(box)

FreeEntity(terrain)

ClearWorld(box,terrain,Grass ) ;this is not the right parameters... you would have to give the parameters (true, true, true) to this function, but as this is already default, just "ClearWorld" is enough...


mfg Raitsun


Raitsun(Posted 2005) [#48]
Your code, corrected: (use this instead of your old code)
;Name of application
AppTitle "My First Terrain And First animated Character"

;Initialise Graphics mode
Graphics3D 800,600,16,1
SetBuffer BackBuffer()

;Camera has to be set, so the scene is visible
Camera=CreateCamera()
PositionEntity camera,30,1,2,True 

;Light The Scene, so that it doesn't look flat
Light=CreateLight()
RotateEntity Light,90,0,0

;Create the "Terrain" Entity...
terrain=LoadMesh("terrain1.x")
PositionEntity terrain,0,0,5
RotateEntity terrain,0,20,0 
TranslateEntity terrain,30,0,-.15 
;...and texture it
Grass=LoadTexture("grass2.bmp")
EntityTexture terrain,Grass

;Create the "Box" entity and animate it
box=LoadAnimMesh("model\BOX.B3D")
ScaleEntity box,.1,.1,.1
PositionEntity box,0,0,5
TranslateEntity box,30,0,-.15
SetAnimKey box,15,True,True,True
AddAnimSeq(box,15)
Animate box,1,2,0,100

;Set Collision types fot the "collisions" command 1-player, 2-ground
type_box=1
type_terrain=2
EntityType box,type_box
EntityType terrain,type_terrain

;Adjust Radius of Sphere, that's used for Sphere-Polygon collisions
box_radius#=1
EntityRadius box, box_radius

;Initialise Collisions between player and ground
Collisions type_box,type_terrain,2,2 

;Dither scene, so that it does look good with 16 Bit Color-Depth
Dither True 

;Main Loop
While Not KeyHit(88) ;press F12 To Exit
  
  ;Press F11 to see the world in Wireframe mode
  If KeyHit(87)=True Then enable=1-enable 
  WireFrame enable 
  
  ;Parent the player to the camera, so that moving the player makes the camera follow it
  EntityParent(camera,box,1)

  ;Keyboard input (cursor-keys) for moving the player around
  If KeyDown( 32 )=True Then TurnEntity box,0,-1,0
  If KeyDown( 30 )=True Then TurnEntity box,0,1,0
  If KeyDown( 31 )=True Then MoveEntity box,0,0,-0.05
  If KeyDown( 17 )=True Then MoveEntity box,0,0,0.05

  ;Update the animation-Frames and Render the calculated scene, Flip Back- with Frontbuffer after that, so the new frame becomes visible
  UpdateWorld
  RenderWorld
  Flip 

Wend

;Free the Memory and end the program
ClearWorld
End 



Raitsun(Posted 2005) [#49]
concerning entityradius...
The Radius of an Entity (only if its collision sphere is used in any collisions() command) should be that big, that the whole mesh does exactly fit into the sphere. The Collision sphere is the Shape of the entity that will collide with the other entity-type that's been given to "Collisions()".
Of course such a shape does no exaxt collisions... if you want polygon to polygon collisions use:
MeshesIntersect(Mesh1, Mesh2) that returns "true" if the meshes collide, "false" if they don't. But it's a very slow command that should not be used often...

mfg Raitsun


seferey(Posted 2005) [#50]
hey RaitSun

collisions

my entity goes up the mountain or hill perfectly but

when I turn left or right It looks fake also when I get to the top of the mountain and I'm thinking well I't'll go down the hill or mountain rigth wrong
instead of going down the hill or mountain with forward arrow it goes forward and makes it look like it's flying and that's not what I wanted and I don't know how to fix it


Raitsun(Posted 2005) [#51]
Put "Translateentity box, 0, -3, 0" inside your main loop.