We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
No difference between AddBackImage and AddImage in LD3DView
#1
Hi
I noticed there is no difference between AddBackImage and AddImage in LD3DView.

st
Reply
#2
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!
[-] The following 1 user Likes litdev's post:
  • stevantosic
Reply
#3
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
[-] The following 1 user Likes stevantosic's post:
  • litdev
Reply
#4
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.
Reply
#5
Sad 
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?
Reply
#6
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.
[-] The following 3 users Like litdev's post:
  • AbsoluteBeginner, Scout, stevantosic
Reply
#7
Thumbs Up 
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 ?

   


Attached Files Thumbnail(s)
   
[-] The following 3 users Like Scout's post:
  • AbsoluteBeginner, litdev, stevantosic
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)