I use mesh loading from obj
files using blender for modeling.
I have one cube also in physics world it is the cube shape.
And my physics works fine.
Now i need to detect which edge is on top (dice).
This is source project link
Logic is : Vertex stay same – state is in viewModel/projection
I need find trixk to catch and figure which face is touchig or which face is on top in current situation.
Here some most interest part of code :
<code> this.getTransformationMatrix = (pos) => {
const now = Date.now();
const deltaTime = (now - this.lastFrameMS) / this.mainCameraParams.responseCoef;
this.lastFrameMS = now;
// const this.viewMatrix = mat4.identity()
const camera = this.cameras[this.mainCameraParams.type];
this.viewMatrix = camera.update(deltaTime, this.inputHandler());
mat4.translate(this.viewMatrix, vec3.fromValues(pos.x, pos.y, pos.z), this.viewMatrix);
mat4.rotate(
this.viewMatrix,
vec3.fromValues(this.rotation.axis.x, this.rotation.axis.y, this.rotation.axis.z),
degToRad(this.rotation.angle), this.viewMatrix)
// console.info('angle: ', this.rotation.angle, ' axis ' , this.rotation.axis.x, ' , ', this.rotation.axis.y, ' , ', this.rotation.axis.z)
mat4.multiply(this.projectionMatrix, this.viewMatrix, this.modelViewProjectionMatrix);
return this.modelViewProjectionMatrix;
}
</code>
<code> this.getTransformationMatrix = (pos) => {
const now = Date.now();
const deltaTime = (now - this.lastFrameMS) / this.mainCameraParams.responseCoef;
this.lastFrameMS = now;
// const this.viewMatrix = mat4.identity()
const camera = this.cameras[this.mainCameraParams.type];
this.viewMatrix = camera.update(deltaTime, this.inputHandler());
mat4.translate(this.viewMatrix, vec3.fromValues(pos.x, pos.y, pos.z), this.viewMatrix);
mat4.rotate(
this.viewMatrix,
vec3.fromValues(this.rotation.axis.x, this.rotation.axis.y, this.rotation.axis.z),
degToRad(this.rotation.angle), this.viewMatrix)
// console.info('angle: ', this.rotation.angle, ' axis ' , this.rotation.axis.x, ' , ', this.rotation.axis.y, ' , ', this.rotation.axis.z)
mat4.multiply(this.projectionMatrix, this.viewMatrix, this.modelViewProjectionMatrix);
return this.modelViewProjectionMatrix;
}
</code>
this.getTransformationMatrix = (pos) => {
const now = Date.now();
const deltaTime = (now - this.lastFrameMS) / this.mainCameraParams.responseCoef;
this.lastFrameMS = now;
// const this.viewMatrix = mat4.identity()
const camera = this.cameras[this.mainCameraParams.type];
this.viewMatrix = camera.update(deltaTime, this.inputHandler());
mat4.translate(this.viewMatrix, vec3.fromValues(pos.x, pos.y, pos.z), this.viewMatrix);
mat4.rotate(
this.viewMatrix,
vec3.fromValues(this.rotation.axis.x, this.rotation.axis.y, this.rotation.axis.z),
degToRad(this.rotation.angle), this.viewMatrix)
// console.info('angle: ', this.rotation.angle, ' axis ' , this.rotation.axis.x, ' , ', this.rotation.axis.y, ' , ', this.rotation.axis.z)
mat4.multiply(this.projectionMatrix, this.viewMatrix, this.modelViewProjectionMatrix);
return this.modelViewProjectionMatrix;
}
I dont now who can help me info from quat to find top side face…
Any suggestion.