Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
arata-nvm committed Sep 5, 2021
2 parents a9b5c5a + c229802 commit f7729eb
Show file tree
Hide file tree
Showing 28 changed files with 4,207 additions and 81 deletions.
19 changes: 19 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/go/.devcontainer/base.Dockerfile

# [Choice] Go version: 1, 1.16, 1.15
ARG VARIANT="1.16"
FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT}

# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment the next line to use go get to install anything else you need
# RUN go get -x <your-dependency-or-tool>

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
37 changes: 37 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/go
{
"name": "Go",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Update the VARIANT arg to pick a version of Go: 1, 1.16, 1.15
"VARIANT": "1",
// Options
"NODE_VERSION": "none"
}
},
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],

// Set *default* container specific settings.json values on container create.
"settings": {
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.gopath": "/go",
"go.goroot": "/usr/local/go"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"golang.Go"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "go version",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
out*
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/poly.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.PHONY: build
build:
go build -o poly ./examples

.PHONY: run
run:
go run ./examples
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ A simple 3D renderer written in Go.

## screenshot

![](screenshots/example.png)
![](screenshots/bunny.png)
52 changes: 36 additions & 16 deletions examples/box3.obj
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
v 1.000000 1.000000 -1.000000
v 1.000000 -1.000000 -1.000000
v 1.000000 1.000000 1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 1.000000 -1.000000
v -1.000000 -1.000000 -1.000000
v -1.000000 1.000000 1.000000
v 1.000000 1.000000 1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
f 5 3 1
f 3 8 4
f 7 6 8
f 2 8 6
f 1 4 2
f 5 2 6
f 5 7 3
f 3 7 8
f 7 5 6
f 2 4 8
f 1 3 4
f 5 1 2
v -1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 -1.000000
vt 0.875000 0.500000
vt 0.625000 0.750000
vt 0.625000 0.500000
vt 0.375000 1.000000
vt 0.375000 0.750000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.375000 0.000000
vt 0.375000 0.500000
vt 0.125000 0.750000
vt 0.125000 0.500000
vt 0.625000 0.250000
vt 0.875000 0.750000
vt 0.625000 1.000000
vn 0.0000 1.0000 0.0000
vn 0.0000 -0.0000 1.0000
vn -1.0000 -0.0000 0.0000
vn 0.0000 -1.0000 -0.0000
vn 1.0000 -0.0000 0.0000
vn 0.0000 0.0000 -1.0000
f 2/1/1 4/2/1 1/3/1
f 4/2/2 6/4/2 5/5/2
f 3/6/3 7/7/3 6/8/3
f 8/9/4 6/10/4 7/11/4
f 1/3/5 5/5/5 8/9/5
f 2/12/6 8/9/6 7/7/6
f 2/1/1 3/13/1 4/2/1
f 4/2/2 3/14/2 6/4/2
f 3/6/3 2/12/3 7/7/3
f 8/9/4 5/5/4 6/10/4
f 1/3/5 4/2/5 5/5/5
f 2/12/6 1/3/6 8/9/6
21 changes: 18 additions & 3 deletions examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@ package main

import (
. "github.com/arata-nvm/poly/poly"
. "github.com/arata-nvm/poly/vecmath"
)

func main() {
d := NewDevice(256, 256)
size := 1024
d := NewDevice(size, size)
d.ClearColorBuffer(BLACK)

m := LoadObj("examples/box3.obj")
eye := NewVector3(-1, 0, 1)
target := NewVector3(0, 0.1, 0)
c := NewCamera(eye, target, UnitY())
d.SetCamera(c)

d.DrawMesh(m, WHITE)
d.Perspective(10, 1.0, 1, 10)

cl := NewColor(0.5, 1, 0.6, 1)
light := NewVector3(1, 0, 1)
shader := NewPhongShader(light, eye, cl, 64)
d.SetShader(shader)

bunny := LoadPly("examples/bunny/reconstruction/bun_zipper.ply")
bunny.CalcNormal()
bunny.SmoothNormals()
d.DrawMesh(bunny)

Save("out.png", d.Image())
}
17 changes: 17 additions & 0 deletions examples/plane.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Blender v2.82 (sub 7) OBJ File: ''
# www.blender.org
mtllib plane.mtl
o Plane
v -1.000000 0.000000 1.000000
v 1.000000 0.000000 1.000000
v -1.000000 0.000000 -1.000000
v 1.000000 0.000000 -1.000000
vt 1.000000 0.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vt 1.000000 1.000000
vn 0.0000 1.0000 0.0000
usemtl None
s off
f 2/1/1 3/2/1 1/3/1
f 2/1/1 4/4/1 3/2/1
Loading

0 comments on commit f7729eb

Please sign in to comment.