trying to draw a 2d line in 3d

Blitz3D Forums/Blitz3D Programming/trying to draw a 2d line in 3d

dman(Posted 2011) [#1]
How can I use the line command to draw a line in a 3d section of the screen?


I want to square off a section of the screen with 3d, then draw lines within that section also have clipping. So the lines do not go outside the section.


Kryzon(Posted 2011) [#2]
I don't really understand what you're trying to do.
Any drawing operation you do after calling RenderWorld() will overlay the 3D scene, so you can either use the Line() function or build a 3D line object with the following code: http://blitzbasic.com/codearcs/codearcs.php?code=839 (copy and paste that to see what it does, it's very nice).


Yasha(Posted 2011) [#3]
Here's a similar thing that lets the lines have thickness: http://www.blitzbasic.com/codearcs/codearcs.php?code=2590

...although use with aution, as it may be rather buggier than the other one (it doesn't work if one end of the line is behind the camera).

</owntrumpet>


dman(Posted 2011) [#4]
I fail to mention, that I wanted something like the viewport.
I tried using the viewport but it only let me use one. I need two viewports and be able to put them anywhere on the screen and use the line command in 2d instead of 3d, because I'm using the line command to draw.

someone used cameras in darkbasic pro to do the same effect.
I wonder if the same can be done in blitz3d.

Last edited 2011


Warner(Posted 2011) [#5]
No, I don't think that is possible. You could maybe use ImageBuffers for this?


Last edited 2011


_PJ_(Posted 2011) [#6]
You can use ViewPort command, ensuring the parameters are set to match the same as the 3D camera's CameraViewPort, Do all your 2D drawing AFTER the Renderworld command.

You can use the Viewport command multiple times, keeping te drawing routines separate for each 'window'.

Alternatively, as Warner suggests, use ImageBuffers.


Kryzon(Posted 2011) [#7]
I tried using the viewport but it only let me use one. I need two viewports and be able to put them anywhere on the screen and use the line command in 2d instead of 3d, because I'm using the line command to draw.

someone used cameras in darkbasic pro to do the same effect.
I wonder if the same can be done in blitz3d.

This can be done if you specify viewports that don't overlap. The CameraViewport command specifies the viewport for a single camera. Just specify different viewports for each of the cameras you have in your scene. A single call to RenderWorld will render all the viewports.

Use the coordinates you specified for each viewport as reference when drawing the lines around them.

The help file is clear that this can be used to achieve split-screen or multiple-views effects.

Last edited 2011


Adam Novagen(Posted 2011) [#8]
The help file is clear that this can be used to achieve split-screen or multiple-views effects.

You can even see multiple cameras in action from the Blitz demos. On the B3D main page - the one you see when you first boot the Blitz IDE - click Games, and load up "Wing Ring." It uses a multi-camera system, the main camera situated behind the fighter, and a smaller HUD-type camera for an overhead view.

As for drawing 2D on 3D, remember this very important yet so small and easy-to-miss detail: ALL 2D DRAWING COMMANDS SHOULD BE CALLED AFTER RenderWorld() IN YOUR MAIN LOOP. RenderWorld() acts like very much like DrawBlock() when it draws the 3D onto the screen. Any images, lines, rectangles or whatever that are drawn prior to it, or "underneath" it, will be drawn OVER and obscured. That could be your entire problem right there; make sure your line-drawing code is coming AFTER RenderWorld(), not before.

Just to make this as simple as I possibly can, here's a fully functional example. Copy and paste it into a blank Blitz file:




dman(Posted 2011) [#9]
thanks everyone, but I found out how to use viewport command.

I call the viewport with the location then draw my lines then call the other viewport with location and draw lines.

I put them in a loop so they get updated.


thanks again...