News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

File Reader help???

Started by ScottieB, June 20, 2013, 10:32:59 AM

Previous topic - Next topic

ScottieB

Here's the .3ds you can work with this one and I can fix it for the viewer.


Kevin - Still waiting ankchesly for replies.

ScottieB

#16
Check out this screenie it's texturemapping all the way babay!


Mod Edit: replaced 3070K picture with 68K version.

ScottieB

Here's the code for those interested like BlinkOk I think.

BlinkOk


kevin

   
Why are you still posting BMP's ???


Stripped out some of the computational redundancy in the rotation/drawing routines. 

PlayBASIC Code: [Select]
X_Screen_Res = GetScreenWidth()
Y_Screen_Res = GetScreenHeight()

LoadFxImage "ship1uv.bmp",1

ReadFile "ship1.txt",1

Number_Of_Vertexs = ReadValue(1)

Dim X_Vertex#(Number_Of_Vertexs)
Dim Y_Vertex#(Number_Of_Vertexs)
Dim Z_Vertex#(Number_Of_Vertexs)
Dim U_Vertex#(Number_Of_Vertexs)
Dim V_Vertex#(Number_Of_Vertexs)

Dim X_Scale#(Number_Of_Vertexs)
Dim Y_Scale#(Number_Of_Vertexs)
Dim Z_Scale#(Number_Of_Vertexs)

Dim Z_Roll#(Number_Of_Vertexs)

Dim X2D_Vertex#(Number_Of_Vertexs)
Dim Y2D_Vertex#(Number_Of_Vertexs)

dim Values#(5)
dim Values(5)

TextureWidth=GetImageWidth(1)
TextureHeight=GetImageHeight(1)
For Vertexs = 1 To Number_Of_Vertexs
String$ = ReadString$(1)
Count=SplitToArray(String$," ",Values#())
if Count=5
X_Vertex#(Vertexs)=Values#(0)
Y_Vertex#(Vertexs)=Values#(1)
Z_Vertex#(Vertexs)=Values#(2)
U_Vertex#(Vertexs)=Values#(3)*TextureWidth
V_Vertex#(Vertexs)=Values#(4)*TextureHeight
else
#print "Error reading Vertex #"+str$(Vertexs)
endif
next


Number_Of_Tris = ReadValue(1)

Dim P1(Number_Of_Tris)
Dim P2(Number_Of_Tris)
Dim P3(Number_Of_Tris)

For Tris = 1 To Number_Of_Tris
String$ =ReadString$(1)
Count =SplitToArray(String$," ",Values())
p1(tris) =Values(0)+1
p2(tris) =Values(1)+1
p3(tris) =Values(2)+1
next

CloseFile 1


For Vertex = 1 To Number_Of_Vertexs
X_Scale#(Vertex) = X_Vertex#(Vertex) * 10
Y_Scale#(Vertex) = Y_Vertex#(Vertex) * 10
Z_Scale#(Vertex) = Z_Vertex#(Vertex) * 10
Next Vertex


createcamera 1
cameracls 1,off

Do
Cls Rgb(0,0,255)

capturetoscene
clsscene

Gosub Rotation
Gosub Draw_Tris

drawcamera 1
Sync

Loop

Rotation:

// spin object
Yaw# = wrapangle(yaw#+1)
Pitch# = WrapAngle(pitch# + 0.3)
Roll# = 0; wrapangle(roll# + 1)

// none of this is needed, The RotateVertex commands do a much better job at this.

CosYaw#=Cos(Yaw#)
SinYaw#=Sin(Yaw#)

CosPitch#=Cos(Pitch#)
SinPitch#=Sin(Pitch#)

CosRoll#=Cos(Roll#)
SinRoll#=Sin(Roll#)

ScreenCenterX=(X_Screen_Res / 2)
ScreenCenterY=(Y_Screen_Res / 2)

For Vertex = 1 To Number_Of_Vertexs

X_Scale#=X_Scale#(Vertex)
Y_Yaw# = Y_Scale#(Vertex)
Z_Scale#=Z_Scale#(Vertex)

X_Yaw# = X_Scale# * CosYaw# - Z_Scale# * SinYaw#
Z_Yaw# = X_Scale# * SinYaw# + Z_Scale# * CosYaw#

X_Pitch# = X_Yaw#
Y_Pitch# = Y_Yaw# * CosPitch# + Z_Yaw# * SinPitch#
Z_Pitch# = (-Y_Yaw#) * SinPitch# + Z_Yaw# * CosPitch#

X_Roll# = X_Pitch# * CosRoll# + Y_Pitch# * SinRoll#
Y_Roll# = (-X_Pitch#) * SinRoll# + Y_Pitch# * CosRoll#

// final depth of the object in front
Z_Roll# = 200-Z_Pitch#
Z_Roll#(Vertex)=Z_Roll#

// project to convert 3D points to 2D space
X2D_Vertex#(Vertex) = (X_Roll# * 256 / Z_Roll#) + ScreenCenterX
Y2D_Vertex#(Vertex) = (Y_Roll# * 256 / Z_Roll#) + ScreenCenterY


Next Vertex


Return

Draw_Tris:

Filter=8*LeftMouseButton()

For Tris = 1 To Number_Of_Tris
p1=P1(Tris)
p2=P2(Tris)
p3=P3(Tris)

x1#=X2D_Vertex#(P1)
y1#=Y2D_Vertex#(P1)
Login required to view complete source code


ScottieB

Thank you!  and I'll start converting .bmp's
Though that's what the 3d object converter spits out.

Kevin - How do you do the model outlines?  Looks like there quads.  How do you get them lines from tris?

ScottieB

Kevin - Do you now think that I can add 3D Textured models to the I-Scream Engine?  (Atar's Battlezone Clone)
If so, can you help me out if I have problems?

Will the code we have be able to integrate with the game?
Is the backface removal always faceing forward?  That would be nice.
The is more that rotation going.  There's translation (Moveing)
The viewing frustrum should remove any polygons not in sight.

I was looking for a way to continue without quitting.  I think this may work.
Plus it's one hell of an upgrade.

What's your thoughts?

kevin


QuoteHow do you do the model outlines?  Looks like there quads.  How do you get them lines from tris?

  Whatever exported the TANK  model used triangles.   I just assumed that each pair therefore was a quad.   Wrote a little function  CompressToQuads(index) to run through and convert the triangle pairs to quads.   


QuoteWill the code we have be able to integrate with the game?

   Dunno..  It'd probably need a little tweaking (z clipping), but I can't think of a reason why it couldn't be made to work.   
 


QuoteIs the backface removal always faceing forward?  That would be nice.

   Assuming the faces are defined in clock wise order the translated polygon (in screen space) should be visible.



QuoteThe is more that rotation going.  There's translation (Moveing)
The viewing frustrum should remove any polygons not in sight.

    The examples here  assume the camera is in a fixed location.   The object will need a position in space as will the camera.  So the points needs to be rotated and localized to the camera.

    There's conceptual exclusion volumes around the camera to help remove as many objects that will be outside of the screen as possible.  Depending upon the object count,  then a quick squared distanced check to find if they're in the same sphere would do. Then  grab Z deltas and anything that's negative is behind the camera.    You can cull objects that in front of camera when the projected volume is outside the viewport.   This works pretty well for objects that have evenly distributed vertex, but not so well for rectangular objects.   A bounding box would do for those.     



ScottieB

Kevin - Please hear me out.

I've build the I-Scream Engine from the ground up.
We've finally made a model importer.
I would like to see this in action.  I tried and first I got models that flew around and did not follow the timeing.
Second try I got screwy graphics that did'nt make sence.

I would really like to see how this can be done.  You can use just the tank model to show how it's done.
I erally would appreciated this greatly because I've been working 8 months now and I don't wanna change programs.
I do that too much.  I mve on from project to project without finishing one.  Very bad habit.
I could easily do thiis in another language like darkbasic pro but I designed this for playbasic as I been useing it faithfully for 3-5 years now.
I build this program to learn the math behind the game.  Intro to 3d programming for beginners. I'm not the most advanced programmer and
where where at now I sure could use some help.  If you do it once.  I'll know how to do it for everything else I add to the world and that would be
a big help.  So I hope you take me seriously that I wish you could help me just a bit more and then I'll continue from there.  I don't wanna bug you all the time but once we have the tanks going everything else is just a clone sort of at least for the 3d models with texturemapping.

Thank you very much.

ScottieB

ScottieB

Honestly,  It's my biggest lenght in code and also my least buggy/clichy programs of all.
That alone seems like it is worth the effort to make better.  I would think.

ScottieB

Kevin - Belay my last.
I think I got it now.
Seems to be working great this morning.
Though I still got stuff to iron out.

Thanks anyways.

Peace!
ScottieB