generated from sigonasr2/CPlusPlusProjectTemplate
Mountain scene render
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
8f9cb3d107
commit
0e73971db8
BIN
Body.png
BIN
Body.png
Binary file not shown.
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 308 KiB |
Binary file not shown.
19
Lowpoly_City_Free_Pack.mtl
Normal file
19
Lowpoly_City_Free_Pack.mtl
Normal file
@ -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
|
||||||
|
|
82276
Lowpoly_City_Free_Pack.obj
Normal file
82276
Lowpoly_City_Free_Pack.obj
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Palette.jpg
Normal file
BIN
Palette.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 87 KiB |
BIN
Palette.png
Normal file
BIN
Palette.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 40 KiB |
38236
girl OBJ.obj
Normal file
38236
girl OBJ.obj
Normal file
File diff suppressed because it is too large
Load Diff
29
main.cpp
29
main.cpp
@ -88,9 +88,20 @@ struct mesh
|
|||||||
}
|
}
|
||||||
|
|
||||||
tokens[nTokenCount].pop_back();
|
tokens[nTokenCount].pop_back();
|
||||||
|
triangle newtri{ verts[stoi(tokens[0]) - 1], verts[stoi(tokens[3]) - 1], verts[stoi(tokens[6]) - 1],
|
||||||
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[4]) - 1], uvs[stoi(tokens[7]) - 1]};
|
||||||
uvs[stoi(tokens[1]) - 1], uvs[stoi(tokens[3]) - 1], uvs[stoi(tokens[5]) - 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:
|
public:
|
||||||
bool OnUserCreate() override
|
bool OnUserCreate() override
|
||||||
{
|
{
|
||||||
texture = new Decal(new Sprite("dirtblock.png"));
|
//texture = new Decal(new Sprite("Body.png"));
|
||||||
meshCube.LoadFromObjectFile("cube.obj");
|
meshCube.LoadFromObjectFile("obj_1.obj");
|
||||||
|
|
||||||
matProj=Matrix_MakeProjection(90.0f,(float)ScreenHeight() / (float)ScreenWidth(),0.1f,1000.0f);
|
matProj=Matrix_MakeProjection(90.0f,(float)ScreenHeight() / (float)ScreenWidth(),0.1f,1000.0f);
|
||||||
|
|
||||||
@ -471,7 +482,7 @@ public:
|
|||||||
if (GetKey(olc::LEFT).bHeld) {
|
if (GetKey(olc::LEFT).bHeld) {
|
||||||
vCamera.x-=8*fElapsedTime;
|
vCamera.x-=8*fElapsedTime;
|
||||||
}
|
}
|
||||||
vec3d vForward=Vector_Mul(vLookDir,1*fElapsedTime);
|
vec3d vForward=Vector_Mul(vLookDir,8*fElapsedTime);
|
||||||
if (GetKey(olc::W).bHeld) {
|
if (GetKey(olc::W).bHeld) {
|
||||||
vCamera=Vector_Add(vCamera,vForward);
|
vCamera=Vector_Add(vCamera,vForward);
|
||||||
}
|
}
|
||||||
@ -539,7 +550,7 @@ public:
|
|||||||
triViewed.uv[0]=triTransformed.uv[0];
|
triViewed.uv[0]=triTransformed.uv[0];
|
||||||
triViewed.uv[1]=triTransformed.uv[1];
|
triViewed.uv[1]=triTransformed.uv[1];
|
||||||
triViewed.uv[2]=triTransformed.uv[2];
|
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;
|
int nClippedTriangles = 0;
|
||||||
triangle clipped[2];
|
triangle clipped[2];
|
||||||
@ -641,7 +652,7 @@ public:
|
|||||||
// Rasterize triangle
|
// Rasterize triangle
|
||||||
SetDecalStructure(DecalStructure::LIST);
|
SetDecalStructure(DecalStructure::LIST);
|
||||||
SetDecalMode(DecalMode::NORMAL);
|
SetDecalMode(DecalMode::NORMAL);
|
||||||
DrawPolygonDecal(texture,{
|
DrawPolygonDecal(nullptr,{
|
||||||
{t.p[0].x, t.p[0].y},
|
{t.p[0].x, t.p[0].y},
|
||||||
{t.p[1].x, t.p[1].y},
|
{t.p[1].x, t.p[1].y},
|
||||||
{t.p[2].x, t.p[2].y}
|
{t.p[2].x, t.p[2].y}
|
||||||
@ -666,7 +677,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
SetDecalMode(DecalMode::NORMAL);
|
SetDecalMode(DecalMode::NORMAL);
|
||||||
DrawStringDecal({0,0},"Triangles: "+std::to_string(triRenderCount));
|
DrawStringDecal({0,0},"Triangles: "+std::to_string(triRenderCount),WHITE,{2,2});
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user