Mountain scene render

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 8f9cb3d107
commit 0e73971db8
  1. BIN
      Body.png
  2. BIN
      C++ProjectTemplate
  3. 19
      Lowpoly_City_Free_Pack.mtl
  4. 82276
      Lowpoly_City_Free_Pack.obj
  5. BIN
      Palette.jpg
  6. BIN
      Palette.png
  7. 38236
      girl OBJ.obj
  8. 29
      main.cpp
  9. 755058
      obj_1.obj

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 308 KiB

Binary file not shown.

@ -0,0 +1,19 @@
# Exported from Wings 3D 2.2.9
newmtl World
Ns 19.999999999999996
d 1.0
illum 2
Kd 1.0 1.0 1.0
Ka 0.0 0.0 0.0
Ks 0.19 0.19 0.19
Ke 0.0 0.0 0.0
newmtl default
Ns 19.999999999999996
d 1.0
illum 2
Kd 0.7898538076923077 0.8133333333333334 0.6940444444444445
Ka 0.0 0.0 0.0
Ks 0.1689853807692308 0.17133333333333334 0.15940444444444446
Ke 0.0 0.0 0.0

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

File diff suppressed because it is too large Load Diff

@ -88,9 +88,20 @@ struct mesh
}
tokens[nTokenCount].pop_back();
tris.push_back({ verts[stoi(tokens[0]) - 1], verts[stoi(tokens[2]) - 1], verts[stoi(tokens[4]) - 1],
uvs[stoi(tokens[1]) - 1], uvs[stoi(tokens[3]) - 1], uvs[stoi(tokens[5]) - 1]});
triangle newtri{ verts[stoi(tokens[0]) - 1], verts[stoi(tokens[3]) - 1], verts[stoi(tokens[6]) - 1],
uvs[stoi(tokens[1]) - 1], uvs[stoi(tokens[4]) - 1], uvs[stoi(tokens[7]) - 1]};
if (newtri.p[0].y>16||newtri.p[1].y>16||newtri.p[2].y>16) {
newtri.col=WHITE;
} else
if (newtri.p[0].y>10||newtri.p[1].y>10||newtri.p[2].y>10) {
newtri.col=DARK_GREEN;
} else
if (newtri.p[0].y>6||newtri.p[1].y>6||newtri.p[2].y>6) {
newtri.col=Pixel(56, 38, 39);
} else {
newtri.col=Pixel(0,100,255);
}
tris.push_back(newtri);
}
}
@ -449,8 +460,8 @@ private:
public:
bool OnUserCreate() override
{
texture = new Decal(new Sprite("dirtblock.png"));
meshCube.LoadFromObjectFile("cube.obj");
//texture = new Decal(new Sprite("Body.png"));
meshCube.LoadFromObjectFile("obj_1.obj");
matProj=Matrix_MakeProjection(90.0f,(float)ScreenHeight() / (float)ScreenWidth(),0.1f,1000.0f);
@ -471,7 +482,7 @@ public:
if (GetKey(olc::LEFT).bHeld) {
vCamera.x-=8*fElapsedTime;
}
vec3d vForward=Vector_Mul(vLookDir,1*fElapsedTime);
vec3d vForward=Vector_Mul(vLookDir,8*fElapsedTime);
if (GetKey(olc::W).bHeld) {
vCamera=Vector_Add(vCamera,vForward);
}
@ -539,7 +550,7 @@ public:
triViewed.uv[0]=triTransformed.uv[0];
triViewed.uv[1]=triTransformed.uv[1];
triViewed.uv[2]=triTransformed.uv[2];
triViewed.col=Pixel(255*dp*dp,255*dp*dp,255*dp*dp);
triViewed.col=Pixel(tri.col.r*dp*dp,tri.col.g*dp*dp,tri.col.b*dp*dp);
int nClippedTriangles = 0;
triangle clipped[2];
@ -641,7 +652,7 @@ public:
// Rasterize triangle
SetDecalStructure(DecalStructure::LIST);
SetDecalMode(DecalMode::NORMAL);
DrawPolygonDecal(texture,{
DrawPolygonDecal(nullptr,{
{t.p[0].x, t.p[0].y},
{t.p[1].x, t.p[1].y},
{t.p[2].x, t.p[2].y}
@ -666,7 +677,7 @@ public:
}
SetDecalMode(DecalMode::NORMAL);
DrawStringDecal({0,0},"Triangles: "+std::to_string(triRenderCount));
DrawStringDecal({0,0},"Triangles: "+std::to_string(triRenderCount),WHITE,{2,2});
return true;

755058
obj_1.obj

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save