× General stuff

Request for help with model rendering (Specifically from Manus)

  • Posts: 100
  • Thank you received: 4

GolddolphinSKB created the topic: Request for help with model rendering (Specifically from Manus)

Hello all,
I have restarted work on my web-based model rendering tool which imports from a Flans Mod Model.
Current Progress
As you can see, the model isn't drawing very well because some vertex co-ordinates are wrong based on my calculations.

I request to see Toolbox's vertex calls and the calculation of vertices so that I can get a better idea of what I should be doing dimensions wise.
Thanks in advance,
GoldSloth

#80084

Please Log in or Create an account to join the conversation.

  • Posts: 1804
  • Karma: 40
  • Thank you received: 52

Manus replied the topic: Request for help with model rendering (Specifically from Manus)

What exactly do you require?

#80085

Please Log in or Create an account to join the conversation.

  • Posts: 100
  • Thank you received: 4

GolddolphinSKB replied the topic: Request for help with model rendering (Specifically from Manus)

I would request source code for the parts in Toolbox which do the following things:
Take dimensions of shapebox (Something like size, position and offset)
and converts them to co-ordinates to send to OpenGL using somthing like:
vertex(x, y, z)

If you can easily provide these, I would be grateful.
If not, it is okay, I'll work it out again to try and get it right.

#80086

Please Log in or Create an account to join the conversation.

  • Posts: 1804
  • Karma: 40
  • Thank you received: 52

Manus replied the topic: Request for help with model rendering (Specifically from Manus)

you mean something like this?

x0 = CSng(0 + Parts.Item(id).OffsetX - CDbl(Parts.Item(id).ShapeBoxX(0)) - P1X)
y0 = CSng(0 - Parts.Item(id).OffsetY + CDbl(Parts.Item(id).ShapeBoxY(0)) + P1Y)
z0 = CSng(0 + Parts.Item(id).OffsetZ - CDbl(Parts.Item(id).ShapeBoxZ(0)) - P1Z)

x1 = CSng(0 + CInt(Parts.Item(id).DimX) + Parts.Item(id).OffsetX + CDbl(Parts.Item(id).ShapeBoxX(1)) + P2X + DimX)
y1 = CSng(0 - Parts.Item(id).OffsetY + CDbl(Parts.Item(id).ShapeBoxY(1)) + P2Y)
z1 = CSng(0 + Parts.Item(id).OffsetZ - CDbl(Parts.Item(id).ShapeBoxZ(1)) - P2Z)

x2 = CSng(0 + CInt(Parts.Item(id).DimX) + Parts.Item(id).OffsetX + CDbl(Parts.Item(id).ShapeBoxX(2)) + P3X + DimX)
y2 = CSng(0 - Parts.Item(id).OffsetY + CDbl(Parts.Item(id).ShapeBoxY(2)) + P3Y)
z2 = CSng(0 + CInt(Parts.Item(id).DimZ) + Parts.Item(id).OffsetZ + CDbl(Parts.Item(id).ShapeBoxZ(2)) + P3Z + DimZ)

x3 = CSng(0 + Parts.Item(id).OffsetX - CDbl(Parts.Item(id).ShapeBoxX(3)) - P4X)
y3 = CSng(0 - Parts.Item(id).OffsetY + CDbl(Parts.Item(id).ShapeBoxY(3)) + P4Y)
z3 = CSng(0 + CInt(Parts.Item(id).DimZ) + Parts.Item(id).OffsetZ + CDbl(Parts.Item(id).ShapeBoxZ(3)) + P4Z + DimZ)

x4 = CSng(0 + Parts.Item(id).OffsetX - CDbl(Parts.Item(id).ShapeBoxX(4)) - P5X)
y4 = CSng(0 - CInt(Parts.Item(id).DimY) - Parts.Item(id).OffsetY - CDbl(Parts.Item(id).ShapeBoxY(4)) - P5Y + DimY)
z4 = CSng(0 + Parts.Item(id).OffsetZ - CDbl(Parts.Item(id).ShapeBoxZ(4)) - P5Z)

x5 = CSng(0 + CInt(Parts.Item(id).DimX) + Parts.Item(id).OffsetX + CDbl(Parts.Item(id).ShapeBoxX(5)) + P6X + DimX)
y5 = CSng(0 - CInt(Parts.Item(id).DimY) - Parts.Item(id).OffsetY - CDbl(Parts.Item(id).ShapeBoxY(5)) - P6Y + DimY)
z5 = CSng(0 + Parts.Item(id).OffsetZ - CDbl(Parts.Item(id).ShapeBoxZ(5)) - P6Z)

x6 = CSng(0 + CInt(Parts.Item(id).DimX) + Parts.Item(id).OffsetX + CDbl(Parts.Item(id).ShapeBoxX(6)) + P7X + DimX)
y6 = CSng(0 - CInt(Parts.Item(id).DimY) - Parts.Item(id).OffsetY - CDbl(Parts.Item(id).ShapeBoxY(6)) - P7Y + DimY)
z6 = CSng(0 + CInt(Parts.Item(id).DimZ) + Parts.Item(id).OffsetZ + CDbl(Parts.Item(id).ShapeBoxZ(6)) + P7Z + DimZ)

x7 = CSng(0 + Parts.Item(id).OffsetX - CDbl(Parts.Item(id).ShapeBoxX(7)) - P8X)
y7 = CSng(0 - CInt(Parts.Item(id).DimY) - Parts.Item(id).OffsetY - CDbl(Parts.Item(id).ShapeBoxY(7)) - P8Y + DimY)
z7 = CSng(0 + CInt(Parts.Item(id).DimZ) + Parts.Item(id).OffsetZ + CDbl(Parts.Item(id).ShapeBoxZ(7)) + P8Z + DimZ)

these are the formulas to calculate the 8 corners of a box.
- Offset = the offset of the part
- Shapebox = the corner modifier
- Dim = Dimension of the part
- P1-P8 = modifier for mirroring, you can ignore them

then i build the vertexes out of them and store them with the texture coords in a vbo, first coord point value, secound coord texture value

New Vector3(z2, y2, x2),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ + Parts.Item(id).DimX)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY)), 0),
New Vector3(z3, y3, x3),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY)), 0),
New Vector3(z0, y0, x0),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ)), 0),
New Vector3(z1, y1, x1),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ + Parts.Item(id).DimX)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ)), 0),
New Vector3(z5, y5, x5),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ + Parts.Item(id).DimX + Parts.Item(id).DimX)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY)), 0),
New Vector3(z4, y4, x4),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ + Parts.Item(id).DimX)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY)), 0),
New Vector3(z7, y7, x7),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ + Parts.Item(id).DimX)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ)), 0),
New Vector3(z6, y6, x6),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ + Parts.Item(id).DimX + Parts.Item(id).DimX)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ)), 0),
New Vector3(z0, y0, x0),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ)), 0),
New Vector3(z3, y3, x3),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ)), 0),
New Vector3(z7, y7, x7),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ + Parts.Item(id).DimY)), 0),
New Vector3(z4, y4, x4),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ + Parts.Item(id).DimY)), 0),
New Vector3(z2, y2, x2),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ + Parts.Item(id).DimX + Parts.Item(id).DimZ)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ)), 0),
New Vector3(z1, y1, x1),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ + Parts.Item(id).DimX)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ)), 0),
New Vector3(z5, y5, x5),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ + Parts.Item(id).DimX)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ + Parts.Item(id).DimY)), 0),
New Vector3(z6, y6, x6),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ + Parts.Item(id).DimX + Parts.Item(id).DimZ)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ + Parts.Item(id).DimY)), 0),
New Vector3(z1, y1, x1),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ + Parts.Item(id).DimX)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ)), 0),
New Vector3(z0, y0, x0),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ)), 0),
New Vector3(z4, y4, x4),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ + Parts.Item(id).DimY)), 0),
New Vector3(z5, y5, x5),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ + Parts.Item(id).DimX)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ + Parts.Item(id).DimY)), 0),
New Vector3(z3, y3, x3),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ + Parts.Item(id).DimX + Parts.Item(id).DimZ + Parts.Item(id).DimX)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ)), 0),
New Vector3(z2, y2, x2),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ + Parts.Item(id).DimX + Parts.Item(id).DimZ)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ)), 0),
New Vector3(z6, y6, x6),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ + Parts.Item(id).DimX + Parts.Item(id).DimZ)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ + Parts.Item(id).DimY)), 0),
New Vector3(z7, y7, x7),
New Vector3(CSng((1 / PicWidth) * (Parts.Item(id).TextureX + Parts.Item(id).DimZ + Parts.Item(id).DimX + Parts.Item(id).DimZ + Parts.Item(id).DimX)), CSng((1 / PicHeight) * (Parts.Item(id).TextureY + Parts.Item(id).DimZ + Parts.Item(id).DimY)), 0),

GL.GenBuffers(1, Parts.Item(id).VBO)
GL.BindBuffer(BufferTarget.ArrayBuffer, Parts.Item(id).VBO)
GL.BufferData(Of Vector3)(BufferTarget.ArrayBuffer, New IntPtr(vertices.Length * Vector3.SizeInBytes), vertices, BufferUsageHint.StaticDraw)
GL.BindBuffer(BufferTarget.ArrayBuffer, 0)

For drawing i call the vbo and display all 6 sides with the unique color or texture

GL.Enable(EnableCap.Texture2D)
GL.EnableClientState(ArrayCap.VertexArray)
GL.EnableClientState(ArrayCap.TextureCoordArray)
GL.BindBuffer(BufferTarget.ArrayBuffer, Parts.Item(id).VBO)
GL.VertexPointer(3, VertexPointerType.Float, Vector3.SizeInBytes * 2, 0)
GL.TexCoordPointer(3, TexCoordPointerType.Float, Vector3.SizeInBytes * 2, Vector3.SizeInBytes)

GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill)
GL.Color3(My.Settings.colorBox1)
GL.DrawArrays(PrimitiveType.Quads, 0, 4)
GL.Color3(My.Settings.colorBox2)
GL.DrawArrays(PrimitiveType.Quads, 4, 4)
GL.Color3(My.Settings.colorBox3)
GL.DrawArrays(PrimitiveType.Quads, 8, 4)
GL.Color3(My.Settings.colorBox4)
GL.DrawArrays(PrimitiveType.Quads, 12, 4)
GL.Color3(My.Settings.colorBox5)
GL.DrawArrays(PrimitiveType.Quads, 16, 4)
GL.Color3(My.Settings.colorBox6)
GL.DrawArrays(PrimitiveType.Quads, 20, 4)

#80089

Please Log in or Create an account to join the conversation.

  • Posts: 100
  • Thank you received: 4

GolddolphinSKB replied the topic: Request for help with model rendering (Specifically from Manus)

Yes, this is beautiful!
Thanks for your help.

#80092

Please Log in or Create an account to join the conversation.

  • Posts: 100
  • Thank you received: 4

GolddolphinSKB replied the topic: Request for help with model rendering (Specifically from Manus)

Just a quick question, in the line:

x2 = CSng(0 + CInt(Parts.Item(id).DimX) + Parts.Item(id).OffsetX + CDbl(Parts.Item(id).ShapeBoxX(2)) + P3X + DimX)

What is the difference between Parts.Item(id).DimX) and DimX? Because they are both stated.

#80093

Please Log in or Create an account to join the conversation.

 
Latest Forum Posts
 
Latest Blog Posts
 
User Online
 
User Menu