It is currently Wed Jun 19, 2013 12:07 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: 4.60 3DEngine demos
PostPosted: Mon Nov 07, 2011 9:52 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 2506
Location: New Zealand
Have Fixed all the 3D demos for Linux

except for
manualmesh (winding issue perhaps?)
Sound3D (sound works if you convert roar.wav to and ogg file)
Terrain (can't see any terrain)
WorldDebug (crashes on F3 key)

to test them if the 4.60 Ide doesn't play nice on your system copy the 4.51 IDE into 4.60 compilers directory
so you can test the examples, test it in windowed mode first, and confirm if you can see bullets and move ...

you may need to specify opengl in the subsystem

Note that ExamineMouse() needs to be called before ExamineKeyBoard() or the mouse will lag and freeze
you need to set the keyboard mode to international to use the arrow keys KeyboardMode(#PB_Keyboard_International)
and there's something unusual going on with the order of mesh creation in the first person shooter demo

can you please confirm if the demos works and report your distro

tested on ubuntu 11.04 32bit

http://ubuntuone.com/7LOibCJNdrdPBBF8ge15cB

extract and overwrite the /exmaples/3d


Top
 Profile  
 
 Post subject: Re: 4.60 3DEngine demos
PostPosted: Thu Nov 10, 2011 1:23 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Mar 24, 2011 12:40 am
Posts: 160
Location: Iowa, USA
Hi Idle,

I have tested some of your demo's.
Using Ubuntu 10.04 32 bit
Using PureBasic 4.60 (x86)

I get the following error with Billboard and every other of your programs that I have tried.

Image



Using the DEFAULT Billboard file I get this message in the IDE.
"[Error] Invalid Memory Access" in line 50 of Screen3DRequester.pb
Then I have to kill it.

Image

I have yet to succeed in getting a 3D program to run under Linux using PureBasic.
Thanks for your effort in trying to get this 3D stuff working.

Edit: Using PB 4.51 IDE produces the same results.

Edit: I didn't actually overwrite the original demos, I ran them from a separate folder.
could this be a problem?


Top
 Profile  
 
 Post subject: Re: 4.60 3DEngine demos
PostPosted: Thu Nov 10, 2011 3:12 am 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 2506
Location: New Zealand
your missing a dependency but I don't recognize what it is from the linker error

google says
Code:
sudo apt-get install libXxf86vm-dev


but if you ever need to find out whats needed by something use this handy code from remi_meier in the terminal
got to where an exe or lib resides and paste the code in the terminal and replace the EXE with whatever
it will list dependencies and which packages the lib is from

Code:
EXE=engine3d.so FILES=`ldd $EXE | cut -d= -f1 | cut -f2 | cut -d" " -f1` ; echo -e "### FILES ###\n$FILES\n\n### PACKAGES ###" ; dpkg -S $FILES | fgrep "$FILES"


Top
 Profile  
 
 Post subject: Re: 4.60 3DEngine demos
PostPosted: Thu Nov 10, 2011 3:50 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Mar 24, 2011 12:40 am
Posts: 160
Location: Iowa, USA
Idle,
Thank you, the
sudo apt-get install libXxf86vm-dev
worked.
Now I can run the 3D demos.
I have just tried the one so far: Billboard and it seems ok.
I will test the others later, maybe in a day.

Something needs to be done with the 'Screen3DRequester' fullscreen option.
When you run it for the first time there is no default screen resolution selected and
if you click on the full screen button the program will fail.
If you go ahead and select something from the pull down menu then it works Ok.
This is used with many of the demos and it took me a while to figure out what was wrong,
but I had discovered this problem before so I knew to look out for it.

Also thank you for showing how to check for dependencies.
That one is going in my tool box for sure.


Top
 Profile  
 
 Post subject: Re: 4.60 3DEngine demos
PostPosted: Thu Nov 10, 2011 7:24 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 2506
Location: New Zealand
I guess the 3DScreenRequester had been broken for a while, should be working now.


Top
 Profile  
 
 Post subject: Re: 4.60 3DEngine demos
PostPosted: Sat Nov 12, 2011 6:22 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Mar 24, 2011 12:40 am
Posts: 160
Location: Iowa, USA
Idle,

Here are the results of my tests of you demos.
OS = Linux Ubuntu 10.04.
All were run using PB 4.60 (x86) final and the default IDE.
I checked each one with both full screen and windowed options.
I always used maximum screen resolution 1280 x 1024_32 in my case.

Code:
Screen3DRequester:
   on initial run fullscreen defauls to highest resolution, this is good.
   windowed screen defaults to the lowest resolution, perhaps this should also
   default to the highest resolution.  Other than that it seems perfect.

Billboard:
   Fullscreen and windowed both run OK.
   the three objects are not in view when the program first runs, you
   have to hunt for them.

BillboardGrass:
   Fullscreen and windowed both run OK.

Bridge:
   Fullscreen and windowed both run OK.

Camera:
   Objects are not in view when program opens.
   Other than that everything seems ok both fullscreen and windowed.

CameraProjection:
   runs in fullscreen and windowed.  If the object (is that a plane?) moves to
   the edge of screen then it appears to jump to the upper left corner.

CameraTrack:
   Runs OK fullscreen and windowed. Nice demo, one of my favorites.
   Would be even better if the robot stopped walking when it stops moving.
   
ConeJoint:
   Runs OK fullscreen and windowed.
   In the source code comment at the top it is named ConeTwistJoint.
   This does not match the filename.

CopyMaterial:
   Fullscreen and windowed both run OK.

CreateLine3D:
   mouse movement is jerky and slow to respond in both windowed and full.

CreateTexture:
   Runs OK fullscreen and windowed.
   Object is not in view when program starts and is hard to locate.

Entity:
   Runs OK fullscreen and windowed.

EntityCollide:
   Runs in fullscreen and windowed. Sometimes balls goes thru the rock.
   When balls hits objects they (the objects) just disappear but one time
   one was knocked off the rock. This is probably the desired response.

Gadget 3D :
   Runs OK fullscreen and windowed.

GetEntityMaterial:
   Runs OK fullscreen and windowed. Looks exactly like CopyMaterial demo.

GetScriptMaterial:
   Runs OK fullscreen and windowed.

HingeJoint:
   Runs OK fullscreen and windowed.

Joint:
   Runs in fullscreen and windowed.
   Filename does not match comment name (SliderJoint & HingeJoint) in code.
   In the windows version of this demo the ball rolls forward and triggers
   the hinge joint before it rolls off the boards. In this demo it just
   sits there until you press space then disappears and gets replaced.

Light:
   for both fullscreen and windowed the robot is out of view and hard to locate.

LightLookAt:
   Runs OK fullscreen and windowed.

Material:
   Robots are out of view on startup otherwise runs OK in fullscreen and windowed.

Mesh:
   Runs OK fullscreen and windowed.

MeshManual:
   Runs OK fullscreen and windowed.
   comment at top of code says ";broken linux"

MousePick:
   Runs OK fullscreen and windowed.

Node:
   Runs OK fullscreen and windowed.

Particle:
   Runs fullscreen and windowed.  Objects are out of view to start.

Pendule:
   Runs OK fullscreen and windowed.
   maybe should be namen Pendulum, I don't know what a pendule is.

PointJoint:
   Runs OK fullscreen and windowed.

PointPick:
   balls sometimes go thru the rock. Runs fullscreen and windowed.

PointPick 2D->3D:
   Runs OK fullscreen and windowed.

Ribbon:
   Runs OK fullscreen and windowed.
   Makes me dizzy.

Skybox:
   Runs OK fullscreen and windowed.
   Camera zoom is a little fast.

SkyDome:
   Runs OK fullscreen and windowed.
   Maybe the camera should point at the robot on startup.

SliderJoint:
   Runs OK fullscreen and windowed.
   I had to look thru the code to figure out how to activate the slider.
   PgUp / PgDn

Sound3D:
   Runs OK fullscreen and windowed.
   Code still has debug in it but is commented out so is OK.

StaticGeometry:
   Runs OK fullscreen and windowed.
   Without using shift key the camera movement is so slow that I thought
   it wasn't working.

Terrain:
   Runs fullscreen and windowed.
   Terrain is not visible, just a black square. (you know this already)

Terrain_KeepDistance:
   Runs fullscreen and windowed.
   No way to move the camera.
   Mouse only makes the screen shake, camera does not move.
   Arrow keys do not move camera.

Texture:
   Runs OK fullscreen and windowed.
   Robots are not in view on startup.

Window3D:
   Runs OK fullscreen and windowed.

WorldDebug:
   Runs fullscreen and windowed.
        You already know this.
   >>> IF you press F3 bad things happen. :( <<<
   IDE becomes visible and shows:
   Error! Program aborted, (by external library)
   No mouse or keyboard control possible.
   PC totally locks up, had to restart PC.
   Fullscreen and windowed produce same result.







Edit:
Here are the ones in the 'Demos' folder.

Code:
FPSFirstPerson:
   Screen3DRequester.pb is the buggy version.
   Runs OK fullscreen and windowed.

Tank:
   Ran OK fullscreen and windowed.
   looks a lot different from the windows version.

ThirdPerson:
   Runs OK fullscreen and windowed.



Top
 Profile  
 
 Post subject: Re: 4.60 3DEngine demos
PostPosted: Sat Nov 12, 2011 9:36 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 2506
Location: New Zealand
Thanks.
I think the Terrain is broken on all platforms.

The manual meshes are a bit odd on my system sometimes it displays other times it doesn't

createline3D, sounds like I missed that one.

in a lot of the demos the objects are not initially in view I don't know if it's specific to linux or not
will fix it with a CameraLookAt

It sounds like there might be a bug in the collision detection, though it's hard to tell without a specific test
in the FPS demo shooting the ground sometimes the bullets disappear and other times they bounce
which suggests that the bullet has passed through the plane when the collision detection is checked

I'll grab the joint version from windows sounds like it's a different file

thanks for the report


Top
 Profile  
 
 Post subject: Re: 4.60 3DEngine demos
PostPosted: Sun Nov 13, 2011 4:07 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Mar 24, 2011 12:40 am
Posts: 160
Location: Iowa, USA
I have a suggestion for a possible improvement to the ThirdPerson.pb demo.
This change will make the robot animation stop when it stops moving.
It was one thing that really bothered me about an otherwise excellent demo program.
IMO this small amount of code change will make the demo much more elegant.
It is totally up to you of course if you choose to implement this modification or not.
I will take no offense if you don't.
Also, you may invent a more elegant way to code it. Your option.

I use the AnimateEntity() to affect the change.
There is one thing though, using the "Stop" string with AnimateEntity() was a pure guess.
It seems to work though.

I added two new variables in 'HandleEntity()' procedure.
Action.s and LastAction.s

Here are the line by line details of what I have done.

Code:
Modifications to 'ThirdPerson.pb' demo.

Line 13     #PlayerSpeed = 26 ;IMO a better choice

Line 113    AnimateEntity(0, "Stop") ;changed "Walk" to "Stop"

Line 228    Protected.f Speed, Speed2, x, y, MouseX, MouseY, Action.s ;added Action.s
Line 229    Static Jump.f, MemJump.i, Rot.Vector3, Trans.Vector3, Clic, LastAction.s ;Added LastAction.s

Line 263    Action = "Stop" ;a new line

Line 268    Action = "Walk" ;a new line

Line 272    Action = "Walk" ;a new line

Line 284    Action = "Walk" ;a new line

Line 288    Action = "Walk" ;a new line

;a new if block
Line 291    If Action <> LastAction
Line 292       LastAction = Action
Line 293       AnimateEntity(0, Action)
Line 294    EndIf


Here is the complete modified code.

Code:
;
; ------------------------------------------------------------
;
;   PureBasic - Third Person
;
;    (c) 2011 - Fantaisie Software
;
; ------------------------------------------------------------
;

IncludeFile "Screen3DRequester.pb"

#PlayerSpeed = 26
#CameraSpeed = 10


Structure Vector3
  x.f
  y.f
  z.f
EndStructure

Structure s_Key
  Up.i
  Down.i
  Left.i
  Right.i
  StrafeLeft.i
  StrafeRight.i
  Jump.i
EndStructure

Structure s_Entity
  Entity.i
  EntityBody.i
  BodyOffsetY.f
  elapsedTime.f
  Key.s_Key
  MainNode.i 
  SightNode.i
  CameraNode.i 
  ForwardNode.i
  StrafeNode.i
EndStructure

Structure s_Camera
  Camera.i
  Tightness.f
  CameraNode.i
  TargetNode.i
EndStructure   

Macro GetNodePosition(Position, Node)
  Position\x = NodeX(Node) 
  Position\y = NodeY(Node) 
  Position\z = NodeZ(Node) 
EndMacro

Macro SubVector3(V, V1, V2)
  V\x = V1\x - V2\x
  V\y = V1\y - V2\y
  V\z = V1\z - V2\z
EndMacro

;-Declare
Declare HandleEntity(*Entity.s_Entity)
Declare CameraTrack(*Camera.s_Camera, *Entity.s_Entity)
Declare OnGround(*Entity.s_Entity)
Declare MakeColimacon(PX.f, PY.f, PZ.f, Length.i, Height.i, Width.i, Stair.i)
Declare MakeStair(PX.f, PY.f, PZ.f, Length.i, Height.i, Width.i, Stair.i)
Declare AddObjects()

Define Robot.s_Entity
Define Camera.s_Camera

If InitEngine3D()
 
  InitSprite()
  InitKeyboard()
  InitMouse()
 
  If Screen3DRequester()
    KeyboardMode(#PB_Keyboard_International)
   
    Add3DArchive("../Data/Textures"        , #PB_3DArchive_FileSystem)
    Add3DArchive("../Data/Models"          , #PB_3DArchive_FileSystem)
    Add3DArchive("../Data/Scripts"         , #PB_3DArchive_FileSystem)
    Add3DArchive("../Data/GUI"             , #PB_3DArchive_FileSystem)
    Add3DArchive("../Data/Packs/desert.zip", #PB_3DArchive_Zip)
    Parse3DScripts()
   
    WorldShadows(#PB_Shadow_Modulative, 500)
   
    ;Texture
    CreateTexture(1, 256, 256)
    StartDrawing(TextureOutput(1))
    Box(0, 0, 256, 256, $002255)
    DrawingMode(#PB_2DDrawing_Outlined)
    Box(0, 0, 256, 256, $FFFFFF)
    Box(10, 10, 236, 236, $FFFF)
    StopDrawing()
   
    ;Material
    CreateMaterial(0, LoadTexture(0, "r2skin.jpg"))
    CreateMaterial(1, TextureID(1))
    CreateMaterial(2, LoadTexture(2, "Dirt.jpg"))
    CreateMaterial(3, LoadTexture(3, "Wood.jpg"))
    GetScriptMaterial(4, "Scene/GroundBlend")
   
    ;Robot
    LoadMesh   (0, "robot.mesh")
    CreateEntity (0, MeshID(0), #PB_Material_None);
    AnimateEntity(0, "Stop")
   
    ;Robot Body
    CreateEntity(1, MeshID(0), #PB_Material_None, 0, 26, 0)
    HideEntity(1, 1)
   
    ;Ground
    CreatePlane(2, 5000, 5000, 100, 100, 100, 100)
    CreateEntity(2, MeshID(2), MaterialID(1), 0, 0, 0)
   
    ;Body
    EntityPhysicBody(1, #PB_Entity_CapsuleBody, 1, 0, 0)
    EntityPhysicBody(2, #PB_Entity_StaticBody)
   
    ;Add some statics and dynamics objects
    CreateCube(3, 1)
    AddObjects() 
   
    ;Add some stairs
    MakeColimacon(120, 0, 120, 130, 7, 48, 15)
    MakeStair(360, 0, 220, 130, 11, 48, 15)
   
    ;-Light
    CreateLight(0,RGB(155,155,155),700,500,0)
    AmbientColor(RGB(85,85,85))
   
    ; Skybox
    SkyBox("desert07.jpg")
   
    ;
    With Robot
      \Entity = 0
      \EntityBody = 1
      \BodyOffsetY = 43
     
      \Key\Down        = #PB_Key_Down
      \Key\Left        = #PB_Key_Left
      \Key\Right       = #PB_Key_Right
      \Key\Up          = #PB_Key_Up
      \Key\StrafeLeft  = #PB_Key_X
      \Key\StrafeRight = #PB_Key_C
      \Key\Jump        = #PB_Key_Space
     
      \MainNode    = CreateNode(#PB_Any) ; Entity position
      \SightNode   = CreateNode(#PB_Any,  120,  20,  0) ; For cameraLookAt
      \CameraNode  = CreateNode(#PB_Any, -140, 100,  0) ; Camera position
      \ForwardNode = CreateNode(#PB_Any,    1,   0,  0) ; Direction normalized
      \StrafeNode  = CreateNode(#PB_Any,    0,   0, -1) ; Direction normalized
     
      AttachNodeObject(\MainNode, NodeID(\SightNode)  , #PB_Node_Node)
      AttachNodeObject(\MainNode, NodeID(\CameraNode) , #PB_Node_Node)   
      AttachNodeObject(\MainNode, NodeID(\ForwardNode), #PB_Node_Node)     
      AttachNodeObject(\MainNode, NodeID(\StrafeNode) , #PB_Node_Node)   
      AttachNodeObject(\MainNode, EntityID(\Entity)   , #PB_Node_Entity)
    EndWith
   
    ;-Camera
    CreateCamera(0, 0, 0, 100, 100)
    With Camera 
      \Camera = 0
      \Tightness = 0.035
      ; Camera use 2 nodes
      \CameraNode = CreateNode(#PB_Any, -3000, 700, 0) ; Camera position
      \TargetNode = CreateNode(#PB_Any) ; For cameraLookAt
      AttachNodeObject(\CameraNode, CameraID(\Camera), #PB_Node_Camera)
    EndWith 
   
    ;-Main loop   
    ;
    Repeat
      Screen3DEvents()
     
      If Engine3DFrameRate(#PB_Engine3D_Current)
        Robot\elapsedTime = 40/Engine3DFrameRate(#PB_Engine3D_Current)
      EndIf       
     
      HandleEntity(@Robot)
     
      CameraTrack(@Camera, @Robot)
     
      RenderWorld(50)
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
 
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf

End

Procedure OnGround(*Entity.s_Entity)
  With *Entity
    ProcedureReturn RayCollide(NodeX(\MainNode),  NodeY(\MainNode)+3, NodeZ(\MainNode), NodeX(\MainNode), NodeY(\MainNode),  NodeZ(\MainNode))
  EndWith 
EndProcedure

Procedure IsStair(*Entity.s_Entity)
  Protected.f x, y, z
  With *Entity
    x = (NodeX(\ForwardNode) - NodeX(\MainNode))*30
    y = (NodeY(\ForwardNode) - NodeY(\MainNode))*30
    z = (NodeZ(\ForwardNode) - NodeZ(\MainNode))*30
    ;CreateLine3D(20, NodeX(\MainNode), NodeY(\MainNode)+20, NodeZ(\MainNode), $FFFF, NodeX(\MainNode)+V\x, NodeY(\MainNode)+V\y+20,  NodeZ(\MainNode)+V\z, $FFFF)
    Ray1 = RayCollide(NodeX(\MainNode), NodeY(\MainNode)+10, NodeZ(\MainNode),  NodeX(\MainNode)+x, NodeY(\MainNode)+y+10,  NodeZ(\MainNode)+z)
    Ray2 = RayCollide(NodeX(\MainNode), NodeY(\MainNode)+20, NodeZ(\MainNode),  NodeX(\MainNode)+x, NodeY(\MainNode)+y+20,  NodeZ(\MainNode)+z)
    If Ray1 And Ray2=0
      ProcedureReturn 1
    EndIf
    ProcedureReturn 0
  EndWith 
EndProcedure

Procedure HandleEntity(*Entity.s_Entity)
  Protected.Vector3 Forward, Strafe, PosMain, PosDir, PosStrafe
  Protected.f Speed, Speed2, x, y, MouseX, MouseY, Action.s
  Static Jump.f, MemJump.i, Rot.Vector3, Trans.Vector3, Clic, LastAction.s
 
  With *Entity
    GetNodePosition(PosMain, \MainNode)
    GetNodePosition(PosDir, \ForwardNode)
    GetNodePosition(PosStrafe, \StrafeNode)
    SubVector3(Forward, PosDir, PosMain)
    SubVector3(Strafe, PosStrafe, PosMain)
   
    Speed = #PlayerSpeed * \elapsedTime
    Speed2 = Speed / 2
   
    If ExamineKeyboard()
     
      If KeyboardReleased(#PB_Key_F5)
        WorldDebug(#PB_World_DebugBody)
      ElseIf KeyboardReleased(#PB_Key_F6)
        WorldDebug(#PB_World_DebugEntity)
      ElseIf KeyboardReleased(#PB_Key_F7)
        WorldDebug(#PB_World_DebugNone)
      EndIf
     
      If KeyboardPushed(\Key\Jump) And OnGround(*Entity)
        Jump = 4
        MemJump = 1
      EndIf 
     
      Rot\x * 0.30
      Rot\y * 0.30
      Rot\z * 0.30
      Trans\x * 0.20
      Trans\y = Jump
      Trans\z * 0.20
     
      Action = "Stop"
     
      If KeyboardPushed(\Key\Up)
        Trans\x + Forward\x * Speed
        Trans\z + Forward\z * Speed
        Action = "Walk"
      ElseIf KeyboardPushed(\Key\Down)
        Trans\x + Forward\x * -Speed2
        Trans\z + Forward\z * -Speed2
        Action = "Walk"
      EndIf
     
      If KeyboardPushed(\Key\Left)
        Rot\y + 2 * \elapsedTime
      ElseIf KeyboardPushed(\Key\Right)
        Rot\y - 2 * \elapsedTime
      EndIf
     
      If KeyboardPushed(\Key\StrafeLeft)
        Trans\x + Strafe\x * Speed2
        Trans\z + Strafe\z * Speed2
        Action = "Walk"
      ElseIf KeyboardPushed(\Key\StrafeRight)
        Trans\x + Strafe\x * -Speed2
        Trans\z + Strafe\z * -Speed2
        Action = "Walk"
      EndIf
     
      If Action <> LastAction
        LastAction = Action
        AnimateEntity(0, Action)
      EndIf
     
      If OnGround(*Entity)
        Jump = 0
      ElseIf MemJump 
        Jump + 20
        If Jump > 80
          MemJump = 0
        EndIf 
      Else 
        Jump - 9
      EndIf 
     
      If IsStair(*Entity) And Jump = 0 And ( Abs(Trans\x)>=Speed / 2 Or Abs(Trans\z)>=Speed / 2)
        Jump = 22 ; Or more
      EndIf
     
    EndIf
   
    MoveEntity  (\EntityBody, Trans\x, Trans\y, Trans\z)
    RotateEntity(\EntityBody, 0, Rot\y, 0, #PB_Relative)   
   
    NodeLocate(\MainNode, EntityX(\EntityBody), EntityY(\EntityBody)-\BodyOffsetY, EntityZ(\EntityBody))
    RotateNode(\MainNode, 0, EntityYaw(\EntityBody), 0)
  EndWith   
EndProcedure


Procedure CameraTrack(*Camera.s_Camera, *Entity.s_Entity)
  Protected CameraPosition.Vector3, TargetPosition.Vector3, Temp.Vector3
  Protected V1.Vector3, V2.Vector3, x.f, y.f, z.f
 
  GetNodePosition(CameraPosition, *Entity\CameraNode)
  GetNodePosition(TargetPosition, *Entity\SightNode)
  x = NodeX(*Camera\CameraNode)
  y = NodeY(*Camera\CameraNode)
  z = NodeZ(*Camera\CameraNode)
  x = (CameraPosition\x - x) *  *Camera\Tightness
  y = (CameraPosition\y - y) *  *Camera\Tightness
  z = (CameraPosition\z - z) *  *Camera\Tightness
  MoveNode(*Camera\CameraNode, x, y, z)
 
  x = NodeX(*Camera\TargetNode)
  y = NodeY(*Camera\TargetNode)
  z = NodeZ(*Camera\TargetNode)
  x = (TargetPosition\x - x) *  *Camera\Tightness
  y = (TargetPosition\y - y) *  *Camera\Tightness
  z = (TargetPosition\z - z) *  *Camera\Tightness
  MoveNode(*Camera\TargetNode, x, y, z)
 
  CameraLookAt(*Camera\Camera, NodeX(*Camera\TargetNode), NodeY(*Camera\TargetNode), NodeZ(*Camera\TargetNode))
 
EndProcedure


Procedure MakeColimacon(PX.f, PY.f, PZ.f, Length.i, Height.i, Width.i, Stair.i)
  Protected.f Angle
  Protected.i a, Ent
 
  For a = 1 To Stair
    Ent = CreateEntity(#PB_Any, MeshID(3), MaterialID(2))
    ScaleEntity(Ent, Length, Height, Width)
    EntityLocate(Ent, PX + Cos(Radian(Angle)) * Width * 5, PY + (a-1) * Height * 4, PZ -Sin(Radian(Angle)) * Width * 5)
    RotateEntity(Ent, 0, Angle, 0)
    EntityPhysicBody(Ent, #PB_Entity_StaticBody)
    Angle = Mod(Angle + 30, 360)
  Next
EndProcedure

Procedure MakeStair(PX.f, PY.f, PZ.f, Length.i, Height.i, Width.i, Stair.i)
  Protected.i a, Ent, Nb
  Protected.f Size, Delta, H 
 
  For a = 1 To Stair
    Ent = CreateEntity(#PB_Any, MeshID(3), MaterialID(2))
    ScaleEntity(Ent, Length, Height, Width)
    EntityLocate(Ent, PX, PY + (a-1) * Height, PZ + (a-1) * Width * 0.8)
    EntityPhysicBody(Ent, #PB_Entity_StaticBody)
  Next a
 
  ;Add a plateform
  Ent = CreateEntity(#PB_Any, MeshID(3), MaterialID(2))
  ScaleEntity(Ent, Length*5, Height, Width*5)
  EntityLocate(Ent, PX, PY + (a-1) * Height, PZ + (a-1) * Width)
  EntityPhysicBody(Ent, #PB_Entity_StaticBody)
 
  ;Add Pyramid
  Nb = 7
  Delta = 0.01
  Size = 20
  H = EntityY(Ent) + Height/2
  For j = 0 To Nb
    For i= 0 To Nb-j
      Ent = CreateEntity(#PB_Any, MeshID(3), MaterialID(4))
      ScaleEntity(Ent, Size, Size, Size)
      EntityPhysicBody(Ent, #PB_Entity_BoxBody, 0.5)
      EntityLocate(Ent, 340 +  j * ((Size) / 2) + i * Size, H + ((Size) / 2) + (j * (Size)), 890)
    Next
  Next
EndProcedure

Procedure AddObjects()
  Protected Size.Vector3
  Protected.f x, z
  Protected.i Ent, i 
 
  For i = 0 To 100
    If Random(1)
      Size\x = Random(60) + 30
      Size\y = Random(60) + 30
      Size\z = Random(60) + 30     
      Volume.f = Size\x * Size\y * Size\z
      Ent=CreateEntity(#PB_Any, MeshID(3), MaterialID(3), Random(5000)-2600, 100, Random(5000)-2500)
      RotateEntity(Ent, 0, Random(360), 0)
      ScaleEntity(ent, Size\x, Size\y, Size\z)       
      EntityPhysicBody(Ent, #PB_Entity_BoxBody, (Volume / 7000), 0, 2)
    Else
      Size\x = Random( 60) + 30
      Size\y = Random(160) + 30
      Size\z = Random( 60) + 30     
     
      Repeat
        x = Random(5000)-2500
      Until x < -400 Or x > 400 
     
      Repeat
        z = Random(5000)-2500
      Until z < -400 Or z > 400 
     
      Ent=CreateEntity(#PB_Any, MeshID(3), MaterialID(2), x, Size\y/2 + Random(90) , z)
      RotateEntity(Ent, 0, Random(360), 0)
      ScaleEntity(Ent, Size\x, Size\y, Size\z)
      EntityPhysicBody(Ent, #PB_Entity_StaticBody)   
    EndIf
   
  Next
EndProcedure   


Top
 Profile  
 
 Post subject: Re: 4.60 3DEngine demos
PostPosted: Sun Nov 13, 2011 7:57 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Mar 24, 2011 12:40 am
Posts: 160
Location: Iowa, USA
I know what is causing objects to not be in front of the camera on start up.
At least in the case of 'Billboard'.
The first time the loop executes the MouseDeltaX() and MouseDeltaY()
return a value other than zero.
this line:
Code:
RotateCamera(0, MouseY, MouseX, RollZ, #PB_Relative)

then rotates the camera.

Put this code before the 'repeat' loop.
Code:
    If ExamineMouse()
      MouseDeltaX()
      MouseDeltaY()
    EndIf

Then the first pass thru the loop MouseDeltaX() and MouseDeltaY()
return zero and the camera does not rotate.

What about that 'RollZ' variable in the line above?
It's not defined or used anywhere else in the code and could just
as well be a zero.

Chances are this is the cause of some of the other demos having the same
problem but I haven't checked.

B.P.


Top
 Profile  
 
 Post subject: Re: 4.60 3DEngine demos
PostPosted: Sun Nov 13, 2011 10:09 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 2506
Location: New Zealand
Added the improved ThirdPerson, fixed the jump decent so it uses the elapsedtime

Code:
 ;~line 296
 If OnGround(*Entity)
        Jump = 0
      ElseIf MemJump
        Jump + 30
        If Jump > 80
          MemJump = 0
        EndIf
      Else
        Jump - 4 * \elapsedTime
      EndIf



fixed the billboard it shouldn't have been calling divide not when the mouse delta could be zero
I'll fix up the other examples so they're the same.
Code:
 
  ;#CameraSpeed = 1
  If ExamineMouse()
      MouseX = MouseDeltaX()*#CameraSpeed*0.05
      MouseY = MouseDeltaY()*#CameraSpeed*0.05
  EndIf


Thanks the Third person demo is much better


Top
 Profile  
 
 Post subject: Re: 4.60 3DEngine demos
PostPosted: Mon Nov 14, 2011 11:19 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Aug 19, 2003 11:36 am
Posts: 1106
Location: Doubs - France
"Stop" is not an animation, try this one
Code:
Action = "Idle"

_________________
Please correct my english
http://purebasic.developpez.com/


Top
 Profile  
 
 Post subject: Re: 4.60 3DEngine demos
PostPosted: Mon Nov 14, 2011 11:36 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 2506
Location: New Zealand
Comtois wrote:
"Stop" is not an animation, try this one
Code:
Action = "Idle"


that's the same action I try to perform every day :lol:

cheers


Top
 Profile  
 
 Post subject: Re: 4.60 3DEngine demos
PostPosted: Mon Nov 28, 2011 8:44 pm 
Offline
User
User
User avatar

Joined: Fri Jan 28, 2005 11:53 pm
Posts: 25
Location: Otterloh
Hola BasicallyPure,

did you use the debugger while doing the tests on the demos???

I had the same problems with the delivered demos, your demos ran well...with the debugger just before the "end" statement. The problem was the finishing in the library. I testet it without debugger and most demos ran perfectly (I didn't test all of them).

Greetings
Thorsten

_________________
nullius jurare in verba magistri
"You probably know that arrogance, in computer science, is measured in nanodijkstras." Alan Kay, keynote speech at OOPSLA 1997


Top
 Profile  
 
 Post subject: Re: 4.60 3DEngine demos
PostPosted: Mon May 21, 2012 10:46 am 
Offline
Addict
Addict
User avatar

Joined: Tue Aug 19, 2003 11:36 am
Posts: 1106
Location: Doubs - France
idle wrote:
Note that ExamineMouse() needs to be called before ExamineKeyBoard() or the mouse will lag and freeze
you need to set the keyboard mode to international to use the arrow keys KeyboardMode(#PB_Keyboard_International)


After reading this, is this still valid with version 4.61 ?

_________________
Please correct my english
http://purebasic.developpez.com/


Top
 Profile  
 
 Post subject: Re: 4.60 3DEngine demos
PostPosted: Mon May 21, 2012 12:12 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 8951
Location: France
No, order isn't important anymore and KeyboardMode() has no effect on Linux (always in international mode)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye