Jump to content

GIMPY73

Members
  • Posts

    300
  • Joined

  • Last visited

Everything posted by GIMPY73

  1. Cheers For the link MG , will take a look I'm also going over Aggror's lua code again I'm just after selecting a cube/sphere/model etc.. , then lock it to the mouse's X,Y,Z. Then release the mouse button to place the cube/sphere/model etc.. The code i did kinda works , but as you've seen if the mouse is moved fast it lets go of the selected object. Thanks Gimpy73
  2. Well still no luck with this , but i did come up with a simple Point'N'Click routine Thanks Gimyp73
  3. Ok here is a simple point'n'click routine:) 'Use the Leadwerks Engine module as our base Framework leadwerks.engine 'Create an OpenGL graphics window Graphics 800, 600 'Allows the engine to find files and load files from zip packages RegisterAbstractPath AppDir 'Create a world If Not CreateWorld() RuntimeError "Failed to create world." 'Create a camera cam:TCamera = CreateCamera() 'MoveEntity cam, Vec3(0, 45, - 45) 'create a ligt light:TLight = CreateDirectionalLight() RotateEntity(light, Vec3(65, 45, 0)) 'Create a render Buffer buffer:TBuffer = CreateBuffer(800, 600, BUFFER_COLOR | BUFFER_DEPTH | BUFFER_NORMAL) piv=createpivot() 'create a mesh cube:TMesh = CreateCube() Local plane:tentity = CreatePlane() ScaleEntity plane, Vec3(100,0.1,100) PaintEntity (plane,LoadMaterial("abstract::cobblestones.mat")) Local pick:TPick 'Main loop While Not KeyHit(KEY_ESCAPE) positionentity (cam,vec3(cube.position.x,cube.position.y+25,cube.position.z-25)) pointentity cam,cube 'pick objects with the mouse If MouseDown(1) = True pick = CameraPick(cam, Vec3(MouseX(), MouseY(), 1000)) If pick Then positionentity (piv,vec3(pick.x,.5,pick.z)) pointentity cube,piv Local speed#=.3 End If End If If (entitydistance(cube,piv) < 1.2) speed#=0 End If moveentity cube,vec3(0,0,speed#) 'Update timing, physics, and other miscellaneous updates UpdateWorld 'Draw the world SetBuffer(buffer) RenderWorld 'render lighting SetBuffer(BackBuffer()) RenderLights(buffer) 'Swap the graphics buffers so we can see what we drew Flip Wend Could be used for an RPG/RTS style of game. Feel free to laugh/poke fun at it , just thought i would share Thanks Gimpy73
  4. Thanks Aggror , will check it out Thanks Gimpy73
  5. Ok had a play with CameraProject , aint gota clue what im doing lol 'Use the Leadwerks Engine module as our base Framework leadwerks.engine 'Create an OpenGL graphics window Graphics 800, 600 'Allows the engine to find files and load files from zip packages RegisterAbstractPath AppDir 'Create a world If Not CreateWorld() RuntimeError "Failed to create world." 'Create a camera cam:TCamera = CreateCamera() CameraClearColor(cam, Vec4(0, 0, 1, 1)) MoveEntity cam, Vec3(0, 30, -10) 'create a ligt light:TLight = CreateDirectionalLight() RotateEntity(light, Vec3(65, 45, 0)) 'Create a render Buffer buffer:TBuffer = CreateBuffer(800, 600, BUFFER_COLOR | BUFFER_DEPTH | BUFFER_NORMAL) 'create a mesh cube:TMesh = CreateCube() sphere:TMesh = Createsphere() positionentity sphere,vec3(0,10,0) Local pick:TPick 'create materials selectionmaterial:TMaterial = CreateMaterial() SetMaterialColor(selectionmaterial, Vec4(1, 0, 0, 1)) pointentity cam , cube debugphysics(1) depth:Float = 0.0 near:Float = 1.0 far:Float = 10.0 'Main loop While Not KeyHit(KEY_ESCAPE) 'pick objects with the mouse If MouseDown(1) PaintEntity(cube, 0) PaintEntity(sphere, 0) pick = CameraPick(cam, Vec3(MouseX(), MouseY(), 1000)) If pick Then PaintEntity(pick.entity, selectionmaterial) glReadPixels(MouseX(), GraphicsHeight() - MouseY(), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, Varptr(depth)) z:Float = near / (far - depth * (far - near)) * far; pos:TVec3 = CameraProject(cam, Vec3(MouseX(), MouseY(), z)) positionentity (pick.entity, Vec3(pos.x,pos.y,pos.z)) End If End If 'Update timing, physics, and other miscellaneous updates UpdateWorld 'Draw the world SetBuffer(buffer) RenderWorld DrawText "Depth: " + depth, 0, 0 DrawText "Projected: " + pos.x + ", " + pos.y + ", " + pos.z,0,12 'render lighting SetBuffer(BackBuffer()) RenderLights(buffer) 'Swap the graphics buffers so we can see what we drew Flip Wend It seems to hold onto the mouse better , but it still don't seem right. Thanks Gimpy73
  6. Ahh a new command to look into Cheers MG , will try CameraProject command and see what i can come up with. Thanks Gimpy73
  7. Ok i see what is happening there MG. So maybe i need to set some kind of flag , that turns the pick off once an entity is selected ??? Thanks Gimpy73
  8. HA HA MG Just read the link to the super glue Thanks Gimpy73
  9. Yep thats what is happening MG Maybe i need to add somit about the mouse speed ?? Anyway thanks for looking @Lumooja I'll try holding the mouse button down with 2 hands lol Thanks Gimpy73
  10. Ok after going through the BMax tut's that Foolish converted , I started to play about with the Pick commands. Now what i'm after is : Select a cube with the mouse. Attach the cube to the mouse's x,y,z coordinates while the mouse button is held. Drop the cube when mouse button is released. Here is what i have sofar: 'Use the Leadwerks Engine module as our base Framework leadwerks.engine 'Create an OpenGL graphics window Graphics 800, 600 'Allows the engine to find files and load files from zip packages RegisterAbstractPath AppDir 'Create a world If Not CreateWorld() RuntimeError "Failed to create world." 'Create a camera cam:TCamera = CreateCamera() CameraClearColor(cam, Vec4(0, 0, 1, 1)) MoveEntity cam, Vec3(0, 20, - 35) 'create a ligt light:TLight = CreateDirectionalLight() RotateEntity(light, Vec3(65, 45, 0)) 'Create a render Buffer buffer:TBuffer = CreateBuffer(800, 600, BUFFER_COLOR | BUFFER_DEPTH | BUFFER_NORMAL) 'create a mesh cube:TMesh = CreateCube() Local pick:TPick 'create materials selectionmaterial:TMaterial = CreateMaterial() SetMaterialColor(selectionmaterial, Vec4(1, 0, 0, 1)) pointentity cam , cube 'Main loop While Not KeyHit(KEY_ESCAPE) 'pick objects with the mouse If MouseDown(1) PaintEntity(cube, 0) pick = CameraPick(cam, Vec3(MouseX(), MouseY(), 1000)) If pick Then PaintEntity(pick.entity, selectionmaterial) positionentity (pick.entity , vec3(pick.x,0,pick.z)) End If End If 'Update timing, physics, and other miscellaneous updates UpdateWorld 'Draw the world SetBuffer(buffer) RenderWorld 'render lighting SetBuffer(BackBuffer()) RenderLights(buffer) 'Swap the graphics buffers so we can see what we drew Flip Wend It kinda works , but the cube keeps letting go , even if i still have the mouse button held down??? Any ideas Thanks Gimpy73
  11. Well thanks for all the hard work Foolish Time for me to get stuck into BlitzMax , and make somit Thanks Gimpy73
  12. Thanks Foolish Thanks Gimpy73
  13. Thanks Foolish Oh and thanks Puki for having an idea Thanks Gimpy73
  14. Great news Foolish Looking foward to go through them. Thanks Gimpy73
  15. You have BMax code for the first 17 tutorials?? Would be cool and a help to other BMax user's if you uploaded them to the wiki/code section of this site. Thanks Gimpy73
  16. Thanks Joh As Mac said your code worked fine Thanks Gimpy73
  17. Hey Mac. Did you find a solution to this problem?? Ive been looking at the BlitzMax code on the wiki and that works for a mesh , but i would also like this to work on a loaded model. Thanks Gimpy73
  18. Hey Rick. Once you have loaded in your heightmap , try changing the altitude > 100. Thanks Gimpy73
  19. Feel free to use it RP Thanks Gimpy73
  20. This is looking great Dave , keep it up
×
×
  • Create New...