Small Basic Forum
No difference between AddBackImage and AddImage in LD3DView - Printable Version

+- Small Basic Forum (https://litdev.uk/mybb)
+-- Forum: Small Basic (https://litdev.uk/mybb/forumdisplay.php?fid=1)
+--- Forum: Extensions (https://litdev.uk/mybb/forumdisplay.php?fid=3)
+--- Thread: No difference between AddBackImage and AddImage in LD3DView (/showthread.php?tid=29)



No difference between AddBackImage and AddImage in LD3DView - stevantosic - 01-23-2024

Hi
I noticed there is no difference between AddBackImage and AddImage in LD3DView.

st


RE: No difference between AddBackImage and AddImage in LD3DView - litdev - 01-24-2024

Hi st,

The difference is quite subtle, but AddBackImage applies to the back of an object and AddImage to the front.  By default the back surface is not shown.  Google 'GeometryModel3D.BackMaterial' for more info.

We should be able to see the effect with this

Code:
view3D = LD3DView.AddView(GraphicsWindow.Width,GraphicsWindow.Height,"True")
LD3DView.AutoControl("True","True",2,1)
LD3DView.AddDirectionalLight(view3D,"White",-0.612372,-0.5,-0.612372)
LD3DView.AddDirectionalLight(view3D,"White",0.612372,-0.5,-0.612372)
triangle = LD3DView.AddGeometry(view3D,"-0.5 -0.5 0.5 0.5 -0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 -0.5 0.5 0.5 -0.5 -0.5 0.5","0 1 2 3 4 5","","Red","D")
LD3DView.AddBackImage(view3D,triangle,"","Blue","D")
LD3DView.AnimateRotation(view3D,triangle,1,0,0,0,360,5,-1)

However, there is a BUG preventing the back material from being correctly added.

I have uploaded the fix to Beta version of LitDev extension version 1.2.26.0

Thanks for reporting!


RE: No difference between AddBackImage and AddImage in LD3DView - stevantosic - 01-24-2024

Thanks LitDev.

I have just tried this:

LD3DView.SetBackMaterial(view3D, floor, "Yellow", "D")
LD3DView.AddBackImage(view3D,floor,textures,img,"D")

and it also works.

st


RE: No difference between AddBackImage and AddImage in LD3DView - litdev - 01-24-2024

Yeah, that also makes sense. AddBackImage adds a layer to back material, SetBackMaterial creates it. The bug was related to adding before creating, the fix was to create and add if it didn't already exist.


RE: No difference between AddBackImage and AddImage in LD3DView - Scout - 01-26-2024

I haven't managed to insert a back image yet. For the solid bodies at least the image passed with AddImage appears; with AddGeometry only the colors appear.

Code:
LDUtilities.CurrentCulture = "en-US"
LDUtilities.Version()

Outside = ImageList.LoadImage (Program.Directory + "\Teich.jpg")'<-----------put ur image here
Inside  = ImageList.LoadImage (Program.Directory + "\Rosen.jpg")'<-----------put ur image here
view3D = LD3DView.AddView(GraphicsWindow.Width,GraphicsWindow.Height,"True")
LD3DView.AutoControl("True","True",2,1)
LD3DView.AddDirectionalLight(view3D,"White",-0.612372,-0.5,-0.612372)
LD3DView.AddDirectionalLight(view3D,"White",0.612372,-0.5,-0.612372)
cone =LD3DView.AddPipe  (view3D 13 6 8 36 "white" "D")
LD3DView.AddImage(view3D,cone,"",Outside ,"D")
LD3DView.SetBackMaterial(view3D,cone ,  "Green" ,"D")
LD3DView.AddBackImage(view3D,cone,"", Inside ,"D")
LD3DView.TranslateGeometry (view3D,cone,-5,1,-5)
LD3DView.AnimateRotation(view3D,cone,1,0,0,0,360,15,-1)

triangle = LD3DView.AddGeometry(view3D,"-0.5 -0.5 0.5 0.5 -0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 -0.5 0.5 0.5 -0.5 -0.5 0.5","0 1 2 3 4 5","","Red","D")
LD3DView.AddImage(view3D,triangle,"",Outside ,"D")
LD3DView.SetBackMaterial(view3D,triangle ,  "Green" ,"D")
LD3DView.AddBackImage(view3D,triangle,"", Inside ,"D")
LD3DView.TranslateGeometry (view3D,triangle,5,5,-5)
LD3DView.AnimateRotation(view3D,triangle,1,5,1,0,360,5,-1)

cube = LD3DView.AddGeometry(view3D,"-1 1 1 -1 -1 1 1 -1 1 1 1 1 1 1 1 1 -1 1 1 -1 -1 1 1 -1 -1 1 -1 -1 1 1 1 1 1 1 1 -1","0 1 2 2 3 0 4 5 6 6 7 4 8 9 10 10 11 8","","Red","D")
LD3DView.AddImage(view3D,cube,"",Outside ,"D")
LD3DView.SetBackMaterial(view3D,cube ,  "Green" ,"D")
LD3DView.AddBackImage(view3D,cube,"", Inside ,"D")
LD3DView.TranslateGeometry (view3D,cube,10,10,-5)
LD3DView.AnimateRotation(view3D,cube,1,11,1,0,360,3,-1)

   

Does anyone have a small demo that displays both images?


RE: No difference between AddBackImage and AddImage in LD3DView - litdev - 01-26-2024

Hi Scout,

Outside (front) is defined by triangle index order, anticlocwise as viewed from the front (2D) or from outside for a 3D shape.  Backface is therefore when viewed with clockwise triangle indices.

To view the backface of a 3D object you must be inside looking out.  Viewing from the other side is still looking at the outside faces, just from a different direction.

Code:
view3D = LD3DView.AddView(GraphicsWindow.Width,GraphicsWindow.Height,"True")
LD3DView.AutoControl("True","True",2,1)
LD3DView.AddDirectionalLight(view3D,"White",-0.612372,-0.5,-0.612372)
LD3DView.AddDirectionalLight(view3D,"White",0.612372,-0.5,-0.612372)
cube = LD3DView.AddCube(view3D,1,"Red","D")
LD3DView.AddBackImage(view3D,cube,"","Blue","D")
LD3DView.AnimateRotation(view3D,cube,1,0,0,0,360,5,-1)

Above is a cube, with inside coloured blue, to get inside you need to mouse wheel back.

Harder to position inside your tube, but its there for me when viewed from inside it.


RE: No difference between AddBackImage and AddImage in LD3DView - Scout - 01-26-2024

Thanks Litdev

It works !

Code:
LDUtilities.CurrentCulture = "en-US"
Outside = ImageList.LoadImage (Program.Directory + "\Teich.jpg")'<-----------put ur image here
Inside  = ImageList.LoadImage (Program.Directory + "\Rosen.jpg")'<-----------put ur image here
view3D = LD3DView.AddView(GraphicsWindow.Width,GraphicsWindow.Height,"True")
LD3DView.AutoControl("True","True",2,1)
LD3DView.AddDirectionalLight(view3D,"White",-0.612372,-0.5,-0.612372)
LD3DView.AddDirectionalLight(view3D,"White",0.612372,-0.5,-0.612372)
cube = LD3DView.AddCube(view3D,1,"Red","D")
LD3DView.AddImage(view3D,cube,"",Outside,"D")
LD3DView.AddBackImage(view3D,cube,"",Inside,"D")
LD3DView.AnimateRotation(view3D,cube,1,1,1,0,360,15,-1)
 
The sea outside and the roses inside.
What more do you want ?